@@ -60,6 +60,9 @@ discard block |
||
| 60 | 60 | $_SERVER['REDIRECT_STATUS'] = 404; |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | +/** |
|
| 64 | + * @param string $name |
|
| 65 | + */ |
|
| 63 | 66 | function getURLParam ($name, $default = NULL) { |
| 64 | 67 | if (!empty ($_GET) && isset($_GET[$name]) && $_GET[$name] != "") { |
| 65 | 68 | return $_GET[$name]; |
@@ -95,6 +98,11 @@ discard block |
||
| 95 | 98 | return $url . "?v=" . VERSION; |
| 96 | 99 | } |
| 97 | 100 | |
| 101 | +/** |
|
| 102 | + * @param string $xml |
|
| 103 | + * |
|
| 104 | + * @return string |
|
| 105 | + */ |
|
| 98 | 106 | function xml2xhtml($xml) { |
| 99 | 107 | return preg_replace_callback('#<(\w+)([^>]*)\s*/>#s', create_function('$m', ' |
| 100 | 108 | $xhtml_tags = array("br", "hr", "input", "frame", "img", "area", "link", "col", "base", "basefont", "param"); |
@@ -308,6 +316,9 @@ discard block |
||
| 308 | 316 | return $phrase; |
| 309 | 317 | } |
| 310 | 318 | |
| 319 | +/** |
|
| 320 | + * @param string $paramName |
|
| 321 | + */ |
|
| 311 | 322 | function addURLParameter($urlParams, $paramName, $paramValue) { |
| 312 | 323 | if (empty ($urlParams)) { |
| 313 | 324 | $urlParams = ""; |
@@ -30,9 +30,9 @@ discard block |
||
| 30 | 30 | // Generate the function for the template |
| 31 | 31 | $template = new doT (); |
| 32 | 32 | $dot = $template->template ($page, array ("bookdetail" => $bookdetail, |
| 33 | - "header" => $header, |
|
| 34 | - "footer" => $footer, |
|
| 35 | - "main" => $main)); |
|
| 33 | + "header" => $header, |
|
| 34 | + "footer" => $footer, |
|
| 35 | + "main" => $main)); |
|
| 36 | 36 | // If there is a syntax error in the function created |
| 37 | 37 | // $dot will be equal to FALSE |
| 38 | 38 | if (!$dot) { |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | case LIBXML_ERR_WARNING: |
| 112 | 112 | $return .= "Warning $error->code: "; |
| 113 | 113 | break; |
| 114 | - case LIBXML_ERR_ERROR: |
|
| 114 | + case LIBXML_ERR_ERROR: |
|
| 115 | 115 | $return .= "Error $error->code: "; |
| 116 | 116 | break; |
| 117 | 117 | case LIBXML_ERR_FATAL: |
@@ -120,8 +120,8 @@ discard block |
||
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | $return .= trim($error->message) . |
| 123 | - "\n Line: $error->line" . |
|
| 124 | - "\n Column: $error->column"; |
|
| 123 | + "\n Line: $error->line" . |
|
| 124 | + "\n Column: $error->column"; |
|
| 125 | 125 | |
| 126 | 126 | if ($error->file) { |
| 127 | 127 | $return .= "\n File: $error->file"; |
@@ -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 | } |
@@ -13,12 +13,14 @@ discard block |
||
| 13 | 13 | date_default_timezone_set($config['default_timezone']); |
| 14 | 14 | |
| 15 | 15 | |
| 16 | -function useServerSideRendering () { |
|
| 16 | +function useServerSideRendering () |
|
| 17 | +{ |
|
| 17 | 18 | global $config; |
| 18 | 19 | return preg_match("/" . $config['cops_server_side_render'] . "/", $_SERVER['HTTP_USER_AGENT']); |
| 19 | 20 | } |
| 20 | 21 | |
| 21 | -function serverSideRender ($data) { |
|
| 22 | +function serverSideRender ($data) |
|
| 23 | +{ |
|
| 22 | 24 | // Get the templates |
| 23 | 25 | $theme = getCurrentTemplate (); |
| 24 | 26 | $header = file_get_contents('templates/' . $theme . '/header.html'); |
@@ -46,28 +48,32 @@ discard block |
||
| 46 | 48 | return NULL; |
| 47 | 49 | } |
| 48 | 50 | |
| 49 | -function getQueryString () { |
|
| 51 | +function getQueryString () |
|
| 52 | +{ |
|
| 50 | 53 | if ( isset($_SERVER['QUERY_STRING']) ) { |
| 51 | 54 | return $_SERVER['QUERY_STRING']; |
| 52 | 55 | } |
| 53 | 56 | return ""; |
| 54 | 57 | } |
| 55 | 58 | |
| 56 | -function notFound () { |
|
| 59 | +function notFound () |
|
| 60 | +{ |
|
| 57 | 61 | header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found"); |
| 58 | 62 | header("Status: 404 Not Found"); |
| 59 | 63 | |
| 60 | 64 | $_SERVER['REDIRECT_STATUS'] = 404; |
| 61 | 65 | } |
| 62 | 66 | |
| 63 | -function getURLParam ($name, $default = NULL) { |
|
| 67 | +function getURLParam ($name, $default = NULL) |
|
| 68 | +{ |
|
| 64 | 69 | if (!empty ($_GET) && isset($_GET[$name]) && $_GET[$name] != "") { |
| 65 | 70 | return $_GET[$name]; |
| 66 | 71 | } |
| 67 | 72 | return $default; |
| 68 | 73 | } |
| 69 | 74 | |
| 70 | -function getCurrentOption ($option) { |
|
| 75 | +function getCurrentOption ($option) |
|
| 76 | +{ |
|
| 71 | 77 | global $config; |
| 72 | 78 | if (isset($_COOKIE[$option])) { |
| 73 | 79 | if (isset($config ["cops_" . $option]) && is_array ($config ["cops_" . $option])) { |
@@ -83,19 +89,23 @@ discard block |
||
| 83 | 89 | return ""; |
| 84 | 90 | } |
| 85 | 91 | |
| 86 | -function getCurrentCss () { |
|
| 92 | +function getCurrentCss () |
|
| 93 | +{ |
|
| 87 | 94 | return "templates/" . getCurrentTemplate () . "/styles/style-" . getCurrentOption ("style") . ".css"; |
| 88 | 95 | } |
| 89 | 96 | |
| 90 | -function getCurrentTemplate () { |
|
| 97 | +function getCurrentTemplate () |
|
| 98 | +{ |
|
| 91 | 99 | return getCurrentOption ("template"); |
| 92 | 100 | } |
| 93 | 101 | |
| 94 | -function getUrlWithVersion ($url) { |
|
| 102 | +function getUrlWithVersion ($url) |
|
| 103 | +{ |
|
| 95 | 104 | return $url . "?v=" . VERSION; |
| 96 | 105 | } |
| 97 | 106 | |
| 98 | -function xml2xhtml($xml) { |
|
| 107 | +function xml2xhtml($xml) |
|
| 108 | +{ |
|
| 99 | 109 | return preg_replace_callback('#<(\w+)([^>]*)\s*/>#s', create_function('$m', ' |
| 100 | 110 | $xhtml_tags = array("br", "hr", "input", "frame", "img", "area", "link", "col", "base", "basefont", "param"); |
| 101 | 111 | return in_array($m[1], $xhtml_tags) ? "<$m[1]$m[2] />" : "<$m[1]$m[2]></$m[1]>"; |
@@ -135,12 +145,15 @@ discard block |
||
| 135 | 145 | $errors = libxml_get_errors(); |
| 136 | 146 | |
| 137 | 147 | foreach ($errors as $error) { |
| 138 | - if ($error->code == 801) return false; |
|
| 148 | + if ($error->code == 801) { |
|
| 149 | + return false; |
|
| 150 | + } |
|
| 139 | 151 | } |
| 140 | 152 | return true; |
| 141 | 153 | } |
| 142 | 154 | |
| 143 | -function html2xhtml ($html) { |
|
| 155 | +function html2xhtml ($html) |
|
| 156 | +{ |
|
| 144 | 157 | $doc = new DOMDocument(); |
| 145 | 158 | libxml_use_internal_errors(true); |
| 146 | 159 | |
@@ -160,7 +173,9 @@ discard block |
||
| 160 | 173 | } |
| 161 | 174 | */ |
| 162 | 175 | |
| 163 | - if (!are_libxml_errors_ok ()) $output = "HTML code not valid."; |
|
| 176 | + if (!are_libxml_errors_ok ()) { |
|
| 177 | + $output = "HTML code not valid."; |
|
| 178 | + } |
|
| 164 | 179 | |
| 165 | 180 | libxml_use_internal_errors(false); |
| 166 | 181 | return $output; |
@@ -170,7 +185,8 @@ discard block |
||
| 170 | 185 | * This method is a direct copy-paste from |
| 171 | 186 | * http://tmont.com/blargh/2010/1/string-format-in-php |
| 172 | 187 | */ |
| 173 | -function str_format($format) { |
|
| 188 | +function str_format($format) |
|
| 189 | +{ |
|
| 174 | 190 | $args = func_get_args(); |
| 175 | 191 | $format = array_shift($args); |
| 176 | 192 | |
@@ -190,7 +206,8 @@ discard block |
||
| 190 | 206 | * languages id are normalized : fr-fr -> fr_FR |
| 191 | 207 | * @return array of languages |
| 192 | 208 | */ |
| 193 | -function getAcceptLanguages() { |
|
| 209 | +function getAcceptLanguages() |
|
| 210 | +{ |
|
| 194 | 211 | $langs = array(); |
| 195 | 212 | |
| 196 | 213 | if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { |
@@ -218,7 +235,9 @@ discard block |
||
| 218 | 235 | |
| 219 | 236 | // set default to 1 for any without q factor |
| 220 | 237 | foreach ($langs as $lang => $val) { |
| 221 | - if ($val === '') $langs[$lang] = 1; |
|
| 238 | + if ($val === '') { |
|
| 239 | + $langs[$lang] = 1; |
|
| 240 | + } |
|
| 222 | 241 | } |
| 223 | 242 | |
| 224 | 243 | // sort list based on value |
@@ -233,14 +252,14 @@ discard block |
||
| 233 | 252 | * Find the best translation file possible based on the accepted languages |
| 234 | 253 | * @return array of language and language file |
| 235 | 254 | */ |
| 236 | -function getLangAndTranslationFile() { |
|
| 255 | +function getLangAndTranslationFile() |
|
| 256 | +{ |
|
| 237 | 257 | global $config; |
| 238 | 258 | $langs = array(); |
| 239 | 259 | $lang = "en"; |
| 240 | 260 | if (!empty($config['cops_language'])) { |
| 241 | 261 | $lang = $config['cops_language']; |
| 242 | - } |
|
| 243 | - elseif (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { |
|
| 262 | + } elseif (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { |
|
| 244 | 263 | $langs = getAcceptLanguages(); |
| 245 | 264 | } |
| 246 | 265 | //echo var_dump($langs); |
@@ -263,14 +282,18 @@ discard block |
||
| 263 | 282 | * This method is based on this page |
| 264 | 283 | * http://www.mind-it.info/2010/02/22/a-simple-approach-to-localization-in-php/ |
| 265 | 284 | */ |
| 266 | -function localize($phrase, $count=-1, $reset=false) { |
|
| 285 | +function localize($phrase, $count=-1, $reset=false) |
|
| 286 | +{ |
|
| 267 | 287 | global $config; |
| 268 | - if ($count == 0) |
|
| 269 | - $phrase .= ".none"; |
|
| 270 | - if ($count == 1) |
|
| 271 | - $phrase .= ".one"; |
|
| 272 | - if ($count > 1) |
|
| 273 | - $phrase .= ".many"; |
|
| 288 | + if ($count == 0) { |
|
| 289 | + $phrase .= ".none"; |
|
| 290 | + } |
|
| 291 | + if ($count == 1) { |
|
| 292 | + $phrase .= ".one"; |
|
| 293 | + } |
|
| 294 | + if ($count > 1) { |
|
| 295 | + $phrase .= ".many"; |
|
| 296 | + } |
|
| 274 | 297 | |
| 275 | 298 | /* Static keyword is used to ensure the file is loaded only once */ |
| 276 | 299 | static $translations = NULL; |
@@ -295,8 +318,7 @@ discard block |
||
| 295 | 318 | unset ($translations [$key]); |
| 296 | 319 | } |
| 297 | 320 | } |
| 298 | - if ($lang_file_en) |
|
| 299 | - { |
|
| 321 | + if ($lang_file_en) { |
|
| 300 | 322 | $lang_file_content = file_get_contents($lang_file_en); |
| 301 | 323 | $translations_en = json_decode($lang_file_content, true); |
| 302 | 324 | $translations = array_merge ($translations_en, $translations); |
@@ -308,7 +330,8 @@ discard block |
||
| 308 | 330 | return $phrase; |
| 309 | 331 | } |
| 310 | 332 | |
| 311 | -function addURLParameter($urlParams, $paramName, $paramValue) { |
|
| 333 | +function addURLParameter($urlParams, $paramName, $paramValue) |
|
| 334 | +{ |
|
| 312 | 335 | if (empty ($urlParams)) { |
| 313 | 336 | $urlParams = ""; |
| 314 | 337 | } |
@@ -327,16 +350,19 @@ discard block |
||
| 327 | 350 | return $start . http_build_query($params); |
| 328 | 351 | } |
| 329 | 352 | |
| 330 | -function useNormAndUp () { |
|
| 353 | +function useNormAndUp () |
|
| 354 | +{ |
|
| 331 | 355 | global $config; |
| 332 | 356 | return $config ['cops_normalized_search'] == "1"; |
| 333 | 357 | } |
| 334 | 358 | |
| 335 | -function normalizeUtf8String( $s) { |
|
| 359 | +function normalizeUtf8String( $s) |
|
| 360 | +{ |
|
| 336 | 361 | include_once 'transliteration.php'; |
| 337 | 362 | return _transliteration_process($s); |
| 338 | 363 | } |
| 339 | 364 | |
| 340 | -function normAndUp ($s) { |
|
| 365 | +function normAndUp ($s) |
|
| 366 | +{ |
|
| 341 | 367 | return mb_strtoupper (normalizeUtf8String($s), 'UTF-8'); |
| 342 | 368 | } |
@@ -36,14 +36,14 @@ discard block |
||
| 36 | 36 | // If there is a syntax error in the function created |
| 37 | 37 | // $dot will be equal to FALSE |
| 38 | 38 | if (!$dot) { |
| 39 | - return FALSE; |
|
| 39 | + return false; |
|
| 40 | 40 | } |
| 41 | 41 | // Execute the template |
| 42 | 42 | if (!empty ($data)) { |
| 43 | 43 | return $dot ($data); |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - return NULL; |
|
| 46 | + return null; |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | function getQueryString () { |
@@ -60,7 +60,7 @@ discard block |
||
| 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 | } |
@@ -109,10 +109,10 @@ discard block |
||
| 109 | 109 | |
| 110 | 110 | switch ($error->level) { |
| 111 | 111 | case LIBXML_ERR_WARNING: |
| 112 | - $return .= "Warning $error->code: "; |
|
| 112 | + $return .= "warning $error->code: "; |
|
| 113 | 113 | break; |
| 114 | 114 | case LIBXML_ERR_ERROR: |
| 115 | - $return .= "Error $error->code: "; |
|
| 115 | + $return .= "error $error->code: "; |
|
| 116 | 116 | break; |
| 117 | 117 | case LIBXML_ERR_FATAL: |
| 118 | 118 | $return .= "Fatal Error $error->code: "; |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | $langs = getAcceptLanguages(); |
| 245 | 245 | } |
| 246 | 246 | //echo var_dump($langs); |
| 247 | - $lang_file = NULL; |
|
| 247 | + $lang_file = null; |
|
| 248 | 248 | foreach ($langs as $language => $val) { |
| 249 | 249 | $temp_file = dirname(__FILE__). '/lang/Localization_' . $language . '.json'; |
| 250 | 250 | if (file_exists($temp_file)) { |
@@ -273,13 +273,13 @@ discard block |
||
| 273 | 273 | $phrase .= ".many"; |
| 274 | 274 | |
| 275 | 275 | /* Static keyword is used to ensure the file is loaded only once */ |
| 276 | - static $translations = NULL; |
|
| 276 | + static $translations = null; |
|
| 277 | 277 | if ($reset) { |
| 278 | - $translations = NULL; |
|
| 278 | + $translations = null; |
|
| 279 | 279 | } |
| 280 | 280 | /* If no instance of $translations has occured load the language file */ |
| 281 | 281 | if (is_null($translations)) { |
| 282 | - $lang_file_en = NULL; |
|
| 282 | + $lang_file_en = null; |
|
| 283 | 283 | list ($lang, $lang_file) = getLangAndTranslationFile(); |
| 284 | 284 | if ($lang != "en") { |
| 285 | 285 | $lang_file_en = dirname(__FILE__). '/lang/' . 'Localization_en.json'; |
@@ -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 | list (, $result) = self::executeQuery ($query, $columns, "", $params, -1); |
| 164 | 179 | $entryArray = array(); |
@@ -177,6 +192,9 @@ discard block |
||
| 177 | 192 | return $entryArray; |
| 178 | 193 | } |
| 179 | 194 | |
| 195 | + /** |
|
| 196 | + * @param string $filter |
|
| 197 | + */ |
|
| 180 | 198 | public static function executeQuery($query, $columns, $filter, $params, $n, $database = NULL, $numberPerPage = NULL) { |
| 181 | 199 | $totalResult = -1; |
| 182 | 200 | |
@@ -37,142 +37,142 @@ discard block |
||
| 37 | 37 | |
| 38 | 38 | private static $db = NULL; |
| 39 | 39 | |
| 40 | - public static function isMultipleDatabaseEnabled () { |
|
| 40 | + public static function isMultipleDatabaseEnabled() { |
|
| 41 | 41 | global $config; |
| 42 | - return is_array ($config['calibre_directory']); |
|
| 42 | + return is_array($config['calibre_directory']); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - public static function useAbsolutePath () { |
|
| 45 | + public static function useAbsolutePath() { |
|
| 46 | 46 | global $config; |
| 47 | 47 | $path = self::getDbDirectory(); |
| 48 | - return preg_match ('/^\//', $path) || // Linux / |
|
| 49 | - preg_match ('/^\w\:/', $path); // Windows X: |
|
| 48 | + return preg_match('/^\//', $path) || // Linux / |
|
| 49 | + preg_match('/^\w\:/', $path); // Windows X: |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - public static function noDatabaseSelected () { |
|
| 53 | - return self::isMultipleDatabaseEnabled () && is_null (GetUrlParam (DB)); |
|
| 52 | + public static function noDatabaseSelected() { |
|
| 53 | + return self::isMultipleDatabaseEnabled() && is_null(GetUrlParam(DB)); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - public static function getDbList () { |
|
| 56 | + public static function getDbList() { |
|
| 57 | 57 | global $config; |
| 58 | - if (self::isMultipleDatabaseEnabled ()) { |
|
| 58 | + if (self::isMultipleDatabaseEnabled()) { |
|
| 59 | 59 | return $config['calibre_directory']; |
| 60 | 60 | } else { |
| 61 | - return array ("" => $config['calibre_directory']); |
|
| 61 | + return array("" => $config['calibre_directory']); |
|
| 62 | 62 | } |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - public static function getDbNameList () { |
|
| 65 | + public static function getDbNameList() { |
|
| 66 | 66 | global $config; |
| 67 | - if (self::isMultipleDatabaseEnabled ()) { |
|
| 68 | - return array_keys ($config['calibre_directory']); |
|
| 67 | + if (self::isMultipleDatabaseEnabled()) { |
|
| 68 | + return array_keys($config['calibre_directory']); |
|
| 69 | 69 | } else { |
| 70 | - return array (""); |
|
| 70 | + return array(""); |
|
| 71 | 71 | } |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - public static function getDbName ($database = NULL) { |
|
| 74 | + public static function getDbName($database = NULL) { |
|
| 75 | 75 | global $config; |
| 76 | - if (self::isMultipleDatabaseEnabled ()) { |
|
| 77 | - if (is_null ($database)) $database = GetUrlParam (DB, 0); |
|
| 76 | + if (self::isMultipleDatabaseEnabled()) { |
|
| 77 | + if (is_null($database)) $database = GetUrlParam(DB, 0); |
|
| 78 | 78 | if (!is_null($database) && !preg_match('/^\d+$/', $database)) { |
| 79 | - return self::error ($database); |
|
| 79 | + return self::error($database); |
|
| 80 | 80 | } |
| 81 | - $array = array_keys ($config['calibre_directory']); |
|
| 81 | + $array = array_keys($config['calibre_directory']); |
|
| 82 | 82 | return $array[$database]; |
| 83 | 83 | } |
| 84 | 84 | return ""; |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - public static function getDbDirectory ($database = NULL) { |
|
| 87 | + public static function getDbDirectory($database = NULL) { |
|
| 88 | 88 | global $config; |
| 89 | - if (self::isMultipleDatabaseEnabled ()) { |
|
| 90 | - if (is_null ($database)) $database = GetUrlParam (DB, 0); |
|
| 89 | + if (self::isMultipleDatabaseEnabled()) { |
|
| 90 | + if (is_null($database)) $database = GetUrlParam(DB, 0); |
|
| 91 | 91 | if (!is_null($database) && !preg_match('/^\d+$/', $database)) { |
| 92 | - return self::error ($database); |
|
| 92 | + return self::error($database); |
|
| 93 | 93 | } |
| 94 | - $array = array_values ($config['calibre_directory']); |
|
| 94 | + $array = array_values($config['calibre_directory']); |
|
| 95 | 95 | return $array[$database]; |
| 96 | 96 | } |
| 97 | 97 | return $config['calibre_directory']; |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | |
| 101 | - public static function getDbFileName ($database = NULL) { |
|
| 102 | - return self::getDbDirectory ($database) .'metadata.db'; |
|
| 101 | + public static function getDbFileName($database = NULL) { |
|
| 102 | + return self::getDbDirectory($database) . 'metadata.db'; |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - private static function error ($database) { |
|
| 105 | + private static function error($database) { |
|
| 106 | 106 | if (php_sapi_name() != "cli") { |
| 107 | 107 | header("location: checkconfig.php?err=1"); |
| 108 | 108 | } |
| 109 | 109 | throw new Exception("Database <{$database}> not found."); |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - public static function getDb ($database = NULL) { |
|
| 113 | - if (is_null (self::$db)) { |
|
| 112 | + public static function getDb($database = NULL) { |
|
| 113 | + if (is_null(self::$db)) { |
|
| 114 | 114 | try { |
| 115 | - if (is_readable (self::getDbFileName ($database))) { |
|
| 116 | - self::$db = new PDO('sqlite:'. self::getDbFileName ($database)); |
|
| 117 | - if (useNormAndUp ()) { |
|
| 118 | - self::$db->sqliteCreateFunction ('normAndUp', 'normAndUp', 1); |
|
| 115 | + if (is_readable(self::getDbFileName($database))) { |
|
| 116 | + self::$db = new PDO('sqlite:' . self::getDbFileName($database)); |
|
| 117 | + if (useNormAndUp()) { |
|
| 118 | + self::$db->sqliteCreateFunction('normAndUp', 'normAndUp', 1); |
|
| 119 | 119 | } |
| 120 | 120 | } else { |
| 121 | - self::error ($database); |
|
| 121 | + self::error($database); |
|
| 122 | 122 | } |
| 123 | 123 | } catch (Exception $e) { |
| 124 | - self::error ($database); |
|
| 124 | + self::error($database); |
|
| 125 | 125 | } |
| 126 | 126 | } |
| 127 | 127 | return self::$db; |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - public static function checkDatabaseAvailability () { |
|
| 131 | - if (self::noDatabaseSelected ()) { |
|
| 132 | - for ($i = 0; $i < count (self::getDbList ()); $i++) { |
|
| 133 | - self::getDb ($i); |
|
| 134 | - self::clearDb (); |
|
| 130 | + public static function checkDatabaseAvailability() { |
|
| 131 | + if (self::noDatabaseSelected()) { |
|
| 132 | + for ($i = 0; $i < count(self::getDbList()); $i++) { |
|
| 133 | + self::getDb($i); |
|
| 134 | + self::clearDb(); |
|
| 135 | 135 | } |
| 136 | 136 | } else { |
| 137 | - self::getDb (); |
|
| 137 | + self::getDb(); |
|
| 138 | 138 | } |
| 139 | 139 | return true; |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | - public static function clearDb () { |
|
| 142 | + public static function clearDb() { |
|
| 143 | 143 | self::$db = NULL; |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | - public static function executeQuerySingle ($query, $database = NULL) { |
|
| 147 | - return self::getDb ($database)->query($query)->fetchColumn(); |
|
| 146 | + public static function executeQuerySingle($query, $database = NULL) { |
|
| 147 | + return self::getDb($database)->query($query)->fetchColumn(); |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | public static function getCountGeneric($table, $id, $pageId, $numberOfString = NULL) { |
| 151 | 151 | if (!$numberOfString) { |
| 152 | 152 | $numberOfString = $table . ".alphabetical"; |
| 153 | 153 | } |
| 154 | - $count = self::executeQuerySingle ('select count(*) from ' . $table); |
|
| 154 | + $count = self::executeQuerySingle('select count(*) from ' . $table); |
|
| 155 | 155 | if ($count == 0) return NULL; |
| 156 | - $entry = new Entry (localize($table . ".title"), $id, |
|
| 157 | - str_format (localize($numberOfString, $count), $count), "text", |
|
| 158 | - array ( new LinkNavigation ("?page=".$pageId)), "", $count); |
|
| 156 | + $entry = new Entry(localize($table . ".title"), $id, |
|
| 157 | + str_format(localize($numberOfString, $count), $count), "text", |
|
| 158 | + array(new LinkNavigation("?page=" . $pageId)), "", $count); |
|
| 159 | 159 | return $entry; |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - public static function getEntryArrayWithBookNumber ($query, $columns, $params, $category) { |
|
| 163 | - list (, $result) = self::executeQuery ($query, $columns, "", $params, -1); |
|
| 162 | + public static function getEntryArrayWithBookNumber($query, $columns, $params, $category) { |
|
| 163 | + list (, $result) = self::executeQuery($query, $columns, "", $params, -1); |
|
| 164 | 164 | $entryArray = array(); |
| 165 | - while ($post = $result->fetchObject ()) |
|
| 165 | + while ($post = $result->fetchObject()) |
|
| 166 | 166 | { |
| 167 | - $instance = new $category ($post); |
|
| 167 | + $instance = new $category($post); |
|
| 168 | 168 | if (property_exists($post, "sort")) { |
| 169 | 169 | $title = $post->sort; |
| 170 | 170 | } else { |
| 171 | 171 | $title = $post->name; |
| 172 | 172 | } |
| 173 | - array_push ($entryArray, new Entry ($title, $instance->getEntryId (), |
|
| 174 | - str_format (localize("bookword", $post->count), $post->count), "text", |
|
| 175 | - array ( new LinkNavigation ($instance->getUri ())), "", $post->count)); |
|
| 173 | + array_push($entryArray, new Entry($title, $instance->getEntryId(), |
|
| 174 | + str_format(localize("bookword", $post->count), $post->count), "text", |
|
| 175 | + array(new LinkNavigation($instance->getUri())), "", $post->count)); |
|
| 176 | 176 | } |
| 177 | 177 | return $entryArray; |
| 178 | 178 | } |
@@ -180,30 +180,30 @@ discard block |
||
| 180 | 180 | public static function executeQuery($query, $columns, $filter, $params, $n, $database = NULL, $numberPerPage = NULL) { |
| 181 | 181 | $totalResult = -1; |
| 182 | 182 | |
| 183 | - if (useNormAndUp ()) { |
|
| 183 | + if (useNormAndUp()) { |
|
| 184 | 184 | $query = preg_replace("/upper/", "normAndUp", $query); |
| 185 | 185 | $columns = preg_replace("/upper/", "normAndUp", $columns); |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | - if (is_null ($numberPerPage)) { |
|
| 189 | - $numberPerPage = getCurrentOption ("max_item_per_page"); |
|
| 188 | + if (is_null($numberPerPage)) { |
|
| 189 | + $numberPerPage = getCurrentOption("max_item_per_page"); |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | if ($numberPerPage != -1 && $n != -1) |
| 193 | 193 | { |
| 194 | 194 | // First check total number of results |
| 195 | - $result = self::getDb ($database)->prepare (str_format ($query, "count(*)", $filter)); |
|
| 196 | - $result->execute ($params); |
|
| 197 | - $totalResult = $result->fetchColumn (); |
|
| 195 | + $result = self::getDb($database)->prepare(str_format($query, "count(*)", $filter)); |
|
| 196 | + $result->execute($params); |
|
| 197 | + $totalResult = $result->fetchColumn(); |
|
| 198 | 198 | |
| 199 | 199 | // Next modify the query and params |
| 200 | 200 | $query .= " limit ?, ?"; |
| 201 | - array_push ($params, ($n - 1) * $numberPerPage, $numberPerPage); |
|
| 201 | + array_push($params, ($n - 1) * $numberPerPage, $numberPerPage); |
|
| 202 | 202 | } |
| 203 | 203 | |
| 204 | - $result = self::getDb ($database)->prepare(str_format ($query, $columns, $filter)); |
|
| 205 | - $result->execute ($params); |
|
| 206 | - return array ($totalResult, $result); |
|
| 204 | + $result = self::getDb($database)->prepare(str_format($query, $columns, $filter)); |
|
| 205 | + $result->execute($params); |
|
| 206 | + return array($totalResult, $result); |
|
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | } |
@@ -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 | return 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 | return 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,31 +154,36 @@ 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 | list (, $result) = self::executeQuery ($query, $columns, "", $params, -1); |
| 164 | 185 | $entryArray = array(); |
| 165 | - while ($post = $result->fetchObject ()) |
|
| 166 | - { |
|
| 186 | + while ($post = $result->fetchObject ()) { |
|
| 167 | 187 | $instance = new $category ($post); |
| 168 | 188 | if (property_exists($post, "sort")) { |
| 169 | 189 | $title = $post->sort; |
@@ -177,7 +197,8 @@ discard block |
||
| 177 | 197 | return $entryArray; |
| 178 | 198 | } |
| 179 | 199 | |
| 180 | - public static function executeQuery($query, $columns, $filter, $params, $n, $database = NULL, $numberPerPage = NULL) { |
|
| 200 | + public static function executeQuery($query, $columns, $filter, $params, $n, $database = NULL, $numberPerPage = NULL) |
|
| 201 | + { |
|
| 181 | 202 | $totalResult = -1; |
| 182 | 203 | |
| 183 | 204 | if (useNormAndUp ()) { |
@@ -189,8 +210,7 @@ discard block |
||
| 189 | 210 | $numberPerPage = getCurrentOption ("max_item_per_page"); |
| 190 | 211 | } |
| 191 | 212 | |
| 192 | - if ($numberPerPage != -1 && $n != -1) |
|
| 193 | - { |
|
| 213 | + if ($numberPerPage != -1 && $n != -1) { |
|
| 194 | 214 | // First check total number of results |
| 195 | 215 | $result = self::getDb ($database)->prepare (str_format ($query, "count(*)", $filter)); |
| 196 | 216 | $result->execute ($params); |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | |
| 36 | 36 | const COMPATIBILITY_XML_ALDIKO = "aldiko"; |
| 37 | 37 | |
| 38 | - private static $db = NULL; |
|
| 38 | + private static $db = null; |
|
| 39 | 39 | |
| 40 | 40 | public static function isMultipleDatabaseEnabled () { |
| 41 | 41 | global $config; |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | } |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - public static function getDbName ($database = NULL) { |
|
| 74 | + public static function getDbName ($database = null) { |
|
| 75 | 75 | global $config; |
| 76 | 76 | if (self::isMultipleDatabaseEnabled ()) { |
| 77 | 77 | if (is_null ($database)) $database = GetUrlParam (DB, 0); |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | return ""; |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - public static function getDbDirectory ($database = NULL) { |
|
| 87 | + public static function getDbDirectory ($database = null) { |
|
| 88 | 88 | global $config; |
| 89 | 89 | if (self::isMultipleDatabaseEnabled ()) { |
| 90 | 90 | if (is_null ($database)) $database = GetUrlParam (DB, 0); |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | |
| 101 | - public static function getDbFileName ($database = NULL) { |
|
| 101 | + public static function getDbFileName ($database = null) { |
|
| 102 | 102 | return self::getDbDirectory ($database) .'metadata.db'; |
| 103 | 103 | } |
| 104 | 104 | |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | throw new Exception("Database <{$database}> not found."); |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - public static function getDb ($database = NULL) { |
|
| 112 | + public static function getDb ($database = null) { |
|
| 113 | 113 | if (is_null (self::$db)) { |
| 114 | 114 | try { |
| 115 | 115 | if (is_readable (self::getDbFileName ($database))) { |
@@ -140,19 +140,19 @@ discard block |
||
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | public static function clearDb () { |
| 143 | - self::$db = NULL; |
|
| 143 | + self::$db = null; |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | - public static function executeQuerySingle ($query, $database = NULL) { |
|
| 146 | + public static function executeQuerySingle ($query, $database = null) { |
|
| 147 | 147 | return self::getDb ($database)->query($query)->fetchColumn(); |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | - public static function getCountGeneric($table, $id, $pageId, $numberOfString = NULL) { |
|
| 150 | + public static function getCountGeneric($table, $id, $pageId, $numberOfString = null) { |
|
| 151 | 151 | if (!$numberOfString) { |
| 152 | 152 | $numberOfString = $table . ".alphabetical"; |
| 153 | 153 | } |
| 154 | 154 | $count = self::executeQuerySingle ('select count(*) from ' . $table); |
| 155 | - if ($count == 0) return NULL; |
|
| 155 | + if ($count == 0) return null; |
|
| 156 | 156 | $entry = new Entry (localize($table . ".title"), $id, |
| 157 | 157 | str_format (localize($numberOfString, $count), $count), "text", |
| 158 | 158 | array ( new LinkNavigation ("?page=".$pageId)), "", $count); |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | return $entryArray; |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | - public static function executeQuery($query, $columns, $filter, $params, $n, $database = NULL, $numberPerPage = NULL) { |
|
| 180 | + public static function executeQuery($query, $columns, $filter, $params, $n, $database = null, $numberPerPage = null) { |
|
| 181 | 181 | $totalResult = -1; |
| 182 | 182 | |
| 183 | 183 | if (useNormAndUp ()) { |
@@ -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)); |
@@ -9,8 +9,8 @@ |
||
| 9 | 9 | class LinkFacet extends Link |
| 10 | 10 | { |
| 11 | 11 | public function __construct($phref, $ptitle = NULL, $pfacetGroup = NULL, $pactiveFacet = FALSE) { |
| 12 | - 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)); |
|
| 12 | + 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 | 14 | $this->href = parent::getScriptName() . $this->href; |
| 15 | 15 | } |
| 16 | 16 | } |
@@ -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,7 +8,7 @@ |
||
| 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 | parent::__construct ($phref, Link::OPDS_PAGING_TYPE, "http://opds-spec.org/facet", $ptitle, $pfacetGroup, $pactiveFacet); |
| 13 | 13 | if (!is_null (GetUrlParam (DB))) $this->href = addURLParameter ($this->href, DB, GetUrlParam (DB)); |
| 14 | 14 | $this->href = parent::getScriptName() . $this->href; |
@@ -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)); |
@@ -9,10 +9,10 @@ |
||
| 9 | 9 | class LinkNavigation extends Link |
| 10 | 10 | { |
| 11 | 11 | public function __construct($phref, $prel = NULL, $ptitle = NULL) { |
| 12 | - 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; |
|
| 15 | - if (preg_match ("/(bookdetail|getJSON).php/", parent::getScriptName())) { |
|
| 12 | + 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; |
|
| 15 | + if (preg_match("/(bookdetail|getJSON).php/", parent::getScriptName())) { |
|
| 16 | 16 | $this->href = "index.php" . $this->href; |
| 17 | 17 | } else { |
| 18 | 18 | $this->href = parent::getScriptName() . $this->href; |
@@ -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,7 +8,7 @@ |
||
| 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 | parent::__construct ($phref, Link::OPDS_NAVIGATION_TYPE, $prel, $ptitle); |
| 13 | 13 | if (!is_null (GetUrlParam (DB))) $this->href = addURLParameter ($this->href, DB, GetUrlParam (DB)); |
| 14 | 14 | if (!preg_match ("#^\?(.*)#", $this->href) && !empty ($this->href)) $this->href = "?" . $this->href; |
@@ -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'"; |
@@ -45,11 +45,11 @@ |
||
| 45 | 45 | $this->entryArray = array (); |
| 46 | 46 | |
| 47 | 47 | $ignoredBaseArray = array (PageQueryResult::SCOPE_AUTHOR, |
| 48 | - PageQueryResult::SCOPE_TAG, |
|
| 49 | - PageQueryResult::SCOPE_SERIES, |
|
| 50 | - PageQueryResult::SCOPE_PUBLISHER, |
|
| 51 | - PageQueryResult::SCOPE_RATING, |
|
| 52 | - "language"); |
|
| 48 | + PageQueryResult::SCOPE_TAG, |
|
| 49 | + PageQueryResult::SCOPE_SERIES, |
|
| 50 | + PageQueryResult::SCOPE_PUBLISHER, |
|
| 51 | + PageQueryResult::SCOPE_RATING, |
|
| 52 | + "language"); |
|
| 53 | 53 | |
| 54 | 54 | $content = ""; |
| 55 | 55 | array_push ($this->entryArray, new Entry ("Template", "", |
@@ -8,10 +8,10 @@ discard block |
||
| 8 | 8 | |
| 9 | 9 | class PageCustomize extends Page |
| 10 | 10 | { |
| 11 | - private function isChecked ($key, $testedValue = 1) { |
|
| 12 | - $value = getCurrentOption ($key); |
|
| 13 | - if (is_array ($value)) { |
|
| 14 | - if (in_array ($testedValue, $value)) { |
|
| 11 | + private function isChecked($key, $testedValue = 1) { |
|
| 12 | + $value = getCurrentOption($key); |
|
| 13 | + if (is_array($value)) { |
|
| 14 | + if (in_array($testedValue, $value)) { |
|
| 15 | 15 | return "checked='checked'"; |
| 16 | 16 | } |
| 17 | 17 | } else { |
@@ -22,29 +22,29 @@ discard block |
||
| 22 | 22 | return ""; |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | - private function isSelected ($key, $value) { |
|
| 26 | - if (getCurrentOption ($key) == $value) { |
|
| 25 | + private function isSelected($key, $value) { |
|
| 26 | + if (getCurrentOption($key) == $value) { |
|
| 27 | 27 | return "selected='selected'"; |
| 28 | 28 | } |
| 29 | 29 | return ""; |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - private function getStyleList () { |
|
| 33 | - $result = array (); |
|
| 34 | - foreach (glob ("templates/" . getCurrentTemplate () . "/styles/style-*.css") as $filename) { |
|
| 35 | - if (preg_match ('/styles\/style-(.*?)\.css/', $filename, $m)) { |
|
| 36 | - array_push ($result, $m [1]); |
|
| 32 | + private function getStyleList() { |
|
| 33 | + $result = array(); |
|
| 34 | + foreach (glob("templates/" . getCurrentTemplate() . "/styles/style-*.css") as $filename) { |
|
| 35 | + if (preg_match('/styles\/style-(.*?)\.css/', $filename, $m)) { |
|
| 36 | + array_push($result, $m [1]); |
|
| 37 | 37 | } |
| 38 | 38 | } |
| 39 | 39 | return $result; |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - public function InitializeContent () |
|
| 42 | + public function InitializeContent() |
|
| 43 | 43 | { |
| 44 | - $this->title = localize ("customize.title"); |
|
| 45 | - $this->entryArray = array (); |
|
| 44 | + $this->title = localize("customize.title"); |
|
| 45 | + $this->entryArray = array(); |
|
| 46 | 46 | |
| 47 | - $ignoredBaseArray = array (PageQueryResult::SCOPE_AUTHOR, |
|
| 47 | + $ignoredBaseArray = array(PageQueryResult::SCOPE_AUTHOR, |
|
| 48 | 48 | PageQueryResult::SCOPE_TAG, |
| 49 | 49 | PageQueryResult::SCOPE_SERIES, |
| 50 | 50 | PageQueryResult::SCOPE_PUBLISHER, |
@@ -52,49 +52,49 @@ discard block |
||
| 52 | 52 | "language"); |
| 53 | 53 | |
| 54 | 54 | $content = ""; |
| 55 | - array_push ($this->entryArray, new Entry ("Template", "", |
|
| 55 | + array_push($this->entryArray, new Entry("Template", "", |
|
| 56 | 56 | "<span style='cursor: pointer;' onclick='$.cookie(\"template\", \"bootstrap\", { expires: 365 });window.location=$(\".headleft\").attr(\"href\");'>Click to switch to Bootstrap</span>", "text", |
| 57 | - array ())); |
|
| 57 | + array())); |
|
| 58 | 58 | if (!preg_match("/(Kobo|Kindle\/3.0|EBRD1101)/", $_SERVER['HTTP_USER_AGENT'])) { |
| 59 | 59 | $content .= '<select id="style" onchange="updateCookie (this);">'; |
| 60 | - foreach ($this-> getStyleList () as $filename) { |
|
| 61 | - $content .= "<option value='{$filename}' " . $this->isSelected ("style", $filename) . ">{$filename}</option>"; |
|
| 60 | + foreach ($this-> getStyleList() as $filename) { |
|
| 61 | + $content .= "<option value='{$filename}' " . $this->isSelected("style", $filename) . ">{$filename}</option>"; |
|
| 62 | 62 | } |
| 63 | 63 | $content .= '</select>'; |
| 64 | 64 | } else { |
| 65 | - foreach ($this-> getStyleList () as $filename) { |
|
| 66 | - $content .= "<input type='radio' onchange='updateCookieFromCheckbox (this);' id='style-{$filename}' name='style' value='{$filename}' " . $this->isChecked ("style", $filename) . " /><label for='style-{$filename}'> {$filename} </label>"; |
|
| 65 | + foreach ($this-> getStyleList() as $filename) { |
|
| 66 | + $content .= "<input type='radio' onchange='updateCookieFromCheckbox (this);' id='style-{$filename}' name='style' value='{$filename}' " . $this->isChecked("style", $filename) . " /><label for='style-{$filename}'> {$filename} </label>"; |
|
| 67 | 67 | } |
| 68 | 68 | } |
| 69 | - array_push ($this->entryArray, new Entry (localize ("customize.style"), "", |
|
| 69 | + array_push($this->entryArray, new Entry(localize("customize.style"), "", |
|
| 70 | 70 | $content, "text", |
| 71 | - array ())); |
|
| 72 | - if (!useServerSideRendering ()) { |
|
| 73 | - $content = '<input type="checkbox" onchange="updateCookieFromCheckbox (this);" id="use_fancyapps" ' . $this->isChecked ("use_fancyapps") . ' />'; |
|
| 74 | - array_push ($this->entryArray, new Entry (localize ("customize.fancybox"), "", |
|
| 71 | + array())); |
|
| 72 | + if (!useServerSideRendering()) { |
|
| 73 | + $content = '<input type="checkbox" onchange="updateCookieFromCheckbox (this);" id="use_fancyapps" ' . $this->isChecked("use_fancyapps") . ' />'; |
|
| 74 | + array_push($this->entryArray, new Entry(localize("customize.fancybox"), "", |
|
| 75 | 75 | $content, "text", |
| 76 | - array ())); |
|
| 76 | + array())); |
|
| 77 | 77 | } |
| 78 | - $content = '<input type="number" onchange="updateCookie (this);" id="max_item_per_page" value="' . getCurrentOption ("max_item_per_page") . '" min="-1" max="1200" pattern="^[-+]?[0-9]+$" />'; |
|
| 79 | - array_push ($this->entryArray, new Entry (localize ("customize.paging"), "", |
|
| 78 | + $content = '<input type="number" onchange="updateCookie (this);" id="max_item_per_page" value="' . getCurrentOption("max_item_per_page") . '" min="-1" max="1200" pattern="^[-+]?[0-9]+$" />'; |
|
| 79 | + array_push($this->entryArray, new Entry(localize("customize.paging"), "", |
|
| 80 | 80 | $content, "text", |
| 81 | - array ())); |
|
| 82 | - $content = '<input type="text" onchange="updateCookie (this);" id="email" value="' . getCurrentOption ("email") . '" />'; |
|
| 83 | - array_push ($this->entryArray, new Entry (localize ("customize.email"), "", |
|
| 81 | + array())); |
|
| 82 | + $content = '<input type="text" onchange="updateCookie (this);" id="email" value="' . getCurrentOption("email") . '" />'; |
|
| 83 | + array_push($this->entryArray, new Entry(localize("customize.email"), "", |
|
| 84 | 84 | $content, "text", |
| 85 | - array ())); |
|
| 86 | - $content = '<input type="checkbox" onchange="updateCookieFromCheckbox (this);" id="html_tag_filter" ' . $this->isChecked ("html_tag_filter") . ' />'; |
|
| 87 | - array_push ($this->entryArray, new Entry (localize ("customize.filter"), "", |
|
| 85 | + array())); |
|
| 86 | + $content = '<input type="checkbox" onchange="updateCookieFromCheckbox (this);" id="html_tag_filter" ' . $this->isChecked("html_tag_filter") . ' />'; |
|
| 87 | + array_push($this->entryArray, new Entry(localize("customize.filter"), "", |
|
| 88 | 88 | $content, "text", |
| 89 | - array ())); |
|
| 89 | + array())); |
|
| 90 | 90 | $content = ""; |
| 91 | 91 | foreach ($ignoredBaseArray as $key) { |
| 92 | - $keyPlural = preg_replace ('/(ss)$/', 's', $key . "s"); |
|
| 93 | - $content .= '<input type="checkbox" name="ignored_categories[]" onchange="updateCookieFromCheckboxGroup (this);" id="ignored_categories_' . $key . '" ' . $this->isChecked ("ignored_categories", $key) . ' > ' . localize ("{$keyPlural}.title") . '</input> '; |
|
| 92 | + $keyPlural = preg_replace('/(ss)$/', 's', $key . "s"); |
|
| 93 | + $content .= '<input type="checkbox" name="ignored_categories[]" onchange="updateCookieFromCheckboxGroup (this);" id="ignored_categories_' . $key . '" ' . $this->isChecked("ignored_categories", $key) . ' > ' . localize("{$keyPlural}.title") . '</input> '; |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | - array_push ($this->entryArray, new Entry (localize ("customize.ignored"), "", |
|
| 96 | + array_push($this->entryArray, new Entry(localize("customize.ignored"), "", |
|
| 97 | 97 | $content, "text", |
| 98 | - array ())); |
|
| 98 | + array())); |
|
| 99 | 99 | } |
| 100 | 100 | } |
@@ -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)) { |
@@ -13,20 +13,24 @@ discard block |
||
| 13 | 13 | public $id; |
| 14 | 14 | public $lang_code; |
| 15 | 15 | |
| 16 | - public function __construct($pid, $plang_code) { |
|
| 16 | + public function __construct($pid, $plang_code) |
|
| 17 | + { |
|
| 17 | 18 | $this->id = $pid; |
| 18 | 19 | $this->lang_code = $plang_code; |
| 19 | 20 | } |
| 20 | 21 | |
| 21 | - public function getUri () { |
|
| 22 | + public function getUri () |
|
| 23 | + { |
|
| 22 | 24 | return "?page=".parent::PAGE_LANGUAGE_DETAIL."&id=$this->id"; |
| 23 | 25 | } |
| 24 | 26 | |
| 25 | - public function getEntryId () { |
|
| 27 | + public function getEntryId () |
|
| 28 | + { |
|
| 26 | 29 | return self::ALL_LANGUAGES_ID.":".$this->id; |
| 27 | 30 | } |
| 28 | 31 | |
| 29 | - public static function getLanguageString ($code) { |
|
| 32 | + public static function getLanguageString ($code) |
|
| 33 | + { |
|
| 30 | 34 | $string = localize("languages.".$code); |
| 31 | 35 | if (preg_match ("/^languages/", $string)) { |
| 32 | 36 | return $code; |
@@ -34,12 +38,14 @@ discard block |
||
| 34 | 38 | return $string; |
| 35 | 39 | } |
| 36 | 40 | |
| 37 | - public static function getCount() { |
|
| 41 | + public static function getCount() |
|
| 42 | + { |
|
| 38 | 43 | // str_format (localize("languages.alphabetical", count(array)) |
| 39 | 44 | return parent::getCountGeneric ("languages", self::ALL_LANGUAGES_ID, parent::PAGE_ALL_LANGUAGES); |
| 40 | 45 | } |
| 41 | 46 | |
| 42 | - public static function getLanguageById ($languageId) { |
|
| 47 | + public static function getLanguageById ($languageId) |
|
| 48 | + { |
|
| 43 | 49 | $result = parent::getDb ()->prepare('select id, lang_code from languages where id = ?'); |
| 44 | 50 | $result->execute (array ($languageId)); |
| 45 | 51 | if ($post = $result->fetchObject ()) { |
@@ -50,15 +56,15 @@ discard block |
||
| 50 | 56 | |
| 51 | 57 | |
| 52 | 58 | |
| 53 | - public static function getAllLanguages() { |
|
| 59 | + public static function getAllLanguages() |
|
| 60 | + { |
|
| 54 | 61 | $result = parent::getDb ()->query('select languages.id as id, languages.lang_code as lang_code, count(*) as count |
| 55 | 62 | from languages, books_languages_link |
| 56 | 63 | where languages.id = books_languages_link.lang_code |
| 57 | 64 | group by languages.id, books_languages_link.lang_code |
| 58 | 65 | order by languages.lang_code'); |
| 59 | 66 | $entryArray = array(); |
| 60 | - while ($post = $result->fetchObject ()) |
|
| 61 | - { |
|
| 67 | + while ($post = $result->fetchObject ()) { |
|
| 62 | 68 | $language = new Language ($post->id, $post->lang_code); |
| 63 | 69 | array_push ($entryArray, new Entry (Language::getLanguageString ($language->lang_code), $language->getEntryId (), |
| 64 | 70 | str_format (localize("bookword", $post->count), $post->count), "text", |
@@ -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; |
@@ -15,11 +15,13 @@ discard block |
||
| 15 | 15 | const SCOPE_BOOK = "book"; |
| 16 | 16 | const SCOPE_PUBLISHER = "publisher"; |
| 17 | 17 | |
| 18 | - private function useTypeahead () { |
|
| 18 | + private function useTypeahead () |
|
| 19 | + { |
|
| 19 | 20 | return !is_null (getURLParam ("search")); |
| 20 | 21 | } |
| 21 | 22 | |
| 22 | - private function searchByScope ($scope, $limit = FALSE) { |
|
| 23 | + private function searchByScope ($scope, $limit = FALSE) |
|
| 24 | + { |
|
| 23 | 25 | $n = $this->n; |
| 24 | 26 | $numberPerPage = NULL; |
| 25 | 27 | $queryNormedAndUp = $this->query; |
@@ -54,7 +56,8 @@ discard block |
||
| 54 | 56 | return $array; |
| 55 | 57 | } |
| 56 | 58 | |
| 57 | - public function doSearchByCategory () { |
|
| 59 | + public function doSearchByCategory () |
|
| 60 | + { |
|
| 58 | 61 | $database = GetUrlParam (DB); |
| 59 | 62 | $out = array (); |
| 60 | 63 | $pagequery = Base::PAGE_OPENSEARCH_QUERY; |
@@ -19,9 +19,9 @@ discard block |
||
| 19 | 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 | - $numberPerPage = NULL; |
|
| 24 | + $numberPerPage = null; |
|
| 25 | 25 | $queryNormedAndUp = $this->query; |
| 26 | 26 | if (useNormAndUp ()) { |
| 27 | 27 | $queryNormedAndUp = normAndUp ($this->query); |
@@ -32,7 +32,7 @@ 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 | 38 | $array = Author::getAuthorsForSearch ('%' . $queryNormedAndUp); |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 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 | 47 | $array = Publisher::getAllPublishersByQuery ($queryNormedAndUp); |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 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 | 87 | if (count ($array) == 2 && is_array ($array [0])) { |
@@ -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 | } |
@@ -10,7 +10,7 @@ |
||
| 10 | 10 | { |
| 11 | 11 | public function InitializeContent () |
| 12 | 12 | { |
| 13 | - $customId = getURLParam ("custom", NULL); |
|
| 13 | + $customId = getURLParam ("custom", null); |
|
| 14 | 14 | $custom = CustomColumn::getCustomById ($customId, $this->idGet); |
| 15 | 15 | $this->idPage = $custom->getEntryId (); |
| 16 | 16 | $this->title = $custom->name; |
@@ -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 | } |