@@ -163,7 +163,7 @@ |
||
| 163 | 163 | /** |
| 164 | 164 | * Replaces a Unicode character using the transliteration database. |
| 165 | 165 | * |
| 166 | - * @param $ord |
|
| 166 | + * @param integer $ord |
|
| 167 | 167 | * An ordinal Unicode character code. |
| 168 | 168 | * @param $unknown |
| 169 | 169 | * Replacement string for characters that do not have a suitable ASCII |
@@ -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 | } |
@@ -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 | |
@@ -2,7 +2,8 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | require_once ("config.php"); |
| 4 | 4 | |
| 5 | -function checkConfiguration () { |
|
| 5 | +function checkConfiguration () |
|
| 6 | +{ |
|
| 6 | 7 | global $config; |
| 7 | 8 | |
| 8 | 9 | if (is_null ($config['cops_mail_configuration']) || |
@@ -14,7 +15,8 @@ discard block |
||
| 14 | 15 | return False; |
| 15 | 16 | } |
| 16 | 17 | |
| 17 | -function checkRequest ($idData, $emailDest) { |
|
| 18 | +function checkRequest ($idData, $emailDest) |
|
| 19 | +{ |
|
| 18 | 20 | if (empty ($idData)) { |
| 19 | 21 | return 'No data sent.'; |
| 20 | 22 | } |
@@ -58,9 +60,15 @@ discard block |
||
| 58 | 60 | $mail->Port = 465; |
| 59 | 61 | } |
| 60 | 62 | $mail->SMTPAuth = !empty ($config['cops_mail_configuration']["smtp.username"]); |
| 61 | -if (!empty ($config['cops_mail_configuration']["smtp.username"])) $mail->Username = $config['cops_mail_configuration']["smtp.username"]; |
|
| 62 | -if (!empty ($config['cops_mail_configuration']["smtp.password"])) $mail->Password = $config['cops_mail_configuration']["smtp.password"]; |
|
| 63 | -if (!empty ($config['cops_mail_configuration']["smtp.secure"])) $mail->SMTPSecure = $config['cops_mail_configuration']["smtp.secure"]; |
|
| 63 | +if (!empty ($config['cops_mail_configuration']["smtp.username"])) { |
|
| 64 | + $mail->Username = $config['cops_mail_configuration']["smtp.username"]; |
|
| 65 | +} |
|
| 66 | +if (!empty ($config['cops_mail_configuration']["smtp.password"])) { |
|
| 67 | + $mail->Password = $config['cops_mail_configuration']["smtp.password"]; |
|
| 68 | +} |
|
| 69 | +if (!empty ($config['cops_mail_configuration']["smtp.secure"])) { |
|
| 70 | + $mail->SMTPSecure = $config['cops_mail_configuration']["smtp.secure"]; |
|
| 71 | +} |
|
| 64 | 72 | |
| 65 | 73 | $mail->From = $config['cops_mail_configuration']["address.from"]; |
| 66 | 74 | $mail->FromName = $config['cops_title_default']; |
@@ -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; } |
@@ -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_once 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 |
@@ -16,7 +16,7 @@ |
||
| 16 | 16 | |
| 17 | 17 | $err = getURLParam ("err", -1); |
| 18 | 18 | $full = getURLParam ("full"); |
| 19 | - $error = NULL; |
|
| 19 | + $error = null; |
|
| 20 | 20 | switch ($err) { |
| 21 | 21 | case 1 : |
| 22 | 22 | $error = "Database error"; |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | require_once 'config.php'; |
| 13 | 13 | require_once 'base.php'; |
| 14 | 14 | |
| 15 | - header ('Content-Type:text/html; charset=UTF-8'); |
|
| 15 | + header('Content-Type:text/html; charset=UTF-8'); |
|
| 16 | 16 | |
| 17 | 17 | $err = getURLParam('err', -1); |
| 18 | 18 | $full = getURLParam('full'); |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | <meta charset="utf-8"> |
| 29 | 29 | <meta name="viewport" content="width=device-width, initial-scale=1.0" /> |
| 30 | 30 | <title>COPS Configuration Check</title> |
| 31 | - <link rel="stylesheet" type="text/css" href="<?php echo getUrlWithVersion(getCurrentCss ()) ?>" media="screen" /> |
|
| 31 | + <link rel="stylesheet" type="text/css" href="<?php echo getUrlWithVersion(getCurrentCss()) ?>" media="screen" /> |
|
| 32 | 32 | </head> |
| 33 | 33 | <body> |
| 34 | 34 | <div class="container"> |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | <h2>Check if the rendering will be done on client side or server side</h2> |
| 154 | 154 | <h4> |
| 155 | 155 | <?php |
| 156 | - if (useServerSideRendering ()) { |
|
| 156 | + if (useServerSideRendering()) { |
|
| 157 | 157 | echo 'Server side rendering'; |
| 158 | 158 | } else { |
| 159 | 159 | echo 'Client side rendering'; |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | <h2>Check if Calibre database path is not an URL</h2> |
| 170 | 170 | <h4> |
| 171 | 171 | <?php |
| 172 | - if (!preg_match ('#^http#', $database)) { |
|
| 172 | + if (!preg_match('#^http#', $database)) { |
|
| 173 | 173 | echo 'OK'; |
| 174 | 174 | } else { |
| 175 | 175 | echo 'Calibre path has to be local (no URL allowed)'; |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | <h4> |
| 203 | 203 | <?php |
| 204 | 204 | try { |
| 205 | - $db = new PDO('sqlite:'. Base::getDbFileName($i)); |
|
| 205 | + $db = new PDO('sqlite:' . Base::getDbFileName($i)); |
|
| 206 | 206 | echo $name . ' OK'; |
| 207 | 207 | } catch (Exception $e) { |
| 208 | 208 | echo $name . ' If the file is readable, check your php configuration. Exception detail : ' . $e; |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | <h4> |
| 216 | 216 | <?php |
| 217 | 217 | try { |
| 218 | - $db = new PDO('sqlite:'. Base::getDbFileName($i)); |
|
| 218 | + $db = new PDO('sqlite:' . Base::getDbFileName($i)); |
|
| 219 | 219 | $count = $db->query('select count(*) FROM sqlite_master WHERE type="table" AND name in ("books", "authors", "tags", "series")')->fetchColumn(); |
| 220 | 220 | if ($count == 4) { |
| 221 | 221 | echo $name . ' OK'; |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | $result->execute(); |
| 240 | 240 | while ($post = $result->fetchObject()) |
| 241 | 241 | { |
| 242 | - if (!is_file (Base::getDbDirectory($i) . $post->fullpath)) { |
|
| 242 | + if (!is_file(Base::getDbDirectory($i) . $post->fullpath)) { |
|
| 243 | 243 | echo '<p>' . Base::getDbDirectory($i) . $post->fullpath . '</p>'; |
| 244 | 244 | } |
| 245 | 245 | } |
@@ -237,8 +237,7 @@ |
||
| 237 | 237 | $db = new PDO('sqlite:' . Base::getDbFileName($i)); |
| 238 | 238 | $result = $db->prepare('select books.path || "/" || data.name || "." || lower (format) as fullpath from data join books on data.book = books.id'); |
| 239 | 239 | $result->execute(); |
| 240 | - while ($post = $result->fetchObject()) |
|
| 241 | - { |
|
| 240 | + while ($post = $result->fetchObject()) { |
|
| 242 | 241 | if (!is_file (Base::getDbDirectory($i) . $post->fullpath)) { |
| 243 | 242 | echo '<p>' . Base::getDbDirectory($i) . $post->fullpath . '</p>'; |
| 244 | 243 | } |
@@ -60,6 +60,9 @@ discard block |
||
| 60 | 60 | $_SERVER['REDIRECT_STATUS'] = 404; |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | +/** |
|
| 64 | + * @param string $name |
|
| 65 | + */ |
|
| 63 | 66 | function getURLParam ($name, $default = NULL) { |
| 64 | 67 | if (!empty ($_GET) && isset($_GET[$name]) && $_GET[$name] != "") { |
| 65 | 68 | return $_GET[$name]; |
@@ -95,6 +98,11 @@ discard block |
||
| 95 | 98 | return $url . "?v=" . VERSION; |
| 96 | 99 | } |
| 97 | 100 | |
| 101 | +/** |
|
| 102 | + * @param string $xml |
|
| 103 | + * |
|
| 104 | + * @return string |
|
| 105 | + */ |
|
| 98 | 106 | function xml2xhtml($xml) { |
| 99 | 107 | return preg_replace_callback('#<(\w+)([^>]*)\s*/>#s', create_function('$m', ' |
| 100 | 108 | $xhtml_tags = array("br", "hr", "input", "frame", "img", "area", "link", "col", "base", "basefont", "param"); |
@@ -308,6 +316,9 @@ discard block |
||
| 308 | 316 | return $phrase; |
| 309 | 317 | } |
| 310 | 318 | |
| 319 | +/** |
|
| 320 | + * @param string $paramName |
|
| 321 | + */ |
|
| 311 | 322 | function addURLParameter($urlParams, $paramName, $paramValue) { |
| 312 | 323 | if (empty ($urlParams)) { |
| 313 | 324 | $urlParams = ""; |
@@ -32,9 +32,9 @@ discard block |
||
| 32 | 32 | // Generate the function for the template |
| 33 | 33 | $template = new doT (); |
| 34 | 34 | $dot = $template->template ($page, array ('bookdetail' => $bookdetail, |
| 35 | - 'header' => $header, |
|
| 36 | - 'footer' => $footer, |
|
| 37 | - 'main' => $main)); |
|
| 35 | + 'header' => $header, |
|
| 36 | + 'footer' => $footer, |
|
| 37 | + 'main' => $main)); |
|
| 38 | 38 | // If there is a syntax error in the function created |
| 39 | 39 | // $dot will be equal to FALSE |
| 40 | 40 | if (!$dot) { |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | case LIBXML_ERR_WARNING: |
| 126 | 126 | $return .= 'Warning ' . $error->code . ': '; |
| 127 | 127 | break; |
| 128 | - case LIBXML_ERR_ERROR: |
|
| 128 | + case LIBXML_ERR_ERROR: |
|
| 129 | 129 | $return .= 'Error ' . $error->code . ': '; |
| 130 | 130 | break; |
| 131 | 131 | case LIBXML_ERR_FATAL: |
@@ -134,8 +134,8 @@ discard block |
||
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | $return .= trim($error->message) . |
| 137 | - "\n Line: " . $error->line . |
|
| 138 | - "\n Column: " . $error->column; |
|
| 137 | + "\n Line: " . $error->line . |
|
| 138 | + "\n Column: " . $error->column; |
|
| 139 | 139 | |
| 140 | 140 | if ($error->file) { |
| 141 | 141 | $return .= "\n File: " . $error->file; |
@@ -8,8 +8,8 @@ discard block |
||
| 8 | 8 | |
| 9 | 9 | require_once 'config.php'; |
| 10 | 10 | |
| 11 | -define ('VERSION', '1.0.0RC4'); |
|
| 12 | -define ('DB', 'db'); |
|
| 11 | +define('VERSION', '1.0.0RC4'); |
|
| 12 | +define('DB', 'db'); |
|
| 13 | 13 | date_default_timezone_set($config['default_timezone']); |
| 14 | 14 | |
| 15 | 15 | |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | function serverSideRender($data) |
| 23 | 23 | { |
| 24 | 24 | // Get the templates |
| 25 | - $theme = getCurrentTemplate (); |
|
| 25 | + $theme = getCurrentTemplate(); |
|
| 26 | 26 | $header = file_get_contents('templates/' . $theme . '/header.html'); |
| 27 | 27 | $footer = file_get_contents('templates/' . $theme . '/footer.html'); |
| 28 | 28 | $main = file_get_contents('templates/' . $theme . '/main.html'); |
@@ -30,8 +30,8 @@ discard block |
||
| 30 | 30 | $page = file_get_contents('templates/' . $theme . '/page.html'); |
| 31 | 31 | |
| 32 | 32 | // Generate the function for the template |
| 33 | - $template = new doT (); |
|
| 34 | - $dot = $template->template ($page, array ('bookdetail' => $bookdetail, |
|
| 33 | + $template = new doT(); |
|
| 34 | + $dot = $template->template($page, array('bookdetail' => $bookdetail, |
|
| 35 | 35 | 'header' => $header, |
| 36 | 36 | 'footer' => $footer, |
| 37 | 37 | 'main' => $main)); |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | } |
| 43 | 43 | // Execute the template |
| 44 | 44 | if (!empty ($data)) { |
| 45 | - return $dot ($data); |
|
| 45 | + return $dot($data); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | return NULL; |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | |
| 59 | 59 | function notFound() |
| 60 | 60 | { |
| 61 | - header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found'); |
|
| 61 | + header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found'); |
|
| 62 | 62 | header('Status: 404 Not Found'); |
| 63 | 63 | |
| 64 | 64 | $_SERVER['REDIRECT_STATUS'] = 404; |
@@ -76,8 +76,8 @@ discard block |
||
| 76 | 76 | { |
| 77 | 77 | global $config; |
| 78 | 78 | if (isset($_COOKIE[$option])) { |
| 79 | - if (isset($config ['cops_' . $option]) && is_array ($config ['cops_' . $option])) { |
|
| 80 | - return explode (',', $_COOKIE[$option]); |
|
| 79 | + if (isset($config ['cops_' . $option]) && is_array($config ['cops_' . $option])) { |
|
| 80 | + return explode(',', $_COOKIE[$option]); |
|
| 81 | 81 | } else { |
| 82 | 82 | return $_COOKIE[$option]; |
| 83 | 83 | } |
@@ -91,12 +91,12 @@ discard block |
||
| 91 | 91 | |
| 92 | 92 | function getCurrentCss() |
| 93 | 93 | { |
| 94 | - return 'templates/' . getCurrentTemplate () . '/styles/style-' . getCurrentOption('style') . '.css'; |
|
| 94 | + return 'templates/' . getCurrentTemplate() . '/styles/style-' . getCurrentOption('style') . '.css'; |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | function getCurrentTemplate() |
| 98 | 98 | { |
| 99 | - return getCurrentOption ('template'); |
|
| 99 | + return getCurrentOption('template'); |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | function getUrlWithVersion($url) |
@@ -160,10 +160,10 @@ discard block |
||
| 160 | 160 | libxml_use_internal_errors(true); |
| 161 | 161 | |
| 162 | 162 | $doc->loadHTML('<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body>' . |
| 163 | - $html . '</body></html>'); // Load the HTML |
|
| 163 | + $html . '</body></html>'); // Load the HTML |
|
| 164 | 164 | $output = $doc->saveXML($doc->documentElement); // Transform to an Ansi xml stream |
| 165 | 165 | $output = xml2xhtml($output); |
| 166 | - if (preg_match ('#<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></meta></head><body>(.*)</body></html>#ms', $output, $matches)) { |
|
| 166 | + if (preg_match('#<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></meta></head><body>(.*)</body></html>#ms', $output, $matches)) { |
|
| 167 | 167 | $output = $matches [1]; // Remove <html><body> |
| 168 | 168 | } |
| 169 | 169 | /* |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | } |
| 176 | 176 | */ |
| 177 | 177 | |
| 178 | - if (!are_libxml_errors_ok ()) $output = 'HTML code not valid.'; |
|
| 178 | + if (!are_libxml_errors_ok()) $output = 'HTML code not valid.'; |
|
| 179 | 179 | |
| 180 | 180 | libxml_use_internal_errors(false); |
| 181 | 181 | return $output; |
@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | //echo var_dump($langs); |
| 265 | 265 | $lang_file = NULL; |
| 266 | 266 | foreach ($langs as $language => $val) { |
| 267 | - $temp_file = dirname(__FILE__). '/lang/Localization_' . $language . '.json'; |
|
| 267 | + $temp_file = dirname(__FILE__) . '/lang/Localization_' . $language . '.json'; |
|
| 268 | 268 | if (file_exists($temp_file)) { |
| 269 | 269 | $lang = $language; |
| 270 | 270 | $lang_file = $temp_file; |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | } |
| 273 | 273 | } |
| 274 | 274 | if (empty ($lang_file)) { |
| 275 | - $lang_file = dirname(__FILE__). '/lang/Localization_' . $lang . '.json'; |
|
| 275 | + $lang_file = dirname(__FILE__) . '/lang/Localization_' . $lang . '.json'; |
|
| 276 | 276 | } |
| 277 | 277 | return array($lang, $lang_file); |
| 278 | 278 | } |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | * This method is based on this page |
| 282 | 282 | * http://www.mind-it.info/2010/02/22/a-simple-approach-to-localization-in-php/ |
| 283 | 283 | */ |
| 284 | -function localize($phrase, $count=-1, $reset=false) |
|
| 284 | +function localize($phrase, $count = -1, $reset = false) |
|
| 285 | 285 | { |
| 286 | 286 | global $config; |
| 287 | 287 | if ($count == 0) |
@@ -301,7 +301,7 @@ discard block |
||
| 301 | 301 | $lang_file_en = NULL; |
| 302 | 302 | list ($lang, $lang_file) = getLangAndTranslationFile(); |
| 303 | 303 | if ($lang != 'en') { |
| 304 | - $lang_file_en = dirname(__FILE__). '/lang/' . 'Localization_en.json'; |
|
| 304 | + $lang_file_en = dirname(__FILE__) . '/lang/' . 'Localization_en.json'; |
|
| 305 | 305 | } |
| 306 | 306 | |
| 307 | 307 | $lang_file_content = file_get_contents($lang_file); |
@@ -309,8 +309,8 @@ discard block |
||
| 309 | 309 | $translations = json_decode($lang_file_content, true); |
| 310 | 310 | |
| 311 | 311 | /* Clean the array of all unfinished translations */ |
| 312 | - foreach (array_keys ($translations) as $key) { |
|
| 313 | - if (preg_match ('/^##TODO##/', $key)) { |
|
| 312 | + foreach (array_keys($translations) as $key) { |
|
| 313 | + if (preg_match('/^##TODO##/', $key)) { |
|
| 314 | 314 | unset ($translations [$key]); |
| 315 | 315 | } |
| 316 | 316 | } |
@@ -318,10 +318,10 @@ discard block |
||
| 318 | 318 | { |
| 319 | 319 | $lang_file_content = file_get_contents($lang_file_en); |
| 320 | 320 | $translations_en = json_decode($lang_file_content, true); |
| 321 | - $translations = array_merge ($translations_en, $translations); |
|
| 321 | + $translations = array_merge($translations_en, $translations); |
|
| 322 | 322 | } |
| 323 | 323 | } |
| 324 | - if (array_key_exists ($phrase, $translations)) { |
|
| 324 | + if (array_key_exists($phrase, $translations)) { |
|
| 325 | 325 | return $translations[$phrase]; |
| 326 | 326 | } |
| 327 | 327 | return $phrase; |
@@ -333,7 +333,7 @@ discard block |
||
| 333 | 333 | $urlParams = ''; |
| 334 | 334 | } |
| 335 | 335 | $start = ''; |
| 336 | - if (preg_match ('#^\?(.*)#', $urlParams, $matches)) { |
|
| 336 | + if (preg_match('#^\?(.*)#', $urlParams, $matches)) { |
|
| 337 | 337 | $start = '?'; |
| 338 | 338 | $urlParams = $matches[1]; |
| 339 | 339 | } |
@@ -38,14 +38,14 @@ discard block |
||
| 38 | 38 | // If there is a syntax error in the function created |
| 39 | 39 | // $dot will be equal to FALSE |
| 40 | 40 | if (!$dot) { |
| 41 | - return FALSE; |
|
| 41 | + return false; |
|
| 42 | 42 | } |
| 43 | 43 | // Execute the template |
| 44 | 44 | if (!empty ($data)) { |
| 45 | 45 | return $dot ($data); |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - return NULL; |
|
| 48 | + return null; |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | function getQueryString() |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | $_SERVER['REDIRECT_STATUS'] = 404; |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | -function getURLParam($name, $default = NULL) |
|
| 67 | +function getURLParam($name, $default = null) |
|
| 68 | 68 | { |
| 69 | 69 | if (!empty ($_GET) && isset($_GET[$name]) && $_GET[$name] != '') { |
| 70 | 70 | return $_GET[$name]; |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | $langs = getAcceptLanguages(); |
| 263 | 263 | } |
| 264 | 264 | //echo var_dump($langs); |
| 265 | - $lang_file = NULL; |
|
| 265 | + $lang_file = null; |
|
| 266 | 266 | foreach ($langs as $language => $val) { |
| 267 | 267 | $temp_file = dirname(__FILE__). '/lang/Localization_' . $language . '.json'; |
| 268 | 268 | if (file_exists($temp_file)) { |
@@ -292,13 +292,13 @@ discard block |
||
| 292 | 292 | $phrase .= '.many'; |
| 293 | 293 | |
| 294 | 294 | /* Static keyword is used to ensure the file is loaded only once */ |
| 295 | - static $translations = NULL; |
|
| 295 | + static $translations = null; |
|
| 296 | 296 | if ($reset) { |
| 297 | - $translations = NULL; |
|
| 297 | + $translations = null; |
|
| 298 | 298 | } |
| 299 | 299 | /* If no instance of $translations has occured load the language file */ |
| 300 | 300 | if (is_null($translations)) { |
| 301 | - $lang_file_en = NULL; |
|
| 301 | + $lang_file_en = null; |
|
| 302 | 302 | list ($lang, $lang_file) = getLangAndTranslationFile(); |
| 303 | 303 | if ($lang != 'en') { |
| 304 | 304 | $lang_file_en = dirname(__FILE__). '/lang/' . 'Localization_en.json'; |
@@ -149,7 +149,9 @@ discard block |
||
| 149 | 149 | $errors = libxml_get_errors(); |
| 150 | 150 | |
| 151 | 151 | foreach ($errors as $error) { |
| 152 | - if ($error->code == 801) return false; |
|
| 152 | + if ($error->code == 801) { |
|
| 153 | + return false; |
|
| 154 | + } |
|
| 153 | 155 | } |
| 154 | 156 | return true; |
| 155 | 157 | } |
@@ -175,7 +177,9 @@ discard block |
||
| 175 | 177 | } |
| 176 | 178 | */ |
| 177 | 179 | |
| 178 | - if (!are_libxml_errors_ok ()) $output = 'HTML code not valid.'; |
|
| 180 | + if (!are_libxml_errors_ok ()) { |
|
| 181 | + $output = 'HTML code not valid.'; |
|
| 182 | + } |
|
| 179 | 183 | |
| 180 | 184 | libxml_use_internal_errors(false); |
| 181 | 185 | return $output; |
@@ -235,7 +239,9 @@ discard block |
||
| 235 | 239 | |
| 236 | 240 | // set default to 1 for any without q factor |
| 237 | 241 | foreach ($langs as $lang => $val) { |
| 238 | - if ($val === '') $langs[$lang] = 1; |
|
| 242 | + if ($val === '') { |
|
| 243 | + $langs[$lang] = 1; |
|
| 244 | + } |
|
| 239 | 245 | } |
| 240 | 246 | |
| 241 | 247 | // sort list based on value |
@@ -257,8 +263,7 @@ discard block |
||
| 257 | 263 | $lang = 'en'; |
| 258 | 264 | if (!empty($config['cops_language'])) { |
| 259 | 265 | $lang = $config['cops_language']; |
| 260 | - } |
|
| 261 | - elseif (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { |
|
| 266 | + } elseif (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { |
|
| 262 | 267 | $langs = getAcceptLanguages(); |
| 263 | 268 | } |
| 264 | 269 | //echo var_dump($langs); |
@@ -284,12 +289,15 @@ discard block |
||
| 284 | 289 | function localize($phrase, $count=-1, $reset=false) |
| 285 | 290 | { |
| 286 | 291 | global $config; |
| 287 | - if ($count == 0) |
|
| 288 | - $phrase .= '.none'; |
|
| 289 | - if ($count == 1) |
|
| 290 | - $phrase .= '.one'; |
|
| 291 | - if ($count > 1) |
|
| 292 | - $phrase .= '.many'; |
|
| 292 | + if ($count == 0) { |
|
| 293 | + $phrase .= '.none'; |
|
| 294 | + } |
|
| 295 | + if ($count == 1) { |
|
| 296 | + $phrase .= '.one'; |
|
| 297 | + } |
|
| 298 | + if ($count > 1) { |
|
| 299 | + $phrase .= '.many'; |
|
| 300 | + } |
|
| 293 | 301 | |
| 294 | 302 | /* Static keyword is used to ensure the file is loaded only once */ |
| 295 | 303 | static $translations = NULL; |
@@ -84,6 +84,9 @@ discard block |
||
| 84 | 84 | return ""; |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | + /** |
|
| 88 | + * @return string |
|
| 89 | + */ |
|
| 87 | 90 | public static function getDbDirectory ($database = NULL) { |
| 88 | 91 | global $config; |
| 89 | 92 | if (self::isMultipleDatabaseEnabled ()) { |
@@ -143,10 +146,18 @@ discard block |
||
| 143 | 146 | self::$db = NULL; |
| 144 | 147 | } |
| 145 | 148 | |
| 149 | + /** |
|
| 150 | + * @param string $query |
|
| 151 | + */ |
|
| 146 | 152 | public static function executeQuerySingle ($query, $database = NULL) { |
| 147 | 153 | return self::getDb ($database)->query($query)->fetchColumn(); |
| 148 | 154 | } |
| 149 | 155 | |
| 156 | + /** |
|
| 157 | + * @param string $table |
|
| 158 | + * @param string $id |
|
| 159 | + * @param string $numberOfString |
|
| 160 | + */ |
|
| 150 | 161 | public static function getCountGeneric($table, $id, $pageId, $numberOfString = NULL) { |
| 151 | 162 | if (!$numberOfString) { |
| 152 | 163 | $numberOfString = $table . ".alphabetical"; |
@@ -159,6 +170,10 @@ discard block |
||
| 159 | 170 | return $entry; |
| 160 | 171 | } |
| 161 | 172 | |
| 173 | + /** |
|
| 174 | + * @param string $columns |
|
| 175 | + * @param string $category |
|
| 176 | + */ |
|
| 162 | 177 | public static function getEntryArrayWithBookNumber ($query, $columns, $params, $category) { |
| 163 | 178 | list (, $result) = self::executeQuery ($query, $columns, "", $params, -1); |
| 164 | 179 | $entryArray = array(); |
@@ -177,6 +192,9 @@ discard block |
||
| 177 | 192 | return $entryArray; |
| 178 | 193 | } |
| 179 | 194 | |
| 195 | + /** |
|
| 196 | + * @param string $filter |
|
| 197 | + */ |
|
| 180 | 198 | public static function executeQuery($query, $columns, $filter, $params, $n, $database = NULL, $numberPerPage = NULL) { |
| 181 | 199 | $totalResult = -1; |
| 182 | 200 | |
@@ -40,15 +40,15 @@ discard block |
||
| 40 | 40 | public static function isMultipleDatabaseEnabled() |
| 41 | 41 | { |
| 42 | 42 | global $config; |
| 43 | - return is_array ($config['calibre_directory']); |
|
| 43 | + return is_array($config['calibre_directory']); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | public static function useAbsolutePath() |
| 47 | 47 | { |
| 48 | 48 | global $config; |
| 49 | 49 | $path = self::getDbDirectory(); |
| 50 | - return preg_match ('/^\//', $path) || // Linux / |
|
| 51 | - preg_match ('/^\w\:/', $path); // Windows X: |
|
| 50 | + return preg_match('/^\//', $path) || // Linux / |
|
| 51 | + preg_match('/^\w\:/', $path); // Windows X: |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | public static function noDatabaseSelected() |
@@ -70,9 +70,9 @@ discard block |
||
| 70 | 70 | { |
| 71 | 71 | global $config; |
| 72 | 72 | if (self::isMultipleDatabaseEnabled()) { |
| 73 | - return array_keys ($config['calibre_directory']); |
|
| 73 | + return array_keys($config['calibre_directory']); |
|
| 74 | 74 | } else { |
| 75 | - return array (''); |
|
| 75 | + return array(''); |
|
| 76 | 76 | } |
| 77 | 77 | } |
| 78 | 78 | |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | |
| 107 | 107 | public static function getDbFileName($database = NULL) |
| 108 | 108 | { |
| 109 | - return self::getDbDirectory($database) .'metadata.db'; |
|
| 109 | + return self::getDbDirectory($database) . 'metadata.db'; |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | private static function error($database) |
@@ -117,12 +117,12 @@ discard block |
||
| 117 | 117 | throw new Exception('Database <' . $database . '> not found.'); |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - public static function getDb ($database = NULL) |
|
| 120 | + public static function getDb($database = NULL) |
|
| 121 | 121 | { |
| 122 | - if (is_null (self::$db)) { |
|
| 122 | + if (is_null(self::$db)) { |
|
| 123 | 123 | try { |
| 124 | - if (is_readable(self::getDbFileName ($database))) { |
|
| 125 | - self::$db = new PDO('sqlite:'. self::getDbFileName($database)); |
|
| 124 | + if (is_readable(self::getDbFileName($database))) { |
|
| 125 | + self::$db = new PDO('sqlite:' . self::getDbFileName($database)); |
|
| 126 | 126 | if (useNormAndUp()) { |
| 127 | 127 | self::$db->sqliteCreateFunction('normAndUp', 'normAndUp', 1); |
| 128 | 128 | } |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | } |
| 171 | 171 | $entry = new Entry(localize($table . '.title'), $id, |
| 172 | 172 | str_format(localize($numberOfString, $count), $count), 'text', |
| 173 | - array(new LinkNavigation('?page='.$pageId)), '', $count); |
|
| 173 | + array(new LinkNavigation('?page=' . $pageId)), '', $count); |
|
| 174 | 174 | return $entry; |
| 175 | 175 | } |
| 176 | 176 | |
@@ -80,7 +80,9 @@ discard block |
||
| 80 | 80 | { |
| 81 | 81 | global $config; |
| 82 | 82 | if (self::isMultipleDatabaseEnabled()) { |
| 83 | - if (is_null($database)) $database = GetUrlParam(DB, 0); |
|
| 83 | + if (is_null($database)) { |
|
| 84 | + $database = GetUrlParam(DB, 0); |
|
| 85 | + } |
|
| 84 | 86 | if (!is_null($database) && !preg_match('/^\d+$/', $database)) { |
| 85 | 87 | self::error($database); |
| 86 | 88 | } |
@@ -94,7 +96,9 @@ discard block |
||
| 94 | 96 | { |
| 95 | 97 | global $config; |
| 96 | 98 | if (self::isMultipleDatabaseEnabled()) { |
| 97 | - if (is_null($database)) $database = GetUrlParam(DB, 0); |
|
| 99 | + if (is_null($database)) { |
|
| 100 | + $database = GetUrlParam(DB, 0); |
|
| 101 | + } |
|
| 98 | 102 | if (!is_null($database) && !preg_match('/^\d+$/', $database)) { |
| 99 | 103 | self::error($database); |
| 100 | 104 | } |
@@ -180,8 +184,7 @@ discard block |
||
| 180 | 184 | |
| 181 | 185 | list (, $result) = self::executeQuery($query, $columns, '', $params, -1); |
| 182 | 186 | $entryArray = array(); |
| 183 | - while ($post = $result->fetchObject()) |
|
| 184 | - { |
|
| 187 | + while ($post = $result->fetchObject()) { |
|
| 185 | 188 | /* @var $instance Author|Tag|Serie|Publisher */ |
| 186 | 189 | |
| 187 | 190 | $instance = new $category($post); |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | |
| 36 | 36 | const COMPATIBILITY_XML_ALDIKO = 'aldiko'; |
| 37 | 37 | |
| 38 | - private static $db = NULL; |
|
| 38 | + private static $db = null; |
|
| 39 | 39 | |
| 40 | 40 | public static function isMultipleDatabaseEnabled() |
| 41 | 41 | { |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | } |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - public static function getDbName($database = NULL) |
|
| 79 | + public static function getDbName($database = null) |
|
| 80 | 80 | { |
| 81 | 81 | global $config; |
| 82 | 82 | if (self::isMultipleDatabaseEnabled()) { |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | return ''; |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - public static function getDbDirectory($database = NULL) |
|
| 93 | + public static function getDbDirectory($database = null) |
|
| 94 | 94 | { |
| 95 | 95 | global $config; |
| 96 | 96 | if (self::isMultipleDatabaseEnabled()) { |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | return $config['calibre_directory']; |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - public static function getDbFileName($database = NULL) |
|
| 107 | + public static function getDbFileName($database = null) |
|
| 108 | 108 | { |
| 109 | 109 | return self::getDbDirectory($database) .'metadata.db'; |
| 110 | 110 | } |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | throw new Exception('Database <' . $database . '> not found.'); |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - public static function getDb ($database = NULL) |
|
| 120 | + public static function getDb ($database = null) |
|
| 121 | 121 | { |
| 122 | 122 | if (is_null (self::$db)) { |
| 123 | 123 | try { |
@@ -151,22 +151,22 @@ discard block |
||
| 151 | 151 | |
| 152 | 152 | public static function clearDb() |
| 153 | 153 | { |
| 154 | - self::$db = NULL; |
|
| 154 | + self::$db = null; |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | - public static function executeQuerySingle($query, $database = NULL) |
|
| 157 | + public static function executeQuerySingle($query, $database = null) |
|
| 158 | 158 | { |
| 159 | 159 | return self::getDb($database)->query($query)->fetchColumn(); |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - public static function getCountGeneric($table, $id, $pageId, $numberOfString = NULL) |
|
| 162 | + public static function getCountGeneric($table, $id, $pageId, $numberOfString = null) |
|
| 163 | 163 | { |
| 164 | 164 | if (!$numberOfString) { |
| 165 | 165 | $numberOfString = $table . '.alphabetical'; |
| 166 | 166 | } |
| 167 | 167 | $count = self::executeQuerySingle('select count(*) from ' . $table); |
| 168 | 168 | if ($count == 0) { |
| 169 | - return NULL; |
|
| 169 | + return null; |
|
| 170 | 170 | } |
| 171 | 171 | $entry = new Entry(localize($table . '.title'), $id, |
| 172 | 172 | str_format(localize($numberOfString, $count), $count), 'text', |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | return $entryArray; |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | - public static function executeQuery($query, $columns, $filter, $params, $n, $database = NULL, $numberPerPage = NULL) |
|
| 200 | + public static function executeQuery($query, $columns, $filter, $params, $n, $database = null, $numberPerPage = null) |
|
| 201 | 201 | { |
| 202 | 202 | $totalResult = -1; |
| 203 | 203 | |
@@ -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; |