| @@ -64,6 +64,9 @@ discard block | ||
| 64 | 64 | $_SERVER['REDIRECT_STATUS'] = 404; | 
| 65 | 65 | } | 
| 66 | 66 | |
| 67 | +/** | |
| 68 | + * @param string $name | |
| 69 | + */ | |
| 67 | 70 | function getURLParam($name, $default = NULL) | 
| 68 | 71 |  { | 
| 69 | 72 |      if (!empty ($_GET) && isset($_GET[$name]) && $_GET[$name] != '') { | 
| @@ -104,6 +107,11 @@ discard block | ||
| 104 | 107 | return $url . '?v=' . VERSION; | 
| 105 | 108 | } | 
| 106 | 109 | |
| 110 | +/** | |
| 111 | + * @param string $xml | |
| 112 | + * | |
| 113 | + * @return string | |
| 114 | + */ | |
| 107 | 115 | function xml2xhtml($xml) | 
| 108 | 116 |  { | 
| 109 | 117 |      return preg_replace_callback('#<(\w+)([^>]*)\s*/>#s', function($m) { | 
| @@ -326,6 +334,9 @@ discard block | ||
| 326 | 334 | return $phrase; | 
| 327 | 335 | } | 
| 328 | 336 | |
| 337 | +/** | |
| 338 | + * @param string $paramName | |
| 339 | + */ | |
| 329 | 340 | function addURLParameter($urlParams, $paramName, $paramValue) | 
| 330 | 341 |  { | 
| 331 | 342 |      if (empty ($urlParams)) { | 
| @@ -32,9 +32,9 @@ discard block | ||
| 32 | 32 | // Generate the function for the template | 
| 33 | 33 | $template = new doT (); | 
| 34 | 34 |      $dot = $template->template ($page, array ('bookdetail' => $bookdetail, | 
| 35 | - 'header' => $header, | |
| 36 | - 'footer' => $footer, | |
| 37 | - 'main' => $main)); | |
| 35 | + 'header' => $header, | |
| 36 | + 'footer' => $footer, | |
| 37 | + 'main' => $main)); | |
| 38 | 38 | // If there is a syntax error in the function created | 
| 39 | 39 | // $dot will be equal to FALSE | 
| 40 | 40 |      if (!$dot) { | 
| @@ -125,7 +125,7 @@ discard block | ||
| 125 | 125 | case LIBXML_ERR_WARNING: | 
| 126 | 126 | $return .= 'Warning ' . $error->code . ': '; | 
| 127 | 127 | break; | 
| 128 | - case LIBXML_ERR_ERROR: | |
| 128 | + case LIBXML_ERR_ERROR: | |
| 129 | 129 | $return .= 'Error ' . $error->code . ': '; | 
| 130 | 130 | break; | 
| 131 | 131 | case LIBXML_ERR_FATAL: | 
| @@ -134,8 +134,8 @@ discard block | ||
| 134 | 134 | } | 
| 135 | 135 | |
| 136 | 136 | $return .= trim($error->message) . | 
| 137 | - "\n Line: " . $error->line . | |
| 138 | - "\n Column: " . $error->column; | |
| 137 | + "\n Line: " . $error->line . | |
| 138 | + "\n Column: " . $error->column; | |
| 139 | 139 | |
| 140 | 140 |      if ($error->file) { | 
| 141 | 141 | $return .= "\n File: " . $error->file; | 
| @@ -149,7 +149,9 @@ discard block | ||
| 149 | 149 | $errors = libxml_get_errors(); | 
| 150 | 150 | |
| 151 | 151 |      foreach ($errors as $error) { | 
| 152 | - if ($error->code == 801) return false; | |
| 152 | +        if ($error->code == 801) { | |
| 153 | + return false; | |
| 154 | + } | |
| 153 | 155 | } | 
| 154 | 156 | return true; | 
| 155 | 157 | } | 
| @@ -175,7 +177,9 @@ discard block | ||
| 175 | 177 | } | 
| 176 | 178 | */ | 
| 177 | 179 | |
| 178 | - if (!are_libxml_errors_ok ()) $output = 'HTML code not valid.'; | |
| 180 | +    if (!are_libxml_errors_ok ()) { | |
| 181 | + $output = 'HTML code not valid.'; | |
| 182 | + } | |
| 179 | 183 | |
| 180 | 184 | libxml_use_internal_errors(false); | 
| 181 | 185 | return $output; | 
| @@ -235,7 +239,9 @@ discard block | ||
| 235 | 239 | |
| 236 | 240 | // set default to 1 for any without q factor | 
| 237 | 241 |              foreach ($langs as $lang => $val) { | 
| 238 | - if ($val === '') $langs[$lang] = 1; | |
| 242 | +                if ($val === '') { | |
| 243 | + $langs[$lang] = 1; | |
| 244 | + } | |
| 239 | 245 | } | 
| 240 | 246 | |
| 241 | 247 | // sort list based on value | 
| @@ -257,8 +263,7 @@ discard block | ||
| 257 | 263 | $lang = 'en'; | 
| 258 | 264 |      if (!empty($config['cops_language'])) { | 
| 259 | 265 | $lang = $config['cops_language']; | 
| 260 | - } | |
| 261 | -    elseif (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { | |
| 266 | +    } elseif (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { | |
| 262 | 267 | $langs = getAcceptLanguages(); | 
| 263 | 268 | } | 
| 264 | 269 | //echo var_dump($langs); | 
| @@ -284,12 +289,15 @@ discard block | ||
| 284 | 289 | function localize($phrase, $count=-1, $reset=false) | 
| 285 | 290 |  { | 
| 286 | 291 | global $config; | 
| 287 | - if ($count == 0) | |
| 288 | - $phrase .= '.none'; | |
| 289 | - if ($count == 1) | |
| 290 | - $phrase .= '.one'; | |
| 291 | - if ($count > 1) | |
| 292 | - $phrase .= '.many'; | |
| 292 | +    if ($count == 0) { | |
| 293 | + $phrase .= '.none'; | |
| 294 | + } | |
| 295 | +    if ($count == 1) { | |
| 296 | + $phrase .= '.one'; | |
| 297 | + } | |
| 298 | +    if ($count > 1) { | |
| 299 | + $phrase .= '.many'; | |
| 300 | + } | |
| 293 | 301 | |
| 294 | 302 | /* Static keyword is used to ensure the file is loaded only once */ | 
| 295 | 303 | static $translations = NULL; | 
| @@ -38,14 +38,14 @@ discard block | ||
| 38 | 38 | // If there is a syntax error in the function created | 
| 39 | 39 | // $dot will be equal to FALSE | 
| 40 | 40 |      if (!$dot) { | 
| 41 | - return FALSE; | |
| 41 | + return false; | |
| 42 | 42 | } | 
| 43 | 43 | // Execute the template | 
| 44 | 44 |      if (!empty ($data)) { | 
| 45 | 45 | return $dot ($data); | 
| 46 | 46 | } | 
| 47 | 47 | |
| 48 | - return NULL; | |
| 48 | + return null; | |
| 49 | 49 | } | 
| 50 | 50 | |
| 51 | 51 | function getQueryString() | 
| @@ -64,7 +64,7 @@ discard block | ||
| 64 | 64 | $_SERVER['REDIRECT_STATUS'] = 404; | 
| 65 | 65 | } | 
| 66 | 66 | |
| 67 | -function getURLParam($name, $default = NULL) | |
| 67 | +function getURLParam($name, $default = null) | |
| 68 | 68 |  { | 
| 69 | 69 |      if (!empty ($_GET) && isset($_GET[$name]) && $_GET[$name] != '') { | 
| 70 | 70 | return $_GET[$name]; | 
| @@ -262,7 +262,7 @@ discard block | ||
| 262 | 262 | $langs = getAcceptLanguages(); | 
| 263 | 263 | } | 
| 264 | 264 | //echo var_dump($langs); | 
| 265 | - $lang_file = NULL; | |
| 265 | + $lang_file = null; | |
| 266 | 266 |      foreach ($langs as $language => $val) { | 
| 267 | 267 | $temp_file = dirname(__FILE__). '/lang/Localization_' . $language . '.json'; | 
| 268 | 268 |          if (file_exists($temp_file)) { | 
| @@ -292,13 +292,13 @@ discard block | ||
| 292 | 292 | $phrase .= '.many'; | 
| 293 | 293 | |
| 294 | 294 | /* Static keyword is used to ensure the file is loaded only once */ | 
| 295 | - static $translations = NULL; | |
| 295 | + static $translations = null; | |
| 296 | 296 |      if ($reset) { | 
| 297 | - $translations = NULL; | |
| 297 | + $translations = null; | |
| 298 | 298 | } | 
| 299 | 299 | /* If no instance of $translations has occured load the language file */ | 
| 300 | 300 |      if (is_null($translations)) { | 
| 301 | - $lang_file_en = NULL; | |
| 301 | + $lang_file_en = null; | |
| 302 | 302 | list ($lang, $lang_file) = getLangAndTranslationFile(); | 
| 303 | 303 |          if ($lang != 'en') { | 
| 304 | 304 | $lang_file_en = dirname(__FILE__). '/lang/' . 'Localization_en.json'; | 
| @@ -8,8 +8,8 @@ discard block | ||
| 8 | 8 | |
| 9 | 9 | require_once 'config.php'; | 
| 10 | 10 | |
| 11 | -define ('VERSION', '1.0.2'); | |
| 12 | -define ('DB', 'db'); | |
| 11 | +define('VERSION', '1.0.2'); | |
| 12 | +define('DB', 'db'); | |
| 13 | 13 | date_default_timezone_set($config['default_timezone']); | 
| 14 | 14 | |
| 15 | 15 | |
| @@ -22,7 +22,7 @@ discard block | ||
| 22 | 22 | function serverSideRender($data) | 
| 23 | 23 |  { | 
| 24 | 24 | // Get the templates | 
| 25 | - $theme = getCurrentTemplate (); | |
| 25 | + $theme = getCurrentTemplate(); | |
| 26 | 26 |      $header = file_get_contents('templates/' . $theme . '/header.html'); | 
| 27 | 27 |      $footer = file_get_contents('templates/' . $theme . '/footer.html'); | 
| 28 | 28 |      $main = file_get_contents('templates/' . $theme . '/main.html'); | 
| @@ -30,8 +30,8 @@ discard block | ||
| 30 | 30 |      $page = file_get_contents('templates/' . $theme . '/page.html'); | 
| 31 | 31 | |
| 32 | 32 | // Generate the function for the template | 
| 33 | - $template = new doT (); | |
| 34 | -    $dot = $template->template ($page, array ('bookdetail' => $bookdetail, | |
| 33 | + $template = new doT(); | |
| 34 | +    $dot = $template->template($page, array('bookdetail' => $bookdetail, | |
| 35 | 35 | 'header' => $header, | 
| 36 | 36 | 'footer' => $footer, | 
| 37 | 37 | 'main' => $main)); | 
| @@ -42,7 +42,7 @@ discard block | ||
| 42 | 42 | } | 
| 43 | 43 | // Execute the template | 
| 44 | 44 |      if (!empty ($data)) { | 
| 45 | - return $dot ($data); | |
| 45 | + return $dot($data); | |
| 46 | 46 | } | 
| 47 | 47 | |
| 48 | 48 | return NULL; | 
| @@ -58,7 +58,7 @@ discard block | ||
| 58 | 58 | |
| 59 | 59 | function notFound() | 
| 60 | 60 |  { | 
| 61 | - header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found'); | |
| 61 | + header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found'); | |
| 62 | 62 |      header('Status: 404 Not Found'); | 
| 63 | 63 | |
| 64 | 64 | $_SERVER['REDIRECT_STATUS'] = 404; | 
| @@ -76,8 +76,8 @@ discard block | ||
| 76 | 76 |  { | 
| 77 | 77 | global $config; | 
| 78 | 78 |      if (isset($_COOKIE[$option])) { | 
| 79 | -        if (isset($config ['cops_' . $option]) && is_array ($config ['cops_' . $option])) { | |
| 80 | -            return explode (',', $_COOKIE[$option]); | |
| 79 | +        if (isset($config ['cops_' . $option]) && is_array($config ['cops_' . $option])) { | |
| 80 | +            return explode(',', $_COOKIE[$option]); | |
| 81 | 81 |          } else { | 
| 82 | 82 | return $_COOKIE[$option]; | 
| 83 | 83 | } | 
| @@ -91,12 +91,12 @@ discard block | ||
| 91 | 91 | |
| 92 | 92 | function getCurrentCss() | 
| 93 | 93 |  { | 
| 94 | -    return 'templates/' . getCurrentTemplate () . '/styles/style-' . getCurrentOption('style') . '.css'; | |
| 94 | +    return 'templates/' . getCurrentTemplate() . '/styles/style-' . getCurrentOption('style') . '.css'; | |
| 95 | 95 | } | 
| 96 | 96 | |
| 97 | 97 | function getCurrentTemplate() | 
| 98 | 98 |  { | 
| 99 | -    return getCurrentOption ('template'); | |
| 99 | +    return getCurrentOption('template'); | |
| 100 | 100 | } | 
| 101 | 101 | |
| 102 | 102 | function getUrlWithVersion($url) | 
| @@ -160,10 +160,10 @@ discard block | ||
| 160 | 160 | libxml_use_internal_errors(true); | 
| 161 | 161 | |
| 162 | 162 |      $doc->loadHTML('<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body>' . | 
| 163 | - $html . '</body></html>'); // Load the HTML | |
| 163 | + $html . '</body></html>'); // Load the HTML | |
| 164 | 164 | $output = $doc->saveXML($doc->documentElement); // Transform to an Ansi xml stream | 
| 165 | 165 | $output = xml2xhtml($output); | 
| 166 | -    if (preg_match ('#<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></meta></head><body>(.*)</body></html>#ms', $output, $matches)) { | |
| 166 | +    if (preg_match('#<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></meta></head><body>(.*)</body></html>#ms', $output, $matches)) { | |
| 167 | 167 | $output = $matches [1]; // Remove <html><body> | 
| 168 | 168 | } | 
| 169 | 169 | /* | 
| @@ -175,7 +175,7 @@ discard block | ||
| 175 | 175 | } | 
| 176 | 176 | */ | 
| 177 | 177 | |
| 178 | - if (!are_libxml_errors_ok ()) $output = 'HTML code not valid.'; | |
| 178 | + if (!are_libxml_errors_ok()) $output = 'HTML code not valid.'; | |
| 179 | 179 | |
| 180 | 180 | libxml_use_internal_errors(false); | 
| 181 | 181 | return $output; | 
| @@ -264,7 +264,7 @@ discard block | ||
| 264 | 264 | //echo var_dump($langs); | 
| 265 | 265 | $lang_file = NULL; | 
| 266 | 266 |      foreach ($langs as $language => $val) { | 
| 267 | - $temp_file = dirname(__FILE__). '/lang/Localization_' . $language . '.json'; | |
| 267 | + $temp_file = dirname(__FILE__) . '/lang/Localization_' . $language . '.json'; | |
| 268 | 268 |          if (file_exists($temp_file)) { | 
| 269 | 269 | $lang = $language; | 
| 270 | 270 | $lang_file = $temp_file; | 
| @@ -272,7 +272,7 @@ discard block | ||
| 272 | 272 | } | 
| 273 | 273 | } | 
| 274 | 274 |      if (empty ($lang_file)) { | 
| 275 | - $lang_file = dirname(__FILE__). '/lang/Localization_' . $lang . '.json'; | |
| 275 | + $lang_file = dirname(__FILE__) . '/lang/Localization_' . $lang . '.json'; | |
| 276 | 276 | } | 
| 277 | 277 | return array($lang, $lang_file); | 
| 278 | 278 | } | 
| @@ -281,7 +281,7 @@ discard block | ||
| 281 | 281 | * This method is based on this page | 
| 282 | 282 | * http://www.mind-it.info/2010/02/22/a-simple-approach-to-localization-in-php/ | 
| 283 | 283 | */ | 
| 284 | -function localize($phrase, $count=-1, $reset=false) | |
| 284 | +function localize($phrase, $count = -1, $reset = false) | |
| 285 | 285 |  { | 
| 286 | 286 | global $config; | 
| 287 | 287 | if ($count == 0) | 
| @@ -301,7 +301,7 @@ discard block | ||
| 301 | 301 | $lang_file_en = NULL; | 
| 302 | 302 | list ($lang, $lang_file) = getLangAndTranslationFile(); | 
| 303 | 303 |          if ($lang != 'en') { | 
| 304 | - $lang_file_en = dirname(__FILE__). '/lang/' . 'Localization_en.json'; | |
| 304 | + $lang_file_en = dirname(__FILE__) . '/lang/' . 'Localization_en.json'; | |
| 305 | 305 | } | 
| 306 | 306 | |
| 307 | 307 | $lang_file_content = file_get_contents($lang_file); | 
| @@ -309,18 +309,18 @@ discard block | ||
| 309 | 309 | $translations = json_decode($lang_file_content, true); | 
| 310 | 310 | |
| 311 | 311 | /* Clean the array of all unfinished translations */ | 
| 312 | -        foreach (array_keys ($translations) as $key) { | |
| 313 | -            if (preg_match ('/^##TODO##/', $key)) { | |
| 312 | +        foreach (array_keys($translations) as $key) { | |
| 313 | +            if (preg_match('/^##TODO##/', $key)) { | |
| 314 | 314 | unset ($translations [$key]); | 
| 315 | 315 | } | 
| 316 | 316 | } | 
| 317 | 317 |          if (!is_null($lang_file_en)) { | 
| 318 | 318 | $lang_file_content = file_get_contents($lang_file_en); | 
| 319 | 319 | $translations_en = json_decode($lang_file_content, true); | 
| 320 | - $translations = array_merge ($translations_en, $translations); | |
| 320 | + $translations = array_merge($translations_en, $translations); | |
| 321 | 321 | } | 
| 322 | 322 | } | 
| 323 | -    if (array_key_exists ($phrase, $translations)) { | |
| 323 | +    if (array_key_exists($phrase, $translations)) { | |
| 324 | 324 | return $translations[$phrase]; | 
| 325 | 325 | } | 
| 326 | 326 | return $phrase; | 
| @@ -332,7 +332,7 @@ discard block | ||
| 332 | 332 | $urlParams = ''; | 
| 333 | 333 | } | 
| 334 | 334 | $start = ''; | 
| 335 | -    if (preg_match ('#^\?(.*)#', $urlParams, $matches)) { | |
| 335 | +    if (preg_match('#^\?(.*)#', $urlParams, $matches)) { | |
| 336 | 336 | $start = '?'; | 
| 337 | 337 | $urlParams = $matches[1]; | 
| 338 | 338 | } | 
| @@ -62,6 +62,9 @@ discard block | ||
| 62 | 62 | return self::getEntryArray (self::SQL_AUTHORS_BY_FIRST_LETTER, array ($letter . "%")); | 
| 63 | 63 | } | 
| 64 | 64 | |
| 65 | + /** | |
| 66 | + * @param string $query | |
| 67 | + */ | |
| 65 | 68 |      public static function getAuthorsForSearch($query) { | 
| 66 | 69 | return self::getEntryArray (self::SQL_AUTHORS_FOR_SEARCH, array ($query . "%", $query . "%")); | 
| 67 | 70 | } | 
| @@ -70,6 +73,9 @@ discard block | ||
| 70 | 73 | return self::getEntryArray (self::SQL_ALL_AUTHORS, array ()); | 
| 71 | 74 | } | 
| 72 | 75 | |
| 76 | + /** | |
| 77 | + * @param string $query | |
| 78 | + */ | |
| 73 | 79 |      public static function getEntryArray ($query, $params) { | 
| 74 | 80 | return Base::getEntryArrayWithBookNumber ($query, self::AUTHOR_COLUMNS, $params, "Author"); | 
| 75 | 81 | } | 
| @@ -25,69 +25,69 @@ | ||
| 25 | 25 | $this->sort = $post->sort; | 
| 26 | 26 | } | 
| 27 | 27 | |
| 28 | -    public function getUri () { | |
| 29 | - return "?page=".parent::PAGE_AUTHOR_DETAIL."&id=$this->id"; | |
| 28 | +    public function getUri() { | |
| 29 | + return "?page=" . parent::PAGE_AUTHOR_DETAIL . "&id=$this->id"; | |
| 30 | 30 | } | 
| 31 | 31 | |
| 32 | -    public function getEntryId () { | |
| 33 | - return self::ALL_AUTHORS_ID.":".$this->id; | |
| 32 | +    public function getEntryId() { | |
| 33 | + return self::ALL_AUTHORS_ID . ":" . $this->id; | |
| 34 | 34 | } | 
| 35 | 35 | |
| 36 | -    public static function getEntryIdByLetter ($startingLetter) { | |
| 37 | - return self::ALL_AUTHORS_ID.":letter:".$startingLetter; | |
| 36 | +    public static function getEntryIdByLetter($startingLetter) { | |
| 37 | + return self::ALL_AUTHORS_ID . ":letter:" . $startingLetter; | |
| 38 | 38 | } | 
| 39 | 39 | |
| 40 | 40 |      public static function getCount() { | 
| 41 | 41 |          // str_format (localize("authors.alphabetical", count(array)) | 
| 42 | -        return parent::getCountGeneric ("authors", self::ALL_AUTHORS_ID, parent::PAGE_ALL_AUTHORS); | |
| 42 | +        return parent::getCountGeneric("authors", self::ALL_AUTHORS_ID, parent::PAGE_ALL_AUTHORS); | |
| 43 | 43 | } | 
| 44 | 44 | |
| 45 | 45 |      public static function getAllAuthorsByFirstLetter() { | 
| 46 | -        list (, $result) = parent::executeQuery ("select {0} | |
| 46 | +        list (, $result) = parent::executeQuery("select {0} | |
| 47 | 47 | from authors | 
| 48 | 48 | group by substr (upper (sort), 1, 1) | 
| 49 | -order by substr (upper (sort), 1, 1)", "substr (upper (sort), 1, 1) as title, count(*) as count", "", array (), -1); | |
| 49 | +order by substr (upper (sort), 1, 1)", "substr (upper (sort), 1, 1) as title, count(*) as count", "", array(), -1); | |
| 50 | 50 | $entryArray = array(); | 
| 51 | - while ($post = $result->fetchObject ()) | |
| 51 | + while ($post = $result->fetchObject()) | |
| 52 | 52 |          { | 
| 53 | - array_push ($entryArray, new Entry ($post->title, Author::getEntryIdByLetter ($post->title), | |
| 54 | -                str_format (localize("authorword", $post->count), $post->count), "text", | |
| 55 | -                array ( new LinkNavigation ("?page=".parent::PAGE_AUTHORS_FIRST_LETTER."&id=". rawurlencode ($post->title))), "", $post->count)); | |
| 53 | + array_push($entryArray, new Entry($post->title, Author::getEntryIdByLetter($post->title), | |
| 54 | +                str_format(localize("authorword", $post->count), $post->count), "text", | |
| 55 | +                array(new LinkNavigation("?page=" . parent::PAGE_AUTHORS_FIRST_LETTER . "&id=" . rawurlencode($post->title))), "", $post->count)); | |
| 56 | 56 | } | 
| 57 | 57 | return $entryArray; | 
| 58 | 58 | } | 
| 59 | 59 | |
| 60 | 60 |      public static function getAuthorsByStartingLetter($letter) { | 
| 61 | - return self::getEntryArray (self::SQL_AUTHORS_BY_FIRST_LETTER, array ($letter . "%")); | |
| 61 | + return self::getEntryArray(self::SQL_AUTHORS_BY_FIRST_LETTER, array($letter . "%")); | |
| 62 | 62 | } | 
| 63 | 63 | |
| 64 | 64 |      public static function getAuthorsForSearch($query) { | 
| 65 | - return self::getEntryArray (self::SQL_AUTHORS_FOR_SEARCH, array ($query . "%", $query . "%")); | |
| 65 | + return self::getEntryArray(self::SQL_AUTHORS_FOR_SEARCH, array($query . "%", $query . "%")); | |
| 66 | 66 | } | 
| 67 | 67 | |
| 68 | 68 |      public static function getAllAuthors() { | 
| 69 | - return self::getEntryArray (self::SQL_ALL_AUTHORS, array ()); | |
| 69 | + return self::getEntryArray(self::SQL_ALL_AUTHORS, array()); | |
| 70 | 70 | } | 
| 71 | 71 | |
| 72 | -    public static function getEntryArray ($query, $params) { | |
| 73 | - return Base::getEntryArrayWithBookNumber ($query, self::AUTHOR_COLUMNS, $params, "Author"); | |
| 72 | +    public static function getEntryArray($query, $params) { | |
| 73 | + return Base::getEntryArrayWithBookNumber($query, self::AUTHOR_COLUMNS, $params, "Author"); | |
| 74 | 74 | } | 
| 75 | 75 | |
| 76 | -    public static function getAuthorById ($authorId) { | |
| 77 | -        $result = parent::getDb ()->prepare('select ' . self::AUTHOR_COLUMNS . ' from authors where id = ?'); | |
| 78 | - $result->execute (array ($authorId)); | |
| 79 | - $post = $result->fetchObject (); | |
| 80 | - return new Author ($post); | |
| 76 | +    public static function getAuthorById($authorId) { | |
| 77 | +        $result = parent::getDb()->prepare('select ' . self::AUTHOR_COLUMNS . ' from authors where id = ?'); | |
| 78 | + $result->execute(array($authorId)); | |
| 79 | + $post = $result->fetchObject(); | |
| 80 | + return new Author($post); | |
| 81 | 81 | } | 
| 82 | 82 | |
| 83 | -    public static function getAuthorByBookId ($bookId) { | |
| 84 | -        $result = parent::getDb ()->prepare('select authors.id as id, authors.name as name, authors.sort as sort from authors, books_authors_link | |
| 83 | +    public static function getAuthorByBookId($bookId) { | |
| 84 | +        $result = parent::getDb()->prepare('select authors.id as id, authors.name as name, authors.sort as sort from authors, books_authors_link | |
| 85 | 85 | where author = authors.id | 
| 86 | 86 | and book = ?'); | 
| 87 | - $result->execute (array ($bookId)); | |
| 88 | - $authorArray = array (); | |
| 89 | -        while ($post = $result->fetchObject ()) { | |
| 90 | - array_push ($authorArray, new Author ($post)); | |
| 87 | + $result->execute(array($bookId)); | |
| 88 | + $authorArray = array(); | |
| 89 | +        while ($post = $result->fetchObject()) { | |
| 90 | + array_push($authorArray, new Author($post)); | |
| 91 | 91 | } | 
| 92 | 92 | return $authorArray; | 
| 93 | 93 | } | 
| @@ -19,37 +19,42 @@ discard block | ||
| 19 | 19 | public $name; | 
| 20 | 20 | public $sort; | 
| 21 | 21 | |
| 22 | -    public function __construct($post) { | |
| 22 | + public function __construct($post) | |
| 23 | +    { | |
| 23 | 24 | $this->id = $post->id; | 
| 24 | 25 |          $this->name = str_replace("|", ",", $post->name); | 
| 25 | 26 | $this->sort = $post->sort; | 
| 26 | 27 | } | 
| 27 | 28 | |
| 28 | -    public function getUri () { | |
| 29 | + public function getUri () | |
| 30 | +    { | |
| 29 | 31 | return "?page=".parent::PAGE_AUTHOR_DETAIL."&id=$this->id"; | 
| 30 | 32 | } | 
| 31 | 33 | |
| 32 | -    public function getEntryId () { | |
| 34 | + public function getEntryId () | |
| 35 | +    { | |
| 33 | 36 | return self::ALL_AUTHORS_ID.":".$this->id; | 
| 34 | 37 | } | 
| 35 | 38 | |
| 36 | -    public static function getEntryIdByLetter ($startingLetter) { | |
| 39 | + public static function getEntryIdByLetter ($startingLetter) | |
| 40 | +    { | |
| 37 | 41 | return self::ALL_AUTHORS_ID.":letter:".$startingLetter; | 
| 38 | 42 | } | 
| 39 | 43 | |
| 40 | -    public static function getCount() { | |
| 44 | + public static function getCount() | |
| 45 | +    { | |
| 41 | 46 |          // str_format (localize("authors.alphabetical", count(array)) | 
| 42 | 47 |          return parent::getCountGeneric ("authors", self::ALL_AUTHORS_ID, parent::PAGE_ALL_AUTHORS); | 
| 43 | 48 | } | 
| 44 | 49 | |
| 45 | -    public static function getAllAuthorsByFirstLetter() { | |
| 50 | + public static function getAllAuthorsByFirstLetter() | |
| 51 | +    { | |
| 46 | 52 |          list (, $result) = parent::executeQuery ("select {0} | 
| 47 | 53 | from authors | 
| 48 | 54 | group by substr (upper (sort), 1, 1) | 
| 49 | 55 | order by substr (upper (sort), 1, 1)", "substr (upper (sort), 1, 1) as title, count(*) as count", "", array (), -1); | 
| 50 | 56 | $entryArray = array(); | 
| 51 | - while ($post = $result->fetchObject ()) | |
| 52 | -        { | |
| 57 | +        while ($post = $result->fetchObject ()) { | |
| 53 | 58 | array_push ($entryArray, new Entry ($post->title, Author::getEntryIdByLetter ($post->title), | 
| 54 | 59 |                  str_format (localize("authorword", $post->count), $post->count), "text", | 
| 55 | 60 |                  array ( new LinkNavigation ("?page=".parent::PAGE_AUTHORS_FIRST_LETTER."&id=". rawurlencode ($post->title))), "", $post->count)); | 
| @@ -57,30 +62,36 @@ discard block | ||
| 57 | 62 | return $entryArray; | 
| 58 | 63 | } | 
| 59 | 64 | |
| 60 | -    public static function getAuthorsByStartingLetter($letter) { | |
| 65 | + public static function getAuthorsByStartingLetter($letter) | |
| 66 | +    { | |
| 61 | 67 | return self::getEntryArray (self::SQL_AUTHORS_BY_FIRST_LETTER, array ($letter . "%")); | 
| 62 | 68 | } | 
| 63 | 69 | |
| 64 | -    public static function getAuthorsForSearch($query) { | |
| 70 | + public static function getAuthorsForSearch($query) | |
| 71 | +    { | |
| 65 | 72 | return self::getEntryArray (self::SQL_AUTHORS_FOR_SEARCH, array ($query . "%", $query . "%")); | 
| 66 | 73 | } | 
| 67 | 74 | |
| 68 | -    public static function getAllAuthors() { | |
| 75 | + public static function getAllAuthors() | |
| 76 | +    { | |
| 69 | 77 | return self::getEntryArray (self::SQL_ALL_AUTHORS, array ()); | 
| 70 | 78 | } | 
| 71 | 79 | |
| 72 | -    public static function getEntryArray ($query, $params) { | |
| 80 | + public static function getEntryArray ($query, $params) | |
| 81 | +    { | |
| 73 | 82 | return Base::getEntryArrayWithBookNumber ($query, self::AUTHOR_COLUMNS, $params, "Author"); | 
| 74 | 83 | } | 
| 75 | 84 | |
| 76 | -    public static function getAuthorById ($authorId) { | |
| 85 | + public static function getAuthorById ($authorId) | |
| 86 | +    { | |
| 77 | 87 |          $result = parent::getDb ()->prepare('select ' . self::AUTHOR_COLUMNS . ' from authors where id = ?'); | 
| 78 | 88 | $result->execute (array ($authorId)); | 
| 79 | 89 | $post = $result->fetchObject (); | 
| 80 | 90 | return new Author ($post); | 
| 81 | 91 | } | 
| 82 | 92 | |
| 83 | -    public static function getAuthorByBookId ($bookId) { | |
| 93 | + public static function getAuthorByBookId ($bookId) | |
| 94 | +    { | |
| 84 | 95 |          $result = parent::getDb ()->prepare('select authors.id as id, authors.name as name, authors.sort as sort from authors, books_authors_link | 
| 85 | 96 | where author = authors.id | 
| 86 | 97 | and book = ?'); | 
| @@ -84,6 +84,9 @@ discard block | ||
| 84 | 84 | return ""; | 
| 85 | 85 | } | 
| 86 | 86 | |
| 87 | + /** | |
| 88 | + * @return string | |
| 89 | + */ | |
| 87 | 90 |      public static function getDbDirectory ($database = NULL) { | 
| 88 | 91 | global $config; | 
| 89 | 92 |          if (self::isMultipleDatabaseEnabled ()) { | 
| @@ -143,10 +146,18 @@ discard block | ||
| 143 | 146 | self::$db = NULL; | 
| 144 | 147 | } | 
| 145 | 148 | |
| 149 | + /** | |
| 150 | + * @param string $query | |
| 151 | + */ | |
| 146 | 152 |      public static function executeQuerySingle ($query, $database = NULL) { | 
| 147 | 153 | return self::getDb ($database)->query($query)->fetchColumn(); | 
| 148 | 154 | } | 
| 149 | 155 | |
| 156 | + /** | |
| 157 | + * @param string $table | |
| 158 | + * @param string $id | |
| 159 | + * @param string $numberOfString | |
| 160 | + */ | |
| 150 | 161 |      public static function getCountGeneric($table, $id, $pageId, $numberOfString = NULL) { | 
| 151 | 162 |          if (!$numberOfString) { | 
| 152 | 163 | $numberOfString = $table . ".alphabetical"; | 
| @@ -159,6 +170,10 @@ discard block | ||
| 159 | 170 | return $entry; | 
| 160 | 171 | } | 
| 161 | 172 | |
| 173 | + /** | |
| 174 | + * @param string $columns | |
| 175 | + * @param string $category | |
| 176 | + */ | |
| 162 | 177 |      public static function getEntryArrayWithBookNumber ($query, $columns, $params, $category) { | 
| 163 | 178 | /* @var $result PDOStatement */ | 
| 164 | 179 | |
| @@ -181,6 +196,9 @@ discard block | ||
| 181 | 196 | return $entryArray; | 
| 182 | 197 | } | 
| 183 | 198 | |
| 199 | + /** | |
| 200 | + * @param string $filter | |
| 201 | + */ | |
| 184 | 202 |      public static function executeQuery($query, $columns, $filter, $params, $n, $database = NULL, $numberPerPage = NULL) { | 
| 185 | 203 | $totalResult = -1; | 
| 186 | 204 | |
| @@ -37,146 +37,146 @@ 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 | - self::error ($database); | |
| 79 | + 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 | - self::error ($database); | |
| 92 | + 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) { | |
| 162 | +    public static function getEntryArrayWithBookNumber($query, $columns, $params, $category) { | |
| 163 | 163 | /* @var $result PDOStatement */ | 
| 164 | 164 | |
| 165 | - list (, $result) = self::executeQuery ($query, $columns, "", $params, -1); | |
| 165 | + list (, $result) = self::executeQuery($query, $columns, "", $params, -1); | |
| 166 | 166 | $entryArray = array(); | 
| 167 | - while ($post = $result->fetchObject ()) | |
| 167 | + while ($post = $result->fetchObject()) | |
| 168 | 168 |          { | 
| 169 | 169 | /* @var $instance Author|Tag|Serie|Publisher */ | 
| 170 | 170 | |
| 171 | - $instance = new $category ($post); | |
| 171 | + $instance = new $category($post); | |
| 172 | 172 |              if (property_exists($post, "sort")) { | 
| 173 | 173 | $title = $post->sort; | 
| 174 | 174 |              } else { | 
| 175 | 175 | $title = $post->name; | 
| 176 | 176 | } | 
| 177 | - array_push ($entryArray, new Entry ($title, $instance->getEntryId (), | |
| 178 | -                str_format (localize("bookword", $post->count), $post->count), "text", | |
| 179 | - array ( new LinkNavigation ($instance->getUri ())), "", $post->count)); | |
| 177 | + array_push($entryArray, new Entry($title, $instance->getEntryId(), | |
| 178 | +                str_format(localize("bookword", $post->count), $post->count), "text", | |
| 179 | + array(new LinkNavigation($instance->getUri())), "", $post->count)); | |
| 180 | 180 | } | 
| 181 | 181 | return $entryArray; | 
| 182 | 182 | } | 
| @@ -184,30 +184,30 @@ discard block | ||
| 184 | 184 |      public static function executeQuery($query, $columns, $filter, $params, $n, $database = NULL, $numberPerPage = NULL) { | 
| 185 | 185 | $totalResult = -1; | 
| 186 | 186 | |
| 187 | -        if (useNormAndUp ()) { | |
| 187 | +        if (useNormAndUp()) { | |
| 188 | 188 |              $query = preg_replace("/upper/", "normAndUp", $query); | 
| 189 | 189 |              $columns = preg_replace("/upper/", "normAndUp", $columns); | 
| 190 | 190 | } | 
| 191 | 191 | |
| 192 | -        if (is_null ($numberPerPage)) { | |
| 193 | -            $numberPerPage = getCurrentOption ("max_item_per_page"); | |
| 192 | +        if (is_null($numberPerPage)) { | |
| 193 | +            $numberPerPage = getCurrentOption("max_item_per_page"); | |
| 194 | 194 | } | 
| 195 | 195 | |
| 196 | 196 | if ($numberPerPage != -1 && $n != -1) | 
| 197 | 197 |          { | 
| 198 | 198 | // First check total number of results | 
| 199 | - $result = self::getDb ($database)->prepare (str_format ($query, "count(*)", $filter)); | |
| 200 | - $result->execute ($params); | |
| 201 | - $totalResult = $result->fetchColumn (); | |
| 199 | + $result = self::getDb($database)->prepare(str_format($query, "count(*)", $filter)); | |
| 200 | + $result->execute($params); | |
| 201 | + $totalResult = $result->fetchColumn(); | |
| 202 | 202 | |
| 203 | 203 | // Next modify the query and params | 
| 204 | 204 | $query .= " limit ?, ?"; | 
| 205 | - array_push ($params, ($n - 1) * $numberPerPage, $numberPerPage); | |
| 205 | + array_push($params, ($n - 1) * $numberPerPage, $numberPerPage); | |
| 206 | 206 | } | 
| 207 | 207 | |
| 208 | - $result = self::getDb ($database)->prepare(str_format ($query, $columns, $filter)); | |
| 209 | - $result->execute ($params); | |
| 210 | - return array ($totalResult, $result); | |
| 208 | + $result = self::getDb($database)->prepare(str_format($query, $columns, $filter)); | |
| 209 | + $result->execute($params); | |
| 210 | + return array($totalResult, $result); | |
| 211 | 211 | } | 
| 212 | 212 | |
| 213 | 213 | } | 
| @@ -37,23 +37,27 @@ discard block | ||
| 37 | 37 | |
| 38 | 38 | private static $db = NULL; | 
| 39 | 39 | |
| 40 | -    public static function isMultipleDatabaseEnabled () { | |
| 40 | + public static function isMultipleDatabaseEnabled () | |
| 41 | +    { | |
| 41 | 42 | global $config; | 
| 42 | 43 | return is_array ($config['calibre_directory']); | 
| 43 | 44 | } | 
| 44 | 45 | |
| 45 | -    public static function useAbsolutePath () { | |
| 46 | + public static function useAbsolutePath () | |
| 47 | +    { | |
| 46 | 48 | global $config; | 
| 47 | 49 | $path = self::getDbDirectory(); | 
| 48 | 50 |          return preg_match ('/^\//', $path) || // Linux / | 
| 49 | 51 |                 preg_match ('/^\w\:/', $path); // Windows X: | 
| 50 | 52 | } | 
| 51 | 53 | |
| 52 | -    public static function noDatabaseSelected () { | |
| 54 | + public static function noDatabaseSelected () | |
| 55 | +    { | |
| 53 | 56 | return self::isMultipleDatabaseEnabled () && is_null (GetUrlParam (DB)); | 
| 54 | 57 | } | 
| 55 | 58 | |
| 56 | -    public static function getDbList () { | |
| 59 | + public static function getDbList () | |
| 60 | +    { | |
| 57 | 61 | global $config; | 
| 58 | 62 |          if (self::isMultipleDatabaseEnabled ()) { | 
| 59 | 63 | return $config['calibre_directory']; | 
| @@ -62,7 +66,8 @@ discard block | ||
| 62 | 66 | } | 
| 63 | 67 | } | 
| 64 | 68 | |
| 65 | -    public static function getDbNameList () { | |
| 69 | + public static function getDbNameList () | |
| 70 | +    { | |
| 66 | 71 | global $config; | 
| 67 | 72 |          if (self::isMultipleDatabaseEnabled ()) { | 
| 68 | 73 | return array_keys ($config['calibre_directory']); | 
| @@ -71,10 +76,13 @@ discard block | ||
| 71 | 76 | } | 
| 72 | 77 | } | 
| 73 | 78 | |
| 74 | -    public static function getDbName ($database = NULL) { | |
| 79 | + public static function getDbName ($database = NULL) | |
| 80 | +    { | |
| 75 | 81 | global $config; | 
| 76 | 82 |          if (self::isMultipleDatabaseEnabled ()) { | 
| 77 | - if (is_null ($database)) $database = GetUrlParam (DB, 0); | |
| 83 | +            if (is_null ($database)) { | |
| 84 | + $database = GetUrlParam (DB, 0); | |
| 85 | + } | |
| 78 | 86 |              if (!is_null($database) && !preg_match('/^\d+$/', $database)) { | 
| 79 | 87 | self::error ($database); | 
| 80 | 88 | } | 
| @@ -84,10 +92,13 @@ discard block | ||
| 84 | 92 | return ""; | 
| 85 | 93 | } | 
| 86 | 94 | |
| 87 | -    public static function getDbDirectory ($database = NULL) { | |
| 95 | + public static function getDbDirectory ($database = NULL) | |
| 96 | +    { | |
| 88 | 97 | global $config; | 
| 89 | 98 |          if (self::isMultipleDatabaseEnabled ()) { | 
| 90 | - if (is_null ($database)) $database = GetUrlParam (DB, 0); | |
| 99 | +            if (is_null ($database)) { | |
| 100 | + $database = GetUrlParam (DB, 0); | |
| 101 | + } | |
| 91 | 102 |              if (!is_null($database) && !preg_match('/^\d+$/', $database)) { | 
| 92 | 103 | self::error ($database); | 
| 93 | 104 | } | 
| @@ -98,18 +109,21 @@ discard block | ||
| 98 | 109 | } | 
| 99 | 110 | |
| 100 | 111 | |
| 101 | -    public static function getDbFileName ($database = NULL) { | |
| 112 | + public static function getDbFileName ($database = NULL) | |
| 113 | +    { | |
| 102 | 114 | return self::getDbDirectory ($database) .'metadata.db'; | 
| 103 | 115 | } | 
| 104 | 116 | |
| 105 | -    private static function error ($database) { | |
| 117 | + private static function error ($database) | |
| 118 | +    { | |
| 106 | 119 |          if (php_sapi_name() != "cli") { | 
| 107 | 120 |              header("location: checkconfig.php?err=1"); | 
| 108 | 121 | } | 
| 109 | 122 |          throw new Exception("Database <{$database}> not found."); | 
| 110 | 123 | } | 
| 111 | 124 | |
| 112 | -    public static function getDb ($database = NULL) { | |
| 125 | + public static function getDb ($database = NULL) | |
| 126 | +    { | |
| 113 | 127 |          if (is_null (self::$db)) { | 
| 114 | 128 |              try { | 
| 115 | 129 |                  if (is_readable (self::getDbFileName ($database))) { | 
| @@ -127,7 +141,8 @@ discard block | ||
| 127 | 141 | return self::$db; | 
| 128 | 142 | } | 
| 129 | 143 | |
| 130 | -    public static function checkDatabaseAvailability () { | |
| 144 | + public static function checkDatabaseAvailability () | |
| 145 | +    { | |
| 131 | 146 |          if (self::noDatabaseSelected ()) { | 
| 132 | 147 |              for ($i = 0; $i < count (self::getDbList ()); $i++) { | 
| 133 | 148 | self::getDb ($i); | 
| @@ -139,33 +154,38 @@ discard block | ||
| 139 | 154 | return true; | 
| 140 | 155 | } | 
| 141 | 156 | |
| 142 | -    public static function clearDb () { | |
| 157 | + public static function clearDb () | |
| 158 | +    { | |
| 143 | 159 | self::$db = NULL; | 
| 144 | 160 | } | 
| 145 | 161 | |
| 146 | -    public static function executeQuerySingle ($query, $database = NULL) { | |
| 162 | + public static function executeQuerySingle ($query, $database = NULL) | |
| 163 | +    { | |
| 147 | 164 | return self::getDb ($database)->query($query)->fetchColumn(); | 
| 148 | 165 | } | 
| 149 | 166 | |
| 150 | -    public static function getCountGeneric($table, $id, $pageId, $numberOfString = NULL) { | |
| 167 | + public static function getCountGeneric($table, $id, $pageId, $numberOfString = NULL) | |
| 168 | +    { | |
| 151 | 169 |          if (!$numberOfString) { | 
| 152 | 170 | $numberOfString = $table . ".alphabetical"; | 
| 153 | 171 | } | 
| 154 | 172 |          $count = self::executeQuerySingle ('select count(*) from ' . $table); | 
| 155 | - if ($count == 0) return NULL; | |
| 173 | +        if ($count == 0) { | |
| 174 | + return NULL; | |
| 175 | + } | |
| 156 | 176 | $entry = new Entry (localize($table . ".title"), $id, | 
| 157 | 177 | str_format (localize($numberOfString, $count), $count), "text", | 
| 158 | 178 |              array ( new LinkNavigation ("?page=".$pageId)), "", $count); | 
| 159 | 179 | return $entry; | 
| 160 | 180 | } | 
| 161 | 181 | |
| 162 | -    public static function getEntryArrayWithBookNumber ($query, $columns, $params, $category) { | |
| 182 | + public static function getEntryArrayWithBookNumber ($query, $columns, $params, $category) | |
| 183 | +    { | |
| 163 | 184 | /* @var $result PDOStatement */ | 
| 164 | 185 | |
| 165 | 186 | list (, $result) = self::executeQuery ($query, $columns, "", $params, -1); | 
| 166 | 187 | $entryArray = array(); | 
| 167 | - while ($post = $result->fetchObject ()) | |
| 168 | -        { | |
| 188 | +        while ($post = $result->fetchObject ()) { | |
| 169 | 189 | /* @var $instance Author|Tag|Serie|Publisher */ | 
| 170 | 190 | |
| 171 | 191 | $instance = new $category ($post); | 
| @@ -181,7 +201,8 @@ discard block | ||
| 181 | 201 | return $entryArray; | 
| 182 | 202 | } | 
| 183 | 203 | |
| 184 | -    public static function executeQuery($query, $columns, $filter, $params, $n, $database = NULL, $numberPerPage = NULL) { | |
| 204 | + public static function executeQuery($query, $columns, $filter, $params, $n, $database = NULL, $numberPerPage = NULL) | |
| 205 | +    { | |
| 185 | 206 | $totalResult = -1; | 
| 186 | 207 | |
| 187 | 208 |          if (useNormAndUp ()) { | 
| @@ -193,8 +214,7 @@ discard block | ||
| 193 | 214 |              $numberPerPage = getCurrentOption ("max_item_per_page"); | 
| 194 | 215 | } | 
| 195 | 216 | |
| 196 | - if ($numberPerPage != -1 && $n != -1) | |
| 197 | -        { | |
| 217 | +        if ($numberPerPage != -1 && $n != -1) { | |
| 198 | 218 | // First check total number of results | 
| 199 | 219 | $result = self::getDb ($database)->prepare (str_format ($query, "count(*)", $filter)); | 
| 200 | 220 | $result->execute ($params); | 
| @@ -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); | 
| @@ -181,7 +181,7 @@ discard block | ||
| 181 | 181 | return $entryArray; | 
| 182 | 182 | } | 
| 183 | 183 | |
| 184 | -    public static function executeQuery($query, $columns, $filter, $params, $n, $database = NULL, $numberPerPage = NULL) { | |
| 184 | +    public static function executeQuery($query, $columns, $filter, $params, $n, $database = null, $numberPerPage = null) { | |
| 185 | 185 | $totalResult = -1; | 
| 186 | 186 | |
| 187 | 187 |          if (useNormAndUp ()) { | 
| @@ -144,6 +144,9 @@ discard block | ||
| 144 | 144 | return 'index.php' . $urlParam; | 
| 145 | 145 | } | 
| 146 | 146 | |
| 147 | + /** | |
| 148 | + * @return string | |
| 149 | + */ | |
| 147 | 150 |      public function getTitle () { | 
| 148 | 151 | return $this->title; | 
| 149 | 152 | } | 
| @@ -331,6 +334,9 @@ discard block | ||
| 331 | 334 | return reset($reduced); | 
| 332 | 335 | } | 
| 333 | 336 | |
| 337 | + /** | |
| 338 | + * @param string $extension | |
| 339 | + */ | |
| 334 | 340 | public function getFilePath($extension, $idData = NULL, $relative = false) | 
| 335 | 341 |      { | 
| 336 | 342 | if ($extension == 'jpg') | 
| @@ -464,6 +470,9 @@ discard block | ||
| 464 | 470 | $this->getLinkArray(), $this); | 
| 465 | 471 | } | 
| 466 | 472 | |
| 473 | + /** | |
| 474 | + * @param integer $database | |
| 475 | + */ | |
| 467 | 476 |      public static function getBookCount($database = NULL) { | 
| 468 | 477 |          return parent::executeQuerySingle('select count(*) from books', $database); | 
| 469 | 478 | } | 
| @@ -512,7 +521,7 @@ discard block | ||
| 512 | 521 | } | 
| 513 | 522 | |
| 514 | 523 | /** | 
| 515 | - * @param $customColumn CustomColumn | |
| 524 | + * @param CustomColumn $customColumn CustomColumn | |
| 516 | 525 | * @param $id integer | 
| 517 | 526 | * @param $n integer | 
| 518 | 527 | * @return array | 
| @@ -552,6 +561,10 @@ discard block | ||
| 552 | 561 | return NULL; | 
| 553 | 562 | } | 
| 554 | 563 | |
| 564 | + /** | |
| 565 | + * @param integer $database | |
| 566 | + * @param integer $numberPerPage | |
| 567 | + */ | |
| 555 | 568 |      public static function getBooksByQuery($query, $n, $database = NULL, $numberPerPage = NULL) { | 
| 556 | 569 | $i = 0; | 
| 557 | 570 | $critArray = array(); | 
| @@ -599,6 +612,9 @@ discard block | ||
| 599 | 612 | return $entryArray; | 
| 600 | 613 | } | 
| 601 | 614 | |
| 615 | + /** | |
| 616 | + * @param integer $numberPerPage | |
| 617 | + */ | |
| 602 | 618 |      public static function getBooksByStartingLetter($letter, $n, $database = NULL, $numberPerPage = NULL) { | 
| 603 | 619 | return self::getEntryArray(self::SQL_BOOKS_BY_FIRST_LETTER, array($letter . '%'), $n, $database, $numberPerPage); | 
| 604 | 620 | } | 
| @@ -473,15 +473,15 @@ discard block | ||
| 473 | 473 |          $nBooks = parent::executeQuerySingle('select count(*) from books'); | 
| 474 | 474 | $result = array(); | 
| 475 | 475 |          $entry = new Entry(localize('allbooks.title'), | 
| 476 | - self::ALL_BOOKS_ID, | |
| 477 | -                          str_format(localize('allbooks.alphabetical', $nBooks), $nBooks), 'text', | |
| 478 | -                          array(new LinkNavigation('?page='.parent::PAGE_ALL_BOOKS)), '', $nBooks); | |
| 476 | + self::ALL_BOOKS_ID, | |
| 477 | +                            str_format(localize('allbooks.alphabetical', $nBooks), $nBooks), 'text', | |
| 478 | +                            array(new LinkNavigation('?page='.parent::PAGE_ALL_BOOKS)), '', $nBooks); | |
| 479 | 479 | array_push($result, $entry); | 
| 480 | 480 |          if ($config['cops_recentbooks_limit'] > 0) { | 
| 481 | 481 |              $entry = new Entry(localize('recent.title'), | 
| 482 | - self::ALL_RECENT_BOOKS_ID, | |
| 483 | -                              str_format(localize('recent.list'), $config['cops_recentbooks_limit']), 'text', | |
| 484 | -                              array ( new LinkNavigation ('?page='.parent::PAGE_ALL_RECENT_BOOKS)), '', $config['cops_recentbooks_limit']); | |
| 482 | + self::ALL_RECENT_BOOKS_ID, | |
| 483 | +                                str_format(localize('recent.list'), $config['cops_recentbooks_limit']), 'text', | |
| 484 | +                                array ( new LinkNavigation ('?page='.parent::PAGE_ALL_RECENT_BOOKS)), '', $config['cops_recentbooks_limit']); | |
| 485 | 485 | array_push($result, $entry); | 
| 486 | 486 | } | 
| 487 | 487 | return $result; | 
| @@ -556,10 +556,10 @@ discard block | ||
| 556 | 556 | $i = 0; | 
| 557 | 557 | $critArray = array(); | 
| 558 | 558 | foreach (array(PageQueryResult::SCOPE_AUTHOR, | 
| 559 | - PageQueryResult::SCOPE_TAG, | |
| 560 | - PageQueryResult::SCOPE_SERIES, | |
| 561 | - PageQueryResult::SCOPE_PUBLISHER, | |
| 562 | -                       PageQueryResult::SCOPE_BOOK) as $key) { | |
| 559 | + PageQueryResult::SCOPE_TAG, | |
| 560 | + PageQueryResult::SCOPE_SERIES, | |
| 561 | + PageQueryResult::SCOPE_PUBLISHER, | |
| 562 | +                        PageQueryResult::SCOPE_BOOK) as $key) { | |
| 563 | 563 |              if (in_array($key, getCurrentOption('ignored_categories')) || | 
| 564 | 564 |                  (!array_key_exists($key, $query) && !array_key_exists('all', $query))) { | 
| 565 | 565 | $critArray[$i] = self::BAD_SEARCH; | 
| @@ -99,12 +99,12 @@ discard block | ||
| 99 | 99 | public $seriesIndex; | 
| 100 | 100 | public $comment; | 
| 101 | 101 | public $rating; | 
| 102 | - public $datas = NULL; | |
| 103 | - public $authors = NULL; | |
| 104 | - public $publisher = NULL; | |
| 105 | - public $serie = NULL; | |
| 106 | - public $tags = NULL; | |
| 107 | - public $languages = NULL; | |
| 102 | + public $datas = null; | |
| 103 | + public $authors = null; | |
| 104 | + public $publisher = null; | |
| 105 | + public $serie = null; | |
| 106 | + public $tags = null; | |
| 107 | + public $languages = null; | |
| 108 | 108 | public $format = array (); | 
| 109 | 109 | |
| 110 | 110 | |
| @@ -242,7 +242,7 @@ discard block | ||
| 242 | 242 | /* End of other class (author, series, tag, ...) initialization and accessors */ | 
| 243 | 243 | |
| 244 | 244 |      public static function getFilterString() { | 
| 245 | -        $filter = getURLParam('tag', NULL); | |
| 245 | +        $filter = getURLParam('tag', null); | |
| 246 | 246 | if (empty($filter)) return ''; | 
| 247 | 247 | |
| 248 | 248 | $exists = true; | 
| @@ -264,7 +264,7 @@ discard block | ||
| 264 | 264 |      { | 
| 265 | 265 |          $bestFormatForKindle = array('EPUB', 'PDF', 'AZW3', 'MOBI'); | 
| 266 | 266 | $bestRank = -1; | 
| 267 | - $bestData = NULL; | |
| 267 | + $bestData = null; | |
| 268 | 268 |          foreach ($this->getDatas() as $data) { | 
| 269 | 269 | $key = array_search($data->format, $bestFormatForKindle); | 
| 270 | 270 |              if ($key !== false && $key > $bestRank) { | 
| @@ -331,7 +331,7 @@ discard block | ||
| 331 | 331 | return reset($reduced); | 
| 332 | 332 | } | 
| 333 | 333 | |
| 334 | - public function getFilePath($extension, $idData = NULL, $relative = false) | |
| 334 | + public function getFilePath($extension, $idData = null, $relative = false) | |
| 335 | 335 |      { | 
| 336 | 336 | if ($extension == 'jpg') | 
| 337 | 337 |          { | 
| @@ -340,7 +340,7 @@ discard block | ||
| 340 | 340 | else | 
| 341 | 341 |          { | 
| 342 | 342 | $data = $this->getDataById($idData); | 
| 343 | - if (!$data) return NULL; | |
| 343 | + if (!$data) return null; | |
| 344 | 344 | $file = $data->name . '.' . strtolower($data->format); | 
| 345 | 345 | } | 
| 346 | 346 | |
| @@ -390,7 +390,7 @@ discard block | ||
| 390 | 390 | } | 
| 391 | 391 | } | 
| 392 | 392 | |
| 393 | -    public function getThumbnail($width, $height, $outputfile = NULL) { | |
| 393 | +    public function getThumbnail($width, $height, $outputfile = null) { | |
| 394 | 394 |          if (is_null($width) && is_null($height)) { | 
| 395 | 395 | return false; | 
| 396 | 396 | } | 
| @@ -431,9 +431,9 @@ discard block | ||
| 431 | 431 | |
| 432 | 432 | if ($this->hasCover) | 
| 433 | 433 |          { | 
| 434 | - array_push($linkArray, Data::getLink($this, 'jpg', 'image/jpeg', Link::OPDS_IMAGE_TYPE, 'cover.jpg', NULL)); | |
| 434 | + array_push($linkArray, Data::getLink($this, 'jpg', 'image/jpeg', Link::OPDS_IMAGE_TYPE, 'cover.jpg', null)); | |
| 435 | 435 | |
| 436 | - array_push($linkArray, Data::getLink($this, 'jpg', 'image/jpeg', Link::OPDS_THUMBNAIL_TYPE, 'cover.jpg', NULL)); | |
| 436 | + array_push($linkArray, Data::getLink($this, 'jpg', 'image/jpeg', Link::OPDS_THUMBNAIL_TYPE, 'cover.jpg', null)); | |
| 437 | 437 | } | 
| 438 | 438 | |
| 439 | 439 | foreach ($this->getDatas() as $data) | 
| @@ -464,7 +464,7 @@ discard block | ||
| 464 | 464 | $this->getLinkArray(), $this); | 
| 465 | 465 | } | 
| 466 | 466 | |
| 467 | -    public static function getBookCount($database = NULL) { | |
| 467 | +    public static function getBookCount($database = null) { | |
| 468 | 468 |          return parent::executeQuerySingle('select count(*) from books', $database); | 
| 469 | 469 | } | 
| 470 | 470 | |
| @@ -533,7 +533,7 @@ discard block | ||
| 533 | 533 | $book = new Book($post); | 
| 534 | 534 | return $book; | 
| 535 | 535 | } | 
| 536 | - return NULL; | |
| 536 | + return null; | |
| 537 | 537 | } | 
| 538 | 538 | |
| 539 | 539 |      public static function getBookByDataId($dataId) { | 
| @@ -549,10 +549,10 @@ discard block | ||
| 549 | 549 | $book->datas = array($data); | 
| 550 | 550 | return $book; | 
| 551 | 551 | } | 
| 552 | - return NULL; | |
| 552 | + return null; | |
| 553 | 553 | } | 
| 554 | 554 | |
| 555 | -    public static function getBooksByQuery($query, $n, $database = NULL, $numberPerPage = NULL) { | |
| 555 | +    public static function getBooksByQuery($query, $n, $database = null, $numberPerPage = null) { | |
| 556 | 556 | $i = 0; | 
| 557 | 557 | $critArray = array(); | 
| 558 | 558 | foreach (array(PageQueryResult::SCOPE_AUTHOR, | 
| @@ -599,11 +599,11 @@ discard block | ||
| 599 | 599 | return $entryArray; | 
| 600 | 600 | } | 
| 601 | 601 | |
| 602 | -    public static function getBooksByStartingLetter($letter, $n, $database = NULL, $numberPerPage = NULL) { | |
| 602 | +    public static function getBooksByStartingLetter($letter, $n, $database = null, $numberPerPage = null) { | |
| 603 | 603 | return self::getEntryArray(self::SQL_BOOKS_BY_FIRST_LETTER, array($letter . '%'), $n, $database, $numberPerPage); | 
| 604 | 604 | } | 
| 605 | 605 | |
| 606 | -    public static function getEntryArray($query, $params, $n, $database = NULL, $numberPerPage = NULL) { | |
| 606 | +    public static function getEntryArray($query, $params, $n, $database = null, $numberPerPage = null) { | |
| 607 | 607 | /* @var $totalNumber integer */ | 
| 608 | 608 | /* @var $result PDOStatement */ | 
| 609 | 609 | list($totalNumber, $result) = parent::executeQuery($query, self::BOOK_COLUMNS, self::getFilterString(), $params, $n, $database, $numberPerPage); | 
| @@ -7,55 +7,55 @@ discard block | ||
| 7 | 7 | */ | 
| 8 | 8 | |
| 9 | 9 | // Silly thing because PHP forbid string concatenation in class const | 
| 10 | -define ('SQL_BOOKS_LEFT_JOIN', 'left outer join comments on comments.book = books.id | |
| 10 | +define('SQL_BOOKS_LEFT_JOIN', 'left outer join comments on comments.book = books.id | |
| 11 | 11 | left outer join books_ratings_link on books_ratings_link.book = books.id | 
| 12 | 12 | left outer join ratings on books_ratings_link.rating = ratings.id '); | 
| 13 | -define ('SQL_BOOKS_ALL', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . ' order by books.sort '); | |
| 14 | -define ('SQL_BOOKS_BY_PUBLISHER', 'select {0} from books_publishers_link, books ' . SQL_BOOKS_LEFT_JOIN . ' | |
| 13 | +define('SQL_BOOKS_ALL', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . ' order by books.sort '); | |
| 14 | +define('SQL_BOOKS_BY_PUBLISHER', 'select {0} from books_publishers_link, books ' . SQL_BOOKS_LEFT_JOIN . ' | |
| 15 | 15 |                                                      where books_publishers_link.book = books.id and publisher = ? {1} order by publisher'); | 
| 16 | -define ('SQL_BOOKS_BY_FIRST_LETTER', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . ' | |
| 16 | +define('SQL_BOOKS_BY_FIRST_LETTER', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . ' | |
| 17 | 17 | where upper (books.sort) like ? order by books.sort'); | 
| 18 | -define ('SQL_BOOKS_BY_AUTHOR', 'select {0} from books_authors_link, books ' . SQL_BOOKS_LEFT_JOIN . ' | |
| 18 | +define('SQL_BOOKS_BY_AUTHOR', 'select {0} from books_authors_link, books ' . SQL_BOOKS_LEFT_JOIN . ' | |
| 19 | 19 | left outer join books_series_link on books_series_link.book = books.id | 
| 20 | 20 |                                                      where books_authors_link.book = books.id and author = ? {1} order by series desc, series_index asc, pubdate asc'); | 
| 21 | -define ('SQL_BOOKS_BY_SERIE', 'select {0} from books_series_link, books ' . SQL_BOOKS_LEFT_JOIN . ' | |
| 21 | +define('SQL_BOOKS_BY_SERIE', 'select {0} from books_series_link, books ' . SQL_BOOKS_LEFT_JOIN . ' | |
| 22 | 22 |                                                      where books_series_link.book = books.id and series = ? {1} order by series_index'); | 
| 23 | -define ('SQL_BOOKS_BY_TAG', 'select {0} from books_tags_link, books ' . SQL_BOOKS_LEFT_JOIN . ' | |
| 23 | +define('SQL_BOOKS_BY_TAG', 'select {0} from books_tags_link, books ' . SQL_BOOKS_LEFT_JOIN . ' | |
| 24 | 24 |                                                      where books_tags_link.book = books.id and tag = ? {1} order by sort'); | 
| 25 | -define ('SQL_BOOKS_BY_LANGUAGE', 'select {0} from books_languages_link, books ' . SQL_BOOKS_LEFT_JOIN . ' | |
| 25 | +define('SQL_BOOKS_BY_LANGUAGE', 'select {0} from books_languages_link, books ' . SQL_BOOKS_LEFT_JOIN . ' | |
| 26 | 26 |                                                      where books_languages_link.book = books.id and lang_code = ? {1} order by sort'); | 
| 27 | -define ('SQL_BOOKS_BY_CUSTOM', 'select {0} from {2}, books ' . SQL_BOOKS_LEFT_JOIN . ' | |
| 27 | +define('SQL_BOOKS_BY_CUSTOM', 'select {0} from {2}, books ' . SQL_BOOKS_LEFT_JOIN . ' | |
| 28 | 28 |                                                      where {2}.book = books.id and {2}.{3} = ? {1} order by sort'); | 
| 29 | -define ('SQL_BOOKS_BY_CUSTOM_BOOL_TRUE', 'select {0} from {2}, books ' . SQL_BOOKS_LEFT_JOIN . ' | |
| 29 | +define('SQL_BOOKS_BY_CUSTOM_BOOL_TRUE', 'select {0} from {2}, books ' . SQL_BOOKS_LEFT_JOIN . ' | |
| 30 | 30 |                                                      where {2}.book = books.id and {2}.value = 1 {1} order by sort'); | 
| 31 | -define ('SQL_BOOKS_BY_CUSTOM_BOOL_FALSE', 'select {0} from {2}, books ' . SQL_BOOKS_LEFT_JOIN . ' | |
| 31 | +define('SQL_BOOKS_BY_CUSTOM_BOOL_FALSE', 'select {0} from {2}, books ' . SQL_BOOKS_LEFT_JOIN . ' | |
| 32 | 32 |                                                      where {2}.book = books.id and {2}.value = 0 {1} order by sort'); | 
| 33 | -define ('SQL_BOOKS_BY_CUSTOM_BOOL_NULL', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . ' | |
| 33 | +define('SQL_BOOKS_BY_CUSTOM_BOOL_NULL', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . ' | |
| 34 | 34 |                                                      where books.id not in (select book from {2}) {1} order by sort'); | 
| 35 | -define ('SQL_BOOKS_BY_CUSTOM_RATING', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . ' | |
| 35 | +define('SQL_BOOKS_BY_CUSTOM_RATING', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . ' | |
| 36 | 36 |                                                      left join {2} on {2}.book = books.id | 
| 37 | 37 |                                                      left join {3} on {3}.id = {2}.{4} | 
| 38 | 38 |                                                      where {3}.value = ?  order by sort'); | 
| 39 | -define ('SQL_BOOKS_BY_CUSTOM_RATING_NULL', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . ' | |
| 39 | +define('SQL_BOOKS_BY_CUSTOM_RATING_NULL', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . ' | |
| 40 | 40 |  								                    left join {2} on {2}.book = books.id | 
| 41 | 41 |  								                    left join {3} on {3}.id = {2}.{4} | 
| 42 | 42 |                                                      where ((books.id not in (select {2}.book from {2})) or ({3}.value = 0)) {1} order by sort'); | 
| 43 | -define ('SQL_BOOKS_BY_CUSTOM_DATE', 'select {0} from {2}, books ' . SQL_BOOKS_LEFT_JOIN . ' | |
| 43 | +define('SQL_BOOKS_BY_CUSTOM_DATE', 'select {0} from {2}, books ' . SQL_BOOKS_LEFT_JOIN . ' | |
| 44 | 44 |                                                      where {2}.book = books.id and date({2}.value) = ? {1} order by sort'); | 
| 45 | -define ('SQL_BOOKS_BY_CUSTOM_DIRECT', 'select {0} from {2}, books ' . SQL_BOOKS_LEFT_JOIN . ' | |
| 45 | +define('SQL_BOOKS_BY_CUSTOM_DIRECT', 'select {0} from {2}, books ' . SQL_BOOKS_LEFT_JOIN . ' | |
| 46 | 46 |                                                      where {2}.book = books.id and {2}.value = ? {1} order by sort'); | 
| 47 | -define ('SQL_BOOKS_BY_CUSTOM_DIRECT_ID', 'select {0} from {2}, books ' . SQL_BOOKS_LEFT_JOIN . ' | |
| 47 | +define('SQL_BOOKS_BY_CUSTOM_DIRECT_ID', 'select {0} from {2}, books ' . SQL_BOOKS_LEFT_JOIN . ' | |
| 48 | 48 |                                                      where {2}.book = books.id and {2}.id = ? {1} order by sort'); | 
| 49 | -define ('SQL_BOOKS_QUERY', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . ' | |
| 49 | +define('SQL_BOOKS_QUERY', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . ' | |
| 50 | 50 | where ( | 
| 51 | 51 | exists (select null from authors, books_authors_link where book = books.id and author = authors.id and authors.name like ?) or | 
| 52 | 52 | exists (select null from tags, books_tags_link where book = books.id and tag = tags.id and tags.name like ?) or | 
| 53 | 53 | exists (select null from series, books_series_link on book = books.id and books_series_link.series = series.id and series.name like ?) or | 
| 54 | 54 | exists (select null from publishers, books_publishers_link where book = books.id and books_publishers_link.publisher = publishers.id and publishers.name like ?) or | 
| 55 | 55 |                                                      title like ?) {1} order by books.sort'); | 
| 56 | -define ('SQL_BOOKS_RECENT', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . ' | |
| 56 | +define('SQL_BOOKS_RECENT', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . ' | |
| 57 | 57 |                                                      where 1=1 {1} order by timestamp desc limit '); | 
| 58 | -define ('SQL_BOOKS_BY_RATING', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . ' | |
| 58 | +define('SQL_BOOKS_BY_RATING', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . ' | |
| 59 | 59 |                                                      where books_ratings_link.book = books.id and ratings.id = ? {1} order by sort'); | 
| 60 | 60 | |
| 61 | 61 | class Book extends Base | 
| @@ -105,7 +105,7 @@ discard block | ||
| 105 | 105 | public $serie = NULL; | 
| 106 | 106 | public $tags = NULL; | 
| 107 | 107 | public $languages = NULL; | 
| 108 | - public $format = array (); | |
| 108 | + public $format = array(); | |
| 109 | 109 | |
| 110 | 110 | |
| 111 | 111 |      public function __construct($line) { | 
| @@ -127,24 +127,24 @@ discard block | ||
| 127 | 127 | } | 
| 128 | 128 | |
| 129 | 129 |      public function getEntryId() { | 
| 130 | - return self::ALL_BOOKS_UUID.':'.$this->uuid; | |
| 130 | + return self::ALL_BOOKS_UUID . ':' . $this->uuid; | |
| 131 | 131 | } | 
| 132 | 132 | |
| 133 | -    public static function getEntryIdByLetter ($startingLetter) { | |
| 134 | - return self::ALL_BOOKS_ID.':letter:'.$startingLetter; | |
| 133 | +    public static function getEntryIdByLetter($startingLetter) { | |
| 134 | + return self::ALL_BOOKS_ID . ':letter:' . $startingLetter; | |
| 135 | 135 | } | 
| 136 | 136 | |
| 137 | -    public function getUri () { | |
| 138 | - return '?page='.parent::PAGE_BOOK_DETAIL.'&id=' . $this->id; | |
| 137 | +    public function getUri() { | |
| 138 | + return '?page=' . parent::PAGE_BOOK_DETAIL . '&id=' . $this->id; | |
| 139 | 139 | } | 
| 140 | 140 | |
| 141 | -    public function getDetailUrl () { | |
| 141 | +    public function getDetailUrl() { | |
| 142 | 142 | $urlParam = $this->getUri(); | 
| 143 | - if (!is_null(GetUrlParam(DB))) $urlParam = addURLParameter($urlParam, DB, GetUrlParam (DB)); | |
| 143 | + if (!is_null(GetUrlParam(DB))) $urlParam = addURLParameter($urlParam, DB, GetUrlParam(DB)); | |
| 144 | 144 | return 'index.php' . $urlParam; | 
| 145 | 145 | } | 
| 146 | 146 | |
| 147 | -    public function getTitle () { | |
| 147 | +    public function getTitle() { | |
| 148 | 148 | return $this->title; | 
| 149 | 149 | } | 
| 150 | 150 | |
| @@ -153,22 +153,22 @@ discard block | ||
| 153 | 153 | /** | 
| 154 | 154 | * @return Author[] | 
| 155 | 155 | */ | 
| 156 | -    public function getAuthors () { | |
| 156 | +    public function getAuthors() { | |
| 157 | 157 |          if (is_null($this->authors)) { | 
| 158 | 158 | $this->authors = Author::getAuthorByBookId($this->id); | 
| 159 | 159 | } | 
| 160 | 160 | return $this->authors; | 
| 161 | 161 | } | 
| 162 | 162 | |
| 163 | -    public function getAuthorsName () { | |
| 164 | -        return implode(', ', array_map(function ($author) { return $author->name; }, $this->getAuthors())); | |
| 163 | +    public function getAuthorsName() { | |
| 164 | +        return implode(', ', array_map(function($author) { return $author->name; }, $this->getAuthors())); | |
| 165 | 165 | } | 
| 166 | 166 | |
| 167 | -    public function getAuthorsSort () { | |
| 168 | -        return implode(', ', array_map(function ($author) { return $author->sort; }, $this->getAuthors())); | |
| 167 | +    public function getAuthorsSort() { | |
| 168 | +        return implode(', ', array_map(function($author) { return $author->sort; }, $this->getAuthors())); | |
| 169 | 169 | } | 
| 170 | 170 | |
| 171 | -    public function getPublisher () { | |
| 171 | +    public function getPublisher() { | |
| 172 | 172 |          if (is_null($this->publisher)) { | 
| 173 | 173 | $this->publisher = Publisher::getPublisherByBookId($this->id); | 
| 174 | 174 | } | 
| @@ -207,7 +207,7 @@ discard block | ||
| 207 | 207 | * @return Tag[] | 
| 208 | 208 | */ | 
| 209 | 209 |      public function getTags() { | 
| 210 | -        if (is_null ($this->tags)) { | |
| 210 | +        if (is_null($this->tags)) { | |
| 211 | 211 | $this->tags = array(); | 
| 212 | 212 | |
| 213 | 213 |              $result = parent::getDb()->prepare('select tags.id as id, name | 
| @@ -225,7 +225,7 @@ discard block | ||
| 225 | 225 | } | 
| 226 | 226 | |
| 227 | 227 |      public function getTagsName() { | 
| 228 | -        return implode(', ', array_map(function ($tag) { return $tag->name; }, $this->getTags())); | |
| 228 | +        return implode(', ', array_map(function($tag) { return $tag->name; }, $this->getTags())); | |
| 229 | 229 | } | 
| 230 | 230 | |
| 231 | 231 | /** | 
| @@ -277,7 +277,7 @@ discard block | ||
| 277 | 277 | |
| 278 | 278 | public function getDataById($idData) | 
| 279 | 279 |      { | 
| 280 | -        $reduced = array_filter($this->getDatas(), function ($data) use ($idData) { | |
| 280 | +        $reduced = array_filter($this->getDatas(), function($data) use ($idData) { | |
| 281 | 281 | return $data->id == $idData; | 
| 282 | 282 | }); | 
| 283 | 283 | return reset($reduced); | 
| @@ -301,7 +301,7 @@ discard block | ||
| 301 | 301 |          if (empty ($this->pubdate)) { | 
| 302 | 302 | return ''; | 
| 303 | 303 | } | 
| 304 | - $dateY = (int) substr($this->pubdate, 0, 4); | |
| 304 | + $dateY = (int)substr($this->pubdate, 0, 4); | |
| 305 | 305 |          if ($dateY > 102) { | 
| 306 | 306 | return str_pad($dateY, 4, '0', STR_PAD_LEFT); | 
| 307 | 307 | } | 
| @@ -310,8 +310,8 @@ discard block | ||
| 310 | 310 | |
| 311 | 311 |      public function getComment($withSerie = true) { | 
| 312 | 312 | $addition = ''; | 
| 313 | - $se = $this->getSerie (); | |
| 314 | -        if (!is_null ($se) && $withSerie) { | |
| 313 | + $se = $this->getSerie(); | |
| 314 | +        if (!is_null($se) && $withSerie) { | |
| 315 | 315 |              $addition = $addition . '<strong>' . localize('content.series') . '</strong>' . str_format(localize('content.series.data'), $this->seriesIndex, htmlspecialchars($se->name)) . "<br />\n"; | 
| 316 | 316 | } | 
| 317 | 317 |          if (preg_match('/<\/(div|p|a|span)>/', $this->comment)) | 
| @@ -325,7 +325,7 @@ discard block | ||
| 325 | 325 | } | 
| 326 | 326 | |
| 327 | 327 |      public function getDataFormat($format) { | 
| 328 | -        $reduced = array_filter($this->getDatas(), function ($data) use ($format) { | |
| 328 | +        $reduced = array_filter($this->getDatas(), function($data) use ($format) { | |
| 329 | 329 | return $data->format == $format; | 
| 330 | 330 | }); | 
| 331 | 331 | return reset($reduced); | 
| @@ -346,11 +346,11 @@ discard block | ||
| 346 | 346 | |
| 347 | 347 | if ($relative) | 
| 348 | 348 |          { | 
| 349 | - return $this->relativePath.'/'.$file; | |
| 349 | + return $this->relativePath . '/' . $file; | |
| 350 | 350 | } | 
| 351 | 351 | else | 
| 352 | 352 |          { | 
| 353 | - return $this->path.'/'.$file; | |
| 353 | + return $this->path . '/' . $file; | |
| 354 | 354 | } | 
| 355 | 355 | } | 
| 356 | 356 | |
| @@ -370,7 +370,7 @@ discard block | ||
| 370 | 370 | } | 
| 371 | 371 | $epub->Authors($authorArray); | 
| 372 | 372 | $epub->Language($this->getLanguages()); | 
| 373 | - $epub->Description ($this->getComment(false)); | |
| 373 | + $epub->Description($this->getComment(false)); | |
| 374 | 374 | $epub->Subjects($this->getTagsName()); | 
| 375 | 375 |              $epub->Cover2($this->getFilePath('jpg'), 'image/jpeg'); | 
| 376 | 376 | $epub->Calibre($this->uuid); | 
| @@ -379,7 +379,7 @@ discard block | ||
| 379 | 379 | $epub->Serie($se->name); | 
| 380 | 380 | $epub->SerieIndex($this->seriesIndex); | 
| 381 | 381 | } | 
| 382 | -            if ($config['cops_provide_kepub'] == '1'  && preg_match('/Kobo/', $_SERVER['HTTP_USER_AGENT'])) { | |
| 382 | +            if ($config['cops_provide_kepub'] == '1' && preg_match('/Kobo/', $_SERVER['HTTP_USER_AGENT'])) { | |
| 383 | 383 | $epub->updateForKepub(); | 
| 384 | 384 | } | 
| 385 | 385 | $epub->download($data->getUpdatedFilenameEpub()); | 
| @@ -404,11 +404,11 @@ discard block | ||
| 404 | 404 |              if (!is_null($width)) { | 
| 405 | 405 | $nw = $width; | 
| 406 | 406 |                  if ($nw >= $w) { return false; } | 
| 407 | - $nh = ($nw*$h)/$w; | |
| 407 | + $nh = ($nw * $h) / $w; | |
| 408 | 408 |              } else { | 
| 409 | 409 | $nh = $height; | 
| 410 | 410 |                  if ($nh >= $h) { return false; } | 
| 411 | - $nw = ($nh*$w)/$h; | |
| 411 | + $nw = ($nh * $w) / $h; | |
| 412 | 412 | } | 
| 413 | 413 |          } else { | 
| 414 | 414 | return false; | 
| @@ -416,16 +416,16 @@ discard block | ||
| 416 | 416 | |
| 417 | 417 | //draw the image | 
| 418 | 418 | $src_img = imagecreatefromjpeg($file); | 
| 419 | - $dst_img = imagecreatetruecolor($nw,$nh); | |
| 420 | - imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $nw, $nh, $w, $h);//resizing the image | |
| 421 | - imagejpeg($dst_img,$outputfile,80); | |
| 419 | + $dst_img = imagecreatetruecolor($nw, $nh); | |
| 420 | + imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $nw, $nh, $w, $h); //resizing the image | |
| 421 | + imagejpeg($dst_img, $outputfile, 80); | |
| 422 | 422 | imagedestroy($src_img); | 
| 423 | 423 | imagedestroy($dst_img); | 
| 424 | 424 | |
| 425 | 425 | return true; | 
| 426 | 426 | } | 
| 427 | 427 | |
| 428 | - public function getLinkArray () | |
| 428 | + public function getLinkArray() | |
| 429 | 429 |      { | 
| 430 | 430 | $linkArray = array(); | 
| 431 | 431 | |
| @@ -450,7 +450,7 @@ discard block | ||
| 450 | 450 | } | 
| 451 | 451 | |
| 452 | 452 | $serie = $this->getSerie(); | 
| 453 | -        if (!is_null ($serie)) { | |
| 453 | +        if (!is_null($serie)) { | |
| 454 | 454 |              array_push($linkArray, new LinkNavigation($serie->getUri(), 'related', str_format(localize('content.series.data'), $this->seriesIndex, $serie->name))); | 
| 455 | 455 | } | 
| 456 | 456 | |
| @@ -475,13 +475,13 @@ discard block | ||
| 475 | 475 |          $entry = new Entry(localize('allbooks.title'), | 
| 476 | 476 | self::ALL_BOOKS_ID, | 
| 477 | 477 |                            str_format(localize('allbooks.alphabetical', $nBooks), $nBooks), 'text', | 
| 478 | -                          array(new LinkNavigation('?page='.parent::PAGE_ALL_BOOKS)), '', $nBooks); | |
| 478 | +                          array(new LinkNavigation('?page=' . parent::PAGE_ALL_BOOKS)), '', $nBooks); | |
| 479 | 479 | array_push($result, $entry); | 
| 480 | 480 |          if ($config['cops_recentbooks_limit'] > 0) { | 
| 481 | 481 |              $entry = new Entry(localize('recent.title'), | 
| 482 | 482 | self::ALL_RECENT_BOOKS_ID, | 
| 483 | 483 |                                str_format(localize('recent.list'), $config['cops_recentbooks_limit']), 'text', | 
| 484 | -                              array ( new LinkNavigation ('?page='.parent::PAGE_ALL_RECENT_BOOKS)), '', $config['cops_recentbooks_limit']); | |
| 484 | +                              array(new LinkNavigation('?page=' . parent::PAGE_ALL_RECENT_BOOKS)), '', $config['cops_recentbooks_limit']); | |
| 485 | 485 | array_push($result, $entry); | 
| 486 | 486 | } | 
| 487 | 487 | return $result; | 
| @@ -577,7 +577,7 @@ discard block | ||
| 577 | 577 | } | 
| 578 | 578 | |
| 579 | 579 |      public static function getBooks($n) { | 
| 580 | - list ($entryArray, $totalNumber) = self::getEntryArray(self::SQL_BOOKS_ALL , array (), $n); | |
| 580 | + list ($entryArray, $totalNumber) = self::getEntryArray(self::SQL_BOOKS_ALL, array(), $n); | |
| 581 | 581 | return array($entryArray, $totalNumber); | 
| 582 | 582 | } | 
| 583 | 583 | |
| @@ -594,7 +594,7 @@ discard block | ||
| 594 | 594 |          { | 
| 595 | 595 | array_push($entryArray, new Entry($post->title, Book::getEntryIdByLetter($post->title), | 
| 596 | 596 |                  str_format(localize('bookword', $post->count), $post->count), 'text', | 
| 597 | -                array(new LinkNavigation('?page='.parent::PAGE_ALL_BOOKS_LETTER.'&id='. rawurlencode($post->title))), '', $post->count)); | |
| 597 | +                array(new LinkNavigation('?page=' . parent::PAGE_ALL_BOOKS_LETTER . '&id=' . rawurlencode($post->title))), '', $post->count)); | |
| 598 | 598 | } | 
| 599 | 599 | return $entryArray; | 
| 600 | 600 | } | 
| @@ -619,7 +619,7 @@ discard block | ||
| 619 | 619 | |
| 620 | 620 |      public static function getAllRecentBooks() { | 
| 621 | 621 | global $config; | 
| 622 | - list ($entryArray, ) = self::getEntryArray(self::SQL_BOOKS_RECENT . $config['cops_recentbooks_limit'], array(), -1); | |
| 622 | + list ($entryArray,) = self::getEntryArray(self::SQL_BOOKS_RECENT . $config['cops_recentbooks_limit'], array(), -1); | |
| 623 | 623 | return $entryArray; | 
| 624 | 624 | } | 
| 625 | 625 | |
| @@ -108,7 +108,8 @@ discard block | ||
| 108 | 108 | public $format = array (); | 
| 109 | 109 | |
| 110 | 110 | |
| 111 | -    public function __construct($line) { | |
| 111 | + public function __construct($line) | |
| 112 | +    { | |
| 112 | 113 | $this->id = $line->id; | 
| 113 | 114 | $this->title = $line->title; | 
| 114 | 115 | $this->timestamp = strtotime($line->timestamp); | 
| @@ -126,25 +127,32 @@ discard block | ||
| 126 | 127 | $this->rating = $line->rating; | 
| 127 | 128 | } | 
| 128 | 129 | |
| 129 | -    public function getEntryId() { | |
| 130 | + public function getEntryId() | |
| 131 | +    { | |
| 130 | 132 | return self::ALL_BOOKS_UUID.':'.$this->uuid; | 
| 131 | 133 | } | 
| 132 | 134 | |
| 133 | -    public static function getEntryIdByLetter ($startingLetter) { | |
| 135 | + public static function getEntryIdByLetter ($startingLetter) | |
| 136 | +    { | |
| 134 | 137 | return self::ALL_BOOKS_ID.':letter:'.$startingLetter; | 
| 135 | 138 | } | 
| 136 | 139 | |
| 137 | -    public function getUri () { | |
| 140 | + public function getUri () | |
| 141 | +    { | |
| 138 | 142 | return '?page='.parent::PAGE_BOOK_DETAIL.'&id=' . $this->id; | 
| 139 | 143 | } | 
| 140 | 144 | |
| 141 | -    public function getDetailUrl () { | |
| 145 | + public function getDetailUrl () | |
| 146 | +    { | |
| 142 | 147 | $urlParam = $this->getUri(); | 
| 143 | - if (!is_null(GetUrlParam(DB))) $urlParam = addURLParameter($urlParam, DB, GetUrlParam (DB)); | |
| 148 | +        if (!is_null(GetUrlParam(DB))) { | |
| 149 | + $urlParam = addURLParameter($urlParam, DB, GetUrlParam (DB)); | |
| 150 | + } | |
| 144 | 151 | return 'index.php' . $urlParam; | 
| 145 | 152 | } | 
| 146 | 153 | |
| 147 | -    public function getTitle () { | |
| 154 | + public function getTitle () | |
| 155 | +    { | |
| 148 | 156 | return $this->title; | 
| 149 | 157 | } | 
| 150 | 158 | |
| @@ -153,22 +161,26 @@ discard block | ||
| 153 | 161 | /** | 
| 154 | 162 | * @return Author[] | 
| 155 | 163 | */ | 
| 156 | -    public function getAuthors () { | |
| 164 | + public function getAuthors () | |
| 165 | +    { | |
| 157 | 166 |          if (is_null($this->authors)) { | 
| 158 | 167 | $this->authors = Author::getAuthorByBookId($this->id); | 
| 159 | 168 | } | 
| 160 | 169 | return $this->authors; | 
| 161 | 170 | } | 
| 162 | 171 | |
| 163 | -    public function getAuthorsName () { | |
| 172 | + public function getAuthorsName () | |
| 173 | +    { | |
| 164 | 174 |          return implode(', ', array_map(function ($author) { return $author->name; }, $this->getAuthors())); | 
| 165 | 175 | } | 
| 166 | 176 | |
| 167 | -    public function getAuthorsSort () { | |
| 177 | + public function getAuthorsSort () | |
| 178 | +    { | |
| 168 | 179 |          return implode(', ', array_map(function ($author) { return $author->sort; }, $this->getAuthors())); | 
| 169 | 180 | } | 
| 170 | 181 | |
| 171 | -    public function getPublisher () { | |
| 182 | + public function getPublisher () | |
| 183 | +    { | |
| 172 | 184 |          if (is_null($this->publisher)) { | 
| 173 | 185 | $this->publisher = Publisher::getPublisherByBookId($this->id); | 
| 174 | 186 | } | 
| @@ -178,7 +190,8 @@ discard block | ||
| 178 | 190 | /** | 
| 179 | 191 | * @return Serie | 
| 180 | 192 | */ | 
| 181 | -    public function getSerie() { | |
| 193 | + public function getSerie() | |
| 194 | +    { | |
| 182 | 195 |          if (is_null($this->serie)) { | 
| 183 | 196 | $this->serie = Serie::getSerieByBookId($this->id); | 
| 184 | 197 | } | 
| @@ -188,7 +201,8 @@ discard block | ||
| 188 | 201 | /** | 
| 189 | 202 | * @return string | 
| 190 | 203 | */ | 
| 191 | -    public function getLanguages() { | |
| 204 | + public function getLanguages() | |
| 205 | +    { | |
| 192 | 206 | $lang = array(); | 
| 193 | 207 |          $result = parent::getDb()->prepare('select languages.lang_code | 
| 194 | 208 | from books_languages_link, languages | 
| @@ -196,8 +210,7 @@ discard block | ||
| 196 | 210 | and book = ? | 
| 197 | 211 | order by item_order'); | 
| 198 | 212 | $result->execute(array($this->id)); | 
| 199 | - while ($post = $result->fetchObject()) | |
| 200 | -        { | |
| 213 | +        while ($post = $result->fetchObject()) { | |
| 201 | 214 | array_push($lang, Language::getLanguageString($post->lang_code)); | 
| 202 | 215 | } | 
| 203 | 216 |          return implode(', ', $lang); | 
| @@ -206,7 +219,8 @@ discard block | ||
| 206 | 219 | /** | 
| 207 | 220 | * @return Tag[] | 
| 208 | 221 | */ | 
| 209 | -    public function getTags() { | |
| 222 | + public function getTags() | |
| 223 | +    { | |
| 210 | 224 |          if (is_null ($this->tags)) { | 
| 211 | 225 | $this->tags = array(); | 
| 212 | 226 | |
| @@ -216,15 +230,15 @@ discard block | ||
| 216 | 230 | and book = ? | 
| 217 | 231 | order by name'); | 
| 218 | 232 | $result->execute(array($this->id)); | 
| 219 | - while ($post = $result->fetchObject()) | |
| 220 | -            { | |
| 233 | +            while ($post = $result->fetchObject()) { | |
| 221 | 234 | array_push($this->tags, new Tag($post)); | 
| 222 | 235 | } | 
| 223 | 236 | } | 
| 224 | 237 | return $this->tags; | 
| 225 | 238 | } | 
| 226 | 239 | |
| 227 | -    public function getTagsName() { | |
| 240 | + public function getTagsName() | |
| 241 | +    { | |
| 228 | 242 |          return implode(', ', array_map(function ($tag) { return $tag->name; }, $this->getTags())); | 
| 229 | 243 | } | 
| 230 | 244 | |
| @@ -241,9 +255,12 @@ discard block | ||
| 241 | 255 | |
| 242 | 256 | /* End of other class (author, series, tag, ...) initialization and accessors */ | 
| 243 | 257 | |
| 244 | -    public static function getFilterString() { | |
| 258 | + public static function getFilterString() | |
| 259 | +    { | |
| 245 | 260 |          $filter = getURLParam('tag', NULL); | 
| 246 | - if (empty($filter)) return ''; | |
| 261 | +        if (empty($filter)) { | |
| 262 | + return ''; | |
| 263 | + } | |
| 247 | 264 | |
| 248 | 265 | $exists = true; | 
| 249 | 266 |          if (preg_match("/^!(.*)$/", $filter, $matches)) { | 
| @@ -283,7 +300,8 @@ discard block | ||
| 283 | 300 | return reset($reduced); | 
| 284 | 301 | } | 
| 285 | 302 | |
| 286 | -    public function getRating() { | |
| 303 | + public function getRating() | |
| 304 | +    { | |
| 287 | 305 |          if (is_null($this->rating) || $this->rating == 0) { | 
| 288 | 306 | return ''; | 
| 289 | 307 | } | 
| @@ -297,7 +315,8 @@ discard block | ||
| 297 | 315 | return $retour; | 
| 298 | 316 | } | 
| 299 | 317 | |
| 300 | -    public function getPubDate() { | |
| 318 | + public function getPubDate() | |
| 319 | +    { | |
| 301 | 320 |          if (empty ($this->pubdate)) { | 
| 302 | 321 | return ''; | 
| 303 | 322 | } | 
| @@ -308,23 +327,22 @@ discard block | ||
| 308 | 327 | return ''; | 
| 309 | 328 | } | 
| 310 | 329 | |
| 311 | -    public function getComment($withSerie = true) { | |
| 330 | + public function getComment($withSerie = true) | |
| 331 | +    { | |
| 312 | 332 | $addition = ''; | 
| 313 | 333 | $se = $this->getSerie (); | 
| 314 | 334 |          if (!is_null ($se) && $withSerie) { | 
| 315 | 335 |              $addition = $addition . '<strong>' . localize('content.series') . '</strong>' . str_format(localize('content.series.data'), $this->seriesIndex, htmlspecialchars($se->name)) . "<br />\n"; | 
| 316 | 336 | } | 
| 317 | -        if (preg_match('/<\/(div|p|a|span)>/', $this->comment)) | |
| 318 | -        { | |
| 337 | +        if (preg_match('/<\/(div|p|a|span)>/', $this->comment)) { | |
| 319 | 338 | return $addition . html2xhtml($this->comment); | 
| 320 | - } | |
| 321 | - else | |
| 322 | -        { | |
| 339 | +        } else { | |
| 323 | 340 | return $addition . htmlspecialchars($this->comment); | 
| 324 | 341 | } | 
| 325 | 342 | } | 
| 326 | 343 | |
| 327 | -    public function getDataFormat($format) { | |
| 344 | + public function getDataFormat($format) | |
| 345 | +    { | |
| 328 | 346 |          $reduced = array_filter($this->getDatas(), function ($data) use ($format) { | 
| 329 | 347 | return $data->format == $format; | 
| 330 | 348 | }); | 
| @@ -333,23 +351,19 @@ discard block | ||
| 333 | 351 | |
| 334 | 352 | public function getFilePath($extension, $idData = NULL, $relative = false) | 
| 335 | 353 |      { | 
| 336 | - if ($extension == 'jpg') | |
| 337 | -        { | |
| 354 | +        if ($extension == 'jpg') { | |
| 338 | 355 | $file = 'cover.jpg'; | 
| 339 | - } | |
| 340 | - else | |
| 341 | -        { | |
| 356 | +        } else { | |
| 342 | 357 | $data = $this->getDataById($idData); | 
| 343 | - if (!$data) return NULL; | |
| 358 | +            if (!$data) { | |
| 359 | + return NULL; | |
| 360 | + } | |
| 344 | 361 | $file = $data->name . '.' . strtolower($data->format); | 
| 345 | 362 | } | 
| 346 | 363 | |
| 347 | - if ($relative) | |
| 348 | -        { | |
| 364 | +        if ($relative) { | |
| 349 | 365 | return $this->relativePath.'/'.$file; | 
| 350 | - } | |
| 351 | - else | |
| 352 | -        { | |
| 366 | +        } else { | |
| 353 | 367 | return $this->path.'/'.$file; | 
| 354 | 368 | } | 
| 355 | 369 | } | 
| @@ -359,8 +373,7 @@ discard block | ||
| 359 | 373 | global $config; | 
| 360 | 374 | $data = $this->getDataById($idData); | 
| 361 | 375 | |
| 362 | - try | |
| 363 | -        { | |
| 376 | +        try { | |
| 364 | 377 | $epub = new EPub($data->getLocalPath()); | 
| 365 | 378 | |
| 366 | 379 | $epub->Title($this->title); | 
| @@ -383,14 +396,13 @@ discard block | ||
| 383 | 396 | $epub->updateForKepub(); | 
| 384 | 397 | } | 
| 385 | 398 | $epub->download($data->getUpdatedFilenameEpub()); | 
| 386 | - } | |
| 387 | - catch (Exception $e) | |
| 388 | -        { | |
| 399 | +        } catch (Exception $e) { | |
| 389 | 400 | echo 'Exception : ' . $e->getMessage(); | 
| 390 | 401 | } | 
| 391 | 402 | } | 
| 392 | 403 | |
| 393 | -    public function getThumbnail($width, $height, $outputfile = NULL) { | |
| 404 | + public function getThumbnail($width, $height, $outputfile = NULL) | |
| 405 | +    { | |
| 394 | 406 |          if (is_null($width) && is_null($height)) { | 
| 395 | 407 | return false; | 
| 396 | 408 | } | 
| @@ -429,17 +441,14 @@ discard block | ||
| 429 | 441 |      { | 
| 430 | 442 | $linkArray = array(); | 
| 431 | 443 | |
| 432 | - if ($this->hasCover) | |
| 433 | -        { | |
| 444 | +        if ($this->hasCover) { | |
| 434 | 445 | array_push($linkArray, Data::getLink($this, 'jpg', 'image/jpeg', Link::OPDS_IMAGE_TYPE, 'cover.jpg', NULL)); | 
| 435 | 446 | |
| 436 | 447 | array_push($linkArray, Data::getLink($this, 'jpg', 'image/jpeg', Link::OPDS_THUMBNAIL_TYPE, 'cover.jpg', NULL)); | 
| 437 | 448 | } | 
| 438 | 449 | |
| 439 | - foreach ($this->getDatas() as $data) | |
| 440 | -        { | |
| 441 | - if ($data->isKnownType()) | |
| 442 | -            { | |
| 450 | +        foreach ($this->getDatas() as $data) { | |
| 451 | +            if ($data->isKnownType()) { | |
| 443 | 452 | array_push($linkArray, $data->getDataLink(Link::OPDS_ACQUISITION_TYPE, $data->format)); | 
| 444 | 453 | } | 
| 445 | 454 | } | 
| @@ -458,17 +467,20 @@ discard block | ||
| 458 | 467 | } | 
| 459 | 468 | |
| 460 | 469 | |
| 461 | -    public function getEntry() { | |
| 470 | + public function getEntry() | |
| 471 | +    { | |
| 462 | 472 | return new EntryBook($this->getTitle(), $this->getEntryId(), | 
| 463 | 473 | $this->getComment(), 'text/html', | 
| 464 | 474 | $this->getLinkArray(), $this); | 
| 465 | 475 | } | 
| 466 | 476 | |
| 467 | -    public static function getBookCount($database = NULL) { | |
| 477 | + public static function getBookCount($database = NULL) | |
| 478 | +    { | |
| 468 | 479 |          return parent::executeQuerySingle('select count(*) from books', $database); | 
| 469 | 480 | } | 
| 470 | 481 | |
| 471 | -    public static function getCount() { | |
| 482 | + public static function getCount() | |
| 483 | +    { | |
| 472 | 484 | global $config; | 
| 473 | 485 |          $nBooks = parent::executeQuerySingle('select count(*) from books'); | 
| 474 | 486 | $result = array(); | 
| @@ -487,27 +499,33 @@ discard block | ||
| 487 | 499 | return $result; | 
| 488 | 500 | } | 
| 489 | 501 | |
| 490 | -    public static function getBooksByAuthor($authorId, $n) { | |
| 502 | + public static function getBooksByAuthor($authorId, $n) | |
| 503 | +    { | |
| 491 | 504 | return self::getEntryArray(self::SQL_BOOKS_BY_AUTHOR, array($authorId), $n); | 
| 492 | 505 | } | 
| 493 | 506 | |
| 494 | -    public static function getBooksByRating($ratingId, $n) { | |
| 507 | + public static function getBooksByRating($ratingId, $n) | |
| 508 | +    { | |
| 495 | 509 | return self::getEntryArray(self::SQL_BOOKS_BY_RATING, array($ratingId), $n); | 
| 496 | 510 | } | 
| 497 | 511 | |
| 498 | -    public static function getBooksByPublisher($publisherId, $n) { | |
| 512 | + public static function getBooksByPublisher($publisherId, $n) | |
| 513 | +    { | |
| 499 | 514 | return self::getEntryArray(self::SQL_BOOKS_BY_PUBLISHER, array($publisherId), $n); | 
| 500 | 515 | } | 
| 501 | 516 | |
| 502 | -    public static function getBooksBySeries($serieId, $n) { | |
| 517 | + public static function getBooksBySeries($serieId, $n) | |
| 518 | +    { | |
| 503 | 519 | return self::getEntryArray(self::SQL_BOOKS_BY_SERIE, array($serieId), $n); | 
| 504 | 520 | } | 
| 505 | 521 | |
| 506 | -    public static function getBooksByTag($tagId, $n) { | |
| 522 | + public static function getBooksByTag($tagId, $n) | |
| 523 | +    { | |
| 507 | 524 | return self::getEntryArray(self::SQL_BOOKS_BY_TAG, array($tagId), $n); | 
| 508 | 525 | } | 
| 509 | 526 | |
| 510 | -    public static function getBooksByLanguage($languageId, $n) { | |
| 527 | + public static function getBooksByLanguage($languageId, $n) | |
| 528 | +    { | |
| 511 | 529 | return self::getEntryArray(self::SQL_BOOKS_BY_LANGUAGE, array($languageId), $n); | 
| 512 | 530 | } | 
| 513 | 531 | |
| @@ -517,32 +535,33 @@ discard block | ||
| 517 | 535 | * @param $n integer | 
| 518 | 536 | * @return array | 
| 519 | 537 | */ | 
| 520 | -    public static function getBooksByCustom($customColumn, $id, $n) { | |
| 538 | + public static function getBooksByCustom($customColumn, $id, $n) | |
| 539 | +    { | |
| 521 | 540 | list($query, $params) = $customColumn->getQuery($id); | 
| 522 | 541 | |
| 523 | 542 | return self::getEntryArray($query, $params, $n); | 
| 524 | 543 | } | 
| 525 | 544 | |
| 526 | -    public static function getBookById($bookId) { | |
| 545 | + public static function getBookById($bookId) | |
| 546 | +    { | |
| 527 | 547 |          $result = parent::getDb()->prepare('select ' . self::BOOK_COLUMNS . ' | 
| 528 | 548 | from books ' . self::SQL_BOOKS_LEFT_JOIN . ' | 
| 529 | 549 | where books.id = ?'); | 
| 530 | 550 | $result->execute(array($bookId)); | 
| 531 | - while ($post = $result->fetchObject()) | |
| 532 | -        { | |
| 551 | +        while ($post = $result->fetchObject()) { | |
| 533 | 552 | $book = new Book($post); | 
| 534 | 553 | return $book; | 
| 535 | 554 | } | 
| 536 | 555 | return NULL; | 
| 537 | 556 | } | 
| 538 | 557 | |
| 539 | -    public static function getBookByDataId($dataId) { | |
| 558 | + public static function getBookByDataId($dataId) | |
| 559 | +    { | |
| 540 | 560 |          $result = parent::getDb()->prepare('select ' . self::BOOK_COLUMNS . ', data.name, data.format | 
| 541 | 561 | from data, books ' . self::SQL_BOOKS_LEFT_JOIN . ' | 
| 542 | 562 | where data.book = books.id and data.id = ?'); | 
| 543 | 563 | $result->execute(array($dataId)); | 
| 544 | - while ($post = $result->fetchObject()) | |
| 545 | -        { | |
| 564 | +        while ($post = $result->fetchObject()) { | |
| 546 | 565 | $book = new Book($post); | 
| 547 | 566 | $data = new Data($post, $book); | 
| 548 | 567 | $data->id = $dataId; | 
| @@ -552,7 +571,8 @@ discard block | ||
| 552 | 571 | return NULL; | 
| 553 | 572 | } | 
| 554 | 573 | |
| 555 | -    public static function getBooksByQuery($query, $n, $database = NULL, $numberPerPage = NULL) { | |
| 574 | + public static function getBooksByQuery($query, $n, $database = NULL, $numberPerPage = NULL) | |
| 575 | +    { | |
| 556 | 576 | $i = 0; | 
| 557 | 577 | $critArray = array(); | 
| 558 | 578 | foreach (array(PageQueryResult::SCOPE_AUTHOR, | 
| @@ -563,8 +583,7 @@ discard block | ||
| 563 | 583 |              if (in_array($key, getCurrentOption('ignored_categories')) || | 
| 564 | 584 |                  (!array_key_exists($key, $query) && !array_key_exists('all', $query))) { | 
| 565 | 585 | $critArray[$i] = self::BAD_SEARCH; | 
| 566 | - } | |
| 567 | -            else { | |
| 586 | +            } else { | |
| 568 | 587 |                  if (array_key_exists($key, $query)) { | 
| 569 | 588 | $critArray[$i] = $query[$key]; | 
| 570 | 589 |                  } else { | 
| @@ -576,12 +595,14 @@ discard block | ||
| 576 | 595 | return self::getEntryArray(self::SQL_BOOKS_QUERY, $critArray, $n, $database, $numberPerPage); | 
| 577 | 596 | } | 
| 578 | 597 | |
| 579 | -    public static function getBooks($n) { | |
| 598 | + public static function getBooks($n) | |
| 599 | +    { | |
| 580 | 600 | list ($entryArray, $totalNumber) = self::getEntryArray(self::SQL_BOOKS_ALL , array (), $n); | 
| 581 | 601 | return array($entryArray, $totalNumber); | 
| 582 | 602 | } | 
| 583 | 603 | |
| 584 | -    public static function getAllBooks() { | |
| 604 | + public static function getAllBooks() | |
| 605 | +    { | |
| 585 | 606 | /* @var $result PDOStatement */ | 
| 586 | 607 | |
| 587 | 608 |          list (, $result) = parent::executeQuery('select {0} | 
| @@ -590,8 +611,7 @@ discard block | ||
| 590 | 611 | order by substr (upper (sort), 1, 1)', 'substr (upper (sort), 1, 1) as title, count(*) as count', self::getFilterString(), array(), -1); | 
| 591 | 612 | |
| 592 | 613 | $entryArray = array(); | 
| 593 | - while ($post = $result->fetchObject()) | |
| 594 | -        { | |
| 614 | +        while ($post = $result->fetchObject()) { | |
| 595 | 615 | array_push($entryArray, new Entry($post->title, Book::getEntryIdByLetter($post->title), | 
| 596 | 616 |                  str_format(localize('bookword', $post->count), $post->count), 'text', | 
| 597 | 617 |                  array(new LinkNavigation('?page='.parent::PAGE_ALL_BOOKS_LETTER.'&id='. rawurlencode($post->title))), '', $post->count)); | 
| @@ -599,25 +619,27 @@ discard block | ||
| 599 | 619 | return $entryArray; | 
| 600 | 620 | } | 
| 601 | 621 | |
| 602 | -    public static function getBooksByStartingLetter($letter, $n, $database = NULL, $numberPerPage = NULL) { | |
| 622 | + public static function getBooksByStartingLetter($letter, $n, $database = NULL, $numberPerPage = NULL) | |
| 623 | +    { | |
| 603 | 624 | return self::getEntryArray(self::SQL_BOOKS_BY_FIRST_LETTER, array($letter . '%'), $n, $database, $numberPerPage); | 
| 604 | 625 | } | 
| 605 | 626 | |
| 606 | -    public static function getEntryArray($query, $params, $n, $database = NULL, $numberPerPage = NULL) { | |
| 627 | + public static function getEntryArray($query, $params, $n, $database = NULL, $numberPerPage = NULL) | |
| 628 | +    { | |
| 607 | 629 | /* @var $totalNumber integer */ | 
| 608 | 630 | /* @var $result PDOStatement */ | 
| 609 | 631 | list($totalNumber, $result) = parent::executeQuery($query, self::BOOK_COLUMNS, self::getFilterString(), $params, $n, $database, $numberPerPage); | 
| 610 | 632 | |
| 611 | 633 | $entryArray = array(); | 
| 612 | - while ($post = $result->fetchObject()) | |
| 613 | -        { | |
| 634 | +        while ($post = $result->fetchObject()) { | |
| 614 | 635 | $book = new Book($post); | 
| 615 | 636 | array_push($entryArray, $book->getEntry()); | 
| 616 | 637 | } | 
| 617 | 638 | return array($entryArray, $totalNumber); | 
| 618 | 639 | } | 
| 619 | 640 | |
| 620 | -    public static function getAllRecentBooks() { | |
| 641 | + public static function getAllRecentBooks() | |
| 642 | +    { | |
| 621 | 643 | global $config; | 
| 622 | 644 | list ($entryArray, ) = self::getEntryArray(self::SQL_BOOKS_RECENT . $config['cops_recentbooks_limit'], array(), -1); | 
| 623 | 645 | return $entryArray; | 
| @@ -629,7 +651,8 @@ discard block | ||
| 629 | 651 | * @param string[] $columns | 
| 630 | 652 | * @return CustomColumn[] | 
| 631 | 653 | */ | 
| 632 | -    public function getCustomColumnValues($columns, $asArray = false) { | |
| 654 | + public function getCustomColumnValues($columns, $asArray = false) | |
| 655 | +    { | |
| 633 | 656 | $result = array(); | 
| 634 | 657 | |
| 635 | 658 |          foreach ($columns as $lookup) { | 
| @@ -39,6 +39,9 @@ discard block | ||
| 39 | 39 | /** @var null|Entry[] */ | 
| 40 | 40 | private $customValues = NULL; | 
| 41 | 41 | |
| 42 | + /** | |
| 43 | + * @param string $pdatatype | |
| 44 | + */ | |
| 42 | 45 | protected function __construct($pcustomId, $pdatatype) | 
| 43 | 46 |      { | 
| 44 | 47 | $this->columnTitle = self::getTitleByCustomID($pcustomId); | 
| @@ -147,7 +150,7 @@ discard block | ||
| 147 | 150 | /** | 
| 148 | 151 | * Encode a value of this column ready to be displayed in an HTML document | 
| 149 | 152 | * | 
| 150 | - * @param integer|string $value | |
| 153 | + * @param string $value | |
| 151 | 154 | * @return string | 
| 152 | 155 | */ | 
| 153 | 156 | public function encodeHTMLValue($value) | 
| @@ -277,7 +280,7 @@ discard block | ||
| 277 | 280 | /** | 
| 278 | 281 | * Get a CustomColumn for a specified (by ID) value | 
| 279 | 282 | * | 
| 280 | - * @param string|integer $id the id of the searched value | |
| 283 | + * @param integer $id the id of the searched value | |
| 281 | 284 | * @return CustomColumn | 
| 282 | 285 | */ | 
| 283 | 286 | abstract public function getCustom($id); | 
| @@ -11,18 +11,18 @@ discard block | ||
| 11 | 11 | */ | 
| 12 | 12 | abstract class CustomColumnType extends Base | 
| 13 | 13 |  { | 
| 14 | - const ALL_CUSTOMS_ID = "cops:custom"; | |
| 14 | + const ALL_CUSTOMS_ID = "cops:custom"; | |
| 15 | 15 | |
| 16 | - const CUSTOM_TYPE_TEXT = "text"; // type 1 + 2 | |
| 17 | - const CUSTOM_TYPE_COMMENT = "comments"; // type 3 | |
| 18 | - const CUSTOM_TYPE_SERIES = "series"; // type 4 | |
| 16 | + const CUSTOM_TYPE_TEXT = "text"; // type 1 + 2 | |
| 17 | + const CUSTOM_TYPE_COMMENT = "comments"; // type 3 | |
| 18 | + const CUSTOM_TYPE_SERIES = "series"; // type 4 | |
| 19 | 19 | const CUSTOM_TYPE_ENUM = "enumeration"; // type 5 | 
| 20 | - const CUSTOM_TYPE_DATE = "datetime"; // type 6 | |
| 21 | - const CUSTOM_TYPE_FLOAT = "float"; // type 7 | |
| 22 | - const CUSTOM_TYPE_INT = "int"; // type 8 | |
| 23 | - const CUSTOM_TYPE_RATING = "rating"; // type 9 | |
| 24 | - const CUSTOM_TYPE_BOOL = "bool"; // type 10 | |
| 25 | - const CUSTOM_TYPE_COMPOSITE = "composite"; // type 11 + 12 | |
| 20 | + const CUSTOM_TYPE_DATE = "datetime"; // type 6 | |
| 21 | + const CUSTOM_TYPE_FLOAT = "float"; // type 7 | |
| 22 | + const CUSTOM_TYPE_INT = "int"; // type 8 | |
| 23 | + const CUSTOM_TYPE_RATING = "rating"; // type 9 | |
| 24 | + const CUSTOM_TYPE_BOOL = "bool"; // type 10 | |
| 25 | + const CUSTOM_TYPE_COMPOSITE = "composite"; // type 11 + 12 | |
| 26 | 26 | |
| 27 | 27 | /** @var array[integer]CustomColumnType */ | 
| 28 | 28 | private static $customColumnCacheID = array(); | 
| @@ -110,7 +110,7 @@ discard block | ||
| 110 | 110 | $result->execute(array($this->customId)); | 
| 111 | 111 |          if ($post = $result->fetchObject()) { | 
| 112 | 112 | $json = json_decode($post->display); | 
| 113 | - return (isset($json->description) && !empty($json->description)) ? $json->description : NULL; | |
| 113 | + return (isset($json->description) && !empty($json->description))?$json->description:NULL; | |
| 114 | 114 | } | 
| 115 | 115 | return NULL; | 
| 116 | 116 | } | 
| @@ -181,8 +181,9 @@ discard block | ||
| 181 | 181 | public static function createByCustomID($customId) | 
| 182 | 182 |      { | 
| 183 | 183 | // Reuse already created CustomColumns for performance | 
| 184 | - if (array_key_exists($customId, self::$customColumnCacheID)) | |
| 185 | - return self::$customColumnCacheID[$customId]; | |
| 184 | +        if (array_key_exists($customId, self::$customColumnCacheID)) { | |
| 185 | + return self::$customColumnCacheID[$customId]; | |
| 186 | + } | |
| 186 | 187 | |
| 187 | 188 | $datatype = self::getDatatypeByCustomID($customId); | 
| 188 | 189 | |
| @@ -221,8 +222,9 @@ discard block | ||
| 221 | 222 | public static function createByLookup($lookup) | 
| 222 | 223 |      { | 
| 223 | 224 | // Reuse already created CustomColumns for performance | 
| 224 | - if (array_key_exists($lookup, self::$customColumnCacheLookup)) | |
| 225 | - return self::$customColumnCacheLookup[$lookup]; | |
| 225 | +        if (array_key_exists($lookup, self::$customColumnCacheLookup)) { | |
| 226 | + return self::$customColumnCacheLookup[$lookup]; | |
| 227 | + } | |
| 226 | 228 | |
| 227 | 229 |          $result = parent::getDb()->prepare('SELECT id FROM custom_columns WHERE label = ?'); | 
| 228 | 230 | $result->execute(array($lookup)); | 
| @@ -241,8 +243,9 @@ discard block | ||
| 241 | 243 | public function getAllCustomValues() | 
| 242 | 244 |      { | 
| 243 | 245 | // lazy loading | 
| 244 | - if ($this->customValues == NULL) | |
| 245 | - $this->customValues = $this->getAllCustomValuesFromDatabase(); | |
| 246 | +        if ($this->customValues == NULL) { | |
| 247 | + $this->customValues = $this->getAllCustomValuesFromDatabase(); | |
| 248 | + } | |
| 246 | 249 | |
| 247 | 250 | return $this->customValues; | 
| 248 | 251 | } | 
| @@ -37,14 +37,14 @@ discard block | ||
| 37 | 37 | /** @var string the datatype of this column (one of the CUSTOM_TYPE_* constant values) */ | 
| 38 | 38 | public $datatype; | 
| 39 | 39 | /** @var null|Entry[] */ | 
| 40 | - private $customValues = NULL; | |
| 40 | + private $customValues = null; | |
| 41 | 41 | |
| 42 | 42 | protected function __construct($pcustomId, $pdatatype) | 
| 43 | 43 |      { | 
| 44 | 44 | $this->columnTitle = self::getTitleByCustomID($pcustomId); | 
| 45 | 45 | $this->customId = $pcustomId; | 
| 46 | 46 | $this->datatype = $pdatatype; | 
| 47 | - $this->customValues = NULL; | |
| 47 | + $this->customValues = null; | |
| 48 | 48 | } | 
| 49 | 49 | |
| 50 | 50 | /** | 
| @@ -110,9 +110,9 @@ discard block | ||
| 110 | 110 | $result->execute(array($this->customId)); | 
| 111 | 111 |          if ($post = $result->fetchObject()) { | 
| 112 | 112 | $json = json_decode($post->display); | 
| 113 | - return (isset($json->description) && !empty($json->description)) ? $json->description : NULL; | |
| 113 | + return (isset($json->description) && !empty($json->description)) ? $json->description : null; | |
| 114 | 114 | } | 
| 115 | - return NULL; | |
| 115 | + return null; | |
| 116 | 116 | } | 
| 117 | 117 | |
| 118 | 118 | /** | 
| @@ -168,7 +168,7 @@ discard block | ||
| 168 | 168 |          if ($post = $result->fetchObject()) { | 
| 169 | 169 | return $post->datatype; | 
| 170 | 170 | } | 
| 171 | - return NULL; | |
| 171 | + return null; | |
| 172 | 172 | } | 
| 173 | 173 | |
| 174 | 174 | /** | 
| @@ -206,7 +206,7 @@ discard block | ||
| 206 | 206 | case self::CUSTOM_TYPE_BOOL: | 
| 207 | 207 | return self::$customColumnCacheID[$customId] = new CustomColumnTypeBool($customId); | 
| 208 | 208 | case self::CUSTOM_TYPE_COMPOSITE: | 
| 209 | - return NULL; //TODO Currently not supported | |
| 209 | + return null; //TODO Currently not supported | |
| 210 | 210 | default: | 
| 211 | 211 |                  throw new Exception("Unkown column type: " . $datatype); | 
| 212 | 212 | } | 
| @@ -229,7 +229,7 @@ discard block | ||
| 229 | 229 |          if ($post = $result->fetchObject()) { | 
| 230 | 230 | return self::$customColumnCacheLookup[$lookup] = self::createByCustomID($post->id); | 
| 231 | 231 | } | 
| 232 | - return self::$customColumnCacheLookup[$lookup] = NULL; | |
| 232 | + return self::$customColumnCacheLookup[$lookup] = null; | |
| 233 | 233 | } | 
| 234 | 234 | |
| 235 | 235 | /** | 
| @@ -241,7 +241,7 @@ discard block | ||
| 241 | 241 | public function getAllCustomValues() | 
| 242 | 242 |      { | 
| 243 | 243 | // lazy loading | 
| 244 | - if ($this->customValues == NULL) | |
| 244 | + if ($this->customValues == null) | |
| 245 | 245 | $this->customValues = $this->getAllCustomValuesFromDatabase(); | 
| 246 | 246 | |
| 247 | 247 | return $this->customValues; | 
| @@ -139,6 +139,9 @@ discard block | ||
| 139 | 139 | return new Link ($href, $this->getMimeType (), Link::OPDS_ACQUISITION_TYPE, $title); | 
| 140 | 140 | } | 
| 141 | 141 | |
| 142 | + /** | |
| 143 | + * @param Book $book | |
| 144 | + */ | |
| 142 | 145 |      public static function getDataByBook ($book) { | 
| 143 | 146 | $out = array (); | 
| 144 | 147 |          $result = parent::getDb ()->prepare('select id, format, name | 
| @@ -152,6 +155,9 @@ discard block | ||
| 152 | 155 | return $out; | 
| 153 | 156 | } | 
| 154 | 157 | |
| 158 | + /** | |
| 159 | + * @param string $urlParam | |
| 160 | + */ | |
| 155 | 161 |      public static function handleThumbnailLink ($urlParam, $height) { | 
| 156 | 162 | global $config; | 
| 157 | 163 | |
| @@ -171,6 +177,10 @@ discard block | ||
| 171 | 177 | return $urlParam; | 
| 172 | 178 | } | 
| 173 | 179 | |
| 180 | + /** | |
| 181 | + * @param string $type | |
| 182 | + * @param string $filename | |
| 183 | + */ | |
| 174 | 184 | public static function getLink ($book, $type, $mime, $rel, $filename, $idData, $title = NULL, $height = NULL) | 
| 175 | 185 |      { | 
| 176 | 186 | global $config; | 
| @@ -105,7 +105,7 @@ | ||
| 105 | 105 |      public function getUpdatedFilenameKepub () { | 
| 106 | 106 | $str = $this->getUpdatedFilename () . ".kepub.epub"; | 
| 107 | 107 |          return str_replace(array(':', '#', '&'), | 
| 108 | -                           array('-', '-', ' '), $str ); | |
| 108 | +                            array('-', '-', ' '), $str ); | |
| 109 | 109 | } | 
| 110 | 110 | |
| 111 | 111 |      public function getDataLink ($rel, $title = NULL) { | 
| @@ -59,25 +59,25 @@ discard block | ||
| 59 | 59 | $this->id = $post->id; | 
| 60 | 60 | $this->name = $post->name; | 
| 61 | 61 | $this->format = $post->format; | 
| 62 | -        $this->realFormat = str_replace ("ORIGINAL_", "", $post->format); | |
| 63 | - $this->extension = strtolower ($this->realFormat); | |
| 62 | +        $this->realFormat = str_replace("ORIGINAL_", "", $post->format); | |
| 63 | + $this->extension = strtolower($this->realFormat); | |
| 64 | 64 | $this->book = $book; | 
| 65 | 65 | } | 
| 66 | 66 | |
| 67 | -    public function isKnownType () { | |
| 68 | - return array_key_exists ($this->extension, self::$mimetypes); | |
| 67 | +    public function isKnownType() { | |
| 68 | + return array_key_exists($this->extension, self::$mimetypes); | |
| 69 | 69 | } | 
| 70 | 70 | |
| 71 | -    public function getMimeType () { | |
| 71 | +    public function getMimeType() { | |
| 72 | 72 | $result = "application/octet-stream"; | 
| 73 | -        if ($this->isKnownType ()) { | |
| 73 | +        if ($this->isKnownType()) { | |
| 74 | 74 | return self::$mimetypes [$this->extension]; | 
| 75 | 75 |          } elseif (function_exists('finfo_open') === true) { | 
| 76 | 76 | $finfo = finfo_open(FILEINFO_MIME_TYPE); | 
| 77 | 77 | |
| 78 | 78 | if (is_resource($finfo) === true) | 
| 79 | 79 |              { | 
| 80 | - $result = finfo_file($finfo, $this->getLocalPath ()); | |
| 80 | + $result = finfo_file($finfo, $this->getLocalPath()); | |
| 81 | 81 | } | 
| 82 | 82 | |
| 83 | 83 | finfo_close($finfo); | 
| @@ -86,82 +86,82 @@ discard block | ||
| 86 | 86 | return $result; | 
| 87 | 87 | } | 
| 88 | 88 | |
| 89 | -    public function isEpubValidOnKobo () { | |
| 89 | +    public function isEpubValidOnKobo() { | |
| 90 | 90 | return $this->format == "EPUB" || $this->format == "KEPUB"; | 
| 91 | 91 | } | 
| 92 | 92 | |
| 93 | -    public function getFilename () { | |
| 94 | - return $this->name . "." . strtolower ($this->format); | |
| 93 | +    public function getFilename() { | |
| 94 | + return $this->name . "." . strtolower($this->format); | |
| 95 | 95 | } | 
| 96 | 96 | |
| 97 | -    public function getUpdatedFilename () { | |
| 98 | - return $this->book->getAuthorsSort () . " - " . $this->book->title; | |
| 97 | +    public function getUpdatedFilename() { | |
| 98 | + return $this->book->getAuthorsSort() . " - " . $this->book->title; | |
| 99 | 99 | } | 
| 100 | 100 | |
| 101 | -    public function getUpdatedFilenameEpub () { | |
| 102 | - return $this->getUpdatedFilename () . ".epub"; | |
| 101 | +    public function getUpdatedFilenameEpub() { | |
| 102 | + return $this->getUpdatedFilename() . ".epub"; | |
| 103 | 103 | } | 
| 104 | 104 | |
| 105 | -    public function getUpdatedFilenameKepub () { | |
| 106 | - $str = $this->getUpdatedFilename () . ".kepub.epub"; | |
| 105 | +    public function getUpdatedFilenameKepub() { | |
| 106 | + $str = $this->getUpdatedFilename() . ".kepub.epub"; | |
| 107 | 107 |          return str_replace(array(':', '#', '&'), | 
| 108 | -                           array('-', '-', ' '), $str ); | |
| 108 | +                           array('-', '-', ' '), $str); | |
| 109 | 109 | } | 
| 110 | 110 | |
| 111 | -    public function getDataLink ($rel, $title = NULL) { | |
| 111 | +    public function getDataLink($rel, $title = NULL) { | |
| 112 | 112 | global $config; | 
| 113 | 113 | |
| 114 | 114 |          if ($rel == Link::OPDS_ACQUISITION_TYPE && $config['cops_use_url_rewriting'] == "1") { | 
| 115 | 115 | return $this->getHtmlLinkWithRewriting($title); | 
| 116 | 116 | } | 
| 117 | 117 | |
| 118 | - return self::getLink ($this->book, $this->extension, $this->getMimeType (), $rel, $this->getFilename (), $this->id, $title); | |
| 118 | + return self::getLink($this->book, $this->extension, $this->getMimeType(), $rel, $this->getFilename(), $this->id, $title); | |
| 119 | 119 | } | 
| 120 | 120 | |
| 121 | -    public function getHtmlLink () { | |
| 121 | +    public function getHtmlLink() { | |
| 122 | 122 | return $this->getDataLink(Link::OPDS_ACQUISITION_TYPE)->href; | 
| 123 | 123 | } | 
| 124 | 124 | |
| 125 | -    public function getLocalPath () { | |
| 126 | - return $this->book->path . "/" . $this->getFilename (); | |
| 125 | +    public function getLocalPath() { | |
| 126 | + return $this->book->path . "/" . $this->getFilename(); | |
| 127 | 127 | } | 
| 128 | 128 | |
| 129 | -    public function getHtmlLinkWithRewriting ($title = NULL) { | |
| 129 | +    public function getHtmlLinkWithRewriting($title = NULL) { | |
| 130 | 130 | global $config; | 
| 131 | 131 | |
| 132 | 132 | $database = ""; | 
| 133 | - if (!is_null (GetUrlParam (DB))) $database = GetUrlParam (DB) . "/"; | |
| 133 | + if (!is_null(GetUrlParam(DB))) $database = GetUrlParam(DB) . "/"; | |
| 134 | 134 | |
| 135 | 135 | $href = "download/" . $this->id . "/" . $database; | 
| 136 | 136 | |
| 137 | 137 | if ($config['cops_provide_kepub'] == "1" && | 
| 138 | - $this->isEpubValidOnKobo () && | |
| 138 | + $this->isEpubValidOnKobo() && | |
| 139 | 139 |              preg_match("/Kobo/", $_SERVER['HTTP_USER_AGENT'])) { | 
| 140 | - $href .= rawurlencode ($this->getUpdatedFilenameKepub ()); | |
| 140 | + $href .= rawurlencode($this->getUpdatedFilenameKepub()); | |
| 141 | 141 |          } else { | 
| 142 | - $href .= rawurlencode ($this->getFilename ()); | |
| 142 | + $href .= rawurlencode($this->getFilename()); | |
| 143 | 143 | } | 
| 144 | - return new Link ($href, $this->getMimeType (), Link::OPDS_ACQUISITION_TYPE, $title); | |
| 144 | + return new Link($href, $this->getMimeType(), Link::OPDS_ACQUISITION_TYPE, $title); | |
| 145 | 145 | } | 
| 146 | 146 | |
| 147 | -    public static function getDataByBook ($book) { | |
| 148 | - $out = array (); | |
| 149 | -        $result = parent::getDb ()->prepare('select id, format, name | |
| 147 | +    public static function getDataByBook($book) { | |
| 148 | + $out = array(); | |
| 149 | +        $result = parent::getDb()->prepare('select id, format, name | |
| 150 | 150 | from data where book = ?'); | 
| 151 | - $result->execute (array ($book->id)); | |
| 151 | + $result->execute(array($book->id)); | |
| 152 | 152 | |
| 153 | - while ($post = $result->fetchObject ()) | |
| 153 | + while ($post = $result->fetchObject()) | |
| 154 | 154 |          { | 
| 155 | - array_push ($out, new Data ($post, $book)); | |
| 155 | + array_push($out, new Data($post, $book)); | |
| 156 | 156 | } | 
| 157 | 157 | return $out; | 
| 158 | 158 | } | 
| 159 | 159 | |
| 160 | -    public static function handleThumbnailLink ($urlParam, $height) { | |
| 160 | +    public static function handleThumbnailLink($urlParam, $height) { | |
| 161 | 161 | global $config; | 
| 162 | 162 | |
| 163 | -        if (is_null ($height)) { | |
| 164 | -            if (preg_match ('/feed.php/', $_SERVER["SCRIPT_NAME"])) { | |
| 163 | +        if (is_null($height)) { | |
| 164 | +            if (preg_match('/feed.php/', $_SERVER["SCRIPT_NAME"])) { | |
| 165 | 165 | $height = $config['cops_opds_thumbnail_height']; | 
| 166 | 166 | } | 
| 167 | 167 | else | 
| @@ -176,13 +176,13 @@ discard block | ||
| 176 | 176 | return $urlParam; | 
| 177 | 177 | } | 
| 178 | 178 | |
| 179 | - public static function getLink ($book, $type, $mime, $rel, $filename, $idData, $title = NULL, $height = NULL) | |
| 179 | + public static function getLink($book, $type, $mime, $rel, $filename, $idData, $title = NULL, $height = NULL) | |
| 180 | 180 |      { | 
| 181 | 181 | global $config; | 
| 182 | 182 | |
| 183 | 183 |          $urlParam = addURLParameter("", "data", $idData); | 
| 184 | 184 | |
| 185 | - if (Base::useAbsolutePath () || | |
| 185 | + if (Base::useAbsolutePath() || | |
| 186 | 186 | $rel == Link::OPDS_THUMBNAIL_TYPE || | 
| 187 | 187 | ($type == "epub" && $config['cops_update_epub-metadata'])) | 
| 188 | 188 |          { | 
| @@ -191,18 +191,18 @@ discard block | ||
| 191 | 191 | $urlParam = self::handleThumbnailLink($urlParam, $height); | 
| 192 | 192 | } | 
| 193 | 193 | $urlParam = addURLParameter($urlParam, "id", $book->id); | 
| 194 | - if (!is_null (GetUrlParam (DB))) $urlParam = addURLParameter ($urlParam, DB, GetUrlParam (DB)); | |
| 194 | + if (!is_null(GetUrlParam(DB))) $urlParam = addURLParameter($urlParam, DB, GetUrlParam(DB)); | |
| 195 | 195 | if ($config['cops_thumbnail_handling'] != "1" && | 
| 196 | 196 | !empty ($config['cops_thumbnail_handling']) && | 
| 197 | 197 |                  $rel == Link::OPDS_THUMBNAIL_TYPE) { | 
| 198 | - return new Link ($config['cops_thumbnail_handling'], $mime, $rel, $title); | |
| 198 | + return new Link($config['cops_thumbnail_handling'], $mime, $rel, $title); | |
| 199 | 199 |              } else { | 
| 200 | -                return new Link ("fetch.php?" . $urlParam, $mime, $rel, $title); | |
| 200 | +                return new Link("fetch.php?" . $urlParam, $mime, $rel, $title); | |
| 201 | 201 | } | 
| 202 | 202 | } | 
| 203 | 203 | else | 
| 204 | 204 |          { | 
| 205 | -            return new Link (str_replace('%2F','/',rawurlencode ($book->path."/".$filename)), $mime, $rel, $title); | |
| 205 | +            return new Link(str_replace('%2F', '/', rawurlencode($book->path . "/" . $filename)), $mime, $rel, $title); | |
| 206 | 206 | } | 
| 207 | 207 | } | 
| 208 | 208 | } | 
| @@ -55,7 +55,8 @@ discard block | ||
| 55 | 55 | 'zip' => 'application/zip' | 
| 56 | 56 | ); | 
| 57 | 57 | |
| 58 | -    public function __construct($post, $book = null) { | |
| 58 | + public function __construct($post, $book = null) | |
| 59 | +    { | |
| 59 | 60 | $this->id = $post->id; | 
| 60 | 61 | $this->name = $post->name; | 
| 61 | 62 | $this->format = $post->format; | 
| @@ -64,19 +65,20 @@ discard block | ||
| 64 | 65 | $this->book = $book; | 
| 65 | 66 | } | 
| 66 | 67 | |
| 67 | -    public function isKnownType () { | |
| 68 | + public function isKnownType () | |
| 69 | +    { | |
| 68 | 70 | return array_key_exists ($this->extension, self::$mimetypes); | 
| 69 | 71 | } | 
| 70 | 72 | |
| 71 | -    public function getMimeType () { | |
| 73 | + public function getMimeType () | |
| 74 | +    { | |
| 72 | 75 | $result = "application/octet-stream"; | 
| 73 | 76 |          if ($this->isKnownType ()) { | 
| 74 | 77 | return self::$mimetypes [$this->extension]; | 
| 75 | 78 |          } elseif (function_exists('finfo_open') === true) { | 
| 76 | 79 | $finfo = finfo_open(FILEINFO_MIME_TYPE); | 
| 77 | 80 | |
| 78 | - if (is_resource($finfo) === true) | |
| 79 | -            { | |
| 81 | +            if (is_resource($finfo) === true) { | |
| 80 | 82 | $result = finfo_file($finfo, $this->getLocalPath ()); | 
| 81 | 83 | } | 
| 82 | 84 | |
| @@ -86,29 +88,35 @@ discard block | ||
| 86 | 88 | return $result; | 
| 87 | 89 | } | 
| 88 | 90 | |
| 89 | -    public function isEpubValidOnKobo () { | |
| 91 | + public function isEpubValidOnKobo () | |
| 92 | +    { | |
| 90 | 93 | return $this->format == "EPUB" || $this->format == "KEPUB"; | 
| 91 | 94 | } | 
| 92 | 95 | |
| 93 | -    public function getFilename () { | |
| 96 | + public function getFilename () | |
| 97 | +    { | |
| 94 | 98 | return $this->name . "." . strtolower ($this->format); | 
| 95 | 99 | } | 
| 96 | 100 | |
| 97 | -    public function getUpdatedFilename () { | |
| 101 | + public function getUpdatedFilename () | |
| 102 | +    { | |
| 98 | 103 | return $this->book->getAuthorsSort () . " - " . $this->book->title; | 
| 99 | 104 | } | 
| 100 | 105 | |
| 101 | -    public function getUpdatedFilenameEpub () { | |
| 106 | + public function getUpdatedFilenameEpub () | |
| 107 | +    { | |
| 102 | 108 | return $this->getUpdatedFilename () . ".epub"; | 
| 103 | 109 | } | 
| 104 | 110 | |
| 105 | -    public function getUpdatedFilenameKepub () { | |
| 111 | + public function getUpdatedFilenameKepub () | |
| 112 | +    { | |
| 106 | 113 | $str = $this->getUpdatedFilename () . ".kepub.epub"; | 
| 107 | 114 |          return str_replace(array(':', '#', '&'), | 
| 108 | 115 |                             array('-', '-', ' '), $str ); | 
| 109 | 116 | } | 
| 110 | 117 | |
| 111 | -    public function getDataLink ($rel, $title = NULL) { | |
| 118 | + public function getDataLink ($rel, $title = NULL) | |
| 119 | +    { | |
| 112 | 120 | global $config; | 
| 113 | 121 | |
| 114 | 122 |          if ($rel == Link::OPDS_ACQUISITION_TYPE && $config['cops_use_url_rewriting'] == "1") { | 
| @@ -118,19 +126,24 @@ discard block | ||
| 118 | 126 | return self::getLink ($this->book, $this->extension, $this->getMimeType (), $rel, $this->getFilename (), $this->id, $title); | 
| 119 | 127 | } | 
| 120 | 128 | |
| 121 | -    public function getHtmlLink () { | |
| 129 | + public function getHtmlLink () | |
| 130 | +    { | |
| 122 | 131 | return $this->getDataLink(Link::OPDS_ACQUISITION_TYPE)->href; | 
| 123 | 132 | } | 
| 124 | 133 | |
| 125 | -    public function getLocalPath () { | |
| 134 | + public function getLocalPath () | |
| 135 | +    { | |
| 126 | 136 | return $this->book->path . "/" . $this->getFilename (); | 
| 127 | 137 | } | 
| 128 | 138 | |
| 129 | -    public function getHtmlLinkWithRewriting ($title = NULL) { | |
| 139 | + public function getHtmlLinkWithRewriting ($title = NULL) | |
| 140 | +    { | |
| 130 | 141 | global $config; | 
| 131 | 142 | |
| 132 | 143 | $database = ""; | 
| 133 | - if (!is_null (GetUrlParam (DB))) $database = GetUrlParam (DB) . "/"; | |
| 144 | +        if (!is_null (GetUrlParam (DB))) { | |
| 145 | + $database = GetUrlParam (DB) . "/"; | |
| 146 | + } | |
| 134 | 147 | |
| 135 | 148 | $href = "download/" . $this->id . "/" . $database; | 
| 136 | 149 | |
| @@ -144,28 +157,27 @@ discard block | ||
| 144 | 157 | return new Link ($href, $this->getMimeType (), Link::OPDS_ACQUISITION_TYPE, $title); | 
| 145 | 158 | } | 
| 146 | 159 | |
| 147 | -    public static function getDataByBook ($book) { | |
| 160 | + public static function getDataByBook ($book) | |
| 161 | +    { | |
| 148 | 162 | $out = array (); | 
| 149 | 163 |          $result = parent::getDb ()->prepare('select id, format, name | 
| 150 | 164 | from data where book = ?'); | 
| 151 | 165 | $result->execute (array ($book->id)); | 
| 152 | 166 | |
| 153 | - while ($post = $result->fetchObject ()) | |
| 154 | -        { | |
| 167 | +        while ($post = $result->fetchObject ()) { | |
| 155 | 168 | array_push ($out, new Data ($post, $book)); | 
| 156 | 169 | } | 
| 157 | 170 | return $out; | 
| 158 | 171 | } | 
| 159 | 172 | |
| 160 | -    public static function handleThumbnailLink ($urlParam, $height) { | |
| 173 | + public static function handleThumbnailLink ($urlParam, $height) | |
| 174 | +    { | |
| 161 | 175 | global $config; | 
| 162 | 176 | |
| 163 | 177 |          if (is_null ($height)) { | 
| 164 | 178 |              if (preg_match ('/feed.php/', $_SERVER["SCRIPT_NAME"])) { | 
| 165 | 179 | $height = $config['cops_opds_thumbnail_height']; | 
| 166 | - } | |
| 167 | - else | |
| 168 | -            { | |
| 180 | +            } else { | |
| 169 | 181 | $height = $config['cops_html_thumbnail_height']; | 
| 170 | 182 | } | 
| 171 | 183 | } | 
| @@ -184,14 +196,17 @@ discard block | ||
| 184 | 196 | |
| 185 | 197 | if (Base::useAbsolutePath () || | 
| 186 | 198 | $rel == Link::OPDS_THUMBNAIL_TYPE || | 
| 187 | - ($type == "epub" && $config['cops_update_epub-metadata'])) | |
| 188 | -        { | |
| 189 | - if ($type != "jpg") $urlParam = addURLParameter($urlParam, "type", $type); | |
| 199 | +            ($type == "epub" && $config['cops_update_epub-metadata'])) { | |
| 200 | +            if ($type != "jpg") { | |
| 201 | + $urlParam = addURLParameter($urlParam, "type", $type); | |
| 202 | + } | |
| 190 | 203 |              if ($rel == Link::OPDS_THUMBNAIL_TYPE) { | 
| 191 | 204 | $urlParam = self::handleThumbnailLink($urlParam, $height); | 
| 192 | 205 | } | 
| 193 | 206 | $urlParam = addURLParameter($urlParam, "id", $book->id); | 
| 194 | - if (!is_null (GetUrlParam (DB))) $urlParam = addURLParameter ($urlParam, DB, GetUrlParam (DB)); | |
| 207 | +            if (!is_null (GetUrlParam (DB))) { | |
| 208 | + $urlParam = addURLParameter ($urlParam, DB, GetUrlParam (DB)); | |
| 209 | + } | |
| 195 | 210 | if ($config['cops_thumbnail_handling'] != "1" && | 
| 196 | 211 | !empty ($config['cops_thumbnail_handling']) && | 
| 197 | 212 |                  $rel == Link::OPDS_THUMBNAIL_TYPE) { | 
| @@ -199,9 +214,7 @@ discard block | ||
| 199 | 214 |              } else { | 
| 200 | 215 |                  return new Link ("fetch.php?" . $urlParam, $mime, $rel, $title); | 
| 201 | 216 | } | 
| 202 | - } | |
| 203 | - else | |
| 204 | -        { | |
| 217 | +        } else { | |
| 205 | 218 |              return new Link (str_replace('%2F','/',rawurlencode ($book->path."/".$filename)), $mime, $rel, $title); | 
| 206 | 219 | } | 
| 207 | 220 | } | 
| @@ -108,7 +108,7 @@ discard block | ||
| 108 | 108 |                             array('-', '-', ' '), $str ); | 
| 109 | 109 | } | 
| 110 | 110 | |
| 111 | -    public function getDataLink ($rel, $title = NULL) { | |
| 111 | +    public function getDataLink ($rel, $title = null) { | |
| 112 | 112 | global $config; | 
| 113 | 113 | |
| 114 | 114 |          if ($rel == Link::OPDS_ACQUISITION_TYPE && $config['cops_use_url_rewriting'] == "1") { | 
| @@ -126,7 +126,7 @@ discard block | ||
| 126 | 126 | return $this->book->path . "/" . $this->getFilename (); | 
| 127 | 127 | } | 
| 128 | 128 | |
| 129 | -    public function getHtmlLinkWithRewriting ($title = NULL) { | |
| 129 | +    public function getHtmlLinkWithRewriting ($title = null) { | |
| 130 | 130 | global $config; | 
| 131 | 131 | |
| 132 | 132 | $database = ""; | 
| @@ -176,7 +176,7 @@ discard block | ||
| 176 | 176 | return $urlParam; | 
| 177 | 177 | } | 
| 178 | 178 | |
| 179 | - public static function getLink ($book, $type, $mime, $rel, $filename, $idData, $title = NULL, $height = NULL) | |
| 179 | + public static function getLink ($book, $type, $mime, $rel, $filename, $idData, $title = null, $height = null) | |
| 180 | 180 |      { | 
| 181 | 181 | global $config; | 
| 182 | 182 | |
| @@ -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)) { |