@@ -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,9 +61,15 @@ 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"]; |
|
| 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 | +} |
|
| 65 | 73 | |
| 66 | 74 | $mail->From = $config['cops_mail_configuration']["address.from"]; |
| 67 | 75 | $mail->FromName = $config['cops_title_default']; |
@@ -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 | } |
@@ -25,7 +25,7 @@ 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 | // ASCII is always valid NFC! If we're only ever given plain ASCII, we can |
| 30 | 30 | // avoid the overhead of initializing the decomposition tables by skipping |
| 31 | 31 | // out early. |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | * @return |
| 176 | 176 | * ASCII replacement character. |
| 177 | 177 | */ |
| 178 | -function _transliteration_replace($ord, $unknown = '?', $langcode = NULL) { |
|
| 178 | +function _transliteration_replace($ord, $unknown = '?', $langcode = null) { |
|
| 179 | 179 | static $map = array(); |
| 180 | 180 | |
| 181 | 181 | //GL: set language later |
@@ -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 | } |
@@ -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_once 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"'); |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | * "address.from" => "[email protected]" |
| 211 | 211 | * ); |
| 212 | 212 | */ |
| 213 | - $config['cops_mail_configuration'] = NULL; |
|
| 213 | + $config['cops_mail_configuration'] = null; |
|
| 214 | 214 | |
| 215 | 215 | /* |
| 216 | 216 | * Use filter in HTML catalog |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | * array( "username" => "xxx", "password" => "secret") : Enable PHP password protection |
| 283 | 283 | * NULL : Disable PHP password protection (You can still use htpasswd) |
| 284 | 284 | */ |
| 285 | - $config['cops_basic_authentication'] = NULL; |
|
| 285 | + $config['cops_basic_authentication'] = null; |
|
| 286 | 286 | |
| 287 | 287 | /* |
| 288 | 288 | * Which template is used by default : |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | * |
| 190 | 190 | * Note that the composite custom columns are not supported |
| 191 | 191 | */ |
| 192 | - $config['cops_calibre_custom_column_list'] = array (); |
|
| 192 | + $config['cops_calibre_custom_column_list'] = array(); |
|
| 193 | 193 | |
| 194 | 194 | /* |
| 195 | 195 | * Custom Columns for the book preview panel |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | * |
| 200 | 200 | * Note that the composite custom columns are not supported |
| 201 | 201 | */ |
| 202 | - $config['cops_calibre_custom_column_preview'] = array (); |
|
| 202 | + $config['cops_calibre_custom_column_preview'] = array(); |
|
| 203 | 203 | |
| 204 | 204 | /* |
| 205 | 205 | * Rename .epub to .kepub.epub if downloaded from a Kobo eReader |
@@ -8,6 +8,9 @@ |
||
| 8 | 8 | |
| 9 | 9 | class LinkFacet extends Link |
| 10 | 10 | { |
| 11 | + /** |
|
| 12 | + * @param string $phref |
|
| 13 | + */ |
|
| 11 | 14 | public function __construct($phref, $ptitle = NULL, $pfacetGroup = NULL, $pactiveFacet = FALSE) { |
| 12 | 15 | parent::__construct ($phref, Link::OPDS_PAGING_TYPE, "http://opds-spec.org/facet", $ptitle, $pfacetGroup, $pactiveFacet); |
| 13 | 16 | if (!is_null (GetUrlParam (DB))) $this->href = addURLParameter ($this->href, DB, GetUrlParam (DB)); |
@@ -9,8 +9,8 @@ |
||
| 9 | 9 | class LinkFacet extends Link |
| 10 | 10 | { |
| 11 | 11 | public function __construct($phref, $ptitle = NULL, $pfacetGroup = NULL, $pactiveFacet = FALSE) { |
| 12 | - parent::__construct ($phref, Link::OPDS_PAGING_TYPE, "http://opds-spec.org/facet", $ptitle, $pfacetGroup, $pactiveFacet); |
|
| 13 | - if (!is_null (GetUrlParam (DB))) $this->href = addURLParameter ($this->href, DB, GetUrlParam (DB)); |
|
| 12 | + parent::__construct($phref, Link::OPDS_PAGING_TYPE, "http://opds-spec.org/facet", $ptitle, $pfacetGroup, $pactiveFacet); |
|
| 13 | + if (!is_null(GetUrlParam(DB))) $this->href = addURLParameter($this->href, DB, GetUrlParam(DB)); |
|
| 14 | 14 | $this->href = parent::getScriptName() . $this->href; |
| 15 | 15 | } |
| 16 | 16 | } |
@@ -8,9 +8,12 @@ |
||
| 8 | 8 | |
| 9 | 9 | class LinkFacet extends Link |
| 10 | 10 | { |
| 11 | - public function __construct($phref, $ptitle = NULL, $pfacetGroup = NULL, $pactiveFacet = FALSE) { |
|
| 11 | + public function __construct($phref, $ptitle = NULL, $pfacetGroup = NULL, $pactiveFacet = FALSE) |
|
| 12 | + { |
|
| 12 | 13 | parent::__construct ($phref, Link::OPDS_PAGING_TYPE, "http://opds-spec.org/facet", $ptitle, $pfacetGroup, $pactiveFacet); |
| 13 | - if (!is_null (GetUrlParam (DB))) $this->href = addURLParameter ($this->href, DB, GetUrlParam (DB)); |
|
| 14 | + if (!is_null (GetUrlParam (DB))) { |
|
| 15 | + $this->href = addURLParameter ($this->href, DB, GetUrlParam (DB)); |
|
| 16 | + } |
|
| 14 | 17 | $this->href = parent::getScriptName() . $this->href; |
| 15 | 18 | } |
| 16 | 19 | } |
@@ -8,7 +8,7 @@ |
||
| 8 | 8 | |
| 9 | 9 | class LinkFacet extends Link |
| 10 | 10 | { |
| 11 | - public function __construct($phref, $ptitle = NULL, $pfacetGroup = NULL, $pactiveFacet = FALSE) { |
|
| 11 | + public function __construct($phref, $ptitle = null, $pfacetGroup = null, $pactiveFacet = false) { |
|
| 12 | 12 | parent::__construct ($phref, Link::OPDS_PAGING_TYPE, "http://opds-spec.org/facet", $ptitle, $pfacetGroup, $pactiveFacet); |
| 13 | 13 | if (!is_null (GetUrlParam (DB))) $this->href = addURLParameter ($this->href, DB, GetUrlParam (DB)); |
| 14 | 14 | $this->href = parent::getScriptName() . $this->href; |
@@ -8,6 +8,9 @@ |
||
| 8 | 8 | |
| 9 | 9 | class LinkNavigation extends Link |
| 10 | 10 | { |
| 11 | + /** |
|
| 12 | + * @param string $prel |
|
| 13 | + */ |
|
| 11 | 14 | public function __construct($phref, $prel = NULL, $ptitle = NULL) { |
| 12 | 15 | parent::__construct ($phref, Link::OPDS_NAVIGATION_TYPE, $prel, $ptitle); |
| 13 | 16 | if (!is_null (GetUrlParam (DB))) $this->href = addURLParameter ($this->href, DB, GetUrlParam (DB)); |
@@ -9,10 +9,10 @@ |
||
| 9 | 9 | class LinkNavigation extends Link |
| 10 | 10 | { |
| 11 | 11 | public function __construct($phref, $prel = NULL, $ptitle = NULL) { |
| 12 | - parent::__construct ($phref, Link::OPDS_NAVIGATION_TYPE, $prel, $ptitle); |
|
| 13 | - if (!is_null (GetUrlParam (DB))) $this->href = addURLParameter ($this->href, DB, GetUrlParam (DB)); |
|
| 14 | - if (!preg_match ("#^\?(.*)#", $this->href) && !empty ($this->href)) $this->href = "?" . $this->href; |
|
| 15 | - if (preg_match ("/(bookdetail|getJSON).php/", parent::getScriptName())) { |
|
| 12 | + parent::__construct($phref, Link::OPDS_NAVIGATION_TYPE, $prel, $ptitle); |
|
| 13 | + if (!is_null(GetUrlParam(DB))) $this->href = addURLParameter($this->href, DB, GetUrlParam(DB)); |
|
| 14 | + if (!preg_match("#^\?(.*)#", $this->href) && !empty ($this->href)) $this->href = "?" . $this->href; |
|
| 15 | + if (preg_match("/(bookdetail|getJSON).php/", parent::getScriptName())) { |
|
| 16 | 16 | $this->href = "index.php" . $this->href; |
| 17 | 17 | } else { |
| 18 | 18 | $this->href = parent::getScriptName() . $this->href; |
@@ -8,10 +8,15 @@ |
||
| 8 | 8 | |
| 9 | 9 | class LinkNavigation extends Link |
| 10 | 10 | { |
| 11 | - public function __construct($phref, $prel = NULL, $ptitle = NULL) { |
|
| 11 | + public function __construct($phref, $prel = NULL, $ptitle = NULL) |
|
| 12 | + { |
|
| 12 | 13 | parent::__construct ($phref, Link::OPDS_NAVIGATION_TYPE, $prel, $ptitle); |
| 13 | - if (!is_null (GetUrlParam (DB))) $this->href = addURLParameter ($this->href, DB, GetUrlParam (DB)); |
|
| 14 | - if (!preg_match ("#^\?(.*)#", $this->href) && !empty ($this->href)) $this->href = "?" . $this->href; |
|
| 14 | + if (!is_null (GetUrlParam (DB))) { |
|
| 15 | + $this->href = addURLParameter ($this->href, DB, GetUrlParam (DB)); |
|
| 16 | + } |
|
| 17 | + if (!preg_match ("#^\?(.*)#", $this->href) && !empty ($this->href)) { |
|
| 18 | + $this->href = "?" . $this->href; |
|
| 19 | + } |
|
| 15 | 20 | if (preg_match ("/(bookdetail|getJSON).php/", parent::getScriptName())) { |
| 16 | 21 | $this->href = "index.php" . $this->href; |
| 17 | 22 | } else { |
@@ -8,7 +8,7 @@ |
||
| 8 | 8 | |
| 9 | 9 | class LinkNavigation extends Link |
| 10 | 10 | { |
| 11 | - public function __construct($phref, $prel = NULL, $ptitle = NULL) { |
|
| 11 | + public function __construct($phref, $prel = null, $ptitle = null) { |
|
| 12 | 12 | parent::__construct ($phref, Link::OPDS_NAVIGATION_TYPE, $prel, $ptitle); |
| 13 | 13 | if (!is_null (GetUrlParam (DB))) $this->href = addURLParameter ($this->href, DB, GetUrlParam (DB)); |
| 14 | 14 | if (!preg_match ("#^\?(.*)#", $this->href) && !empty ($this->href)) $this->href = "?" . $this->href; |
@@ -8,6 +8,9 @@ discard block |
||
| 8 | 8 | |
| 9 | 9 | class PageCustomize extends Page |
| 10 | 10 | { |
| 11 | + /** |
|
| 12 | + * @param string $key |
|
| 13 | + */ |
|
| 11 | 14 | private function isChecked ($key, $testedValue = 1) { |
| 12 | 15 | $value = getCurrentOption ($key); |
| 13 | 16 | if (is_array ($value)) { |
@@ -22,6 +25,9 @@ discard block |
||
| 22 | 25 | return ""; |
| 23 | 26 | } |
| 24 | 27 | |
| 28 | + /** |
|
| 29 | + * @param string $key |
|
| 30 | + */ |
|
| 25 | 31 | private function isSelected ($key, $value) { |
| 26 | 32 | if (getCurrentOption ($key) == $value) { |
| 27 | 33 | return "selected='selected'"; |
@@ -45,11 +45,11 @@ |
||
| 45 | 45 | $this->entryArray = array (); |
| 46 | 46 | |
| 47 | 47 | $ignoredBaseArray = array (PageQueryResult::SCOPE_AUTHOR, |
| 48 | - PageQueryResult::SCOPE_TAG, |
|
| 49 | - PageQueryResult::SCOPE_SERIES, |
|
| 50 | - PageQueryResult::SCOPE_PUBLISHER, |
|
| 51 | - PageQueryResult::SCOPE_RATING, |
|
| 52 | - "language"); |
|
| 48 | + PageQueryResult::SCOPE_TAG, |
|
| 49 | + PageQueryResult::SCOPE_SERIES, |
|
| 50 | + PageQueryResult::SCOPE_PUBLISHER, |
|
| 51 | + PageQueryResult::SCOPE_RATING, |
|
| 52 | + "language"); |
|
| 53 | 53 | |
| 54 | 54 | $content = ""; |
| 55 | 55 | array_push ($this->entryArray, new Entry ("Template", "", |
@@ -8,10 +8,10 @@ discard block |
||
| 8 | 8 | |
| 9 | 9 | class PageCustomize extends Page |
| 10 | 10 | { |
| 11 | - private function isChecked ($key, $testedValue = 1) { |
|
| 12 | - $value = getCurrentOption ($key); |
|
| 13 | - if (is_array ($value)) { |
|
| 14 | - if (in_array ($testedValue, $value)) { |
|
| 11 | + private function isChecked($key, $testedValue = 1) { |
|
| 12 | + $value = getCurrentOption($key); |
|
| 13 | + if (is_array($value)) { |
|
| 14 | + if (in_array($testedValue, $value)) { |
|
| 15 | 15 | return "checked='checked'"; |
| 16 | 16 | } |
| 17 | 17 | } else { |
@@ -22,29 +22,29 @@ discard block |
||
| 22 | 22 | return ""; |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | - private function isSelected ($key, $value) { |
|
| 26 | - if (getCurrentOption ($key) == $value) { |
|
| 25 | + private function isSelected($key, $value) { |
|
| 26 | + if (getCurrentOption($key) == $value) { |
|
| 27 | 27 | return "selected='selected'"; |
| 28 | 28 | } |
| 29 | 29 | return ""; |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - private function getStyleList () { |
|
| 33 | - $result = array (); |
|
| 34 | - foreach (glob ("templates/" . getCurrentTemplate () . "/styles/style-*.css") as $filename) { |
|
| 35 | - if (preg_match ('/styles\/style-(.*?)\.css/', $filename, $m)) { |
|
| 36 | - array_push ($result, $m [1]); |
|
| 32 | + private function getStyleList() { |
|
| 33 | + $result = array(); |
|
| 34 | + foreach (glob("templates/" . getCurrentTemplate() . "/styles/style-*.css") as $filename) { |
|
| 35 | + if (preg_match('/styles\/style-(.*?)\.css/', $filename, $m)) { |
|
| 36 | + array_push($result, $m [1]); |
|
| 37 | 37 | } |
| 38 | 38 | } |
| 39 | 39 | return $result; |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - public function InitializeContent () |
|
| 42 | + public function InitializeContent() |
|
| 43 | 43 | { |
| 44 | - $this->title = localize ("customize.title"); |
|
| 45 | - $this->entryArray = array (); |
|
| 44 | + $this->title = localize("customize.title"); |
|
| 45 | + $this->entryArray = array(); |
|
| 46 | 46 | |
| 47 | - $ignoredBaseArray = array (PageQueryResult::SCOPE_AUTHOR, |
|
| 47 | + $ignoredBaseArray = array(PageQueryResult::SCOPE_AUTHOR, |
|
| 48 | 48 | PageQueryResult::SCOPE_TAG, |
| 49 | 49 | PageQueryResult::SCOPE_SERIES, |
| 50 | 50 | PageQueryResult::SCOPE_PUBLISHER, |
@@ -52,49 +52,49 @@ discard block |
||
| 52 | 52 | "language"); |
| 53 | 53 | |
| 54 | 54 | $content = ""; |
| 55 | - array_push ($this->entryArray, new Entry ("Template", "", |
|
| 55 | + array_push($this->entryArray, new Entry("Template", "", |
|
| 56 | 56 | "<span style='cursor: pointer;' onclick='$.cookie(\"template\", \"bootstrap\", { expires: 365 });window.location=$(\".headleft\").attr(\"href\");'>Click to switch to Bootstrap</span>", "text", |
| 57 | - array ())); |
|
| 57 | + array())); |
|
| 58 | 58 | if (!preg_match("/(Kobo|Kindle\/3.0|EBRD1101)/", $_SERVER['HTTP_USER_AGENT'])) { |
| 59 | 59 | $content .= '<select id="style" onchange="updateCookie (this);">'; |
| 60 | - foreach ($this-> getStyleList () as $filename) { |
|
| 61 | - $content .= "<option value='{$filename}' " . $this->isSelected ("style", $filename) . ">{$filename}</option>"; |
|
| 60 | + foreach ($this-> getStyleList() as $filename) { |
|
| 61 | + $content .= "<option value='{$filename}' " . $this->isSelected("style", $filename) . ">{$filename}</option>"; |
|
| 62 | 62 | } |
| 63 | 63 | $content .= '</select>'; |
| 64 | 64 | } else { |
| 65 | - foreach ($this-> getStyleList () as $filename) { |
|
| 66 | - $content .= "<input type='radio' onchange='updateCookieFromCheckbox (this);' id='style-{$filename}' name='style' value='{$filename}' " . $this->isChecked ("style", $filename) . " /><label for='style-{$filename}'> {$filename} </label>"; |
|
| 65 | + foreach ($this-> getStyleList() as $filename) { |
|
| 66 | + $content .= "<input type='radio' onchange='updateCookieFromCheckbox (this);' id='style-{$filename}' name='style' value='{$filename}' " . $this->isChecked("style", $filename) . " /><label for='style-{$filename}'> {$filename} </label>"; |
|
| 67 | 67 | } |
| 68 | 68 | } |
| 69 | - array_push ($this->entryArray, new Entry (localize ("customize.style"), "", |
|
| 69 | + array_push($this->entryArray, new Entry(localize("customize.style"), "", |
|
| 70 | 70 | $content, "text", |
| 71 | - array ())); |
|
| 72 | - if (!useServerSideRendering ()) { |
|
| 73 | - $content = '<input type="checkbox" onchange="updateCookieFromCheckbox (this);" id="use_fancyapps" ' . $this->isChecked ("use_fancyapps") . ' />'; |
|
| 74 | - array_push ($this->entryArray, new Entry (localize ("customize.fancybox"), "", |
|
| 71 | + array())); |
|
| 72 | + if (!useServerSideRendering()) { |
|
| 73 | + $content = '<input type="checkbox" onchange="updateCookieFromCheckbox (this);" id="use_fancyapps" ' . $this->isChecked("use_fancyapps") . ' />'; |
|
| 74 | + array_push($this->entryArray, new Entry(localize("customize.fancybox"), "", |
|
| 75 | 75 | $content, "text", |
| 76 | - array ())); |
|
| 76 | + array())); |
|
| 77 | 77 | } |
| 78 | - $content = '<input type="number" onchange="updateCookie (this);" id="max_item_per_page" value="' . getCurrentOption ("max_item_per_page") . '" min="-1" max="1200" pattern="^[-+]?[0-9]+$" />'; |
|
| 79 | - array_push ($this->entryArray, new Entry (localize ("customize.paging"), "", |
|
| 78 | + $content = '<input type="number" onchange="updateCookie (this);" id="max_item_per_page" value="' . getCurrentOption("max_item_per_page") . '" min="-1" max="1200" pattern="^[-+]?[0-9]+$" />'; |
|
| 79 | + array_push($this->entryArray, new Entry(localize("customize.paging"), "", |
|
| 80 | 80 | $content, "text", |
| 81 | - array ())); |
|
| 82 | - $content = '<input type="text" onchange="updateCookie (this);" id="email" value="' . getCurrentOption ("email") . '" />'; |
|
| 83 | - array_push ($this->entryArray, new Entry (localize ("customize.email"), "", |
|
| 81 | + array())); |
|
| 82 | + $content = '<input type="text" onchange="updateCookie (this);" id="email" value="' . getCurrentOption("email") . '" />'; |
|
| 83 | + array_push($this->entryArray, new Entry(localize("customize.email"), "", |
|
| 84 | 84 | $content, "text", |
| 85 | - array ())); |
|
| 86 | - $content = '<input type="checkbox" onchange="updateCookieFromCheckbox (this);" id="html_tag_filter" ' . $this->isChecked ("html_tag_filter") . ' />'; |
|
| 87 | - array_push ($this->entryArray, new Entry (localize ("customize.filter"), "", |
|
| 85 | + array())); |
|
| 86 | + $content = '<input type="checkbox" onchange="updateCookieFromCheckbox (this);" id="html_tag_filter" ' . $this->isChecked("html_tag_filter") . ' />'; |
|
| 87 | + array_push($this->entryArray, new Entry(localize("customize.filter"), "", |
|
| 88 | 88 | $content, "text", |
| 89 | - array ())); |
|
| 89 | + array())); |
|
| 90 | 90 | $content = ""; |
| 91 | 91 | foreach ($ignoredBaseArray as $key) { |
| 92 | - $keyPlural = preg_replace ('/(ss)$/', 's', $key . "s"); |
|
| 93 | - $content .= '<input type="checkbox" name="ignored_categories[]" onchange="updateCookieFromCheckboxGroup (this);" id="ignored_categories_' . $key . '" ' . $this->isChecked ("ignored_categories", $key) . ' > ' . localize ("{$keyPlural}.title") . '</input> '; |
|
| 92 | + $keyPlural = preg_replace('/(ss)$/', 's', $key . "s"); |
|
| 93 | + $content .= '<input type="checkbox" name="ignored_categories[]" onchange="updateCookieFromCheckboxGroup (this);" id="ignored_categories_' . $key . '" ' . $this->isChecked("ignored_categories", $key) . ' > ' . localize("{$keyPlural}.title") . '</input> '; |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | - array_push ($this->entryArray, new Entry (localize ("customize.ignored"), "", |
|
| 96 | + array_push($this->entryArray, new Entry(localize("customize.ignored"), "", |
|
| 97 | 97 | $content, "text", |
| 98 | - array ())); |
|
| 98 | + array())); |
|
| 99 | 99 | } |
| 100 | 100 | } |
@@ -8,7 +8,8 @@ discard block |
||
| 8 | 8 | |
| 9 | 9 | class PageCustomize extends Page |
| 10 | 10 | { |
| 11 | - private function isChecked ($key, $testedValue = 1) { |
|
| 11 | + private function isChecked ($key, $testedValue = 1) |
|
| 12 | + { |
|
| 12 | 13 | $value = getCurrentOption ($key); |
| 13 | 14 | if (is_array ($value)) { |
| 14 | 15 | if (in_array ($testedValue, $value)) { |
@@ -22,14 +23,16 @@ discard block |
||
| 22 | 23 | return ""; |
| 23 | 24 | } |
| 24 | 25 | |
| 25 | - private function isSelected ($key, $value) { |
|
| 26 | + private function isSelected ($key, $value) |
|
| 27 | + { |
|
| 26 | 28 | if (getCurrentOption ($key) == $value) { |
| 27 | 29 | return "selected='selected'"; |
| 28 | 30 | } |
| 29 | 31 | return ""; |
| 30 | 32 | } |
| 31 | 33 | |
| 32 | - private function getStyleList () { |
|
| 34 | + private function getStyleList () |
|
| 35 | + { |
|
| 33 | 36 | $result = array (); |
| 34 | 37 | foreach (glob ("templates/" . getCurrentTemplate () . "/styles/style-*.css") as $filename) { |
| 35 | 38 | if (preg_match ('/styles\/style-(.*?)\.css/', $filename, $m)) { |
@@ -44,7 +44,7 @@ |
||
| 44 | 44 | if ($post = $result->fetchObject ()) { |
| 45 | 45 | return new Language ($post->id, Language::getLanguageString ($post->lang_code)); |
| 46 | 46 | } |
| 47 | - return NULL; |
|
| 47 | + return null; |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | |
@@ -18,17 +18,17 @@ discard block |
||
| 18 | 18 | $this->lang_code = $plang_code; |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | - public function getUri () { |
|
| 22 | - return "?page=".Base::PAGE_LANGUAGE_DETAIL."&id=$this->id"; |
|
| 21 | + public function getUri() { |
|
| 22 | + return "?page=" . Base::PAGE_LANGUAGE_DETAIL . "&id=$this->id"; |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | - public function getEntryId () { |
|
| 26 | - return self::ALL_LANGUAGES_ID.":".$this->id; |
|
| 25 | + public function getEntryId() { |
|
| 26 | + return self::ALL_LANGUAGES_ID . ":" . $this->id; |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | - public static function getLanguageString ($code) { |
|
| 30 | - $string = localize("languages.".$code); |
|
| 31 | - if (preg_match ("/^languages/", $string)) { |
|
| 29 | + public static function getLanguageString($code) { |
|
| 30 | + $string = localize("languages." . $code); |
|
| 31 | + if (preg_match("/^languages/", $string)) { |
|
| 32 | 32 | return $code; |
| 33 | 33 | } |
| 34 | 34 | return $string; |
@@ -36,14 +36,14 @@ discard block |
||
| 36 | 36 | |
| 37 | 37 | public static function getCount() { |
| 38 | 38 | // str_format (localize("languages.alphabetical", count(array)) |
| 39 | - return Base::getCountGeneric ("languages", self::ALL_LANGUAGES_ID, Base::PAGE_ALL_LANGUAGES); |
|
| 39 | + return Base::getCountGeneric("languages", self::ALL_LANGUAGES_ID, Base::PAGE_ALL_LANGUAGES); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - public static function getLanguageById ($languageId) { |
|
| 43 | - $result = Base::getDb ()->prepare('select id, lang_code from languages where id = ?'); |
|
| 44 | - $result->execute (array ($languageId)); |
|
| 45 | - if ($post = $result->fetchObject ()) { |
|
| 46 | - return new Language ($post->id, Language::getLanguageString ($post->lang_code)); |
|
| 42 | + public static function getLanguageById($languageId) { |
|
| 43 | + $result = Base::getDb()->prepare('select id, lang_code from languages where id = ?'); |
|
| 44 | + $result->execute(array($languageId)); |
|
| 45 | + if ($post = $result->fetchObject()) { |
|
| 46 | + return new Language($post->id, Language::getLanguageString($post->lang_code)); |
|
| 47 | 47 | } |
| 48 | 48 | return NULL; |
| 49 | 49 | } |
@@ -57,12 +57,12 @@ discard block |
||
| 57 | 57 | group by languages.id, books_languages_link.lang_code |
| 58 | 58 | order by languages.lang_code'); |
| 59 | 59 | $entryArray = array(); |
| 60 | - while ($post = $result->fetchObject ()) |
|
| 60 | + while ($post = $result->fetchObject()) |
|
| 61 | 61 | { |
| 62 | - $language = new Language ($post->id, $post->lang_code); |
|
| 63 | - array_push ($entryArray, new Entry (Language::getLanguageString ($language->lang_code), $language->getEntryId (), |
|
| 64 | - str_format (localize("bookword", $post->count), $post->count), "text", |
|
| 65 | - array ( new LinkNavigation ($language->getUri ())), "", $post->count)); |
|
| 62 | + $language = new Language($post->id, $post->lang_code); |
|
| 63 | + array_push($entryArray, new Entry(Language::getLanguageString($language->lang_code), $language->getEntryId(), |
|
| 64 | + str_format(localize("bookword", $post->count), $post->count), "text", |
|
| 65 | + array(new LinkNavigation($language->getUri())), "", $post->count)); |
|
| 66 | 66 | } |
| 67 | 67 | return $entryArray; |
| 68 | 68 | } |
@@ -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=".Base::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 Base::getCountGeneric ("languages", self::ALL_LANGUAGES_ID, Base::PAGE_ALL_LANGUAGES); |
| 40 | 45 | } |
| 41 | 46 | |
| 42 | - public static function getLanguageById ($languageId) { |
|
| 47 | + public static function getLanguageById ($languageId) |
|
| 48 | + { |
|
| 43 | 49 | $result = Base::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 = Base::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", |
@@ -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 | } |