@@ -15,8 +15,9 @@ |
||
| 15 | 15 | |
| 16 | 16 | global $fetch_last_error_content; |
| 17 | 17 | |
| 18 | - if (!$res && $fetch_last_error_content) |
|
| 19 | - $res = $fetch_last_error_content; |
|
| 18 | + if (!$res && $fetch_last_error_content) { |
|
| 19 | + $res = $fetch_last_error_content; |
|
| 20 | + } |
|
| 20 | 21 | |
| 21 | 22 | $doc = new DOMDocument(); |
| 22 | 23 | |
@@ -22,8 +22,9 @@ |
||
| 22 | 22 | |
| 23 | 23 | public function hook_article_filter($article) { |
| 24 | 24 | |
| 25 | - if (!function_exists("curl_init") || ini_get("open_basedir")) |
|
| 26 | - return $article; |
|
| 25 | + if (!function_exists("curl_init") || ini_get("open_basedir")) { |
|
| 26 | + return $article; |
|
| 27 | + } |
|
| 27 | 28 | |
| 28 | 29 | $doc = new DOMDocument(); |
| 29 | 30 | $doc->loadHTML('<?xml encoding="UTF-8">' . $article["content"]); |
@@ -53,10 +53,11 @@ |
||
| 53 | 53 | |
| 54 | 54 | $ids = join(",", $ids); |
| 55 | 55 | |
| 56 | - if ($ids) |
|
| 57 | - return array("ref_id IN ($ids)", array()); |
|
| 58 | - else |
|
| 59 | - return array("ref_id = -1", array()); |
|
| 56 | + if ($ids) { |
|
| 57 | + return array("ref_id IN ($ids)", array()); |
|
| 58 | + } else { |
|
| 59 | + return array("ref_id = -1", array()); |
|
| 60 | + } |
|
| 60 | 61 | } |
| 61 | 62 | |
| 62 | 63 | public function api_version() { |
@@ -140,8 +140,9 @@ discard block |
||
| 140 | 140 | function load_tables() { |
| 141 | 141 | if (is_array($this->cache_translations) && |
| 142 | 142 | is_array($this->table_originals) && |
| 143 | - is_array($this->table_translations)) |
|
| 144 | - return; |
|
| 143 | + is_array($this->table_translations)) { |
|
| 144 | + return; |
|
| 145 | + } |
|
| 145 | 146 | |
| 146 | 147 | /* get original and translations tables */ |
| 147 | 148 | if (!is_array($this->table_originals)) { |
@@ -176,8 +177,9 @@ discard block |
||
| 176 | 177 | function get_original_string($num) { |
| 177 | 178 | $length = $this->table_originals[$num * 2 + 1]; |
| 178 | 179 | $offset = $this->table_originals[$num * 2 + 2]; |
| 179 | - if (! $length) |
|
| 180 | - return ''; |
|
| 180 | + if (! $length) { |
|
| 181 | + return ''; |
|
| 182 | + } |
|
| 181 | 183 | $this->STREAM->seekto($offset); |
| 182 | 184 | $data = $this->STREAM->read($length); |
| 183 | 185 | return (string)$data; |
@@ -193,8 +195,9 @@ discard block |
||
| 193 | 195 | function get_translation_string($num) { |
| 194 | 196 | $length = $this->table_translations[$num * 2 + 1]; |
| 195 | 197 | $offset = $this->table_translations[$num * 2 + 2]; |
| 196 | - if (! $length) |
|
| 197 | - return ''; |
|
| 198 | + if (! $length) { |
|
| 199 | + return ''; |
|
| 200 | + } |
|
| 198 | 201 | $this->STREAM->seekto($offset); |
| 199 | 202 | $data = $this->STREAM->read($length); |
| 200 | 203 | return (string)$data; |
@@ -218,10 +221,11 @@ discard block |
||
| 218 | 221 | if (abs($start - $end) <= 1) { |
| 219 | 222 | // We're done, now we either found the string, or it doesn't exist |
| 220 | 223 | $txt = $this->get_original_string($start); |
| 221 | - if ($string == $txt) |
|
| 222 | - return $start; |
|
| 223 | - else |
|
| 224 | - return -1; |
|
| 224 | + if ($string == $txt) { |
|
| 225 | + return $start; |
|
| 226 | + } else { |
|
| 227 | + return -1; |
|
| 228 | + } |
|
| 225 | 229 | } else if ($start > $end) { |
| 226 | 230 | // start > end -> turn around and start over |
| 227 | 231 | return $this->find_string($string, $end, $start); |
@@ -229,15 +233,16 @@ discard block |
||
| 229 | 233 | // Divide table in two parts |
| 230 | 234 | $half = (int)(($start + $end) / 2); |
| 231 | 235 | $cmp = strcmp($string, $this->get_original_string($half)); |
| 232 | - if ($cmp == 0) |
|
| 233 | - // string is exactly in the middle => return it |
|
| 236 | + if ($cmp == 0) { |
|
| 237 | + // string is exactly in the middle => return it |
|
| 234 | 238 | return $half; |
| 235 | - else if ($cmp < 0) |
|
| 236 | - // The string is in the upper half |
|
| 239 | + } else if ($cmp < 0) { |
|
| 240 | + // The string is in the upper half |
|
| 237 | 241 | return $this->find_string($string, $start, $half); |
| 238 | - else |
|
| 239 | - // The string is in the lower half |
|
| 242 | + } else { |
|
| 243 | + // The string is in the lower half |
|
| 240 | 244 | return $this->find_string($string, $half, $end); |
| 245 | + } |
|
| 241 | 246 | } |
| 242 | 247 | } |
| 243 | 248 | |
@@ -249,23 +254,26 @@ discard block |
||
| 249 | 254 | * @return string translated string (or original, if not found) |
| 250 | 255 | */ |
| 251 | 256 | function translate($string) { |
| 252 | - if ($this->short_circuit) |
|
| 253 | - return $string; |
|
| 257 | + if ($this->short_circuit) { |
|
| 258 | + return $string; |
|
| 259 | + } |
|
| 254 | 260 | $this->load_tables(); |
| 255 | 261 | |
| 256 | 262 | if ($this->enable_cache) { |
| 257 | 263 | // Caching enabled, get translated string from cache |
| 258 | - if (array_key_exists($string, $this->cache_translations)) |
|
| 259 | - return $this->cache_translations[$string]; |
|
| 260 | - else |
|
| 261 | - return $string; |
|
| 264 | + if (array_key_exists($string, $this->cache_translations)) { |
|
| 265 | + return $this->cache_translations[$string]; |
|
| 266 | + } else { |
|
| 267 | + return $string; |
|
| 268 | + } |
|
| 262 | 269 | } else { |
| 263 | 270 | // Caching not enabled, try to find string |
| 264 | 271 | $num = $this->find_string($string); |
| 265 | - if ($num == -1) |
|
| 266 | - return $string; |
|
| 267 | - else |
|
| 268 | - return $this->get_translation_string($num); |
|
| 272 | + if ($num == -1) { |
|
| 273 | + return $string; |
|
| 274 | + } else { |
|
| 275 | + return $this->get_translation_string($num); |
|
| 276 | + } |
|
| 269 | 277 | } |
| 270 | 278 | } |
| 271 | 279 | |
@@ -311,10 +319,11 @@ discard block |
||
| 311 | 319 | * @return string verbatim plural form header field |
| 312 | 320 | */ |
| 313 | 321 | function extract_plural_forms_header_from_po_header($header) { |
| 314 | - if (preg_match("/(^|\n)plural-forms: ([^\n]*)\n/i", $header, $regs)) |
|
| 315 | - $expr = $regs[2]; |
|
| 316 | - else |
|
| 317 | - $expr = "nplurals=2; plural=n == 1 ? 0 : 1;"; |
|
| 322 | + if (preg_match("/(^|\n)plural-forms: ([^\n]*)\n/i", $header, $regs)) { |
|
| 323 | + $expr = $regs[2]; |
|
| 324 | + } else { |
|
| 325 | + $expr = "nplurals=2; plural=n == 1 ? 0 : 1;"; |
|
| 326 | + } |
|
| 318 | 327 | return $expr; |
| 319 | 328 | } |
| 320 | 329 | |
@@ -363,7 +372,9 @@ discard block |
||
| 363 | 372 | $plural = 0; |
| 364 | 373 | |
| 365 | 374 | eval("$string"); |
| 366 | - if ($plural >= $total) $plural = $total - 1; |
|
| 375 | + if ($plural >= $total) { |
|
| 376 | + $plural = $total - 1; |
|
| 377 | + } |
|
| 367 | 378 | return $plural; |
| 368 | 379 | } |
| 369 | 380 | |
@@ -378,10 +389,11 @@ discard block |
||
| 378 | 389 | */ |
| 379 | 390 | function ngettext($single, $plural, $number) { |
| 380 | 391 | if ($this->short_circuit) { |
| 381 | - if ($number != 1) |
|
| 382 | - return $plural; |
|
| 383 | - else |
|
| 384 | - return $single; |
|
| 392 | + if ($number != 1) { |
|
| 393 | + return $plural; |
|
| 394 | + } else { |
|
| 395 | + return $single; |
|
| 396 | + } |
|
| 385 | 397 | } |
| 386 | 398 | |
| 387 | 399 | // find out the appropriate form |
@@ -80,32 +80,45 @@ discard block |
||
| 80 | 80 | ."(?:@(?P<modifier>[-A-Za-z0-9_]+))?$/", // @ modifier |
| 81 | 81 | $locale, $matches)) { |
| 82 | 82 | |
| 83 | - if (isset($matches["lang"])) $lang = $matches["lang"]; |
|
| 84 | - if (isset($matches["country"])) $country = $matches["country"]; |
|
| 85 | - if (isset($matches["charset"])) $charset = $matches["charset"]; |
|
| 86 | - if (isset($matches["modifier"])) $modifier = $matches["modifier"]; |
|
| 83 | + if (isset($matches["lang"])) { |
|
| 84 | + $lang = $matches["lang"]; |
|
| 85 | + } |
|
| 86 | + if (isset($matches["country"])) { |
|
| 87 | + $country = $matches["country"]; |
|
| 88 | + } |
|
| 89 | + if (isset($matches["charset"])) { |
|
| 90 | + $charset = $matches["charset"]; |
|
| 91 | + } |
|
| 92 | + if (isset($matches["modifier"])) { |
|
| 93 | + $modifier = $matches["modifier"]; |
|
| 94 | + } |
|
| 87 | 95 | |
| 88 | 96 | if ($modifier) { |
| 89 | 97 | if ($country) { |
| 90 | - if ($charset) |
|
| 91 | - array_push($locale_names, "${lang}_$country.$charset@$modifier"); |
|
| 98 | + if ($charset) { |
|
| 99 | + array_push($locale_names, "${lang}_$country.$charset@$modifier"); |
|
| 100 | + } |
|
| 92 | 101 | array_push($locale_names, "${lang}_$country@$modifier"); |
| 93 | - } elseif ($charset) |
|
| 94 | - array_push($locale_names, "${lang}.$charset@$modifier"); |
|
| 102 | + } elseif ($charset) { |
|
| 103 | + array_push($locale_names, "${lang}.$charset@$modifier"); |
|
| 104 | + } |
|
| 95 | 105 | array_push($locale_names, "$lang@$modifier"); |
| 96 | 106 | } |
| 97 | 107 | if ($country) { |
| 98 | - if ($charset) |
|
| 99 | - array_push($locale_names, "${lang}_$country.$charset"); |
|
| 108 | + if ($charset) { |
|
| 109 | + array_push($locale_names, "${lang}_$country.$charset"); |
|
| 110 | + } |
|
| 100 | 111 | array_push($locale_names, "${lang}_$country"); |
| 101 | - } elseif ($charset) |
|
| 102 | - array_push($locale_names, "${lang}.$charset"); |
|
| 112 | + } elseif ($charset) { |
|
| 113 | + array_push($locale_names, "${lang}.$charset"); |
|
| 114 | + } |
|
| 103 | 115 | array_push($locale_names, $lang); |
| 104 | 116 | } |
| 105 | 117 | |
| 106 | 118 | // If the locale name doesn't match POSIX style, just include it as-is. |
| 107 | - if (!in_array($locale, $locale_names)) |
|
| 108 | - array_push($locale_names, $locale); |
|
| 119 | + if (!in_array($locale, $locale_names)) { |
|
| 120 | + array_push($locale_names, $locale); |
|
| 121 | + } |
|
| 109 | 122 | } |
| 110 | 123 | return $locale_names; |
| 111 | 124 | } |
@@ -115,7 +128,9 @@ discard block |
||
| 115 | 128 | */ |
| 116 | 129 | function _get_reader($domain=null, $category=5, $enable_cache=true) { |
| 117 | 130 | global $text_domains, $default_domain, $LC_CATEGORIES; |
| 118 | - if (!isset($domain)) $domain = $default_domain; |
|
| 131 | + if (!isset($domain)) { |
|
| 132 | + $domain = $default_domain; |
|
| 133 | + } |
|
| 119 | 134 | if (!isset($text_domains[$domain]->l10n)) { |
| 120 | 135 | // get the current locale |
| 121 | 136 | $locale = _setlocale(LC_MESSAGES, 0); |
@@ -156,8 +171,9 @@ discard block |
||
| 156 | 171 | */ |
| 157 | 172 | function _check_locale_and_function($function=false) { |
| 158 | 173 | global $EMULATEGETTEXT; |
| 159 | - if ($function and !function_exists($function)) |
|
| 160 | - return false; |
|
| 174 | + if ($function and !function_exists($function)) { |
|
| 175 | + return false; |
|
| 176 | + } |
|
| 161 | 177 | return !$EMULATEGETTEXT; |
| 162 | 178 | } |
| 163 | 179 | |
@@ -166,7 +182,9 @@ discard block |
||
| 166 | 182 | */ |
| 167 | 183 | function _get_codeset($domain=null) { |
| 168 | 184 | global $text_domains, $default_domain, $LC_CATEGORIES; |
| 169 | - if (!isset($domain)) $domain = $default_domain; |
|
| 185 | + if (!isset($domain)) { |
|
| 186 | + $domain = $default_domain; |
|
| 187 | + } |
|
| 170 | 188 | return (isset($text_domains[$domain]->codeset))? $text_domains[$domain]->codeset : ini_get('mbstring.internal_encoding'); |
| 171 | 189 | } |
| 172 | 190 | |
@@ -177,8 +195,9 @@ discard block |
||
| 177 | 195 | $target_encoding = _get_codeset(); |
| 178 | 196 | if (function_exists("mb_detect_encoding")) { |
| 179 | 197 | $source_encoding = mb_detect_encoding($text); |
| 180 | - if ($source_encoding != $target_encoding) |
|
| 181 | - $text = mb_convert_encoding($text, $target_encoding, $source_encoding); |
|
| 198 | + if ($source_encoding != $target_encoding) { |
|
| 199 | + $text = mb_convert_encoding($text, $target_encoding, $source_encoding); |
|
| 200 | + } |
|
| 182 | 201 | } |
| 183 | 202 | return $text; |
| 184 | 203 | } |
@@ -190,11 +209,13 @@ discard block |
||
| 190 | 209 | * Returns passed in $locale, or environment variable $LANG if $locale == ''. |
| 191 | 210 | */ |
| 192 | 211 | function _get_default_locale($locale) { |
| 193 | - if ($locale == '') // emulate variable support |
|
| 212 | + if ($locale == '') { |
|
| 213 | + // emulate variable support |
|
| 194 | 214 | return getenv('LANG'); |
| 195 | - else |
|
| 196 | - return $locale; |
|
| 197 | -} |
|
| 215 | + } else { |
|
| 216 | + return $locale; |
|
| 217 | + } |
|
| 218 | + } |
|
| 198 | 219 | |
| 199 | 220 | /** |
| 200 | 221 | * Sets a requested locale, if needed emulates it. |
@@ -202,12 +223,13 @@ discard block |
||
| 202 | 223 | function _setlocale($category, $locale) { |
| 203 | 224 | global $CURRENTLOCALE, $EMULATEGETTEXT; |
| 204 | 225 | if ($locale === 0) { // use === to differentiate between string "0" |
| 205 | - if ($CURRENTLOCALE != '') |
|
| 206 | - return $CURRENTLOCALE; |
|
| 207 | - else |
|
| 208 | - // obey LANG variable, maybe extend to support all of LC_* vars |
|
| 226 | + if ($CURRENTLOCALE != '') { |
|
| 227 | + return $CURRENTLOCALE; |
|
| 228 | + } else { |
|
| 229 | + // obey LANG variable, maybe extend to support all of LC_* vars |
|
| 209 | 230 | // even if we tried to read locale without setting it first |
| 210 | 231 | return _setlocale($category, $CURRENTLOCALE); |
| 232 | + } |
|
| 211 | 233 | } else { |
| 212 | 234 | if (function_exists('setlocale')) { |
| 213 | 235 | $ret = setlocale($category, $locale); |
@@ -241,11 +263,13 @@ discard block |
||
| 241 | 263 | global $text_domains; |
| 242 | 264 | // ensure $path ends with a slash ('/' should work for both, but lets still play nice) |
| 243 | 265 | if (substr(php_uname(), 0, 7) == "Windows") { |
| 244 | - if ($path[strlen($path)-1] != '\\' and $path[strlen($path)-1] != '/') |
|
| 245 | - $path .= '\\'; |
|
| 266 | + if ($path[strlen($path)-1] != '\\' and $path[strlen($path)-1] != '/') { |
|
| 267 | + $path .= '\\'; |
|
| 268 | + } |
|
| 246 | 269 | } else { |
| 247 | - if ($path[strlen($path)-1] != '/') |
|
| 248 | - $path .= '/'; |
|
| 270 | + if ($path[strlen($path)-1] != '/') { |
|
| 271 | + $path .= '/'; |
|
| 272 | + } |
|
| 249 | 273 | } |
| 250 | 274 | if (!array_key_exists($domain, $text_domains)) { |
| 251 | 275 | // Initialize an empty domain object. |
@@ -384,96 +408,126 @@ discard block |
||
| 384 | 408 | } |
| 385 | 409 | |
| 386 | 410 | function T_bindtextdomain($domain, $path) { |
| 387 | - if (_check_locale_and_function()) return bindtextdomain($domain, $path); |
|
| 388 | - else return _bindtextdomain($domain, $path); |
|
| 389 | -} |
|
| 411 | + if (_check_locale_and_function()) { |
|
| 412 | + return bindtextdomain($domain, $path); |
|
| 413 | + } else { |
|
| 414 | + return _bindtextdomain($domain, $path); |
|
| 415 | + } |
|
| 416 | + } |
|
| 390 | 417 | function T_bind_textdomain_codeset($domain, $codeset) { |
| 391 | 418 | // bind_textdomain_codeset is available only in PHP 4.2.0+ |
| 392 | - if (_check_locale_and_function('bind_textdomain_codeset')) |
|
| 393 | - return bind_textdomain_codeset($domain, $codeset); |
|
| 394 | - else return _bind_textdomain_codeset($domain, $codeset); |
|
| 395 | -} |
|
| 419 | + if (_check_locale_and_function('bind_textdomain_codeset')) { |
|
| 420 | + return bind_textdomain_codeset($domain, $codeset); |
|
| 421 | + } else { |
|
| 422 | + return _bind_textdomain_codeset($domain, $codeset); |
|
| 423 | + } |
|
| 424 | + } |
|
| 396 | 425 | function T_textdomain($domain) { |
| 397 | - if (_check_locale_and_function()) return textdomain($domain); |
|
| 398 | - else return _textdomain($domain); |
|
| 399 | -} |
|
| 426 | + if (_check_locale_and_function()) { |
|
| 427 | + return textdomain($domain); |
|
| 428 | + } else { |
|
| 429 | + return _textdomain($domain); |
|
| 430 | + } |
|
| 431 | + } |
|
| 400 | 432 | function T_gettext($msgid) { |
| 401 | - if (_check_locale_and_function()) return gettext($msgid); |
|
| 402 | - else return _gettext($msgid); |
|
| 403 | -} |
|
| 433 | + if (_check_locale_and_function()) { |
|
| 434 | + return gettext($msgid); |
|
| 435 | + } else { |
|
| 436 | + return _gettext($msgid); |
|
| 437 | + } |
|
| 438 | + } |
|
| 404 | 439 | function T_($msgid) { |
| 405 | - if (_check_locale_and_function()) return _($msgid); |
|
| 440 | + if (_check_locale_and_function()) { |
|
| 441 | + return _($msgid); |
|
| 442 | + } |
|
| 406 | 443 | return __($msgid); |
| 407 | 444 | } |
| 408 | 445 | function T_ngettext($singular, $plural, $number) { |
| 409 | - if (_check_locale_and_function()) |
|
| 410 | - return ngettext($singular, $plural, $number); |
|
| 411 | - else return _ngettext($singular, $plural, $number); |
|
| 412 | -} |
|
| 446 | + if (_check_locale_and_function()) { |
|
| 447 | + return ngettext($singular, $plural, $number); |
|
| 448 | + } else { |
|
| 449 | + return _ngettext($singular, $plural, $number); |
|
| 450 | + } |
|
| 451 | + } |
|
| 413 | 452 | function T_dgettext($domain, $msgid) { |
| 414 | - if (_check_locale_and_function()) return dgettext($domain, $msgid); |
|
| 415 | - else return _dgettext($domain, $msgid); |
|
| 416 | -} |
|
| 453 | + if (_check_locale_and_function()) { |
|
| 454 | + return dgettext($domain, $msgid); |
|
| 455 | + } else { |
|
| 456 | + return _dgettext($domain, $msgid); |
|
| 457 | + } |
|
| 458 | + } |
|
| 417 | 459 | function T_dngettext($domain, $singular, $plural, $number) { |
| 418 | - if (_check_locale_and_function()) |
|
| 419 | - return dngettext($domain, $singular, $plural, $number); |
|
| 420 | - else return _dngettext($domain, $singular, $plural, $number); |
|
| 421 | -} |
|
| 460 | + if (_check_locale_and_function()) { |
|
| 461 | + return dngettext($domain, $singular, $plural, $number); |
|
| 462 | + } else { |
|
| 463 | + return _dngettext($domain, $singular, $plural, $number); |
|
| 464 | + } |
|
| 465 | + } |
|
| 422 | 466 | function T_dcgettext($domain, $msgid, $category) { |
| 423 | - if (_check_locale_and_function()) |
|
| 424 | - return dcgettext($domain, $msgid, $category); |
|
| 425 | - else return _dcgettext($domain, $msgid, $category); |
|
| 426 | -} |
|
| 467 | + if (_check_locale_and_function()) { |
|
| 468 | + return dcgettext($domain, $msgid, $category); |
|
| 469 | + } else { |
|
| 470 | + return _dcgettext($domain, $msgid, $category); |
|
| 471 | + } |
|
| 472 | + } |
|
| 427 | 473 | function T_dcngettext($domain, $singular, $plural, $number, $category) { |
| 428 | - if (_check_locale_and_function()) |
|
| 429 | - return dcngettext($domain, $singular, $plural, $number, $category); |
|
| 430 | - else return _dcngettext($domain, $singular, $plural, $number, $category); |
|
| 431 | -} |
|
| 474 | + if (_check_locale_and_function()) { |
|
| 475 | + return dcngettext($domain, $singular, $plural, $number, $category); |
|
| 476 | + } else { |
|
| 477 | + return _dcngettext($domain, $singular, $plural, $number, $category); |
|
| 478 | + } |
|
| 479 | + } |
|
| 432 | 480 | |
| 433 | 481 | function T_pgettext($context, $msgid) { |
| 434 | - if (_check_locale_and_function('pgettext')) |
|
| 435 | - return pgettext($context, $msgid); |
|
| 436 | - else |
|
| 437 | - return _pgettext($context, $msgid); |
|
| 438 | -} |
|
| 482 | + if (_check_locale_and_function('pgettext')) { |
|
| 483 | + return pgettext($context, $msgid); |
|
| 484 | + } else { |
|
| 485 | + return _pgettext($context, $msgid); |
|
| 486 | + } |
|
| 487 | + } |
|
| 439 | 488 | |
| 440 | 489 | function T_dpgettext($domain, $context, $msgid) { |
| 441 | - if (_check_locale_and_function('dpgettext')) |
|
| 442 | - return dpgettext($domain, $context, $msgid); |
|
| 443 | - else |
|
| 444 | - return _dpgettext($domain, $context, $msgid); |
|
| 445 | -} |
|
| 490 | + if (_check_locale_and_function('dpgettext')) { |
|
| 491 | + return dpgettext($domain, $context, $msgid); |
|
| 492 | + } else { |
|
| 493 | + return _dpgettext($domain, $context, $msgid); |
|
| 494 | + } |
|
| 495 | + } |
|
| 446 | 496 | |
| 447 | 497 | function T_dcpgettext($domain, $context, $msgid, $category) { |
| 448 | - if (_check_locale_and_function('dcpgettext')) |
|
| 449 | - return dcpgettext($domain, $context, $msgid, $category); |
|
| 450 | - else |
|
| 451 | - return _dcpgettext($domain, $context, $msgid, $category); |
|
| 452 | -} |
|
| 498 | + if (_check_locale_and_function('dcpgettext')) { |
|
| 499 | + return dcpgettext($domain, $context, $msgid, $category); |
|
| 500 | + } else { |
|
| 501 | + return _dcpgettext($domain, $context, $msgid, $category); |
|
| 502 | + } |
|
| 503 | + } |
|
| 453 | 504 | |
| 454 | 505 | function T_npgettext($context, $singular, $plural, $number) { |
| 455 | - if (_check_locale_and_function('npgettext')) |
|
| 456 | - return npgettext($context, $singular, $plural, $number); |
|
| 457 | - else |
|
| 458 | - return _npgettext($context, $singular, $plural, $number); |
|
| 459 | -} |
|
| 506 | + if (_check_locale_and_function('npgettext')) { |
|
| 507 | + return npgettext($context, $singular, $plural, $number); |
|
| 508 | + } else { |
|
| 509 | + return _npgettext($context, $singular, $plural, $number); |
|
| 510 | + } |
|
| 511 | + } |
|
| 460 | 512 | |
| 461 | 513 | function T_dnpgettext($domain, $context, $singular, $plural, $number) { |
| 462 | - if (_check_locale_and_function('dnpgettext')) |
|
| 463 | - return dnpgettext($domain, $context, $singular, $plural, $number); |
|
| 464 | - else |
|
| 465 | - return _dnpgettext($domain, $context, $singular, $plural, $number); |
|
| 466 | -} |
|
| 514 | + if (_check_locale_and_function('dnpgettext')) { |
|
| 515 | + return dnpgettext($domain, $context, $singular, $plural, $number); |
|
| 516 | + } else { |
|
| 517 | + return _dnpgettext($domain, $context, $singular, $plural, $number); |
|
| 518 | + } |
|
| 519 | + } |
|
| 467 | 520 | |
| 468 | 521 | function T_dcnpgettext($domain, $context, $singular, $plural, |
| 469 | 522 | $number, $category) { |
| 470 | - if (_check_locale_and_function('dcnpgettext')) |
|
| 471 | - return dcnpgettext($domain, $context, $singular, |
|
| 523 | + if (_check_locale_and_function('dcnpgettext')) { |
|
| 524 | + return dcnpgettext($domain, $context, $singular, |
|
| 472 | 525 | $plural, $number, $category); |
| 473 | - else |
|
| 474 | - return _dcnpgettext($domain, $context, $singular, |
|
| 526 | + } else { |
|
| 527 | + return _dcnpgettext($domain, $context, $singular, |
|
| 475 | 528 | $plural, $number, $category); |
| 476 | -} |
|
| 529 | + } |
|
| 530 | + } |
|
| 477 | 531 | |
| 478 | 532 | |
| 479 | 533 | |
@@ -57,16 +57,18 @@ discard block |
||
| 57 | 57 | function read($bytes) { |
| 58 | 58 | $data = substr($this->_str, $this->_pos, $bytes); |
| 59 | 59 | $this->_pos += $bytes; |
| 60 | - if (strlen($this->_str)<$this->_pos) |
|
| 61 | - $this->_pos = strlen($this->_str); |
|
| 60 | + if (strlen($this->_str)<$this->_pos) { |
|
| 61 | + $this->_pos = strlen($this->_str); |
|
| 62 | + } |
|
| 62 | 63 | |
| 63 | 64 | return $data; |
| 64 | 65 | } |
| 65 | 66 | |
| 66 | 67 | function seekto($pos) { |
| 67 | 68 | $this->_pos = $pos; |
| 68 | - if (strlen($this->_str)<$this->_pos) |
|
| 69 | - $this->_pos = strlen($this->_str); |
|
| 69 | + if (strlen($this->_str)<$this->_pos) { |
|
| 70 | + $this->_pos = strlen($this->_str); |
|
| 71 | + } |
|
| 70 | 72 | return $this->_pos; |
| 71 | 73 | } |
| 72 | 74 | |
@@ -117,7 +119,9 @@ discard block |
||
| 117 | 119 | $this->_pos = ftell($this->_fd); |
| 118 | 120 | |
| 119 | 121 | return $data; |
| 120 | - } else return ''; |
|
| 122 | + } else { |
|
| 123 | + return ''; |
|
| 124 | + } |
|
| 121 | 125 | } |
| 122 | 126 | |
| 123 | 127 | function seekto($pos) { |
@@ -47,8 +47,9 @@ discard block |
||
| 47 | 47 | //---------------------------------------------------------------------- |
| 48 | 48 | public static function isdigitat($str, $pos) |
| 49 | 49 | {
|
| 50 | - if ($pos >= strlen($str)) |
|
| 51 | - return false; |
|
| 50 | + if ($pos >= strlen($str)) { |
|
| 51 | + return false; |
|
| 52 | + } |
|
| 52 | 53 | |
| 53 | 54 | return ((ord($str[$pos]) >= ord('0'))&&(ord($str[$pos]) <= ord('9')));
|
| 54 | 55 | } |
@@ -56,8 +57,9 @@ discard block |
||
| 56 | 57 | //---------------------------------------------------------------------- |
| 57 | 58 | public static function isalnumat($str, $pos) |
| 58 | 59 | {
|
| 59 | - if ($pos >= strlen($str)) |
|
| 60 | - return false; |
|
| 60 | + if ($pos >= strlen($str)) { |
|
| 61 | + return false; |
|
| 62 | + } |
|
| 61 | 63 | |
| 62 | 64 | return (QRinput::lookAnTable(ord($str[$pos])) >= 0); |
| 63 | 65 | } |
@@ -65,8 +67,9 @@ discard block |
||
| 65 | 67 | //---------------------------------------------------------------------- |
| 66 | 68 | public function identifyMode($pos) |
| 67 | 69 | {
|
| 68 | - if ($pos >= strlen($this->dataStr)) |
|
| 69 | - return QR_MODE_NUL; |
|
| 70 | + if ($pos >= strlen($this->dataStr)) { |
|
| 71 | + return QR_MODE_NUL; |
|
| 72 | + } |
|
| 70 | 73 | |
| 71 | 74 | $c = $this->dataStr[$pos]; |
| 72 | 75 | |
@@ -120,8 +123,9 @@ discard block |
||
| 120 | 123 | } |
| 121 | 124 | |
| 122 | 125 | $ret = $this->input->append(QR_MODE_NUM, $run, str_split($this->dataStr)); |
| 123 | - if($ret < 0) |
|
| 124 | - return -1; |
|
| 126 | + if($ret < 0) { |
|
| 127 | + return -1; |
|
| 128 | + } |
|
| 125 | 129 | |
| 126 | 130 | return $run; |
| 127 | 131 | } |
@@ -167,8 +171,9 @@ discard block |
||
| 167 | 171 | } |
| 168 | 172 | |
| 169 | 173 | $ret = $this->input->append(QR_MODE_AN, $run, str_split($this->dataStr)); |
| 170 | - if($ret < 0) |
|
| 171 | - return -1; |
|
| 174 | + if($ret < 0) { |
|
| 175 | + return -1; |
|
| 176 | + } |
|
| 172 | 177 | |
| 173 | 178 | return $run; |
| 174 | 179 | } |
@@ -183,8 +188,9 @@ discard block |
||
| 183 | 188 | } |
| 184 | 189 | |
| 185 | 190 | $ret = $this->input->append(QR_MODE_KANJI, $p, str_split($this->dataStr)); |
| 186 | - if($ret < 0) |
|
| 187 | - return -1; |
|
| 191 | + if($ret < 0) { |
|
| 192 | + return -1; |
|
| 193 | + } |
|
| 188 | 194 | |
| 189 | 195 | return $ret; |
| 190 | 196 | } |
@@ -238,8 +244,9 @@ discard block |
||
| 238 | 244 | $run = $p; |
| 239 | 245 | $ret = $this->input->append(QR_MODE_8, $run, str_split($this->dataStr)); |
| 240 | 246 | |
| 241 | - if($ret < 0) |
|
| 242 | - return -1; |
|
| 247 | + if($ret < 0) { |
|
| 248 | + return -1; |
|
| 249 | + } |
|
| 243 | 250 | |
| 244 | 251 | return $run; |
| 245 | 252 | } |
@@ -249,8 +256,9 @@ discard block |
||
| 249 | 256 | {
|
| 250 | 257 | while (strlen($this->dataStr) > 0) |
| 251 | 258 | {
|
| 252 | - if($this->dataStr == '') |
|
| 253 | - return 0; |
|
| 259 | + if($this->dataStr == '') { |
|
| 260 | + return 0; |
|
| 261 | + } |
|
| 254 | 262 | |
| 255 | 263 | $mode = $this->identifyMode(0); |
| 256 | 264 | |
@@ -258,16 +266,22 @@ discard block |
||
| 258 | 266 | case QR_MODE_NUM: $length = $this->eatNum(); break; |
| 259 | 267 | case QR_MODE_AN: $length = $this->eatAn(); break; |
| 260 | 268 | case QR_MODE_KANJI: |
| 261 | - if ($this->modeHint == QR_MODE_KANJI) |
|
| 262 | - $length = $this->eatKanji(); |
|
| 263 | - else $length = $this->eat8(); |
|
| 269 | + if ($this->modeHint == QR_MODE_KANJI) { |
|
| 270 | + $length = $this->eatKanji(); |
|
| 271 | + } else { |
|
| 272 | + $length = $this->eat8(); |
|
| 273 | + } |
|
| 264 | 274 | break; |
| 265 | 275 | default: $length = $this->eat8(); break; |
| 266 | 276 | |
| 267 | 277 | } |
| 268 | 278 | |
| 269 | - if($length == 0) return 0; |
|
| 270 | - if($length < 0) return -1; |
|
| 279 | + if($length == 0) { |
|
| 280 | + return 0; |
|
| 281 | + } |
|
| 282 | + if($length < 0) { |
|
| 283 | + return -1; |
|
| 284 | + } |
|
| 271 | 285 | |
| 272 | 286 | $this->dataStr = substr($this->dataStr, $length); |
| 273 | 287 | } |
@@ -303,8 +317,9 @@ discard block |
||
| 303 | 317 | |
| 304 | 318 | $split = new QRsplit($string, $input, $modeHint); |
| 305 | 319 | |
| 306 | - if(!$casesensitive) |
|
| 307 | - $split->toUpper(); |
|
| 320 | + if(!$casesensitive) { |
|
| 321 | + $split->toUpper(); |
|
| 322 | + } |
|
| 308 | 323 | |
| 309 | 324 | return $split->splitString(); |
| 310 | 325 | } |
@@ -197,8 +197,9 @@ discard block |
||
| 197 | 197 | {
|
| 198 | 198 | $bits = 0; |
| 199 | 199 | |
| 200 | - if($version == 0) |
|
| 201 | - $version = 1; |
|
| 200 | + if($version == 0) { |
|
| 201 | + $version = 1; |
|
| 202 | + } |
|
| 202 | 203 | |
| 203 | 204 | switch($this->mode) {
|
| 204 | 205 | case QR_MODE_NUM: $bits = QRinput::estimateBitsModeNum($this->size); break; |
@@ -257,8 +258,9 @@ discard block |
||
| 257 | 258 | break; |
| 258 | 259 | } |
| 259 | 260 | |
| 260 | - if($ret < 0) |
|
| 261 | - return -1; |
|
| 261 | + if($ret < 0) { |
|
| 262 | + return -1; |
|
| 263 | + } |
|
| 262 | 264 | } |
| 263 | 265 | |
| 264 | 266 | return $this->bstream->size(); |
@@ -475,8 +477,9 @@ discard block |
||
| 475 | 477 | //---------------------------------------------------------------------- |
| 476 | 478 | public static function checkModeKanji($size, $data) |
| 477 | 479 | {
|
| 478 | - if($size & 1) |
|
| 479 | - return false; |
|
| 480 | + if($size & 1) { |
|
| 481 | + return false; |
|
| 482 | + } |
|
| 480 | 483 | |
| 481 | 484 | for($i=0; $i<$size; $i+=2) {
|
| 482 | 485 | $val = (ord($data[$i]) << 8) | ord($data[$i+1]); |
@@ -496,8 +499,9 @@ discard block |
||
| 496 | 499 | |
| 497 | 500 | public static function check($mode, $size, $data) |
| 498 | 501 | {
|
| 499 | - if($size <= 0) |
|
| 500 | - return false; |
|
| 502 | + if($size <= 0) { |
|
| 503 | + return false; |
|
| 504 | + } |
|
| 501 | 505 | |
| 502 | 506 | switch($mode) {
|
| 503 | 507 | case QR_MODE_NUM: return self::checkModeNum($size, $data); break; |
@@ -562,8 +566,9 @@ discard block |
||
| 562 | 566 | $chunks = (int)($payload / 11); |
| 563 | 567 | $remain = $payload - $chunks * 11; |
| 564 | 568 | $size = $chunks * 2; |
| 565 | - if($remain >= 6) |
|
| 566 | - $size++; |
|
| 569 | + if($remain >= 6) { |
|
| 570 | + $size++; |
|
| 571 | + } |
|
| 567 | 572 | break; |
| 568 | 573 | case QR_MODE_8: |
| 569 | 574 | $size = (int)($payload / 8); |
@@ -580,8 +585,12 @@ discard block |
||
| 580 | 585 | } |
| 581 | 586 | |
| 582 | 587 | $maxsize = QRspec::maximumWords($mode, $version); |
| 583 | - if($size < 0) $size = 0; |
|
| 584 | - if($size > $maxsize) $size = $maxsize; |
|
| 588 | + if($size < 0) { |
|
| 589 | + $size = 0; |
|
| 590 | + } |
|
| 591 | + if($size > $maxsize) { |
|
| 592 | + $size = $maxsize; |
|
| 593 | + } |
|
| 585 | 594 | |
| 586 | 595 | return $size; |
| 587 | 596 | } |
@@ -594,8 +603,9 @@ discard block |
||
| 594 | 603 | foreach($this->items as $item) {
|
| 595 | 604 | $bits = $item->encodeBitStream($this->version); |
| 596 | 605 | |
| 597 | - if($bits < 0) |
|
| 598 | - return -1; |
|
| 606 | + if($bits < 0) { |
|
| 607 | + return -1; |
|
| 608 | + } |
|
| 599 | 609 | |
| 600 | 610 | $total += $bits; |
| 601 | 611 | } |
@@ -614,8 +624,9 @@ discard block |
||
| 614 | 624 | for(;;) {
|
| 615 | 625 | $bits = $this->createBitStream(); |
| 616 | 626 | |
| 617 | - if($bits < 0) |
|
| 618 | - return -1; |
|
| 627 | + if($bits < 0) { |
|
| 628 | + return -1; |
|
| 629 | + } |
|
| 619 | 630 | |
| 620 | 631 | $ver = QRspec::getMinimumVersion((int)(($bits + 7) / 8), $this->level); |
| 621 | 632 | if($ver < 0) {
|
@@ -652,8 +663,9 @@ discard block |
||
| 652 | 663 | $padding = new QRbitstream(); |
| 653 | 664 | $ret = $padding->appendNum($words * 8 - $bits + 4, 0); |
| 654 | 665 | |
| 655 | - if($ret < 0) |
|
| 656 | - return $ret; |
|
| 666 | + if($ret < 0) { |
|
| 667 | + return $ret; |
|
| 668 | + } |
|
| 657 | 669 | |
| 658 | 670 | $padlen = $maxwords - $words; |
| 659 | 671 | |
@@ -666,8 +678,9 @@ discard block |
||
| 666 | 678 | |
| 667 | 679 | $ret = $padding->appendBytes($padlen, $padbuf); |
| 668 | 680 | |
| 669 | - if($ret < 0) |
|
| 670 | - return $ret; |
|
| 681 | + if($ret < 0) { |
|
| 682 | + return $ret; |
|
| 683 | + } |
|
| 671 | 684 | |
| 672 | 685 | } |
| 673 | 686 | |
@@ -63,11 +63,23 @@ discard block |
||
| 63 | 63 | $rs = null; |
| 64 | 64 | |
| 65 | 65 | // Check parameter ranges |
| 66 | - if($symsize < 0 || $symsize > 8) return $rs; |
|
| 67 | - if($fcr < 0 || $fcr >= (1<<$symsize)) return $rs; |
|
| 68 | - if($prim <= 0 || $prim >= (1<<$symsize)) return $rs; |
|
| 69 | - if($nroots < 0 || $nroots >= (1<<$symsize)) return $rs; // Can't have more roots than symbol values! |
|
| 70 | - if($pad < 0 || $pad >= ((1<<$symsize) -1 - $nroots)) return $rs; // Too much padding |
|
| 66 | + if($symsize < 0 || $symsize > 8) { |
|
| 67 | + return $rs; |
|
| 68 | + } |
|
| 69 | + if($fcr < 0 || $fcr >= (1<<$symsize)) { |
|
| 70 | + return $rs; |
|
| 71 | + } |
|
| 72 | + if($prim <= 0 || $prim >= (1<<$symsize)) { |
|
| 73 | + return $rs; |
|
| 74 | + } |
|
| 75 | + if($nroots < 0 || $nroots >= (1<<$symsize)) { |
|
| 76 | + return $rs; |
|
| 77 | + } |
|
| 78 | + // Can't have more roots than symbol values! |
|
| 79 | + if($pad < 0 || $pad >= ((1<<$symsize) -1 - $nroots)) { |
|
| 80 | + return $rs; |
|
| 81 | + } |
|
| 82 | + // Too much padding |
|
| 71 | 83 | |
| 72 | 84 | $rs = new QRrsItem(); |
| 73 | 85 | $rs->mm = $symsize; |
@@ -133,8 +145,9 @@ discard block |
||
| 133 | 145 | } |
| 134 | 146 | |
| 135 | 147 | // convert rs->genpoly[] to index form for quicker encoding |
| 136 | - for ($i = 0; $i <= $nroots; $i++) |
|
| 137 | - $rs->genpoly[$i] = $rs->index_of[$rs->genpoly[$i]]; |
|
| 148 | + for ($i = 0; $i <= $nroots; $i++) { |
|
| 149 | + $rs->genpoly[$i] = $rs->index_of[$rs->genpoly[$i]]; |
|
| 150 | + } |
|
| 138 | 151 | |
| 139 | 152 | return $rs; |
| 140 | 153 | } |
@@ -192,12 +205,24 @@ discard block |
||
| 192 | 205 | public static function init_rs($symsize, $gfpoly, $fcr, $prim, $nroots, $pad) |
| 193 | 206 | {
|
| 194 | 207 | foreach(self::$items as $rs) {
|
| 195 | - if($rs->pad != $pad) continue; |
|
| 196 | - if($rs->nroots != $nroots) continue; |
|
| 197 | - if($rs->mm != $symsize) continue; |
|
| 198 | - if($rs->gfpoly != $gfpoly) continue; |
|
| 199 | - if($rs->fcr != $fcr) continue; |
|
| 200 | - if($rs->prim != $prim) continue; |
|
| 208 | + if($rs->pad != $pad) { |
|
| 209 | + continue; |
|
| 210 | + } |
|
| 211 | + if($rs->nroots != $nroots) { |
|
| 212 | + continue; |
|
| 213 | + } |
|
| 214 | + if($rs->mm != $symsize) { |
|
| 215 | + continue; |
|
| 216 | + } |
|
| 217 | + if($rs->gfpoly != $gfpoly) { |
|
| 218 | + continue; |
|
| 219 | + } |
|
| 220 | + if($rs->fcr != $fcr) { |
|
| 221 | + continue; |
|
| 222 | + } |
|
| 223 | + if($rs->prim != $prim) { |
|
| 224 | + continue; |
|
| 225 | + } |
|
| 201 | 226 | |
| 202 | 227 | return $rs; |
| 203 | 228 | } |