@@ -37,14 +37,14 @@ |
||
| 37 | 37 | header('Content-Type:text/html;charset=utf-8'); |
| 38 | 38 | |
| 39 | 39 | $data = array('title' => $config['cops_title_default'], |
| 40 | - 'version' => VERSION, |
|
| 41 | - 'opds_url' => $config['cops_full_url'] . 'feed.php', |
|
| 42 | - 'customHeader' => '', |
|
| 43 | - 'template' => getCurrentTemplate(), |
|
| 44 | - 'server_side_rendering' => useServerSideRendering(), |
|
| 45 | - 'current_css' => getCurrentCss(), |
|
| 46 | - 'favico' => $config['cops_icon'], |
|
| 47 | - 'getjson_url' => 'getJSON.php?' . addURLParameter(getQueryString(), 'complete', 1)); |
|
| 40 | + 'version' => VERSION, |
|
| 41 | + 'opds_url' => $config['cops_full_url'] . 'feed.php', |
|
| 42 | + 'customHeader' => '', |
|
| 43 | + 'template' => getCurrentTemplate(), |
|
| 44 | + 'server_side_rendering' => useServerSideRendering(), |
|
| 45 | + 'current_css' => getCurrentCss(), |
|
| 46 | + 'favico' => $config['cops_icon'], |
|
| 47 | + 'getjson_url' => 'getJSON.php?' . addURLParameter(getQueryString(), 'complete', 1)); |
|
| 48 | 48 | if (preg_match('/Kindle/', $_SERVER['HTTP_USER_AGENT'])) { |
| 49 | 49 | $data['customHeader'] = '<style media="screen" type="text/css"> html { font-size: 75%; -webkit-text-size-adjust: 75%; -ms-text-size-adjust: 75%; }</style>'; |
| 50 | 50 | } |
@@ -26,56 +26,56 @@ discard block |
||
| 26 | 26 | * Transliterated text. |
| 27 | 27 | */ |
| 28 | 28 | function _transliteration_process($string, $unknown = '?', $source_langcode = NULL) { |
| 29 | - // ASCII is always valid NFC! If we're only ever given plain ASCII, we can |
|
| 30 | - // avoid the overhead of initializing the decomposition tables by skipping |
|
| 31 | - // out early. |
|
| 32 | - if (!preg_match('/[\x80-\xff]/', $string)) { |
|
| 29 | + // ASCII is always valid NFC! If we're only ever given plain ASCII, we can |
|
| 30 | + // avoid the overhead of initializing the decomposition tables by skipping |
|
| 31 | + // out early. |
|
| 32 | + if (!preg_match('/[\x80-\xff]/', $string)) { |
|
| 33 | 33 | return $string; |
| 34 | - } |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - static $tail_bytes; |
|
| 36 | + static $tail_bytes; |
|
| 37 | 37 | |
| 38 | - if (!isset($tail_bytes)) { |
|
| 38 | + if (!isset($tail_bytes)) { |
|
| 39 | 39 | // Each UTF-8 head byte is followed by a certain number of tail bytes. |
| 40 | 40 | $tail_bytes = array(); |
| 41 | 41 | for ($n = 0; $n < 256; $n++) { |
| 42 | - if ($n < 0xc0) { |
|
| 42 | + if ($n < 0xc0) { |
|
| 43 | 43 | $remaining = 0; |
| 44 | - } |
|
| 45 | - elseif ($n < 0xe0) { |
|
| 44 | + } |
|
| 45 | + elseif ($n < 0xe0) { |
|
| 46 | 46 | $remaining = 1; |
| 47 | - } |
|
| 48 | - elseif ($n < 0xf0) { |
|
| 47 | + } |
|
| 48 | + elseif ($n < 0xf0) { |
|
| 49 | 49 | $remaining = 2; |
| 50 | - } |
|
| 51 | - elseif ($n < 0xf8) { |
|
| 50 | + } |
|
| 51 | + elseif ($n < 0xf8) { |
|
| 52 | 52 | $remaining = 3; |
| 53 | - } |
|
| 54 | - elseif ($n < 0xfc) { |
|
| 53 | + } |
|
| 54 | + elseif ($n < 0xfc) { |
|
| 55 | 55 | $remaining = 4; |
| 56 | - } |
|
| 57 | - elseif ($n < 0xfe) { |
|
| 56 | + } |
|
| 57 | + elseif ($n < 0xfe) { |
|
| 58 | 58 | $remaining = 5; |
| 59 | - } |
|
| 60 | - else { |
|
| 59 | + } |
|
| 60 | + else { |
|
| 61 | 61 | $remaining = 0; |
| 62 | - } |
|
| 63 | - $tail_bytes[chr($n)] = $remaining; |
|
| 62 | + } |
|
| 63 | + $tail_bytes[chr($n)] = $remaining; |
|
| 64 | + } |
|
| 64 | 65 | } |
| 65 | - } |
|
| 66 | 66 | |
| 67 | - // Chop the text into pure-ASCII and non-ASCII areas; large ASCII parts can |
|
| 68 | - // be handled much more quickly. Don't chop up Unicode areas for punctuation, |
|
| 69 | - // though, that wastes energy. |
|
| 70 | - preg_match_all('/[\x00-\x7f]+|[\x80-\xff][\x00-\x40\x5b-\x5f\x7b-\xff]*/', $string, $matches); |
|
| 67 | + // Chop the text into pure-ASCII and non-ASCII areas; large ASCII parts can |
|
| 68 | + // be handled much more quickly. Don't chop up Unicode areas for punctuation, |
|
| 69 | + // though, that wastes energy. |
|
| 70 | + preg_match_all('/[\x00-\x7f]+|[\x80-\xff][\x00-\x40\x5b-\x5f\x7b-\xff]*/', $string, $matches); |
|
| 71 | 71 | |
| 72 | - $result = ''; |
|
| 73 | - foreach ($matches[0] as $str) { |
|
| 72 | + $result = ''; |
|
| 73 | + foreach ($matches[0] as $str) { |
|
| 74 | 74 | if ($str[0] < "\x80") { |
| 75 | - // ASCII chunk: guaranteed to be valid UTF-8 and in normal form C, so |
|
| 76 | - // skip over it. |
|
| 77 | - $result .= $str; |
|
| 78 | - continue; |
|
| 75 | + // ASCII chunk: guaranteed to be valid UTF-8 and in normal form C, so |
|
| 76 | + // skip over it. |
|
| 77 | + $result .= $str; |
|
| 78 | + continue; |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | // We'll have to examine the chunk byte by byte to ensure that it consists |
@@ -91,72 +91,72 @@ discard block |
||
| 91 | 91 | $len = $chunk + 1; |
| 92 | 92 | |
| 93 | 93 | for ($i = -1; --$len; ) { |
| 94 | - $c = $str[++$i]; |
|
| 95 | - if ($remaining = $tail_bytes[$c]) { |
|
| 94 | + $c = $str[++$i]; |
|
| 95 | + if ($remaining = $tail_bytes[$c]) { |
|
| 96 | 96 | // UTF-8 head byte! |
| 97 | 97 | $sequence = $head = $c; |
| 98 | 98 | do { |
| 99 | - // Look for the defined number of tail bytes... |
|
| 100 | - if (--$len && ($c = $str[++$i]) >= "\x80" && $c < "\xc0") { |
|
| 99 | + // Look for the defined number of tail bytes... |
|
| 100 | + if (--$len && ($c = $str[++$i]) >= "\x80" && $c < "\xc0") { |
|
| 101 | 101 | // Legal tail bytes are nice. |
| 102 | 102 | $sequence .= $c; |
| 103 | - } |
|
| 104 | - else { |
|
| 103 | + } |
|
| 104 | + else { |
|
| 105 | 105 | if ($len == 0) { |
| 106 | - // Premature end of string! Drop a replacement character into |
|
| 107 | - // output to represent the invalid UTF-8 sequence. |
|
| 108 | - $result .= $unknown; |
|
| 109 | - break 2; |
|
| 106 | + // Premature end of string! Drop a replacement character into |
|
| 107 | + // output to represent the invalid UTF-8 sequence. |
|
| 108 | + $result .= $unknown; |
|
| 109 | + break 2; |
|
| 110 | 110 | } |
| 111 | 111 | else { |
| 112 | - // Illegal tail byte; abandon the sequence. |
|
| 113 | - $result .= $unknown; |
|
| 114 | - // Back up and reprocess this byte; it may itself be a legal |
|
| 115 | - // ASCII or UTF-8 sequence head. |
|
| 116 | - --$i; |
|
| 117 | - ++$len; |
|
| 118 | - continue 2; |
|
| 112 | + // Illegal tail byte; abandon the sequence. |
|
| 113 | + $result .= $unknown; |
|
| 114 | + // Back up and reprocess this byte; it may itself be a legal |
|
| 115 | + // ASCII or UTF-8 sequence head. |
|
| 116 | + --$i; |
|
| 117 | + ++$len; |
|
| 118 | + continue 2; |
|
| 119 | + } |
|
| 119 | 120 | } |
| 120 | - } |
|
| 121 | 121 | } while (--$remaining); |
| 122 | 122 | |
| 123 | 123 | $n = ord($head); |
| 124 | 124 | if ($n <= 0xdf) { |
| 125 | - $ord = ($n - 192) * 64 + (ord($sequence[1]) - 128); |
|
| 125 | + $ord = ($n - 192) * 64 + (ord($sequence[1]) - 128); |
|
| 126 | 126 | } |
| 127 | 127 | elseif ($n <= 0xef) { |
| 128 | - $ord = ($n - 224) * 4096 + (ord($sequence[1]) - 128) * 64 + (ord($sequence[2]) - 128); |
|
| 128 | + $ord = ($n - 224) * 4096 + (ord($sequence[1]) - 128) * 64 + (ord($sequence[2]) - 128); |
|
| 129 | 129 | } |
| 130 | 130 | elseif ($n <= 0xf7) { |
| 131 | - $ord = ($n - 240) * 262144 + (ord($sequence[1]) - 128) * 4096 + (ord($sequence[2]) - 128) * 64 + (ord($sequence[3]) - 128); |
|
| 131 | + $ord = ($n - 240) * 262144 + (ord($sequence[1]) - 128) * 4096 + (ord($sequence[2]) - 128) * 64 + (ord($sequence[3]) - 128); |
|
| 132 | 132 | } |
| 133 | 133 | elseif ($n <= 0xfb) { |
| 134 | - $ord = ($n - 248) * 16777216 + (ord($sequence[1]) - 128) * 262144 + (ord($sequence[2]) - 128) * 4096 + (ord($sequence[3]) - 128) * 64 + (ord($sequence[4]) - 128); |
|
| 134 | + $ord = ($n - 248) * 16777216 + (ord($sequence[1]) - 128) * 262144 + (ord($sequence[2]) - 128) * 4096 + (ord($sequence[3]) - 128) * 64 + (ord($sequence[4]) - 128); |
|
| 135 | 135 | } |
| 136 | 136 | elseif ($n <= 0xfd) { |
| 137 | - $ord = ($n - 252) * 1073741824 + (ord($sequence[1]) - 128) * 16777216 + (ord($sequence[2]) - 128) * 262144 + (ord($sequence[3]) - 128) * 4096 + (ord($sequence[4]) - 128) * 64 + (ord($sequence[5]) - 128); |
|
| 137 | + $ord = ($n - 252) * 1073741824 + (ord($sequence[1]) - 128) * 16777216 + (ord($sequence[2]) - 128) * 262144 + (ord($sequence[3]) - 128) * 4096 + (ord($sequence[4]) - 128) * 64 + (ord($sequence[5]) - 128); |
|
| 138 | 138 | } else { |
| 139 | - $ord = $n; |
|
| 139 | + $ord = $n; |
|
| 140 | 140 | } |
| 141 | 141 | $result .= _transliteration_replace($ord, $unknown, $source_langcode); |
| 142 | 142 | $head = ''; |
| 143 | - } elseif ($c < "\x80") { |
|
| 143 | + } elseif ($c < "\x80") { |
|
| 144 | 144 | // ASCII byte. |
| 145 | 145 | $result .= $c; |
| 146 | 146 | $head = ''; |
| 147 | - } elseif ($c < "\xc0") { |
|
| 147 | + } elseif ($c < "\xc0") { |
|
| 148 | 148 | // Illegal tail bytes. |
| 149 | 149 | if ($head == '') { |
| 150 | - $result .= $unknown; |
|
| 150 | + $result .= $unknown; |
|
| 151 | 151 | } |
| 152 | - } else { |
|
| 152 | + } else { |
|
| 153 | 153 | // Miscellaneous freaks. |
| 154 | 154 | $result .= $unknown; |
| 155 | 155 | $head = ''; |
| 156 | - } |
|
| 156 | + } |
|
| 157 | 157 | } |
| 158 | - } |
|
| 159 | - return $result; |
|
| 158 | + } |
|
| 159 | + return $result; |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | /** |
@@ -175,38 +175,38 @@ discard block |
||
| 175 | 175 | * ASCII replacement character. |
| 176 | 176 | */ |
| 177 | 177 | function _transliteration_replace($ord, $unknown = '?', $langcode = NULL) { |
| 178 | - static $map = array(); |
|
| 178 | + static $map = array(); |
|
| 179 | 179 | |
| 180 | - //GL: set language later |
|
| 181 | - /* |
|
| 180 | + //GL: set language later |
|
| 181 | + /* |
|
| 182 | 182 | if (!isset($langcode)) { |
| 183 | 183 | global $language; |
| 184 | 184 | $langcode = $language->language; |
| 185 | 185 | } |
| 186 | 186 | */ |
| 187 | 187 | |
| 188 | - $bank = $ord >> 8; |
|
| 188 | + $bank = $ord >> 8; |
|
| 189 | 189 | |
| 190 | - if (!isset($map[$bank][$langcode])) { |
|
| 190 | + if (!isset($map[$bank][$langcode])) { |
|
| 191 | 191 | $file = './resources/transliteration-data/' . sprintf('x%02x', $bank) . '.php'; |
| 192 | 192 | if (file_exists($file)) { |
| 193 | - $base = array(); |
|
| 194 | - $variant = array(); |
|
| 195 | - include $file; |
|
| 196 | - if ($langcode != 'en' && isset($variant[$langcode])) { |
|
| 193 | + $base = array(); |
|
| 194 | + $variant = array(); |
|
| 195 | + include $file; |
|
| 196 | + if ($langcode != 'en' && isset($variant[$langcode])) { |
|
| 197 | 197 | // Merge in language specific mappings. |
| 198 | 198 | $map[$bank][$langcode] = $variant[$langcode] + $base; |
| 199 | - } |
|
| 200 | - else { |
|
| 199 | + } |
|
| 200 | + else { |
|
| 201 | 201 | $map[$bank][$langcode] = $base; |
| 202 | - } |
|
| 202 | + } |
|
| 203 | 203 | } |
| 204 | 204 | else { |
| 205 | - $map[$bank][$langcode] = array(); |
|
| 205 | + $map[$bank][$langcode] = array(); |
|
| 206 | + } |
|
| 206 | 207 | } |
| 207 | - } |
|
| 208 | 208 | |
| 209 | - $ord = $ord & 255; |
|
| 209 | + $ord = $ord & 255; |
|
| 210 | 210 | |
| 211 | - return isset($map[$bank][$langcode][$ord]) ? $map[$bank][$langcode][$ord] : $unknown; |
|
| 211 | + return isset($map[$bank][$langcode][$ord]) ? $map[$bank][$langcode][$ord] : $unknown; |
|
| 212 | 212 | } |
@@ -25,7 +25,8 @@ discard block |
||
| 25 | 25 | * @return |
| 26 | 26 | * Transliterated text. |
| 27 | 27 | */ |
| 28 | -function _transliteration_process($string, $unknown = '?', $source_langcode = NULL) { |
|
| 28 | +function _transliteration_process($string, $unknown = '?', $source_langcode = NULL) |
|
| 29 | +{ |
|
| 29 | 30 | // ASCII is always valid NFC! If we're only ever given plain ASCII, we can |
| 30 | 31 | // avoid the overhead of initializing the decomposition tables by skipping |
| 31 | 32 | // out early. |
@@ -41,23 +42,17 @@ discard block |
||
| 41 | 42 | for ($n = 0; $n < 256; $n++) { |
| 42 | 43 | if ($n < 0xc0) { |
| 43 | 44 | $remaining = 0; |
| 44 | - } |
|
| 45 | - elseif ($n < 0xe0) { |
|
| 45 | + } elseif ($n < 0xe0) { |
|
| 46 | 46 | $remaining = 1; |
| 47 | - } |
|
| 48 | - elseif ($n < 0xf0) { |
|
| 47 | + } elseif ($n < 0xf0) { |
|
| 49 | 48 | $remaining = 2; |
| 50 | - } |
|
| 51 | - elseif ($n < 0xf8) { |
|
| 49 | + } elseif ($n < 0xf8) { |
|
| 52 | 50 | $remaining = 3; |
| 53 | - } |
|
| 54 | - elseif ($n < 0xfc) { |
|
| 51 | + } elseif ($n < 0xfc) { |
|
| 55 | 52 | $remaining = 4; |
| 56 | - } |
|
| 57 | - elseif ($n < 0xfe) { |
|
| 53 | + } elseif ($n < 0xfe) { |
|
| 58 | 54 | $remaining = 5; |
| 59 | - } |
|
| 60 | - else { |
|
| 55 | + } else { |
|
| 61 | 56 | $remaining = 0; |
| 62 | 57 | } |
| 63 | 58 | $tail_bytes[chr($n)] = $remaining; |
@@ -100,15 +95,13 @@ discard block |
||
| 100 | 95 | if (--$len && ($c = $str[++$i]) >= "\x80" && $c < "\xc0") { |
| 101 | 96 | // Legal tail bytes are nice. |
| 102 | 97 | $sequence .= $c; |
| 103 | - } |
|
| 104 | - else { |
|
| 98 | + } else { |
|
| 105 | 99 | if ($len == 0) { |
| 106 | 100 | // Premature end of string! Drop a replacement character into |
| 107 | 101 | // output to represent the invalid UTF-8 sequence. |
| 108 | 102 | $result .= $unknown; |
| 109 | 103 | break 2; |
| 110 | - } |
|
| 111 | - else { |
|
| 104 | + } else { |
|
| 112 | 105 | // Illegal tail byte; abandon the sequence. |
| 113 | 106 | $result .= $unknown; |
| 114 | 107 | // Back up and reprocess this byte; it may itself be a legal |
@@ -123,17 +116,13 @@ discard block |
||
| 123 | 116 | $n = ord($head); |
| 124 | 117 | if ($n <= 0xdf) { |
| 125 | 118 | $ord = ($n - 192) * 64 + (ord($sequence[1]) - 128); |
| 126 | - } |
|
| 127 | - elseif ($n <= 0xef) { |
|
| 119 | + } elseif ($n <= 0xef) { |
|
| 128 | 120 | $ord = ($n - 224) * 4096 + (ord($sequence[1]) - 128) * 64 + (ord($sequence[2]) - 128); |
| 129 | - } |
|
| 130 | - elseif ($n <= 0xf7) { |
|
| 121 | + } elseif ($n <= 0xf7) { |
|
| 131 | 122 | $ord = ($n - 240) * 262144 + (ord($sequence[1]) - 128) * 4096 + (ord($sequence[2]) - 128) * 64 + (ord($sequence[3]) - 128); |
| 132 | - } |
|
| 133 | - elseif ($n <= 0xfb) { |
|
| 123 | + } elseif ($n <= 0xfb) { |
|
| 134 | 124 | $ord = ($n - 248) * 16777216 + (ord($sequence[1]) - 128) * 262144 + (ord($sequence[2]) - 128) * 4096 + (ord($sequence[3]) - 128) * 64 + (ord($sequence[4]) - 128); |
| 135 | - } |
|
| 136 | - elseif ($n <= 0xfd) { |
|
| 125 | + } elseif ($n <= 0xfd) { |
|
| 137 | 126 | $ord = ($n - 252) * 1073741824 + (ord($sequence[1]) - 128) * 16777216 + (ord($sequence[2]) - 128) * 262144 + (ord($sequence[3]) - 128) * 4096 + (ord($sequence[4]) - 128) * 64 + (ord($sequence[5]) - 128); |
| 138 | 127 | } else { |
| 139 | 128 | $ord = $n; |
@@ -174,7 +163,8 @@ discard block |
||
| 174 | 163 | * @return |
| 175 | 164 | * ASCII replacement character. |
| 176 | 165 | */ |
| 177 | -function _transliteration_replace($ord, $unknown = '?', $langcode = NULL) { |
|
| 166 | +function _transliteration_replace($ord, $unknown = '?', $langcode = NULL) |
|
| 167 | +{ |
|
| 178 | 168 | static $map = array(); |
| 179 | 169 | |
| 180 | 170 | //GL: set language later |
@@ -196,12 +186,10 @@ discard block |
||
| 196 | 186 | if ($langcode != 'en' && isset($variant[$langcode])) { |
| 197 | 187 | // Merge in language specific mappings. |
| 198 | 188 | $map[$bank][$langcode] = $variant[$langcode] + $base; |
| 199 | - } |
|
| 200 | - else { |
|
| 189 | + } else { |
|
| 201 | 190 | $map[$bank][$langcode] = $base; |
| 202 | 191 | } |
| 203 | - } |
|
| 204 | - else { |
|
| 192 | + } else { |
|
| 205 | 193 | $map[$bank][$langcode] = array(); |
| 206 | 194 | } |
| 207 | 195 | } |
@@ -55,7 +55,9 @@ |
||
| 55 | 55 | public function getDescription() |
| 56 | 56 | { |
| 57 | 57 | $desc = $this->getDatabaseDescription(); |
| 58 | - if ($desc === NULL || empty($desc)) $desc = str_format(localize("customcolumn.description"), $this->getTitle()); |
|
| 58 | + if ($desc === NULL || empty($desc)) { |
|
| 59 | + $desc = str_format(localize("customcolumn.description"), $this->getTitle()); |
|
| 60 | + } |
|
| 59 | 61 | return $desc; |
| 60 | 62 | } |
| 61 | 63 | |
@@ -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 | } |
@@ -16,25 +16,30 @@ discard block |
||
| 16 | 16 | public $id; |
| 17 | 17 | public $name; |
| 18 | 18 | |
| 19 | - public function __construct($post) { |
|
| 19 | + public function __construct($post) |
|
| 20 | + { |
|
| 20 | 21 | $this->id = $post->id; |
| 21 | 22 | $this->name = $post->name; |
| 22 | 23 | } |
| 23 | 24 | |
| 24 | - public function getUri () { |
|
| 25 | + public function getUri () |
|
| 26 | + { |
|
| 25 | 27 | return "?page=".parent::PAGE_SERIE_DETAIL."&id=$this->id"; |
| 26 | 28 | } |
| 27 | 29 | |
| 28 | - public function getEntryId () { |
|
| 30 | + public function getEntryId () |
|
| 31 | + { |
|
| 29 | 32 | return self::ALL_SERIES_ID.":".$this->id; |
| 30 | 33 | } |
| 31 | 34 | |
| 32 | - public static function getCount() { |
|
| 35 | + public static function getCount() |
|
| 36 | + { |
|
| 33 | 37 | // str_format (localize("series.alphabetical", count(array)) |
| 34 | 38 | return parent::getCountGeneric ("series", self::ALL_SERIES_ID, parent::PAGE_ALL_SERIES); |
| 35 | 39 | } |
| 36 | 40 | |
| 37 | - public static function getSerieByBookId ($bookId) { |
|
| 41 | + public static function getSerieByBookId ($bookId) |
|
| 42 | + { |
|
| 38 | 43 | $result = parent::getDb ()->prepare('select series.id as id, name |
| 39 | 44 | from books_series_link, series |
| 40 | 45 | where series.id = series and book = ?'); |
@@ -45,7 +50,8 @@ discard block |
||
| 45 | 50 | return NULL; |
| 46 | 51 | } |
| 47 | 52 | |
| 48 | - public static function getSerieById ($serieId) { |
|
| 53 | + public static function getSerieById ($serieId) |
|
| 54 | + { |
|
| 49 | 55 | $result = parent::getDb ()->prepare('select id, name from series where id = ?'); |
| 50 | 56 | $result->execute (array ($serieId)); |
| 51 | 57 | if ($post = $result->fetchObject ()) { |
@@ -54,11 +60,13 @@ discard block |
||
| 54 | 60 | return NULL; |
| 55 | 61 | } |
| 56 | 62 | |
| 57 | - public static function getAllSeries() { |
|
| 63 | + public static function getAllSeries() |
|
| 64 | + { |
|
| 58 | 65 | return Base::getEntryArrayWithBookNumber (self::SQL_ALL_SERIES, self::SERIES_COLUMNS, array (), "Serie"); |
| 59 | 66 | } |
| 60 | 67 | |
| 61 | - public static function getAllSeriesByQuery($query) { |
|
| 68 | + public static function getAllSeriesByQuery($query) |
|
| 69 | + { |
|
| 62 | 70 | return Base::getEntryArrayWithBookNumber (self::SQL_SERIES_FOR_SEARCH, self::SERIES_COLUMNS, array ('%' . $query . '%'), "Serie"); |
| 63 | 71 | } |
| 64 | 72 | } |
@@ -13,20 +13,24 @@ discard block |
||
| 13 | 13 | public $id; |
| 14 | 14 | public $lang_code; |
| 15 | 15 | |
| 16 | - public function __construct($pid, $plang_code) { |
|
| 16 | + public function __construct($pid, $plang_code) |
|
| 17 | + { |
|
| 17 | 18 | $this->id = $pid; |
| 18 | 19 | $this->lang_code = $plang_code; |
| 19 | 20 | } |
| 20 | 21 | |
| 21 | - public function getUri () { |
|
| 22 | + public function getUri () |
|
| 23 | + { |
|
| 22 | 24 | return "?page=".parent::PAGE_LANGUAGE_DETAIL."&id=$this->id"; |
| 23 | 25 | } |
| 24 | 26 | |
| 25 | - public function getEntryId () { |
|
| 27 | + public function getEntryId () |
|
| 28 | + { |
|
| 26 | 29 | return self::ALL_LANGUAGES_ID.":".$this->id; |
| 27 | 30 | } |
| 28 | 31 | |
| 29 | - public static function getLanguageString ($code) { |
|
| 32 | + public static function getLanguageString ($code) |
|
| 33 | + { |
|
| 30 | 34 | $string = localize("languages.".$code); |
| 31 | 35 | if (preg_match ("/^languages/", $string)) { |
| 32 | 36 | return $code; |
@@ -34,12 +38,14 @@ discard block |
||
| 34 | 38 | return $string; |
| 35 | 39 | } |
| 36 | 40 | |
| 37 | - public static function getCount() { |
|
| 41 | + public static function getCount() |
|
| 42 | + { |
|
| 38 | 43 | // str_format (localize("languages.alphabetical", count(array)) |
| 39 | 44 | return parent::getCountGeneric ("languages", self::ALL_LANGUAGES_ID, parent::PAGE_ALL_LANGUAGES); |
| 40 | 45 | } |
| 41 | 46 | |
| 42 | - public static function getLanguageById ($languageId) { |
|
| 47 | + public static function getLanguageById ($languageId) |
|
| 48 | + { |
|
| 43 | 49 | $result = parent::getDb ()->prepare('select id, lang_code from languages where id = ?'); |
| 44 | 50 | $result->execute (array ($languageId)); |
| 45 | 51 | if ($post = $result->fetchObject ()) { |
@@ -50,15 +56,15 @@ discard block |
||
| 50 | 56 | |
| 51 | 57 | |
| 52 | 58 | |
| 53 | - public static function getAllLanguages() { |
|
| 59 | + public static function getAllLanguages() |
|
| 60 | + { |
|
| 54 | 61 | $result = parent::getDb ()->query('select languages.id as id, languages.lang_code as lang_code, count(*) as count |
| 55 | 62 | from languages, books_languages_link |
| 56 | 63 | where languages.id = books_languages_link.lang_code |
| 57 | 64 | group by languages.id, books_languages_link.lang_code |
| 58 | 65 | order by languages.lang_code'); |
| 59 | 66 | $entryArray = array(); |
| 60 | - while ($post = $result->fetchObject ()) |
|
| 61 | - { |
|
| 67 | + while ($post = $result->fetchObject ()) { |
|
| 62 | 68 | $language = new Language ($post->id, $post->lang_code); |
| 63 | 69 | array_push ($entryArray, new Entry (Language::getLanguageString ($language->lang_code), $language->getEntryId (), |
| 64 | 70 | str_format (localize("bookword", $post->count), $post->count), "text", |
@@ -14,12 +14,12 @@ discard block |
||
| 14 | 14 | * @param Book $book |
| 15 | 15 | * @return array |
| 16 | 16 | */ |
| 17 | - public static function getBookContentArray ($book) { |
|
| 17 | + public static function getBookContentArray ($book) |
|
| 18 | + { |
|
| 18 | 19 | global $config; |
| 19 | 20 | $i = 0; |
| 20 | 21 | $preferedData = array (); |
| 21 | - foreach ($config['cops_prefered_format'] as $format) |
|
| 22 | - { |
|
| 22 | + foreach ($config['cops_prefered_format'] as $format) { |
|
| 23 | 23 | if ($i == 2) { break; } |
| 24 | 24 | if ($data = $book->getDataFormat ($format)) { |
| 25 | 25 | $i++; |
@@ -71,7 +71,8 @@ discard block |
||
| 71 | 71 | * @param Book $book |
| 72 | 72 | * @return array |
| 73 | 73 | */ |
| 74 | - public static function getFullBookContentArray ($book) { |
|
| 74 | + public static function getFullBookContentArray ($book) |
|
| 75 | + { |
|
| 75 | 76 | global $config; |
| 76 | 77 | $out = self::getBookContentArray ($book); |
| 77 | 78 | $database = GetUrlParam (DB); |
@@ -106,7 +107,8 @@ discard block |
||
| 106 | 107 | return $out; |
| 107 | 108 | } |
| 108 | 109 | |
| 109 | - public static function getContentArray ($entry) { |
|
| 110 | + public static function getContentArray ($entry) |
|
| 111 | + { |
|
| 110 | 112 | if ($entry instanceof EntryBook) { |
| 111 | 113 | $out = array ( "title" => $entry->title); |
| 112 | 114 | $out ["book"] = self::getBookContentArray ($entry->book); |
@@ -115,7 +117,8 @@ discard block |
||
| 115 | 117 | return array ( "title" => $entry->title, "content" => $entry->content, "navlink" => $entry->getNavLink (), "number" => $entry->numberOfElement ); |
| 116 | 118 | } |
| 117 | 119 | |
| 118 | - public static function getContentArrayTypeahead ($page) { |
|
| 120 | + public static function getContentArrayTypeahead ($page) |
|
| 121 | + { |
|
| 119 | 122 | $out = array (); |
| 120 | 123 | foreach ($page->entryArray as $entry) { |
| 121 | 124 | if ($entry instanceof EntryBook) { |
@@ -131,7 +134,8 @@ discard block |
||
| 131 | 134 | return $out; |
| 132 | 135 | } |
| 133 | 136 | |
| 134 | - public static function addCompleteArray ($in) { |
|
| 137 | + public static function addCompleteArray ($in) |
|
| 138 | + { |
|
| 135 | 139 | global $config; |
| 136 | 140 | $out = $in; |
| 137 | 141 | |
@@ -178,7 +182,8 @@ discard block |
||
| 178 | 182 | return $out; |
| 179 | 183 | } |
| 180 | 184 | |
| 181 | - public static function getJson ($complete = false) { |
|
| 185 | + public static function getJson ($complete = false) |
|
| 186 | + { |
|
| 182 | 187 | global $config; |
| 183 | 188 | $page = getURLParam ("page", Base::PAGE_INDEX); |
| 184 | 189 | $query = getURLParam ("query"); |
@@ -247,7 +252,9 @@ discard block |
||
| 247 | 252 | } |
| 248 | 253 | |
| 249 | 254 | $out ["homeurl"] = "index.php"; |
| 250 | - if ($page != Base::PAGE_INDEX && !is_null ($database)) $out ["homeurl"] = $out ["homeurl"] . "?" . addURLParameter ("", DB, $database); |
|
| 255 | + if ($page != Base::PAGE_INDEX && !is_null ($database)) { |
|
| 256 | + $out ["homeurl"] = $out ["homeurl"] . "?" . addURLParameter ("", DB, $database); |
|
| 257 | + } |
|
| 251 | 258 | |
| 252 | 259 | return $out; |
| 253 | 260 | } |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | if ($data = $book->getDataFormat ($format)) { |
| 25 | 25 | $i++; |
| 26 | 26 | array_push ($preferedData, array ("url" => $data->getHtmlLink (), |
| 27 | - "viewUrl" => $data->getViewHtmlLink (), "name" => $format)); |
|
| 27 | + "viewUrl" => $data->getViewHtmlLink (), "name" => $format)); |
|
| 28 | 28 | } |
| 29 | 29 | } |
| 30 | 30 | |
@@ -52,20 +52,20 @@ discard block |
||
| 52 | 52 | $cc = $book->getCustomColumnValues($config['cops_calibre_custom_column_list'], true); |
| 53 | 53 | |
| 54 | 54 | return array ("id" => $book->id, |
| 55 | - "hasCover" => $book->hasCover, |
|
| 56 | - "preferedData" => $preferedData, |
|
| 57 | - "rating" => $book->getRating (), |
|
| 58 | - "publisherName" => $pn, |
|
| 59 | - "publisherurl" => $pu, |
|
| 60 | - "pubDate" => $book->getPubDate (), |
|
| 61 | - "languagesName" => $book->getLanguages (), |
|
| 62 | - "authorsName" => $book->getAuthorsName (), |
|
| 63 | - "tagsName" => $book->getTagsName (), |
|
| 64 | - "seriesName" => $sn, |
|
| 65 | - "seriesIndex" => $book->seriesIndex, |
|
| 66 | - "seriesCompleteName" => $scn, |
|
| 67 | - "seriesurl" => $su, |
|
| 68 | - "customcolumns_list" => $cc); |
|
| 55 | + "hasCover" => $book->hasCover, |
|
| 56 | + "preferedData" => $preferedData, |
|
| 57 | + "rating" => $book->getRating (), |
|
| 58 | + "publisherName" => $pn, |
|
| 59 | + "publisherurl" => $pu, |
|
| 60 | + "pubDate" => $book->getPubDate (), |
|
| 61 | + "languagesName" => $book->getLanguages (), |
|
| 62 | + "authorsName" => $book->getAuthorsName (), |
|
| 63 | + "tagsName" => $book->getTagsName (), |
|
| 64 | + "seriesName" => $sn, |
|
| 65 | + "seriesIndex" => $book->seriesIndex, |
|
| 66 | + "seriesCompleteName" => $scn, |
|
| 67 | + "seriesurl" => $su, |
|
| 68 | + "customcolumns_list" => $cc); |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | /** |
@@ -142,45 +142,45 @@ discard block |
||
| 142 | 142 | $out = $in; |
| 143 | 143 | |
| 144 | 144 | $out ["c"] = array ("version" => VERSION, "i18n" => array ( |
| 145 | - "coverAlt" => localize("i18n.coversection"), |
|
| 146 | - "authorsTitle" => localize("authors.title"), |
|
| 147 | - "bookwordTitle" => localize("bookword.title"), |
|
| 148 | - "tagsTitle" => localize("tags.title"), |
|
| 149 | - "seriesTitle" => localize("series.title"), |
|
| 150 | - "customizeTitle" => localize ("customize.title"), |
|
| 151 | - "aboutTitle" => localize ("about.title"), |
|
| 152 | - "previousAlt" => localize ("paging.previous.alternate"), |
|
| 153 | - "nextAlt" => localize ("paging.next.alternate"), |
|
| 154 | - "searchAlt" => localize ("search.alternate"), |
|
| 155 | - "sortAlt" => localize ("sort.alternate"), |
|
| 156 | - "homeAlt" => localize ("home.alternate"), |
|
| 157 | - "cogAlt" => localize ("cog.alternate"), |
|
| 158 | - "permalinkAlt" => localize ("permalink.alternate"), |
|
| 159 | - "publisherName" => localize("publisher.name"), |
|
| 160 | - "pubdateTitle" => localize("pubdate.title"), |
|
| 161 | - "languagesTitle" => localize("language.title"), |
|
| 162 | - "contentTitle" => localize("content.summary"), |
|
| 163 | - "filterClearAll" => localize("filter.clearall"), |
|
| 164 | - "sortorderAsc" => localize("search.sortorder.asc"), |
|
| 165 | - "sortorderDesc" => localize("search.sortorder.desc"), |
|
| 166 | - "customizeEmail" => localize("customize.email")), |
|
| 167 | - "url" => array ( |
|
| 168 | - "detailUrl" => "index.php?page=13&id={0}&db={1}", |
|
| 169 | - "coverUrl" => "fetch.php?id={0}&db={1}", |
|
| 170 | - "thumbnailUrl" => "fetch.php?height=" . $config['cops_html_thumbnail_height'] . "&id={0}&db={1}"), |
|
| 171 | - "config" => array ( |
|
| 172 | - "use_fancyapps" => $config ["cops_use_fancyapps"], |
|
| 173 | - "max_item_per_page" => $config['cops_max_item_per_page'], |
|
| 174 | - "kindleHack" => "", |
|
| 175 | - "server_side_rendering" => useServerSideRendering (), |
|
| 176 | - "html_tag_filter" => $config['cops_html_tag_filter'])); |
|
| 145 | + "coverAlt" => localize("i18n.coversection"), |
|
| 146 | + "authorsTitle" => localize("authors.title"), |
|
| 147 | + "bookwordTitle" => localize("bookword.title"), |
|
| 148 | + "tagsTitle" => localize("tags.title"), |
|
| 149 | + "seriesTitle" => localize("series.title"), |
|
| 150 | + "customizeTitle" => localize ("customize.title"), |
|
| 151 | + "aboutTitle" => localize ("about.title"), |
|
| 152 | + "previousAlt" => localize ("paging.previous.alternate"), |
|
| 153 | + "nextAlt" => localize ("paging.next.alternate"), |
|
| 154 | + "searchAlt" => localize ("search.alternate"), |
|
| 155 | + "sortAlt" => localize ("sort.alternate"), |
|
| 156 | + "homeAlt" => localize ("home.alternate"), |
|
| 157 | + "cogAlt" => localize ("cog.alternate"), |
|
| 158 | + "permalinkAlt" => localize ("permalink.alternate"), |
|
| 159 | + "publisherName" => localize("publisher.name"), |
|
| 160 | + "pubdateTitle" => localize("pubdate.title"), |
|
| 161 | + "languagesTitle" => localize("language.title"), |
|
| 162 | + "contentTitle" => localize("content.summary"), |
|
| 163 | + "filterClearAll" => localize("filter.clearall"), |
|
| 164 | + "sortorderAsc" => localize("search.sortorder.asc"), |
|
| 165 | + "sortorderDesc" => localize("search.sortorder.desc"), |
|
| 166 | + "customizeEmail" => localize("customize.email")), |
|
| 167 | + "url" => array ( |
|
| 168 | + "detailUrl" => "index.php?page=13&id={0}&db={1}", |
|
| 169 | + "coverUrl" => "fetch.php?id={0}&db={1}", |
|
| 170 | + "thumbnailUrl" => "fetch.php?height=" . $config['cops_html_thumbnail_height'] . "&id={0}&db={1}"), |
|
| 171 | + "config" => array ( |
|
| 172 | + "use_fancyapps" => $config ["cops_use_fancyapps"], |
|
| 173 | + "max_item_per_page" => $config['cops_max_item_per_page'], |
|
| 174 | + "kindleHack" => "", |
|
| 175 | + "server_side_rendering" => useServerSideRendering (), |
|
| 176 | + "html_tag_filter" => $config['cops_html_tag_filter'])); |
|
| 177 | 177 | if ($config['cops_thumbnail_handling'] == "1") { |
| 178 | 178 | $out ["c"]["url"]["thumbnailUrl"] = $out ["c"]["url"]["coverUrl"]; |
| 179 | 179 | } else if (!empty ($config['cops_thumbnail_handling'])) { |
| 180 | 180 | $out ["c"]["url"]["thumbnailUrl"] = $config['cops_thumbnail_handling']; |
| 181 | 181 | } |
| 182 | 182 | if (preg_match("/./", $_SERVER['HTTP_USER_AGENT'])) { |
| 183 | - $out ["c"]["config"]["kindleHack"] = 'style="text-decoration: none !important;"'; |
|
| 183 | + $out ["c"]["config"]["kindleHack"] = 'style="text-decoration: none !important;"'; |
|
| 184 | 184 | } |
| 185 | 185 | return $out; |
| 186 | 186 | } |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | } |
| 240 | 240 | if (!is_null (getURLParam ("complete")) || $complete) { |
| 241 | 241 | $out = self::addCompleteArray ($out); |
| 242 | - } |
|
| 242 | + } |
|
| 243 | 243 | |
| 244 | 244 | $out ["containsBook"] = 0; |
| 245 | 245 | if ($currentPage->containsBook ()) { |
@@ -13,8 +13,7 @@ |
||
| 13 | 13 | $this->title = localize ("allbooks.title"); |
| 14 | 14 | if (getCurrentOption ("titles_split_first_letter") == 1) { |
| 15 | 15 | $this->entryArray = Book::getAllBooks(); |
| 16 | - } |
|
| 17 | - else { |
|
| 16 | + } else { |
|
| 18 | 17 | list ($this->entryArray, $this->totalNumber) = Book::getBooks ($this->n); |
| 19 | 18 | } |
| 20 | 19 | $this->idPage = Book::ALL_BOOKS_ID; |
@@ -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 = ?'); |