@@ -78,9 +78,9 @@ |
||
| 78 | 78 | $mail->AltBody = "Sent by COPS"; |
| 79 | 79 | |
| 80 | 80 | if (!$mail->Send()) { |
| 81 | - echo localize ("mail.messagenotsent"); |
|
| 82 | - echo 'Mailer Error: ' . $mail->ErrorInfo; |
|
| 83 | - exit; |
|
| 81 | + echo localize ("mail.messagenotsent"); |
|
| 82 | + echo 'Mailer Error: ' . $mail->ErrorInfo; |
|
| 83 | + exit; |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | echo localize ("mail.messagesent"); |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | empty ($config['cops_mail_configuration']["address.from"])) { |
| 12 | 12 | return "NOK. bad configuration."; |
| 13 | 13 | } |
| 14 | - return False; |
|
| 14 | + return false; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | function checkRequest ($idData, $emailDest) { |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | if (empty ($emailDest)) { |
| 22 | 22 | return 'No email sent.'; |
| 23 | 23 | } |
| 24 | - return False; |
|
| 24 | + return false; |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | if (php_sapi_name() === 'cli') { return; } |
@@ -3,11 +3,11 @@ discard block |
||
| 3 | 3 | require_once dirname(__FILE__) . '/config.php'; |
| 4 | 4 | require_once dirname(__FILE__) . '/base.php'; |
| 5 | 5 | |
| 6 | -function checkConfiguration () { |
|
| 6 | +function checkConfiguration() { |
|
| 7 | 7 | global $config; |
| 8 | 8 | |
| 9 | - if (is_null ($config['cops_mail_configuration']) || |
|
| 10 | - !is_array ($config['cops_mail_configuration']) || |
|
| 9 | + if (is_null($config['cops_mail_configuration']) || |
|
| 10 | + !is_array($config['cops_mail_configuration']) || |
|
| 11 | 11 | empty ($config['cops_mail_configuration']["smtp.host"]) || |
| 12 | 12 | empty ($config['cops_mail_configuration']["address.from"])) { |
| 13 | 13 | return "NOK. bad configuration."; |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | return False; |
| 16 | 16 | } |
| 17 | 17 | |
| 18 | -function checkRequest ($idData, $emailDest) { |
|
| 18 | +function checkRequest($idData, $emailDest) { |
|
| 19 | 19 | if (empty ($idData)) { |
| 20 | 20 | return 'No data sent.'; |
| 21 | 21 | } |
@@ -29,22 +29,22 @@ discard block |
||
| 29 | 29 | |
| 30 | 30 | global $config; |
| 31 | 31 | |
| 32 | -if ($error = checkConfiguration ()) { |
|
| 32 | +if ($error = checkConfiguration()) { |
|
| 33 | 33 | echo $error; |
| 34 | 34 | exit; |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | $idData = $_REQUEST["data"]; |
| 38 | 38 | $emailDest = $_REQUEST["email"]; |
| 39 | -if ($error = checkRequest ($idData, $emailDest)) { |
|
| 39 | +if ($error = checkRequest($idData, $emailDest)) { |
|
| 40 | 40 | echo $error; |
| 41 | 41 | exit; |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | $book = Book::getBookByDataId($idData); |
| 45 | -$data = $book->getDataById ($idData); |
|
| 45 | +$data = $book->getDataById($idData); |
|
| 46 | 46 | |
| 47 | -if (filesize ($data->getLocalPath ()) > 10 * 1024 * 1024) { |
|
| 47 | +if (filesize($data->getLocalPath()) > 10 * 1024 * 1024) { |
|
| 48 | 48 | echo 'Attachment too big'; |
| 49 | 49 | exit; |
| 50 | 50 | } |
@@ -66,12 +66,12 @@ discard block |
||
| 66 | 66 | $mail->From = $config['cops_mail_configuration']["address.from"]; |
| 67 | 67 | $mail->FromName = $config['cops_title_default']; |
| 68 | 68 | |
| 69 | -foreach (explode (";", $emailDest) as $emailAddress) { |
|
| 69 | +foreach (explode(";", $emailDest) as $emailAddress) { |
|
| 70 | 70 | if (empty ($emailAddress)) { continue; } |
| 71 | 71 | $mail->AddAddress($emailAddress); |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | -$mail->AddAttachment($data->getLocalPath ()); |
|
| 74 | +$mail->AddAttachment($data->getLocalPath()); |
|
| 75 | 75 | |
| 76 | 76 | $mail->IsHTML(true); |
| 77 | 77 | $mail->CharSet = "UTF-8"; |
@@ -79,15 +79,15 @@ discard block |
||
| 79 | 79 | if (!empty ($config['cops_mail_configuration']["subject"])) { |
| 80 | 80 | $mail->Subject = $config['cops_mail_configuration']["subject"]; |
| 81 | 81 | } |
| 82 | -$mail->Subject .= $data->getUpdatedFilename (); |
|
| 83 | -$mail->Body = "<h1>" . $book->title . "</h1><h2>" . $book->getAuthorsName () . "</h2>" . $book->getComment (); |
|
| 82 | +$mail->Subject .= $data->getUpdatedFilename(); |
|
| 83 | +$mail->Body = "<h1>" . $book->title . "</h1><h2>" . $book->getAuthorsName() . "</h2>" . $book->getComment(); |
|
| 84 | 84 | $mail->AltBody = "Sent by COPS"; |
| 85 | 85 | |
| 86 | 86 | if (!$mail->Send()) { |
| 87 | - echo localize ("mail.messagenotsent"); |
|
| 87 | + echo localize("mail.messagenotsent"); |
|
| 88 | 88 | echo 'Mailer Error: ' . $mail->ErrorInfo; |
| 89 | 89 | exit; |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | -echo localize ("mail.messagesent"); |
|
| 92 | +echo localize("mail.messagesent"); |
|
| 93 | 93 | |
@@ -3,7 +3,8 @@ discard block |
||
| 3 | 3 | require_once dirname(__FILE__) . '/config.php'; |
| 4 | 4 | require_once dirname(__FILE__) . '/base.php'; |
| 5 | 5 | |
| 6 | -function checkConfiguration () { |
|
| 6 | +function checkConfiguration () |
|
| 7 | +{ |
|
| 7 | 8 | global $config; |
| 8 | 9 | |
| 9 | 10 | if (is_null ($config['cops_mail_configuration']) || |
@@ -15,7 +16,8 @@ discard block |
||
| 15 | 16 | return False; |
| 16 | 17 | } |
| 17 | 18 | |
| 18 | -function checkRequest ($idData, $emailDest) { |
|
| 19 | +function checkRequest ($idData, $emailDest) |
|
| 20 | +{ |
|
| 19 | 21 | if (empty ($idData)) { |
| 20 | 22 | return 'No data sent.'; |
| 21 | 23 | } |
@@ -59,10 +61,18 @@ discard block |
||
| 59 | 61 | $mail->Port = 465; |
| 60 | 62 | } |
| 61 | 63 | $mail->SMTPAuth = !empty ($config['cops_mail_configuration']["smtp.username"]); |
| 62 | -if (!empty ($config['cops_mail_configuration']["smtp.username"])) $mail->Username = $config['cops_mail_configuration']["smtp.username"]; |
|
| 63 | -if (!empty ($config['cops_mail_configuration']["smtp.password"])) $mail->Password = $config['cops_mail_configuration']["smtp.password"]; |
|
| 64 | -if (!empty ($config['cops_mail_configuration']["smtp.secure"])) $mail->SMTPSecure = $config['cops_mail_configuration']["smtp.secure"]; |
|
| 65 | -if (!empty ($config['cops_mail_configuration']["smtp.port"])) $mail->Port = $config['cops_mail_configuration']["smtp.port"]; |
|
| 64 | +if (!empty ($config['cops_mail_configuration']["smtp.username"])) { |
|
| 65 | + $mail->Username = $config['cops_mail_configuration']["smtp.username"]; |
|
| 66 | +} |
|
| 67 | +if (!empty ($config['cops_mail_configuration']["smtp.password"])) { |
|
| 68 | + $mail->Password = $config['cops_mail_configuration']["smtp.password"]; |
|
| 69 | +} |
|
| 70 | +if (!empty ($config['cops_mail_configuration']["smtp.secure"])) { |
|
| 71 | + $mail->SMTPSecure = $config['cops_mail_configuration']["smtp.secure"]; |
|
| 72 | +} |
|
| 73 | +if (!empty ($config['cops_mail_configuration']["smtp.port"])) { |
|
| 74 | + $mail->Port = $config['cops_mail_configuration']["smtp.port"]; |
|
| 75 | +} |
|
| 66 | 76 | |
| 67 | 77 | $mail->From = $config['cops_mail_configuration']["address.from"]; |
| 68 | 78 | $mail->FromName = $config['cops_title_default']; |
@@ -72,11 +72,11 @@ |
||
| 72 | 72 | try { |
| 73 | 73 | $data = getComponentContent($book, $component, $add); |
| 74 | 74 | |
| 75 | - $expires = 60*60*24*14; |
|
| 75 | + $expires = 60 * 60 * 24 * 14; |
|
| 76 | 76 | header('Pragma: public'); |
| 77 | - header('Cache-Control: maxage='.$expires); |
|
| 78 | - header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$expires) . ' GMT'); |
|
| 79 | - header ('Content-Type: ' . $book->componentContentType($component)); |
|
| 77 | + header('Cache-Control: maxage=' . $expires); |
|
| 78 | + header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT'); |
|
| 79 | + header('Content-Type: ' . $book->componentContentType($component)); |
|
| 80 | 80 | echo $data; |
| 81 | 81 | } catch (Exception $e) { |
| 82 | 82 | error_log($e); |
@@ -51,7 +51,7 @@ |
||
| 51 | 51 | return; |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | -$idData = getURLParam('data', NULL); |
|
| 54 | +$idData = getURLParam('data', null); |
|
| 55 | 55 | $add = 'data=' . $idData . '&'; |
| 56 | 56 | if (!is_null(GetUrlParam(DB))) { |
| 57 | 57 | $add .= DB . '=' . GetUrlParam(DB) . '&'; |
@@ -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 'config.php'; |
| 10 | 10 | |
| 11 | -define ('VERSION', '1.2.0'); |
|
| 12 | -define ('DB', 'db'); |
|
| 11 | +define('VERSION', '1.2.0'); |
|
| 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 | } |
@@ -21,13 +21,11 @@ |
||
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | if(!is_null($config['cops_basic_authentication']) && |
| 24 | - is_array($config['cops_basic_authentication'])) |
|
| 25 | -{ |
|
| 24 | + is_array($config['cops_basic_authentication'])) { |
|
| 26 | 25 | if (!isset($_SERVER['PHP_AUTH_USER']) || |
| 27 | 26 | (isset($_SERVER['PHP_AUTH_USER']) && |
| 28 | 27 | ($_SERVER['PHP_AUTH_USER']!=$config['cops_basic_authentication']['username'] || |
| 29 | - $_SERVER['PHP_AUTH_PW'] != $config['cops_basic_authentication']['password']))) |
|
| 30 | - { |
|
| 28 | + $_SERVER['PHP_AUTH_PW'] != $config['cops_basic_authentication']['password']))) { |
|
| 31 | 29 | header('WWW-Authenticate: Basic realm="COPS Authentication"'); |
| 32 | 30 | header('HTTP/1.0 401 Unauthorized'); |
| 33 | 31 | echo 'This site is password protected'; |
@@ -12,20 +12,20 @@ |
||
| 12 | 12 | require dirname(__FILE__) . '/config_local.php'; |
| 13 | 13 | } |
| 14 | 14 | |
| 15 | -$remote_user = array_key_exists('PHP_AUTH_USER', $_SERVER) ? $_SERVER['PHP_AUTH_USER'] : ''; |
|
| 15 | +$remote_user = array_key_exists('PHP_AUTH_USER', $_SERVER)?$_SERVER['PHP_AUTH_USER']:''; |
|
| 16 | 16 | // Clean username, only allow a-z, A-Z, 0-9, -_ chars |
| 17 | -$remote_user = preg_replace( '/[^a-zA-Z0-9_-]/', '', $remote_user); |
|
| 17 | +$remote_user = preg_replace('/[^a-zA-Z0-9_-]/', '', $remote_user); |
|
| 18 | 18 | $user_config_file = 'config_local.' . $remote_user . '.php'; |
| 19 | 19 | if (file_exists(dirname(__FILE__) . '/' . $user_config_file) && (php_sapi_name() !== 'cli')) { |
| 20 | 20 | require dirname(__FILE__) . '/' . $user_config_file; |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | -if(!is_null($config['cops_basic_authentication']) && |
|
| 23 | +if (!is_null($config['cops_basic_authentication']) && |
|
| 24 | 24 | is_array($config['cops_basic_authentication'])) |
| 25 | 25 | { |
| 26 | 26 | if (!isset($_SERVER['PHP_AUTH_USER']) || |
| 27 | 27 | (isset($_SERVER['PHP_AUTH_USER']) && |
| 28 | - ($_SERVER['PHP_AUTH_USER']!=$config['cops_basic_authentication']['username'] || |
|
| 28 | + ($_SERVER['PHP_AUTH_USER'] != $config['cops_basic_authentication']['username'] || |
|
| 29 | 29 | $_SERVER['PHP_AUTH_PW'] != $config['cops_basic_authentication']['password']))) |
| 30 | 30 | { |
| 31 | 31 | header('WWW-Authenticate: Basic realm="COPS Authentication"'); |
@@ -237,8 +237,7 @@ |
||
| 237 | 237 | $db = new PDO('sqlite:' . Base::getDbFileName($i)); |
| 238 | 238 | $result = $db->prepare('select books.path || "/" || data.name || "." || lower (format) as fullpath from data join books on data.book = books.id'); |
| 239 | 239 | $result->execute(); |
| 240 | - while ($post = $result->fetchObject()) |
|
| 241 | - { |
|
| 240 | + while ($post = $result->fetchObject()) { |
|
| 242 | 241 | if (!is_file (Base::getDbDirectory($i) . $post->fullpath)) { |
| 243 | 242 | echo '<p>' . Base::getDbDirectory($i) . $post->fullpath . '</p>'; |
| 244 | 243 | } |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | <meta charset="utf-8"> |
| 27 | 27 | <meta name="viewport" content="width=device-width, initial-scale=1.0" /> |
| 28 | 28 | <title>COPS Configuration Check</title> |
| 29 | - <link rel="stylesheet" type="text/css" href="<?php echo getUrlWithVersion(getCurrentCss ()) ?>" media="screen" /> |
|
| 29 | + <link rel="stylesheet" type="text/css" href="<?php echo getUrlWithVersion(getCurrentCss()) ?>" media="screen" /> |
|
| 30 | 30 | </head> |
| 31 | 31 | <body> |
| 32 | 32 | <div class="container"> |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | <h2>Check if the rendering will be done on client side or server side</h2> |
| 152 | 152 | <h4> |
| 153 | 153 | <?php |
| 154 | - if (useServerSideRendering ()) { |
|
| 154 | + if (useServerSideRendering()) { |
|
| 155 | 155 | echo 'Server side rendering'; |
| 156 | 156 | } else { |
| 157 | 157 | echo 'Client side rendering'; |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | <h2>Check if Calibre database path is not an URL</h2> |
| 168 | 168 | <h4> |
| 169 | 169 | <?php |
| 170 | - if (!preg_match ('#^http#', $database)) { |
|
| 170 | + if (!preg_match('#^http#', $database)) { |
|
| 171 | 171 | echo $name . ' OK'; |
| 172 | 172 | } else { |
| 173 | 173 | echo $name . ' Calibre path has to be local (no URL allowed)'; |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | <h4> |
| 201 | 201 | <?php |
| 202 | 202 | try { |
| 203 | - $db = new PDO('sqlite:'. Base::getDbFileName($i)); |
|
| 203 | + $db = new PDO('sqlite:' . Base::getDbFileName($i)); |
|
| 204 | 204 | echo $name . ' OK'; |
| 205 | 205 | } catch (Exception $e) { |
| 206 | 206 | echo $name . ' If the file is readable, check your php configuration. Exception detail : ' . $e; |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | <h4> |
| 214 | 214 | <?php |
| 215 | 215 | try { |
| 216 | - $db = new PDO('sqlite:'. Base::getDbFileName($i)); |
|
| 216 | + $db = new PDO('sqlite:' . Base::getDbFileName($i)); |
|
| 217 | 217 | $count = $db->query('select count(*) FROM sqlite_master WHERE type="table" AND name in ("books", "authors", "tags", "series")')->fetchColumn(); |
| 218 | 218 | if ($count == 4) { |
| 219 | 219 | echo $name . ' OK'; |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | $result->execute(); |
| 238 | 238 | while ($post = $result->fetchObject()) |
| 239 | 239 | { |
| 240 | - if (!is_file (Base::getDbDirectory($i) . $post->fullpath)) { |
|
| 240 | + if (!is_file(Base::getDbDirectory($i) . $post->fullpath)) { |
|
| 241 | 241 | echo '<p>' . Base::getDbDirectory($i) . $post->fullpath . '</p>'; |
| 242 | 242 | } |
| 243 | 243 | } |
@@ -14,7 +14,7 @@ |
||
| 14 | 14 | |
| 15 | 15 | $err = getURLParam('err', -1); |
| 16 | 16 | $full = getURLParam('full'); |
| 17 | - $error = NULL; |
|
| 17 | + $error = null; |
|
| 18 | 18 | switch ($err) { |
| 19 | 19 | case 1 : |
| 20 | 20 | $error = 'Database error'; |
@@ -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, $view = false) { |
@@ -108,14 +108,14 @@ discard block |
||
| 108 | 108 | array('-', '-', ' '), $str ); |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - public function getDataLink ($rel, $title = NULL, $view = false) { |
|
| 111 | + public function getDataLink ($rel, $title = null, $view = false) { |
|
| 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, $view); |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - return self::getLink ($this->book, $this->extension, $this->getMimeType (), $rel, $this->getFilename (), $this->id, $title, NULL, $view); |
|
| 118 | + return self::getLink ($this->book, $this->extension, $this->getMimeType (), $rel, $this->getFilename (), $this->id, $title, null, $view); |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | public function getHtmlLink () { |
@@ -123,14 +123,14 @@ discard block |
||
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | public function getViewHtmlLink () { |
| 126 | - return $this->getDataLink(Link::OPDS_ACQUISITION_TYPE, NULL, true)->href; |
|
| 126 | + return $this->getDataLink(Link::OPDS_ACQUISITION_TYPE, null, true)->href; |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | public function getLocalPath () { |
| 130 | 130 | return $this->book->path . "/" . $this->getFilename (); |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | - public function getHtmlLinkWithRewriting ($title = NULL, $view = false) { |
|
| 133 | + public function getHtmlLinkWithRewriting ($title = null, $view = false) { |
|
| 134 | 134 | global $config; |
| 135 | 135 | |
| 136 | 136 | $database = ""; |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | return $urlParam; |
| 185 | 185 | } |
| 186 | 186 | |
| 187 | - public static function getLink ($book, $type, $mime, $rel, $filename, $idData, $title = NULL, $height = NULL, $view = false) |
|
| 187 | + public static function getLink ($book, $type, $mime, $rel, $filename, $idData, $title = null, $height = null, $view = false) |
|
| 188 | 188 | { |
| 189 | 189 | global $config; |
| 190 | 190 | |
@@ -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,55 +86,55 @@ 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, $view = false) { |
|
| 111 | + public function getDataLink($rel, $title = NULL, $view = false) { |
|
| 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, $view); |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - return self::getLink ($this->book, $this->extension, $this->getMimeType (), $rel, $this->getFilename (), $this->id, $title, NULL, $view); |
|
| 118 | + return self::getLink($this->book, $this->extension, $this->getMimeType(), $rel, $this->getFilename(), $this->id, $title, NULL, $view); |
|
| 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 getViewHtmlLink () { |
|
| 125 | + public function getViewHtmlLink() { |
|
| 126 | 126 | return $this->getDataLink(Link::OPDS_ACQUISITION_TYPE, NULL, true)->href; |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | - public function getLocalPath () { |
|
| 130 | - return $this->book->path . "/" . $this->getFilename (); |
|
| 129 | + public function getLocalPath() { |
|
| 130 | + return $this->book->path . "/" . $this->getFilename(); |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | - public function getHtmlLinkWithRewriting ($title = NULL, $view = false) { |
|
| 133 | + public function getHtmlLinkWithRewriting($title = NULL, $view = false) { |
|
| 134 | 134 | global $config; |
| 135 | 135 | |
| 136 | 136 | $database = ""; |
| 137 | - if (!is_null (GetUrlParam (DB))) $database = GetUrlParam (DB) . "/"; |
|
| 137 | + if (!is_null(GetUrlParam(DB))) $database = GetUrlParam(DB) . "/"; |
|
| 138 | 138 | |
| 139 | 139 | $prefix = "download"; |
| 140 | 140 | if ($view) { |
@@ -143,19 +143,19 @@ discard block |
||
| 143 | 143 | $href = $prefix . "/" . $this->id . "/" . $database; |
| 144 | 144 | |
| 145 | 145 | if ($config['cops_provide_kepub'] == "1" && |
| 146 | - $this->isEpubValidOnKobo () && |
|
| 146 | + $this->isEpubValidOnKobo() && |
|
| 147 | 147 | preg_match("/Kobo/", $_SERVER['HTTP_USER_AGENT'])) { |
| 148 | - $href .= rawurlencode ($this->getUpdatedFilenameKepub ()); |
|
| 148 | + $href .= rawurlencode($this->getUpdatedFilenameKepub()); |
|
| 149 | 149 | } else { |
| 150 | - $href .= rawurlencode ($this->getFilename ()); |
|
| 150 | + $href .= rawurlencode($this->getFilename()); |
|
| 151 | 151 | } |
| 152 | - return new Link ($href, $this->getMimeType (), Link::OPDS_ACQUISITION_TYPE, $title); |
|
| 152 | + return new Link($href, $this->getMimeType(), Link::OPDS_ACQUISITION_TYPE, $title); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | - public static function getDataByBook ($book) { |
|
| 155 | + public static function getDataByBook($book) { |
|
| 156 | 156 | global $config; |
| 157 | 157 | |
| 158 | - $out = array (); |
|
| 158 | + $out = array(); |
|
| 159 | 159 | |
| 160 | 160 | $sql = 'select id, format, name from data where book = ?'; |
| 161 | 161 | |
@@ -166,21 +166,21 @@ discard block |
||
| 166 | 166 | . "')"; |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | - $result = parent::getDb ()->prepare($sql); |
|
| 170 | - $result->execute (array ($book->id)); |
|
| 169 | + $result = parent::getDb()->prepare($sql); |
|
| 170 | + $result->execute(array($book->id)); |
|
| 171 | 171 | |
| 172 | - while ($post = $result->fetchObject ()) |
|
| 172 | + while ($post = $result->fetchObject()) |
|
| 173 | 173 | { |
| 174 | - array_push ($out, new Data ($post, $book)); |
|
| 174 | + array_push($out, new Data($post, $book)); |
|
| 175 | 175 | } |
| 176 | 176 | return $out; |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - public static function handleThumbnailLink ($urlParam, $height) { |
|
| 179 | + public static function handleThumbnailLink($urlParam, $height) { |
|
| 180 | 180 | global $config; |
| 181 | 181 | |
| 182 | - if (is_null ($height)) { |
|
| 183 | - if (preg_match ('/feed.php/', $_SERVER["SCRIPT_NAME"])) { |
|
| 182 | + if (is_null($height)) { |
|
| 183 | + if (preg_match('/feed.php/', $_SERVER["SCRIPT_NAME"])) { |
|
| 184 | 184 | $height = $config['cops_opds_thumbnail_height']; |
| 185 | 185 | } |
| 186 | 186 | else |
@@ -195,14 +195,14 @@ discard block |
||
| 195 | 195 | return $urlParam; |
| 196 | 196 | } |
| 197 | 197 | |
| 198 | - public static function getLink ($book, $type, $mime, $rel, $filename, $idData, $title = NULL, $height = NULL, $view = false) |
|
| 198 | + public static function getLink($book, $type, $mime, $rel, $filename, $idData, $title = NULL, $height = NULL, $view = false) |
|
| 199 | 199 | { |
| 200 | 200 | global $config; |
| 201 | 201 | |
| 202 | 202 | $urlParam = addURLParameter("", "data", $idData); |
| 203 | 203 | if ($view) $urlParam = addURLParameter($urlParam, "view", 1); |
| 204 | 204 | |
| 205 | - if (Base::useAbsolutePath () || |
|
| 205 | + if (Base::useAbsolutePath() || |
|
| 206 | 206 | $rel == Link::OPDS_THUMBNAIL_TYPE || |
| 207 | 207 | ($type == "epub" && $config['cops_update_epub-metadata'])) |
| 208 | 208 | { |
@@ -211,18 +211,18 @@ discard block |
||
| 211 | 211 | $urlParam = self::handleThumbnailLink($urlParam, $height); |
| 212 | 212 | } |
| 213 | 213 | $urlParam = addURLParameter($urlParam, "id", $book->id); |
| 214 | - if (!is_null (GetUrlParam (DB))) $urlParam = addURLParameter ($urlParam, DB, GetUrlParam (DB)); |
|
| 214 | + if (!is_null(GetUrlParam(DB))) $urlParam = addURLParameter($urlParam, DB, GetUrlParam(DB)); |
|
| 215 | 215 | if ($config['cops_thumbnail_handling'] != "1" && |
| 216 | 216 | !empty ($config['cops_thumbnail_handling']) && |
| 217 | 217 | $rel == Link::OPDS_THUMBNAIL_TYPE) { |
| 218 | - return new Link ($config['cops_thumbnail_handling'], $mime, $rel, $title); |
|
| 218 | + return new Link($config['cops_thumbnail_handling'], $mime, $rel, $title); |
|
| 219 | 219 | } else { |
| 220 | - return new Link ("fetch.php?" . $urlParam, $mime, $rel, $title); |
|
| 220 | + return new Link("fetch.php?" . $urlParam, $mime, $rel, $title); |
|
| 221 | 221 | } |
| 222 | 222 | } |
| 223 | 223 | else |
| 224 | 224 | { |
| 225 | - return new Link (str_replace('%2F','/',rawurlencode ($book->path."/".$filename)), $mime, $rel, $title); |
|
| 225 | + return new Link(str_replace('%2F', '/', rawurlencode($book->path . "/" . $filename)), $mime, $rel, $title); |
|
| 226 | 226 | } |
| 227 | 227 | } |
| 228 | 228 | } |
@@ -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, $view = false) { |
|
| 118 | + public function getDataLink ($rel, $title = NULL, $view = false) |
|
| 119 | + { |
|
| 112 | 120 | global $config; |
| 113 | 121 | |
| 114 | 122 | if ($rel == Link::OPDS_ACQUISITION_TYPE && $config['cops_use_url_rewriting'] == "1") { |
@@ -118,23 +126,29 @@ discard block |
||
| 118 | 126 | return self::getLink ($this->book, $this->extension, $this->getMimeType (), $rel, $this->getFilename (), $this->id, $title, NULL, $view); |
| 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 getViewHtmlLink () { |
|
| 134 | + public function getViewHtmlLink () |
|
| 135 | + { |
|
| 126 | 136 | return $this->getDataLink(Link::OPDS_ACQUISITION_TYPE, NULL, true)->href; |
| 127 | 137 | } |
| 128 | 138 | |
| 129 | - public function getLocalPath () { |
|
| 139 | + public function getLocalPath () |
|
| 140 | + { |
|
| 130 | 141 | return $this->book->path . "/" . $this->getFilename (); |
| 131 | 142 | } |
| 132 | 143 | |
| 133 | - public function getHtmlLinkWithRewriting ($title = NULL, $view = false) { |
|
| 144 | + public function getHtmlLinkWithRewriting ($title = NULL, $view = false) |
|
| 145 | + { |
|
| 134 | 146 | global $config; |
| 135 | 147 | |
| 136 | 148 | $database = ""; |
| 137 | - if (!is_null (GetUrlParam (DB))) $database = GetUrlParam (DB) . "/"; |
|
| 149 | + if (!is_null (GetUrlParam (DB))) { |
|
| 150 | + $database = GetUrlParam (DB) . "/"; |
|
| 151 | + } |
|
| 138 | 152 | |
| 139 | 153 | $prefix = "download"; |
| 140 | 154 | if ($view) { |
@@ -152,7 +166,8 @@ discard block |
||
| 152 | 166 | return new Link ($href, $this->getMimeType (), Link::OPDS_ACQUISITION_TYPE, $title); |
| 153 | 167 | } |
| 154 | 168 | |
| 155 | - public static function getDataByBook ($book) { |
|
| 169 | + public static function getDataByBook ($book) |
|
| 170 | + { |
|
| 156 | 171 | global $config; |
| 157 | 172 | |
| 158 | 173 | $out = array (); |
@@ -169,22 +184,20 @@ discard block |
||
| 169 | 184 | $result = parent::getDb ()->prepare($sql); |
| 170 | 185 | $result->execute (array ($book->id)); |
| 171 | 186 | |
| 172 | - while ($post = $result->fetchObject ()) |
|
| 173 | - { |
|
| 187 | + while ($post = $result->fetchObject ()) { |
|
| 174 | 188 | array_push ($out, new Data ($post, $book)); |
| 175 | 189 | } |
| 176 | 190 | return $out; |
| 177 | 191 | } |
| 178 | 192 | |
| 179 | - public static function handleThumbnailLink ($urlParam, $height) { |
|
| 193 | + public static function handleThumbnailLink ($urlParam, $height) |
|
| 194 | + { |
|
| 180 | 195 | global $config; |
| 181 | 196 | |
| 182 | 197 | if (is_null ($height)) { |
| 183 | 198 | if (preg_match ('/feed.php/', $_SERVER["SCRIPT_NAME"])) { |
| 184 | 199 | $height = $config['cops_opds_thumbnail_height']; |
| 185 | - } |
|
| 186 | - else |
|
| 187 | - { |
|
| 200 | + } else { |
|
| 188 | 201 | $height = $config['cops_html_thumbnail_height']; |
| 189 | 202 | } |
| 190 | 203 | } |
@@ -200,18 +213,23 @@ discard block |
||
| 200 | 213 | global $config; |
| 201 | 214 | |
| 202 | 215 | $urlParam = addURLParameter("", "data", $idData); |
| 203 | - if ($view) $urlParam = addURLParameter($urlParam, "view", 1); |
|
| 216 | + if ($view) { |
|
| 217 | + $urlParam = addURLParameter($urlParam, "view", 1); |
|
| 218 | + } |
|
| 204 | 219 | |
| 205 | 220 | if (Base::useAbsolutePath () || |
| 206 | 221 | $rel == Link::OPDS_THUMBNAIL_TYPE || |
| 207 | - ($type == "epub" && $config['cops_update_epub-metadata'])) |
|
| 208 | - { |
|
| 209 | - if ($type != "jpg") $urlParam = addURLParameter($urlParam, "type", $type); |
|
| 222 | + ($type == "epub" && $config['cops_update_epub-metadata'])) { |
|
| 223 | + if ($type != "jpg") { |
|
| 224 | + $urlParam = addURLParameter($urlParam, "type", $type); |
|
| 225 | + } |
|
| 210 | 226 | if ($rel == Link::OPDS_THUMBNAIL_TYPE) { |
| 211 | 227 | $urlParam = self::handleThumbnailLink($urlParam, $height); |
| 212 | 228 | } |
| 213 | 229 | $urlParam = addURLParameter($urlParam, "id", $book->id); |
| 214 | - if (!is_null (GetUrlParam (DB))) $urlParam = addURLParameter ($urlParam, DB, GetUrlParam (DB)); |
|
| 230 | + if (!is_null (GetUrlParam (DB))) { |
|
| 231 | + $urlParam = addURLParameter ($urlParam, DB, GetUrlParam (DB)); |
|
| 232 | + } |
|
| 215 | 233 | if ($config['cops_thumbnail_handling'] != "1" && |
| 216 | 234 | !empty ($config['cops_thumbnail_handling']) && |
| 217 | 235 | $rel == Link::OPDS_THUMBNAIL_TYPE) { |
@@ -219,9 +237,7 @@ discard block |
||
| 219 | 237 | } else { |
| 220 | 238 | return new Link ("fetch.php?" . $urlParam, $mime, $rel, $title); |
| 221 | 239 | } |
| 222 | - } |
|
| 223 | - else |
|
| 224 | - { |
|
| 240 | + } else { |
|
| 225 | 241 | return new Link (str_replace('%2F','/',rawurlencode ($book->path."/".$filename)), $mime, $rel, $title); |
| 226 | 242 | } |
| 227 | 243 | } |
@@ -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 = ? order by books_authors_link.id'); |
| 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 = ? order by books_authors_link.id'); |
@@ -55,11 +55,11 @@ |
||
| 55 | 55 | $this->entryArray = array (); |
| 56 | 56 | |
| 57 | 57 | $ignoredBaseArray = array (PageQueryResult::SCOPE_AUTHOR, |
| 58 | - PageQueryResult::SCOPE_TAG, |
|
| 59 | - PageQueryResult::SCOPE_SERIES, |
|
| 60 | - PageQueryResult::SCOPE_PUBLISHER, |
|
| 61 | - PageQueryResult::SCOPE_RATING, |
|
| 62 | - "language"); |
|
| 58 | + PageQueryResult::SCOPE_TAG, |
|
| 59 | + PageQueryResult::SCOPE_SERIES, |
|
| 60 | + PageQueryResult::SCOPE_PUBLISHER, |
|
| 61 | + PageQueryResult::SCOPE_RATING, |
|
| 62 | + "language"); |
|
| 63 | 63 | |
| 64 | 64 | $content = ""; |
| 65 | 65 | if (!preg_match("/(Kobo|Kindle\/3.0|EBRD1101)/", $_SERVER['HTTP_USER_AGENT'])) { |
@@ -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,39 +22,39 @@ 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 getTemplateList () { |
|
| 33 | - $result = array (); |
|
| 34 | - foreach (glob ("templates/*") as $filename) { |
|
| 35 | - if (preg_match ('/templates\/(.*)/', $filename, $m)) { |
|
| 36 | - array_push ($result, $m [1]); |
|
| 32 | + private function getTemplateList() { |
|
| 33 | + $result = array(); |
|
| 34 | + foreach (glob("templates/*") as $filename) { |
|
| 35 | + if (preg_match('/templates\/(.*)/', $filename, $m)) { |
|
| 36 | + array_push($result, $m [1]); |
|
| 37 | 37 | } |
| 38 | 38 | } |
| 39 | 39 | return $result; |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - private function getStyleList () { |
|
| 43 | - $result = array (); |
|
| 44 | - foreach (glob ("templates/" . getCurrentTemplate () . "/styles/style-*.css") as $filename) { |
|
| 45 | - if (preg_match ('/styles\/style-(.*?)\.css/', $filename, $m)) { |
|
| 46 | - array_push ($result, $m [1]); |
|
| 42 | + private function getStyleList() { |
|
| 43 | + $result = array(); |
|
| 44 | + foreach (glob("templates/" . getCurrentTemplate() . "/styles/style-*.css") as $filename) { |
|
| 45 | + if (preg_match('/styles\/style-(.*?)\.css/', $filename, $m)) { |
|
| 46 | + array_push($result, $m [1]); |
|
| 47 | 47 | } |
| 48 | 48 | } |
| 49 | 49 | return $result; |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - public function InitializeContent () |
|
| 52 | + public function InitializeContent() |
|
| 53 | 53 | { |
| 54 | - $this->title = localize ("customize.title"); |
|
| 55 | - $this->entryArray = array (); |
|
| 54 | + $this->title = localize("customize.title"); |
|
| 55 | + $this->entryArray = array(); |
|
| 56 | 56 | |
| 57 | - $ignoredBaseArray = array (PageQueryResult::SCOPE_AUTHOR, |
|
| 57 | + $ignoredBaseArray = array(PageQueryResult::SCOPE_AUTHOR, |
|
| 58 | 58 | PageQueryResult::SCOPE_TAG, |
| 59 | 59 | PageQueryResult::SCOPE_SERIES, |
| 60 | 60 | PageQueryResult::SCOPE_PUBLISHER, |
@@ -65,60 +65,60 @@ discard block |
||
| 65 | 65 | if (!preg_match("/(Kobo|Kindle\/3.0|EBRD1101)/", $_SERVER['HTTP_USER_AGENT'])) { |
| 66 | 66 | $content .= "<select id='template' onchange='updateCookie (this); window.location=$(\".headleft\").attr(\"href\");'>"; |
| 67 | 67 | |
| 68 | - foreach ($this-> getTemplateList () as $filename) { |
|
| 69 | - $content .= "<option value='{$filename}' " . $this->isSelected ("template", $filename) . ">{$filename}</option>"; |
|
| 68 | + foreach ($this-> getTemplateList() as $filename) { |
|
| 69 | + $content .= "<option value='{$filename}' " . $this->isSelected("template", $filename) . ">{$filename}</option>"; |
|
| 70 | 70 | } |
| 71 | 71 | $content .= '</select>'; |
| 72 | 72 | } else { |
| 73 | - foreach ($this-> getTemplateList () as $filename) { |
|
| 74 | - $content .= "<input type='radio' onchange='updateCookieFromCheckbox (this); window.location=$(\".headleft\").attr(\"href\");' id='template' name='template' value='{$filename}' " . $this->isChecked ("template", $filename) . " /><label for='template-{$filename}'> {$filename} </label>"; |
|
| 73 | + foreach ($this-> getTemplateList() as $filename) { |
|
| 74 | + $content .= "<input type='radio' onchange='updateCookieFromCheckbox (this); window.location=$(\".headleft\").attr(\"href\");' id='template' name='template' value='{$filename}' " . $this->isChecked("template", $filename) . " /><label for='template-{$filename}'> {$filename} </label>"; |
|
| 75 | 75 | } |
| 76 | 76 | } |
| 77 | - array_push ($this->entryArray, new Entry ("Template", "", |
|
| 77 | + array_push($this->entryArray, new Entry("Template", "", |
|
| 78 | 78 | $content, "text", |
| 79 | - array ())); |
|
| 79 | + array())); |
|
| 80 | 80 | |
| 81 | 81 | $content = ""; |
| 82 | 82 | if (!preg_match("/(Kobo|Kindle\/3.0|EBRD1101)/", $_SERVER['HTTP_USER_AGENT'])) { |
| 83 | 83 | $content .= '<select id="style" onchange="updateCookie (this);">'; |
| 84 | - foreach ($this-> getStyleList () as $filename) { |
|
| 85 | - $content .= "<option value='{$filename}' " . $this->isSelected ("style", $filename) . ">{$filename}</option>"; |
|
| 84 | + foreach ($this-> getStyleList() as $filename) { |
|
| 85 | + $content .= "<option value='{$filename}' " . $this->isSelected("style", $filename) . ">{$filename}</option>"; |
|
| 86 | 86 | } |
| 87 | 87 | $content .= '</select>'; |
| 88 | 88 | } else { |
| 89 | - foreach ($this-> getStyleList () as $filename) { |
|
| 90 | - $content .= "<input type='radio' onchange='updateCookieFromCheckbox (this);' id='style-{$filename}' name='style' value='{$filename}' " . $this->isChecked ("style", $filename) . " /><label for='style-{$filename}'> {$filename} </label>"; |
|
| 89 | + foreach ($this-> getStyleList() as $filename) { |
|
| 90 | + $content .= "<input type='radio' onchange='updateCookieFromCheckbox (this);' id='style-{$filename}' name='style' value='{$filename}' " . $this->isChecked("style", $filename) . " /><label for='style-{$filename}'> {$filename} </label>"; |
|
| 91 | 91 | } |
| 92 | 92 | } |
| 93 | - array_push ($this->entryArray, new Entry (localize ("customize.style"), "", |
|
| 93 | + array_push($this->entryArray, new Entry(localize("customize.style"), "", |
|
| 94 | 94 | $content, "text", |
| 95 | - array ())); |
|
| 96 | - if (!useServerSideRendering ()) { |
|
| 97 | - $content = '<input type="checkbox" onchange="updateCookieFromCheckbox (this);" id="use_fancyapps" ' . $this->isChecked ("use_fancyapps") . ' />'; |
|
| 98 | - array_push ($this->entryArray, new Entry (localize ("customize.fancybox"), "", |
|
| 95 | + array())); |
|
| 96 | + if (!useServerSideRendering()) { |
|
| 97 | + $content = '<input type="checkbox" onchange="updateCookieFromCheckbox (this);" id="use_fancyapps" ' . $this->isChecked("use_fancyapps") . ' />'; |
|
| 98 | + array_push($this->entryArray, new Entry(localize("customize.fancybox"), "", |
|
| 99 | 99 | $content, "text", |
| 100 | - array ())); |
|
| 100 | + array())); |
|
| 101 | 101 | } |
| 102 | - $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]+$" />'; |
|
| 103 | - array_push ($this->entryArray, new Entry (localize ("customize.paging"), "", |
|
| 102 | + $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]+$" />'; |
|
| 103 | + array_push($this->entryArray, new Entry(localize("customize.paging"), "", |
|
| 104 | 104 | $content, "text", |
| 105 | - array ())); |
|
| 106 | - $content = '<input type="text" onchange="updateCookie (this);" id="email" value="' . getCurrentOption ("email") . '" />'; |
|
| 107 | - array_push ($this->entryArray, new Entry (localize ("customize.email"), "", |
|
| 105 | + array())); |
|
| 106 | + $content = '<input type="text" onchange="updateCookie (this);" id="email" value="' . getCurrentOption("email") . '" />'; |
|
| 107 | + array_push($this->entryArray, new Entry(localize("customize.email"), "", |
|
| 108 | 108 | $content, "text", |
| 109 | - array ())); |
|
| 110 | - $content = '<input type="checkbox" onchange="updateCookieFromCheckbox (this);" id="html_tag_filter" ' . $this->isChecked ("html_tag_filter") . ' />'; |
|
| 111 | - array_push ($this->entryArray, new Entry (localize ("customize.filter"), "", |
|
| 109 | + array())); |
|
| 110 | + $content = '<input type="checkbox" onchange="updateCookieFromCheckbox (this);" id="html_tag_filter" ' . $this->isChecked("html_tag_filter") . ' />'; |
|
| 111 | + array_push($this->entryArray, new Entry(localize("customize.filter"), "", |
|
| 112 | 112 | $content, "text", |
| 113 | - array ())); |
|
| 113 | + array())); |
|
| 114 | 114 | $content = ""; |
| 115 | 115 | foreach ($ignoredBaseArray as $key) { |
| 116 | - $keyPlural = preg_replace ('/(ss)$/', 's', $key . "s"); |
|
| 117 | - $content .= '<input type="checkbox" name="ignored_categories[]" onchange="updateCookieFromCheckboxGroup (this);" id="ignored_categories_' . $key . '" ' . $this->isChecked ("ignored_categories", $key) . ' > ' . localize ("{$keyPlural}.title") . '</input> '; |
|
| 116 | + $keyPlural = preg_replace('/(ss)$/', 's', $key . "s"); |
|
| 117 | + $content .= '<input type="checkbox" name="ignored_categories[]" onchange="updateCookieFromCheckboxGroup (this);" id="ignored_categories_' . $key . '" ' . $this->isChecked("ignored_categories", $key) . ' > ' . localize("{$keyPlural}.title") . '</input> '; |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - array_push ($this->entryArray, new Entry (localize ("customize.ignored"), "", |
|
| 120 | + array_push($this->entryArray, new Entry(localize("customize.ignored"), "", |
|
| 121 | 121 | $content, "text", |
| 122 | - array ())); |
|
| 122 | + array())); |
|
| 123 | 123 | } |
| 124 | 124 | } |
@@ -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 getTemplateList () { |
|
| 34 | + private function getTemplateList () |
|
| 35 | + { |
|
| 33 | 36 | $result = array (); |
| 34 | 37 | foreach (glob ("templates/*") as $filename) { |
| 35 | 38 | if (preg_match ('/templates\/(.*)/', $filename, $m)) { |
@@ -39,7 +42,8 @@ discard block |
||
| 39 | 42 | return $result; |
| 40 | 43 | } |
| 41 | 44 | |
| 42 | - private function getStyleList () { |
|
| 45 | + private function getStyleList () |
|
| 46 | + { |
|
| 43 | 47 | $result = array (); |
| 44 | 48 | foreach (glob ("templates/" . getCurrentTemplate () . "/styles/style-*.css") as $filename) { |
| 45 | 49 | if (preg_match ('/styles\/style-(.*?)\.css/', $filename, $m)) { |
@@ -17,7 +17,7 @@ |
||
| 17 | 17 | public function __construct($post) |
| 18 | 18 | { |
| 19 | 19 | $this->id = $post->id; |
| 20 | - $this->type = strtolower($post->type);; |
|
| 20 | + $this->type = strtolower($post->type); ; |
|
| 21 | 21 | $this->val = $post->val; |
| 22 | 22 | $this->formatType(); |
| 23 | 23 | } |