@@ -64,6 +64,9 @@ discard block |
||
64 | 64 | $_SERVER['REDIRECT_STATUS'] = 404; |
65 | 65 | } |
66 | 66 | |
67 | +/** |
|
68 | + * @param string $name |
|
69 | + */ |
|
67 | 70 | function getURLParam($name, $default = NULL) |
68 | 71 | { |
69 | 72 | if (!empty ($_GET) && isset($_GET[$name]) && $_GET[$name] != '') { |
@@ -104,6 +107,11 @@ discard block |
||
104 | 107 | return $url . '?v=' . VERSION; |
105 | 108 | } |
106 | 109 | |
110 | +/** |
|
111 | + * @param string $xml |
|
112 | + * |
|
113 | + * @return string |
|
114 | + */ |
|
107 | 115 | function xml2xhtml($xml) |
108 | 116 | { |
109 | 117 | return preg_replace_callback('#<(\w+)([^>]*)\s*/>#s', function($m) { |
@@ -326,6 +334,9 @@ discard block |
||
326 | 334 | return $phrase; |
327 | 335 | } |
328 | 336 | |
337 | +/** |
|
338 | + * @param string $paramName |
|
339 | + */ |
|
329 | 340 | function addURLParameter($urlParams, $paramName, $paramValue) |
330 | 341 | { |
331 | 342 | if (empty ($urlParams)) { |
@@ -149,7 +149,9 @@ discard block |
||
149 | 149 | $errors = libxml_get_errors(); |
150 | 150 | |
151 | 151 | foreach ($errors as $error) { |
152 | - if ($error->code == 801) return false; |
|
152 | + if ($error->code == 801) { |
|
153 | + return false; |
|
154 | + } |
|
153 | 155 | } |
154 | 156 | return true; |
155 | 157 | } |
@@ -175,7 +177,9 @@ discard block |
||
175 | 177 | } |
176 | 178 | */ |
177 | 179 | |
178 | - if (!are_libxml_errors_ok ()) $output = 'HTML code not valid.'; |
|
180 | + if (!are_libxml_errors_ok ()) { |
|
181 | + $output = 'HTML code not valid.'; |
|
182 | + } |
|
179 | 183 | |
180 | 184 | libxml_use_internal_errors(false); |
181 | 185 | return $output; |
@@ -235,7 +239,9 @@ discard block |
||
235 | 239 | |
236 | 240 | // set default to 1 for any without q factor |
237 | 241 | foreach ($langs as $lang => $val) { |
238 | - if ($val === '') $langs[$lang] = 1; |
|
242 | + if ($val === '') { |
|
243 | + $langs[$lang] = 1; |
|
244 | + } |
|
239 | 245 | } |
240 | 246 | |
241 | 247 | // sort list based on value |
@@ -257,8 +263,7 @@ discard block |
||
257 | 263 | $lang = 'en'; |
258 | 264 | if (!empty($config['cops_language'])) { |
259 | 265 | $lang = $config['cops_language']; |
260 | - } |
|
261 | - elseif (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { |
|
266 | + } elseif (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { |
|
262 | 267 | $langs = getAcceptLanguages(); |
263 | 268 | } |
264 | 269 | //echo var_dump($langs); |
@@ -284,12 +289,15 @@ discard block |
||
284 | 289 | function localize($phrase, $count=-1, $reset=false) |
285 | 290 | { |
286 | 291 | global $config; |
287 | - if ($count == 0) |
|
288 | - $phrase .= '.none'; |
|
289 | - if ($count == 1) |
|
290 | - $phrase .= '.one'; |
|
291 | - if ($count > 1) |
|
292 | - $phrase .= '.many'; |
|
292 | + if ($count == 0) { |
|
293 | + $phrase .= '.none'; |
|
294 | + } |
|
295 | + if ($count == 1) { |
|
296 | + $phrase .= '.one'; |
|
297 | + } |
|
298 | + if ($count > 1) { |
|
299 | + $phrase .= '.many'; |
|
300 | + } |
|
293 | 301 | |
294 | 302 | /* Static keyword is used to ensure the file is loaded only once */ |
295 | 303 | static $translations = NULL; |
@@ -62,6 +62,9 @@ discard block |
||
62 | 62 | return self::getEntryArray (self::SQL_AUTHORS_BY_FIRST_LETTER, array ($letter . "%")); |
63 | 63 | } |
64 | 64 | |
65 | + /** |
|
66 | + * @param string $query |
|
67 | + */ |
|
65 | 68 | public static function getAuthorsForSearch($query) { |
66 | 69 | return self::getEntryArray (self::SQL_AUTHORS_FOR_SEARCH, array ($query . "%", $query . "%")); |
67 | 70 | } |
@@ -70,6 +73,9 @@ discard block |
||
70 | 73 | return self::getEntryArray (self::SQL_ALL_AUTHORS, array ()); |
71 | 74 | } |
72 | 75 | |
76 | + /** |
|
77 | + * @param string $query |
|
78 | + */ |
|
73 | 79 | public static function getEntryArray ($query, $params) { |
74 | 80 | return Base::getEntryArrayWithBookNumber ($query, self::AUTHOR_COLUMNS, $params, "Author"); |
75 | 81 | } |
@@ -19,37 +19,42 @@ discard block |
||
19 | 19 | public $name; |
20 | 20 | public $sort; |
21 | 21 | |
22 | - public function __construct($post) { |
|
22 | + public function __construct($post) |
|
23 | + { |
|
23 | 24 | $this->id = $post->id; |
24 | 25 | $this->name = str_replace("|", ",", $post->name); |
25 | 26 | $this->sort = $post->sort; |
26 | 27 | } |
27 | 28 | |
28 | - public function getUri () { |
|
29 | + public function getUri () |
|
30 | + { |
|
29 | 31 | return "?page=".parent::PAGE_AUTHOR_DETAIL."&id=$this->id"; |
30 | 32 | } |
31 | 33 | |
32 | - public function getEntryId () { |
|
34 | + public function getEntryId () |
|
35 | + { |
|
33 | 36 | return self::ALL_AUTHORS_ID.":".$this->id; |
34 | 37 | } |
35 | 38 | |
36 | - public static function getEntryIdByLetter ($startingLetter) { |
|
39 | + public static function getEntryIdByLetter ($startingLetter) |
|
40 | + { |
|
37 | 41 | return self::ALL_AUTHORS_ID.":letter:".$startingLetter; |
38 | 42 | } |
39 | 43 | |
40 | - public static function getCount() { |
|
44 | + public static function getCount() |
|
45 | + { |
|
41 | 46 | // str_format (localize("authors.alphabetical", count(array)) |
42 | 47 | return parent::getCountGeneric ("authors", self::ALL_AUTHORS_ID, parent::PAGE_ALL_AUTHORS); |
43 | 48 | } |
44 | 49 | |
45 | - public static function getAllAuthorsByFirstLetter() { |
|
50 | + public static function getAllAuthorsByFirstLetter() |
|
51 | + { |
|
46 | 52 | list (, $result) = parent::executeQuery ("select {0} |
47 | 53 | from authors |
48 | 54 | group by substr (upper (sort), 1, 1) |
49 | 55 | order by substr (upper (sort), 1, 1)", "substr (upper (sort), 1, 1) as title, count(*) as count", "", array (), -1); |
50 | 56 | $entryArray = array(); |
51 | - while ($post = $result->fetchObject ()) |
|
52 | - { |
|
57 | + while ($post = $result->fetchObject ()) { |
|
53 | 58 | array_push ($entryArray, new Entry ($post->title, Author::getEntryIdByLetter ($post->title), |
54 | 59 | str_format (localize("authorword", $post->count), $post->count), "text", |
55 | 60 | array ( new LinkNavigation ("?page=".parent::PAGE_AUTHORS_FIRST_LETTER."&id=". rawurlencode ($post->title))), "", $post->count)); |
@@ -57,30 +62,36 @@ discard block |
||
57 | 62 | return $entryArray; |
58 | 63 | } |
59 | 64 | |
60 | - public static function getAuthorsByStartingLetter($letter) { |
|
65 | + public static function getAuthorsByStartingLetter($letter) |
|
66 | + { |
|
61 | 67 | return self::getEntryArray (self::SQL_AUTHORS_BY_FIRST_LETTER, array ($letter . "%")); |
62 | 68 | } |
63 | 69 | |
64 | - public static function getAuthorsForSearch($query) { |
|
70 | + public static function getAuthorsForSearch($query) |
|
71 | + { |
|
65 | 72 | return self::getEntryArray (self::SQL_AUTHORS_FOR_SEARCH, array ($query . "%", $query . "%")); |
66 | 73 | } |
67 | 74 | |
68 | - public static function getAllAuthors() { |
|
75 | + public static function getAllAuthors() |
|
76 | + { |
|
69 | 77 | return self::getEntryArray (self::SQL_ALL_AUTHORS, array ()); |
70 | 78 | } |
71 | 79 | |
72 | - public static function getEntryArray ($query, $params) { |
|
80 | + public static function getEntryArray ($query, $params) |
|
81 | + { |
|
73 | 82 | return Base::getEntryArrayWithBookNumber ($query, self::AUTHOR_COLUMNS, $params, "Author"); |
74 | 83 | } |
75 | 84 | |
76 | - public static function getAuthorById ($authorId) { |
|
85 | + public static function getAuthorById ($authorId) |
|
86 | + { |
|
77 | 87 | $result = parent::getDb ()->prepare('select ' . self::AUTHOR_COLUMNS . ' from authors where id = ?'); |
78 | 88 | $result->execute (array ($authorId)); |
79 | 89 | $post = $result->fetchObject (); |
80 | 90 | return new Author ($post); |
81 | 91 | } |
82 | 92 | |
83 | - public static function getAuthorByBookId ($bookId) { |
|
93 | + public static function getAuthorByBookId ($bookId) |
|
94 | + { |
|
84 | 95 | $result = parent::getDb ()->prepare('select authors.id as id, authors.name as name, authors.sort as sort from authors, books_authors_link |
85 | 96 | where author = authors.id |
86 | 97 | and book = ?'); |
@@ -84,6 +84,9 @@ discard block |
||
84 | 84 | return ""; |
85 | 85 | } |
86 | 86 | |
87 | + /** |
|
88 | + * @return string |
|
89 | + */ |
|
87 | 90 | public static function getDbDirectory ($database = NULL) { |
88 | 91 | global $config; |
89 | 92 | if (self::isMultipleDatabaseEnabled ()) { |
@@ -143,10 +146,18 @@ discard block |
||
143 | 146 | self::$db = NULL; |
144 | 147 | } |
145 | 148 | |
149 | + /** |
|
150 | + * @param string $query |
|
151 | + */ |
|
146 | 152 | public static function executeQuerySingle ($query, $database = NULL) { |
147 | 153 | return self::getDb ($database)->query($query)->fetchColumn(); |
148 | 154 | } |
149 | 155 | |
156 | + /** |
|
157 | + * @param string $table |
|
158 | + * @param string $id |
|
159 | + * @param string $numberOfString |
|
160 | + */ |
|
150 | 161 | public static function getCountGeneric($table, $id, $pageId, $numberOfString = NULL) { |
151 | 162 | if (!$numberOfString) { |
152 | 163 | $numberOfString = $table . ".alphabetical"; |
@@ -159,6 +170,10 @@ discard block |
||
159 | 170 | return $entry; |
160 | 171 | } |
161 | 172 | |
173 | + /** |
|
174 | + * @param string $columns |
|
175 | + * @param string $category |
|
176 | + */ |
|
162 | 177 | public static function getEntryArrayWithBookNumber ($query, $columns, $params, $category) { |
163 | 178 | /* @var $result PDOStatement */ |
164 | 179 | |
@@ -181,6 +196,9 @@ discard block |
||
181 | 196 | return $entryArray; |
182 | 197 | } |
183 | 198 | |
199 | + /** |
|
200 | + * @param string $filter |
|
201 | + */ |
|
184 | 202 | public static function executeQuery($query, $columns, $filter, $params, $n, $database = NULL, $numberPerPage = NULL) { |
185 | 203 | $totalResult = -1; |
186 | 204 |
@@ -37,23 +37,27 @@ discard block |
||
37 | 37 | |
38 | 38 | private static $db = NULL; |
39 | 39 | |
40 | - public static function isMultipleDatabaseEnabled () { |
|
40 | + public static function isMultipleDatabaseEnabled () |
|
41 | + { |
|
41 | 42 | global $config; |
42 | 43 | return is_array ($config['calibre_directory']); |
43 | 44 | } |
44 | 45 | |
45 | - public static function useAbsolutePath () { |
|
46 | + public static function useAbsolutePath () |
|
47 | + { |
|
46 | 48 | global $config; |
47 | 49 | $path = self::getDbDirectory(); |
48 | 50 | return preg_match ('/^\//', $path) || // Linux / |
49 | 51 | preg_match ('/^\w\:/', $path); // Windows X: |
50 | 52 | } |
51 | 53 | |
52 | - public static function noDatabaseSelected () { |
|
54 | + public static function noDatabaseSelected () |
|
55 | + { |
|
53 | 56 | return self::isMultipleDatabaseEnabled () && is_null (GetUrlParam (DB)); |
54 | 57 | } |
55 | 58 | |
56 | - public static function getDbList () { |
|
59 | + public static function getDbList () |
|
60 | + { |
|
57 | 61 | global $config; |
58 | 62 | if (self::isMultipleDatabaseEnabled ()) { |
59 | 63 | return $config['calibre_directory']; |
@@ -62,7 +66,8 @@ discard block |
||
62 | 66 | } |
63 | 67 | } |
64 | 68 | |
65 | - public static function getDbNameList () { |
|
69 | + public static function getDbNameList () |
|
70 | + { |
|
66 | 71 | global $config; |
67 | 72 | if (self::isMultipleDatabaseEnabled ()) { |
68 | 73 | return array_keys ($config['calibre_directory']); |
@@ -71,10 +76,13 @@ discard block |
||
71 | 76 | } |
72 | 77 | } |
73 | 78 | |
74 | - public static function getDbName ($database = NULL) { |
|
79 | + public static function getDbName ($database = NULL) |
|
80 | + { |
|
75 | 81 | global $config; |
76 | 82 | if (self::isMultipleDatabaseEnabled ()) { |
77 | - if (is_null ($database)) $database = GetUrlParam (DB, 0); |
|
83 | + if (is_null ($database)) { |
|
84 | + $database = GetUrlParam (DB, 0); |
|
85 | + } |
|
78 | 86 | if (!is_null($database) && !preg_match('/^\d+$/', $database)) { |
79 | 87 | self::error ($database); |
80 | 88 | } |
@@ -84,10 +92,13 @@ discard block |
||
84 | 92 | return ""; |
85 | 93 | } |
86 | 94 | |
87 | - public static function getDbDirectory ($database = NULL) { |
|
95 | + public static function getDbDirectory ($database = NULL) |
|
96 | + { |
|
88 | 97 | global $config; |
89 | 98 | if (self::isMultipleDatabaseEnabled ()) { |
90 | - if (is_null ($database)) $database = GetUrlParam (DB, 0); |
|
99 | + if (is_null ($database)) { |
|
100 | + $database = GetUrlParam (DB, 0); |
|
101 | + } |
|
91 | 102 | if (!is_null($database) && !preg_match('/^\d+$/', $database)) { |
92 | 103 | self::error ($database); |
93 | 104 | } |
@@ -98,18 +109,21 @@ discard block |
||
98 | 109 | } |
99 | 110 | |
100 | 111 | |
101 | - public static function getDbFileName ($database = NULL) { |
|
112 | + public static function getDbFileName ($database = NULL) |
|
113 | + { |
|
102 | 114 | return self::getDbDirectory ($database) .'metadata.db'; |
103 | 115 | } |
104 | 116 | |
105 | - private static function error ($database) { |
|
117 | + private static function error ($database) |
|
118 | + { |
|
106 | 119 | if (php_sapi_name() != "cli") { |
107 | 120 | header("location: checkconfig.php?err=1"); |
108 | 121 | } |
109 | 122 | throw new Exception("Database <{$database}> not found."); |
110 | 123 | } |
111 | 124 | |
112 | - public static function getDb ($database = NULL) { |
|
125 | + public static function getDb ($database = NULL) |
|
126 | + { |
|
113 | 127 | if (is_null (self::$db)) { |
114 | 128 | try { |
115 | 129 | if (is_readable (self::getDbFileName ($database))) { |
@@ -127,7 +141,8 @@ discard block |
||
127 | 141 | return self::$db; |
128 | 142 | } |
129 | 143 | |
130 | - public static function checkDatabaseAvailability () { |
|
144 | + public static function checkDatabaseAvailability () |
|
145 | + { |
|
131 | 146 | if (self::noDatabaseSelected ()) { |
132 | 147 | for ($i = 0; $i < count (self::getDbList ()); $i++) { |
133 | 148 | self::getDb ($i); |
@@ -139,33 +154,38 @@ discard block |
||
139 | 154 | return true; |
140 | 155 | } |
141 | 156 | |
142 | - public static function clearDb () { |
|
157 | + public static function clearDb () |
|
158 | + { |
|
143 | 159 | self::$db = NULL; |
144 | 160 | } |
145 | 161 | |
146 | - public static function executeQuerySingle ($query, $database = NULL) { |
|
162 | + public static function executeQuerySingle ($query, $database = NULL) |
|
163 | + { |
|
147 | 164 | return self::getDb ($database)->query($query)->fetchColumn(); |
148 | 165 | } |
149 | 166 | |
150 | - public static function getCountGeneric($table, $id, $pageId, $numberOfString = NULL) { |
|
167 | + public static function getCountGeneric($table, $id, $pageId, $numberOfString = NULL) |
|
168 | + { |
|
151 | 169 | if (!$numberOfString) { |
152 | 170 | $numberOfString = $table . ".alphabetical"; |
153 | 171 | } |
154 | 172 | $count = self::executeQuerySingle ('select count(*) from ' . $table); |
155 | - if ($count == 0) return NULL; |
|
173 | + if ($count == 0) { |
|
174 | + return NULL; |
|
175 | + } |
|
156 | 176 | $entry = new Entry (localize($table . ".title"), $id, |
157 | 177 | str_format (localize($numberOfString, $count), $count), "text", |
158 | 178 | array ( new LinkNavigation ("?page=".$pageId)), "", $count); |
159 | 179 | return $entry; |
160 | 180 | } |
161 | 181 | |
162 | - public static function getEntryArrayWithBookNumber ($query, $columns, $params, $category) { |
|
182 | + public static function getEntryArrayWithBookNumber ($query, $columns, $params, $category) |
|
183 | + { |
|
163 | 184 | /* @var $result PDOStatement */ |
164 | 185 | |
165 | 186 | list (, $result) = self::executeQuery ($query, $columns, "", $params, -1); |
166 | 187 | $entryArray = array(); |
167 | - while ($post = $result->fetchObject ()) |
|
168 | - { |
|
188 | + while ($post = $result->fetchObject ()) { |
|
169 | 189 | /* @var $instance Author|Tag|Serie|Publisher */ |
170 | 190 | |
171 | 191 | $instance = new $category ($post); |
@@ -181,7 +201,8 @@ discard block |
||
181 | 201 | return $entryArray; |
182 | 202 | } |
183 | 203 | |
184 | - public static function executeQuery($query, $columns, $filter, $params, $n, $database = NULL, $numberPerPage = NULL) { |
|
204 | + public static function executeQuery($query, $columns, $filter, $params, $n, $database = NULL, $numberPerPage = NULL) |
|
205 | + { |
|
185 | 206 | $totalResult = -1; |
186 | 207 | |
187 | 208 | if (useNormAndUp ()) { |
@@ -193,8 +214,7 @@ discard block |
||
193 | 214 | $numberPerPage = getCurrentOption ("max_item_per_page"); |
194 | 215 | } |
195 | 216 | |
196 | - if ($numberPerPage != -1 && $n != -1) |
|
197 | - { |
|
217 | + if ($numberPerPage != -1 && $n != -1) { |
|
198 | 218 | // First check total number of results |
199 | 219 | $result = self::getDb ($database)->prepare (str_format ($query, "count(*)", $filter)); |
200 | 220 | $result->execute ($params); |
@@ -144,6 +144,9 @@ discard block |
||
144 | 144 | return 'index.php' . $urlParam; |
145 | 145 | } |
146 | 146 | |
147 | + /** |
|
148 | + * @return string |
|
149 | + */ |
|
147 | 150 | public function getTitle () { |
148 | 151 | return $this->title; |
149 | 152 | } |
@@ -331,6 +334,9 @@ discard block |
||
331 | 334 | return reset($reduced); |
332 | 335 | } |
333 | 336 | |
337 | + /** |
|
338 | + * @param string $extension |
|
339 | + */ |
|
334 | 340 | public function getFilePath($extension, $idData = NULL, $relative = false) |
335 | 341 | { |
336 | 342 | if ($extension == 'jpg') |
@@ -464,6 +470,9 @@ discard block |
||
464 | 470 | $this->getLinkArray(), $this); |
465 | 471 | } |
466 | 472 | |
473 | + /** |
|
474 | + * @param integer $database |
|
475 | + */ |
|
467 | 476 | public static function getBookCount($database = NULL) { |
468 | 477 | return parent::executeQuerySingle('select count(*) from books', $database); |
469 | 478 | } |
@@ -512,7 +521,7 @@ discard block |
||
512 | 521 | } |
513 | 522 | |
514 | 523 | /** |
515 | - * @param $customColumn CustomColumn |
|
524 | + * @param CustomColumn $customColumn CustomColumn |
|
516 | 525 | * @param $id integer |
517 | 526 | * @param $n integer |
518 | 527 | * @return array |
@@ -552,6 +561,10 @@ discard block |
||
552 | 561 | return NULL; |
553 | 562 | } |
554 | 563 | |
564 | + /** |
|
565 | + * @param integer $database |
|
566 | + * @param integer $numberPerPage |
|
567 | + */ |
|
555 | 568 | public static function getBooksByQuery($query, $n, $database = NULL, $numberPerPage = NULL) { |
556 | 569 | $i = 0; |
557 | 570 | $critArray = array(); |
@@ -599,6 +612,9 @@ discard block |
||
599 | 612 | return $entryArray; |
600 | 613 | } |
601 | 614 | |
615 | + /** |
|
616 | + * @param integer $numberPerPage |
|
617 | + */ |
|
602 | 618 | public static function getBooksByStartingLetter($letter, $n, $database = NULL, $numberPerPage = NULL) { |
603 | 619 | return self::getEntryArray(self::SQL_BOOKS_BY_FIRST_LETTER, array($letter . '%'), $n, $database, $numberPerPage); |
604 | 620 | } |
@@ -111,7 +111,8 @@ discard block |
||
111 | 111 | public $format = array (); |
112 | 112 | |
113 | 113 | |
114 | - public function __construct($line) { |
|
114 | + public function __construct($line) |
|
115 | + { |
|
115 | 116 | $this->id = $line->id; |
116 | 117 | $this->title = $line->title; |
117 | 118 | $this->timestamp = strtotime($line->timestamp); |
@@ -129,25 +130,32 @@ discard block |
||
129 | 130 | $this->rating = $line->rating; |
130 | 131 | } |
131 | 132 | |
132 | - public function getEntryId() { |
|
133 | + public function getEntryId() |
|
134 | + { |
|
133 | 135 | return self::ALL_BOOKS_UUID.':'.$this->uuid; |
134 | 136 | } |
135 | 137 | |
136 | - public static function getEntryIdByLetter ($startingLetter) { |
|
138 | + public static function getEntryIdByLetter ($startingLetter) |
|
139 | + { |
|
137 | 140 | return self::ALL_BOOKS_ID.':letter:'.$startingLetter; |
138 | 141 | } |
139 | 142 | |
140 | - public function getUri () { |
|
143 | + public function getUri () |
|
144 | + { |
|
141 | 145 | return '?page='.parent::PAGE_BOOK_DETAIL.'&id=' . $this->id; |
142 | 146 | } |
143 | 147 | |
144 | - public function getDetailUrl () { |
|
148 | + public function getDetailUrl () |
|
149 | + { |
|
145 | 150 | $urlParam = $this->getUri(); |
146 | - if (!is_null(GetUrlParam(DB))) $urlParam = addURLParameter($urlParam, DB, GetUrlParam (DB)); |
|
151 | + if (!is_null(GetUrlParam(DB))) { |
|
152 | + $urlParam = addURLParameter($urlParam, DB, GetUrlParam (DB)); |
|
153 | + } |
|
147 | 154 | return 'index.php' . $urlParam; |
148 | 155 | } |
149 | 156 | |
150 | - public function getTitle () { |
|
157 | + public function getTitle () |
|
158 | + { |
|
151 | 159 | return $this->title; |
152 | 160 | } |
153 | 161 | |
@@ -156,22 +164,26 @@ discard block |
||
156 | 164 | /** |
157 | 165 | * @return Author[] |
158 | 166 | */ |
159 | - public function getAuthors () { |
|
167 | + public function getAuthors () |
|
168 | + { |
|
160 | 169 | if (is_null($this->authors)) { |
161 | 170 | $this->authors = Author::getAuthorByBookId($this->id); |
162 | 171 | } |
163 | 172 | return $this->authors; |
164 | 173 | } |
165 | 174 | |
166 | - public function getAuthorsName () { |
|
175 | + public function getAuthorsName () |
|
176 | + { |
|
167 | 177 | return implode(', ', array_map(function ($author) { return $author->name; }, $this->getAuthors())); |
168 | 178 | } |
169 | 179 | |
170 | - public function getAuthorsSort () { |
|
180 | + public function getAuthorsSort () |
|
181 | + { |
|
171 | 182 | return implode(', ', array_map(function ($author) { return $author->sort; }, $this->getAuthors())); |
172 | 183 | } |
173 | 184 | |
174 | - public function getPublisher () { |
|
185 | + public function getPublisher () |
|
186 | + { |
|
175 | 187 | if (is_null($this->publisher)) { |
176 | 188 | $this->publisher = Publisher::getPublisherByBookId($this->id); |
177 | 189 | } |
@@ -181,7 +193,8 @@ discard block |
||
181 | 193 | /** |
182 | 194 | * @return Serie |
183 | 195 | */ |
184 | - public function getSerie() { |
|
196 | + public function getSerie() |
|
197 | + { |
|
185 | 198 | if (is_null($this->serie)) { |
186 | 199 | $this->serie = Serie::getSerieByBookId($this->id); |
187 | 200 | } |
@@ -191,7 +204,8 @@ discard block |
||
191 | 204 | /** |
192 | 205 | * @return string |
193 | 206 | */ |
194 | - public function getLanguages() { |
|
207 | + public function getLanguages() |
|
208 | + { |
|
195 | 209 | $lang = array(); |
196 | 210 | $result = parent::getDb()->prepare('select languages.lang_code |
197 | 211 | from books_languages_link, languages |
@@ -199,8 +213,7 @@ discard block |
||
199 | 213 | and book = ? |
200 | 214 | order by item_order'); |
201 | 215 | $result->execute(array($this->id)); |
202 | - while ($post = $result->fetchObject()) |
|
203 | - { |
|
216 | + while ($post = $result->fetchObject()) { |
|
204 | 217 | array_push($lang, Language::getLanguageString($post->lang_code)); |
205 | 218 | } |
206 | 219 | return implode(', ', $lang); |
@@ -209,7 +222,8 @@ discard block |
||
209 | 222 | /** |
210 | 223 | * @return Tag[] |
211 | 224 | */ |
212 | - public function getTags() { |
|
225 | + public function getTags() |
|
226 | + { |
|
213 | 227 | if (is_null ($this->tags)) { |
214 | 228 | $this->tags = array(); |
215 | 229 | |
@@ -219,15 +233,15 @@ discard block |
||
219 | 233 | and book = ? |
220 | 234 | order by name'); |
221 | 235 | $result->execute(array($this->id)); |
222 | - while ($post = $result->fetchObject()) |
|
223 | - { |
|
236 | + while ($post = $result->fetchObject()) { |
|
224 | 237 | array_push($this->tags, new Tag($post)); |
225 | 238 | } |
226 | 239 | } |
227 | 240 | return $this->tags; |
228 | 241 | } |
229 | 242 | |
230 | - public function getTagsName() { |
|
243 | + public function getTagsName() |
|
244 | + { |
|
231 | 245 | return implode(', ', array_map(function ($tag) { return $tag->name; }, $this->getTags())); |
232 | 246 | } |
233 | 247 | |
@@ -235,7 +249,8 @@ discard block |
||
235 | 249 | /** |
236 | 250 | * @return Identifiers[] |
237 | 251 | */ |
238 | - public function getIdentifiers() { |
|
252 | + public function getIdentifiers() |
|
253 | + { |
|
239 | 254 | if (is_null ($this->identifiers)) { |
240 | 255 | $this->identifiers = array(); |
241 | 256 | |
@@ -244,8 +259,7 @@ discard block |
||
244 | 259 | where book = ? |
245 | 260 | order by type'); |
246 | 261 | $result->execute(array($this->id)); |
247 | - while ($post = $result->fetchObject()) |
|
248 | - { |
|
262 | + while ($post = $result->fetchObject()) { |
|
249 | 263 | array_push($this->identifiers, new Identifier($post)); |
250 | 264 | } |
251 | 265 | |
@@ -266,9 +280,12 @@ discard block |
||
266 | 280 | |
267 | 281 | /* End of other class (author, series, tag, ...) initialization and accessors */ |
268 | 282 | |
269 | - public static function getFilterString() { |
|
283 | + public static function getFilterString() |
|
284 | + { |
|
270 | 285 | $filter = getURLParam('tag', NULL); |
271 | - if (empty($filter)) return ''; |
|
286 | + if (empty($filter)) { |
|
287 | + return ''; |
|
288 | + } |
|
272 | 289 | |
273 | 290 | $exists = true; |
274 | 291 | if (preg_match("/^!(.*)$/", $filter, $matches)) { |
@@ -308,7 +325,8 @@ discard block |
||
308 | 325 | return reset($reduced); |
309 | 326 | } |
310 | 327 | |
311 | - public function getRating() { |
|
328 | + public function getRating() |
|
329 | + { |
|
312 | 330 | if (is_null($this->rating) || $this->rating == 0) { |
313 | 331 | return ''; |
314 | 332 | } |
@@ -322,7 +340,8 @@ discard block |
||
322 | 340 | return $retour; |
323 | 341 | } |
324 | 342 | |
325 | - public function getPubDate() { |
|
343 | + public function getPubDate() |
|
344 | + { |
|
326 | 345 | if (empty ($this->pubdate)) { |
327 | 346 | return ''; |
328 | 347 | } |
@@ -333,23 +352,22 @@ discard block |
||
333 | 352 | return ''; |
334 | 353 | } |
335 | 354 | |
336 | - public function getComment($withSerie = true) { |
|
355 | + public function getComment($withSerie = true) |
|
356 | + { |
|
337 | 357 | $addition = ''; |
338 | 358 | $se = $this->getSerie (); |
339 | 359 | if (!is_null ($se) && $withSerie) { |
340 | 360 | $addition = $addition . '<strong>' . localize('content.series') . '</strong>' . str_format(localize('content.series.data'), $this->seriesIndex, htmlspecialchars($se->name)) . "<br />\n"; |
341 | 361 | } |
342 | - if (preg_match('/<\/(div|p|a|span)>/', $this->comment)) |
|
343 | - { |
|
362 | + if (preg_match('/<\/(div|p|a|span)>/', $this->comment)) { |
|
344 | 363 | return $addition . html2xhtml($this->comment); |
345 | - } |
|
346 | - else |
|
347 | - { |
|
364 | + } else { |
|
348 | 365 | return $addition . htmlspecialchars($this->comment); |
349 | 366 | } |
350 | 367 | } |
351 | 368 | |
352 | - public function getDataFormat($format) { |
|
369 | + public function getDataFormat($format) |
|
370 | + { |
|
353 | 371 | $reduced = array_filter($this->getDatas(), function ($data) use ($format) { |
354 | 372 | return $data->format == $format; |
355 | 373 | }); |
@@ -358,23 +376,19 @@ discard block |
||
358 | 376 | |
359 | 377 | public function getFilePath($extension, $idData = NULL, $relative = false) |
360 | 378 | { |
361 | - if ($extension == 'jpg') |
|
362 | - { |
|
379 | + if ($extension == 'jpg') { |
|
363 | 380 | $file = 'cover.jpg'; |
364 | - } |
|
365 | - else |
|
366 | - { |
|
381 | + } else { |
|
367 | 382 | $data = $this->getDataById($idData); |
368 | - if (!$data) return NULL; |
|
383 | + if (!$data) { |
|
384 | + return NULL; |
|
385 | + } |
|
369 | 386 | $file = $data->name . '.' . strtolower($data->format); |
370 | 387 | } |
371 | 388 | |
372 | - if ($relative) |
|
373 | - { |
|
389 | + if ($relative) { |
|
374 | 390 | return $this->relativePath.'/'.$file; |
375 | - } |
|
376 | - else |
|
377 | - { |
|
391 | + } else { |
|
378 | 392 | return $this->path.'/'.$file; |
379 | 393 | } |
380 | 394 | } |
@@ -384,8 +398,7 @@ discard block |
||
384 | 398 | global $config; |
385 | 399 | $data = $this->getDataById($idData); |
386 | 400 | |
387 | - try |
|
388 | - { |
|
401 | + try { |
|
389 | 402 | $epub = new EPub($data->getLocalPath()); |
390 | 403 | |
391 | 404 | $epub->Title($this->title); |
@@ -410,14 +423,13 @@ discard block |
||
410 | 423 | $filename = $data->getUpdatedFilenameKepub(); |
411 | 424 | } |
412 | 425 | $epub->download($filename); |
413 | - } |
|
414 | - catch (Exception $e) |
|
415 | - { |
|
426 | + } catch (Exception $e) { |
|
416 | 427 | echo 'Exception : ' . $e->getMessage(); |
417 | 428 | } |
418 | 429 | } |
419 | 430 | |
420 | - public function getThumbnail($width, $height, $outputfile = NULL) { |
|
431 | + public function getThumbnail($width, $height, $outputfile = NULL) |
|
432 | + { |
|
421 | 433 | if (is_null($width) && is_null($height)) { |
422 | 434 | return false; |
423 | 435 | } |
@@ -456,17 +468,14 @@ discard block |
||
456 | 468 | { |
457 | 469 | $linkArray = array(); |
458 | 470 | |
459 | - if ($this->hasCover) |
|
460 | - { |
|
471 | + if ($this->hasCover) { |
|
461 | 472 | array_push($linkArray, Data::getLink($this, 'jpg', 'image/jpeg', Link::OPDS_IMAGE_TYPE, 'cover.jpg', NULL)); |
462 | 473 | |
463 | 474 | array_push($linkArray, Data::getLink($this, 'jpg', 'image/jpeg', Link::OPDS_THUMBNAIL_TYPE, 'cover.jpg', NULL)); |
464 | 475 | } |
465 | 476 | |
466 | - foreach ($this->getDatas() as $data) |
|
467 | - { |
|
468 | - if ($data->isKnownType()) |
|
469 | - { |
|
477 | + foreach ($this->getDatas() as $data) { |
|
478 | + if ($data->isKnownType()) { |
|
470 | 479 | array_push($linkArray, $data->getDataLink(Link::OPDS_ACQUISITION_TYPE, $data->format)); |
471 | 480 | } |
472 | 481 | } |
@@ -485,17 +494,20 @@ discard block |
||
485 | 494 | } |
486 | 495 | |
487 | 496 | |
488 | - public function getEntry() { |
|
497 | + public function getEntry() |
|
498 | + { |
|
489 | 499 | return new EntryBook($this->getTitle(), $this->getEntryId(), |
490 | 500 | $this->getComment(), 'text/html', |
491 | 501 | $this->getLinkArray(), $this); |
492 | 502 | } |
493 | 503 | |
494 | - public static function getBookCount($database = NULL) { |
|
504 | + public static function getBookCount($database = NULL) |
|
505 | + { |
|
495 | 506 | return parent::executeQuerySingle('select count(*) from books', $database); |
496 | 507 | } |
497 | 508 | |
498 | - public static function getCount() { |
|
509 | + public static function getCount() |
|
510 | + { |
|
499 | 511 | global $config; |
500 | 512 | $nBooks = parent::executeQuerySingle('select count(*) from books'); |
501 | 513 | $result = array(); |
@@ -514,27 +526,33 @@ discard block |
||
514 | 526 | return $result; |
515 | 527 | } |
516 | 528 | |
517 | - public static function getBooksByAuthor($authorId, $n) { |
|
529 | + public static function getBooksByAuthor($authorId, $n) |
|
530 | + { |
|
518 | 531 | return self::getEntryArray(self::SQL_BOOKS_BY_AUTHOR, array($authorId), $n); |
519 | 532 | } |
520 | 533 | |
521 | - public static function getBooksByRating($ratingId, $n) { |
|
534 | + public static function getBooksByRating($ratingId, $n) |
|
535 | + { |
|
522 | 536 | return self::getEntryArray(self::SQL_BOOKS_BY_RATING, array($ratingId), $n); |
523 | 537 | } |
524 | 538 | |
525 | - public static function getBooksByPublisher($publisherId, $n) { |
|
539 | + public static function getBooksByPublisher($publisherId, $n) |
|
540 | + { |
|
526 | 541 | return self::getEntryArray(self::SQL_BOOKS_BY_PUBLISHER, array($publisherId), $n); |
527 | 542 | } |
528 | 543 | |
529 | - public static function getBooksBySeries($serieId, $n) { |
|
544 | + public static function getBooksBySeries($serieId, $n) |
|
545 | + { |
|
530 | 546 | return self::getEntryArray(self::SQL_BOOKS_BY_SERIE, array($serieId), $n); |
531 | 547 | } |
532 | 548 | |
533 | - public static function getBooksByTag($tagId, $n) { |
|
549 | + public static function getBooksByTag($tagId, $n) |
|
550 | + { |
|
534 | 551 | return self::getEntryArray(self::SQL_BOOKS_BY_TAG, array($tagId), $n); |
535 | 552 | } |
536 | 553 | |
537 | - public static function getBooksByLanguage($languageId, $n) { |
|
554 | + public static function getBooksByLanguage($languageId, $n) |
|
555 | + { |
|
538 | 556 | return self::getEntryArray(self::SQL_BOOKS_BY_LANGUAGE, array($languageId), $n); |
539 | 557 | } |
540 | 558 | |
@@ -544,32 +562,33 @@ discard block |
||
544 | 562 | * @param $n integer |
545 | 563 | * @return array |
546 | 564 | */ |
547 | - public static function getBooksByCustom($customColumn, $id, $n) { |
|
565 | + public static function getBooksByCustom($customColumn, $id, $n) |
|
566 | + { |
|
548 | 567 | list($query, $params) = $customColumn->getQuery($id); |
549 | 568 | |
550 | 569 | return self::getEntryArray($query, $params, $n); |
551 | 570 | } |
552 | 571 | |
553 | - public static function getBookById($bookId) { |
|
572 | + public static function getBookById($bookId) |
|
573 | + { |
|
554 | 574 | $result = parent::getDb()->prepare('select ' . self::BOOK_COLUMNS . ' |
555 | 575 | from books ' . self::SQL_BOOKS_LEFT_JOIN . ' |
556 | 576 | where books.id = ?'); |
557 | 577 | $result->execute(array($bookId)); |
558 | - while ($post = $result->fetchObject()) |
|
559 | - { |
|
578 | + while ($post = $result->fetchObject()) { |
|
560 | 579 | $book = new Book($post); |
561 | 580 | return $book; |
562 | 581 | } |
563 | 582 | return NULL; |
564 | 583 | } |
565 | 584 | |
566 | - public static function getBookByDataId($dataId) { |
|
585 | + public static function getBookByDataId($dataId) |
|
586 | + { |
|
567 | 587 | $result = parent::getDb()->prepare('select ' . self::BOOK_COLUMNS . ', data.name, data.format |
568 | 588 | from data, books ' . self::SQL_BOOKS_LEFT_JOIN . ' |
569 | 589 | where data.book = books.id and data.id = ?'); |
570 | 590 | $result->execute(array($dataId)); |
571 | - while ($post = $result->fetchObject()) |
|
572 | - { |
|
591 | + while ($post = $result->fetchObject()) { |
|
573 | 592 | $book = new Book($post); |
574 | 593 | $data = new Data($post, $book); |
575 | 594 | $data->id = $dataId; |
@@ -579,7 +598,8 @@ discard block |
||
579 | 598 | return NULL; |
580 | 599 | } |
581 | 600 | |
582 | - public static function getBooksByQuery($query, $n, $database = NULL, $numberPerPage = NULL) { |
|
601 | + public static function getBooksByQuery($query, $n, $database = NULL, $numberPerPage = NULL) |
|
602 | + { |
|
583 | 603 | $i = 0; |
584 | 604 | $critArray = array(); |
585 | 605 | foreach (array(PageQueryResult::SCOPE_AUTHOR, |
@@ -590,8 +610,7 @@ discard block |
||
590 | 610 | if (in_array($key, getCurrentOption('ignored_categories')) || |
591 | 611 | (!array_key_exists($key, $query) && !array_key_exists('all', $query))) { |
592 | 612 | $critArray[$i] = self::BAD_SEARCH; |
593 | - } |
|
594 | - else { |
|
613 | + } else { |
|
595 | 614 | if (array_key_exists($key, $query)) { |
596 | 615 | $critArray[$i] = $query[$key]; |
597 | 616 | } else { |
@@ -603,12 +622,14 @@ discard block |
||
603 | 622 | return self::getEntryArray(self::SQL_BOOKS_QUERY, $critArray, $n, $database, $numberPerPage); |
604 | 623 | } |
605 | 624 | |
606 | - public static function getBooks($n) { |
|
625 | + public static function getBooks($n) |
|
626 | + { |
|
607 | 627 | list ($entryArray, $totalNumber) = self::getEntryArray(self::SQL_BOOKS_ALL , array (), $n); |
608 | 628 | return array($entryArray, $totalNumber); |
609 | 629 | } |
610 | 630 | |
611 | - public static function getAllBooks() { |
|
631 | + public static function getAllBooks() |
|
632 | + { |
|
612 | 633 | /* @var $result PDOStatement */ |
613 | 634 | |
614 | 635 | list (, $result) = parent::executeQuery('select {0} |
@@ -617,8 +638,7 @@ discard block |
||
617 | 638 | order by substr (upper (sort), 1, 1)', 'substr (upper (sort), 1, 1) as title, count(*) as count', self::getFilterString(), array(), -1); |
618 | 639 | |
619 | 640 | $entryArray = array(); |
620 | - while ($post = $result->fetchObject()) |
|
621 | - { |
|
641 | + while ($post = $result->fetchObject()) { |
|
622 | 642 | array_push($entryArray, new Entry($post->title, Book::getEntryIdByLetter($post->title), |
623 | 643 | str_format(localize('bookword', $post->count), $post->count), 'text', |
624 | 644 | array(new LinkNavigation('?page='.parent::PAGE_ALL_BOOKS_LETTER.'&id='. rawurlencode($post->title))), '', $post->count)); |
@@ -626,25 +646,27 @@ discard block |
||
626 | 646 | return $entryArray; |
627 | 647 | } |
628 | 648 | |
629 | - public static function getBooksByStartingLetter($letter, $n, $database = NULL, $numberPerPage = NULL) { |
|
649 | + public static function getBooksByStartingLetter($letter, $n, $database = NULL, $numberPerPage = NULL) |
|
650 | + { |
|
630 | 651 | return self::getEntryArray(self::SQL_BOOKS_BY_FIRST_LETTER, array($letter . '%'), $n, $database, $numberPerPage); |
631 | 652 | } |
632 | 653 | |
633 | - public static function getEntryArray($query, $params, $n, $database = NULL, $numberPerPage = NULL) { |
|
654 | + public static function getEntryArray($query, $params, $n, $database = NULL, $numberPerPage = NULL) |
|
655 | + { |
|
634 | 656 | /* @var $totalNumber integer */ |
635 | 657 | /* @var $result PDOStatement */ |
636 | 658 | list($totalNumber, $result) = parent::executeQuery($query, self::BOOK_COLUMNS, self::getFilterString(), $params, $n, $database, $numberPerPage); |
637 | 659 | |
638 | 660 | $entryArray = array(); |
639 | - while ($post = $result->fetchObject()) |
|
640 | - { |
|
661 | + while ($post = $result->fetchObject()) { |
|
641 | 662 | $book = new Book($post); |
642 | 663 | array_push($entryArray, $book->getEntry()); |
643 | 664 | } |
644 | 665 | return array($entryArray, $totalNumber); |
645 | 666 | } |
646 | 667 | |
647 | - public static function getAllRecentBooks() { |
|
668 | + public static function getAllRecentBooks() |
|
669 | + { |
|
648 | 670 | global $config; |
649 | 671 | list ($entryArray, ) = self::getEntryArray(self::SQL_BOOKS_RECENT . $config['cops_recentbooks_limit'], array(), -1); |
650 | 672 | return $entryArray; |
@@ -656,7 +678,8 @@ discard block |
||
656 | 678 | * @param string[] $columns |
657 | 679 | * @return CustomColumn[] |
658 | 680 | */ |
659 | - public function getCustomColumnValues($columns, $asArray = false) { |
|
681 | + public function getCustomColumnValues($columns, $asArray = false) |
|
682 | + { |
|
660 | 683 | $result = array(); |
661 | 684 | |
662 | 685 | foreach ($columns as $lookup) { |
@@ -39,6 +39,9 @@ discard block |
||
39 | 39 | /** @var null|Entry[] */ |
40 | 40 | private $customValues = NULL; |
41 | 41 | |
42 | + /** |
|
43 | + * @param string $pdatatype |
|
44 | + */ |
|
42 | 45 | protected function __construct($pcustomId, $pdatatype) |
43 | 46 | { |
44 | 47 | $this->columnTitle = self::getTitleByCustomID($pcustomId); |
@@ -147,7 +150,7 @@ discard block |
||
147 | 150 | /** |
148 | 151 | * Encode a value of this column ready to be displayed in an HTML document |
149 | 152 | * |
150 | - * @param integer|string $value |
|
153 | + * @param string $value |
|
151 | 154 | * @return string |
152 | 155 | */ |
153 | 156 | public function encodeHTMLValue($value) |
@@ -277,7 +280,7 @@ discard block |
||
277 | 280 | /** |
278 | 281 | * Get a CustomColumn for a specified (by ID) value |
279 | 282 | * |
280 | - * @param string|integer $id the id of the searched value |
|
283 | + * @param integer $id the id of the searched value |
|
281 | 284 | * @return CustomColumn |
282 | 285 | */ |
283 | 286 | abstract public function getCustom($id); |
@@ -181,8 +181,9 @@ discard block |
||
181 | 181 | public static function createByCustomID($customId) |
182 | 182 | { |
183 | 183 | // Reuse already created CustomColumns for performance |
184 | - if (array_key_exists($customId, self::$customColumnCacheID)) |
|
185 | - return self::$customColumnCacheID[$customId]; |
|
184 | + if (array_key_exists($customId, self::$customColumnCacheID)) { |
|
185 | + return self::$customColumnCacheID[$customId]; |
|
186 | + } |
|
186 | 187 | |
187 | 188 | $datatype = self::getDatatypeByCustomID($customId); |
188 | 189 | |
@@ -221,8 +222,9 @@ discard block |
||
221 | 222 | public static function createByLookup($lookup) |
222 | 223 | { |
223 | 224 | // Reuse already created CustomColumns for performance |
224 | - if (array_key_exists($lookup, self::$customColumnCacheLookup)) |
|
225 | - return self::$customColumnCacheLookup[$lookup]; |
|
225 | + if (array_key_exists($lookup, self::$customColumnCacheLookup)) { |
|
226 | + return self::$customColumnCacheLookup[$lookup]; |
|
227 | + } |
|
226 | 228 | |
227 | 229 | $result = parent::getDb()->prepare('SELECT id FROM custom_columns WHERE label = ?'); |
228 | 230 | $result->execute(array($lookup)); |
@@ -241,8 +243,9 @@ discard block |
||
241 | 243 | public function getAllCustomValues() |
242 | 244 | { |
243 | 245 | // lazy loading |
244 | - if ($this->customValues == NULL) |
|
245 | - $this->customValues = $this->getAllCustomValuesFromDatabase(); |
|
246 | + if ($this->customValues == NULL) { |
|
247 | + $this->customValues = $this->getAllCustomValuesFromDatabase(); |
|
248 | + } |
|
246 | 249 | |
247 | 250 | return $this->customValues; |
248 | 251 | } |
@@ -8,6 +8,9 @@ |
||
8 | 8 | |
9 | 9 | class LinkFacet extends Link |
10 | 10 | { |
11 | + /** |
|
12 | + * @param string $phref |
|
13 | + */ |
|
11 | 14 | public function __construct($phref, $ptitle = NULL, $pfacetGroup = NULL, $pactiveFacet = FALSE) { |
12 | 15 | parent::__construct ($phref, Link::OPDS_PAGING_TYPE, "http://opds-spec.org/facet", $ptitle, $pfacetGroup, $pactiveFacet); |
13 | 16 | if (!is_null (GetUrlParam (DB))) $this->href = addURLParameter ($this->href, DB, GetUrlParam (DB)); |
@@ -8,9 +8,12 @@ |
||
8 | 8 | |
9 | 9 | class LinkFacet extends Link |
10 | 10 | { |
11 | - public function __construct($phref, $ptitle = NULL, $pfacetGroup = NULL, $pactiveFacet = FALSE) { |
|
11 | + public function __construct($phref, $ptitle = NULL, $pfacetGroup = NULL, $pactiveFacet = FALSE) |
|
12 | + { |
|
12 | 13 | parent::__construct ($phref, Link::OPDS_PAGING_TYPE, "http://opds-spec.org/facet", $ptitle, $pfacetGroup, $pactiveFacet); |
13 | - if (!is_null (GetUrlParam (DB))) $this->href = addURLParameter ($this->href, DB, GetUrlParam (DB)); |
|
14 | + if (!is_null (GetUrlParam (DB))) { |
|
15 | + $this->href = addURLParameter ($this->href, DB, GetUrlParam (DB)); |
|
16 | + } |
|
14 | 17 | $this->href = parent::getScriptName() . $this->href; |
15 | 18 | } |
16 | 19 | } |
@@ -8,6 +8,9 @@ |
||
8 | 8 | |
9 | 9 | class LinkNavigation extends Link |
10 | 10 | { |
11 | + /** |
|
12 | + * @param string $prel |
|
13 | + */ |
|
11 | 14 | public function __construct($phref, $prel = NULL, $ptitle = NULL) { |
12 | 15 | parent::__construct ($phref, Link::OPDS_NAVIGATION_TYPE, $prel, $ptitle); |
13 | 16 | if (!is_null (GetUrlParam (DB))) $this->href = addURLParameter ($this->href, DB, GetUrlParam (DB)); |
@@ -8,10 +8,15 @@ |
||
8 | 8 | |
9 | 9 | class LinkNavigation extends Link |
10 | 10 | { |
11 | - public function __construct($phref, $prel = NULL, $ptitle = NULL) { |
|
11 | + public function __construct($phref, $prel = NULL, $ptitle = NULL) |
|
12 | + { |
|
12 | 13 | parent::__construct ($phref, Link::OPDS_NAVIGATION_TYPE, $prel, $ptitle); |
13 | - if (!is_null (GetUrlParam (DB))) $this->href = addURLParameter ($this->href, DB, GetUrlParam (DB)); |
|
14 | - if (!preg_match ("#^\?(.*)#", $this->href) && !empty ($this->href)) $this->href = "?" . $this->href; |
|
14 | + if (!is_null (GetUrlParam (DB))) { |
|
15 | + $this->href = addURLParameter ($this->href, DB, GetUrlParam (DB)); |
|
16 | + } |
|
17 | + if (!preg_match ("#^\?(.*)#", $this->href) && !empty ($this->href)) { |
|
18 | + $this->href = "?" . $this->href; |
|
19 | + } |
|
15 | 20 | if (preg_match ("/(bookdetail|getJSON).php/", parent::getScriptName())) { |
16 | 21 | $this->href = "index.php" . $this->href; |
17 | 22 | } else { |
@@ -8,6 +8,9 @@ discard block |
||
8 | 8 | |
9 | 9 | class PageCustomize extends Page |
10 | 10 | { |
11 | + /** |
|
12 | + * @param string $key |
|
13 | + */ |
|
11 | 14 | private function isChecked ($key, $testedValue = 1) { |
12 | 15 | $value = getCurrentOption ($key); |
13 | 16 | if (is_array ($value)) { |
@@ -22,6 +25,9 @@ discard block |
||
22 | 25 | return ""; |
23 | 26 | } |
24 | 27 | |
28 | + /** |
|
29 | + * @param string $key |
|
30 | + */ |
|
25 | 31 | private function isSelected ($key, $value) { |
26 | 32 | if (getCurrentOption ($key) == $value) { |
27 | 33 | return "selected='selected'"; |
@@ -8,7 +8,8 @@ discard block |
||
8 | 8 | |
9 | 9 | class PageCustomize extends Page |
10 | 10 | { |
11 | - private function isChecked ($key, $testedValue = 1) { |
|
11 | + private function isChecked ($key, $testedValue = 1) |
|
12 | + { |
|
12 | 13 | $value = getCurrentOption ($key); |
13 | 14 | if (is_array ($value)) { |
14 | 15 | if (in_array ($testedValue, $value)) { |
@@ -22,14 +23,16 @@ discard block |
||
22 | 23 | return ""; |
23 | 24 | } |
24 | 25 | |
25 | - private function isSelected ($key, $value) { |
|
26 | + private function isSelected ($key, $value) |
|
27 | + { |
|
26 | 28 | if (getCurrentOption ($key) == $value) { |
27 | 29 | return "selected='selected'"; |
28 | 30 | } |
29 | 31 | return ""; |
30 | 32 | } |
31 | 33 | |
32 | - private function getStyleList () { |
|
34 | + private function getStyleList () |
|
35 | + { |
|
33 | 36 | $result = array (); |
34 | 37 | foreach (glob ("templates/" . getCurrentTemplate () . "/styles/style-*.css") as $filename) { |
35 | 38 | if (preg_match ('/styles\/style-(.*?)\.css/', $filename, $m)) { |
@@ -38,6 +38,9 @@ |
||
38 | 38 | return self::getEntryArray (self::SQL_ALL_RATINGS, array ()); |
39 | 39 | } |
40 | 40 | |
41 | + /** |
|
42 | + * @param string $query |
|
43 | + */ |
|
41 | 44 | public static function getEntryArray ($query, $params) { |
42 | 45 | list (, $result) = parent::executeQuery ($query, self::RATING_COLUMNS, "", $params, -1); |
43 | 46 | $entryArray = array(); |
@@ -15,33 +15,38 @@ discard block |
||
15 | 15 | public $id; |
16 | 16 | public $name; |
17 | 17 | |
18 | - public function __construct($pid, $pname) { |
|
18 | + public function __construct($pid, $pname) |
|
19 | + { |
|
19 | 20 | $this->id = $pid; |
20 | 21 | $this->name = $pname; |
21 | 22 | } |
22 | 23 | |
23 | - public function getUri () { |
|
24 | + public function getUri () |
|
25 | + { |
|
24 | 26 | return "?page=".parent::PAGE_RATING_DETAIL."&id=$this->id"; |
25 | 27 | } |
26 | 28 | |
27 | - public function getEntryId () { |
|
29 | + public function getEntryId () |
|
30 | + { |
|
28 | 31 | return self::ALL_RATING_ID.":".$this->id; |
29 | 32 | } |
30 | 33 | |
31 | - public static function getCount() { |
|
34 | + public static function getCount() |
|
35 | + { |
|
32 | 36 | // str_format (localize("ratings", count(array)) |
33 | 37 | return parent::getCountGeneric ("ratings", self::ALL_RATING_ID, parent::PAGE_ALL_RATINGS, "ratings"); |
34 | 38 | } |
35 | 39 | |
36 | - public static function getAllRatings() { |
|
40 | + public static function getAllRatings() |
|
41 | + { |
|
37 | 42 | return self::getEntryArray (self::SQL_ALL_RATINGS, array ()); |
38 | 43 | } |
39 | 44 | |
40 | - public static function getEntryArray ($query, $params) { |
|
45 | + public static function getEntryArray ($query, $params) |
|
46 | + { |
|
41 | 47 | list (, $result) = parent::executeQuery ($query, self::RATING_COLUMNS, "", $params, -1); |
42 | 48 | $entryArray = array(); |
43 | - while ($post = $result->fetchObject ()) |
|
44 | - { |
|
49 | + while ($post = $result->fetchObject ()) { |
|
45 | 50 | $ratingObj = new Rating ($post->id, $post->rating); |
46 | 51 | $rating=$post->rating/2; |
47 | 52 | $rating = str_format (localize("ratingword", $rating), $rating); |
@@ -52,7 +57,8 @@ discard block |
||
52 | 57 | return $entryArray; |
53 | 58 | } |
54 | 59 | |
55 | - public static function getRatingById ($ratingId) { |
|
60 | + public static function getRatingById ($ratingId) |
|
61 | + { |
|
56 | 62 | $result = parent::getDb ()->prepare('select rating from ratings where id = ?'); |
57 | 63 | $result->execute (array ($ratingId)); |
58 | 64 | return new Rating ($ratingId, $result->fetchColumn ()); |