@@ -73,16 +73,16 @@ discard block |
||
73 | 73 | protected $_lcount = 19; |
74 | 74 | protected $_vcount = 21; |
75 | 75 | protected $_tcount = 28; |
76 | - protected $_ncount = 588; // _vcount * _tcount |
|
76 | + protected $_ncount = 588; // _vcount * _tcount |
|
77 | 77 | protected $_scount = 11172; // _lcount * _tcount * _vcount |
78 | 78 | protected $_error = false; |
79 | 79 | protected static $_mb_string_overload = null; |
80 | 80 | // See {@link set_paramter()} for details of how to change the following |
81 | 81 | // settings from within your script / application |
82 | - protected $_api_encoding = 'utf8'; // Default input charset is UTF-8 |
|
83 | - protected $_allow_overlong = false; // Overlong UTF-8 encodings are forbidden |
|
84 | - protected $_strict_mode = false; // Behave strict or not |
|
85 | - protected $_idn_version = 2003; // Can be either 2003 (old, default) or 2008 |
|
82 | + protected $_api_encoding = 'utf8'; // Default input charset is UTF-8 |
|
83 | + protected $_allow_overlong = false; // Overlong UTF-8 encodings are forbidden |
|
84 | + protected $_strict_mode = false; // Behave strict or not |
|
85 | + protected $_idn_version = 2003; // Can be either 2003 (old, default) or 2008 |
|
86 | 86 | |
87 | 87 | /** |
88 | 88 | * the constructor |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | |
108 | 108 | public function get_version() |
109 | 109 | { |
110 | - return $this->version.'-'.$this->sub_version; |
|
110 | + return $this->version . '-' . $this->sub_version; |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | /** |
@@ -241,12 +241,12 @@ discard block |
||
241 | 241 | } |
242 | 242 | } |
243 | 243 | $parsed['host'] = join('.', $arr); |
244 | - $return = (empty($parsed['scheme']) ? '' : $parsed['scheme'] . (strtolower($parsed['scheme']) == 'mailto' ? ':' : '://')). |
|
245 | - (empty($parsed['user']) ? '' : $parsed['user'] . (empty($parsed['pass']) ? '' : ':' . $parsed['pass']) . '@'). |
|
246 | - $parsed['host']. |
|
247 | - (empty($parsed['port']) ? '' : ':' . $parsed['port']). |
|
248 | - (empty($parsed['path']) ? '' : $parsed['path']). |
|
249 | - (empty($parsed['query']) ? '' : '?' . $parsed['query']). |
|
244 | + $return = (empty($parsed['scheme']) ? '' : $parsed['scheme'] . (strtolower($parsed['scheme']) == 'mailto' ? ':' : '://')) . |
|
245 | + (empty($parsed['user']) ? '' : $parsed['user'] . (empty($parsed['pass']) ? '' : ':' . $parsed['pass']) . '@') . |
|
246 | + $parsed['host'] . |
|
247 | + (empty($parsed['port']) ? '' : ':' . $parsed['port']) . |
|
248 | + (empty($parsed['path']) ? '' : $parsed['path']) . |
|
249 | + (empty($parsed['query']) ? '' : '?' . $parsed['query']) . |
|
250 | 250 | (empty($parsed['fragment']) ? '' : '#' . $parsed['fragment']); |
251 | 251 | } else { // parse_url seems to have failed, try without it |
252 | 252 | $arr = explode('.', $input); |
@@ -265,8 +265,8 @@ discard block |
||
265 | 265 | // The output is UTF-8 by default, other output formats need conversion here |
266 | 266 | // If one time encoding is given, use this, else the objects property |
267 | 267 | switch (($one_time_encoding) ? $one_time_encoding : $this->_api_encoding) { |
268 | - case 'utf8': return $return; // break; |
|
269 | - case 'ucs4_string': return $this->_ucs4_to_ucs4_string($this->_utf8_to_ucs4($return)); // break; |
|
268 | + case 'utf8' : return $return; // break; |
|
269 | + case 'ucs4_string': return $this->_ucs4_to_ucs4_string($this->_utf8_to_ucs4($return)); // break; |
|
270 | 270 | case 'ucs4_array': return $this->_utf8_to_ucs4($return); // break; |
271 | 271 | default: $this->_error('Unsupported output format'); return false; |
272 | 272 | } |
@@ -283,8 +283,7 @@ discard block |
||
283 | 283 | // Forcing conversion of input to UCS4 array |
284 | 284 | // If one time encoding is given, use this, else the objects property |
285 | 285 | switch ($one_time_encoding ? $one_time_encoding : $this->_api_encoding) { |
286 | - case 'utf8': |
|
287 | - $decoded = $this->_utf8_to_ucs4($decoded); |
|
286 | + case 'utf8' : $decoded = $this->_utf8_to_ucs4($decoded); |
|
288 | 287 | break; |
289 | 288 | case 'ucs4_string': |
290 | 289 | $decoded = $this->_ucs4_string_to_ucs4($decoded); |
@@ -380,12 +379,12 @@ discard block |
||
380 | 379 | } |
381 | 380 | } |
382 | 381 | $parsed['host'] = join('.', $arr); |
383 | - $return = (empty($parsed['scheme']) ? '' : $parsed['scheme'] . (strtolower($parsed['scheme']) == 'mailto' ? ':' : '://')). |
|
384 | - (empty($parsed['user']) ? '' : $parsed['user'] . (empty($parsed['pass']) ? '' : ':' . $parsed['pass']) . '@'). |
|
385 | - $parsed['host']. |
|
386 | - (empty($parsed['port']) ? '' : ':' . $parsed['port']). |
|
387 | - (empty($parsed['path']) ? '' : $parsed['path']). |
|
388 | - (empty($parsed['query']) ? '' : '?' . $parsed['query']). |
|
382 | + $return = (empty($parsed['scheme']) ? '' : $parsed['scheme'] . (strtolower($parsed['scheme']) == 'mailto' ? ':' : '://')) . |
|
383 | + (empty($parsed['user']) ? '' : $parsed['user'] . (empty($parsed['pass']) ? '' : ':' . $parsed['pass']) . '@') . |
|
384 | + $parsed['host'] . |
|
385 | + (empty($parsed['port']) ? '' : ':' . $parsed['port']) . |
|
386 | + (empty($parsed['path']) ? '' : $parsed['path']) . |
|
387 | + (empty($parsed['query']) ? '' : '?' . $parsed['query']) . |
|
389 | 388 | (empty($parsed['fragment']) ? '' : '#' . $parsed['fragment']); |
390 | 389 | return $return; |
391 | 390 | } |
@@ -439,16 +438,15 @@ discard block |
||
439 | 438 | for ($old_idx = $idx, $w = 1, $k = $this->_base; 1; $k += $this->_base) { |
440 | 439 | $digit = $this->_decode_digit($encoded{$enco_idx++}); |
441 | 440 | $idx += $digit * $w; |
442 | - $t = ($k <= $bias) ? $this->_tmin : |
|
443 | - (($k >= $bias + $this->_tmax) ? $this->_tmax : ($k - $bias)); |
|
441 | + $t = ($k <= $bias) ? $this->_tmin : (($k >= $bias + $this->_tmax) ? $this->_tmax : ($k - $bias)); |
|
444 | 442 | if ($digit < $t) { |
445 | 443 | break; |
446 | 444 | } |
447 | - $w = (int) ($w * ($this->_base - $t)); |
|
445 | + $w = (int)($w * ($this->_base - $t)); |
|
448 | 446 | } |
449 | 447 | $bias = $this->_adapt($idx - $old_idx, $deco_len + 1, $is_first); |
450 | 448 | $is_first = false; |
451 | - $char += (int) ($idx / ($deco_len + 1)); |
|
449 | + $char += (int)($idx / ($deco_len + 1)); |
|
452 | 450 | $idx %= ($deco_len + 1); |
453 | 451 | if ($deco_len > 0) { |
454 | 452 | // Make room for the decoded char |
@@ -540,13 +538,12 @@ discard block |
||
540 | 538 | $delta++; |
541 | 539 | } elseif ($decoded[$i] == $cur_code) { |
542 | 540 | for ($q = $delta, $k = $this->_base; 1; $k += $this->_base) { |
543 | - $t = ($k <= $bias) ? $this->_tmin : |
|
544 | - (($k >= $bias + $this->_tmax) ? $this->_tmax : $k - $bias); |
|
541 | + $t = ($k <= $bias) ? $this->_tmin : (($k >= $bias + $this->_tmax) ? $this->_tmax : $k - $bias); |
|
545 | 542 | if ($q < $t) { |
546 | 543 | break; |
547 | 544 | } |
548 | 545 | $encoded .= $this->_encode_digit(intval($t + (($q - $t) % ($this->_base - $t)))); //v0.4.5 Changed from ceil() to intval() |
549 | - $q = (int) (($q - $t) / ($this->_base - $t)); |
|
546 | + $q = (int)(($q - $t) / ($this->_base - $t)); |
|
550 | 547 | } |
551 | 548 | $encoded .= $this->_encode_digit($q); |
552 | 549 | $bias = $this->_adapt($delta, $codecount + 1, $is_first); |
@@ -641,18 +638,18 @@ discard block |
||
641 | 638 | if (0xAC00 <= $v && $v <= 0xD7AF) { |
642 | 639 | // Hangul syllable decomposition |
643 | 640 | foreach ($this->_hangul_decompose($v) as $out) { |
644 | - $output[] = (int) $out; |
|
641 | + $output[] = (int)$out; |
|
645 | 642 | } |
646 | 643 | } elseif (($this->_idn_version == '2003') && isset(self::$NP['replacemaps_2003'][$v])) { |
647 | 644 | foreach ($this->_apply_cannonical_ordering(self::$NP['replacemaps_2003'][$v]) as $out) { |
648 | - $output[] = (int) $out; |
|
645 | + $output[] = (int)$out; |
|
649 | 646 | } |
650 | 647 | } elseif (($this->_idn_version == '2008') && isset(self::$NP['replacemaps'][$v])) { |
651 | 648 | foreach ($this->_apply_cannonical_ordering(self::$NP['replacemaps'][$v]) as $out) { |
652 | - $output[] = (int) $out; |
|
649 | + $output[] = (int)$out; |
|
653 | 650 | } |
654 | 651 | } else { |
655 | - $output[] = (int) $v; |
|
652 | + $output[] = (int)$v; |
|
656 | 653 | } |
657 | 654 | } |
658 | 655 | // Before applying any Combining, try to rearrange any Hangul syllables |
@@ -703,13 +700,13 @@ discard block |
||
703 | 700 | */ |
704 | 701 | protected function _hangul_decompose($char) |
705 | 702 | { |
706 | - $sindex = (int) $char - $this->_sbase; |
|
703 | + $sindex = (int)$char - $this->_sbase; |
|
707 | 704 | if ($sindex < 0 || $sindex >= $this->_scount) { |
708 | 705 | return array($char); |
709 | 706 | } |
710 | 707 | $result = array(); |
711 | - $result[] = (int) $this->_lbase + $sindex / $this->_ncount; |
|
712 | - $result[] = (int) $this->_vbase + ($sindex % $this->_ncount) / $this->_tcount; |
|
708 | + $result[] = (int)$this->_lbase + $sindex / $this->_ncount; |
|
709 | + $result[] = (int)$this->_vbase + ($sindex % $this->_ncount) / $this->_tcount; |
|
713 | 710 | $T = intval($this->_tbase + $sindex % $this->_tcount); |
714 | 711 | if ($T != $this->_tbase) { |
715 | 712 | $result[] = $T; |
@@ -730,11 +727,11 @@ discard block |
||
730 | 727 | return array(); |
731 | 728 | } |
732 | 729 | $result = array(); |
733 | - $last = (int) $input[0]; |
|
730 | + $last = (int)$input[0]; |
|
734 | 731 | $result[] = $last; // copy first char from input to output |
735 | 732 | |
736 | 733 | for ($i = 1; $i < $inp_len; ++$i) { |
737 | - $char = (int) $input[$i]; |
|
734 | + $char = (int)$input[$i]; |
|
738 | 735 | $sindex = $last - $this->_sbase; |
739 | 736 | $lindex = $last - $this->_lbase; |
740 | 737 | $vindex = $char - $this->_vbase; |
@@ -749,7 +746,7 @@ discard block |
||
749 | 746 | // Find out, whether two current characters form L and V |
750 | 747 | if (0 <= $lindex && $lindex < $this->_lcount && 0 <= $vindex && $vindex < $this->_vcount) { |
751 | 748 | // create syllable of form LV |
752 | - $last = (int) $this->_sbase + ($lindex * $this->_vcount + $vindex) * $this->_tcount; |
|
749 | + $last = (int)$this->_sbase + ($lindex * $this->_vcount + $vindex) * $this->_tcount; |
|
753 | 750 | $result[(count($result) - 1)] = $last; // reset last |
754 | 751 | continue; // discard char |
755 | 752 | } |
@@ -898,7 +895,7 @@ discard block |
||
898 | 895 | return false; |
899 | 896 | } |
900 | 897 | if ('add' == $mode) { |
901 | - $output[$out_len] = (int) $v; |
|
898 | + $output[$out_len] = (int)$v; |
|
902 | 899 | ++$out_len; |
903 | 900 | continue; |
904 | 901 | } |
@@ -995,7 +992,7 @@ discard block |
||
995 | 992 | $out_len++; |
996 | 993 | $output[$out_len] = 0; |
997 | 994 | } |
998 | - $output[$out_len] += ord($input{$i}) << (8 * (3 - ($i % 4) ) ); |
|
995 | + $output[$out_len] += ord($input{$i}) << (8 * (3 - ($i % 4))); |
|
999 | 996 | } |
1000 | 997 | return $output; |
1001 | 998 | } |
@@ -1012,7 +1009,7 @@ discard block |
||
1012 | 1009 | if (self::$_mb_string_overload) { |
1013 | 1010 | return mb_strlen($string, '8bit'); |
1014 | 1011 | } |
1015 | - return strlen((binary) $string); |
|
1012 | + return strlen((binary)$string); |
|
1016 | 1013 | } |
1017 | 1014 | |
1018 | 1015 | /** |
@@ -49,7 +49,8 @@ discard block |
||
49 | 49 | * @copyright 2004-2014 phlyLabs Berlin, http://phlylabs.de |
50 | 50 | * @version 0.9.0 2014-12-12 |
51 | 51 | */ |
52 | -class idna_convert { |
|
52 | +class idna_convert |
|
53 | +{ |
|
53 | 54 | |
54 | 55 | private $version = '0.9.0'; |
55 | 56 | protected $sub_version = 'main'; |
@@ -197,7 +198,8 @@ discard block |
||
197 | 198 | |
198 | 199 | // Negotiate input and try to determine, whether it is a plain string, |
199 | 200 | // an email address or something like a complete URL |
200 | - if (strpos($input, '@')) { // Maybe it is an email address |
|
201 | + if (strpos($input, '@')) { |
|
202 | +// Maybe it is an email address |
|
201 | 203 | // No no in strict mode |
202 | 204 | if ($this->_strict_mode) { |
203 | 205 | $this->_error('Only simple domain name parts can be handled in strict mode'); |
@@ -225,7 +227,8 @@ discard block |
||
225 | 227 | } |
226 | 228 | $email_pref = join('.', $arr); |
227 | 229 | $return = $email_pref . '@' . $input; |
228 | - } elseif (preg_match('![:\./]!', $input)) { // Or a complete domain name (with or without paths / parameters) |
|
230 | + } elseif (preg_match('![:\./]!', $input)) { |
|
231 | +// Or a complete domain name (with or without paths / parameters) |
|
229 | 232 | // No no in strict mode |
230 | 233 | if ($this->_strict_mode) { |
231 | 234 | $this->_error('Only simple domain name parts can be handled in strict mode'); |
@@ -248,7 +251,8 @@ discard block |
||
248 | 251 | (empty($parsed['path']) ? '' : $parsed['path']). |
249 | 252 | (empty($parsed['query']) ? '' : '?' . $parsed['query']). |
250 | 253 | (empty($parsed['fragment']) ? '' : '#' . $parsed['fragment']); |
251 | - } else { // parse_url seems to have failed, try without it |
|
254 | + } else { |
|
255 | +// parse_url seems to have failed, try without it |
|
252 | 256 | $arr = explode('.', $input); |
253 | 257 | foreach ($arr as $k => $v) { |
254 | 258 | $conv = $this->_decode($v); |
@@ -256,7 +260,8 @@ discard block |
||
256 | 260 | } |
257 | 261 | $return = join('.', $arr); |
258 | 262 | } |
259 | - } else { // Otherwise we consider it being a pure domain name string |
|
263 | + } else { |
|
264 | +// Otherwise we consider it being a pure domain name string |
|
260 | 265 | $return = $this->_decode($input); |
261 | 266 | if (!$return) { |
262 | 267 | $return = $input; |
@@ -865,7 +870,8 @@ discard block |
||
865 | 870 | $test = 'none'; |
866 | 871 | for ($k = 0; $k < $inp_len; ++$k) { |
867 | 872 | $v = ord($input{$k}); // Extract byte from input string |
868 | - if ($v < 128) { // We found an ASCII char - put into stirng as is |
|
873 | + if ($v < 128) { |
|
874 | +// We found an ASCII char - put into stirng as is |
|
869 | 875 | $output[$out_len] = $v; |
870 | 876 | ++$out_len; |
871 | 877 | if ('add' == $mode) { |
@@ -874,23 +880,29 @@ discard block |
||
874 | 880 | } |
875 | 881 | continue; |
876 | 882 | } |
877 | - if ('next' == $mode) { // Try to find the next start byte; determine the width of the Unicode char |
|
883 | + if ('next' == $mode) { |
|
884 | +// Try to find the next start byte; determine the width of the Unicode char |
|
878 | 885 | $start_byte = $v; |
879 | 886 | $mode = 'add'; |
880 | 887 | $test = 'range'; |
881 | - if ($v >> 5 == 6) { // &110xxxxx 10xxxxx |
|
888 | + if ($v >> 5 == 6) { |
|
889 | +// &110xxxxx 10xxxxx |
|
882 | 890 | $next_byte = 0; // Tells, how many times subsequent bitmasks must rotate 6bits to the left |
883 | 891 | $v = ($v - 192) << 6; |
884 | - } elseif ($v >> 4 == 14) { // &1110xxxx 10xxxxxx 10xxxxxx |
|
892 | + } elseif ($v >> 4 == 14) { |
|
893 | +// &1110xxxx 10xxxxxx 10xxxxxx |
|
885 | 894 | $next_byte = 1; |
886 | 895 | $v = ($v - 224) << 12; |
887 | - } elseif ($v >> 3 == 30) { // &11110xxx 10xxxxxx 10xxxxxx 10xxxxxx |
|
896 | + } elseif ($v >> 3 == 30) { |
|
897 | +// &11110xxx 10xxxxxx 10xxxxxx 10xxxxxx |
|
888 | 898 | $next_byte = 2; |
889 | 899 | $v = ($v - 240) << 18; |
890 | - } elseif ($v >> 2 == 62) { // &111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx |
|
900 | + } elseif ($v >> 2 == 62) { |
|
901 | +// &111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx |
|
891 | 902 | $next_byte = 3; |
892 | 903 | $v = ($v - 248) << 24; |
893 | - } elseif ($v >> 1 == 126) { // &1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx |
|
904 | + } elseif ($v >> 1 == 126) { |
|
905 | +// &1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx |
|
894 | 906 | $next_byte = 4; |
895 | 907 | $v = ($v - 252) << 30; |
896 | 908 | } else { |
@@ -911,7 +923,8 @@ discard block |
||
911 | 923 | return false; |
912 | 924 | } |
913 | 925 | } |
914 | - if ($v >> 6 == 2) { // Bit mask must be 10xxxxxx |
|
926 | + if ($v >> 6 == 2) { |
|
927 | +// Bit mask must be 10xxxxxx |
|
915 | 928 | $v = ($v - 128) << ($next_byte * 6); |
916 | 929 | $output[($out_len - 1)] += $v; |
917 | 930 | --$next_byte; |
@@ -937,13 +950,17 @@ discard block |
||
937 | 950 | { |
938 | 951 | $output = ''; |
939 | 952 | foreach ($input as $k => $v) { |
940 | - if ($v < 128) { // 7bit are transferred literally |
|
953 | + if ($v < 128) { |
|
954 | +// 7bit are transferred literally |
|
941 | 955 | $output .= chr($v); |
942 | - } elseif ($v < (1 << 11)) { // 2 bytes |
|
956 | + } elseif ($v < (1 << 11)) { |
|
957 | +// 2 bytes |
|
943 | 958 | $output .= chr(192 + ($v >> 6)) . chr(128 + ($v & 63)); |
944 | - } elseif ($v < (1 << 16)) { // 3 bytes |
|
959 | + } elseif ($v < (1 << 16)) { |
|
960 | +// 3 bytes |
|
945 | 961 | $output .= chr(224 + ($v >> 12)) . chr(128 + (($v >> 6) & 63)) . chr(128 + ($v & 63)); |
946 | - } elseif ($v < (1 << 21)) { // 4 bytes |
|
962 | + } elseif ($v < (1 << 21)) { |
|
963 | +// 4 bytes |
|
947 | 964 | $output .= chr(240 + ($v >> 18)) . chr(128 + (($v >> 12) & 63)) . chr(128 + (($v >> 6) & 63)) . chr(128 + ($v & 63)); |
948 | 965 | } else { |
949 | 966 | $this->_error('Conversion from UCS-4 to UTF-8 failed: malformed input at byte ' . $k); |
@@ -30,15 +30,21 @@ discard block |
||
30 | 30 | } |
31 | 31 | if (function_exists('mb_convert_encoding')) { |
32 | 32 | $conv = @mb_convert_encoding($string, 'UTF-8', strtoupper($encoding)); |
33 | - if ($conv) return $conv; |
|
33 | + if ($conv) { |
|
34 | + return $conv; |
|
35 | + } |
|
34 | 36 | } |
35 | 37 | if (function_exists('iconv')) { |
36 | 38 | $conv = @iconv(strtoupper($encoding), 'UTF-8', $string); |
37 | - if ($conv) return $conv; |
|
39 | + if ($conv) { |
|
40 | + return $conv; |
|
41 | + } |
|
38 | 42 | } |
39 | 43 | if (function_exists('libiconv')) { |
40 | 44 | $conv = @libiconv(strtoupper($encoding), 'UTF-8', $string); |
41 | - if ($conv) return $conv; |
|
45 | + if ($conv) { |
|
46 | + return $conv; |
|
47 | + } |
|
42 | 48 | } |
43 | 49 | return $safe; |
44 | 50 | } |
@@ -55,7 +61,9 @@ discard block |
||
55 | 61 | function decode_utf8($string = '', $encoding = 'iso-8859-1', $safe_mode = false) |
56 | 62 | { |
57 | 63 | $safe = ($safe_mode) ? $string : false; |
58 | - if (!$encoding) $encoding = 'ISO-8859-1'; |
|
64 | + if (!$encoding) { |
|
65 | + $encoding = 'ISO-8859-1'; |
|
66 | + } |
|
59 | 67 | if (strtoupper($encoding) == 'UTF-8' || strtoupper($encoding) == 'UTF8') { |
60 | 68 | return $string; |
61 | 69 | } elseif (strtoupper($encoding) == 'ISO-8859-1') { |
@@ -67,15 +75,21 @@ discard block |
||
67 | 75 | } |
68 | 76 | if (function_exists('mb_convert_encoding')) { |
69 | 77 | $conv = @mb_convert_encoding($string, strtoupper($encoding), 'UTF-8'); |
70 | - if ($conv) return $conv; |
|
78 | + if ($conv) { |
|
79 | + return $conv; |
|
80 | + } |
|
71 | 81 | } |
72 | 82 | if (function_exists('iconv')) { |
73 | 83 | $conv = @iconv('UTF-8', strtoupper($encoding), $string); |
74 | - if ($conv) return $conv; |
|
84 | + if ($conv) { |
|
85 | + return $conv; |
|
86 | + } |
|
75 | 87 | } |
76 | 88 | if (function_exists('libiconv')) { |
77 | 89 | $conv = @libiconv('UTF-8', strtoupper($encoding), $string); |
78 | - if ($conv) return $conv; |
|
90 | + if ($conv) { |
|
91 | + return $conv; |
|
92 | + } |
|
79 | 93 | } |
80 | 94 | return $safe; |
81 | 95 | } |
@@ -89,7 +103,9 @@ discard block |
||
89 | 103 | */ |
90 | 104 | function map_w1252_iso8859_1($string = '') |
91 | 105 | { |
92 | - if ($string == '') return ''; |
|
106 | + if ($string == '') { |
|
107 | + return ''; |
|
108 | + } |
|
93 | 109 | $return = ''; |
94 | 110 | for ($i = 0; $i < strlen($string); ++$i) { |
95 | 111 | $c = ord($string{$i}); |
@@ -116,7 +132,9 @@ discard block |
||
116 | 132 | */ |
117 | 133 | function map_iso8859_1_w1252($string = '') |
118 | 134 | { |
119 | - if ($string == '') return ''; |
|
135 | + if ($string == '') { |
|
136 | + return ''; |
|
137 | + } |
|
120 | 138 | $return = ''; |
121 | 139 | for ($i = 0; $i < strlen($string); ++$i) { |
122 | 140 | $c = ord($string{$i}); |
@@ -24,7 +24,7 @@ |
||
24 | 24 | if (isset($_REQUEST['lang'])) { |
25 | 25 | if ('de' == $_REQUEST['lang'] || 'en' == $_REQUEST['lang']) { |
26 | 26 | $lang = $_REQUEST['lang']; |
27 | - $add .= '<input type="hidden" name="lang" value="'.$lang.'" />'."\n"; |
|
27 | + $add .= '<input type="hidden" name="lang" value="' . $lang . '" />' . "\n"; |
|
28 | 28 | } |
29 | 29 | } |
30 | 30 | ?> |
@@ -206,7 +206,7 @@ |
||
206 | 206 | $p = explode($separator, get_class($this)); |
207 | 207 | $this->name = $p[0]; |
208 | 208 | $this->directory = $this->name; // legacy handling |
209 | - $this->baseDir = $this->libBaseDir = realpath(dirname($this->reflection->getFileName()).'/../..'); |
|
209 | + $this->baseDir = $this->libBaseDir = realpath(dirname($this->reflection->getFileName()) . '/../..'); |
|
210 | 210 | if (realpath($this->baseDir . '/lib/' . $this->name)) { |
211 | 211 | $this->libBaseDir = realpath($this->baseDir . '/lib/' . $this->name); |
212 | 212 | } |
@@ -644,7 +644,7 @@ discard block |
||
644 | 644 | $ostemplate = DataUtil::formatForOS($template); |
645 | 645 | try { |
646 | 646 | $bundle = $this->getContainer()->get('kernel')->getBundle($module); |
647 | - $bundlePath = $relativepath = $bundle->getRelativePath().'/Resources/views'; |
|
647 | + $bundlePath = $relativepath = $bundle->getRelativePath() . '/Resources/views'; |
|
648 | 648 | } catch (\InvalidArgumentException $e) { |
649 | 649 | } |
650 | 650 | |
@@ -741,7 +741,7 @@ discard block |
||
741 | 741 | $core['language'] = $this->language; |
742 | 742 | |
743 | 743 | // add userdata |
744 | - $core['user'] = UserUtil::getVars(SessionUtil::getVar('uid')); |
|
744 | + $core['user'] = UserUtil::getVars(SessionUtil::getVar('uid')); |
|
745 | 745 | |
746 | 746 | if (System::isLegacyMode()) { |
747 | 747 | // add modvars of current modules |
@@ -859,7 +859,7 @@ discard block |
||
859 | 859 | $this->_filter_auto_id($compile_id); |
860 | 860 | } |
861 | 861 | |
862 | - $auto_id = $cache_id . (!empty($compile_id) ? '/'.$compile_id : ''); |
|
862 | + $auto_id = $cache_id . (!empty($compile_id) ? '/' . $compile_id : ''); |
|
863 | 863 | |
864 | 864 | $auto_id = trim($auto_id, '/'); |
865 | 865 | |
@@ -944,7 +944,7 @@ discard block |
||
944 | 944 | if (empty($themedir)) { |
945 | 945 | $themedir = $this->themeinfo['directory']; |
946 | 946 | } |
947 | - $path .= '--t_'.$themedir.'-l_' . $this->language; |
|
947 | + $path .= '--t_' . $themedir . '-l_' . $this->language; |
|
948 | 948 | |
949 | 949 | // if we are not compiling, end with a suffix |
950 | 950 | if (!$tocompile) { |
@@ -1117,7 +1117,7 @@ discard block |
||
1117 | 1117 | $moduledir = $this->modinfo['directory']; |
1118 | 1118 | } |
1119 | 1119 | |
1120 | - return $this->clear_folder($this->cache_dir .'/'. $moduledir); |
|
1120 | + return $this->clear_folder($this->cache_dir . '/' . $moduledir); |
|
1121 | 1121 | } |
1122 | 1122 | |
1123 | 1123 | /** |
@@ -2950,7 +2950,7 @@ discard block |
||
2950 | 2950 | if ($this->cache_modified_check) { |
2951 | 2951 | $_server_vars = ($this->request_use_auto_globals) ? $_SERVER : $GLOBALS['HTTP_SERVER_VARS']; |
2952 | 2952 | $_last_modified_date = @substr($_server_vars['HTTP_IF_MODIFIED_SINCE'], 0, strpos($_server_vars['HTTP_IF_MODIFIED_SINCE'], 'GMT') + 3); |
2953 | - $_gmt_mtime = gmdate('D, d M Y H:i:s', $this->_cache_info['timestamp']).' GMT'; |
|
2953 | + $_gmt_mtime = gmdate('D, d M Y H:i:s', $this->_cache_info['timestamp']) . ' GMT'; |
|
2954 | 2954 | if (@count($this->_cache_info['insert_tags']) == 0 |
2955 | 2955 | && !$this->_cache_serials |
2956 | 2956 | && $_gmt_mtime == $_last_modified_date) { |
@@ -2960,7 +2960,7 @@ discard block |
||
2960 | 2960 | header('HTTP/1.1 304 Not Modified'); |
2961 | 2961 | } |
2962 | 2962 | } else { |
2963 | - header('Last-Modified: '.$_gmt_mtime); |
|
2963 | + header('Last-Modified: ' . $_gmt_mtime); |
|
2964 | 2964 | echo $_smarty_results; |
2965 | 2965 | } |
2966 | 2966 | } else { |
@@ -2981,7 +2981,7 @@ discard block |
||
2981 | 2981 | } else { |
2982 | 2982 | $this->_cache_info['template'][$resource_name] = true; |
2983 | 2983 | if ($this->cache_modified_check && $display) { |
2984 | - header('Last-Modified: '.gmdate('D, d M Y H:i:s', time()).' GMT'); |
|
2984 | + header('Last-Modified: ' . gmdate('D, d M Y H:i:s', time()) . ' GMT'); |
|
2985 | 2985 | } |
2986 | 2986 | } |
2987 | 2987 | } |
@@ -289,10 +289,10 @@ discard block |
||
289 | 289 | // during {include file='my_template.tpl'} this enables us to store selected module |
290 | 290 | // templates in the theme while others can be kept in the module itself. |
291 | 291 | $this->register_resource('z', ['Zikula_View_Resource', |
292 | - 'z_get_template', |
|
293 | - 'z_get_timestamp', |
|
294 | - 'z_get_secure', |
|
295 | - 'z_get_trusted']); |
|
292 | + 'z_get_template', |
|
293 | + 'z_get_timestamp', |
|
294 | + 'z_get_secure', |
|
295 | + 'z_get_trusted']); |
|
296 | 296 | |
297 | 297 | // set 'z' as default resource type |
298 | 298 | $this->default_resource_type = 'z'; |
@@ -318,18 +318,18 @@ discard block |
||
318 | 318 | |
319 | 319 | // assign some useful settings |
320 | 320 | $this->assign('homepage', $this->homepage) |
321 | - ->assign('modinfo', $this->modinfo) |
|
322 | - ->assign('module', $moduleName) |
|
323 | - ->assign('toplevelmodule', $this->toplevelmodule) |
|
324 | - ->assign('type', $this->type) |
|
325 | - ->assign('func', $this->func) |
|
326 | - ->assign('lang', $this->language) |
|
327 | - ->assign('themeinfo', $this->themeinfo) |
|
328 | - ->assign('themepath', isset($themeBundle) ? $themeBundle->getRelativePath() : $this->baseurl . 'themes/' . $theme) |
|
329 | - ->assign('baseurl', $this->baseurl) |
|
330 | - ->assign('baseuri', $this->baseuri) |
|
331 | - ->assign('moduleBundle', ModUtil::getModule($moduleName)) // is NULL for pre-1.4.0-type modules |
|
332 | - ->assign('themeBundle', $themeBundle); |
|
321 | + ->assign('modinfo', $this->modinfo) |
|
322 | + ->assign('module', $moduleName) |
|
323 | + ->assign('toplevelmodule', $this->toplevelmodule) |
|
324 | + ->assign('type', $this->type) |
|
325 | + ->assign('func', $this->func) |
|
326 | + ->assign('lang', $this->language) |
|
327 | + ->assign('themeinfo', $this->themeinfo) |
|
328 | + ->assign('themepath', isset($themeBundle) ? $themeBundle->getRelativePath() : $this->baseurl . 'themes/' . $theme) |
|
329 | + ->assign('baseurl', $this->baseurl) |
|
330 | + ->assign('baseuri', $this->baseuri) |
|
331 | + ->assign('moduleBundle', ModUtil::getModule($moduleName)) // is NULL for pre-1.4.0-type modules |
|
332 | + ->assign('themeBundle', $themeBundle); |
|
333 | 333 | |
334 | 334 | if (isset($themeBundle)) { |
335 | 335 | $stylePath = $themeBundle->getRelativePath() . "/Resources/public/css"; |
@@ -343,9 +343,9 @@ discard block |
||
343 | 343 | $imageLangPath = $this->baseurl . "themes/$theme/images/" . $this->language; |
344 | 344 | } |
345 | 345 | $this->assign('stylepath', $stylePath) |
346 | - ->assign('scriptpath', $javascriptPath) |
|
347 | - ->assign('imagepath', $imagePath) |
|
348 | - ->assign('imagelangpath', $imageLangPath); |
|
346 | + ->assign('scriptpath', $javascriptPath) |
|
347 | + ->assign('imagepath', $imagePath) |
|
348 | + ->assign('imagelangpath', $imageLangPath); |
|
349 | 349 | |
350 | 350 | // for {gt} template plugin to detect gettext domain |
351 | 351 | if ($this->modinfo['type'] == ModUtil::TYPE_MODULE) { |
@@ -152,7 +152,7 @@ |
||
152 | 152 | |
153 | 153 | if (isset($debug)) { |
154 | 154 | $qb->set('w.debug', ':newDebug') |
155 | - ->setParameter('newDebug', $debug); |
|
155 | + ->setParameter('newDebug', $debug); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | $query = $qb->where('w.id = :id') |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | $this->workflow['workflow'] = []; |
183 | 183 | } else { |
184 | 184 | $state = 'error'; |
185 | - $this->workflow['errorMessage'] = $this->unexpectedXMLError($name, "$state ". __LINE__); |
|
185 | + $this->workflow['errorMessage'] = $this->unexpectedXMLError($name, "$state " . __LINE__); |
|
186 | 186 | } |
187 | 187 | break; |
188 | 188 | |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | $this->workflow['actions'] = []; |
202 | 202 | break; |
203 | 203 | default: |
204 | - $this->workflow['errorMessage'] = $this->unexpectedXMLError($name, "$state ". __LINE__); |
|
204 | + $this->workflow['errorMessage'] = $this->unexpectedXMLError($name, "$state " . __LINE__); |
|
205 | 205 | $state = 'error'; |
206 | 206 | break; |
207 | 207 | } |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | $this->workflow['stateValue'] = ['id' => trim($attribs['ID'])]; |
213 | 213 | $state = 'state'; |
214 | 214 | } else { |
215 | - $this->workflow['errorMessage'] = $this->unexpectedXMLError($name, "$state ". __LINE__); |
|
215 | + $this->workflow['errorMessage'] = $this->unexpectedXMLError($name, "$state " . __LINE__); |
|
216 | 216 | $state = 'error'; |
217 | 217 | } |
218 | 218 | break; |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | if ($name == 'TITLE' || $name == 'DESCRIPTION') { |
222 | 222 | $this->workflow['value'] = ''; |
223 | 223 | } else { |
224 | - $this->workflow['errorMessage'] = $this->unexpectedXMLError($name, "$state ". __LINE__); |
|
224 | + $this->workflow['errorMessage'] = $this->unexpectedXMLError($name, "$state " . __LINE__); |
|
225 | 225 | $state = 'error'; |
226 | 226 | } |
227 | 227 | break; |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | ]; |
237 | 237 | $state = 'action'; |
238 | 238 | } else { |
239 | - $this->workflow['errorMessage'] = $this->unexpectedXMLError($name, "$state ". __LINE__); |
|
239 | + $this->workflow['errorMessage'] = $this->unexpectedXMLError($name, "$state " . __LINE__); |
|
240 | 240 | $state = 'error'; |
241 | 241 | } |
242 | 242 | break; |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | $this->workflow['actionParameter'] = $attribs; |
260 | 260 | break; |
261 | 261 | default: |
262 | - $this->workflow['errorMessage'] = $this->unexpectedXMLError($name, "$state ". __LINE__); |
|
262 | + $this->workflow['errorMessage'] = $this->unexpectedXMLError($name, "$state " . __LINE__); |
|
263 | 263 | $state = 'error'; |
264 | 264 | break; |
265 | 265 | } |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | if ($name == '') { |
270 | 270 | $state = ''; |
271 | 271 | } else { |
272 | - $this->workflow['errorMessage'] = $this->unexpectedXMLError($name, "$state ". __LINE__); |
|
272 | + $this->workflow['errorMessage'] = $this->unexpectedXMLError($name, "$state " . __LINE__); |
|
273 | 273 | $state = 'error'; |
274 | 274 | } |
275 | 275 | break; |
@@ -388,7 +388,7 @@ |
||
388 | 388 | $workflow = $query->getArrayResult(); |
389 | 389 | if ($workflow) { |
390 | 390 | $workflow = $workflow[0]; |
391 | - $renameKey = function (&$array, $old, $new) { |
|
391 | + $renameKey = function(&$array, $old, $new) { |
|
392 | 392 | $array[$new] = $array[$old]; |
393 | 393 | unset($array[$old]); |
394 | 394 | }; |
@@ -197,10 +197,10 @@ |
||
197 | 197 | |
198 | 198 | //create the dql query. |
199 | 199 | $query = $entityManager->createQueryBuilder() |
200 | - ->delete('Zikula\Core\Doctrine\Entity\WorkflowEntity', 'w') |
|
201 | - ->where('w.module = :module') |
|
202 | - ->setParameter('module', $theModule) |
|
203 | - ->getQuery(); |
|
200 | + ->delete('Zikula\Core\Doctrine\Entity\WorkflowEntity', 'w') |
|
201 | + ->where('w.module = :module') |
|
202 | + ->setParameter('module', $theModule) |
|
203 | + ->getQuery(); |
|
204 | 204 | |
205 | 205 | $result = $query->execute(); |
206 | 206 |
@@ -305,7 +305,7 @@ |
||
305 | 305 | if (!isset($this->requirements[$token[1]])) { |
306 | 306 | $this->requirements[$token[1]] = '[^/\.\-]+'; |
307 | 307 | } |
308 | - $regex .= '(?P<'.$token[1].'>'.$this->requirements[$token[1]].')'; |
|
308 | + $regex .= '(?P<' . $token[1] . '>' . $this->requirements[$token[1]] . ')'; |
|
309 | 309 | } elseif ($token[0] == 'text' || $token[0] == 'separator') { |
310 | 310 | if ($token[1] == '*') { |
311 | 311 | if ($this->tokens[$i - 1] && $this->tokens[$i - 1][0] == 'separator') { |