@@ -360,7 +360,7 @@ discard block |
||
| 360 | 360 | * Get output mode |
| 361 | 361 | * @see setOutputMode() |
| 362 | 362 | * |
| 363 | - * @return output mode constant |
|
| 363 | + * @return integer mode constant |
|
| 364 | 364 | */ |
| 365 | 365 | public function getOutputMode() |
| 366 | 366 | { |
@@ -389,9 +389,8 @@ discard block |
||
| 389 | 389 | /** |
| 390 | 390 | * Get input and ouput encoding. |
| 391 | 391 | * |
| 392 | - * @param string $enc example: 'UTF-8' |
|
| 393 | 392 | * |
| 394 | - * @return $this |
|
| 393 | + * @return string |
|
| 395 | 394 | */ |
| 396 | 395 | public function getEncoding() |
| 397 | 396 | { |
@@ -743,6 +742,7 @@ discard block |
||
| 743 | 742 | * |
| 744 | 743 | * @param PHPTAL $local_tpl is PHPTAL instance of the file in which macro is defined |
| 745 | 744 | * (it will be different from $this if it's external macro call) |
| 745 | + * @param string $path |
|
| 746 | 746 | * @access private |
| 747 | 747 | */ |
| 748 | 748 | final public function _executeMacroOfTemplate($path, PHPTAL $local_tpl) |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | * |
| 176 | 176 | * @param string $path Template file path. |
| 177 | 177 | */ |
| 178 | - public function __construct($path=false) |
|
| 178 | + public function __construct($path = false) |
|
| 179 | 179 | { |
| 180 | 180 | $this->_path = $path; |
| 181 | 181 | $this->_globalContext = new stdClass(); |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | * |
| 204 | 204 | * @return PHPTAL |
| 205 | 205 | */ |
| 206 | - public static function create($path=false) |
|
| 206 | + public static function create($path = false) |
|
| 207 | 207 | { |
| 208 | 208 | return new PHPTAL($path); |
| 209 | 209 | } |
@@ -408,7 +408,7 @@ discard block |
||
| 408 | 408 | */ |
| 409 | 409 | public function setPhpCodeDestination($path) |
| 410 | 410 | { |
| 411 | - $this->_phpCodeDestination = rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; |
|
| 411 | + $this->_phpCodeDestination = rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR; |
|
| 412 | 412 | $this->resetPrepared(); |
| 413 | 413 | return $this; |
| 414 | 414 | } |
@@ -548,7 +548,7 @@ discard block |
||
| 548 | 548 | private function getPreFiltersCacheId() |
| 549 | 549 | { |
| 550 | 550 | $cacheid = ''; |
| 551 | - foreach($this->getPreFilters() as $key => $prefilter) { |
|
| 551 | + foreach ($this->getPreFilters() as $key => $prefilter) { |
|
| 552 | 552 | if ($prefilter instanceof PHPTAL_PreFilter) { |
| 553 | 553 | $cacheid .= $key.$prefilter->getCacheId(); |
| 554 | 554 | } elseif ($prefilter instanceof PHPTAL_Filter) { |
@@ -569,7 +569,7 @@ discard block |
||
| 569 | 569 | { |
| 570 | 570 | $prefilters = $this->getPreFilters(); |
| 571 | 571 | |
| 572 | - foreach($prefilters as $prefilter) { |
|
| 572 | + foreach ($prefilters as $prefilter) { |
|
| 573 | 573 | if ($prefilter instanceof PHPTAL_PreFilter) { |
| 574 | 574 | $prefilter->setPHPTAL($this); |
| 575 | 575 | } |
@@ -675,12 +675,12 @@ discard block |
||
| 675 | 675 | |
| 676 | 676 | // unshift doctype |
| 677 | 677 | if ($this->_context->_docType) { |
| 678 | - $res = $this->_context->_docType . $res; |
|
| 678 | + $res = $this->_context->_docType.$res; |
|
| 679 | 679 | } |
| 680 | 680 | |
| 681 | 681 | // unshift xml declaration |
| 682 | 682 | if ($this->_context->_xmlDeclaration) { |
| 683 | - $res = $this->_context->_xmlDeclaration . "\n" . $res; |
|
| 683 | + $res = $this->_context->_xmlDeclaration."\n".$res; |
|
| 684 | 684 | } |
| 685 | 685 | |
| 686 | 686 | if ($this->_postfilter) { |
@@ -768,7 +768,7 @@ discard block |
||
| 768 | 768 | $this->externalMacroTemplatesCache[$file] = $tpl; |
| 769 | 769 | } |
| 770 | 770 | |
| 771 | - $fun = $tpl->getFunctionName() . '_' . strtr($macroName, "-", "_"); |
|
| 771 | + $fun = $tpl->getFunctionName().'_'.strtr($macroName, "-", "_"); |
|
| 772 | 772 | if (!function_exists($fun)) { |
| 773 | 773 | throw new PHPTAL_MacroMissingException("Macro '$macroName' is not defined in $file", $this->_source->getRealPath()); |
| 774 | 774 | } |
@@ -777,11 +777,11 @@ discard block |
||
| 777 | 777 | |
| 778 | 778 | } else { |
| 779 | 779 | // call local macro |
| 780 | - $fun = $local_tpl->getFunctionName() . '_' . strtr($path, "-", "_"); |
|
| 780 | + $fun = $local_tpl->getFunctionName().'_'.strtr($path, "-", "_"); |
|
| 781 | 781 | if (!function_exists($fun)) { |
| 782 | 782 | throw new PHPTAL_MacroMissingException("Macro '$path' is not defined", $local_tpl->_source->getRealPath()); |
| 783 | 783 | } |
| 784 | - $fun( $local_tpl, $this); |
|
| 784 | + $fun($local_tpl, $this); |
|
| 785 | 785 | } |
| 786 | 786 | } |
| 787 | 787 | |
@@ -791,7 +791,7 @@ discard block |
||
| 791 | 791 | private function setCodeFile() |
| 792 | 792 | { |
| 793 | 793 | $this->findTemplate(); |
| 794 | - $this->_codeFile = $this->getPhpCodeDestination() . $this->getFunctionName() . '.' . $this->getPhpCodeExtension(); |
|
| 794 | + $this->_codeFile = $this->getPhpCodeDestination().$this->getFunctionName().'.'.$this->getPhpCodeExtension(); |
|
| 795 | 795 | } |
| 796 | 796 | |
| 797 | 797 | protected function resetPrepared() |
@@ -819,7 +819,7 @@ discard block |
||
| 819 | 819 | |
| 820 | 820 | // i'm not sure where that belongs, but not in normal path of execution |
| 821 | 821 | // because some sites have _a lot_ of files in temp |
| 822 | - if ($this->getCachePurgeFrequency() && mt_rand()%$this->getCachePurgeFrequency() == 0) { |
|
| 822 | + if ($this->getCachePurgeFrequency() && mt_rand() % $this->getCachePurgeFrequency() == 0) { |
|
| 823 | 823 | $this->cleanUpGarbage(); |
| 824 | 824 | } |
| 825 | 825 | |
@@ -836,7 +836,7 @@ discard block |
||
| 836 | 836 | try { |
| 837 | 837 | eval("?>\n".$result); |
| 838 | 838 | } |
| 839 | - catch(Exception $e) { |
|
| 839 | + catch (Exception $e) { |
|
| 840 | 840 | ob_end_clean(); |
| 841 | 841 | throw $e; |
| 842 | 842 | } |
@@ -845,7 +845,7 @@ discard block |
||
| 845 | 845 | $msg = str_replace('eval()\'d code', $this->getCodePath(), ob_get_clean()); |
| 846 | 846 | |
| 847 | 847 | // greedy .* ensures last match |
| 848 | - if (preg_match('/.*on line (\d+)$/m', $msg, $m)) $line=$m[1]; else $line=0; |
|
| 848 | + if (preg_match('/.*on line (\d+)$/m', $msg, $m)) $line = $m[1]; else $line = 0; |
|
| 849 | 849 | throw new PHPTAL_TemplateException(trim($msg), $this->getCodePath(), $line); |
| 850 | 850 | } |
| 851 | 851 | ob_end_clean(); |
@@ -886,7 +886,7 @@ discard block |
||
| 886 | 886 | */ |
| 887 | 887 | public function setCachePurgeFrequency($n) |
| 888 | 888 | { |
| 889 | - $this->_cachePurgeFrequency = (int)$n; |
|
| 889 | + $this->_cachePurgeFrequency = (int) $n; |
|
| 890 | 890 | return $this; |
| 891 | 891 | } |
| 892 | 892 | |
@@ -906,14 +906,14 @@ discard block |
||
| 906 | 906 | */ |
| 907 | 907 | public function cleanUpGarbage() |
| 908 | 908 | { |
| 909 | - $cacheFilesExpire = time() - $this->getCacheLifetime() * 3600 * 24; |
|
| 909 | + $cacheFilesExpire = time()-$this->getCacheLifetime() * 3600 * 24; |
|
| 910 | 910 | |
| 911 | 911 | // relies on templates sorting order being related to their modification dates |
| 912 | - $upperLimit = $this->getPhpCodeDestination() . $this->getFunctionNamePrefix($cacheFilesExpire) . '_'; |
|
| 913 | - $lowerLimit = $this->getPhpCodeDestination() . $this->getFunctionNamePrefix(0); |
|
| 912 | + $upperLimit = $this->getPhpCodeDestination().$this->getFunctionNamePrefix($cacheFilesExpire).'_'; |
|
| 913 | + $lowerLimit = $this->getPhpCodeDestination().$this->getFunctionNamePrefix(0); |
|
| 914 | 914 | |
| 915 | 915 | // second * gets phptal:cache |
| 916 | - $cacheFiles = glob($this->getPhpCodeDestination() . 'tpl_????????_*.' . $this->getPhpCodeExtension() . '*'); |
|
| 916 | + $cacheFiles = glob($this->getPhpCodeDestination().'tpl_????????_*.'.$this->getPhpCodeExtension().'*'); |
|
| 917 | 917 | |
| 918 | 918 | if ($cacheFiles) { |
| 919 | 919 | foreach ($cacheFiles as $index => $file) { |
@@ -936,7 +936,7 @@ discard block |
||
| 936 | 936 | public function cleanUpCache() |
| 937 | 937 | { |
| 938 | 938 | $filename = $this->getCodePath(); |
| 939 | - $cacheFiles = glob($filename . '?*'); |
|
| 939 | + $cacheFiles = glob($filename.'?*'); |
|
| 940 | 940 | if ($cacheFiles) { |
| 941 | 941 | foreach ($cacheFiles as $file) { |
| 942 | 942 | if (substr($file, 0, strlen($filename)) !== $filename) continue; // safety net |
@@ -975,7 +975,7 @@ discard block |
||
| 975 | 975 | $basename = preg_replace('/\.[a-z]{3,5}$/', '', basename($this->_source->getRealPath())); |
| 976 | 976 | $basename = substr(trim(preg_replace('/[^a-zA-Z0-9]+/', '_', $basename), "_"), 0, 20); |
| 977 | 977 | |
| 978 | - $hash = md5(PHPTAL_VERSION . PHP_VERSION |
|
| 978 | + $hash = md5(PHPTAL_VERSION.PHP_VERSION |
|
| 979 | 979 | . $this->_source->getRealPath() |
| 980 | 980 | . $this->getEncoding() |
| 981 | 981 | . $this->getPrefiltersCacheId() |
@@ -986,10 +986,10 @@ discard block |
||
| 986 | 986 | // uses base64 rather than hex to make filename shorter. |
| 987 | 987 | // there is loss of some bits due to name constraints and case-insensivity, |
| 988 | 988 | // but that's still over 110 bits in addition to basename and timestamp. |
| 989 | - $hash = strtr(rtrim(base64_encode($hash),"="),"+/=","_A_"); |
|
| 989 | + $hash = strtr(rtrim(base64_encode($hash), "="), "+/=", "_A_"); |
|
| 990 | 990 | |
| 991 | - $this->_functionName = $this->getFunctionNamePrefix($this->_source->getLastModifiedTime()) . |
|
| 992 | - $basename . '__' . $hash; |
|
| 991 | + $this->_functionName = $this->getFunctionNamePrefix($this->_source->getLastModifiedTime()). |
|
| 992 | + $basename.'__'.$hash; |
|
| 993 | 993 | } |
| 994 | 994 | return $this->_functionName; |
| 995 | 995 | } |
@@ -1006,7 +1006,7 @@ discard block |
||
| 1006 | 1006 | { |
| 1007 | 1007 | // tpl_ prefix and last modified time must not be changed, |
| 1008 | 1008 | // because cache cleanup relies on that |
| 1009 | - return 'tpl_' . sprintf("%08x", $timestamp) .'_'; |
|
| 1009 | + return 'tpl_'.sprintf("%08x", $timestamp).'_'; |
|
| 1010 | 1010 | } |
| 1011 | 1011 | |
| 1012 | 1012 | /** |
@@ -1036,7 +1036,7 @@ discard block |
||
| 1036 | 1036 | */ |
| 1037 | 1037 | public function addError(Exception $error) |
| 1038 | 1038 | { |
| 1039 | - $this->_errors[] = $error; |
|
| 1039 | + $this->_errors[] = $error; |
|
| 1040 | 1040 | } |
| 1041 | 1041 | |
| 1042 | 1042 | /** |
@@ -1092,7 +1092,7 @@ discard block |
||
| 1092 | 1092 | $data = $this->_source->getData(); |
| 1093 | 1093 | |
| 1094 | 1094 | $prefilters = $this->getPreFilterInstances(); |
| 1095 | - foreach($prefilters as $prefilter) { |
|
| 1095 | + foreach ($prefilters as $prefilter) { |
|
| 1096 | 1096 | $data = $prefilter->filter($data); |
| 1097 | 1097 | } |
| 1098 | 1098 | |
@@ -1102,7 +1102,7 @@ discard block |
||
| 1102 | 1102 | $builder = new PHPTAL_Dom_PHPTALDocumentBuilder(); |
| 1103 | 1103 | $tree = $parser->parseString($builder, $data, $realpath)->getResult(); |
| 1104 | 1104 | |
| 1105 | - foreach($prefilters as $prefilter) { |
|
| 1105 | + foreach ($prefilters as $prefilter) { |
|
| 1106 | 1106 | if ($prefilter instanceof PHPTAL_PreFilter) { |
| 1107 | 1107 | if ($prefilter->filterDOM($tree) !== NULL) { |
| 1108 | 1108 | throw new PHPTAL_ConfigurationException("Don't return value from filterDOM()"); |
@@ -1189,7 +1189,7 @@ discard block |
||
| 1189 | 1189 | |
| 1190 | 1190 | if (substr($class, 0, 7) !== 'PHPTAL_') return; |
| 1191 | 1191 | |
| 1192 | - $path = dirname(__FILE__) . strtr("_".$class, "_", DIRECTORY_SEPARATOR) . '.php'; |
|
| 1192 | + $path = dirname(__FILE__).strtr("_".$class, "_", DIRECTORY_SEPARATOR).'.php'; |
|
| 1193 | 1193 | |
| 1194 | 1194 | require $path; |
| 1195 | 1195 | } |
@@ -1214,9 +1214,9 @@ discard block |
||
| 1214 | 1214 | // Prepending PHPTAL's autoloader helps if there are other autoloaders |
| 1215 | 1215 | // that throw/die when file is not found. Only >5.3 though. |
| 1216 | 1216 | if (version_compare(PHP_VERSION, '5.3', '>=')) { |
| 1217 | - spl_autoload_register(array(__CLASS__,'autoload'), false, true); |
|
| 1217 | + spl_autoload_register(array(__CLASS__, 'autoload'), false, true); |
|
| 1218 | 1218 | } else { |
| 1219 | - spl_autoload_register(array(__CLASS__,'autoload')); |
|
| 1219 | + spl_autoload_register(array(__CLASS__, 'autoload')); |
|
| 1220 | 1220 | } |
| 1221 | 1221 | |
| 1222 | 1222 | if ($uses_autoload) { |
@@ -379,7 +379,9 @@ discard block |
||
| 379 | 379 | $enc = strtoupper($enc); |
| 380 | 380 | if ($enc != $this->_encoding) { |
| 381 | 381 | $this->_encoding = $enc; |
| 382 | - if ($this->_translator) $this->_translator->setEncoding($enc); |
|
| 382 | + if ($this->_translator) { |
|
| 383 | + $this->_translator->setEncoding($enc); |
|
| 384 | + } |
|
| 383 | 385 | |
| 384 | 386 | $this->resetPrepared(); |
| 385 | 387 | } |
@@ -666,8 +668,7 @@ discard block |
||
| 666 | 668 | ob_start(); |
| 667 | 669 | $templateFunction($this, $this->_context); |
| 668 | 670 | $res = ob_get_clean(); |
| 669 | - } |
|
| 670 | - catch (Exception $e) |
|
| 671 | + } catch (Exception $e) |
|
| 671 | 672 | { |
| 672 | 673 | ob_end_clean(); |
| 673 | 674 | throw $e; |
@@ -686,8 +687,7 @@ discard block |
||
| 686 | 687 | if ($this->_postfilter) { |
| 687 | 688 | return $this->_postfilter->filter($res); |
| 688 | 689 | } |
| 689 | - } |
|
| 690 | - catch (Exception $e) |
|
| 690 | + } catch (Exception $e) |
|
| 691 | 691 | { |
| 692 | 692 | PHPTAL_ExceptionHandler::handleException($e, $this->getEncoding()); |
| 693 | 693 | } |
@@ -717,8 +717,7 @@ discard block |
||
| 717 | 717 | |
| 718 | 718 | $templateFunction = $this->getFunctionName(); |
| 719 | 719 | $templateFunction($this, $this->_context); |
| 720 | - } |
|
| 721 | - catch (Exception $e) |
|
| 720 | + } catch (Exception $e) |
|
| 722 | 721 | { |
| 723 | 722 | PHPTAL_ExceptionHandler::handleException($e, $this->getEncoding()); |
| 724 | 723 | } |
@@ -835,8 +834,7 @@ discard block |
||
| 835 | 834 | ob_start(); |
| 836 | 835 | try { |
| 837 | 836 | eval("?>\n".$result); |
| 838 | - } |
|
| 839 | - catch(Exception $e) { |
|
| 837 | + } catch(Exception $e) { |
|
| 840 | 838 | ob_end_clean(); |
| 841 | 839 | throw $e; |
| 842 | 840 | } |
@@ -845,7 +843,11 @@ discard block |
||
| 845 | 843 | $msg = str_replace('eval()\'d code', $this->getCodePath(), ob_get_clean()); |
| 846 | 844 | |
| 847 | 845 | // greedy .* ensures last match |
| 848 | - if (preg_match('/.*on line (\d+)$/m', $msg, $m)) $line=$m[1]; else $line=0; |
|
| 846 | + if (preg_match('/.*on line (\d+)$/m', $msg, $m)) { |
|
| 847 | + $line=$m[1]; |
|
| 848 | + } else { |
|
| 849 | + $line=0; |
|
| 850 | + } |
|
| 849 | 851 | throw new PHPTAL_TemplateException(trim($msg), $this->getCodePath(), $line); |
| 850 | 852 | } |
| 851 | 853 | ob_end_clean(); |
@@ -939,7 +941,10 @@ discard block |
||
| 939 | 941 | $cacheFiles = glob($filename . '?*'); |
| 940 | 942 | if ($cacheFiles) { |
| 941 | 943 | foreach ($cacheFiles as $file) { |
| 942 | - if (substr($file, 0, strlen($filename)) !== $filename) continue; // safety net |
|
| 944 | + if (substr($file, 0, strlen($filename)) !== $filename) { |
|
| 945 | + continue; |
|
| 946 | + } |
|
| 947 | + // safety net |
|
| 943 | 948 | @unlink($file); |
| 944 | 949 | } |
| 945 | 950 | } |
@@ -956,7 +961,9 @@ discard block |
||
| 956 | 961 | */ |
| 957 | 962 | public function getCodePath() |
| 958 | 963 | { |
| 959 | - if (!$this->_codeFile) $this->setCodeFile(); |
|
| 964 | + if (!$this->_codeFile) { |
|
| 965 | + $this->setCodeFile(); |
|
| 966 | + } |
|
| 960 | 967 | return $this->_codeFile; |
| 961 | 968 | } |
| 962 | 969 | |
@@ -1187,7 +1194,9 @@ discard block |
||
| 1187 | 1194 | $class = strtr($class, '\\', '_'); |
| 1188 | 1195 | } |
| 1189 | 1196 | |
| 1190 | - if (substr($class, 0, 7) !== 'PHPTAL_') return; |
|
| 1197 | + if (substr($class, 0, 7) !== 'PHPTAL_') { |
|
| 1198 | + return; |
|
| 1199 | + } |
|
| 1191 | 1200 | |
| 1192 | 1201 | $path = dirname(__FILE__) . strtr("_".$class, "_", DIRECTORY_SEPARATOR) . '.php'; |
| 1193 | 1202 | |
@@ -1,17 +1,17 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * PHPTAL templating engine |
|
| 4 | - * |
|
| 5 | - * PHP Version 5 |
|
| 6 | - * |
|
| 7 | - * @category HTML |
|
| 8 | - * @package PHPTAL |
|
| 9 | - * @author Laurent Bedubourg <[email protected]> |
|
| 10 | - * @author Kornel Lesiński <[email protected]> |
|
| 11 | - * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License |
|
| 12 | - * @version SVN: $Id$ |
|
| 13 | - * @link http://phptal.org/ |
|
| 14 | - */ |
|
| 3 | + * PHPTAL templating engine |
|
| 4 | + * |
|
| 5 | + * PHP Version 5 |
|
| 6 | + * |
|
| 7 | + * @category HTML |
|
| 8 | + * @package PHPTAL |
|
| 9 | + * @author Laurent Bedubourg <[email protected]> |
|
| 10 | + * @author Kornel Lesiński <[email protected]> |
|
| 11 | + * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License |
|
| 12 | + * @version SVN: $Id$ |
|
| 13 | + * @link http://phptal.org/ |
|
| 14 | + */ |
|
| 15 | 15 | |
| 16 | 16 | define('PHPTAL_VERSION', '1_3_0'); |
| 17 | 17 | |
@@ -966,10 +966,10 @@ discard block |
||
| 966 | 966 | */ |
| 967 | 967 | public function getFunctionName() |
| 968 | 968 | { |
| 969 | - // function name is used as base for caching, so it must be unique for |
|
| 970 | - // every combination of settings that changes code in compiled template |
|
| 969 | + // function name is used as base for caching, so it must be unique for |
|
| 970 | + // every combination of settings that changes code in compiled template |
|
| 971 | 971 | |
| 972 | - if (!$this->_functionName) { |
|
| 972 | + if (!$this->_functionName) { |
|
| 973 | 973 | |
| 974 | 974 | // just to make tempalte name recognizable |
| 975 | 975 | $basename = preg_replace('/\.[a-z]{3,5}$/', '', basename($this->_source->getRealPath())); |
@@ -989,7 +989,7 @@ discard block |
||
| 989 | 989 | $hash = strtr(rtrim(base64_encode($hash),"="),"+/=","_A_"); |
| 990 | 990 | |
| 991 | 991 | $this->_functionName = $this->getFunctionNamePrefix($this->_source->getLastModifiedTime()) . |
| 992 | - $basename . '__' . $hash; |
|
| 992 | + $basename . '__' . $hash; |
|
| 993 | 993 | } |
| 994 | 994 | return $this->_functionName; |
| 995 | 995 | } |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | /** |
| 65 | 65 | * save current execution context |
| 66 | 66 | * |
| 67 | - * @return Context (new) |
|
| 67 | + * @return PHPTAL_Context (new) |
|
| 68 | 68 | */ |
| 69 | 69 | public function pushContext() |
| 70 | 70 | { |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | /** |
| 77 | 77 | * get previously saved execution context |
| 78 | 78 | * |
| 79 | - * @return Context (old) |
|
| 79 | + * @return PHPTAL_Context (old) |
|
| 80 | 80 | */ |
| 81 | 81 | public function popContext() |
| 82 | 82 | { |
@@ -263,6 +263,7 @@ discard block |
||
| 263 | 263 | /** |
| 264 | 264 | * Context setter. |
| 265 | 265 | * |
| 266 | + * @param string $varname |
|
| 266 | 267 | * @return void |
| 267 | 268 | */ |
| 268 | 269 | public function __set($varname, $value) |
@@ -312,6 +313,7 @@ discard block |
||
| 312 | 313 | * helper method for PHPTAL_Context::path() |
| 313 | 314 | * |
| 314 | 315 | * @access private |
| 316 | + * @param string $path |
|
| 315 | 317 | */ |
| 316 | 318 | private static function pathError($base, $path, $current, $basename) |
| 317 | 319 | { |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | * |
| 102 | 102 | * @return void |
| 103 | 103 | */ |
| 104 | - public function setDocType($doctype,$called_from_macro) |
|
| 104 | + public function setDocType($doctype, $called_from_macro) |
|
| 105 | 105 | { |
| 106 | 106 | // FIXME: this is temporary workaround for problem of DOCTYPE disappearing in cloned PHPTAL object (because clone keeps _parentContext) |
| 107 | 107 | if (!$this->_docType) { |
@@ -246,7 +246,7 @@ discard block |
||
| 246 | 246 | */ |
| 247 | 247 | public function pushSlots() |
| 248 | 248 | { |
| 249 | - $this->_slotsStack[] = $this->_slots; |
|
| 249 | + $this->_slotsStack[] = $this->_slots; |
|
| 250 | 250 | $this->_slots = array(); |
| 251 | 251 | } |
| 252 | 252 | |
@@ -320,7 +320,7 @@ discard block |
||
| 320 | 320 | } else $pathinfo = ''; |
| 321 | 321 | |
| 322 | 322 | if (!empty($basename)) { |
| 323 | - $basename = "'" . $basename . "' "; |
|
| 323 | + $basename = "'".$basename."' "; |
|
| 324 | 324 | } |
| 325 | 325 | |
| 326 | 326 | if (is_array($base)) { |
@@ -350,7 +350,7 @@ discard block |
||
| 350 | 350 | * @access private |
| 351 | 351 | * @return mixed |
| 352 | 352 | */ |
| 353 | - public static function path($base, $path, $nothrow=false) |
|
| 353 | + public static function path($base, $path, $nothrow = false) |
|
| 354 | 354 | { |
| 355 | 355 | if ($base === null) { |
| 356 | 356 | if ($nothrow) return null; |
@@ -414,7 +414,7 @@ discard block |
||
| 414 | 414 | $base = $base->__call($current, array()); |
| 415 | 415 | continue; |
| 416 | 416 | } |
| 417 | - catch(BadMethodCallException $e) {} |
|
| 417 | + catch (BadMethodCallException $e) {} |
|
| 418 | 418 | } |
| 419 | 419 | |
| 420 | 420 | if (is_callable($base)) { |
@@ -433,7 +433,7 @@ discard block |
||
| 433 | 433 | // array handling |
| 434 | 434 | if (is_array($base)) { |
| 435 | 435 | // key or index |
| 436 | - if (array_key_exists((string)$current, $base)) { |
|
| 436 | + if (array_key_exists((string) $current, $base)) { |
|
| 437 | 437 | $base = $base[$current]; |
| 438 | 438 | continue; |
| 439 | 439 | } |
@@ -481,7 +481,7 @@ discard block |
||
| 481 | 481 | * @see PHPTAL_Context::path() |
| 482 | 482 | * @deprecated |
| 483 | 483 | */ |
| 484 | -function phptal_path($base, $path, $nothrow=false) |
|
| 484 | +function phptal_path($base, $path, $nothrow = false) |
|
| 485 | 485 | { |
| 486 | 486 | return PHPTAL_Context::path($base, $path, $nothrow); |
| 487 | 487 | } |
@@ -496,7 +496,7 @@ discard block |
||
| 496 | 496 | function phptal_isempty($var) |
| 497 | 497 | { |
| 498 | 498 | return $var === null || $var === false || $var === '' |
| 499 | - || ((is_array($var) || $var instanceof Countable) && count($var)===0); |
|
| 499 | + || ((is_array($var) || $var instanceof Countable) && count($var) === 0); |
|
| 500 | 500 | } |
| 501 | 501 | |
| 502 | 502 | /** |
@@ -535,7 +535,7 @@ discard block |
||
| 535 | 535 | if (is_string($var)) { |
| 536 | 536 | return $var; |
| 537 | 537 | } elseif (is_bool($var)) { |
| 538 | - return (int)$var; |
|
| 538 | + return (int) $var; |
|
| 539 | 539 | } elseif (is_array($var)) { |
| 540 | 540 | return implode(', ', array_map('phptal_tostring', $var)); |
| 541 | 541 | } elseif ($var instanceof SimpleXMLElement) { |
@@ -549,7 +549,7 @@ discard block |
||
| 549 | 549 | return $xml; |
| 550 | 550 | } |
| 551 | 551 | } |
| 552 | - return (string)phptal_unravel_closure($var); |
|
| 552 | + return (string) phptal_unravel_closure($var); |
|
| 553 | 553 | } |
| 554 | 554 | |
| 555 | 555 | /** |
@@ -116,8 +116,7 @@ discard block |
||
| 116 | 116 | } else { |
| 117 | 117 | throw new PHPTAL_ConfigurationException("Executed macro in file with DOCTYPE when using echoExecute(). This is not supported yet. Remove DOCTYPE or use PHPTAL->execute()."); |
| 118 | 118 | } |
| 119 | - } |
|
| 120 | - else if (!$this->_docType) { |
|
| 119 | + } else if (!$this->_docType) { |
|
| 121 | 120 | $this->_docType = $doctype; |
| 122 | 121 | } |
| 123 | 122 | } |
@@ -317,7 +316,9 @@ discard block |
||
| 317 | 316 | { |
| 318 | 317 | if ($current !== $path) { |
| 319 | 318 | $pathinfo = " (in path '.../$path')"; |
| 320 | - } else $pathinfo = ''; |
|
| 319 | + } else { |
|
| 320 | + $pathinfo = ''; |
|
| 321 | + } |
|
| 321 | 322 | |
| 322 | 323 | if (!empty($basename)) { |
| 323 | 324 | $basename = "'" . $basename . "' "; |
@@ -353,7 +354,9 @@ discard block |
||
| 353 | 354 | public static function path($base, $path, $nothrow=false) |
| 354 | 355 | { |
| 355 | 356 | if ($base === null) { |
| 356 | - if ($nothrow) return null; |
|
| 357 | + if ($nothrow) { |
|
| 358 | + return null; |
|
| 359 | + } |
|
| 357 | 360 | PHPTAL_Context::pathError($base, $path, $path, $path); |
| 358 | 361 | } |
| 359 | 362 | |
@@ -413,8 +416,7 @@ discard block |
||
| 413 | 416 | { |
| 414 | 417 | $base = $base->__call($current, array()); |
| 415 | 418 | continue; |
| 416 | - } |
|
| 417 | - catch(BadMethodCallException $e) {} |
|
| 419 | + } catch(BadMethodCallException $e) {} |
|
| 418 | 420 | } |
| 419 | 421 | |
| 420 | 422 | if (is_callable($base)) { |
@@ -444,8 +446,9 @@ discard block |
||
| 444 | 446 | continue; |
| 445 | 447 | } |
| 446 | 448 | |
| 447 | - if ($nothrow) |
|
| 448 | - return null; |
|
| 449 | + if ($nothrow) { |
|
| 450 | + return null; |
|
| 451 | + } |
|
| 449 | 452 | |
| 450 | 453 | PHPTAL_Context::pathError($base, $path, $current, $prev); |
| 451 | 454 | } |
@@ -467,8 +470,9 @@ discard block |
||
| 467 | 470 | |
| 468 | 471 | // if this point is reached, then the part cannot be resolved |
| 469 | 472 | |
| 470 | - if ($nothrow) |
|
| 471 | - return null; |
|
| 473 | + if ($nothrow) { |
|
| 474 | + return null; |
|
| 475 | + } |
|
| 472 | 476 | |
| 473 | 477 | PHPTAL_Context::pathError($base, $path, $current, $prev); |
| 474 | 478 | } |
@@ -1,17 +1,17 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * PHPTAL templating engine |
|
| 4 | - * |
|
| 5 | - * PHP Version 5 |
|
| 6 | - * |
|
| 7 | - * @category HTML |
|
| 8 | - * @package PHPTAL |
|
| 9 | - * @author Laurent Bedubourg <[email protected]> |
|
| 10 | - * @author Kornel Lesiński <[email protected]> |
|
| 11 | - * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License |
|
| 12 | - * @version SVN: $Id$ |
|
| 13 | - * @link http://phptal.org/ |
|
| 14 | - */ |
|
| 3 | + * PHPTAL templating engine |
|
| 4 | + * |
|
| 5 | + * PHP Version 5 |
|
| 6 | + * |
|
| 7 | + * @category HTML |
|
| 8 | + * @package PHPTAL |
|
| 9 | + * @author Laurent Bedubourg <[email protected]> |
|
| 10 | + * @author Kornel Lesiński <[email protected]> |
|
| 11 | + * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License |
|
| 12 | + * @version SVN: $Id$ |
|
| 13 | + * @link http://phptal.org/ |
|
| 14 | + */ |
|
| 15 | 15 | |
| 16 | 16 | /** |
| 17 | 17 | * You're probably not using PHPTAL class properly |
@@ -82,7 +82,7 @@ |
||
| 82 | 82 | /** |
| 83 | 83 | * Returns true if this attribute is ns declaration (xmlns="...") |
| 84 | 84 | * |
| 85 | - * @return bool |
|
| 85 | + * @return integer |
|
| 86 | 86 | */ |
| 87 | 87 | function isNamespaceDeclaration() |
| 88 | 88 | { |
@@ -1,17 +1,17 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * PHPTAL templating engine |
|
| 4 | - * |
|
| 5 | - * PHP Version 5 |
|
| 6 | - * |
|
| 7 | - * @category HTML |
|
| 8 | - * @package PHPTAL |
|
| 9 | - * @author Laurent Bedubourg <[email protected]> |
|
| 10 | - * @author Kornel Lesiński <[email protected]> |
|
| 11 | - * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License |
|
| 12 | - * @version SVN: $Id$ |
|
| 13 | - * @link http://phptal.org/ |
|
| 14 | - */ |
|
| 3 | + * PHPTAL templating engine |
|
| 4 | + * |
|
| 5 | + * PHP Version 5 |
|
| 6 | + * |
|
| 7 | + * @category HTML |
|
| 8 | + * @package PHPTAL |
|
| 9 | + * @author Laurent Bedubourg <[email protected]> |
|
| 10 | + * @author Kornel Lesiński <[email protected]> |
|
| 11 | + * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License |
|
| 12 | + * @version SVN: $Id$ |
|
| 13 | + * @link http://phptal.org/ |
|
| 14 | + */ |
|
| 15 | 15 | |
| 16 | 16 | /** |
| 17 | 17 | * You're probably not using PHPTAL class properly |
@@ -52,7 +52,6 @@ |
||
| 52 | 52 | * true if it's empty in XHTML (e.g. <img/>) |
| 53 | 53 | * it will assume elements with no namespace may be XHTML too. |
| 54 | 54 | * |
| 55 | - * @param string $tagName local name of the tag |
|
| 56 | 55 | * |
| 57 | 56 | * @return bool |
| 58 | 57 | */ |
@@ -119,7 +119,9 @@ |
||
| 119 | 119 | */ |
| 120 | 120 | public function isValidAttributeNS($namespace_uri, $local_name) |
| 121 | 121 | { |
| 122 | - if (!$this->isHandledNamespace($namespace_uri)) return false; |
|
| 122 | + if (!$this->isHandledNamespace($namespace_uri)) { |
|
| 123 | + return false; |
|
| 124 | + } |
|
| 123 | 125 | |
| 124 | 126 | $attrs = $this->namespaces_by_uri[$namespace_uri]->getAttributes(); |
| 125 | 127 | return isset($attrs[$local_name]); |
@@ -1,17 +1,17 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * PHPTAL templating engine |
|
| 4 | - * |
|
| 5 | - * PHP Version 5 |
|
| 6 | - * |
|
| 7 | - * @category HTML |
|
| 8 | - * @package PHPTAL |
|
| 9 | - * @author Laurent Bedubourg <[email protected]> |
|
| 10 | - * @author Kornel Lesiński <[email protected]> |
|
| 11 | - * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License |
|
| 12 | - * @version SVN: $Id$ |
|
| 13 | - * @link http://phptal.org/ |
|
| 14 | - */ |
|
| 3 | + * PHPTAL templating engine |
|
| 4 | + * |
|
| 5 | + * PHP Version 5 |
|
| 6 | + * |
|
| 7 | + * @category HTML |
|
| 8 | + * @package PHPTAL |
|
| 9 | + * @author Laurent Bedubourg <[email protected]> |
|
| 10 | + * @author Kornel Lesiński <[email protected]> |
|
| 11 | + * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License |
|
| 12 | + * @version SVN: $Id$ |
|
| 13 | + * @link http://phptal.org/ |
|
| 14 | + */ |
|
| 15 | 15 | |
| 16 | 16 | /** |
| 17 | 17 | * You're probably not using PHPTAL class properly |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | * @param string $qname qualified name of the element, e.g. "tal:block" |
| 41 | 41 | * @param string $namespace_uri namespace of this element |
| 42 | 42 | * @param array $attribute_nodes array of PHPTAL_Dom_Attr elements |
| 43 | - * @param object $xmlns object that represents namespaces/prefixes known in element's context |
|
| 43 | + * @param PHPTAL_Dom_XmlnsState $xmlns object that represents namespaces/prefixes known in element's context |
|
| 44 | 44 | */ |
| 45 | 45 | public function __construct($qname, $namespace_uri, array $attribute_nodes, PHPTAL_Dom_XmlnsState $xmlns) |
| 46 | 46 | { |
@@ -229,6 +229,10 @@ discard block |
||
| 229 | 229 | return null; |
| 230 | 230 | } |
| 231 | 231 | |
| 232 | + /** |
|
| 233 | + * @param string $ns_uri |
|
| 234 | + * @param string $localname |
|
| 235 | + */ |
|
| 232 | 236 | public function removeAttributeNS($ns_uri, $localname) |
| 233 | 237 | { |
| 234 | 238 | foreach ($this->attribute_nodes as $k => $attr) { |
@@ -239,6 +243,9 @@ discard block |
||
| 239 | 243 | } |
| 240 | 244 | } |
| 241 | 245 | |
| 246 | + /** |
|
| 247 | + * @return PHPTAL_Php_CodeWriter |
|
| 248 | + */ |
|
| 242 | 249 | public function getAttributeNode($qname) |
| 243 | 250 | { |
| 244 | 251 | foreach($this->attribute_nodes as $attr) if ($attr->getQualifiedName() === $qname) return $attr; |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | |
| 184 | 184 | $this->generateSurroundFoot($codewriter); |
| 185 | 185 | } |
| 186 | - catch(PHPTAL_TemplateException $e) { |
|
| 186 | + catch (PHPTAL_TemplateException $e) { |
|
| 187 | 187 | $e->hintSrcPosition($this->getSourceFile(), $this->getSourceLine()); |
| 188 | 188 | throw $e; |
| 189 | 189 | } |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | /** Returns true if the element contains specified PHPTAL attribute. */ |
| 213 | 213 | public function hasAttribute($qname) |
| 214 | 214 | { |
| 215 | - foreach($this->attribute_nodes as $attr) if ($attr->getQualifiedName() == $qname) return true; |
|
| 215 | + foreach ($this->attribute_nodes as $attr) if ($attr->getQualifiedName() == $qname) return true; |
|
| 216 | 216 | return false; |
| 217 | 217 | } |
| 218 | 218 | |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | |
| 242 | 242 | public function getAttributeNode($qname) |
| 243 | 243 | { |
| 244 | - foreach($this->attribute_nodes as $attr) if ($attr->getQualifiedName() === $qname) return $attr; |
|
| 244 | + foreach ($this->attribute_nodes as $attr) if ($attr->getQualifiedName() === $qname) return $attr; |
|
| 245 | 245 | return null; |
| 246 | 246 | } |
| 247 | 247 | |
@@ -348,15 +348,15 @@ discard block |
||
| 348 | 348 | } |
| 349 | 349 | } |
| 350 | 350 | |
| 351 | - public function generateContent(PHPTAL_Php_CodeWriter $codewriter = null, $realContent=false) |
|
| 351 | + public function generateContent(PHPTAL_Php_CodeWriter $codewriter = null, $realContent = false) |
|
| 352 | 352 | { |
| 353 | 353 | if (!$this->isEmptyNode($codewriter->getOutputMode())) { |
| 354 | 354 | if ($realContent || !count($this->contentAttributes)) { |
| 355 | - foreach($this->childNodes as $child) { |
|
| 355 | + foreach ($this->childNodes as $child) { |
|
| 356 | 356 | $child->generateCode($codewriter); |
| 357 | 357 | } |
| 358 | 358 | } |
| 359 | - else foreach($this->contentAttributes as $att) { |
|
| 359 | + else foreach ($this->contentAttributes as $att) { |
|
| 360 | 360 | $att->before($codewriter); |
| 361 | 361 | $att->after($codewriter); |
| 362 | 362 | } |
@@ -434,7 +434,7 @@ discard block |
||
| 434 | 434 | private function isEmptyNode($mode) |
| 435 | 435 | { |
| 436 | 436 | return (($mode === PHPTAL::XHTML || $mode === PHPTAL::HTML5) && PHPTAL_Dom_Defs::getInstance()->isEmptyTagNS($this->getNamespaceURI(), $this->getLocalName())) || |
| 437 | - ( $mode === PHPTAL::XML && !$this->hasContent()); |
|
| 437 | + ($mode === PHPTAL::XML && !$this->hasContent()); |
|
| 438 | 438 | } |
| 439 | 439 | |
| 440 | 440 | private function hasContent() |
@@ -468,7 +468,7 @@ discard block |
||
| 468 | 468 | throw new PHPTAL_TemplateException(sprintf("Attribute conflict in < %s > '%s' cannot appear with '%s'", |
| 469 | 469 | $this->qualifiedName, |
| 470 | 470 | $key, |
| 471 | - $temp[$nsattr->getPriority()][0]->getNamespace()->getPrefix() . ':' . $temp[$nsattr->getPriority()][0]->getLocalName() |
|
| 471 | + $temp[$nsattr->getPriority()][0]->getNamespace()->getPrefix().':'.$temp[$nsattr->getPriority()][0]->getLocalName() |
|
| 472 | 472 | ), $this->getSourceFile(), $this->getSourceLine()); |
| 473 | 473 | } |
| 474 | 474 | $temp[$nsattr->getPriority()] = array($nsattr, $domattr); |
@@ -94,7 +94,9 @@ discard block |
||
| 94 | 94 | $value = ''; |
| 95 | 95 | foreach ($this->childNodes as $node) { |
| 96 | 96 | // leave it alone if there is CDATA, comment, or anything else. |
| 97 | - if (!$node instanceof PHPTAL_Dom_Text) return; |
|
| 97 | + if (!$node instanceof PHPTAL_Dom_Text) { |
|
| 98 | + return; |
|
| 99 | + } |
|
| 98 | 100 | |
| 99 | 101 | $value .= $node->getValue(); |
| 100 | 102 | $valueEscaped .= $node->getValueEscaped(); |
@@ -118,7 +120,9 @@ discard block |
||
| 118 | 120 | |
| 119 | 121 | public function appendChild(PHPTAL_Dom_Node $child) |
| 120 | 122 | { |
| 121 | - if ($child->parentNode) $child->parentNode->removeChild($child); |
|
| 123 | + if ($child->parentNode) { |
|
| 124 | + $child->parentNode->removeChild($child); |
|
| 125 | + } |
|
| 122 | 126 | $child->parentNode = $this; |
| 123 | 127 | $this->childNodes[] = $child; |
| 124 | 128 | } |
@@ -141,7 +145,9 @@ discard block |
||
| 141 | 145 | if ($node === $oldElement) { |
| 142 | 146 | $oldElement->parentNode = NULL; |
| 143 | 147 | |
| 144 | - if ($newElement->parentNode) $newElement->parentNode->removeChild($child); |
|
| 148 | + if ($newElement->parentNode) { |
|
| 149 | + $newElement->parentNode->removeChild($child); |
|
| 150 | + } |
|
| 145 | 151 | $newElement->parentNode = $this; |
| 146 | 152 | |
| 147 | 153 | $this->childNodes[$k] = $newElement; |
@@ -182,8 +188,7 @@ discard block |
||
| 182 | 188 | } |
| 183 | 189 | |
| 184 | 190 | $this->generateSurroundFoot($codewriter); |
| 185 | - } |
|
| 186 | - catch(PHPTAL_TemplateException $e) { |
|
| 191 | + } catch(PHPTAL_TemplateException $e) { |
|
| 187 | 192 | $e->hintSrcPosition($this->getSourceFile(), $this->getSourceLine()); |
| 188 | 193 | throw $e; |
| 189 | 194 | } |
@@ -212,7 +217,9 @@ discard block |
||
| 212 | 217 | /** Returns true if the element contains specified PHPTAL attribute. */ |
| 213 | 218 | public function hasAttribute($qname) |
| 214 | 219 | { |
| 215 | - foreach($this->attribute_nodes as $attr) if ($attr->getQualifiedName() == $qname) return true; |
|
| 220 | + foreach($this->attribute_nodes as $attr) { |
|
| 221 | + if ($attr->getQualifiedName() == $qname) return true; |
|
| 222 | + } |
|
| 216 | 223 | return false; |
| 217 | 224 | } |
| 218 | 225 | |
@@ -224,7 +231,9 @@ discard block |
||
| 224 | 231 | public function getAttributeNodeNS($ns_uri, $localname) |
| 225 | 232 | { |
| 226 | 233 | foreach ($this->attribute_nodes as $attr) { |
| 227 | - if ($attr->getNamespaceURI() === $ns_uri && $attr->getLocalName() === $localname) return $attr; |
|
| 234 | + if ($attr->getNamespaceURI() === $ns_uri && $attr->getLocalName() === $localname) { |
|
| 235 | + return $attr; |
|
| 236 | + } |
|
| 228 | 237 | } |
| 229 | 238 | return null; |
| 230 | 239 | } |
@@ -241,7 +250,9 @@ discard block |
||
| 241 | 250 | |
| 242 | 251 | public function getAttributeNode($qname) |
| 243 | 252 | { |
| 244 | - foreach($this->attribute_nodes as $attr) if ($attr->getQualifiedName() === $qname) return $attr; |
|
| 253 | + foreach($this->attribute_nodes as $attr) { |
|
| 254 | + if ($attr->getQualifiedName() === $qname) return $attr; |
|
| 255 | + } |
|
| 245 | 256 | return null; |
| 246 | 257 | } |
| 247 | 258 | |
@@ -252,7 +263,9 @@ discard block |
||
| 252 | 263 | */ |
| 253 | 264 | public function getOrCreateAttributeNode($qname) |
| 254 | 265 | { |
| 255 | - if ($attr = $this->getAttributeNode($qname)) return $attr; |
|
| 266 | + if ($attr = $this->getAttributeNode($qname)) { |
|
| 267 | + return $attr; |
|
| 268 | + } |
|
| 256 | 269 | |
| 257 | 270 | $attr = new PHPTAL_Dom_Attr($qname, "", null, 'UTF-8'); // FIXME: should find namespace and encoding |
| 258 | 271 | $this->attribute_nodes[] = $attr; |
@@ -294,19 +307,27 @@ discard block |
||
| 294 | 307 | */ |
| 295 | 308 | public function hasRealContent() |
| 296 | 309 | { |
| 297 | - if (count($this->contentAttributes) > 0) return true; |
|
| 310 | + if (count($this->contentAttributes) > 0) { |
|
| 311 | + return true; |
|
| 312 | + } |
|
| 298 | 313 | |
| 299 | 314 | foreach ($this->childNodes as $node) { |
| 300 | - if (!$node instanceof PHPTAL_Dom_Text || $node->getValueEscaped() !== '') return true; |
|
| 315 | + if (!$node instanceof PHPTAL_Dom_Text || $node->getValueEscaped() !== '') { |
|
| 316 | + return true; |
|
| 317 | + } |
|
| 301 | 318 | } |
| 302 | 319 | return false; |
| 303 | 320 | } |
| 304 | 321 | |
| 305 | 322 | public function hasRealAttributes() |
| 306 | 323 | { |
| 307 | - if ($this->hasAttributeNS('http://xml.zope.org/namespaces/tal', 'attributes')) return true; |
|
| 324 | + if ($this->hasAttributeNS('http://xml.zope.org/namespaces/tal', 'attributes')) { |
|
| 325 | + return true; |
|
| 326 | + } |
|
| 308 | 327 | foreach ($this->attribute_nodes as $attr) { |
| 309 | - if ($attr->getReplacedState() !== PHPTAL_Dom_Attr::HIDDEN) return true; |
|
| 328 | + if ($attr->getReplacedState() !== PHPTAL_Dom_Attr::HIDDEN) { |
|
| 329 | + return true; |
|
| 330 | + } |
|
| 310 | 331 | } |
| 311 | 332 | return false; |
| 312 | 333 | } |
@@ -322,7 +343,9 @@ discard block |
||
| 322 | 343 | |
| 323 | 344 | public function generateHead(PHPTAL_Php_CodeWriter $codewriter) |
| 324 | 345 | { |
| 325 | - if ($this->headFootDisabled) return; |
|
| 346 | + if ($this->headFootDisabled) { |
|
| 347 | + return; |
|
| 348 | + } |
|
| 326 | 349 | if ($this->headPrintCondition) { |
| 327 | 350 | $codewriter->doIf($this->headPrintCondition); |
| 328 | 351 | } |
@@ -355,9 +378,10 @@ discard block |
||
| 355 | 378 | foreach($this->childNodes as $child) { |
| 356 | 379 | $child->generateCode($codewriter); |
| 357 | 380 | } |
| 358 | - } |
|
| 359 | - else foreach($this->contentAttributes as $att) { |
|
| 381 | + } else { |
|
| 382 | + foreach($this->contentAttributes as $att) { |
|
| 360 | 383 | $att->before($codewriter); |
| 384 | + } |
|
| 361 | 385 | $att->after($codewriter); |
| 362 | 386 | } |
| 363 | 387 | } |
@@ -365,10 +389,12 @@ discard block |
||
| 365 | 389 | |
| 366 | 390 | public function generateFoot(PHPTAL_Php_CodeWriter $codewriter) |
| 367 | 391 | { |
| 368 | - if ($this->headFootDisabled) |
|
| 369 | - return; |
|
| 370 | - if ($this->isEmptyNode($codewriter->getOutputMode())) |
|
| 371 | - return; |
|
| 392 | + if ($this->headFootDisabled) { |
|
| 393 | + return; |
|
| 394 | + } |
|
| 395 | + if ($this->isEmptyNode($codewriter->getOutputMode())) { |
|
| 396 | + return; |
|
| 397 | + } |
|
| 372 | 398 | |
| 373 | 399 | if ($this->footPrintCondition) { |
| 374 | 400 | $codewriter->doIf($this->footPrintCondition); |
@@ -481,15 +507,16 @@ discard block |
||
| 481 | 507 | $handler = $nsattr->createAttributeHandler($this, $domattr->getValue()); |
| 482 | 508 | $this->talHandlers[$prio] = $handler; |
| 483 | 509 | |
| 484 | - if ($nsattr instanceof PHPTAL_NamespaceAttributeSurround) |
|
| 485 | - $this->surroundAttributes[] = $handler; |
|
| 486 | - else if ($nsattr instanceof PHPTAL_NamespaceAttributeReplace) |
|
| 487 | - $this->replaceAttributes[] = $handler; |
|
| 488 | - else if ($nsattr instanceof PHPTAL_NamespaceAttributeContent) |
|
| 489 | - $this->contentAttributes[] = $handler; |
|
| 490 | - else |
|
| 491 | - throw new PHPTAL_ParserException("Unknown namespace attribute class ".get_class($nsattr), |
|
| 510 | + if ($nsattr instanceof PHPTAL_NamespaceAttributeSurround) { |
|
| 511 | + $this->surroundAttributes[] = $handler; |
|
| 512 | + } else if ($nsattr instanceof PHPTAL_NamespaceAttributeReplace) { |
|
| 513 | + $this->replaceAttributes[] = $handler; |
|
| 514 | + } else if ($nsattr instanceof PHPTAL_NamespaceAttributeContent) { |
|
| 515 | + $this->contentAttributes[] = $handler; |
|
| 516 | + } else { |
|
| 517 | + throw new PHPTAL_ParserException("Unknown namespace attribute class ".get_class($nsattr), |
|
| 492 | 518 | $this->getSourceFile(), $this->getSourceLine()); |
| 519 | + } |
|
| 493 | 520 | |
| 494 | 521 | } |
| 495 | 522 | } |
@@ -1,17 +1,17 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * PHPTAL templating engine |
|
| 4 | - * |
|
| 5 | - * PHP Version 5 |
|
| 6 | - * |
|
| 7 | - * @category HTML |
|
| 8 | - * @package PHPTAL |
|
| 9 | - * @author Laurent Bedubourg <[email protected]> |
|
| 10 | - * @author Kornel Lesiński <[email protected]> |
|
| 11 | - * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License |
|
| 12 | - * @version SVN: $Id$ |
|
| 13 | - * @link http://phptal.org/ |
|
| 14 | - */ |
|
| 3 | + * PHPTAL templating engine |
|
| 4 | + * |
|
| 5 | + * PHP Version 5 |
|
| 6 | + * |
|
| 7 | + * @category HTML |
|
| 8 | + * @package PHPTAL |
|
| 9 | + * @author Laurent Bedubourg <[email protected]> |
|
| 10 | + * @author Kornel Lesiński <[email protected]> |
|
| 11 | + * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License |
|
| 12 | + * @version SVN: $Id$ |
|
| 13 | + * @link http://phptal.org/ |
|
| 14 | + */ |
|
| 15 | 15 | |
| 16 | 16 | |
| 17 | 17 | /** |
@@ -466,10 +466,10 @@ discard block |
||
| 466 | 466 | $nsattr = PHPTAL_Dom_Defs::getInstance()->getNamespaceAttribute($domattr->getNamespaceURI(), $domattr->getLocalName()); |
| 467 | 467 | if (array_key_exists($nsattr->getPriority(), $temp)) { |
| 468 | 468 | throw new PHPTAL_TemplateException(sprintf("Attribute conflict in < %s > '%s' cannot appear with '%s'", |
| 469 | - $this->qualifiedName, |
|
| 470 | - $key, |
|
| 471 | - $temp[$nsattr->getPriority()][0]->getNamespace()->getPrefix() . ':' . $temp[$nsattr->getPriority()][0]->getLocalName() |
|
| 472 | - ), $this->getSourceFile(), $this->getSourceLine()); |
|
| 469 | + $this->qualifiedName, |
|
| 470 | + $key, |
|
| 471 | + $temp[$nsattr->getPriority()][0]->getNamespace()->getPrefix() . ':' . $temp[$nsattr->getPriority()][0]->getLocalName() |
|
| 472 | + ), $this->getSourceFile(), $this->getSourceLine()); |
|
| 473 | 473 | } |
| 474 | 474 | $temp[$nsattr->getPriority()] = array($nsattr, $domattr); |
| 475 | 475 | } |
@@ -80,6 +80,10 @@ |
||
| 80 | 80 | ); |
| 81 | 81 | |
| 82 | 82 | private $input_encoding; |
| 83 | + |
|
| 84 | + /** |
|
| 85 | + * @param string $input_encoding |
|
| 86 | + */ |
|
| 83 | 87 | public function __construct($input_encoding) |
| 84 | 88 | { |
| 85 | 89 | $this->input_encoding = $input_encoding; |
@@ -116,12 +116,12 @@ discard block |
||
| 116 | 116 | $builder->setSource($this->_file, $this->_line); |
| 117 | 117 | $builder->onDocumentStart(); |
| 118 | 118 | |
| 119 | - $i=0; |
|
| 119 | + $i = 0; |
|
| 120 | 120 | // remove BOM (UTF-8 byte order mark)... |
| 121 | 121 | if (substr($src, 0, 3) === self::BOM_STR) { |
| 122 | - $i=3; |
|
| 122 | + $i = 3; |
|
| 123 | 123 | } |
| 124 | - for (; $i<$len; $i++) { |
|
| 124 | + for (; $i < $len; $i++) { |
|
| 125 | 125 | $c = $src[$i]; // Change to substr($src, $i, 1); if you want to use mb_string.func_overload |
| 126 | 126 | |
| 127 | 127 | if ($c === "\n") $builder->setSource($this->_file, ++$this->_line); |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | if ($c !== '>') { |
| 202 | 202 | $this->raiseError("Expected '/>', but found '/$c' inside tag < $tagname >"); |
| 203 | 203 | } |
| 204 | - $mark = $i+1; // mark text start |
|
| 204 | + $mark = $i+1; // mark text start |
|
| 205 | 205 | $state = self::ST_TEXT; |
| 206 | 206 | $builder->onElementStart($tagname, $attributes); |
| 207 | 207 | $builder->onElementClose($tagname); |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | case self::ST_TAG_BETWEEN_ATTRIBUTE: |
| 211 | 211 | case self::ST_TAG_ATTRIBUTES: |
| 212 | 212 | if ($c === '>') { |
| 213 | - $mark = $i+1; // mark text start |
|
| 213 | + $mark = $i+1; // mark text start |
|
| 214 | 214 | $state = self::ST_TEXT; |
| 215 | 215 | $builder->onElementStart($tagname, $attributes); |
| 216 | 216 | } elseif ($c === '/') { |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | case self::ST_COMMENT: |
| 227 | 227 | if ($c === '>' && $i > $mark+4 && substr($src, $i-2, 2) === '--') { |
| 228 | 228 | |
| 229 | - if (preg_match('/^-|--|-$/', substr($src, $mark +4, $i-$mark+1 -7))) { |
|
| 229 | + if (preg_match('/^-|--|-$/', substr($src, $mark+4, $i-$mark+1-7))) { |
|
| 230 | 230 | $this->raiseError("Ill-formed comment. XML comments are not allowed to contain '--' or start/end with '-': ".substr($src, $mark+4, $i-$mark+1-7)); |
| 231 | 231 | } |
| 232 | 232 | |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | |
| 290 | 290 | if ($c === '=') $state = self::ST_ATTR_VALUE; |
| 291 | 291 | else /* white char */ $state = self::ST_ATTR_EQ; |
| 292 | - } elseif ($c === '/' || $c==='>') { |
|
| 292 | + } elseif ($c === '/' || $c === '>') { |
|
| 293 | 293 | $attribute = substr($src, $mark, $i-$mark); |
| 294 | 294 | if (!$this->isValidQName($attribute)) { |
| 295 | 295 | $this->raiseError("Invalid attribute name '$attribute'"); |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | |
| 324 | 324 | // PHPTAL's code generator assumes input is escaped for double-quoted strings. Single-quoted attributes need to be converted. |
| 325 | 325 | // FIXME: it should be escaped at later stage. |
| 326 | - $attributes[$attribute] = str_replace('"',""", $attributes[$attribute]); |
|
| 326 | + $attributes[$attribute] = str_replace('"', """, $attributes[$attribute]); |
|
| 327 | 327 | $state = self::ST_TAG_BETWEEN_ATTRIBUTE; |
| 328 | 328 | } |
| 329 | 329 | break; |
@@ -347,7 +347,7 @@ discard block |
||
| 347 | 347 | |
| 348 | 348 | $builder->onDocumentEnd(); |
| 349 | 349 | } |
| 350 | - catch(PHPTAL_TemplateException $e) |
|
| 350 | + catch (PHPTAL_TemplateException $e) |
|
| 351 | 351 | { |
| 352 | 352 | $e->hintSrcPosition($this->_file, $this->_line); |
| 353 | 353 | throw $e; |
@@ -370,7 +370,7 @@ discard block |
||
| 370 | 370 | // $match expression below somehow triggers quite deep recurrency and stack overflow in preg |
| 371 | 371 | // to avoid this, check string bit by bit, omitting ASCII fragments. |
| 372 | 372 | if (strlen($str) > 200) { |
| 373 | - $chunks = preg_split('/(?>[\x09\x0A\x0D\x20-\x7F]+)/',$str,null,PREG_SPLIT_NO_EMPTY); |
|
| 373 | + $chunks = preg_split('/(?>[\x09\x0A\x0D\x20-\x7F]+)/', $str, null, PREG_SPLIT_NO_EMPTY); |
|
| 374 | 374 | foreach ($chunks as $chunk) { |
| 375 | 375 | if (strlen($chunk) < 200) { |
| 376 | 376 | $this->checkEncoding($chunk); |
@@ -389,11 +389,11 @@ discard block |
||
| 389 | 389 | . '|\xED[\x80-\x9F][\x80-\xBF]' // excluding surrogates |
| 390 | 390 | . '|\xF0[\x90-\xBF][\x80-\xBF]{2}' // planes 1-3 |
| 391 | 391 | . '|[\xF1-\xF3][\x80-\xBF]{3}' // planes 4-15 |
| 392 | - . '|\xF4[\x80-\x8F][\x80-\xBF]{2}'; // plane 16 |
|
| 392 | + . '|\xF4[\x80-\x8F][\x80-\xBF]{2}'; // plane 16 |
|
| 393 | 393 | |
| 394 | - if (!preg_match('/^(?:(?>'.$match.'))+$/s',$str)) { |
|
| 395 | - $res = preg_split('/((?>'.$match.')+)/s',$str,null,PREG_SPLIT_DELIM_CAPTURE); |
|
| 396 | - for($i=0; $i < count($res); $i+=2) |
|
| 394 | + if (!preg_match('/^(?:(?>'.$match.'))+$/s', $str)) { |
|
| 395 | + $res = preg_split('/((?>'.$match.')+)/s', $str, null, PREG_SPLIT_DELIM_CAPTURE); |
|
| 396 | + for ($i = 0; $i < count($res); $i += 2) |
|
| 397 | 397 | { |
| 398 | 398 | $res[$i] = self::convertBytesToEntities(array(1=>$res[$i])); |
| 399 | 399 | } |
@@ -425,7 +425,7 @@ discard block |
||
| 425 | 425 | private static function convertBytesToEntities(array $m) |
| 426 | 426 | { |
| 427 | 427 | $m = $m[1]; $out = ''; |
| 428 | - for($i=0; $i < strlen($m); $i++) |
|
| 428 | + for ($i = 0; $i < strlen($m); $i++) |
|
| 429 | 429 | { |
| 430 | 430 | $out .= '&#X'.strtoupper(dechex(ord($m[$i]))).';'; |
| 431 | 431 | } |
@@ -124,7 +124,9 @@ discard block |
||
| 124 | 124 | for (; $i<$len; $i++) { |
| 125 | 125 | $c = $src[$i]; // Change to substr($src, $i, 1); if you want to use mb_string.func_overload |
| 126 | 126 | |
| 127 | - if ($c === "\n") $builder->setSource($this->_file, ++$this->_line); |
|
| 127 | + if ($c === "\n") { |
|
| 128 | + $builder->setSource($this->_file, ++$this->_line); |
|
| 129 | + } |
|
| 128 | 130 | |
| 129 | 131 | switch ($state) { |
| 130 | 132 | case self::ST_ROOT: |
@@ -174,7 +176,9 @@ discard block |
||
| 174 | 176 | case self::ST_TAG_NAME: |
| 175 | 177 | if (self::isWhiteChar($c) || $c === '/' || $c === '>') { |
| 176 | 178 | $tagname = substr($src, $mark, $i-$mark); |
| 177 | - if (!$this->isValidQName($tagname)) $this->raiseError("Invalid tag name '$tagname'"); |
|
| 179 | + if (!$this->isValidQName($tagname)) { |
|
| 180 | + $this->raiseError("Invalid tag name '$tagname'"); |
|
| 181 | + } |
|
| 178 | 182 | |
| 179 | 183 | if ($c === '/') { |
| 180 | 184 | $state = self::ST_TAG_SINGLE; |
@@ -220,7 +224,9 @@ discard block |
||
| 220 | 224 | } elseif ($state === self::ST_TAG_ATTRIBUTES && $this->isValidQName($c)) { |
| 221 | 225 | $mark = $i; // mark attribute key start |
| 222 | 226 | $state = self::ST_ATTR_KEY; |
| 223 | - } else $this->raiseError("Unexpected character '$c' between attributes of < $tagname >"); |
|
| 227 | + } else { |
|
| 228 | + $this->raiseError("Unexpected character '$c' between attributes of < $tagname >"); |
|
| 229 | + } |
|
| 224 | 230 | break; |
| 225 | 231 | |
| 226 | 232 | case self::ST_COMMENT: |
@@ -287,8 +293,11 @@ discard block |
||
| 287 | 293 | $this->raiseError("Attribute $attribute in < $tagname > is defined more than once"); |
| 288 | 294 | } |
| 289 | 295 | |
| 290 | - if ($c === '=') $state = self::ST_ATTR_VALUE; |
|
| 291 | - else /* white char */ $state = self::ST_ATTR_EQ; |
|
| 296 | + if ($c === '=') { |
|
| 297 | + $state = self::ST_ATTR_VALUE; |
|
| 298 | + } else { |
|
| 299 | + /* white char */ $state = self::ST_ATTR_EQ; |
|
| 300 | + } |
|
| 292 | 301 | } elseif ($c === '/' || $c==='>') { |
| 293 | 302 | $attribute = substr($src, $mark, $i-$mark); |
| 294 | 303 | if (!$this->isValidQName($attribute)) { |
@@ -330,11 +339,15 @@ discard block |
||
| 330 | 339 | } |
| 331 | 340 | } |
| 332 | 341 | |
| 333 | - if ($state === self::ST_TEXT) // allows text past root node, which is in violation of XML spec |
|
| 342 | + if ($state === self::ST_TEXT) { |
|
| 343 | + // allows text past root node, which is in violation of XML spec |
|
| 334 | 344 | { |
| 335 | 345 | if ($i > $mark) { |
| 336 | 346 | $text = substr($src, $mark, $i-$mark); |
| 337 | - if (!ctype_space($text)) $this->raiseError("Characters found after end of the root element (wrap document in < tal:block > to avoid this error)"); |
|
| 347 | + } |
|
| 348 | + if (!ctype_space($text)) { |
|
| 349 | + $this->raiseError("Characters found after end of the root element (wrap document in < tal:block > to avoid this error)"); |
|
| 350 | + } |
|
| 338 | 351 | } |
| 339 | 352 | } else { |
| 340 | 353 | if ($state === self::ST_ROOT) { |
@@ -346,8 +359,7 @@ discard block |
||
| 346 | 359 | } |
| 347 | 360 | |
| 348 | 361 | $builder->onDocumentEnd(); |
| 349 | - } |
|
| 350 | - catch(PHPTAL_TemplateException $e) |
|
| 362 | + } catch(PHPTAL_TemplateException $e) |
|
| 351 | 363 | { |
| 352 | 364 | $e->hintSrcPosition($this->_file, $this->_line); |
| 353 | 365 | throw $e; |
@@ -363,7 +375,9 @@ discard block |
||
| 363 | 375 | |
| 364 | 376 | private function checkEncoding($str) |
| 365 | 377 | { |
| 366 | - if ($str === '') return ''; |
|
| 378 | + if ($str === '') { |
|
| 379 | + return ''; |
|
| 380 | + } |
|
| 367 | 381 | |
| 368 | 382 | if ($this->input_encoding === 'UTF-8') { |
| 369 | 383 | |
@@ -454,7 +468,9 @@ discard block |
||
| 454 | 468 | private static function convertPHPBlockToTALES($m) |
| 455 | 469 | { |
| 456 | 470 | list(, $type, $code) = $m; |
| 457 | - if ($type === '=') $code = 'echo '.$code; |
|
| 471 | + if ($type === '=') { |
|
| 472 | + $code = 'echo '.$code; |
|
| 473 | + } |
|
| 458 | 474 | return '${structure phptal-internal-php-block:'.rawurlencode($code).'}'; |
| 459 | 475 | } |
| 460 | 476 | |
@@ -1,17 +1,17 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * PHPTAL templating engine |
|
| 4 | - * |
|
| 5 | - * PHP Version 5 |
|
| 6 | - * |
|
| 7 | - * @category HTML |
|
| 8 | - * @package PHPTAL |
|
| 9 | - * @author Laurent Bedubourg <[email protected]> |
|
| 10 | - * @author Kornel Lesiński <[email protected]> |
|
| 11 | - * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License |
|
| 12 | - * @version SVN: $Id$ |
|
| 13 | - * @link http://phptal.org/ |
|
| 14 | - */ |
|
| 3 | + * PHPTAL templating engine |
|
| 4 | + * |
|
| 5 | + * PHP Version 5 |
|
| 6 | + * |
|
| 7 | + * @category HTML |
|
| 8 | + * @package PHPTAL |
|
| 9 | + * @author Laurent Bedubourg <[email protected]> |
|
| 10 | + * @author Kornel Lesiński <[email protected]> |
|
| 11 | + * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License |
|
| 12 | + * @version SVN: $Id$ |
|
| 13 | + * @link http://phptal.org/ |
|
| 14 | + */ |
|
| 15 | 15 | |
| 16 | 16 | /** |
| 17 | 17 | * Simple sax like xml parser for PHPTAL |
@@ -60,23 +60,23 @@ discard block |
||
| 60 | 60 | |
| 61 | 61 | |
| 62 | 62 | static $state_names = array( |
| 63 | - self::ST_ROOT => 'root node', |
|
| 64 | - self::ST_TEXT => 'text', |
|
| 65 | - self::ST_LT => 'start of tag', |
|
| 66 | - self::ST_TAG_NAME => 'tag name', |
|
| 67 | - self::ST_TAG_CLOSE => 'closing tag', |
|
| 68 | - self::ST_TAG_SINGLE => 'self-closing tag', |
|
| 69 | - self::ST_TAG_ATTRIBUTES => 'tag', |
|
| 70 | - self::ST_TAG_BETWEEN_ATTRIBUTE => 'tag attributes', |
|
| 71 | - self::ST_CDATA => 'CDATA', |
|
| 72 | - self::ST_COMMENT => 'comment', |
|
| 73 | - self::ST_DOCTYPE => 'doctype', |
|
| 74 | - self::ST_XMLDEC => 'XML declaration', |
|
| 75 | - self::ST_PREPROC => 'preprocessor directive', |
|
| 76 | - self::ST_ATTR_KEY => 'attribute name', |
|
| 77 | - self::ST_ATTR_EQ => 'attribute value', |
|
| 78 | - self::ST_ATTR_QUOTE => 'quoted attribute value', |
|
| 79 | - self::ST_ATTR_VALUE => 'unquoted attribute value', |
|
| 63 | + self::ST_ROOT => 'root node', |
|
| 64 | + self::ST_TEXT => 'text', |
|
| 65 | + self::ST_LT => 'start of tag', |
|
| 66 | + self::ST_TAG_NAME => 'tag name', |
|
| 67 | + self::ST_TAG_CLOSE => 'closing tag', |
|
| 68 | + self::ST_TAG_SINGLE => 'self-closing tag', |
|
| 69 | + self::ST_TAG_ATTRIBUTES => 'tag', |
|
| 70 | + self::ST_TAG_BETWEEN_ATTRIBUTE => 'tag attributes', |
|
| 71 | + self::ST_CDATA => 'CDATA', |
|
| 72 | + self::ST_COMMENT => 'comment', |
|
| 73 | + self::ST_DOCTYPE => 'doctype', |
|
| 74 | + self::ST_XMLDEC => 'XML declaration', |
|
| 75 | + self::ST_PREPROC => 'preprocessor directive', |
|
| 76 | + self::ST_ATTR_KEY => 'attribute name', |
|
| 77 | + self::ST_ATTR_EQ => 'attribute value', |
|
| 78 | + self::ST_ATTR_QUOTE => 'quoted attribute value', |
|
| 79 | + self::ST_ATTR_VALUE => 'unquoted attribute value', |
|
| 80 | 80 | ); |
| 81 | 81 | |
| 82 | 82 | private $input_encoding; |
@@ -381,15 +381,15 @@ discard block |
||
| 381 | 381 | |
| 382 | 382 | // http://www.w3.org/International/questions/qa-forms-utf-8 |
| 383 | 383 | $match = '[\x09\x0A\x0D\x20-\x7F]' // ASCII |
| 384 | - . '|[\xC2-\xDF][\x80-\xBF]' // non-overlong 2-byte |
|
| 385 | - . '|\xE0[\xA0-\xBF][\x80-\xBF]' // excluding overlongs |
|
| 386 | - . '|[\xE1-\xEC\xEE\xEE][\x80-\xBF]{2}' // straight 3-byte (exclude FFFE and FFFF) |
|
| 387 | - . '|\xEF[\x80-\xBE][\x80-\xBF]' // straight 3-byte |
|
| 388 | - . '|\xEF\xBF[\x80-\xBD]' // straight 3-byte |
|
| 389 | - . '|\xED[\x80-\x9F][\x80-\xBF]' // excluding surrogates |
|
| 390 | - . '|\xF0[\x90-\xBF][\x80-\xBF]{2}' // planes 1-3 |
|
| 391 | - . '|[\xF1-\xF3][\x80-\xBF]{3}' // planes 4-15 |
|
| 392 | - . '|\xF4[\x80-\x8F][\x80-\xBF]{2}'; // plane 16 |
|
| 384 | + . '|[\xC2-\xDF][\x80-\xBF]' // non-overlong 2-byte |
|
| 385 | + . '|\xE0[\xA0-\xBF][\x80-\xBF]' // excluding overlongs |
|
| 386 | + . '|[\xE1-\xEC\xEE\xEE][\x80-\xBF]{2}' // straight 3-byte (exclude FFFE and FFFF) |
|
| 387 | + . '|\xEF[\x80-\xBE][\x80-\xBF]' // straight 3-byte |
|
| 388 | + . '|\xEF\xBF[\x80-\xBD]' // straight 3-byte |
|
| 389 | + . '|\xED[\x80-\x9F][\x80-\xBF]' // excluding surrogates |
|
| 390 | + . '|\xF0[\x90-\xBF][\x80-\xBF]{2}' // planes 1-3 |
|
| 391 | + . '|[\xF1-\xF3][\x80-\xBF]{3}' // planes 4-15 |
|
| 392 | + . '|\xF4[\x80-\x8F][\x80-\xBF]{2}'; // plane 16 |
|
| 393 | 393 | |
| 394 | 394 | if (!preg_match('/^(?:(?>'.$match.'))+$/s',$str)) { |
| 395 | 395 | $res = preg_split('/((?>'.$match.')+)/s',$str,null,PREG_SPLIT_DELIM_CAPTURE); |
@@ -27,6 +27,7 @@ |
||
| 27 | 27 | * Doesn't change exception handler if non-default one is set. |
| 28 | 28 | * |
| 29 | 29 | * @param Exception e exception to re-throw and display |
| 30 | + * @param string $encoding |
|
| 30 | 31 | * |
| 31 | 32 | * @return void |
| 32 | 33 | * @throws Exception |
@@ -64,11 +64,11 @@ |
||
| 64 | 64 | |
| 65 | 65 | if (ini_get('display_errors')) { |
| 66 | 66 | $title = get_class($e).': '.htmlspecialchars($e->getMessage()); |
| 67 | - $body = "<p><strong>\n".htmlspecialchars($e->getMessage()).'</strong></p>' . |
|
| 67 | + $body = "<p><strong>\n".htmlspecialchars($e->getMessage()).'</strong></p>'. |
|
| 68 | 68 | '<p>In '.htmlspecialchars($line)."</p><pre>\n".htmlspecialchars($e->getTraceAsString()).'</pre>'; |
| 69 | 69 | } else { |
| 70 | 70 | $title = "PHPTAL Exception"; |
| 71 | - $body = "<p>This page cannot be displayed.</p><hr/>" . |
|
| 71 | + $body = "<p>This page cannot be displayed.</p><hr/>". |
|
| 72 | 72 | "<p><small>Enable <code>display_errors</code> to see detailed message.</small></p>"; |
| 73 | 73 | } |
| 74 | 74 | |
@@ -21,6 +21,9 @@ |
||
| 21 | 21 | */ |
| 22 | 22 | interface PHPTAL_Keywords extends Countable |
| 23 | 23 | { |
| 24 | + /** |
|
| 25 | + * @return string |
|
| 26 | + */ |
|
| 24 | 27 | public function __toString(); |
| 25 | 28 | } |
| 26 | 29 | ?> |
@@ -1,16 +1,16 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * PHPTAL templating engine |
|
| 4 | - * |
|
| 5 | - * PHP Version 5 |
|
| 6 | - * |
|
| 7 | - * @category HTML |
|
| 8 | - * @package PHPTAL |
|
| 9 | - * @author Andrew Crites <[email protected]> |
|
| 10 | - * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License |
|
| 11 | - * @version SVN: $Id$ |
|
| 12 | - * @link http://phptal.org/ |
|
| 13 | - */ |
|
| 3 | + * PHPTAL templating engine |
|
| 4 | + * |
|
| 5 | + * PHP Version 5 |
|
| 6 | + * |
|
| 7 | + * @category HTML |
|
| 8 | + * @package PHPTAL |
|
| 9 | + * @author Andrew Crites <[email protected]> |
|
| 10 | + * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License |
|
| 11 | + * @version SVN: $Id$ |
|
| 12 | + * @link http://phptal.org/ |
|
| 13 | + */ |
|
| 14 | 14 | |
| 15 | 15 | |
| 16 | 16 | /** |
@@ -71,8 +71,8 @@ |
||
| 71 | 71 | private $_namespace; |
| 72 | 72 | |
| 73 | 73 | /** |
| 74 | - * @param string $name The attribute name |
|
| 75 | 74 | * @param int $priority Attribute execution priority |
| 75 | + * @param string $local_name |
|
| 76 | 76 | */ |
| 77 | 77 | public function __construct($local_name, $priority) |
| 78 | 78 | { |
@@ -1,17 +1,17 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * PHPTAL templating engine |
|
| 4 | - * |
|
| 5 | - * PHP Version 5 |
|
| 6 | - * |
|
| 7 | - * @category HTML |
|
| 8 | - * @package PHPTAL |
|
| 9 | - * @author Laurent Bedubourg <[email protected]> |
|
| 10 | - * @author Kornel Lesiński <[email protected]> |
|
| 11 | - * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License |
|
| 12 | - * @version SVN: $Id$ |
|
| 13 | - * @link http://phptal.org/ |
|
| 14 | - */ |
|
| 3 | + * PHPTAL templating engine |
|
| 4 | + * |
|
| 5 | + * PHP Version 5 |
|
| 6 | + * |
|
| 7 | + * @category HTML |
|
| 8 | + * @package PHPTAL |
|
| 9 | + * @author Laurent Bedubourg <[email protected]> |
|
| 10 | + * @author Kornel Lesiński <[email protected]> |
|
| 11 | + * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License |
|
| 12 | + * @version SVN: $Id$ |
|
| 13 | + * @link http://phptal.org/ |
|
| 14 | + */ |
|
| 15 | 15 | |
| 16 | 16 | /** |
| 17 | 17 | * You're probably not using PHPTAL class properly |