@@ -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"); |
@@ -2,11 +2,11 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | require_once ("config.php"); |
| 4 | 4 | |
| 5 | -function checkConfiguration () { |
|
| 5 | +function checkConfiguration() { |
|
| 6 | 6 | global $config; |
| 7 | 7 | |
| 8 | - if (is_null ($config['cops_mail_configuration']) || |
|
| 9 | - !is_array ($config['cops_mail_configuration']) || |
|
| 8 | + if (is_null($config['cops_mail_configuration']) || |
|
| 9 | + !is_array($config['cops_mail_configuration']) || |
|
| 10 | 10 | empty ($config['cops_mail_configuration']["smtp.host"]) || |
| 11 | 11 | empty ($config['cops_mail_configuration']["address.from"])) { |
| 12 | 12 | return "NOK. bad configuration."; |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | return False; |
| 15 | 15 | } |
| 16 | 16 | |
| 17 | -function checkRequest ($idData, $emailDest) { |
|
| 17 | +function checkRequest($idData, $emailDest) { |
|
| 18 | 18 | if (empty ($idData)) { |
| 19 | 19 | return 'No data sent.'; |
| 20 | 20 | } |
@@ -28,22 +28,22 @@ discard block |
||
| 28 | 28 | |
| 29 | 29 | global $config; |
| 30 | 30 | |
| 31 | -if ($error = checkConfiguration ()) { |
|
| 31 | +if ($error = checkConfiguration()) { |
|
| 32 | 32 | echo $error; |
| 33 | 33 | exit; |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | $idData = $_REQUEST["data"]; |
| 37 | 37 | $emailDest = $_REQUEST["email"]; |
| 38 | -if ($error = checkRequest ($idData, $emailDest)) { |
|
| 38 | +if ($error = checkRequest($idData, $emailDest)) { |
|
| 39 | 39 | echo $error; |
| 40 | 40 | exit; |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | $book = Book::getBookByDataId($idData); |
| 44 | -$data = $book->getDataById ($idData); |
|
| 44 | +$data = $book->getDataById($idData); |
|
| 45 | 45 | |
| 46 | -if (filesize ($data->getLocalPath ()) > 10 * 1024 * 1024) { |
|
| 46 | +if (filesize($data->getLocalPath()) > 10 * 1024 * 1024) { |
|
| 47 | 47 | echo 'Attachment too big'; |
| 48 | 48 | exit; |
| 49 | 49 | } |
@@ -65,23 +65,23 @@ discard block |
||
| 65 | 65 | $mail->From = $config['cops_mail_configuration']["address.from"]; |
| 66 | 66 | $mail->FromName = $config['cops_title_default']; |
| 67 | 67 | |
| 68 | -foreach (explode (";", $emailDest) as $emailAddress) { |
|
| 68 | +foreach (explode(";", $emailDest) as $emailAddress) { |
|
| 69 | 69 | if (empty ($emailAddress)) { continue; } |
| 70 | 70 | $mail->AddAddress($emailAddress); |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | -$mail->AddAttachment($data->getLocalPath ()); |
|
| 73 | +$mail->AddAttachment($data->getLocalPath()); |
|
| 74 | 74 | |
| 75 | 75 | $mail->IsHTML(true); |
| 76 | -$mail->Subject = 'Sent by COPS : ' . $data->getUpdatedFilename (); |
|
| 77 | -$mail->Body = "<h1>" . $book->title . "</h1><h2>" . $book->getAuthorsName () . "</h2>" . $book->getComment (); |
|
| 76 | +$mail->Subject = 'Sent by COPS : ' . $data->getUpdatedFilename(); |
|
| 77 | +$mail->Body = "<h1>" . $book->title . "</h1><h2>" . $book->getAuthorsName() . "</h2>" . $book->getComment(); |
|
| 78 | 78 | $mail->AltBody = "Sent by COPS"; |
| 79 | 79 | |
| 80 | 80 | if (!$mail->Send()) { |
| 81 | - echo localize ("mail.messagenotsent"); |
|
| 81 | + echo localize("mail.messagenotsent"); |
|
| 82 | 82 | echo 'Mailer Error: ' . $mail->ErrorInfo; |
| 83 | 83 | exit; |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | -echo localize ("mail.messagesent"); |
|
| 86 | +echo localize("mail.messagesent"); |
|
| 87 | 87 | |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | // Counting down is faster. I'm *so* sorry. |
| 91 | 91 | $len = $chunk + 1; |
| 92 | 92 | |
| 93 | - for ($i = -1; --$len; ) { |
|
| 93 | + for ($i = -1; --$len;) { |
|
| 94 | 94 | $c = $str[++$i]; |
| 95 | 95 | if ($remaining = $tail_bytes[$c]) { |
| 96 | 96 | // UTF-8 head byte! |
@@ -207,5 +207,5 @@ discard block |
||
| 207 | 207 | |
| 208 | 208 | $ord = $ord & 255; |
| 209 | 209 | |
| 210 | - return isset($map[$bank][$langcode][$ord]) ? $map[$bank][$langcode][$ord] : $unknown; |
|
| 210 | + return isset($map[$bank][$langcode][$ord])?$map[$bank][$langcode][$ord]:$unknown; |
|
| 211 | 211 | } |
@@ -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 | } |
@@ -17,17 +17,17 @@ discard block |
||
| 17 | 17 | $this->lang_code = $plang_code; |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | - public function getUri () { |
|
| 21 | - return "?page=".parent::PAGE_LANGUAGE_DETAIL."&id=$this->id"; |
|
| 20 | + public function getUri() { |
|
| 21 | + return "?page=" . parent::PAGE_LANGUAGE_DETAIL . "&id=$this->id"; |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | - public function getEntryId () { |
|
| 25 | - return self::ALL_LANGUAGES_ID.":".$this->id; |
|
| 24 | + public function getEntryId() { |
|
| 25 | + return self::ALL_LANGUAGES_ID . ":" . $this->id; |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | - public static function getLanguageString ($code) { |
|
| 29 | - $string = localize("languages.".$code); |
|
| 30 | - if (preg_match ("/^languages/", $string)) { |
|
| 28 | + public static function getLanguageString($code) { |
|
| 29 | + $string = localize("languages." . $code); |
|
| 30 | + if (preg_match("/^languages/", $string)) { |
|
| 31 | 31 | return $code; |
| 32 | 32 | } |
| 33 | 33 | return $string; |
@@ -35,14 +35,14 @@ discard block |
||
| 35 | 35 | |
| 36 | 36 | public static function getCount() { |
| 37 | 37 | // str_format (localize("languages.alphabetical", count(array)) |
| 38 | - return parent::getCountGeneric ("languages", self::ALL_LANGUAGES_ID, parent::PAGE_ALL_LANGUAGES); |
|
| 38 | + return parent::getCountGeneric("languages", self::ALL_LANGUAGES_ID, parent::PAGE_ALL_LANGUAGES); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - public static function getLanguageById ($languageId) { |
|
| 42 | - $result = parent::getDb ()->prepare('select id, lang_code from languages where id = ?'); |
|
| 43 | - $result->execute (array ($languageId)); |
|
| 44 | - if ($post = $result->fetchObject ()) { |
|
| 45 | - return new Language ($post->id, Language::getLanguageString ($post->lang_code)); |
|
| 41 | + public static function getLanguageById($languageId) { |
|
| 42 | + $result = parent::getDb()->prepare('select id, lang_code from languages where id = ?'); |
|
| 43 | + $result->execute(array($languageId)); |
|
| 44 | + if ($post = $result->fetchObject()) { |
|
| 45 | + return new Language($post->id, Language::getLanguageString($post->lang_code)); |
|
| 46 | 46 | } |
| 47 | 47 | return NULL; |
| 48 | 48 | } |
@@ -50,18 +50,18 @@ discard block |
||
| 50 | 50 | |
| 51 | 51 | |
| 52 | 52 | public static function getAllLanguages() { |
| 53 | - $result = parent::getDb ()->query('select languages.id as id, languages.lang_code as lang_code, count(*) as count |
|
| 53 | + $result = parent::getDb()->query('select languages.id as id, languages.lang_code as lang_code, count(*) as count |
|
| 54 | 54 | from languages, books_languages_link |
| 55 | 55 | where languages.id = books_languages_link.lang_code |
| 56 | 56 | group by languages.id, books_languages_link.lang_code |
| 57 | 57 | order by languages.lang_code'); |
| 58 | 58 | $entryArray = array(); |
| 59 | - while ($post = $result->fetchObject ()) |
|
| 59 | + while ($post = $result->fetchObject()) |
|
| 60 | 60 | { |
| 61 | - $language = new Language ($post->id, $post->lang_code); |
|
| 62 | - array_push ($entryArray, new Entry (Language::getLanguageString ($language->lang_code), $language->getEntryId (), |
|
| 63 | - str_format (localize("bookword", $post->count), $post->count), "text", |
|
| 64 | - array ( new LinkNavigation ($language->getUri ())), "", $post->count)); |
|
| 61 | + $language = new Language($post->id, $post->lang_code); |
|
| 62 | + array_push($entryArray, new Entry(Language::getLanguageString($language->lang_code), $language->getEntryId(), |
|
| 63 | + str_format(localize("bookword", $post->count), $post->count), "text", |
|
| 64 | + array(new LinkNavigation($language->getUri())), "", $post->count)); |
|
| 65 | 65 | } |
| 66 | 66 | return $entryArray; |
| 67 | 67 | } |
@@ -15,16 +15,16 @@ discard block |
||
| 15 | 15 | const SCOPE_BOOK = "book"; |
| 16 | 16 | const SCOPE_PUBLISHER = "publisher"; |
| 17 | 17 | |
| 18 | - private function useTypeahead () { |
|
| 19 | - return !is_null (getURLParam ("search")); |
|
| 18 | + private function useTypeahead() { |
|
| 19 | + return !is_null(getURLParam("search")); |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | - private function searchByScope ($scope, $limit = FALSE) { |
|
| 22 | + private function searchByScope($scope, $limit = FALSE) { |
|
| 23 | 23 | $n = $this->n; |
| 24 | 24 | $numberPerPage = NULL; |
| 25 | 25 | $queryNormedAndUp = $this->query; |
| 26 | - if (useNormAndUp ()) { |
|
| 27 | - $queryNormedAndUp = normAndUp ($this->query); |
|
| 26 | + if (useNormAndUp()) { |
|
| 27 | + $queryNormedAndUp = normAndUp($this->query); |
|
| 28 | 28 | } |
| 29 | 29 | if ($limit) { |
| 30 | 30 | $n = 1; |
@@ -32,59 +32,59 @@ discard block |
||
| 32 | 32 | } |
| 33 | 33 | switch ($scope) { |
| 34 | 34 | case self::SCOPE_BOOK : |
| 35 | - $array = Book::getBooksByStartingLetter ('%' . $queryNormedAndUp, $n, NULL, $numberPerPage); |
|
| 35 | + $array = Book::getBooksByStartingLetter('%' . $queryNormedAndUp, $n, NULL, $numberPerPage); |
|
| 36 | 36 | break; |
| 37 | 37 | case self::SCOPE_AUTHOR : |
| 38 | - $array = Author::getAuthorsForSearch ('%' . $queryNormedAndUp); |
|
| 38 | + $array = Author::getAuthorsForSearch('%' . $queryNormedAndUp); |
|
| 39 | 39 | break; |
| 40 | 40 | case self::SCOPE_SERIES : |
| 41 | - $array = Serie::getAllSeriesByQuery ($queryNormedAndUp); |
|
| 41 | + $array = Serie::getAllSeriesByQuery($queryNormedAndUp); |
|
| 42 | 42 | break; |
| 43 | 43 | case self::SCOPE_TAG : |
| 44 | - $array = Tag::getAllTagsByQuery ($queryNormedAndUp, $n, NULL, $numberPerPage); |
|
| 44 | + $array = Tag::getAllTagsByQuery($queryNormedAndUp, $n, NULL, $numberPerPage); |
|
| 45 | 45 | break; |
| 46 | 46 | case self::SCOPE_PUBLISHER : |
| 47 | - $array = Publisher::getAllPublishersByQuery ($queryNormedAndUp); |
|
| 47 | + $array = Publisher::getAllPublishersByQuery($queryNormedAndUp); |
|
| 48 | 48 | break; |
| 49 | 49 | default: |
| 50 | - $array = Book::getBooksByQuery ( |
|
| 51 | - array ("all" => "%" . $queryNormedAndUp . "%"), $n); |
|
| 50 | + $array = Book::getBooksByQuery( |
|
| 51 | + array("all" => "%" . $queryNormedAndUp . "%"), $n); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | return $array; |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - public function doSearchByCategory () { |
|
| 58 | - $database = GetUrlParam (DB); |
|
| 59 | - $out = array (); |
|
| 57 | + public function doSearchByCategory() { |
|
| 58 | + $database = GetUrlParam(DB); |
|
| 59 | + $out = array(); |
|
| 60 | 60 | $pagequery = Base::PAGE_OPENSEARCH_QUERY; |
| 61 | - $dbArray = array (""); |
|
| 61 | + $dbArray = array(""); |
|
| 62 | 62 | $d = $database; |
| 63 | 63 | $query = $this->query; |
| 64 | 64 | // Special case when no databases were chosen, we search on all databases |
| 65 | - if (Base::noDatabaseSelected ()) { |
|
| 66 | - $dbArray = Base::getDbNameList (); |
|
| 65 | + if (Base::noDatabaseSelected()) { |
|
| 66 | + $dbArray = Base::getDbNameList(); |
|
| 67 | 67 | $d = 0; |
| 68 | 68 | } |
| 69 | 69 | foreach ($dbArray as $key) { |
| 70 | - if (Base::noDatabaseSelected ()) { |
|
| 71 | - array_push ($this->entryArray, new Entry ($key, DB . ":query:{$d}", |
|
| 70 | + if (Base::noDatabaseSelected()) { |
|
| 71 | + array_push($this->entryArray, new Entry($key, DB . ":query:{$d}", |
|
| 72 | 72 | " ", "text", |
| 73 | - array ( new LinkNavigation ("?" . DB . "={$d}")), "tt-header")); |
|
| 74 | - Base::getDb ($d); |
|
| 73 | + array(new LinkNavigation("?" . DB . "={$d}")), "tt-header")); |
|
| 74 | + Base::getDb($d); |
|
| 75 | 75 | } |
| 76 | - foreach (array (PageQueryResult::SCOPE_BOOK, |
|
| 76 | + foreach (array(PageQueryResult::SCOPE_BOOK, |
|
| 77 | 77 | PageQueryResult::SCOPE_AUTHOR, |
| 78 | 78 | PageQueryResult::SCOPE_SERIES, |
| 79 | 79 | PageQueryResult::SCOPE_TAG, |
| 80 | 80 | PageQueryResult::SCOPE_PUBLISHER) as $key) { |
| 81 | - if (in_array($key, getCurrentOption ('ignored_categories'))) { |
|
| 81 | + if (in_array($key, getCurrentOption('ignored_categories'))) { |
|
| 82 | 82 | continue; |
| 83 | 83 | } |
| 84 | - $array = $this->searchByScope ($key, TRUE); |
|
| 84 | + $array = $this->searchByScope($key, TRUE); |
|
| 85 | 85 | |
| 86 | 86 | $i = 0; |
| 87 | - if (count ($array) == 2 && is_array ($array [0])) { |
|
| 87 | + if (count($array) == 2 && is_array($array [0])) { |
|
| 88 | 88 | $total = $array [1]; |
| 89 | 89 | $array = $array [0]; |
| 90 | 90 | } else { |
@@ -97,32 +97,32 @@ discard block |
||
| 97 | 97 | // str_format (localize("seriesword", count($array)) |
| 98 | 98 | // str_format (localize("tagword", count($array)) |
| 99 | 99 | // str_format (localize("publisherword", count($array)) |
| 100 | - array_push ($this->entryArray, new Entry (str_format (localize ("search.result.{$key}"), $this->query), DB . ":query:{$d}:{$key}", |
|
| 101 | - str_format (localize("{$key}word", $total), $total), "text", |
|
| 102 | - array ( new LinkNavigation ("?page={$pagequery}&query={$query}&db={$d}&scope={$key}")), |
|
| 103 | - Base::noDatabaseSelected () ? "" : "tt-header", $total)); |
|
| 100 | + array_push($this->entryArray, new Entry(str_format(localize("search.result.{$key}"), $this->query), DB . ":query:{$d}:{$key}", |
|
| 101 | + str_format(localize("{$key}word", $total), $total), "text", |
|
| 102 | + array(new LinkNavigation("?page={$pagequery}&query={$query}&db={$d}&scope={$key}")), |
|
| 103 | + Base::noDatabaseSelected()?"":"tt-header", $total)); |
|
| 104 | 104 | } |
| 105 | - if (!Base::noDatabaseSelected () && $this->useTypeahead ()) { |
|
| 105 | + if (!Base::noDatabaseSelected() && $this->useTypeahead()) { |
|
| 106 | 106 | foreach ($array as $entry) { |
| 107 | - array_push ($this->entryArray, $entry); |
|
| 107 | + array_push($this->entryArray, $entry); |
|
| 108 | 108 | $i++; |
| 109 | 109 | if ($i > 4) { break; }; |
| 110 | 110 | } |
| 111 | 111 | } |
| 112 | 112 | } |
| 113 | 113 | $d++; |
| 114 | - if (Base::noDatabaseSelected ()) { |
|
| 115 | - Base::clearDb (); |
|
| 114 | + if (Base::noDatabaseSelected()) { |
|
| 115 | + Base::clearDb(); |
|
| 116 | 116 | } |
| 117 | 117 | } |
| 118 | 118 | return $out; |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | - public function InitializeContent () |
|
| 121 | + public function InitializeContent() |
|
| 122 | 122 | { |
| 123 | - $scope = getURLParam ("scope"); |
|
| 123 | + $scope = getURLParam("scope"); |
|
| 124 | 124 | if (empty ($scope)) { |
| 125 | - $this->title = str_format (localize ("search.result"), $this->query); |
|
| 125 | + $this->title = str_format(localize("search.result"), $this->query); |
|
| 126 | 126 | } else { |
| 127 | 127 | // Comment to help the perl i18n script |
| 128 | 128 | // str_format (localize ("search.result.author"), $this->query) |
@@ -130,31 +130,31 @@ discard block |
||
| 130 | 130 | // str_format (localize ("search.result.series"), $this->query) |
| 131 | 131 | // str_format (localize ("search.result.book"), $this->query) |
| 132 | 132 | // str_format (localize ("search.result.publisher"), $this->query) |
| 133 | - $this->title = str_format (localize ("search.result.{$scope}"), $this->query); |
|
| 133 | + $this->title = str_format(localize("search.result.{$scope}"), $this->query); |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | $crit = "%" . $this->query . "%"; |
| 137 | 137 | |
| 138 | 138 | // Special case when we are doing a search and no database is selected |
| 139 | - if (Base::noDatabaseSelected () && !$this->useTypeahead ()) { |
|
| 139 | + if (Base::noDatabaseSelected() && !$this->useTypeahead()) { |
|
| 140 | 140 | $i = 0; |
| 141 | - foreach (Base::getDbNameList () as $key) { |
|
| 142 | - Base::clearDb (); |
|
| 143 | - list ($array, $totalNumber) = Book::getBooksByQuery (array ("all" => $crit), 1, $i, 1); |
|
| 144 | - array_push ($this->entryArray, new Entry ($key, DB . ":query:{$i}", |
|
| 145 | - str_format (localize ("bookword", $totalNumber), $totalNumber), "text", |
|
| 146 | - array ( new LinkNavigation ("?" . DB . "={$i}&page=9&query=" . $this->query)), "", $totalNumber)); |
|
| 141 | + foreach (Base::getDbNameList() as $key) { |
|
| 142 | + Base::clearDb(); |
|
| 143 | + list ($array, $totalNumber) = Book::getBooksByQuery(array("all" => $crit), 1, $i, 1); |
|
| 144 | + array_push($this->entryArray, new Entry($key, DB . ":query:{$i}", |
|
| 145 | + str_format(localize("bookword", $totalNumber), $totalNumber), "text", |
|
| 146 | + array(new LinkNavigation("?" . DB . "={$i}&page=9&query=" . $this->query)), "", $totalNumber)); |
|
| 147 | 147 | $i++; |
| 148 | 148 | } |
| 149 | 149 | return; |
| 150 | 150 | } |
| 151 | 151 | if (empty ($scope)) { |
| 152 | - $this->doSearchByCategory (); |
|
| 152 | + $this->doSearchByCategory(); |
|
| 153 | 153 | return; |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | - $array = $this->searchByScope ($scope); |
|
| 157 | - if (count ($array) == 2 && is_array ($array [0])) { |
|
| 156 | + $array = $this->searchByScope($scope); |
|
| 157 | + if (count($array) == 2 && is_array($array [0])) { |
|
| 158 | 158 | list ($this->entryArray, $this->totalNumber) = $array; |
| 159 | 159 | } else { |
| 160 | 160 | $this->entryArray = $array; |
@@ -8,9 +8,9 @@ |
||
| 8 | 8 | |
| 9 | 9 | class PageBookDetail extends Page |
| 10 | 10 | { |
| 11 | - public function InitializeContent () |
|
| 11 | + public function InitializeContent() |
|
| 12 | 12 | { |
| 13 | - $this->book = Book::getBookById ($this->idGet); |
|
| 13 | + $this->book = Book::getBookById($this->idGet); |
|
| 14 | 14 | $this->title = $this->book->title; |
| 15 | 15 | } |
| 16 | 16 | } |
@@ -8,15 +8,15 @@ |
||
| 8 | 8 | |
| 9 | 9 | class PageAllBooksLetter extends Page |
| 10 | 10 | { |
| 11 | - public function InitializeContent () |
|
| 11 | + public function InitializeContent() |
|
| 12 | 12 | { |
| 13 | - list ($this->entryArray, $this->totalNumber) = Book::getBooksByStartingLetter ($this->idGet, $this->n); |
|
| 14 | - $this->idPage = Book::getEntryIdByLetter ($this->idGet); |
|
| 13 | + list ($this->entryArray, $this->totalNumber) = Book::getBooksByStartingLetter($this->idGet, $this->n); |
|
| 14 | + $this->idPage = Book::getEntryIdByLetter($this->idGet); |
|
| 15 | 15 | |
| 16 | 16 | $count = $this->totalNumber; |
| 17 | 17 | if ($count == -1) |
| 18 | - $count = count ($this->entryArray); |
|
| 18 | + $count = count($this->entryArray); |
|
| 19 | 19 | |
| 20 | - $this->title = str_format (localize ("splitByLetter.letter"), str_format (localize ("bookword", $count), $count), $this->idGet); |
|
| 20 | + $this->title = str_format(localize("splitByLetter.letter"), str_format(localize("bookword", $count), $count), $this->idGet); |
|
| 21 | 21 | } |
| 22 | 22 | } |
@@ -8,11 +8,11 @@ |
||
| 8 | 8 | |
| 9 | 9 | class PageLanguageDetail extends Page |
| 10 | 10 | { |
| 11 | - public function InitializeContent () |
|
| 11 | + public function InitializeContent() |
|
| 12 | 12 | { |
| 13 | - $language = Language::getLanguageById ($this->idGet); |
|
| 14 | - $this->idPage = $language->getEntryId (); |
|
| 13 | + $language = Language::getLanguageById($this->idGet); |
|
| 14 | + $this->idPage = $language->getEntryId(); |
|
| 15 | 15 | $this->title = $language->lang_code; |
| 16 | - list ($this->entryArray, $this->totalNumber) = Book::getBooksByLanguage ($this->idGet, $this->n); |
|
| 16 | + list ($this->entryArray, $this->totalNumber) = Book::getBooksByLanguage($this->idGet, $this->n); |
|
| 17 | 17 | } |
| 18 | 18 | } |
@@ -8,10 +8,10 @@ |
||
| 8 | 8 | |
| 9 | 9 | class PageAllAuthorsLetter extends Page |
| 10 | 10 | { |
| 11 | - public function InitializeContent () |
|
| 11 | + public function InitializeContent() |
|
| 12 | 12 | { |
| 13 | - $this->idPage = Author::getEntryIdByLetter ($this->idGet); |
|
| 14 | - $this->entryArray = Author::getAuthorsByStartingLetter ($this->idGet); |
|
| 15 | - $this->title = str_format (localize ("splitByLetter.letter"), str_format (localize ("authorword", count ($this->entryArray)), count ($this->entryArray)), $this->idGet); |
|
| 13 | + $this->idPage = Author::getEntryIdByLetter($this->idGet); |
|
| 14 | + $this->entryArray = Author::getAuthorsByStartingLetter($this->idGet); |
|
| 15 | + $this->title = str_format(localize("splitByLetter.letter"), str_format(localize("authorword", count($this->entryArray)), count($this->entryArray)), $this->idGet); |
|
| 16 | 16 | } |
| 17 | 17 | } |
@@ -11,23 +11,23 @@ |
||
| 11 | 11 | public $book; |
| 12 | 12 | |
| 13 | 13 | public function __construct($ptitle, $pid, $pcontent, $pcontentType, $plinkArray, $pbook) { |
| 14 | - parent::__construct ($ptitle, $pid, $pcontent, $pcontentType, $plinkArray); |
|
| 14 | + parent::__construct($ptitle, $pid, $pcontent, $pcontentType, $plinkArray); |
|
| 15 | 15 | $this->book = $pbook; |
| 16 | 16 | $this->localUpdated = $pbook->timestamp; |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | - public function getCoverThumbnail () { |
|
| 19 | + public function getCoverThumbnail() { |
|
| 20 | 20 | foreach ($this->linkArray as $link) { |
| 21 | 21 | if ($link->rel == Link::OPDS_THUMBNAIL_TYPE) |
| 22 | - return $link->hrefXhtml (); |
|
| 22 | + return $link->hrefXhtml(); |
|
| 23 | 23 | } |
| 24 | 24 | return null; |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | - public function getCover () { |
|
| 27 | + public function getCover() { |
|
| 28 | 28 | foreach ($this->linkArray as $link) { |
| 29 | 29 | if ($link->rel == Link::OPDS_IMAGE_TYPE) |
| 30 | - return $link->hrefXhtml (); |
|
| 30 | + return $link->hrefXhtml(); |
|
| 31 | 31 | } |
| 32 | 32 | return null; |
| 33 | 33 | } |