aboutsummaryrefslogtreecommitdiffhomepage
path: root/inc/3rdparty/libraries/MOBIClass/Prc.php
diff options
context:
space:
mode:
Diffstat (limited to 'inc/3rdparty/libraries/MOBIClass/Prc.php')
-rw-r--r--inc/3rdparty/libraries/MOBIClass/Prc.php97
1 files changed, 0 insertions, 97 deletions
diff --git a/inc/3rdparty/libraries/MOBIClass/Prc.php b/inc/3rdparty/libraries/MOBIClass/Prc.php
deleted file mode 100644
index c40b5805..00000000
--- a/inc/3rdparty/libraries/MOBIClass/Prc.php
+++ /dev/null
@@ -1,97 +0,0 @@
1<?php
2
3/**
4 * Description of Prc
5 *
6 * @author Sander
7 */
8class 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?>