]>
Commit | Line | Data |
---|---|---|
4188f38a | 1 | <?php |
2 | ||
3 | /** | |
4 | * Description of Settings | |
5 | * | |
6 | * @author Sander | |
7 | */ | |
8 | class Settings { | |
9 | /** | |
10 | * Values of the settings | |
11 | * @var array | |
12 | */ | |
13 | public $values; | |
14 | ||
15 | /** | |
16 | * Construct a Settings object with the default settings. If necessary, | |
17 | * those settings can be extended with additional settings | |
18 | * @param array $additionalSettings Additional settings to add (should | |
19 | * be added with a key/value pair format. | |
20 | */ | |
21 | public function __construct($additionalSettings = array()) { | |
fb9df0c2 | 22 | // Most values shouldn't be changed (the result will be an invalid file) |
4188f38a | 23 | $this->values = array( |
24 | "attributes"=>0, | |
25 | "version"=>0, | |
26 | "creationTime"=>time()+94694400, | |
27 | "modificationTime"=>time()+94694400, | |
28 | "backupTime"=>0, | |
29 | "modificationNumber"=>0, | |
30 | "appInfoID"=>0, | |
31 | "sortInfoID"=>0, | |
32 | "prcType"=>"BOOK", | |
33 | "creator"=>"MOBI", | |
34 | "uniqueIDSeed"=>rand(), | |
35 | "nextRecordListID"=>0, | |
36 | "recordAttributes"=>0, | |
37 | "compression"=>NO_COMPRESSION, | |
38 | "recordSize"=>RECORD_SIZE, | |
39 | "encryptionType"=>NO_ENCRYPTION, | |
40 | "mobiIdentifier"=>"MOBI", | |
41 | "mobiHeaderLength"=>0xe8, | |
42 | "mobiType"=>MOBIPOCKET_BOOK, | |
43 | "textEncoding"=>UTF8, | |
44 | "uniqueID"=>rand(), | |
45 | "fileVersion"=>6, | |
46 | "locale"=>0x09, | |
47 | "inputLanguage"=>0, | |
48 | "outputLanguage"=>0, | |
49 | "minimumVersion"=>6, | |
50 | "huffmanRecordOffset"=>0, | |
51 | "huffmanRecordCount"=>0, | |
fb9df0c2 | 52 | "exthFlags"=>0x40, |
4188f38a | 53 | "drmOffset"=>0xFFFFFFFF, |
fb9df0c2 | 54 | "drmCount"=>0, |
4188f38a | 55 | "drmSize"=>0, |
56 | "drmFlags"=>0, | |
57 | "extraDataFlags"=>0, | |
58 | "exthIdentifier"=>"EXTH", | |
fb9df0c2 | 59 | // These can be changed without any risk |
4188f38a | 60 | "title"=>"Unknown title", |
61 | "author"=>"Unknown author", | |
62 | "subject"=>"Unknown subject" | |
63 | ); | |
64 | ||
65 | foreach($additionalSettings as $key=>$value){ | |
66 | $this->values[$key] = $value; | |
67 | } | |
68 | } | |
69 | ||
70 | /** | |
71 | * Get a value from the settings | |
72 | * @param string $key Key of the setting | |
73 | * @return mixed The value of the setting | |
74 | */ | |
75 | public function get($key){ | |
76 | return $this->values[$key]; | |
77 | } | |
78 | ||
79 | /** | |
80 | * Checks if a value is set | |
81 | * @param string $key Key of the setting | |
82 | * @return bool True if the value exists | |
83 | */ | |
84 | public function exists($key){ | |
85 | return isset($this->values[$key]); | |
86 | } | |
87 | ||
88 | public function __toString() { | |
89 | $out = "Settings: {\n"; | |
90 | foreach($this->values as $key=>$value){ | |
91 | $out .= "\t".$key.": ".$value."\n"; | |
92 | } | |
93 | $out .= "}"; | |
94 | return $out; | |
95 | } | |
96 | } | |
97 | ?> |