diff options
author | Thomas Citharel <tcit@tcit.fr> | 2015-02-18 19:17:31 +0100 |
---|---|---|
committer | Thomas Citharel <tcit@tcit.fr> | 2015-02-18 19:17:31 +0100 |
commit | 4b1fa4c2febc7abbc6da3d65e4e760949a55843c (patch) | |
tree | a93ec906dbb03ec70e9cdc5dc876392c6d758e97 /inc/3rdparty/libraries/MOBIClass/Prc.php | |
parent | 364953ede585b75fb29dc94b1c5f853053eaed0b (diff) | |
parent | df89c6f71adebfdb754ec3eb2fd775d8efbdb280 (diff) | |
download | wallabag-1.9.tar.gz wallabag-1.9.tar.zst wallabag-1.9.zip |
Merge pull request #1081 from wallabag/dev1.9
Version 1.9.0
Diffstat (limited to 'inc/3rdparty/libraries/MOBIClass/Prc.php')
-rw-r--r-- | inc/3rdparty/libraries/MOBIClass/Prc.php | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/inc/3rdparty/libraries/MOBIClass/Prc.php b/inc/3rdparty/libraries/MOBIClass/Prc.php new file mode 100644 index 00000000..c40b5805 --- /dev/null +++ b/inc/3rdparty/libraries/MOBIClass/Prc.php | |||
@@ -0,0 +1,97 @@ | |||
1 | <?php | ||
2 | |||
3 | /** | ||
4 | * Description of Prc | ||
5 | * | ||
6 | * @author Sander | ||
7 | */ | ||
8 | class Prc extends FileElement { | ||
9 | public function __construct($settings, $records){ | ||
10 | parent::__construct(array( | ||
11 | "title"=>new FileString(32), | ||
12 | "attributes"=>new FileShort(), | ||
13 | "version"=>new FileShort(), | ||
14 | "creationTime"=>new FileDate(), | ||
15 | "modificationTime"=>new FileDate(), | ||
16 | "backupTime"=>new FileDate(), | ||
17 | "modificationNumber"=>new FileInt(), | ||
18 | "appInfoID"=>new FileInt(), | ||
19 | "sortInfoID"=>new FileInt(), | ||
20 | "prcType"=>new FileString(4), | ||
21 | "creator"=>new FileString(4), | ||
22 | "uniqueIDSeed"=>new FileInt(), | ||
23 | "nextRecordListID"=>new FileInt(), | ||
24 | "numberRecords"=>new FileShort(), | ||
25 | "recordList"=>new FileElement(), | ||
26 | "filler"=>new FileShort(), | ||
27 | "records"=>new FileElement() | ||
28 | )); | ||
29 | |||
30 | //Set values from the info block | ||
31 | foreach($this->elements as $name => $val){ | ||
32 | if($settings->exists($name)){ | ||
33 | $this->get($name)->set($settings->get($name)); | ||
34 | } | ||
35 | } | ||
36 | |||
37 | $this->get("numberRecords")->set(sizeof($records)); | ||
38 | |||
39 | $i = 0; | ||
40 | foreach($records as $record){ | ||
41 | $offset = new FileInt(); | ||
42 | $attr = new FileByte(); | ||
43 | $uniqueID = new FileTri($i); | ||
44 | |||
45 | $this->elements["recordList"]->add("Rec".$i, new FileElement(array( | ||
46 | "offset"=>$offset, | ||
47 | "attribute"=>$attr, | ||
48 | "uniqueID"=>$uniqueID | ||
49 | ))); | ||
50 | |||
51 | $this->elements["records"]->add("Rec".$i, $record); | ||
52 | $i++; | ||
53 | } | ||
54 | |||
55 | $this->updateOffsets($records); | ||
56 | } | ||
57 | |||
58 | public function getByteLength(){ | ||
59 | throw new Exception("Test"); | ||
60 | } | ||
61 | |||
62 | public function updateOffsets($records){ | ||
63 | $base = $this->offsetToEntry("records"); | ||
64 | |||
65 | $i = 0; | ||
66 | |||
67 | foreach($records as $record){ | ||
68 | $el = $this->elements["recordList"]->get("Rec".$i); | ||
69 | |||
70 | $local = $this->elements["records"]->offsetToEntry("Rec".$i); | ||
71 | |||
72 | $el->get("offset")->set($base+$local); | ||
73 | |||
74 | $i++; | ||
75 | } | ||
76 | } | ||
77 | |||
78 | public function save($file){ | ||
79 | $handle = fopen($file, "w"); | ||
80 | fwrite($handle, $this->serialize()); | ||
81 | fclose($handle); | ||
82 | } | ||
83 | |||
84 | public function output(){ | ||
85 | echo $this->serialize(); | ||
86 | } | ||
87 | |||
88 | public function __toString(){ | ||
89 | $output = "Prc (".$this->getByteLength()." bytes): {\n"; | ||
90 | foreach($this->elements as $key=>$value){ | ||
91 | $output .= "\t".$key.": ".$value."\n"; | ||
92 | } | ||
93 | $output .= "}"; | ||
94 | return $output; | ||
95 | } | ||
96 | } | ||
97 | ?> | ||