@@ -176,8 +176,9 @@ discard block |
||
| 176 | 176 | {
|
| 177 | 177 | $barcode_array = array(); |
| 178 | 178 | |
| 179 | - if (!is_array($mode)) |
|
| 180 | - $mode = explode(',', $mode);
|
|
| 179 | + if (!is_array($mode)) { |
|
| 180 | + $mode = explode(',', $mode); |
|
| 181 | + } |
|
| 181 | 182 | |
| 182 | 183 | $eccLevel = 'L'; |
| 183 | 184 | |
@@ -194,8 +195,9 @@ discard block |
||
| 194 | 195 | |
| 195 | 196 | foreach ($qrTab as $line) {
|
| 196 | 197 | $arrAdd = array(); |
| 197 | - foreach(str_split($line) as $char) |
|
| 198 | - $arrAdd[] = ($char=='1')?1:0; |
|
| 198 | + foreach(str_split($line) as $char) { |
|
| 199 | + $arrAdd[] = ($char=='1')?1:0; |
|
| 200 | + } |
|
| 199 | 201 | $barcode_array['bcode'][] = $arrAdd; |
| 200 | 202 | } |
| 201 | 203 | |
@@ -223,8 +225,9 @@ discard block |
||
| 223 | 225 | |
| 224 | 226 | $width = count($frame); |
| 225 | 227 | $bitMask = array_fill(0, $width, array_fill(0, $width, 0)); |
| 226 | - for ($maskNo=0; $maskNo<8; $maskNo++) |
|
| 227 | - $mask->makeMaskNo($maskNo, $width, $frame, $bitMask, true); |
|
| 228 | + for ($maskNo=0; $maskNo<8; $maskNo++) { |
|
| 229 | + $mask->makeMaskNo($maskNo, $width, $frame, $bitMask, true); |
|
| 230 | + } |
|
| 228 | 231 | } |
| 229 | 232 | |
| 230 | 233 | QRtools::markTime('after_build_cache');
|
@@ -261,8 +264,9 @@ discard block |
||
| 261 | 264 | list($usec, $sec) = explode(" ", microtime());
|
| 262 | 265 | $time = ((float)$usec + (float)$sec); |
| 263 | 266 | |
| 264 | - if (!isset($GLOBALS['qr_time_bench'])) |
|
| 265 | - $GLOBALS['qr_time_bench'] = array(); |
|
| 267 | + if (!isset($GLOBALS['qr_time_bench'])) { |
|
| 268 | + $GLOBALS['qr_time_bench'] = array(); |
|
| 269 | + } |
|
| 266 | 270 | |
| 267 | 271 | $GLOBALS['qr_time_bench'][$markerId] = $time; |
| 268 | 272 | } |
@@ -427,8 +431,9 @@ discard block |
||
| 427 | 431 | |
| 428 | 432 | for($i=1; $i<= QRSPEC_VERSION_MAX; $i++) {
|
| 429 | 433 | $words = self::$capacity[$i][QRCAP_WORDS] - self::$capacity[$i][QRCAP_EC][$level]; |
| 430 | - if($words >= $size) |
|
| 431 | - return $i; |
|
| 434 | + if($words >= $size) { |
|
| 435 | + return $i; |
|
| 436 | + } |
|
| 432 | 437 | } |
| 433 | 438 | |
| 434 | 439 | return -1; |
@@ -446,8 +451,9 @@ discard block |
||
| 446 | 451 | //---------------------------------------------------------------------- |
| 447 | 452 | public static function lengthIndicator($mode, $version) |
| 448 | 453 | {
|
| 449 | - if ($mode == QR_MODE_STRUCTURE) |
|
| 450 | - return 0; |
|
| 454 | + if ($mode == QR_MODE_STRUCTURE) { |
|
| 455 | + return 0; |
|
| 456 | + } |
|
| 451 | 457 | |
| 452 | 458 | if ($version <= 9) {
|
| 453 | 459 | $l = 0; |
@@ -463,8 +469,9 @@ discard block |
||
| 463 | 469 | //---------------------------------------------------------------------- |
| 464 | 470 | public static function maximumWords($mode, $version) |
| 465 | 471 | {
|
| 466 | - if($mode == QR_MODE_STRUCTURE) |
|
| 467 | - return 3; |
|
| 472 | + if($mode == QR_MODE_STRUCTURE) { |
|
| 473 | + return 3; |
|
| 474 | + } |
|
| 468 | 475 | |
| 469 | 476 | if($version <= 9) {
|
| 470 | 477 | $l = 0; |
@@ -610,8 +617,9 @@ discard block |
||
| 610 | 617 | //---------------------------------------------------------------------- |
| 611 | 618 | public static function putAlignmentPattern($version, &$frame, $width) |
| 612 | 619 | {
|
| 613 | - if($version < 2) |
|
| 614 | - return; |
|
| 620 | + if($version < 2) { |
|
| 621 | + return; |
|
| 622 | + } |
|
| 615 | 623 | |
| 616 | 624 | $d = self::$alignmentPattern[$version][1] - self::$alignmentPattern[$version][0]; |
| 617 | 625 | if($d < 0) {
|
@@ -663,8 +671,9 @@ discard block |
||
| 663 | 671 | //---------------------------------------------------------------------- |
| 664 | 672 | public static function getVersionPattern($version) |
| 665 | 673 | {
|
| 666 | - if($version < 7 || $version > QRSPEC_VERSION_MAX) |
|
| 667 | - return 0; |
|
| 674 | + if($version < 7 || $version > QRSPEC_VERSION_MAX) { |
|
| 675 | + return 0; |
|
| 676 | + } |
|
| 668 | 677 | |
| 669 | 678 | return self::$versionPattern[$version -7]; |
| 670 | 679 | } |
@@ -681,11 +690,13 @@ discard block |
||
| 681 | 690 | |
| 682 | 691 | public static function getFormatInfo($mask, $level) |
| 683 | 692 | {
|
| 684 | - if($mask < 0 || $mask > 7) |
|
| 685 | - return 0; |
|
| 693 | + if($mask < 0 || $mask > 7) { |
|
| 694 | + return 0; |
|
| 695 | + } |
|
| 686 | 696 | |
| 687 | - if($level < 0 || $level > 3) |
|
| 688 | - return 0; |
|
| 697 | + if($level < 0 || $level > 3) { |
|
| 698 | + return 0; |
|
| 699 | + } |
|
| 689 | 700 | |
| 690 | 701 | return self::$formatInfo[$level][$mask]; |
| 691 | 702 | } |
@@ -865,8 +876,9 @@ discard block |
||
| 865 | 876 | //---------------------------------------------------------------------- |
| 866 | 877 | public static function newFrame($version) |
| 867 | 878 | {
|
| 868 | - if($version < 1 || $version > QRSPEC_VERSION_MAX) |
|
| 869 | - return null; |
|
| 879 | + if($version < 1 || $version > QRSPEC_VERSION_MAX) { |
|
| 880 | + return null; |
|
| 881 | + } |
|
| 870 | 882 | |
| 871 | 883 | if(!isset(self::$frames[$version])) {
|
| 872 | 884 | |
@@ -884,8 +896,9 @@ discard block |
||
| 884 | 896 | } |
| 885 | 897 | } |
| 886 | 898 | |
| 887 | - if(is_null(self::$frames[$version])) |
|
| 888 | - return null; |
|
| 899 | + if(is_null(self::$frames[$version])) { |
|
| 900 | + return null; |
|
| 901 | + } |
|
| 889 | 902 | |
| 890 | 903 | return self::$frames[$version]; |
| 891 | 904 | } |
@@ -950,7 +963,7 @@ discard block |
||
| 950 | 963 | ImagePng($image, $filename); |
| 951 | 964 | header("Content-type: image/png");
|
| 952 | 965 | ImagePng($image); |
| 953 | - }else{
|
|
| 966 | + } else{
|
|
| 954 | 967 | ImagePng($image, $filename); |
| 955 | 968 | } |
| 956 | 969 | } |
@@ -1210,8 +1223,9 @@ discard block |
||
| 1210 | 1223 | {
|
| 1211 | 1224 | $bits = 0; |
| 1212 | 1225 | |
| 1213 | - if($version == 0) |
|
| 1214 | - $version = 1; |
|
| 1226 | + if($version == 0) { |
|
| 1227 | + $version = 1; |
|
| 1228 | + } |
|
| 1215 | 1229 | |
| 1216 | 1230 | switch($this->mode) {
|
| 1217 | 1231 | case QR_MODE_NUM: $bits = QRinput::estimateBitsModeNum($this->size); break; |
@@ -1270,8 +1284,9 @@ discard block |
||
| 1270 | 1284 | break; |
| 1271 | 1285 | } |
| 1272 | 1286 | |
| 1273 | - if($ret < 0) |
|
| 1274 | - return -1; |
|
| 1287 | + if($ret < 0) { |
|
| 1288 | + return -1; |
|
| 1289 | + } |
|
| 1275 | 1290 | } |
| 1276 | 1291 | |
| 1277 | 1292 | return $this->bstream->size(); |
@@ -1488,8 +1503,9 @@ discard block |
||
| 1488 | 1503 | //---------------------------------------------------------------------- |
| 1489 | 1504 | public static function checkModeKanji($size, $data) |
| 1490 | 1505 | {
|
| 1491 | - if($size & 1) |
|
| 1492 | - return false; |
|
| 1506 | + if($size & 1) { |
|
| 1507 | + return false; |
|
| 1508 | + } |
|
| 1493 | 1509 | |
| 1494 | 1510 | for($i=0; $i<$size; $i+=2) {
|
| 1495 | 1511 | $val = (ord($data[$i]) << 8) | ord($data[$i+1]); |
@@ -1509,8 +1525,9 @@ discard block |
||
| 1509 | 1525 | |
| 1510 | 1526 | public static function check($mode, $size, $data) |
| 1511 | 1527 | {
|
| 1512 | - if($size <= 0) |
|
| 1513 | - return false; |
|
| 1528 | + if($size <= 0) { |
|
| 1529 | + return false; |
|
| 1530 | + } |
|
| 1514 | 1531 | |
| 1515 | 1532 | switch($mode) {
|
| 1516 | 1533 | case QR_MODE_NUM: return self::checkModeNum($size, $data); break; |
@@ -1575,8 +1592,9 @@ discard block |
||
| 1575 | 1592 | $chunks = (int)($payload / 11); |
| 1576 | 1593 | $remain = $payload - $chunks * 11; |
| 1577 | 1594 | $size = $chunks * 2; |
| 1578 | - if($remain >= 6) |
|
| 1579 | - $size++; |
|
| 1595 | + if($remain >= 6) { |
|
| 1596 | + $size++; |
|
| 1597 | + } |
|
| 1580 | 1598 | break; |
| 1581 | 1599 | case QR_MODE_8: |
| 1582 | 1600 | $size = (int)($payload / 8); |
@@ -1593,8 +1611,12 @@ discard block |
||
| 1593 | 1611 | } |
| 1594 | 1612 | |
| 1595 | 1613 | $maxsize = QRspec::maximumWords($mode, $version); |
| 1596 | - if($size < 0) $size = 0; |
|
| 1597 | - if($size > $maxsize) $size = $maxsize; |
|
| 1614 | + if($size < 0) { |
|
| 1615 | + $size = 0; |
|
| 1616 | + } |
|
| 1617 | + if($size > $maxsize) { |
|
| 1618 | + $size = $maxsize; |
|
| 1619 | + } |
|
| 1598 | 1620 | |
| 1599 | 1621 | return $size; |
| 1600 | 1622 | } |
@@ -1607,8 +1629,9 @@ discard block |
||
| 1607 | 1629 | foreach($this->items as $item) {
|
| 1608 | 1630 | $bits = $item->encodeBitStream($this->version); |
| 1609 | 1631 | |
| 1610 | - if($bits < 0) |
|
| 1611 | - return -1; |
|
| 1632 | + if($bits < 0) { |
|
| 1633 | + return -1; |
|
| 1634 | + } |
|
| 1612 | 1635 | |
| 1613 | 1636 | $total += $bits; |
| 1614 | 1637 | } |
@@ -1627,8 +1650,9 @@ discard block |
||
| 1627 | 1650 | for(;;) {
|
| 1628 | 1651 | $bits = $this->createBitStream(); |
| 1629 | 1652 | |
| 1630 | - if($bits < 0) |
|
| 1631 | - return -1; |
|
| 1653 | + if($bits < 0) { |
|
| 1654 | + return -1; |
|
| 1655 | + } |
|
| 1632 | 1656 | |
| 1633 | 1657 | $ver = QRspec::getMinimumVersion((int)(($bits + 7) / 8), $this->level); |
| 1634 | 1658 | if($ver < 0) {
|
@@ -1665,8 +1689,9 @@ discard block |
||
| 1665 | 1689 | $padding = new QRbitstream(); |
| 1666 | 1690 | $ret = $padding->appendNum($words * 8 - $bits + 4, 0); |
| 1667 | 1691 | |
| 1668 | - if($ret < 0) |
|
| 1669 | - return $ret; |
|
| 1692 | + if($ret < 0) { |
|
| 1693 | + return $ret; |
|
| 1694 | + } |
|
| 1670 | 1695 | |
| 1671 | 1696 | $padlen = $maxwords - $words; |
| 1672 | 1697 | |
@@ -1679,8 +1704,9 @@ discard block |
||
| 1679 | 1704 | |
| 1680 | 1705 | $ret = $padding->appendBytes($padlen, $padbuf); |
| 1681 | 1706 | |
| 1682 | - if($ret < 0) |
|
| 1683 | - return $ret; |
|
| 1707 | + if($ret < 0) { |
|
| 1708 | + return $ret; |
|
| 1709 | + } |
|
| 1684 | 1710 | |
| 1685 | 1711 | } |
| 1686 | 1712 | |
@@ -1857,13 +1883,15 @@ discard block |
||
| 1857 | 1883 | //---------------------------------------------------------------------- |
| 1858 | 1884 | public function appendNum($bits, $num) |
| 1859 | 1885 | {
|
| 1860 | - if ($bits == 0) |
|
| 1861 | - return 0; |
|
| 1886 | + if ($bits == 0) { |
|
| 1887 | + return 0; |
|
| 1888 | + } |
|
| 1862 | 1889 | |
| 1863 | 1890 | $b = QRbitstream::newFromNum($bits, $num); |
| 1864 | 1891 | |
| 1865 | - if(is_null($b)) |
|
| 1866 | - return -1; |
|
| 1892 | + if(is_null($b)) { |
|
| 1893 | + return -1; |
|
| 1894 | + } |
|
| 1867 | 1895 | |
| 1868 | 1896 | $ret = $this->append($b); |
| 1869 | 1897 | unset($b); |
@@ -1874,13 +1902,15 @@ discard block |
||
| 1874 | 1902 | //---------------------------------------------------------------------- |
| 1875 | 1903 | public function appendBytes($size, $data) |
| 1876 | 1904 | {
|
| 1877 | - if ($size == 0) |
|
| 1878 | - return 0; |
|
| 1905 | + if ($size == 0) { |
|
| 1906 | + return 0; |
|
| 1907 | + } |
|
| 1879 | 1908 | |
| 1880 | 1909 | $b = QRbitstream::newFromBytes($size, $data); |
| 1881 | 1910 | |
| 1882 | - if(is_null($b)) |
|
| 1883 | - return -1; |
|
| 1911 | + if(is_null($b)) { |
|
| 1912 | + return -1; |
|
| 1913 | + } |
|
| 1884 | 1914 | |
| 1885 | 1915 | $ret = $this->append($b); |
| 1886 | 1916 | unset($b); |
@@ -1984,8 +2014,9 @@ discard block |
||
| 1984 | 2014 | //---------------------------------------------------------------------- |
| 1985 | 2015 | public static function isdigitat($str, $pos) |
| 1986 | 2016 | {
|
| 1987 | - if ($pos >= strlen($str)) |
|
| 1988 | - return false; |
|
| 2017 | + if ($pos >= strlen($str)) { |
|
| 2018 | + return false; |
|
| 2019 | + } |
|
| 1989 | 2020 | |
| 1990 | 2021 | return ((ord($str[$pos]) >= ord('0'))&&(ord($str[$pos]) <= ord('9')));
|
| 1991 | 2022 | } |
@@ -1993,8 +2024,9 @@ discard block |
||
| 1993 | 2024 | //---------------------------------------------------------------------- |
| 1994 | 2025 | public static function isalnumat($str, $pos) |
| 1995 | 2026 | {
|
| 1996 | - if ($pos >= strlen($str)) |
|
| 1997 | - return false; |
|
| 2027 | + if ($pos >= strlen($str)) { |
|
| 2028 | + return false; |
|
| 2029 | + } |
|
| 1998 | 2030 | |
| 1999 | 2031 | return (QRinput::lookAnTable(ord($str[$pos])) >= 0); |
| 2000 | 2032 | } |
@@ -2002,8 +2034,9 @@ discard block |
||
| 2002 | 2034 | //---------------------------------------------------------------------- |
| 2003 | 2035 | public function identifyMode($pos) |
| 2004 | 2036 | {
|
| 2005 | - if ($pos >= strlen($this->dataStr)) |
|
| 2006 | - return QR_MODE_NUL; |
|
| 2037 | + if ($pos >= strlen($this->dataStr)) { |
|
| 2038 | + return QR_MODE_NUL; |
|
| 2039 | + } |
|
| 2007 | 2040 | |
| 2008 | 2041 | $c = $this->dataStr[$pos]; |
| 2009 | 2042 | |
@@ -2057,8 +2090,9 @@ discard block |
||
| 2057 | 2090 | } |
| 2058 | 2091 | |
| 2059 | 2092 | $ret = $this->input->append(QR_MODE_NUM, $run, str_split($this->dataStr)); |
| 2060 | - if($ret < 0) |
|
| 2061 | - return -1; |
|
| 2093 | + if($ret < 0) { |
|
| 2094 | + return -1; |
|
| 2095 | + } |
|
| 2062 | 2096 | |
| 2063 | 2097 | return $run; |
| 2064 | 2098 | } |
@@ -2104,8 +2138,9 @@ discard block |
||
| 2104 | 2138 | } |
| 2105 | 2139 | |
| 2106 | 2140 | $ret = $this->input->append(QR_MODE_AN, $run, str_split($this->dataStr)); |
| 2107 | - if($ret < 0) |
|
| 2108 | - return -1; |
|
| 2141 | + if($ret < 0) { |
|
| 2142 | + return -1; |
|
| 2143 | + } |
|
| 2109 | 2144 | |
| 2110 | 2145 | return $run; |
| 2111 | 2146 | } |
@@ -2120,8 +2155,9 @@ discard block |
||
| 2120 | 2155 | } |
| 2121 | 2156 | |
| 2122 | 2157 | $ret = $this->input->append(QR_MODE_KANJI, $p, str_split($this->dataStr)); |
| 2123 | - if($ret < 0) |
|
| 2124 | - return -1; |
|
| 2158 | + if($ret < 0) { |
|
| 2159 | + return -1; |
|
| 2160 | + } |
|
| 2125 | 2161 | |
| 2126 | 2162 | return $run; |
| 2127 | 2163 | } |
@@ -2175,8 +2211,9 @@ discard block |
||
| 2175 | 2211 | $run = $p; |
| 2176 | 2212 | $ret = $this->input->append(QR_MODE_8, $run, str_split($this->dataStr)); |
| 2177 | 2213 | |
| 2178 | - if($ret < 0) |
|
| 2179 | - return -1; |
|
| 2214 | + if($ret < 0) { |
|
| 2215 | + return -1; |
|
| 2216 | + } |
|
| 2180 | 2217 | |
| 2181 | 2218 | return $run; |
| 2182 | 2219 | } |
@@ -2186,8 +2223,9 @@ discard block |
||
| 2186 | 2223 | {
|
| 2187 | 2224 | while (strlen($this->dataStr) > 0) |
| 2188 | 2225 | {
|
| 2189 | - if($this->dataStr == '') |
|
| 2190 | - return 0; |
|
| 2226 | + if($this->dataStr == '') { |
|
| 2227 | + return 0; |
|
| 2228 | + } |
|
| 2191 | 2229 | |
| 2192 | 2230 | $mode = $this->identifyMode(0); |
| 2193 | 2231 | |
@@ -2195,16 +2233,22 @@ discard block |
||
| 2195 | 2233 | case QR_MODE_NUM: $length = $this->eatNum(); break; |
| 2196 | 2234 | case QR_MODE_AN: $length = $this->eatAn(); break; |
| 2197 | 2235 | case QR_MODE_KANJI: |
| 2198 | - if ($this->modeHint == QR_MODE_KANJI) |
|
| 2199 | - $length = $this->eatKanji(); |
|
| 2200 | - else $length = $this->eat8(); |
|
| 2236 | + if ($this->modeHint == QR_MODE_KANJI) { |
|
| 2237 | + $length = $this->eatKanji(); |
|
| 2238 | + } else { |
|
| 2239 | + $length = $this->eat8(); |
|
| 2240 | + } |
|
| 2201 | 2241 | break; |
| 2202 | 2242 | default: $length = $this->eat8(); break; |
| 2203 | 2243 | |
| 2204 | 2244 | } |
| 2205 | 2245 | |
| 2206 | - if($length == 0) return 0; |
|
| 2207 | - if($length < 0) return -1; |
|
| 2246 | + if($length == 0) { |
|
| 2247 | + return 0; |
|
| 2248 | + } |
|
| 2249 | + if($length < 0) { |
|
| 2250 | + return -1; |
|
| 2251 | + } |
|
| 2208 | 2252 | |
| 2209 | 2253 | $this->dataStr = substr($this->dataStr, $length); |
| 2210 | 2254 | } |
@@ -2240,8 +2284,9 @@ discard block |
||
| 2240 | 2284 | |
| 2241 | 2285 | $split = new QRsplit($string, $input, $modeHint); |
| 2242 | 2286 | |
| 2243 | - if(!$casesensitive) |
|
| 2244 | - $split->toUpper(); |
|
| 2287 | + if(!$casesensitive) { |
|
| 2288 | + $split->toUpper(); |
|
| 2289 | + } |
|
| 2245 | 2290 | |
| 2246 | 2291 | return $split->splitString(); |
| 2247 | 2292 | } |
@@ -2318,11 +2363,23 @@ discard block |
||
| 2318 | 2363 | $rs = null; |
| 2319 | 2364 | |
| 2320 | 2365 | // Check parameter ranges |
| 2321 | - if($symsize < 0 || $symsize > 8) return $rs; |
|
| 2322 | - if($fcr < 0 || $fcr >= (1<<$symsize)) return $rs; |
|
| 2323 | - if($prim <= 0 || $prim >= (1<<$symsize)) return $rs; |
|
| 2324 | - if($nroots < 0 || $nroots >= (1<<$symsize)) return $rs; // Can't have more roots than symbol values! |
|
| 2325 | - if($pad < 0 || $pad >= ((1<<$symsize) -1 - $nroots)) return $rs; // Too much padding |
|
| 2366 | + if($symsize < 0 || $symsize > 8) { |
|
| 2367 | + return $rs; |
|
| 2368 | + } |
|
| 2369 | + if($fcr < 0 || $fcr >= (1<<$symsize)) { |
|
| 2370 | + return $rs; |
|
| 2371 | + } |
|
| 2372 | + if($prim <= 0 || $prim >= (1<<$symsize)) { |
|
| 2373 | + return $rs; |
|
| 2374 | + } |
|
| 2375 | + if($nroots < 0 || $nroots >= (1<<$symsize)) { |
|
| 2376 | + return $rs; |
|
| 2377 | + } |
|
| 2378 | + // Can't have more roots than symbol values! |
|
| 2379 | + if($pad < 0 || $pad >= ((1<<$symsize) -1 - $nroots)) { |
|
| 2380 | + return $rs; |
|
| 2381 | + } |
|
| 2382 | + // Too much padding |
|
| 2326 | 2383 | |
| 2327 | 2384 | $rs = new QRrsItem(); |
| 2328 | 2385 | $rs->mm = $symsize; |
@@ -2388,8 +2445,9 @@ discard block |
||
| 2388 | 2445 | } |
| 2389 | 2446 | |
| 2390 | 2447 | // convert rs->genpoly[] to index form for quicker encoding |
| 2391 | - for ($i = 0; $i <= $nroots; $i++) |
|
| 2392 | - $rs->genpoly[$i] = $rs->index_of[$rs->genpoly[$i]]; |
|
| 2448 | + for ($i = 0; $i <= $nroots; $i++) { |
|
| 2449 | + $rs->genpoly[$i] = $rs->index_of[$rs->genpoly[$i]]; |
|
| 2450 | + } |
|
| 2393 | 2451 | |
| 2394 | 2452 | return $rs; |
| 2395 | 2453 | } |
@@ -2447,12 +2505,24 @@ discard block |
||
| 2447 | 2505 | public static function init_rs($symsize, $gfpoly, $fcr, $prim, $nroots, $pad) |
| 2448 | 2506 | {
|
| 2449 | 2507 | foreach(self::$items as $rs) {
|
| 2450 | - if($rs->pad != $pad) continue; |
|
| 2451 | - if($rs->nroots != $nroots) continue; |
|
| 2452 | - if($rs->mm != $symsize) continue; |
|
| 2453 | - if($rs->gfpoly != $gfpoly) continue; |
|
| 2454 | - if($rs->fcr != $fcr) continue; |
|
| 2455 | - if($rs->prim != $prim) continue; |
|
| 2508 | + if($rs->pad != $pad) { |
|
| 2509 | + continue; |
|
| 2510 | + } |
|
| 2511 | + if($rs->nroots != $nroots) { |
|
| 2512 | + continue; |
|
| 2513 | + } |
|
| 2514 | + if($rs->mm != $symsize) { |
|
| 2515 | + continue; |
|
| 2516 | + } |
|
| 2517 | + if($rs->gfpoly != $gfpoly) { |
|
| 2518 | + continue; |
|
| 2519 | + } |
|
| 2520 | + if($rs->fcr != $fcr) { |
|
| 2521 | + continue; |
|
| 2522 | + } |
|
| 2523 | + if($rs->prim != $prim) { |
|
| 2524 | + continue; |
|
| 2525 | + } |
|
| 2456 | 2526 | |
| 2457 | 2527 | return $rs; |
| 2458 | 2528 | } |
@@ -2591,8 +2661,9 @@ discard block |
||
| 2591 | 2661 | {
|
| 2592 | 2662 | $codeArr = array(); |
| 2593 | 2663 | |
| 2594 | - foreach ($bitFrame as $line) |
|
| 2595 | - $codeArr[] = join('', $line);
|
|
| 2664 | + foreach ($bitFrame as $line) { |
|
| 2665 | + $codeArr[] = join('', $line); |
|
| 2666 | + } |
|
| 2596 | 2667 | |
| 2597 | 2668 | return gzcompress(join("\n", $codeArr), 9);
|
| 2598 | 2669 | } |
@@ -2603,8 +2674,9 @@ discard block |
||
| 2603 | 2674 | $codeArr = array(); |
| 2604 | 2675 | |
| 2605 | 2676 | $codeLines = explode("\n", gzuncompress($code));
|
| 2606 | - foreach ($codeLines as $line) |
|
| 2607 | - $codeArr[] = str_split($line); |
|
| 2677 | + foreach ($codeLines as $line) { |
|
| 2678 | + $codeArr[] = str_split($line); |
|
| 2679 | + } |
|
| 2608 | 2680 | |
| 2609 | 2681 | return $codeArr; |
| 2610 | 2682 | } |
@@ -2622,16 +2694,18 @@ discard block |
||
| 2622 | 2694 | $bitMask = self::unserial(file_get_contents($fileName)); |
| 2623 | 2695 | } else {
|
| 2624 | 2696 | $bitMask = $this->generateMaskNo($maskNo, $width, $s); |
| 2625 | - if (!file_exists(QR_CACHE_DIR.'mask_'.$maskNo)) |
|
| 2626 | - mkdir(QR_CACHE_DIR.'mask_'.$maskNo); |
|
| 2697 | + if (!file_exists(QR_CACHE_DIR.'mask_'.$maskNo)) { |
|
| 2698 | + mkdir(QR_CACHE_DIR.'mask_'.$maskNo); |
|
| 2699 | + } |
|
| 2627 | 2700 | file_put_contents($fileName, self::serial($bitMask)); |
| 2628 | 2701 | } |
| 2629 | 2702 | } else {
|
| 2630 | 2703 | $bitMask = $this->generateMaskNo($maskNo, $width, $s); |
| 2631 | 2704 | } |
| 2632 | 2705 | |
| 2633 | - if ($maskGenOnly) |
|
| 2634 | - return; |
|
| 2706 | + if ($maskGenOnly) { |
|
| 2707 | + return; |
|
| 2708 | + } |
|
| 2635 | 2709 | |
| 2636 | 2710 | $d = $s; |
| 2637 | 2711 | |
@@ -2698,8 +2772,9 @@ discard block |
||
| 2698 | 2772 | |
| 2699 | 2773 | $frameY = $frame[$y]; |
| 2700 | 2774 | |
| 2701 | - if ($y>0) |
|
| 2702 | - $frameYM = $frame[$y-1]; |
|
| 2775 | + if ($y>0) { |
|
| 2776 | + $frameYM = $frame[$y-1]; |
|
| 2777 | + } |
|
| 2703 | 2778 | |
| 2704 | 2779 | for($x=0; $x<$width; $x++) {
|
| 2705 | 2780 | if(($x > 0) && ($y > 0)) {
|
@@ -2912,14 +2987,17 @@ discard block |
||
| 2912 | 2987 | $blockNo++; |
| 2913 | 2988 | } |
| 2914 | 2989 | |
| 2915 | - if(QRspec::rsBlockNum2($spec) == 0) |
|
| 2916 | - return 0; |
|
| 2990 | + if(QRspec::rsBlockNum2($spec) == 0) { |
|
| 2991 | + return 0; |
|
| 2992 | + } |
|
| 2917 | 2993 | |
| 2918 | 2994 | $dl = QRspec::rsDataCodes2($spec); |
| 2919 | 2995 | $el = QRspec::rsEccCodes2($spec); |
| 2920 | 2996 | $rs = QRrs::init_rs(8, 0x11d, 0, 1, $el, 255 - $dl - $el); |
| 2921 | 2997 | |
| 2922 | - if($rs == NULL) return -1; |
|
| 2998 | + if($rs == NULL) { |
|
| 2999 | + return -1; |
|
| 3000 | + } |
|
| 2923 | 3001 | |
| 2924 | 3002 | for($i=0; $i<QRspec::rsBlockNum2($spec); $i++) {
|
| 2925 | 3003 | $ecc = array_slice($this->ecccode,$eccPos); |
@@ -3057,7 +3135,9 @@ discard block |
||
| 3057 | 3135 | } |
| 3058 | 3136 | |
| 3059 | 3137 | $input = new QRinput($version, $level); |
| 3060 | - if($input == NULL) return NULL; |
|
| 3138 | + if($input == NULL) { |
|
| 3139 | + return NULL; |
|
| 3140 | + } |
|
| 3061 | 3141 | |
| 3062 | 3142 | $ret = $input->append(QR_MODE_8, strlen($string), str_split($string)); |
| 3063 | 3143 | if($ret < 0) {
|
@@ -3077,7 +3157,9 @@ discard block |
||
| 3077 | 3157 | } |
| 3078 | 3158 | |
| 3079 | 3159 | $input = new QRinput($version, $level); |
| 3080 | - if($input == NULL) return NULL; |
|
| 3160 | + if($input == NULL) { |
|
| 3161 | + return NULL; |
|
| 3162 | + } |
|
| 3081 | 3163 | |
| 3082 | 3164 | $ret = QRsplit::splitStringToQRinput($string, $input, $hint, $casesensitive); |
| 3083 | 3165 | if($ret < 0) {
|
@@ -3187,7 +3269,9 @@ discard block |
||
| 3187 | 3269 | } |
| 3188 | 3270 | } |
| 3189 | 3271 | } |
| 3190 | - if($x < 0 || $y < 0) return null; |
|
| 3272 | + if($x < 0 || $y < 0) { |
|
| 3273 | + return null; |
|
| 3274 | + } |
|
| 3191 | 3275 | |
| 3192 | 3276 | $this->x = $x; |
| 3193 | 3277 | $this->y = $y; |
@@ -3294,8 +3378,9 @@ discard block |
||
| 3294 | 3378 | $err = ob_get_contents(); |
| 3295 | 3379 | ob_end_clean(); |
| 3296 | 3380 | |
| 3297 | - if ($err != '') |
|
| 3298 | - QRtools::log($outfile, $err); |
|
| 3381 | + if ($err != '') { |
|
| 3382 | + QRtools::log($outfile, $err); |
|
| 3383 | + } |
|
| 3299 | 3384 | |
| 3300 | 3385 | $maxSize = (int)(QR_PNG_MAXIMUM_SIZE / (count($tab)+2*$this->margin)); |
| 3301 | 3386 | |
@@ -119,8 +119,9 @@ discard block |
||
| 119 | 119 | {
|
| 120 | 120 | $codeArr = array(); |
| 121 | 121 | |
| 122 | - foreach ($bitFrame as $line) |
|
| 123 | - $codeArr[] = join('', $line);
|
|
| 122 | + foreach ($bitFrame as $line) { |
|
| 123 | + $codeArr[] = join('', $line); |
|
| 124 | + } |
|
| 124 | 125 | |
| 125 | 126 | return gzcompress(join("\n", $codeArr), 9);
|
| 126 | 127 | } |
@@ -131,8 +132,9 @@ discard block |
||
| 131 | 132 | $codeArr = array(); |
| 132 | 133 | |
| 133 | 134 | $codeLines = explode("\n", gzuncompress($code));
|
| 134 | - foreach ($codeLines as $line) |
|
| 135 | - $codeArr[] = str_split($line); |
|
| 135 | + foreach ($codeLines as $line) { |
|
| 136 | + $codeArr[] = str_split($line); |
|
| 137 | + } |
|
| 136 | 138 | |
| 137 | 139 | return $codeArr; |
| 138 | 140 | } |
@@ -150,16 +152,18 @@ discard block |
||
| 150 | 152 | $bitMask = self::unserial(file_get_contents($fileName)); |
| 151 | 153 | } else {
|
| 152 | 154 | $bitMask = $this->generateMaskNo($maskNo, $width, $s); |
| 153 | - if (!file_exists(QR_CACHE_DIR.'mask_'.$maskNo)) |
|
| 154 | - mkdir(QR_CACHE_DIR.'mask_'.$maskNo); |
|
| 155 | + if (!file_exists(QR_CACHE_DIR.'mask_'.$maskNo)) { |
|
| 156 | + mkdir(QR_CACHE_DIR.'mask_'.$maskNo); |
|
| 157 | + } |
|
| 155 | 158 | file_put_contents($fileName, self::serial($bitMask)); |
| 156 | 159 | } |
| 157 | 160 | } else {
|
| 158 | 161 | $bitMask = $this->generateMaskNo($maskNo, $width, $s); |
| 159 | 162 | } |
| 160 | 163 | |
| 161 | - if ($maskGenOnly) |
|
| 162 | - return; |
|
| 164 | + if ($maskGenOnly) { |
|
| 165 | + return; |
|
| 166 | + } |
|
| 163 | 167 | |
| 164 | 168 | $d = $s; |
| 165 | 169 | |
@@ -226,8 +230,9 @@ discard block |
||
| 226 | 230 | |
| 227 | 231 | $frameY = $frame[$y]; |
| 228 | 232 | |
| 229 | - if ($y>0) |
|
| 230 | - $frameYM = $frame[$y-1]; |
|
| 233 | + if ($y>0) { |
|
| 234 | + $frameYM = $frame[$y-1]; |
|
| 235 | + } |
|
| 231 | 236 | |
| 232 | 237 | for($x=0; $x<$width; $x++) {
|
| 233 | 238 | if(($x > 0) && ($y > 0)) {
|
@@ -33,8 +33,9 @@ discard block |
||
| 33 | 33 | include "qrlib.php"; |
| 34 | 34 | |
| 35 | 35 | //ofcourse we need rights to create temp dir |
| 36 | - if (!file_exists($PNG_TEMP_DIR)) |
|
| 37 | - mkdir($PNG_TEMP_DIR); |
|
| 36 | + if (!file_exists($PNG_TEMP_DIR)) { |
|
| 37 | + mkdir($PNG_TEMP_DIR); |
|
| 38 | + } |
|
| 38 | 39 | |
| 39 | 40 | |
| 40 | 41 | $filename = $PNG_TEMP_DIR.'test.png'; |
@@ -42,19 +43,22 @@ discard block |
||
| 42 | 43 | //processing form input |
| 43 | 44 | //remember to sanitize user input in real-life solution !!! |
| 44 | 45 | $errorCorrectionLevel = 'L'; |
| 45 | - if (isset($_REQUEST['level']) && in_array($_REQUEST['level'], array('L','M','Q','H')))
|
|
| 46 | - $errorCorrectionLevel = $_REQUEST['level']; |
|
| 46 | + if (isset($_REQUEST['level']) && in_array($_REQUEST['level'], array('L','M','Q','H'))) { |
|
| 47 | + $errorCorrectionLevel = $_REQUEST['level']; |
|
| 48 | + } |
|
| 47 | 49 | |
| 48 | 50 | $matrixPointSize = 4; |
| 49 | - if (isset($_REQUEST['size'])) |
|
| 50 | - $matrixPointSize = min(max((int)$_REQUEST['size'], 1), 10); |
|
| 51 | + if (isset($_REQUEST['size'])) { |
|
| 52 | + $matrixPointSize = min(max((int)$_REQUEST['size'], 1), 10); |
|
| 53 | + } |
|
| 51 | 54 | |
| 52 | 55 | |
| 53 | 56 | if (isset($_REQUEST['data'])) {
|
| 54 | 57 | |
| 55 | 58 | //it's very important! |
| 56 | - if (trim($_REQUEST['data']) == '') |
|
| 57 | - die('data cannot be empty! <a href="?">back</a>');
|
|
| 59 | + if (trim($_REQUEST['data']) == '') { |
|
| 60 | + die('data cannot be empty! <a href="?">back</a>'); |
|
| 61 | + } |
|
| 58 | 62 | |
| 59 | 63 | // user data |
| 60 | 64 | $filename = $PNG_TEMP_DIR.'test'.md5($_REQUEST['data'].'|'.$errorCorrectionLevel.'|'.$matrixPointSize).'.png'; |
@@ -82,8 +86,9 @@ discard block |
||
| 82 | 86 | </select> |
| 83 | 87 | Size: <select name="size">'; |
| 84 | 88 | |
| 85 | - for($i=1;$i<=10;$i++) |
|
| 86 | - echo '<option value="'.$i.'"'.(($matrixPointSize==$i)?' selected':'').'>'.$i.'</option>'; |
|
| 89 | + for($i=1;$i<=10;$i++) { |
|
| 90 | + echo '<option value="'.$i.'"'.(($matrixPointSize==$i)?' selected':'').'>'.$i.'</option>'; |
|
| 91 | + } |
|
| 87 | 92 | |
| 88 | 93 | echo '</select> |
| 89 | 94 | <input type="submit" value="GENERATE"></form><hr/>'; |
@@ -43,8 +43,9 @@ discard block |
||
| 43 | 43 | {
|
| 44 | 44 | $barcode_array = array(); |
| 45 | 45 | |
| 46 | - if (!is_array($mode)) |
|
| 47 | - $mode = explode(',', $mode);
|
|
| 46 | + if (!is_array($mode)) { |
|
| 47 | + $mode = explode(',', $mode); |
|
| 48 | + } |
|
| 48 | 49 | |
| 49 | 50 | $eccLevel = 'L'; |
| 50 | 51 | |
@@ -61,8 +62,9 @@ discard block |
||
| 61 | 62 | |
| 62 | 63 | foreach ($qrTab as $line) {
|
| 63 | 64 | $arrAdd = array(); |
| 64 | - foreach(str_split($line) as $char) |
|
| 65 | - $arrAdd[] = ($char=='1')?1:0; |
|
| 65 | + foreach(str_split($line) as $char) { |
|
| 66 | + $arrAdd[] = ($char=='1')?1:0; |
|
| 67 | + } |
|
| 66 | 68 | $barcode_array['bcode'][] = $arrAdd; |
| 67 | 69 | } |
| 68 | 70 | |
@@ -90,8 +92,9 @@ discard block |
||
| 90 | 92 | |
| 91 | 93 | $width = count($frame); |
| 92 | 94 | $bitMask = array_fill(0, $width, array_fill(0, $width, 0)); |
| 93 | - for ($maskNo=0; $maskNo<8; $maskNo++) |
|
| 94 | - $mask->makeMaskNo($maskNo, $width, $frame, $bitMask, true); |
|
| 95 | + for ($maskNo=0; $maskNo<8; $maskNo++) { |
|
| 96 | + $mask->makeMaskNo($maskNo, $width, $frame, $bitMask, true); |
|
| 97 | + } |
|
| 95 | 98 | } |
| 96 | 99 | |
| 97 | 100 | QRtools::markTime('after_build_cache');
|
@@ -128,8 +131,9 @@ discard block |
||
| 128 | 131 | list($usec, $sec) = explode(" ", microtime());
|
| 129 | 132 | $time = ((float)$usec + (float)$sec); |
| 130 | 133 | |
| 131 | - if (!isset($GLOBALS['qr_time_bench'])) |
|
| 132 | - $GLOBALS['qr_time_bench'] = array(); |
|
| 134 | + if (!isset($GLOBALS['qr_time_bench'])) { |
|
| 135 | + $GLOBALS['qr_time_bench'] = array(); |
|
| 136 | + } |
|
| 133 | 137 | |
| 134 | 138 | $GLOBALS['qr_time_bench'][$markerId] = $time; |
| 135 | 139 | } |
@@ -39,7 +39,7 @@ |
||
| 39 | 39 | ImagePng($image, $filename); |
| 40 | 40 | header("Content-type: image/png");
|
| 41 | 41 | ImagePng($image); |
| 42 | - }else{
|
|
| 42 | + } else{
|
|
| 43 | 43 | ImagePng($image, $filename); |
| 44 | 44 | } |
| 45 | 45 | } |
@@ -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) { |
@@ -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 |
@@ -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 | |