]>
git.immae.eu Git - github/wallabag/wallabag.git/blob - inc/3rdparty/libraries/MOBIClass/Prc.php
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()
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));
37 $this->get("numberRecords")->set(sizeof($records));
40 foreach($records as $record){
41 $offset = new FileInt();
42 $attr = new FileByte();
43 $uniqueID = new FileTri($i);
45 $this->elements
["recordList"]->add("Rec".$i, new FileElement(array(
51 $this->elements
["records"]->add("Rec".$i, $record);
55 $this->updateOffsets($records);
58 public function getByteLength(){
59 throw new Exception("Test");
62 public function updateOffsets($records){
63 $base = $this->offsetToEntry("records");
67 foreach($records as $record){
68 $el = $this->elements
["recordList"]->get("Rec".$i);
70 $local = $this->elements
["records"]->offsetToEntry("Rec".$i);
72 $el->get("offset")->set($base+
$local);
78 public function save($file){
79 $handle = fopen($file, "w");
80 fwrite($handle, $this->serialize());
84 public function output(){
85 echo $this->serialize();
88 public function __toString(){
89 $output = "Prc (".$this->getByteLength()." bytes): {\n";
90 foreach($this->elements
as $key=>$value){
91 $output .= "\t".$key.": ".$value."\n";