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