@@ -8,19 +8,19 @@ discard block |
||
| 8 | 8 | |
| 9 | 9 | require_once 'config.php'; |
| 10 | 10 | |
| 11 | -define ("VERSION", "1.0.0RC4"); |
|
| 12 | -define ("DB", "db"); |
|
| 11 | +define("VERSION", "1.0.0RC4"); |
|
| 12 | +define("DB", "db"); |
|
| 13 | 13 | date_default_timezone_set($config['default_timezone']); |
| 14 | 14 | |
| 15 | 15 | |
| 16 | -function useServerSideRendering () { |
|
| 16 | +function useServerSideRendering() { |
|
| 17 | 17 | global $config; |
| 18 | 18 | return preg_match("/" . $config['cops_server_side_render'] . "/", $_SERVER['HTTP_USER_AGENT']); |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | -function serverSideRender ($data) { |
|
| 21 | +function serverSideRender($data) { |
|
| 22 | 22 | // Get the templates |
| 23 | - $theme = getCurrentTemplate (); |
|
| 23 | + $theme = getCurrentTemplate(); |
|
| 24 | 24 | $header = file_get_contents('templates/' . $theme . '/header.html'); |
| 25 | 25 | $footer = file_get_contents('templates/' . $theme . '/footer.html'); |
| 26 | 26 | $main = file_get_contents('templates/' . $theme . '/main.html'); |
@@ -28,8 +28,8 @@ discard block |
||
| 28 | 28 | $page = file_get_contents('templates/' . $theme . '/page.html'); |
| 29 | 29 | |
| 30 | 30 | // Generate the function for the template |
| 31 | - $template = new doT (); |
|
| 32 | - $dot = $template->template ($page, array ("bookdetail" => $bookdetail, |
|
| 31 | + $template = new doT(); |
|
| 32 | + $dot = $template->template($page, array("bookdetail" => $bookdetail, |
|
| 33 | 33 | "header" => $header, |
| 34 | 34 | "footer" => $footer, |
| 35 | 35 | "main" => $main)); |
@@ -40,38 +40,38 @@ discard block |
||
| 40 | 40 | } |
| 41 | 41 | // Execute the template |
| 42 | 42 | if (!empty ($data)) { |
| 43 | - return $dot ($data); |
|
| 43 | + return $dot($data); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | return NULL; |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | -function getQueryString () { |
|
| 50 | - if ( isset($_SERVER['QUERY_STRING']) ) { |
|
| 49 | +function getQueryString() { |
|
| 50 | + if (isset($_SERVER['QUERY_STRING'])) { |
|
| 51 | 51 | return $_SERVER['QUERY_STRING']; |
| 52 | 52 | } |
| 53 | 53 | return ""; |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | -function notFound () { |
|
| 57 | - header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found"); |
|
| 56 | +function notFound() { |
|
| 57 | + header($_SERVER["SERVER_PROTOCOL"] . " 404 Not Found"); |
|
| 58 | 58 | header("Status: 404 Not Found"); |
| 59 | 59 | |
| 60 | 60 | $_SERVER['REDIRECT_STATUS'] = 404; |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | -function getURLParam ($name, $default = NULL) { |
|
| 63 | +function getURLParam($name, $default = NULL) { |
|
| 64 | 64 | if (!empty ($_GET) && isset($_GET[$name]) && $_GET[$name] != "") { |
| 65 | 65 | return $_GET[$name]; |
| 66 | 66 | } |
| 67 | 67 | return $default; |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | -function getCurrentOption ($option) { |
|
| 70 | +function getCurrentOption($option) { |
|
| 71 | 71 | global $config; |
| 72 | 72 | if (isset($_COOKIE[$option])) { |
| 73 | - if (isset($config ["cops_" . $option]) && is_array ($config ["cops_" . $option])) { |
|
| 74 | - return explode (",", $_COOKIE[$option]); |
|
| 73 | + if (isset($config ["cops_" . $option]) && is_array($config ["cops_" . $option])) { |
|
| 74 | + return explode(",", $_COOKIE[$option]); |
|
| 75 | 75 | } else { |
| 76 | 76 | return $_COOKIE[$option]; |
| 77 | 77 | } |
@@ -83,15 +83,15 @@ discard block |
||
| 83 | 83 | return ""; |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | -function getCurrentCss () { |
|
| 87 | - return "templates/" . getCurrentTemplate () . "/styles/style-" . getCurrentOption ("style") . ".css"; |
|
| 86 | +function getCurrentCss() { |
|
| 87 | + return "templates/" . getCurrentTemplate() . "/styles/style-" . getCurrentOption("style") . ".css"; |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | -function getCurrentTemplate () { |
|
| 91 | - return getCurrentOption ("template"); |
|
| 90 | +function getCurrentTemplate() { |
|
| 91 | + return getCurrentOption("template"); |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | -function getUrlWithVersion ($url) { |
|
| 94 | +function getUrlWithVersion($url) { |
|
| 95 | 95 | return $url . "?v=" . VERSION; |
| 96 | 96 | } |
| 97 | 97 | |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | return "$return\n\n--------------------------------------------\n\n"; |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | -function are_libxml_errors_ok () |
|
| 133 | +function are_libxml_errors_ok() |
|
| 134 | 134 | { |
| 135 | 135 | $errors = libxml_get_errors(); |
| 136 | 136 | |
@@ -140,15 +140,15 @@ discard block |
||
| 140 | 140 | return true; |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | -function html2xhtml ($html) { |
|
| 143 | +function html2xhtml($html) { |
|
| 144 | 144 | $doc = new DOMDocument(); |
| 145 | 145 | libxml_use_internal_errors(true); |
| 146 | 146 | |
| 147 | 147 | $doc->loadHTML('<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body>' . |
| 148 | - $html . '</body></html>'); // Load the HTML |
|
| 148 | + $html . '</body></html>'); // Load the HTML |
|
| 149 | 149 | $output = $doc->saveXML($doc->documentElement); // Transform to an Ansi xml stream |
| 150 | 150 | $output = xml2xhtml($output); |
| 151 | - if (preg_match ('#<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></meta></head><body>(.*)</body></html>#ms', $output, $matches)) { |
|
| 151 | + if (preg_match('#<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></meta></head><body>(.*)</body></html>#ms', $output, $matches)) { |
|
| 152 | 152 | $output = $matches [1]; // Remove <html><body> |
| 153 | 153 | } |
| 154 | 154 | /* |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | } |
| 161 | 161 | */ |
| 162 | 162 | |
| 163 | - if (!are_libxml_errors_ok ()) $output = "HTML code not valid."; |
|
| 163 | + if (!are_libxml_errors_ok()) $output = "HTML code not valid."; |
|
| 164 | 164 | |
| 165 | 165 | libxml_use_internal_errors(false); |
| 166 | 166 | return $output; |
@@ -246,7 +246,7 @@ discard block |
||
| 246 | 246 | //echo var_dump($langs); |
| 247 | 247 | $lang_file = NULL; |
| 248 | 248 | foreach ($langs as $language => $val) { |
| 249 | - $temp_file = dirname(__FILE__). '/lang/Localization_' . $language . '.json'; |
|
| 249 | + $temp_file = dirname(__FILE__) . '/lang/Localization_' . $language . '.json'; |
|
| 250 | 250 | if (file_exists($temp_file)) { |
| 251 | 251 | $lang = $language; |
| 252 | 252 | $lang_file = $temp_file; |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | } |
| 255 | 255 | } |
| 256 | 256 | if (empty ($lang_file)) { |
| 257 | - $lang_file = dirname(__FILE__). '/lang/Localization_' . $lang . '.json'; |
|
| 257 | + $lang_file = dirname(__FILE__) . '/lang/Localization_' . $lang . '.json'; |
|
| 258 | 258 | } |
| 259 | 259 | return array($lang, $lang_file); |
| 260 | 260 | } |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | * This method is based on this page |
| 264 | 264 | * http://www.mind-it.info/2010/02/22/a-simple-approach-to-localization-in-php/ |
| 265 | 265 | */ |
| 266 | -function localize($phrase, $count=-1, $reset=false) { |
|
| 266 | +function localize($phrase, $count = -1, $reset = false) { |
|
| 267 | 267 | global $config; |
| 268 | 268 | if ($count == 0) |
| 269 | 269 | $phrase .= ".none"; |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | $lang_file_en = NULL; |
| 283 | 283 | list ($lang, $lang_file) = getLangAndTranslationFile(); |
| 284 | 284 | if ($lang != "en") { |
| 285 | - $lang_file_en = dirname(__FILE__). '/lang/' . 'Localization_en.json'; |
|
| 285 | + $lang_file_en = dirname(__FILE__) . '/lang/' . 'Localization_en.json'; |
|
| 286 | 286 | } |
| 287 | 287 | |
| 288 | 288 | $lang_file_content = file_get_contents($lang_file); |
@@ -290,8 +290,8 @@ discard block |
||
| 290 | 290 | $translations = json_decode($lang_file_content, true); |
| 291 | 291 | |
| 292 | 292 | /* Clean the array of all unfinished translations */ |
| 293 | - foreach (array_keys ($translations) as $key) { |
|
| 294 | - if (preg_match ("/^##TODO##/", $key)) { |
|
| 293 | + foreach (array_keys($translations) as $key) { |
|
| 294 | + if (preg_match("/^##TODO##/", $key)) { |
|
| 295 | 295 | unset ($translations [$key]); |
| 296 | 296 | } |
| 297 | 297 | } |
@@ -299,10 +299,10 @@ discard block |
||
| 299 | 299 | { |
| 300 | 300 | $lang_file_content = file_get_contents($lang_file_en); |
| 301 | 301 | $translations_en = json_decode($lang_file_content, true); |
| 302 | - $translations = array_merge ($translations_en, $translations); |
|
| 302 | + $translations = array_merge($translations_en, $translations); |
|
| 303 | 303 | } |
| 304 | 304 | } |
| 305 | - if (array_key_exists ($phrase, $translations)) { |
|
| 305 | + if (array_key_exists($phrase, $translations)) { |
|
| 306 | 306 | return $translations[$phrase]; |
| 307 | 307 | } |
| 308 | 308 | return $phrase; |
@@ -313,7 +313,7 @@ discard block |
||
| 313 | 313 | $urlParams = ""; |
| 314 | 314 | } |
| 315 | 315 | $start = ""; |
| 316 | - if (preg_match ("#^\?(.*)#", $urlParams, $matches)) { |
|
| 316 | + if (preg_match("#^\?(.*)#", $urlParams, $matches)) { |
|
| 317 | 317 | $start = "?"; |
| 318 | 318 | $urlParams = $matches[1]; |
| 319 | 319 | } |
@@ -327,16 +327,16 @@ discard block |
||
| 327 | 327 | return $start . http_build_query($params); |
| 328 | 328 | } |
| 329 | 329 | |
| 330 | -function useNormAndUp () { |
|
| 330 | +function useNormAndUp() { |
|
| 331 | 331 | global $config; |
| 332 | 332 | return $config ['cops_normalized_search'] == "1"; |
| 333 | 333 | } |
| 334 | 334 | |
| 335 | -function normalizeUtf8String( $s) { |
|
| 335 | +function normalizeUtf8String($s) { |
|
| 336 | 336 | include_once 'transliteration.php'; |
| 337 | 337 | return _transliteration_process($s); |
| 338 | 338 | } |
| 339 | 339 | |
| 340 | -function normAndUp ($s) { |
|
| 341 | - return mb_strtoupper (normalizeUtf8String($s), 'UTF-8'); |
|
| 340 | +function normAndUp($s) { |
|
| 341 | + return mb_strtoupper(normalizeUtf8String($s), 'UTF-8'); |
|
| 342 | 342 | } |
@@ -15,16 +15,16 @@ discard block |
||
| 15 | 15 | const SCOPE_BOOK = "book"; |
| 16 | 16 | const SCOPE_PUBLISHER = "publisher"; |
| 17 | 17 | |
| 18 | - private function useTypeahead () { |
|
| 19 | - return !is_null (getURLParam ("search")); |
|
| 18 | + private function useTypeahead() { |
|
| 19 | + return !is_null(getURLParam("search")); |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | - private function searchByScope ($scope, $limit = FALSE) { |
|
| 22 | + private function searchByScope($scope, $limit = FALSE) { |
|
| 23 | 23 | $n = $this->n; |
| 24 | 24 | $numberPerPage = NULL; |
| 25 | 25 | $queryNormedAndUp = $this->query; |
| 26 | - if (useNormAndUp ()) { |
|
| 27 | - $queryNormedAndUp = normAndUp ($this->query); |
|
| 26 | + if (useNormAndUp()) { |
|
| 27 | + $queryNormedAndUp = normAndUp($this->query); |
|
| 28 | 28 | } |
| 29 | 29 | if ($limit) { |
| 30 | 30 | $n = 1; |
@@ -32,59 +32,59 @@ discard block |
||
| 32 | 32 | } |
| 33 | 33 | switch ($scope) { |
| 34 | 34 | case self::SCOPE_BOOK : |
| 35 | - $array = Book::getBooksByStartingLetter ('%' . $queryNormedAndUp, $n, NULL, $numberPerPage); |
|
| 35 | + $array = Book::getBooksByStartingLetter('%' . $queryNormedAndUp, $n, NULL, $numberPerPage); |
|
| 36 | 36 | break; |
| 37 | 37 | case self::SCOPE_AUTHOR : |
| 38 | - $array = Author::getAuthorsForSearch ('%' . $queryNormedAndUp); |
|
| 38 | + $array = Author::getAuthorsForSearch('%' . $queryNormedAndUp); |
|
| 39 | 39 | break; |
| 40 | 40 | case self::SCOPE_SERIES : |
| 41 | - $array = Serie::getAllSeriesByQuery ($queryNormedAndUp); |
|
| 41 | + $array = Serie::getAllSeriesByQuery($queryNormedAndUp); |
|
| 42 | 42 | break; |
| 43 | 43 | case self::SCOPE_TAG : |
| 44 | - $array = Tag::getAllTagsByQuery ($queryNormedAndUp, $n, NULL, $numberPerPage); |
|
| 44 | + $array = Tag::getAllTagsByQuery($queryNormedAndUp, $n, NULL, $numberPerPage); |
|
| 45 | 45 | break; |
| 46 | 46 | case self::SCOPE_PUBLISHER : |
| 47 | - $array = Publisher::getAllPublishersByQuery ($queryNormedAndUp); |
|
| 47 | + $array = Publisher::getAllPublishersByQuery($queryNormedAndUp); |
|
| 48 | 48 | break; |
| 49 | 49 | default: |
| 50 | - $array = Book::getBooksByQuery ( |
|
| 51 | - array ("all" => "%" . $queryNormedAndUp . "%"), $n); |
|
| 50 | + $array = Book::getBooksByQuery( |
|
| 51 | + array("all" => "%" . $queryNormedAndUp . "%"), $n); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | return $array; |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - public function doSearchByCategory () { |
|
| 58 | - $database = GetUrlParam (DB); |
|
| 59 | - $out = array (); |
|
| 57 | + public function doSearchByCategory() { |
|
| 58 | + $database = GetUrlParam(DB); |
|
| 59 | + $out = array(); |
|
| 60 | 60 | $pagequery = Base::PAGE_OPENSEARCH_QUERY; |
| 61 | - $dbArray = array (""); |
|
| 61 | + $dbArray = array(""); |
|
| 62 | 62 | $d = $database; |
| 63 | 63 | $query = $this->query; |
| 64 | 64 | // Special case when no databases were chosen, we search on all databases |
| 65 | - if (Base::noDatabaseSelected ()) { |
|
| 66 | - $dbArray = Base::getDbNameList (); |
|
| 65 | + if (Base::noDatabaseSelected()) { |
|
| 66 | + $dbArray = Base::getDbNameList(); |
|
| 67 | 67 | $d = 0; |
| 68 | 68 | } |
| 69 | 69 | foreach ($dbArray as $key) { |
| 70 | - if (Base::noDatabaseSelected ()) { |
|
| 71 | - array_push ($this->entryArray, new Entry ($key, DB . ":query:{$d}", |
|
| 70 | + if (Base::noDatabaseSelected()) { |
|
| 71 | + array_push($this->entryArray, new Entry($key, DB . ":query:{$d}", |
|
| 72 | 72 | " ", "text", |
| 73 | - array ( new LinkNavigation ("?" . DB . "={$d}")), "tt-header")); |
|
| 74 | - Base::getDb ($d); |
|
| 73 | + array(new LinkNavigation("?" . DB . "={$d}")), "tt-header")); |
|
| 74 | + Base::getDb($d); |
|
| 75 | 75 | } |
| 76 | - foreach (array (PageQueryResult::SCOPE_BOOK, |
|
| 76 | + foreach (array(PageQueryResult::SCOPE_BOOK, |
|
| 77 | 77 | PageQueryResult::SCOPE_AUTHOR, |
| 78 | 78 | PageQueryResult::SCOPE_SERIES, |
| 79 | 79 | PageQueryResult::SCOPE_TAG, |
| 80 | 80 | PageQueryResult::SCOPE_PUBLISHER) as $key) { |
| 81 | - if (in_array($key, getCurrentOption ('ignored_categories'))) { |
|
| 81 | + if (in_array($key, getCurrentOption('ignored_categories'))) { |
|
| 82 | 82 | continue; |
| 83 | 83 | } |
| 84 | - $array = $this->searchByScope ($key, TRUE); |
|
| 84 | + $array = $this->searchByScope($key, TRUE); |
|
| 85 | 85 | |
| 86 | 86 | $i = 0; |
| 87 | - if (count ($array) == 2 && is_array ($array [0])) { |
|
| 87 | + if (count($array) == 2 && is_array($array [0])) { |
|
| 88 | 88 | $total = $array [1]; |
| 89 | 89 | $array = $array [0]; |
| 90 | 90 | } else { |
@@ -97,32 +97,32 @@ discard block |
||
| 97 | 97 | // str_format (localize("seriesword", count($array)) |
| 98 | 98 | // str_format (localize("tagword", count($array)) |
| 99 | 99 | // str_format (localize("publisherword", count($array)) |
| 100 | - array_push ($this->entryArray, new Entry (str_format (localize ("search.result.{$key}"), $this->query), DB . ":query:{$d}:{$key}", |
|
| 101 | - str_format (localize("{$key}word", $total), $total), "text", |
|
| 102 | - array ( new LinkNavigation ("?page={$pagequery}&query={$query}&db={$d}&scope={$key}")), |
|
| 103 | - Base::noDatabaseSelected () ? "" : "tt-header", $total)); |
|
| 100 | + array_push($this->entryArray, new Entry(str_format(localize("search.result.{$key}"), $this->query), DB . ":query:{$d}:{$key}", |
|
| 101 | + str_format(localize("{$key}word", $total), $total), "text", |
|
| 102 | + array(new LinkNavigation("?page={$pagequery}&query={$query}&db={$d}&scope={$key}")), |
|
| 103 | + Base::noDatabaseSelected()?"":"tt-header", $total)); |
|
| 104 | 104 | } |
| 105 | - if (!Base::noDatabaseSelected () && $this->useTypeahead ()) { |
|
| 105 | + if (!Base::noDatabaseSelected() && $this->useTypeahead()) { |
|
| 106 | 106 | foreach ($array as $entry) { |
| 107 | - array_push ($this->entryArray, $entry); |
|
| 107 | + array_push($this->entryArray, $entry); |
|
| 108 | 108 | $i++; |
| 109 | 109 | if ($i > 4) { break; }; |
| 110 | 110 | } |
| 111 | 111 | } |
| 112 | 112 | } |
| 113 | 113 | $d++; |
| 114 | - if (Base::noDatabaseSelected ()) { |
|
| 115 | - Base::clearDb (); |
|
| 114 | + if (Base::noDatabaseSelected()) { |
|
| 115 | + Base::clearDb(); |
|
| 116 | 116 | } |
| 117 | 117 | } |
| 118 | 118 | return $out; |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | - public function InitializeContent () |
|
| 121 | + public function InitializeContent() |
|
| 122 | 122 | { |
| 123 | - $scope = getURLParam ("scope"); |
|
| 123 | + $scope = getURLParam("scope"); |
|
| 124 | 124 | if (empty ($scope)) { |
| 125 | - $this->title = str_format (localize ("search.result"), $this->query); |
|
| 125 | + $this->title = str_format(localize("search.result"), $this->query); |
|
| 126 | 126 | } else { |
| 127 | 127 | // Comment to help the perl i18n script |
| 128 | 128 | // str_format (localize ("search.result.author"), $this->query) |
@@ -130,31 +130,31 @@ discard block |
||
| 130 | 130 | // str_format (localize ("search.result.series"), $this->query) |
| 131 | 131 | // str_format (localize ("search.result.book"), $this->query) |
| 132 | 132 | // str_format (localize ("search.result.publisher"), $this->query) |
| 133 | - $this->title = str_format (localize ("search.result.{$scope}"), $this->query); |
|
| 133 | + $this->title = str_format(localize("search.result.{$scope}"), $this->query); |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | $crit = "%" . $this->query . "%"; |
| 137 | 137 | |
| 138 | 138 | // Special case when we are doing a search and no database is selected |
| 139 | - if (Base::noDatabaseSelected () && !$this->useTypeahead ()) { |
|
| 139 | + if (Base::noDatabaseSelected() && !$this->useTypeahead()) { |
|
| 140 | 140 | $i = 0; |
| 141 | - foreach (Base::getDbNameList () as $key) { |
|
| 142 | - Base::clearDb (); |
|
| 143 | - list ($array, $totalNumber) = Book::getBooksByQuery (array ("all" => $crit), 1, $i, 1); |
|
| 144 | - array_push ($this->entryArray, new Entry ($key, DB . ":query:{$i}", |
|
| 145 | - str_format (localize ("bookword", $totalNumber), $totalNumber), "text", |
|
| 146 | - array ( new LinkNavigation ("?" . DB . "={$i}&page=9&query=" . $this->query)), "", $totalNumber)); |
|
| 141 | + foreach (Base::getDbNameList() as $key) { |
|
| 142 | + Base::clearDb(); |
|
| 143 | + list ($array, $totalNumber) = Book::getBooksByQuery(array("all" => $crit), 1, $i, 1); |
|
| 144 | + array_push($this->entryArray, new Entry($key, DB . ":query:{$i}", |
|
| 145 | + str_format(localize("bookword", $totalNumber), $totalNumber), "text", |
|
| 146 | + array(new LinkNavigation("?" . DB . "={$i}&page=9&query=" . $this->query)), "", $totalNumber)); |
|
| 147 | 147 | $i++; |
| 148 | 148 | } |
| 149 | 149 | return; |
| 150 | 150 | } |
| 151 | 151 | if (empty ($scope)) { |
| 152 | - $this->doSearchByCategory (); |
|
| 152 | + $this->doSearchByCategory(); |
|
| 153 | 153 | return; |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | - $array = $this->searchByScope ($scope); |
|
| 157 | - if (count ($array) == 2 && is_array ($array [0])) { |
|
| 156 | + $array = $this->searchByScope($scope); |
|
| 157 | + if (count($array) == 2 && is_array($array [0])) { |
|
| 158 | 158 | list ($this->entryArray, $this->totalNumber) = $array; |
| 159 | 159 | } else { |
| 160 | 160 | $this->entryArray = $array; |
@@ -8,12 +8,12 @@ |
||
| 8 | 8 | |
| 9 | 9 | class PageCustomDetail extends Page |
| 10 | 10 | { |
| 11 | - public function InitializeContent () |
|
| 11 | + public function InitializeContent() |
|
| 12 | 12 | { |
| 13 | - $customId = getURLParam ("custom", NULL); |
|
| 14 | - $custom = CustomColumn::getCustomById ($customId, $this->idGet); |
|
| 15 | - $this->idPage = $custom->getEntryId (); |
|
| 13 | + $customId = getURLParam("custom", NULL); |
|
| 14 | + $custom = CustomColumn::getCustomById($customId, $this->idGet); |
|
| 15 | + $this->idPage = $custom->getEntryId(); |
|
| 16 | 16 | $this->title = $custom->name; |
| 17 | - list ($this->entryArray, $this->totalNumber) = Book::getBooksByCustom ($customId, $this->idGet, $this->n); |
|
| 17 | + list ($this->entryArray, $this->totalNumber) = Book::getBooksByCustom($customId, $this->idGet, $this->n); |
|
| 18 | 18 | } |
| 19 | 19 | } |
@@ -8,9 +8,9 @@ |
||
| 8 | 8 | |
| 9 | 9 | class PageBookDetail extends Page |
| 10 | 10 | { |
| 11 | - public function InitializeContent () |
|
| 11 | + public function InitializeContent() |
|
| 12 | 12 | { |
| 13 | - $this->book = Book::getBookById ($this->idGet); |
|
| 13 | + $this->book = Book::getBookById($this->idGet); |
|
| 14 | 14 | $this->title = $this->book->title; |
| 15 | 15 | } |
| 16 | 16 | } |
@@ -8,7 +8,7 @@ |
||
| 8 | 8 | |
| 9 | 9 | class PageAllRating extends Page |
| 10 | 10 | { |
| 11 | - public function InitializeContent () |
|
| 11 | + public function InitializeContent() |
|
| 12 | 12 | { |
| 13 | 13 | $this->title = localize("ratings.title"); |
| 14 | 14 | $this->entryArray = Rating::getAllRatings(); |
@@ -22,55 +22,55 @@ discard block |
||
| 22 | 22 | public $totalNumber = -1; |
| 23 | 23 | public $entryArray = array(); |
| 24 | 24 | |
| 25 | - public static function getPage ($pageId, $id, $query, $n) |
|
| 25 | + public static function getPage($pageId, $id, $query, $n) |
|
| 26 | 26 | { |
| 27 | 27 | switch ($pageId) { |
| 28 | 28 | case Base::PAGE_ALL_AUTHORS : |
| 29 | - return new PageAllAuthors ($id, $query, $n); |
|
| 29 | + return new PageAllAuthors($id, $query, $n); |
|
| 30 | 30 | case Base::PAGE_AUTHORS_FIRST_LETTER : |
| 31 | - return new PageAllAuthorsLetter ($id, $query, $n); |
|
| 31 | + return new PageAllAuthorsLetter($id, $query, $n); |
|
| 32 | 32 | case Base::PAGE_AUTHOR_DETAIL : |
| 33 | - return new PageAuthorDetail ($id, $query, $n); |
|
| 33 | + return new PageAuthorDetail($id, $query, $n); |
|
| 34 | 34 | case Base::PAGE_ALL_TAGS : |
| 35 | - return new PageAllTags ($id, $query, $n); |
|
| 35 | + return new PageAllTags($id, $query, $n); |
|
| 36 | 36 | case Base::PAGE_TAG_DETAIL : |
| 37 | - return new PageTagDetail ($id, $query, $n); |
|
| 37 | + return new PageTagDetail($id, $query, $n); |
|
| 38 | 38 | case Base::PAGE_ALL_LANGUAGES : |
| 39 | - return new PageAllLanguages ($id, $query, $n); |
|
| 39 | + return new PageAllLanguages($id, $query, $n); |
|
| 40 | 40 | case Base::PAGE_LANGUAGE_DETAIL : |
| 41 | - return new PageLanguageDetail ($id, $query, $n); |
|
| 41 | + return new PageLanguageDetail($id, $query, $n); |
|
| 42 | 42 | case Base::PAGE_ALL_CUSTOMS : |
| 43 | - return new PageAllCustoms ($id, $query, $n); |
|
| 43 | + return new PageAllCustoms($id, $query, $n); |
|
| 44 | 44 | case Base::PAGE_CUSTOM_DETAIL : |
| 45 | - return new PageCustomDetail ($id, $query, $n); |
|
| 45 | + return new PageCustomDetail($id, $query, $n); |
|
| 46 | 46 | case Base::PAGE_ALL_RATINGS : |
| 47 | - return new PageAllRating ($id, $query, $n); |
|
| 47 | + return new PageAllRating($id, $query, $n); |
|
| 48 | 48 | case Base::PAGE_RATING_DETAIL : |
| 49 | - return new PageRatingDetail ($id, $query, $n); |
|
| 49 | + return new PageRatingDetail($id, $query, $n); |
|
| 50 | 50 | case Base::PAGE_ALL_SERIES : |
| 51 | - return new PageAllSeries ($id, $query, $n); |
|
| 51 | + return new PageAllSeries($id, $query, $n); |
|
| 52 | 52 | case Base::PAGE_ALL_BOOKS : |
| 53 | - return new PageAllBooks ($id, $query, $n); |
|
| 53 | + return new PageAllBooks($id, $query, $n); |
|
| 54 | 54 | case Base::PAGE_ALL_BOOKS_LETTER: |
| 55 | - return new PageAllBooksLetter ($id, $query, $n); |
|
| 55 | + return new PageAllBooksLetter($id, $query, $n); |
|
| 56 | 56 | case Base::PAGE_ALL_RECENT_BOOKS : |
| 57 | - return new PageRecentBooks ($id, $query, $n); |
|
| 57 | + return new PageRecentBooks($id, $query, $n); |
|
| 58 | 58 | case Base::PAGE_SERIE_DETAIL : |
| 59 | - return new PageSerieDetail ($id, $query, $n); |
|
| 59 | + return new PageSerieDetail($id, $query, $n); |
|
| 60 | 60 | case Base::PAGE_OPENSEARCH_QUERY : |
| 61 | - return new PageQueryResult ($id, $query, $n); |
|
| 61 | + return new PageQueryResult($id, $query, $n); |
|
| 62 | 62 | case Base::PAGE_BOOK_DETAIL : |
| 63 | - return new PageBookDetail ($id, $query, $n); |
|
| 63 | + return new PageBookDetail($id, $query, $n); |
|
| 64 | 64 | case Base::PAGE_ALL_PUBLISHERS: |
| 65 | - return new PageAllPublishers ($id, $query, $n); |
|
| 65 | + return new PageAllPublishers($id, $query, $n); |
|
| 66 | 66 | case Base::PAGE_PUBLISHER_DETAIL : |
| 67 | - return new PagePublisherDetail ($id, $query, $n); |
|
| 67 | + return new PagePublisherDetail($id, $query, $n); |
|
| 68 | 68 | case Base::PAGE_ABOUT : |
| 69 | - return new PageAbout ($id, $query, $n); |
|
| 69 | + return new PageAbout($id, $query, $n); |
|
| 70 | 70 | case Base::PAGE_CUSTOMIZE : |
| 71 | - return new PageCustomize ($id, $query, $n); |
|
| 71 | + return new PageCustomize($id, $query, $n); |
|
| 72 | 72 | default: |
| 73 | - $page = new Page ($id, $query, $n); |
|
| 73 | + $page = new Page($id, $query, $n); |
|
| 74 | 74 | $page->idPage = "cops:catalog"; |
| 75 | 75 | return $page; |
| 76 | 76 | } |
@@ -83,96 +83,96 @@ discard block |
||
| 83 | 83 | $this->query = $pquery; |
| 84 | 84 | $this->n = $pn; |
| 85 | 85 | $this->favicon = $config['cops_icon']; |
| 86 | - $this->authorName = empty($config['cops_author_name']) ? utf8_encode('Sébastien Lucas') : $config['cops_author_name']; |
|
| 87 | - $this->authorUri = empty($config['cops_author_uri']) ? 'http://blog.slucas.fr' : $config['cops_author_uri']; |
|
| 88 | - $this->authorEmail = empty($config['cops_author_email']) ? '[email protected]' : $config['cops_author_email']; |
|
| 86 | + $this->authorName = empty($config['cops_author_name'])?utf8_encode('Sébastien Lucas'):$config['cops_author_name']; |
|
| 87 | + $this->authorUri = empty($config['cops_author_uri'])?'http://blog.slucas.fr':$config['cops_author_uri']; |
|
| 88 | + $this->authorEmail = empty($config['cops_author_email'])?'[email protected]':$config['cops_author_email']; |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - public function InitializeContent () |
|
| 91 | + public function InitializeContent() |
|
| 92 | 92 | { |
| 93 | 93 | global $config; |
| 94 | 94 | $this->title = $config['cops_title_default']; |
| 95 | 95 | $this->subtitle = $config['cops_subtitle_default']; |
| 96 | - if (Base::noDatabaseSelected ()) { |
|
| 96 | + if (Base::noDatabaseSelected()) { |
|
| 97 | 97 | $i = 0; |
| 98 | - foreach (Base::getDbNameList () as $key) { |
|
| 99 | - $nBooks = Book::getBookCount ($i); |
|
| 100 | - array_push ($this->entryArray, new Entry ($key, "cops:{$i}:catalog", |
|
| 101 | - str_format (localize ("bookword", $nBooks), $nBooks), "text", |
|
| 102 | - array ( new LinkNavigation ("?" . DB . "={$i}")), "", $nBooks)); |
|
| 98 | + foreach (Base::getDbNameList() as $key) { |
|
| 99 | + $nBooks = Book::getBookCount($i); |
|
| 100 | + array_push($this->entryArray, new Entry($key, "cops:{$i}:catalog", |
|
| 101 | + str_format(localize("bookword", $nBooks), $nBooks), "text", |
|
| 102 | + array(new LinkNavigation("?" . DB . "={$i}")), "", $nBooks)); |
|
| 103 | 103 | $i++; |
| 104 | - Base::clearDb (); |
|
| 104 | + Base::clearDb(); |
|
| 105 | 105 | } |
| 106 | 106 | } else { |
| 107 | - if (!in_array (PageQueryResult::SCOPE_AUTHOR, getCurrentOption ('ignored_categories'))) { |
|
| 108 | - array_push ($this->entryArray, Author::getCount()); |
|
| 107 | + if (!in_array(PageQueryResult::SCOPE_AUTHOR, getCurrentOption('ignored_categories'))) { |
|
| 108 | + array_push($this->entryArray, Author::getCount()); |
|
| 109 | 109 | } |
| 110 | - if (!in_array (PageQueryResult::SCOPE_SERIES, getCurrentOption ('ignored_categories'))) { |
|
| 110 | + if (!in_array(PageQueryResult::SCOPE_SERIES, getCurrentOption('ignored_categories'))) { |
|
| 111 | 111 | $series = Serie::getCount(); |
| 112 | - if (!is_null ($series)) array_push ($this->entryArray, $series); |
|
| 112 | + if (!is_null($series)) array_push($this->entryArray, $series); |
|
| 113 | 113 | } |
| 114 | - if (!in_array (PageQueryResult::SCOPE_PUBLISHER, getCurrentOption ('ignored_categories'))) { |
|
| 114 | + if (!in_array(PageQueryResult::SCOPE_PUBLISHER, getCurrentOption('ignored_categories'))) { |
|
| 115 | 115 | $publisher = Publisher::getCount(); |
| 116 | - if (!is_null ($publisher)) array_push ($this->entryArray, $publisher); |
|
| 116 | + if (!is_null($publisher)) array_push($this->entryArray, $publisher); |
|
| 117 | 117 | } |
| 118 | - if (!in_array (PageQueryResult::SCOPE_TAG, getCurrentOption ('ignored_categories'))) { |
|
| 118 | + if (!in_array(PageQueryResult::SCOPE_TAG, getCurrentOption('ignored_categories'))) { |
|
| 119 | 119 | $tags = Tag::getCount(); |
| 120 | - if (!is_null ($tags)) array_push ($this->entryArray, $tags); |
|
| 120 | + if (!is_null($tags)) array_push($this->entryArray, $tags); |
|
| 121 | 121 | } |
| 122 | - if (!in_array (PageQueryResult::SCOPE_RATING, getCurrentOption ('ignored_categories'))) { |
|
| 122 | + if (!in_array(PageQueryResult::SCOPE_RATING, getCurrentOption('ignored_categories'))) { |
|
| 123 | 123 | $rating = Rating::getCount(); |
| 124 | - if (!is_null ($rating)) array_push ($this->entryArray, $rating); |
|
| 124 | + if (!is_null($rating)) array_push($this->entryArray, $rating); |
|
| 125 | 125 | } |
| 126 | - if (!in_array ("language", getCurrentOption ('ignored_categories'))) { |
|
| 126 | + if (!in_array("language", getCurrentOption('ignored_categories'))) { |
|
| 127 | 127 | $languages = Language::getCount(); |
| 128 | - if (!is_null ($languages)) array_push ($this->entryArray, $languages); |
|
| 128 | + if (!is_null($languages)) array_push($this->entryArray, $languages); |
|
| 129 | 129 | } |
| 130 | 130 | foreach ($config['cops_calibre_custom_column'] as $lookup) { |
| 131 | - $customId = CustomColumn::getCustomId ($lookup); |
|
| 132 | - if (!is_null ($customId)) { |
|
| 133 | - array_push ($this->entryArray, CustomColumn::getCount($customId)); |
|
| 131 | + $customId = CustomColumn::getCustomId($lookup); |
|
| 132 | + if (!is_null($customId)) { |
|
| 133 | + array_push($this->entryArray, CustomColumn::getCount($customId)); |
|
| 134 | 134 | } |
| 135 | 135 | } |
| 136 | - $this->entryArray = array_merge ($this->entryArray, Book::getCount()); |
|
| 136 | + $this->entryArray = array_merge($this->entryArray, Book::getCount()); |
|
| 137 | 137 | |
| 138 | - if (Base::isMultipleDatabaseEnabled ()) $this->title = Base::getDbName (); |
|
| 138 | + if (Base::isMultipleDatabaseEnabled()) $this->title = Base::getDbName(); |
|
| 139 | 139 | } |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | - public function isPaginated () |
|
| 142 | + public function isPaginated() |
|
| 143 | 143 | { |
| 144 | - return (getCurrentOption ("max_item_per_page") != -1 && |
|
| 144 | + return (getCurrentOption("max_item_per_page") != -1 && |
|
| 145 | 145 | $this->totalNumber != -1 && |
| 146 | - $this->totalNumber > getCurrentOption ("max_item_per_page")); |
|
| 146 | + $this->totalNumber > getCurrentOption("max_item_per_page")); |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | - public function getNextLink () |
|
| 149 | + public function getNextLink() |
|
| 150 | 150 | { |
| 151 | - $currentUrl = preg_replace ("/\&n=.*?$/", "", "?" . getQueryString ()); |
|
| 152 | - if (($this->n) * getCurrentOption ("max_item_per_page") < $this->totalNumber) { |
|
| 153 | - return new LinkNavigation ($currentUrl . "&n=" . ($this->n + 1), "next", localize ("paging.next.alternate")); |
|
| 151 | + $currentUrl = preg_replace("/\&n=.*?$/", "", "?" . getQueryString()); |
|
| 152 | + if (($this->n) * getCurrentOption("max_item_per_page") < $this->totalNumber) { |
|
| 153 | + return new LinkNavigation($currentUrl . "&n=" . ($this->n + 1), "next", localize("paging.next.alternate")); |
|
| 154 | 154 | } |
| 155 | 155 | return NULL; |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | - public function getPrevLink () |
|
| 158 | + public function getPrevLink() |
|
| 159 | 159 | { |
| 160 | - $currentUrl = preg_replace ("/\&n=.*?$/", "", "?" . getQueryString ()); |
|
| 160 | + $currentUrl = preg_replace("/\&n=.*?$/", "", "?" . getQueryString()); |
|
| 161 | 161 | if ($this->n > 1) { |
| 162 | - return new LinkNavigation ($currentUrl . "&n=" . ($this->n - 1), "previous", localize ("paging.previous.alternate")); |
|
| 162 | + return new LinkNavigation($currentUrl . "&n=" . ($this->n - 1), "previous", localize("paging.previous.alternate")); |
|
| 163 | 163 | } |
| 164 | 164 | return NULL; |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | - public function getMaxPage () |
|
| 167 | + public function getMaxPage() |
|
| 168 | 168 | { |
| 169 | - return ceil ($this->totalNumber / getCurrentOption ("max_item_per_page")); |
|
| 169 | + return ceil($this->totalNumber / getCurrentOption("max_item_per_page")); |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | - public function containsBook () |
|
| 172 | + public function containsBook() |
|
| 173 | 173 | { |
| 174 | - if (count ($this->entryArray) == 0) return false; |
|
| 175 | - if (get_class ($this->entryArray [0]) == "EntryBook") return true; |
|
| 174 | + if (count($this->entryArray) == 0) return false; |
|
| 175 | + if (get_class($this->entryArray [0]) == "EntryBook") return true; |
|
| 176 | 176 | return false; |
| 177 | 177 | } |
| 178 | 178 | } |
@@ -8,15 +8,15 @@ |
||
| 8 | 8 | |
| 9 | 9 | class PageAllBooksLetter extends Page |
| 10 | 10 | { |
| 11 | - public function InitializeContent () |
|
| 11 | + public function InitializeContent() |
|
| 12 | 12 | { |
| 13 | - list ($this->entryArray, $this->totalNumber) = Book::getBooksByStartingLetter ($this->idGet, $this->n); |
|
| 14 | - $this->idPage = Book::getEntryIdByLetter ($this->idGet); |
|
| 13 | + list ($this->entryArray, $this->totalNumber) = Book::getBooksByStartingLetter($this->idGet, $this->n); |
|
| 14 | + $this->idPage = Book::getEntryIdByLetter($this->idGet); |
|
| 15 | 15 | |
| 16 | 16 | $count = $this->totalNumber; |
| 17 | 17 | if ($count == -1) |
| 18 | - $count = count ($this->entryArray); |
|
| 18 | + $count = count($this->entryArray); |
|
| 19 | 19 | |
| 20 | - $this->title = str_format (localize ("splitByLetter.letter"), str_format (localize ("bookword", $count), $count), $this->idGet); |
|
| 20 | + $this->title = str_format(localize("splitByLetter.letter"), str_format(localize("bookword", $count), $count), $this->idGet); |
|
| 21 | 21 | } |
| 22 | 22 | } |
@@ -8,11 +8,11 @@ |
||
| 8 | 8 | |
| 9 | 9 | class PageLanguageDetail extends Page |
| 10 | 10 | { |
| 11 | - public function InitializeContent () |
|
| 11 | + public function InitializeContent() |
|
| 12 | 12 | { |
| 13 | - $language = Language::getLanguageById ($this->idGet); |
|
| 14 | - $this->idPage = $language->getEntryId (); |
|
| 13 | + $language = Language::getLanguageById($this->idGet); |
|
| 14 | + $this->idPage = $language->getEntryId(); |
|
| 15 | 15 | $this->title = $language->lang_code; |
| 16 | - list ($this->entryArray, $this->totalNumber) = Book::getBooksByLanguage ($this->idGet, $this->n); |
|
| 16 | + list ($this->entryArray, $this->totalNumber) = Book::getBooksByLanguage($this->idGet, $this->n); |
|
| 17 | 17 | } |
| 18 | 18 | } |
@@ -8,10 +8,10 @@ |
||
| 8 | 8 | |
| 9 | 9 | class PageAllAuthorsLetter extends Page |
| 10 | 10 | { |
| 11 | - public function InitializeContent () |
|
| 11 | + public function InitializeContent() |
|
| 12 | 12 | { |
| 13 | - $this->idPage = Author::getEntryIdByLetter ($this->idGet); |
|
| 14 | - $this->entryArray = Author::getAuthorsByStartingLetter ($this->idGet); |
|
| 15 | - $this->title = str_format (localize ("splitByLetter.letter"), str_format (localize ("authorword", count ($this->entryArray)), count ($this->entryArray)), $this->idGet); |
|
| 13 | + $this->idPage = Author::getEntryIdByLetter($this->idGet); |
|
| 14 | + $this->entryArray = Author::getAuthorsByStartingLetter($this->idGet); |
|
| 15 | + $this->title = str_format(localize("splitByLetter.letter"), str_format(localize("authorword", count($this->entryArray)), count($this->entryArray)), $this->idGet); |
|
| 16 | 16 | } |
| 17 | 17 | } |