diff options
author | Thomas Citharel <tcit@tcit.fr> | 2014-12-14 00:16:39 +0100 |
---|---|---|
committer | Thomas Citharel <tcit@tcit.fr> | 2014-12-14 00:16:39 +0100 |
commit | 1256e4c645c86f4165d052bf8116b957b373b837 (patch) | |
tree | 3cc3bd960df403a6e0645afcd9e4f5bbb68bfc0e /inc/3rdparty/libraries/MOBIClass/Settings.php | |
parent | 9c55ed0923273da886497cb62302a79622e34a74 (diff) | |
parent | dc69d3e8d895c87f9d26c2d1309e40d6090d4c8d (diff) | |
download | wallabag-1256e4c645c86f4165d052bf8116b957b373b837.tar.gz wallabag-1256e4c645c86f4165d052bf8116b957b373b837.tar.zst wallabag-1256e4c645c86f4165d052bf8116b957b373b837.zip |
Merge branch 'tcitworld-ebook' into dev
Diffstat (limited to 'inc/3rdparty/libraries/MOBIClass/Settings.php')
-rw-r--r-- | inc/3rdparty/libraries/MOBIClass/Settings.php | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/inc/3rdparty/libraries/MOBIClass/Settings.php b/inc/3rdparty/libraries/MOBIClass/Settings.php new file mode 100644 index 00000000..ddcf2054 --- /dev/null +++ b/inc/3rdparty/libraries/MOBIClass/Settings.php | |||
@@ -0,0 +1,97 @@ | |||
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()) { | ||
22 | // Most values shouldn't be changed (the result will be an invalid file) | ||
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, | ||
52 | "exthFlags"=>0x40, | ||
53 | "drmOffset"=>0xFFFFFFFF, | ||
54 | "drmCount"=>0, | ||
55 | "drmSize"=>0, | ||
56 | "drmFlags"=>0, | ||
57 | "extraDataFlags"=>0, | ||
58 | "exthIdentifier"=>"EXTH", | ||
59 | // These can be changed without any risk | ||
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 | ?> | ||