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