Changing comments layout preparing for generated documentation with Phpdocumentor
[lhc/web/wiklou.git] / includes / HistoryBlob.php
1 <?php
2 /**
3 *
4 */
5
6 /**
7 * Pure virtual parent
8 */
9 class HistoryBlob
10 {
11 function setMeta() {}
12 function getMeta() {}
13 function addItem() {}
14 function getItem() {}
15 }
16
17 /**
18 * The real object
19 */
20 class ConcatenatedGzipHistoryBlob
21 {
22 /* private */ var $mVersion = 0, $mCompressed = false, $mItems = array();
23
24 function HistoryBlob() {
25 if ( !function_exists( 'gzdeflate' ) ) {
26 die( "Need zlib support to read or write this kind of history object (ConcatenatedGzipHistoryBlob)\n" );
27 }
28 }
29
30 function setMeta( $metaData ) {
31 $this->uncompress();
32 $this->mItems['meta'] = $metaData;
33 }
34
35 function getMeta() {
36 $this->uncompress();
37 return $this->mItems['meta'];
38 }
39
40 function addItem( $text ) {
41 $this->uncompress();
42 $this->mItems[md5($text)] = $text;
43 }
44
45 function getItem( $hash ) {
46 $this->compress();
47 return $this->mItems[$hash];
48 }
49
50 function compress() {
51 if ( !$this->mCompressed ) {
52 $this->mItems = gzdeflate( serialize( $this->mItems ) );
53 $this->mCompressed = true;
54 }
55 }
56
57 function uncompress() {
58 if ( $this->mCompressed ) {
59 $this->mItems = unserialize( gzinflate( $this->mItems ) );
60 }
61 }
62
63 function __sleep() {
64 compress();
65 }
66
67 function __wakeup() {
68 uncompress();
69 }
70 }
71 ?>