@@ -39,7 +39,7 @@ |
||
39 | 39 | { |
40 | 40 | $this->compiler = $compiler; |
41 | 41 | $this->template = $compiler->getCore()->getTemplate(); |
42 | - parent::__construct('Compilation error at line ' . $compiler->getLine() . ' in "' . $this->template->getResourceName() . ':' . $this->template->getResourceIdentifier() . '" : ' . $message); |
|
42 | + parent::__construct('Compilation error at line '.$compiler->getLine().' in "'.$this->template->getResourceName().':'.$this->template->getResourceIdentifier().'" : '.$message); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
@@ -56,26 +56,26 @@ discard block |
||
56 | 56 | self::$l = preg_quote($l, '/'); |
57 | 57 | self::$r = preg_quote($r, '/'); |
58 | 58 | self::$regex = '/ |
59 | - ' . self::$l . 'block\s(["\']?)(.+?)\1' . self::$r . '(?:\r?\n?) |
|
59 | + ' . self::$l.'block\s(["\']?)(.+?)\1'.self::$r.'(?:\r?\n?) |
|
60 | 60 | ((?: |
61 | 61 | (?R) |
62 | 62 | | |
63 | - [^' . self::$l . ']* |
|
63 | + [^' . self::$l.']* |
|
64 | 64 | (?: |
65 | - (?! ' . self::$l . '\/?block\b ) |
|
66 | - ' . self::$l . ' |
|
67 | - [^' . self::$l . ']*+ |
|
65 | + (?! ' . self::$l.'\/?block\b ) |
|
66 | + ' . self::$l.' |
|
67 | + [^' . self::$l.']*+ |
|
68 | 68 | )* |
69 | 69 | )*) |
70 | - ' . self::$l . '\/block' . self::$r . ' |
|
70 | + ' . self::$l.'\/block'.self::$r.' |
|
71 | 71 | /six'; |
72 | 72 | |
73 | 73 | if ($compiler->getLooseOpeningHandling()) { |
74 | 74 | self::$l .= '\s*'; |
75 | - self::$r = '\s*' . self::$r; |
|
75 | + self::$r = '\s*'.self::$r; |
|
76 | 76 | } |
77 | 77 | $inheritanceTree = array(array('source' => $compiler->getTemplateSource())); |
78 | - $curPath = dirname($compiler->getCore()->getTemplate()->getResourceIdentifier()) . DIRECTORY_SEPARATOR; |
|
78 | + $curPath = dirname($compiler->getCore()->getTemplate()->getResourceIdentifier()).DIRECTORY_SEPARATOR; |
|
79 | 79 | $curTpl = $compiler->getCore()->getTemplate(); |
80 | 80 | |
81 | 81 | while (!empty($file)) { |
@@ -97,16 +97,16 @@ discard block |
||
97 | 97 | $parent = $compiler->getCore()->templateFactory($resource, $identifier, null, null, null, $curTpl); |
98 | 98 | } |
99 | 99 | catch (SecurityException $e) { |
100 | - throw new CompilationException($compiler, 'Extends : Security restriction : ' . $e->getMessage()); |
|
100 | + throw new CompilationException($compiler, 'Extends : Security restriction : '.$e->getMessage()); |
|
101 | 101 | } |
102 | 102 | catch (Exception $e) { |
103 | - throw new CompilationException($compiler, 'Extends : ' . $e->getMessage()); |
|
103 | + throw new CompilationException($compiler, 'Extends : '.$e->getMessage()); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | if ($parent === null) { |
107 | - throw new CompilationException($compiler, 'Extends : Resource "' . $resource . ':' . $identifier . '" not found.'); |
|
107 | + throw new CompilationException($compiler, 'Extends : Resource "'.$resource.':'.$identifier.'" not found.'); |
|
108 | 108 | } elseif ($parent === false) { |
109 | - throw new CompilationException($compiler, 'Extends : Resource "' . $resource . '" does not support extends.'); |
|
109 | + throw new CompilationException($compiler, 'Extends : Resource "'.$resource.'" does not support extends.'); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | $curTpl = $parent; |
@@ -121,14 +121,14 @@ discard block |
||
121 | 121 | } |
122 | 122 | $inheritanceTree[] = $newParent; |
123 | 123 | |
124 | - if (preg_match('/^' . self::$l . 'extends(?:\(?\s*|\s+)(?:file=)?\s*((["\']).+?\2|\S+?)\s*\)?\s*?' . self::$r . '/i', $parent->getSource(), $match)) { |
|
125 | - $curPath = dirname($identifier) . DIRECTORY_SEPARATOR; |
|
124 | + if (preg_match('/^'.self::$l.'extends(?:\(?\s*|\s+)(?:file=)?\s*((["\']).+?\2|\S+?)\s*\)?\s*?'.self::$r.'/i', $parent->getSource(), $match)) { |
|
125 | + $curPath = dirname($identifier).DIRECTORY_SEPARATOR; |
|
126 | 126 | if (isset($match[2]) && $match[2] == '"') { |
127 | - $file = '"' . str_replace('"', '\\"', substr($match[1], 1, - 1)) . '"'; |
|
127 | + $file = '"'.str_replace('"', '\\"', substr($match[1], 1, - 1)).'"'; |
|
128 | 128 | } elseif (isset($match[2]) && $match[2] == "'") { |
129 | - $file = '"' . substr($match[1], 1, - 1) . '"'; |
|
129 | + $file = '"'.substr($match[1], 1, - 1).'"'; |
|
130 | 130 | } else { |
131 | - $file = '"' . $match[1] . '"'; |
|
131 | + $file = '"'.$match[1].'"'; |
|
132 | 132 | } |
133 | 133 | } else { |
134 | 134 | $file = false; |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | 'Dwoo\Plugins\Functions\PluginExtends', |
148 | 148 | 'replaceBlock' |
149 | 149 | ), $newSource); |
150 | - $newSource = $l . 'do extendsCheck(' . var_export($parent['resource'] . ':' . $parent['identifier'], true) . ')' . $r . $newSource; |
|
150 | + $newSource = $l.'do extendsCheck('.var_export($parent['resource'].':'.$parent['identifier'], true).')'.$r.$newSource; |
|
151 | 151 | |
152 | 152 | if (self::$lastReplacement) { |
153 | 153 | break; |
@@ -174,10 +174,10 @@ discard block |
||
174 | 174 | $r = stripslashes(self::$r); |
175 | 175 | |
176 | 176 | if (self::$lastReplacement) { |
177 | - return preg_replace('/' . self::$l . '\$dwoo\.parent' . self::$r . '/is', $matches[3], $override); |
|
177 | + return preg_replace('/'.self::$l.'\$dwoo\.parent'.self::$r.'/is', $matches[3], $override); |
|
178 | 178 | } |
179 | 179 | |
180 | - return $l . 'block ' . $matches[1] . $matches[2] . $matches[1] . $r . preg_replace('/' . self::$l . '\$dwoo\.parent' . self::$r . '/is', $matches[3], $override) . $l . '/block' . $r; |
|
180 | + return $l.'block '.$matches[1].$matches[2].$matches[1].$r.preg_replace('/'.self::$l.'\$dwoo\.parent'.self::$r.'/is', $matches[3], $override).$l.'/block'.$r; |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | if (preg_match(self::$regex, $matches[3])) { |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | public static function compile(Compiler $compiler, array $rest, array $tokens) |
48 | 48 | { |
49 | 49 | // load if plugin |
50 | - if (!class_exists(Core::NAMESPACE_PLUGINS_BLOCKS . 'PluginIf')) { |
|
50 | + if (!class_exists(Core::NAMESPACE_PLUGINS_BLOCKS.'PluginIf')) { |
|
51 | 51 | try { |
52 | 52 | $compiler->getCore()->getLoader()->loadPlugin('if'); |
53 | 53 | } |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | } elseif (trim(end($rest), '"\'') === '?' || count($rest) === 1) { |
70 | 70 | if ($falseResult === '?' || $falseResult === ':') { |
71 | 71 | throw new CompilationException($compiler, |
72 | - 'Tif: incomplete tif statement, value missing after ' . $falseResult); |
|
72 | + 'Tif: incomplete tif statement, value missing after '.$falseResult); |
|
73 | 73 | } |
74 | 74 | // there was in fact no false result provided, so we move it to be the true result instead |
75 | 75 | $trueResult = $falseResult; |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | // parse condition |
100 | 100 | $condition = PluginIf::replaceKeywords($rest, $tokens, $compiler); |
101 | 101 | |
102 | - return '((' . implode(' ', $condition) . ') ? ' . ($trueResult === true ? implode(' ', |
|
103 | - $condition) : $trueResult) . ' : ' . $falseResult . ')'; |
|
102 | + return '(('.implode(' ', $condition).') ? '.($trueResult === true ? implode(' ', |
|
103 | + $condition) : $trueResult).' : '.$falseResult.')'; |
|
104 | 104 | } |
105 | 105 | } |
106 | 106 | \ No newline at end of file |
@@ -377,8 +377,8 @@ discard block |
||
377 | 377 | } |
378 | 378 | |
379 | 379 | if ($doCache === true) { |
380 | - $out = preg_replace('/(<%|%>|<\?php|<\?|\?>)/', '<?php /*' . $dynamicId . '*/ echo \'$1\'; ?>', $out); |
|
381 | - if (!class_exists(self::NAMESPACE_PLUGINS_BLOCKS . 'PluginDynamic')) { |
|
380 | + $out = preg_replace('/(<%|%>|<\?php|<\?|\?>)/', '<?php /*'.$dynamicId.'*/ echo \'$1\'; ?>', $out); |
|
381 | + if (!class_exists(self::NAMESPACE_PLUGINS_BLOCKS.'PluginDynamic')) { |
|
382 | 382 | $this->getLoader()->loadPlugin('PluginDynamic'); |
383 | 383 | } |
384 | 384 | $out = PluginDynamic::unescape($out, $dynamicId, $compiledTemplate); |
@@ -588,16 +588,16 @@ discard block |
||
588 | 588 | public function addFilter($callback, $autoload = false) |
589 | 589 | { |
590 | 590 | if ($autoload) { |
591 | - $class = self::NAMESPACE_PLUGINS_FILTERS . self::toCamelCase($callback); |
|
591 | + $class = self::NAMESPACE_PLUGINS_FILTERS.self::toCamelCase($callback); |
|
592 | 592 | if (!class_exists($class) && !function_exists($class)) { |
593 | 593 | try { |
594 | 594 | $this->getLoader()->loadPlugin($callback); |
595 | 595 | } |
596 | 596 | catch (Exception $e) { |
597 | 597 | if (strstr($callback, self::NAMESPACE_PLUGINS_FILTERS)) { |
598 | - throw new Exception('Wrong filter name : ' . $callback . ', the "Filter" prefix should not be used, please only use "' . str_replace('Filter', '', $callback) . '"'); |
|
598 | + throw new Exception('Wrong filter name : '.$callback.', the "Filter" prefix should not be used, please only use "'.str_replace('Filter', '', $callback).'"'); |
|
599 | 599 | } else { |
600 | - throw new Exception('Wrong filter name : ' . $callback . ', when using autoload the filter must be in one of your plugin dir as "name.php" containig a class or function named "Filter<name>"'); |
|
600 | + throw new Exception('Wrong filter name : '.$callback.', when using autoload the filter must be in one of your plugin dir as "name.php" containig a class or function named "Filter<name>"'); |
|
601 | 601 | } |
602 | 602 | } |
603 | 603 | } |
@@ -607,7 +607,7 @@ discard block |
||
607 | 607 | } elseif (function_exists($class)) { |
608 | 608 | $callback = $class; |
609 | 609 | } else { |
610 | - throw new Exception('Wrong filter name : ' . $callback . ', when using autoload the filter must be in one of your plugin dir as "name.php" containig a class or function named "Filter<name>"'); |
|
610 | + throw new Exception('Wrong filter name : '.$callback.', when using autoload the filter must be in one of your plugin dir as "name.php" containig a class or function named "Filter<name>"'); |
|
611 | 611 | } |
612 | 612 | |
613 | 613 | $this->filters[] = $callback; |
@@ -625,14 +625,14 @@ discard block |
||
625 | 625 | */ |
626 | 626 | public function removeFilter($callback) |
627 | 627 | { |
628 | - if (($index = array_search(self::NAMESPACE_PLUGINS_FILTERS. 'Filter' . self::toCamelCase($callback), $this->filters, |
|
628 | + if (($index = array_search(self::NAMESPACE_PLUGINS_FILTERS.'Filter'.self::toCamelCase($callback), $this->filters, |
|
629 | 629 | true)) !== |
630 | 630 | false) { |
631 | 631 | unset($this->filters[$index]); |
632 | 632 | } elseif (($index = array_search($callback, $this->filters, true)) !== false) { |
633 | 633 | unset($this->filters[$index]); |
634 | 634 | } else { |
635 | - $class = self::NAMESPACE_PLUGINS_FILTERS . 'Filter' . $callback; |
|
635 | + $class = self::NAMESPACE_PLUGINS_FILTERS.'Filter'.$callback; |
|
636 | 636 | foreach ($this->filters as $index => $filter) { |
637 | 637 | if (is_array($filter) && $filter[0] instanceof $class) { |
638 | 638 | unset($this->filters[$index]); |
@@ -755,7 +755,7 @@ discard block |
||
755 | 755 | public function getCacheDir() |
756 | 756 | { |
757 | 757 | if ($this->cacheDir === null) { |
758 | - $this->setCacheDir(dirname(__DIR__) . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR); |
|
758 | + $this->setCacheDir(dirname(__DIR__).DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR); |
|
759 | 759 | } |
760 | 760 | |
761 | 761 | return $this->cacheDir; |
@@ -771,12 +771,12 @@ discard block |
||
771 | 771 | */ |
772 | 772 | public function setCacheDir($dir) |
773 | 773 | { |
774 | - $this->cacheDir = rtrim($dir, '/\\') . DIRECTORY_SEPARATOR; |
|
774 | + $this->cacheDir = rtrim($dir, '/\\').DIRECTORY_SEPARATOR; |
|
775 | 775 | if (!file_exists($this->cacheDir)) { |
776 | 776 | mkdir($this->cacheDir, 0777, true); |
777 | 777 | } |
778 | 778 | if (is_writable($this->cacheDir) === false) { |
779 | - throw new Exception('The cache directory must be writable, chmod "' . $this->cacheDir . '" to make it writable'); |
|
779 | + throw new Exception('The cache directory must be writable, chmod "'.$this->cacheDir.'" to make it writable'); |
|
780 | 780 | } |
781 | 781 | } |
782 | 782 | |
@@ -788,7 +788,7 @@ discard block |
||
788 | 788 | public function getCompileDir() |
789 | 789 | { |
790 | 790 | if ($this->compileDir === null) { |
791 | - $this->setCompileDir(dirname(__DIR__) . DIRECTORY_SEPARATOR . 'compiled' . DIRECTORY_SEPARATOR); |
|
791 | + $this->setCompileDir(dirname(__DIR__).DIRECTORY_SEPARATOR.'compiled'.DIRECTORY_SEPARATOR); |
|
792 | 792 | } |
793 | 793 | |
794 | 794 | return $this->compileDir; |
@@ -804,12 +804,12 @@ discard block |
||
804 | 804 | */ |
805 | 805 | public function setCompileDir($dir) |
806 | 806 | { |
807 | - $this->compileDir = rtrim($dir, '/\\') . DIRECTORY_SEPARATOR; |
|
807 | + $this->compileDir = rtrim($dir, '/\\').DIRECTORY_SEPARATOR; |
|
808 | 808 | if (!file_exists($this->compileDir)) { |
809 | 809 | mkdir($this->compileDir, 0777, true); |
810 | 810 | } |
811 | 811 | if (is_writable($this->compileDir) === false) { |
812 | - throw new Exception('The compile directory must be writable, chmod "' . $this->compileDir . '" to make it writable'); |
|
812 | + throw new Exception('The compile directory must be writable, chmod "'.$this->compileDir.'" to make it writable'); |
|
813 | 813 | } |
814 | 814 | } |
815 | 815 | |
@@ -833,9 +833,9 @@ discard block |
||
833 | 833 | */ |
834 | 834 | public function setTemplateDir($dir) |
835 | 835 | { |
836 | - $tmpDir = rtrim($dir, '/\\') . DIRECTORY_SEPARATOR; |
|
836 | + $tmpDir = rtrim($dir, '/\\').DIRECTORY_SEPARATOR; |
|
837 | 837 | if (is_dir($tmpDir) === false) { |
838 | - throw new Exception('The template directory: "' . $tmpDir . '" does not exists, create the directory or specify an other location !'); |
|
838 | + throw new Exception('The template directory: "'.$tmpDir.'" does not exists, create the directory or specify an other location !'); |
|
839 | 839 | } |
840 | 840 | $this->templateDir[] = $tmpDir; |
841 | 841 | } |
@@ -859,7 +859,7 @@ discard block |
||
859 | 859 | */ |
860 | 860 | public function setCacheTime($seconds) |
861 | 861 | { |
862 | - $this->cacheTime = (int)$seconds; |
|
862 | + $this->cacheTime = (int) $seconds; |
|
863 | 863 | } |
864 | 864 | |
865 | 865 | /** |
@@ -883,7 +883,7 @@ discard block |
||
883 | 883 | */ |
884 | 884 | public function setCharset($charset) |
885 | 885 | { |
886 | - $this->charset = strtolower((string)$charset); |
|
886 | + $this->charset = strtolower((string) $charset); |
|
887 | 887 | } |
888 | 888 | |
889 | 889 | /** |
@@ -1020,11 +1020,11 @@ discard block |
||
1020 | 1020 | public function clearCache($olderThan = - 1) |
1021 | 1021 | { |
1022 | 1022 | $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->getCacheDir()), \RecursiveIteratorIterator::SELF_FIRST); |
1023 | - $expired = time() - $olderThan; |
|
1023 | + $expired = time()-$olderThan; |
|
1024 | 1024 | $count = 0; |
1025 | 1025 | foreach ($iterator as $file) { |
1026 | 1026 | if ($file->isFile() && $file->getCTime() < $expired) { |
1027 | - $count += unlink((string)$file) ? 1 : 0; |
|
1027 | + $count += unlink((string) $file) ? 1 : 0; |
|
1028 | 1028 | } |
1029 | 1029 | } |
1030 | 1030 | |
@@ -1057,7 +1057,7 @@ discard block |
||
1057 | 1057 | return $class::templateFactory($this, $resourceId, $cacheTime, $cacheId, $compileId, $parentTemplate); |
1058 | 1058 | } |
1059 | 1059 | |
1060 | - throw new Exception('Unknown resource type : ' . $resourceName); |
|
1060 | + throw new Exception('Unknown resource type : '.$resourceName); |
|
1061 | 1061 | } |
1062 | 1062 | |
1063 | 1063 | /** |
@@ -1157,7 +1157,7 @@ discard block |
||
1157 | 1157 | if (!($tplIdentifier = $this->template->getResourceIdentifier())) { |
1158 | 1158 | $tplIdentifier = $this->template->getResourceName(); |
1159 | 1159 | } |
1160 | - trigger_error('Dwoo error (in ' . $tplIdentifier . ') : ' . $message, $level); |
|
1160 | + trigger_error('Dwoo error (in '.$tplIdentifier.') : '.$message, $level); |
|
1161 | 1161 | } |
1162 | 1162 | |
1163 | 1163 | /** |
@@ -1173,7 +1173,7 @@ discard block |
||
1173 | 1173 | if (isset($this->plugins[$blockName])) { |
1174 | 1174 | $class = $this->plugins[$blockName]['class']; |
1175 | 1175 | } else { |
1176 | - $class = self::NAMESPACE_PLUGINS_BLOCKS . 'Plugin' . self::toCamelCase($blockName); |
|
1176 | + $class = self::NAMESPACE_PLUGINS_BLOCKS.'Plugin'.self::toCamelCase($blockName); |
|
1177 | 1177 | } |
1178 | 1178 | |
1179 | 1179 | if ($this->curBlock !== null) { |
@@ -1236,7 +1236,7 @@ discard block |
||
1236 | 1236 | { |
1237 | 1237 | $index = array_search($block, $this->stack, true); |
1238 | 1238 | if ($index !== false && $index > 0) { |
1239 | - return $this->stack[$index - 1]; |
|
1239 | + return $this->stack[$index-1]; |
|
1240 | 1240 | } |
1241 | 1241 | |
1242 | 1242 | return false; |
@@ -1254,7 +1254,7 @@ discard block |
||
1254 | 1254 | if (isset($this->plugins[$type])) { |
1255 | 1255 | $type = $this->plugins[$type]['class']; |
1256 | 1256 | } else { |
1257 | - $type = self::NAMESPACE_PLUGINS_BLOCKS . 'Plugin_' . str_replace(self::NAMESPACE_PLUGINS_BLOCKS.'Plugin', |
|
1257 | + $type = self::NAMESPACE_PLUGINS_BLOCKS.'Plugin_'.str_replace(self::NAMESPACE_PLUGINS_BLOCKS.'Plugin', |
|
1258 | 1258 | '', $type); |
1259 | 1259 | } |
1260 | 1260 | |
@@ -1332,7 +1332,7 @@ discard block |
||
1332 | 1332 | |
1333 | 1333 | if (is_string($callback) === false) { |
1334 | 1334 | while (($i = array_shift($keys)) !== null) { |
1335 | - $out[] = call_user_func_array($callback, array(1 => $items[$i]) + $params); |
|
1335 | + $out[] = call_user_func_array($callback, array(1 => $items[$i])+$params); |
|
1336 | 1336 | } |
1337 | 1337 | } elseif ($cnt === 1) { |
1338 | 1338 | while (($i = array_shift($keys)) !== null) { |
@@ -1348,7 +1348,7 @@ discard block |
||
1348 | 1348 | } |
1349 | 1349 | } else { |
1350 | 1350 | while (($i = array_shift($keys)) !== null) { |
1351 | - $out[] = call_user_func_array($callback, array(1 => $items[$i]) + $params); |
|
1351 | + $out[] = call_user_func_array($callback, array(1 => $items[$i])+$params); |
|
1352 | 1352 | } |
1353 | 1353 | } |
1354 | 1354 | } else { |
@@ -1357,7 +1357,7 @@ discard block |
||
1357 | 1357 | |
1358 | 1358 | if (is_string($callback) === false) { |
1359 | 1359 | while (($i = array_shift($keys)) !== null) { |
1360 | - $out[] = call_user_func_array($callback, array($items[$i]) + $params); |
|
1360 | + $out[] = call_user_func_array($callback, array($items[$i])+$params); |
|
1361 | 1361 | } |
1362 | 1362 | } elseif ($cnt === 1) { |
1363 | 1363 | while (($i = array_shift($keys)) !== null) { |
@@ -1377,7 +1377,7 @@ discard block |
||
1377 | 1377 | } |
1378 | 1378 | } else { |
1379 | 1379 | while (($i = array_shift($keys)) !== null) { |
1380 | - $out[] = call_user_func_array($callback, array($items[$i]) + $params); |
|
1380 | + $out[] = call_user_func_array($callback, array($items[$i])+$params); |
|
1381 | 1381 | } |
1382 | 1382 | } |
1383 | 1383 | } |
@@ -1447,7 +1447,7 @@ discard block |
||
1447 | 1447 | $tree = $this->scopeTree; |
1448 | 1448 | $cur = $this->data; |
1449 | 1449 | |
1450 | - while ($parentLevels -- !== 0) { |
|
1450 | + while ($parentLevels-- !== 0) { |
|
1451 | 1451 | array_pop($tree); |
1452 | 1452 | } |
1453 | 1453 | |
@@ -1485,7 +1485,7 @@ discard block |
||
1485 | 1485 | } elseif ($varstr === '__' || $varstr === '_root') { |
1486 | 1486 | return $this->data; |
1487 | 1487 | } elseif ($varstr === '_' || $varstr === '_parent') { |
1488 | - $varstr = '.' . $varstr; |
|
1488 | + $varstr = '.'.$varstr; |
|
1489 | 1489 | $tree = $this->scopeTree; |
1490 | 1490 | $cur = $this->data; |
1491 | 1491 | array_pop($tree); |
@@ -1511,7 +1511,7 @@ discard block |
||
1511 | 1511 | } |
1512 | 1512 | |
1513 | 1513 | if (substr($varstr, 0, 1) === '.') { |
1514 | - $varstr = 'dwoo' . $varstr; |
|
1514 | + $varstr = 'dwoo'.$varstr; |
|
1515 | 1515 | } |
1516 | 1516 | |
1517 | 1517 | preg_match_all('#(\[|->|\.)?((?:[^.[\]-]|-(?!>))+)\]?#i', $varstr, $m); |
@@ -1618,7 +1618,7 @@ discard block |
||
1618 | 1618 | public function assignInScope($value, $scope) |
1619 | 1619 | { |
1620 | 1620 | if (!is_string($scope)) { |
1621 | - $this->triggerError('Assignments must be done into strings, (' . gettype($scope) . ') ' . var_export($scope, true) . ' given', E_USER_ERROR); |
|
1621 | + $this->triggerError('Assignments must be done into strings, ('.gettype($scope).') '.var_export($scope, true).' given', E_USER_ERROR); |
|
1622 | 1622 | } |
1623 | 1623 | if (strstr($scope, '.') === false && strstr($scope, '->') === false) { |
1624 | 1624 | $this->scope[$scope] = $value; |
@@ -1769,7 +1769,7 @@ discard block |
||
1769 | 1769 | { |
1770 | 1770 | $proxy = $this->getPluginProxy(); |
1771 | 1771 | if (!$proxy) { |
1772 | - throw new Exception('Call to undefined method ' . __CLASS__ . '::' . $method . '()'); |
|
1772 | + throw new Exception('Call to undefined method '.__CLASS__.'::'.$method.'()'); |
|
1773 | 1773 | } |
1774 | 1774 | |
1775 | 1775 | return call_user_func_array($proxy->getCallback($method), $args); |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | */ |
295 | 295 | public function setNestedCommentsHandling($allow = true) |
296 | 296 | { |
297 | - $this->allowNestedComments = (bool)$allow; |
|
297 | + $this->allowNestedComments = (bool) $allow; |
|
298 | 298 | } |
299 | 299 | |
300 | 300 | /** |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | */ |
320 | 320 | public function setLooseOpeningHandling($allow = false) |
321 | 321 | { |
322 | - $this->allowLooseOpenings = (bool)$allow; |
|
322 | + $this->allowLooseOpenings = (bool) $allow; |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | /** |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | */ |
345 | 345 | public function setAutoEscape($enabled) |
346 | 346 | { |
347 | - $this->autoEscape = (bool)$enabled; |
|
347 | + $this->autoEscape = (bool) $enabled; |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | /** |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | { |
372 | 372 | if ($autoload) { |
373 | 373 | $name = str_replace(Core::NAMESPACE_PLUGINS_PROCESSORS, '', Core::toCamelCase($callback)); |
374 | - $class = Core::NAMESPACE_PLUGINS_PROCESSORS . $name; |
|
374 | + $class = Core::NAMESPACE_PLUGINS_PROCESSORS.$name; |
|
375 | 375 | |
376 | 376 | if (class_exists($class)) { |
377 | 377 | $callback = array(new $class($this), 'process'); |
@@ -396,12 +396,12 @@ discard block |
||
396 | 396 | { |
397 | 397 | if (($index = array_search($callback, $this->processors['pre'], true)) !== false) { |
398 | 398 | unset($this->processors['pre'][$index]); |
399 | - } elseif (($index = array_search(Core::NAMESPACE_PLUGINS_PROCESSORS . str_replace(Core::NAMESPACE_PLUGINS_PROCESSORS, '', |
|
399 | + } elseif (($index = array_search(Core::NAMESPACE_PLUGINS_PROCESSORS.str_replace(Core::NAMESPACE_PLUGINS_PROCESSORS, '', |
|
400 | 400 | $callback), |
401 | 401 | $this->processors['pre'], true)) !== false) { |
402 | 402 | unset($this->processors['pre'][$index]); |
403 | 403 | } else { |
404 | - $class = Core::NAMESPACE_PLUGINS_PROCESSORS . str_replace(Core::NAMESPACE_PLUGINS_PROCESSORS, '', $callback); |
|
404 | + $class = Core::NAMESPACE_PLUGINS_PROCESSORS.str_replace(Core::NAMESPACE_PLUGINS_PROCESSORS, '', $callback); |
|
405 | 405 | foreach ($this->processors['pre'] as $index => $proc) { |
406 | 406 | if (is_array($proc) && ($proc[0] instanceof $class) || (isset($proc['class']) && $proc['class'] == $class)) { |
407 | 407 | unset($this->processors['pre'][$index]); |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | { |
425 | 425 | if ($autoload) { |
426 | 426 | $name = str_replace(Core::NAMESPACE_PLUGINS_PROCESSORS, '', $callback); |
427 | - $class = Core::NAMESPACE_PLUGINS_PROCESSORS . Core::toCamelCase($name); |
|
427 | + $class = Core::NAMESPACE_PLUGINS_PROCESSORS.Core::toCamelCase($name); |
|
428 | 428 | |
429 | 429 | if (class_exists($class)) { |
430 | 430 | $callback = array(new $class($this), 'process'); |
@@ -449,12 +449,12 @@ discard block |
||
449 | 449 | { |
450 | 450 | if (($index = array_search($callback, $this->processors['post'], true)) !== false) { |
451 | 451 | unset($this->processors['post'][$index]); |
452 | - } elseif (($index = array_search(Core::NAMESPACE_PLUGINS_PROCESSORS . str_replace(Core::NAMESPACE_PLUGINS_PROCESSORS, '', |
|
452 | + } elseif (($index = array_search(Core::NAMESPACE_PLUGINS_PROCESSORS.str_replace(Core::NAMESPACE_PLUGINS_PROCESSORS, '', |
|
453 | 453 | $callback), |
454 | 454 | $this->processors['post'], true)) !== false) { |
455 | 455 | unset($this->processors['post'][$index]); |
456 | 456 | } else { |
457 | - $class = Core::NAMESPACE_PLUGINS_PROCESSORS . str_replace(Core::NAMESPACE_PLUGINS_PROCESSORS, '', $callback); |
|
457 | + $class = Core::NAMESPACE_PLUGINS_PROCESSORS.str_replace(Core::NAMESPACE_PLUGINS_PROCESSORS, '', $callback); |
|
458 | 458 | foreach ($this->processors['post'] as $index => $proc) { |
459 | 459 | if (is_array($proc) && ($proc[0] instanceof $class) || (isset($proc['class']) && $proc['class'] == $class)) { |
460 | 460 | unset($this->processors['post'][$index]); |
@@ -480,7 +480,7 @@ discard block |
||
480 | 480 | $this->getCore()->getLoader()->loadPlugin($name); |
481 | 481 | } |
482 | 482 | catch (Exception $e) { |
483 | - throw new Exception('Processor ' . $name . ' could not be found in your plugin directories, please ensure it is in a file named ' . $name . '.php in the plugin directory'); |
|
483 | + throw new Exception('Processor '.$name.' could not be found in your plugin directories, please ensure it is in a file named '.$name.'.php in the plugin directory'); |
|
484 | 484 | } |
485 | 485 | } |
486 | 486 | |
@@ -666,7 +666,7 @@ discard block |
||
666 | 666 | public function setTemplateSource($newSource, $fromPointer = false) |
667 | 667 | { |
668 | 668 | if ($fromPointer === true) { |
669 | - $this->templateSource = substr($this->templateSource, 0, $this->pointer) . $newSource; |
|
669 | + $this->templateSource = substr($this->templateSource, 0, $this->pointer).$newSource; |
|
670 | 670 | } else { |
671 | 671 | $this->templateSource = $newSource; |
672 | 672 | } |
@@ -737,11 +737,11 @@ discard block |
||
737 | 737 | |
738 | 738 | if ($this->debug) { |
739 | 739 | echo "\n"; |
740 | - echo 'COMPILER INIT' . "\n"; |
|
740 | + echo 'COMPILER INIT'."\n"; |
|
741 | 741 | } |
742 | 742 | |
743 | 743 | if ($this->debug) { |
744 | - echo 'PROCESSING PREPROCESSORS (' . count($this->processors['pre']) . ')' . "\n"; |
|
744 | + echo 'PROCESSING PREPROCESSORS ('.count($this->processors['pre']).')'."\n"; |
|
745 | 745 | } |
746 | 746 | |
747 | 747 | // runs preprocessors |
@@ -785,23 +785,23 @@ discard block |
||
785 | 785 | if ($pos === false) { |
786 | 786 | $this->push(substr($tpl, $ptr), 0); |
787 | 787 | break; |
788 | - } elseif (substr($tpl, $pos - 1, 1) === '\\' && substr($tpl, $pos - 2, 1) !== '\\') { |
|
789 | - $this->push(substr($tpl, $ptr, $pos - $ptr - 1) . $this->ld); |
|
790 | - $ptr = $pos + strlen($this->ld); |
|
791 | - } elseif (preg_match('/^' . $this->ldr . ($this->allowLooseOpenings ? '\s*' : '') . 'literal' . ($this->allowLooseOpenings ? '\s*' : '') . $this->rdr . '/s', substr($tpl, $pos), $litOpen)) { |
|
792 | - if (!preg_match('/' . $this->ldr . ($this->allowLooseOpenings ? '\s*' : '') . '\/literal' . ($this->allowLooseOpenings ? '\s*' : '') . $this->rdr . '/s', $tpl, $litClose, PREG_OFFSET_CAPTURE, $pos)) { |
|
788 | + } elseif (substr($tpl, $pos-1, 1) === '\\' && substr($tpl, $pos-2, 1) !== '\\') { |
|
789 | + $this->push(substr($tpl, $ptr, $pos-$ptr-1).$this->ld); |
|
790 | + $ptr = $pos+strlen($this->ld); |
|
791 | + } elseif (preg_match('/^'.$this->ldr.($this->allowLooseOpenings ? '\s*' : '').'literal'.($this->allowLooseOpenings ? '\s*' : '').$this->rdr.'/s', substr($tpl, $pos), $litOpen)) { |
|
792 | + if (!preg_match('/'.$this->ldr.($this->allowLooseOpenings ? '\s*' : '').'\/literal'.($this->allowLooseOpenings ? '\s*' : '').$this->rdr.'/s', $tpl, $litClose, PREG_OFFSET_CAPTURE, $pos)) { |
|
793 | 793 | throw new CompilationException($this, 'The {literal} blocks must be closed explicitly with {/literal}'); |
794 | 794 | } |
795 | 795 | $endpos = $litClose[0][1]; |
796 | - $this->push(substr($tpl, $ptr, $pos - $ptr) . substr($tpl, $pos + strlen($litOpen[0]), $endpos - $pos - strlen($litOpen[0]))); |
|
797 | - $ptr = $endpos + strlen($litClose[0][0]); |
|
796 | + $this->push(substr($tpl, $ptr, $pos-$ptr).substr($tpl, $pos+strlen($litOpen[0]), $endpos-$pos-strlen($litOpen[0]))); |
|
797 | + $ptr = $endpos+strlen($litClose[0][0]); |
|
798 | 798 | } else { |
799 | - if (substr($tpl, $pos - 2, 1) === '\\' && substr($tpl, $pos - 1, 1) === '\\') { |
|
800 | - $this->push(substr($tpl, $ptr, $pos - $ptr - 1)); |
|
799 | + if (substr($tpl, $pos-2, 1) === '\\' && substr($tpl, $pos-1, 1) === '\\') { |
|
800 | + $this->push(substr($tpl, $ptr, $pos-$ptr-1)); |
|
801 | 801 | $ptr = $pos; |
802 | 802 | } |
803 | 803 | |
804 | - $this->push(substr($tpl, $ptr, $pos - $ptr)); |
|
804 | + $this->push(substr($tpl, $ptr, $pos-$ptr)); |
|
805 | 805 | $ptr = $pos; |
806 | 806 | |
807 | 807 | $pos += strlen($this->ld); |
@@ -819,7 +819,7 @@ discard block |
||
819 | 819 | |
820 | 820 | // check that there is an end tag present |
821 | 821 | if (strpos($tpl, $this->rd, $pos) === false) { |
822 | - throw new CompilationException($this, 'A template tag was not closed, started with "' . substr($tpl, $ptr, 30) . '"'); |
|
822 | + throw new CompilationException($this, 'A template tag was not closed, started with "'.substr($tpl, $ptr, 30).'"'); |
|
823 | 823 | } |
824 | 824 | |
825 | 825 | $ptr += strlen($this->ld); |
@@ -833,7 +833,7 @@ discard block |
||
833 | 833 | continue 2; |
834 | 834 | } |
835 | 835 | |
836 | - $len = $subptr - $ptr; |
|
836 | + $len = $subptr-$ptr; |
|
837 | 837 | $this->push($parsed, substr_count(substr($tpl, $ptr, $len), "\n")); |
838 | 838 | $ptr += $len; |
839 | 839 | |
@@ -847,7 +847,7 @@ discard block |
||
847 | 847 | $compiled .= $this->removeBlock('TopLevelBlock'); |
848 | 848 | |
849 | 849 | if ($this->debug) { |
850 | - echo 'PROCESSING POSTPROCESSORS' . "\n"; |
|
850 | + echo 'PROCESSING POSTPROCESSORS'."\n"; |
|
851 | 851 | } |
852 | 852 | |
853 | 853 | foreach ($this->processors['post'] as $postProc) { |
@@ -863,7 +863,7 @@ discard block |
||
863 | 863 | unset($postProc); |
864 | 864 | |
865 | 865 | if ($this->debug) { |
866 | - echo 'COMPILATION COMPLETE : MEM USAGE : ' . memory_get_usage() . "\n"; |
|
866 | + echo 'COMPILATION COMPLETE : MEM USAGE : '.memory_get_usage()."\n"; |
|
867 | 867 | } |
868 | 868 | |
869 | 869 | $output = "<?php\n/* template head */\n"; |
@@ -876,30 +876,30 @@ discard block |
||
876 | 876 | |
877 | 877 | switch ($type) { |
878 | 878 | case Core::CLASS_PLUGIN: |
879 | - case Core::CLASS_PLUGIN + Core::BLOCK_PLUGIN: |
|
880 | - if (class_exists('Plugin' . $plugin) !== false) { |
|
881 | - $output .= "if (class_exists('" . "Plugin" . $plugin . "')===false)". |
|
879 | + case Core::CLASS_PLUGIN+Core::BLOCK_PLUGIN: |
|
880 | + if (class_exists('Plugin'.$plugin) !== false) { |
|
881 | + $output .= "if (class_exists('"."Plugin".$plugin."')===false)". |
|
882 | 882 | "\n\t\$this->getLoader()->loadPlugin('Plugin$plugin');\n"; |
883 | 883 | } else { |
884 | - $output .= "if (class_exists('" . Core::NAMESPACE_PLUGINS_BLOCKS . "Plugin" . $plugin . "')===false)". |
|
884 | + $output .= "if (class_exists('".Core::NAMESPACE_PLUGINS_BLOCKS."Plugin".$plugin."')===false)". |
|
885 | 885 | "\n\t\$this->getLoader()->loadPlugin('Plugin$plugin');\n"; |
886 | 886 | } |
887 | 887 | break; |
888 | - case Core::CLASS_PLUGIN + Core::FUNC_PLUGIN: |
|
889 | - if (class_exists('Plugin' . $plugin) !== false) { |
|
890 | - $output .= "if (class_exists('" . "Plugin" . $plugin . "')===false)". |
|
888 | + case Core::CLASS_PLUGIN+Core::FUNC_PLUGIN: |
|
889 | + if (class_exists('Plugin'.$plugin) !== false) { |
|
890 | + $output .= "if (class_exists('"."Plugin".$plugin."')===false)". |
|
891 | 891 | "\n\t\$this->getLoader()->loadPlugin('Plugin$plugin');\n"; |
892 | 892 | } else { |
893 | - $output .= "if (class_exists('" . Core::NAMESPACE_PLUGINS_FUNCTIONS . "Plugin" . $plugin . "')===false)". |
|
893 | + $output .= "if (class_exists('".Core::NAMESPACE_PLUGINS_FUNCTIONS."Plugin".$plugin."')===false)". |
|
894 | 894 | "\n\t\$this->getLoader()->loadPlugin('Plugin$plugin');\n"; |
895 | 895 | } |
896 | 896 | break; |
897 | 897 | case Core::FUNC_PLUGIN: |
898 | - if (function_exists('Plugin' . $plugin) !== false) { |
|
899 | - $output .= "if (function_exists('" . "Plugin" . $plugin . "')===false)". |
|
898 | + if (function_exists('Plugin'.$plugin) !== false) { |
|
899 | + $output .= "if (function_exists('"."Plugin".$plugin."')===false)". |
|
900 | 900 | "\n\t\$this->getLoader()->loadPlugin('Plugin$plugin');\n"; |
901 | 901 | } else { |
902 | - $output .= "if (function_exists('" . Core::NAMESPACE_PLUGINS_FUNCTIONS . "Plugin" . $plugin . "')===false)". |
|
902 | + $output .= "if (function_exists('".Core::NAMESPACE_PLUGINS_FUNCTIONS."Plugin".$plugin."')===false)". |
|
903 | 903 | "\n\t\$this->getLoader()->loadPlugin('Plugin$plugin');\n"; |
904 | 904 | } |
905 | 905 | break; |
@@ -919,7 +919,7 @@ discard block |
||
919 | 919 | $output .= $this->getCore()->getPluginProxy()->getLoader($plugin); |
920 | 920 | break; |
921 | 921 | default: |
922 | - throw new CompilationException($this, 'Type error for ' . $plugin . ' with type' . $type); |
|
922 | + throw new CompilationException($this, 'Type error for '.$plugin.' with type'.$type); |
|
923 | 923 | } |
924 | 924 | } |
925 | 925 | |
@@ -930,30 +930,30 @@ discard block |
||
930 | 930 | } |
931 | 931 | foreach ($this->templatePlugins as $function) { |
932 | 932 | if (isset($function['called']) && $function['called'] === true) { |
933 | - $output .= $function['body'] . PHP_EOL; |
|
933 | + $output .= $function['body'].PHP_EOL; |
|
934 | 934 | } |
935 | 935 | } |
936 | 936 | |
937 | - $output .= $compiled . "\n?>"; |
|
937 | + $output .= $compiled."\n?>"; |
|
938 | 938 | |
939 | - $output = preg_replace('/(?<!;|\}|\*\/|\n|\{)(\s*' . preg_quote(self::PHP_CLOSE, '/') . preg_quote(self::PHP_OPEN, '/') . ')/', ";\n", $output); |
|
940 | - $output = str_replace(self::PHP_CLOSE . self::PHP_OPEN, "\n", $output); |
|
939 | + $output = preg_replace('/(?<!;|\}|\*\/|\n|\{)(\s*'.preg_quote(self::PHP_CLOSE, '/').preg_quote(self::PHP_OPEN, '/').')/', ";\n", $output); |
|
940 | + $output = str_replace(self::PHP_CLOSE.self::PHP_OPEN, "\n", $output); |
|
941 | 941 | |
942 | 942 | // handle <?xml tag at the beginning |
943 | 943 | $output = preg_replace('#(/\* template body \*/ \?>\s*)<\?xml#is', '$1<?php echo \'<?xml\'; ?>', $output); |
944 | 944 | |
945 | 945 | // add another line break after PHP closing tags that have a line break following, |
946 | 946 | // as we do not know whether it's intended, and PHP will strip it otherwise |
947 | - $output = preg_replace('/(?<!"|<\?xml)\s*\?>\n/', '$0' . "\n", $output); |
|
947 | + $output = preg_replace('/(?<!"|<\?xml)\s*\?>\n/', '$0'."\n", $output); |
|
948 | 948 | |
949 | 949 | if ($this->debug) { |
950 | - echo '=============================================================================================' . "\n"; |
|
950 | + echo '============================================================================================='."\n"; |
|
951 | 951 | $lines = preg_split('{\r\n|\n|<br />}', $output); |
952 | 952 | array_shift($lines); |
953 | 953 | foreach ($lines as $i => $line) { |
954 | - echo ($i + 1) . '. ' . $line . "\r\n"; |
|
954 | + echo ($i+1).'. '.$line."\r\n"; |
|
955 | 955 | } |
956 | - echo '=============================================================================================' . "\n"; |
|
956 | + echo '============================================================================================='."\n"; |
|
957 | 957 | } |
958 | 958 | |
959 | 959 | $this->template = $this->dwoo = null; |
@@ -970,13 +970,13 @@ discard block |
||
970 | 970 | protected function resolveSubTemplateDependencies($function) |
971 | 971 | { |
972 | 972 | if ($this->debug) { |
973 | - echo 'Compiler::' . __FUNCTION__ . "\n"; |
|
973 | + echo 'Compiler::'.__FUNCTION__."\n"; |
|
974 | 974 | } |
975 | 975 | |
976 | 976 | $body = $this->templatePlugins[$function]['body']; |
977 | 977 | foreach ($this->templatePlugins as $func => $attr) { |
978 | - if ($func !== $function && !isset($attr['called']) && strpos($body, Core::NAMESPACE_PLUGINS_FUNCTIONS . |
|
979 | - 'Plugin' . Core::toCamelCase($func)) !== false) { |
|
978 | + if ($func !== $function && !isset($attr['called']) && strpos($body, Core::NAMESPACE_PLUGINS_FUNCTIONS. |
|
979 | + 'Plugin'.Core::toCamelCase($func)) !== false) { |
|
980 | 980 | $this->templatePlugins[$func]['called'] = true; |
981 | 981 | $this->resolveSubTemplateDependencies($func); |
982 | 982 | } |
@@ -1000,14 +1000,14 @@ discard block |
||
1000 | 1000 | |
1001 | 1001 | if ($this->curBlock['buffer'] === null && count($this->stack) > 1) { |
1002 | 1002 | // buffer is not initialized yet (the block has just been created) |
1003 | - $this->stack[count($this->stack) - 2]['buffer'] .= (string)$content; |
|
1003 | + $this->stack[count($this->stack)-2]['buffer'] .= (string) $content; |
|
1004 | 1004 | $this->curBlock['buffer'] = ''; |
1005 | 1005 | } else { |
1006 | 1006 | if (!isset($this->curBlock['buffer'])) { |
1007 | 1007 | throw new CompilationException($this, 'The template has been closed too early, you probably have an extra block-closing tag somewhere'); |
1008 | 1008 | } |
1009 | 1009 | // append current content to current block's buffer |
1010 | - $this->curBlock['buffer'] .= (string)$content; |
|
1010 | + $this->curBlock['buffer'] .= (string) $content; |
|
1011 | 1011 | } |
1012 | 1012 | $this->line += $lineCount; |
1013 | 1013 | } |
@@ -1077,23 +1077,23 @@ discard block |
||
1077 | 1077 | public function addBlock($type, array $params, $paramtype) |
1078 | 1078 | { |
1079 | 1079 | if ($this->debug) { |
1080 | - echo 'Compiler::' . __FUNCTION__ . "\n"; |
|
1080 | + echo 'Compiler::'.__FUNCTION__."\n"; |
|
1081 | 1081 | } |
1082 | 1082 | |
1083 | - $class = Core::NAMESPACE_PLUGINS_BLOCKS . 'Plugin' . Core::toCamelCase($type); |
|
1083 | + $class = Core::NAMESPACE_PLUGINS_BLOCKS.'Plugin'.Core::toCamelCase($type); |
|
1084 | 1084 | if (class_exists($class) === false) { |
1085 | 1085 | $this->getCore()->getLoader()->loadPlugin($type); |
1086 | 1086 | } |
1087 | 1087 | $params = $this->mapParams($params, array($class, 'init'), $paramtype); |
1088 | 1088 | |
1089 | - $this->stack[] = array( |
|
1089 | + $this->stack[] = array( |
|
1090 | 1090 | 'type' => $type, |
1091 | 1091 | 'params' => $params, |
1092 | 1092 | 'custom' => false, |
1093 | 1093 | 'class' => $class, |
1094 | 1094 | 'buffer' => null |
1095 | 1095 | ); |
1096 | - $this->curBlock = &$this->stack[count($this->stack) - 1]; |
|
1096 | + $this->curBlock = &$this->stack[count($this->stack)-1]; |
|
1097 | 1097 | |
1098 | 1098 | return call_user_func(array($class, 'preProcessing'), $this, $params, '', '', $type); |
1099 | 1099 | } |
@@ -1118,14 +1118,14 @@ discard block |
||
1118 | 1118 | |
1119 | 1119 | $params = $this->mapParams($params, array($class, 'init'), $paramtype); |
1120 | 1120 | |
1121 | - $this->stack[] = array( |
|
1121 | + $this->stack[] = array( |
|
1122 | 1122 | 'type' => $type, |
1123 | 1123 | 'params' => $params, |
1124 | 1124 | 'custom' => true, |
1125 | 1125 | 'class' => $class, |
1126 | 1126 | 'buffer' => null |
1127 | 1127 | ); |
1128 | - $this->curBlock = &$this->stack[count($this->stack) - 1]; |
|
1128 | + $this->curBlock = &$this->stack[count($this->stack)-1]; |
|
1129 | 1129 | |
1130 | 1130 | return call_user_func(array($class, 'preProcessing'), $this, $params, '', '', $type); |
1131 | 1131 | } |
@@ -1140,21 +1140,21 @@ discard block |
||
1140 | 1140 | public function injectBlock($type, array $params) |
1141 | 1141 | { |
1142 | 1142 | if ($this->debug) { |
1143 | - echo 'Compiler::' . __FUNCTION__ . "\n"; |
|
1143 | + echo 'Compiler::'.__FUNCTION__."\n"; |
|
1144 | 1144 | } |
1145 | 1145 | |
1146 | - $class = Core::NAMESPACE_PLUGINS_BLOCKS . 'Plugin' . Core::toCamelCase($type); |
|
1146 | + $class = Core::NAMESPACE_PLUGINS_BLOCKS.'Plugin'.Core::toCamelCase($type); |
|
1147 | 1147 | if (class_exists($class) === false) { |
1148 | 1148 | $this->getCore()->getLoader()->loadPlugin($type); |
1149 | 1149 | } |
1150 | - $this->stack[] = array( |
|
1150 | + $this->stack[] = array( |
|
1151 | 1151 | 'type' => $type, |
1152 | 1152 | 'params' => $params, |
1153 | 1153 | 'custom' => false, |
1154 | 1154 | 'class' => $class, |
1155 | 1155 | 'buffer' => null |
1156 | 1156 | ); |
1157 | - $this->curBlock = &$this->stack[count($this->stack) - 1]; |
|
1157 | + $this->curBlock = &$this->stack[count($this->stack)-1]; |
|
1158 | 1158 | } |
1159 | 1159 | |
1160 | 1160 | /** |
@@ -1169,7 +1169,7 @@ discard block |
||
1169 | 1169 | public function removeBlock($type) |
1170 | 1170 | { |
1171 | 1171 | if ($this->debug) { |
1172 | - echo 'Compiler::' . __FUNCTION__ . "\n"; |
|
1172 | + echo 'Compiler::'.__FUNCTION__."\n"; |
|
1173 | 1173 | } |
1174 | 1174 | |
1175 | 1175 | $output = ''; |
@@ -1183,10 +1183,10 @@ discard block |
||
1183 | 1183 | if ($top['custom']) { |
1184 | 1184 | $class = $top['class']; |
1185 | 1185 | } else { |
1186 | - $class = Core::NAMESPACE_PLUGINS_BLOCKS . 'Plugin' . Core::toCamelCase($top['type']); |
|
1186 | + $class = Core::NAMESPACE_PLUGINS_BLOCKS.'Plugin'.Core::toCamelCase($top['type']); |
|
1187 | 1187 | } |
1188 | 1188 | if (count($this->stack)) { |
1189 | - $this->curBlock = &$this->stack[count($this->stack) - 1]; |
|
1189 | + $this->curBlock = &$this->stack[count($this->stack)-1]; |
|
1190 | 1190 | $this->push(call_user_func(array( |
1191 | 1191 | $class, |
1192 | 1192 | 'postProcessing' |
@@ -1207,7 +1207,7 @@ discard block |
||
1207 | 1207 | } |
1208 | 1208 | } |
1209 | 1209 | |
1210 | - throw new CompilationException($this, 'Syntax malformation, a block of type "' . $type . '" was closed but was not opened'); |
|
1210 | + throw new CompilationException($this, 'Syntax malformation, a block of type "'.$type.'" was closed but was not opened'); |
|
1211 | 1211 | } |
1212 | 1212 | |
1213 | 1213 | return $output; |
@@ -1245,7 +1245,7 @@ discard block |
||
1245 | 1245 | } |
1246 | 1246 | } |
1247 | 1247 | |
1248 | - throw new CompilationException($this, 'A parent block of type "' . $type . '" is required and can not be found'); |
|
1248 | + throw new CompilationException($this, 'A parent block of type "'.$type.'" is required and can not be found'); |
|
1249 | 1249 | } |
1250 | 1250 | |
1251 | 1251 | /** |
@@ -1268,7 +1268,7 @@ discard block |
||
1268 | 1268 | public function removeTopBlock() |
1269 | 1269 | { |
1270 | 1270 | if ($this->debug) { |
1271 | - echo 'Compiler::' . __FUNCTION__ . "\n"; |
|
1271 | + echo 'Compiler::'.__FUNCTION__."\n"; |
|
1272 | 1272 | } |
1273 | 1273 | |
1274 | 1274 | $o = array_pop($this->stack); |
@@ -1278,10 +1278,10 @@ discard block |
||
1278 | 1278 | if ($o['custom']) { |
1279 | 1279 | $class = $o['class']; |
1280 | 1280 | } else { |
1281 | - $class = Core::NAMESPACE_PLUGINS_BLOCKS . 'Plugin' . Core::toCamelCase($o['type']); |
|
1281 | + $class = Core::NAMESPACE_PLUGINS_BLOCKS.'Plugin'.Core::toCamelCase($o['type']); |
|
1282 | 1282 | } |
1283 | 1283 | |
1284 | - $this->curBlock = &$this->stack[count($this->stack) - 1]; |
|
1284 | + $this->curBlock = &$this->stack[count($this->stack)-1]; |
|
1285 | 1285 | |
1286 | 1286 | return call_user_func(array($class, 'postProcessing'), $this, $o['params'], '', '', $o['buffer']); |
1287 | 1287 | } |
@@ -1360,7 +1360,7 @@ discard block |
||
1360 | 1360 | protected function parse($in, $from, $to, $parsingParams = false, $curBlock = '', &$pointer = null) |
1361 | 1361 | { |
1362 | 1362 | if ($this->debug) { |
1363 | - echo 'Compiler::' . __FUNCTION__ . "\n"; |
|
1363 | + echo 'Compiler::'.__FUNCTION__."\n"; |
|
1364 | 1364 | } |
1365 | 1365 | |
1366 | 1366 | if ($to === null) { |
@@ -1377,14 +1377,14 @@ discard block |
||
1377 | 1377 | // end template tag |
1378 | 1378 | $pointer += strlen($this->rd); |
1379 | 1379 | if ($this->debug) { |
1380 | - echo 'TEMPLATE PARSING ENDED' . "\n"; |
|
1380 | + echo 'TEMPLATE PARSING ENDED'."\n"; |
|
1381 | 1381 | } |
1382 | 1382 | |
1383 | 1383 | return false; |
1384 | 1384 | } |
1385 | - ++ $from; |
|
1385 | + ++$from; |
|
1386 | 1386 | if ($pointer !== null) { |
1387 | - ++ $pointer; |
|
1387 | + ++$pointer; |
|
1388 | 1388 | } |
1389 | 1389 | if ($from >= $to) { |
1390 | 1390 | if (is_array($parsingParams)) { |
@@ -1396,22 +1396,22 @@ discard block |
||
1396 | 1396 | $first = $in[$from]; |
1397 | 1397 | } |
1398 | 1398 | |
1399 | - $substr = substr($in, $from, $to - $from); |
|
1399 | + $substr = substr($in, $from, $to-$from); |
|
1400 | 1400 | |
1401 | 1401 | if ($this->debug) { |
1402 | - echo 'PARSE CALL : PARSING "' . htmlentities(substr($in, $from, min($to - $from, 50))) . (($to - $from) > 50 ? '...' : '') . '" @ ' . $from . ':' . $to . ' in ' . $curBlock . ' : pointer=' . $pointer . "\n"; |
|
1402 | + echo 'PARSE CALL : PARSING "'.htmlentities(substr($in, $from, min($to-$from, 50))).(($to-$from) > 50 ? '...' : '').'" @ '.$from.':'.$to.' in '.$curBlock.' : pointer='.$pointer."\n"; |
|
1403 | 1403 | } |
1404 | 1404 | $parsed = ''; |
1405 | 1405 | |
1406 | 1406 | if ($curBlock === 'root' && $first === '*') { |
1407 | 1407 | $src = $this->getTemplateSource(); |
1408 | - $startpos = $this->getPointer() - strlen($this->ld); |
|
1408 | + $startpos = $this->getPointer()-strlen($this->ld); |
|
1409 | 1409 | if (substr($src, $startpos, strlen($this->ld)) === $this->ld) { |
1410 | 1410 | if ($startpos > 0) { |
1411 | 1411 | do { |
1412 | 1412 | $char = substr($src, -- $startpos, 1); |
1413 | 1413 | if ($char == "\n") { |
1414 | - ++ $startpos; |
|
1414 | + ++$startpos; |
|
1415 | 1415 | $whitespaceStart = true; |
1416 | 1416 | break; |
1417 | 1417 | } |
@@ -1422,12 +1422,12 @@ discard block |
||
1422 | 1422 | if (!isset($whitespaceStart)) { |
1423 | 1423 | $startpos = $this->getPointer(); |
1424 | 1424 | } else { |
1425 | - $pointer -= $this->getPointer() - $startpos; |
|
1425 | + $pointer -= $this->getPointer()-$startpos; |
|
1426 | 1426 | } |
1427 | 1427 | |
1428 | - if ($this->allowNestedComments && strpos($src, $this->ld . '*', $this->getPointer()) !== false) { |
|
1429 | - $comOpen = $this->ld . '*'; |
|
1430 | - $comClose = '*' . $this->rd; |
|
1428 | + if ($this->allowNestedComments && strpos($src, $this->ld.'*', $this->getPointer()) !== false) { |
|
1429 | + $comOpen = $this->ld.'*'; |
|
1430 | + $comClose = '*'.$this->rd; |
|
1431 | 1431 | $level = 1; |
1432 | 1432 | $ptr = $this->getPointer(); |
1433 | 1433 | |
@@ -1437,33 +1437,33 @@ discard block |
||
1437 | 1437 | |
1438 | 1438 | if ($open !== false && $close !== false) { |
1439 | 1439 | if ($open < $close) { |
1440 | - $ptr = $open + strlen($comOpen); |
|
1441 | - ++ $level; |
|
1440 | + $ptr = $open+strlen($comOpen); |
|
1441 | + ++$level; |
|
1442 | 1442 | } else { |
1443 | - $ptr = $close + strlen($comClose); |
|
1444 | - -- $level; |
|
1443 | + $ptr = $close+strlen($comClose); |
|
1444 | + --$level; |
|
1445 | 1445 | } |
1446 | 1446 | } elseif ($open !== false) { |
1447 | - $ptr = $open + strlen($comOpen); |
|
1448 | - ++ $level; |
|
1447 | + $ptr = $open+strlen($comOpen); |
|
1448 | + ++$level; |
|
1449 | 1449 | } elseif ($close !== false) { |
1450 | - $ptr = $close + strlen($comClose); |
|
1451 | - -- $level; |
|
1450 | + $ptr = $close+strlen($comClose); |
|
1451 | + --$level; |
|
1452 | 1452 | } else { |
1453 | 1453 | $ptr = strlen($src); |
1454 | 1454 | } |
1455 | 1455 | } |
1456 | - $endpos = $ptr - strlen('*' . $this->rd); |
|
1456 | + $endpos = $ptr-strlen('*'.$this->rd); |
|
1457 | 1457 | } else { |
1458 | - $endpos = strpos($src, '*' . $this->rd, $startpos); |
|
1458 | + $endpos = strpos($src, '*'.$this->rd, $startpos); |
|
1459 | 1459 | if ($endpos == false) { |
1460 | 1460 | throw new CompilationException($this, 'Un-ended comment'); |
1461 | 1461 | } |
1462 | 1462 | } |
1463 | - $pointer += $endpos - $startpos + strlen('*' . $this->rd); |
|
1464 | - if (isset($whitespaceStart) && preg_match('#^[\t ]*\r?\n#', substr($src, $endpos + strlen('*' . $this->rd)), $m)) { |
|
1463 | + $pointer += $endpos-$startpos+strlen('*'.$this->rd); |
|
1464 | + if (isset($whitespaceStart) && preg_match('#^[\t ]*\r?\n#', substr($src, $endpos+strlen('*'.$this->rd)), $m)) { |
|
1465 | 1465 | $pointer += strlen($m[0]); |
1466 | - $this->curBlock['buffer'] = substr($this->curBlock['buffer'], 0, strlen($this->curBlock['buffer']) - ($this->getPointer() - $startpos - strlen($this->ld))); |
|
1466 | + $this->curBlock['buffer'] = substr($this->curBlock['buffer'], 0, strlen($this->curBlock['buffer'])-($this->getPointer()-$startpos-strlen($this->ld))); |
|
1467 | 1467 | } |
1468 | 1468 | |
1469 | 1469 | return false; |
@@ -1480,20 +1480,20 @@ discard block |
||
1480 | 1480 | } elseif (($first === '"' || $first === "'") && !(is_array($parsingParams) && preg_match('#^([\'"])[a-z0-9_]+\1\s*=>?(?:\s+|[^=])#i', $substr))) { |
1481 | 1481 | // string |
1482 | 1482 | $out = $this->parseString($in, $from, $to, $parsingParams, $curBlock, $pointer); |
1483 | - } elseif (preg_match('/^\\\\?[a-z_](?:\\\\?[a-z0-9_]+)*(?:::[a-z_][a-z0-9_]*)?(' . (is_array($parsingParams) || $curBlock != 'root' ? '' : '\s+[^(]|') . '\s*\(|\s*' . $this->rdr . '|\s*;)/i', $substr)) { |
|
1483 | + } elseif (preg_match('/^\\\\?[a-z_](?:\\\\?[a-z0-9_]+)*(?:::[a-z_][a-z0-9_]*)?('.(is_array($parsingParams) || $curBlock != 'root' ? '' : '\s+[^(]|').'\s*\(|\s*'.$this->rdr.'|\s*;)/i', $substr)) { |
|
1484 | 1484 | // func |
1485 | 1485 | $out = $this->parseFunction($in, $from, $to, $parsingParams, $curBlock, $pointer); |
1486 | 1486 | $parsed = 'func'; |
1487 | 1487 | } elseif ($first === ';') { |
1488 | 1488 | // instruction end |
1489 | 1489 | if ($this->debug) { |
1490 | - echo 'END OF INSTRUCTION' . "\n"; |
|
1490 | + echo 'END OF INSTRUCTION'."\n"; |
|
1491 | 1491 | } |
1492 | 1492 | if ($pointer !== null) { |
1493 | - ++ $pointer; |
|
1493 | + ++$pointer; |
|
1494 | 1494 | } |
1495 | 1495 | |
1496 | - return $this->parse($in, $from + 1, $to, false, 'root', $pointer); |
|
1496 | + return $this->parse($in, $from+1, $to, false, 'root', $pointer); |
|
1497 | 1497 | } elseif ($curBlock === 'root' && preg_match('#^/([a-z_][a-z0-9_]*)?#i', $substr, $match)) { |
1498 | 1498 | // close block |
1499 | 1499 | if (!empty($match[1]) && $match[1] == 'else') { |
@@ -1510,13 +1510,13 @@ discard block |
||
1510 | 1510 | $pointer -= strlen($match[0]); |
1511 | 1511 | } |
1512 | 1512 | if ($this->debug) { |
1513 | - echo 'TOP BLOCK CLOSED' . "\n"; |
|
1513 | + echo 'TOP BLOCK CLOSED'."\n"; |
|
1514 | 1514 | } |
1515 | 1515 | |
1516 | 1516 | return $this->removeTopBlock(); |
1517 | 1517 | } else { |
1518 | 1518 | if ($this->debug) { |
1519 | - echo 'BLOCK OF TYPE ' . $match[1] . ' CLOSED' . "\n"; |
|
1519 | + echo 'BLOCK OF TYPE '.$match[1].' CLOSED'."\n"; |
|
1520 | 1520 | } |
1521 | 1521 | |
1522 | 1522 | return $this->removeBlock($match[1]); |
@@ -1524,19 +1524,19 @@ discard block |
||
1524 | 1524 | } elseif ($curBlock === 'root' && substr($substr, 0, strlen($this->rd)) === $this->rd) { |
1525 | 1525 | // end template tag |
1526 | 1526 | if ($this->debug) { |
1527 | - echo 'TAG PARSING ENDED' . "\n"; |
|
1527 | + echo 'TAG PARSING ENDED'."\n"; |
|
1528 | 1528 | } |
1529 | 1529 | $pointer += strlen($this->rd); |
1530 | 1530 | |
1531 | 1531 | return false; |
1532 | - } elseif (is_array($parsingParams) && preg_match('#^(([\'"]?)[a-z0-9_]+\2\s*=' . ($curBlock === 'array' ? '>?' : '') . ')(?:\s+|[^=]).*#i', $substr, $match)) { |
|
1532 | + } elseif (is_array($parsingParams) && preg_match('#^(([\'"]?)[a-z0-9_]+\2\s*='.($curBlock === 'array' ? '>?' : '').')(?:\s+|[^=]).*#i', $substr, $match)) { |
|
1533 | 1533 | // named parameter |
1534 | 1534 | if ($this->debug) { |
1535 | - echo 'NAMED PARAM FOUND' . "\n"; |
|
1535 | + echo 'NAMED PARAM FOUND'."\n"; |
|
1536 | 1536 | } |
1537 | 1537 | $len = strlen($match[1]); |
1538 | - while (substr($in, $from + $len, 1) === ' ') { |
|
1539 | - ++ $len; |
|
1538 | + while (substr($in, $from+$len, 1) === ' ') { |
|
1539 | + ++$len; |
|
1540 | 1540 | } |
1541 | 1541 | if ($pointer !== null) { |
1542 | 1542 | $pointer += $len; |
@@ -1544,7 +1544,7 @@ discard block |
||
1544 | 1544 | |
1545 | 1545 | $output = array( |
1546 | 1546 | trim($match[1], " \t\r\n=>'\""), |
1547 | - $this->parse($in, $from + $len, $to, false, 'namedparam', $pointer) |
|
1547 | + $this->parse($in, $from+$len, $to, false, 'namedparam', $pointer) |
|
1548 | 1548 | ); |
1549 | 1549 | |
1550 | 1550 | $parsingParams[] = $output; |
@@ -1565,31 +1565,31 @@ discard block |
||
1565 | 1565 | $out = $this->parseOthers($in, $from, $to, $parsingParams, $curBlock, $pointer); |
1566 | 1566 | } else { |
1567 | 1567 | // parse error |
1568 | - throw new CompilationException($this, 'Parse error in "' . substr($in, $from, $to - $from) . '"'); |
|
1568 | + throw new CompilationException($this, 'Parse error in "'.substr($in, $from, $to-$from).'"'); |
|
1569 | 1569 | } |
1570 | 1570 | |
1571 | 1571 | if (empty($out)) { |
1572 | 1572 | return ''; |
1573 | 1573 | } |
1574 | 1574 | |
1575 | - $substr = substr($in, $pointer, $to - $pointer); |
|
1575 | + $substr = substr($in, $pointer, $to-$pointer); |
|
1576 | 1576 | |
1577 | 1577 | // var parsed, check if any var-extension applies |
1578 | 1578 | if ($parsed === 'var') { |
1579 | 1579 | if (preg_match('#^\s*([/%+*-])\s*([a-z0-9]|\$)#i', $substr, $match)) { |
1580 | 1580 | if ($this->debug) { |
1581 | - echo 'PARSING POST-VAR EXPRESSION ' . $substr . "\n"; |
|
1581 | + echo 'PARSING POST-VAR EXPRESSION '.$substr."\n"; |
|
1582 | 1582 | } |
1583 | 1583 | // parse expressions |
1584 | - $pointer += strlen($match[0]) - 1; |
|
1584 | + $pointer += strlen($match[0])-1; |
|
1585 | 1585 | if (is_array($parsingParams)) { |
1586 | 1586 | if ($match[2] == '$') { |
1587 | 1587 | $expr = $this->parseVar($in, $pointer, $to, array(), $curBlock, $pointer); |
1588 | 1588 | } else { |
1589 | 1589 | $expr = $this->parse($in, $pointer, $to, array(), 'expression', $pointer); |
1590 | 1590 | } |
1591 | - $out[count($out) - 1][0] .= $match[1] . $expr[0][0]; |
|
1592 | - $out[count($out) - 1][1] .= $match[1] . $expr[0][1]; |
|
1591 | + $out[count($out)-1][0] .= $match[1].$expr[0][0]; |
|
1592 | + $out[count($out)-1][1] .= $match[1].$expr[0][1]; |
|
1593 | 1593 | } else { |
1594 | 1594 | if ($match[2] == '$') { |
1595 | 1595 | $expr = $this->parseVar($in, $pointer, $to, false, $curBlock, $pointer); |
@@ -1597,26 +1597,26 @@ discard block |
||
1597 | 1597 | $expr = $this->parse($in, $pointer, $to, false, 'expression', $pointer); |
1598 | 1598 | } |
1599 | 1599 | if (is_array($out) && is_array($expr)) { |
1600 | - $out[0] .= $match[1] . $expr[0]; |
|
1601 | - $out[1] .= $match[1] . $expr[1]; |
|
1600 | + $out[0] .= $match[1].$expr[0]; |
|
1601 | + $out[1] .= $match[1].$expr[1]; |
|
1602 | 1602 | } elseif (is_array($out)) { |
1603 | - $out[0] .= $match[1] . $expr; |
|
1604 | - $out[1] .= $match[1] . $expr; |
|
1603 | + $out[0] .= $match[1].$expr; |
|
1604 | + $out[1] .= $match[1].$expr; |
|
1605 | 1605 | } elseif (is_array($expr)) { |
1606 | - $out .= $match[1] . $expr[0]; |
|
1606 | + $out .= $match[1].$expr[0]; |
|
1607 | 1607 | } else { |
1608 | - $out .= $match[1] . $expr; |
|
1608 | + $out .= $match[1].$expr; |
|
1609 | 1609 | } |
1610 | 1610 | } |
1611 | 1611 | } elseif ($curBlock === 'root' && preg_match('#^(\s*(?:[+/*%-.]=|=|\+\+|--)\s*)(.*)#s', $substr, $match)) { |
1612 | 1612 | if ($this->debug) { |
1613 | - echo 'PARSING POST-VAR ASSIGNMENT ' . $substr . "\n"; |
|
1613 | + echo 'PARSING POST-VAR ASSIGNMENT '.$substr."\n"; |
|
1614 | 1614 | } |
1615 | 1615 | // parse assignment |
1616 | 1616 | $value = $match[2]; |
1617 | 1617 | $operator = trim($match[1]); |
1618 | 1618 | if (substr($value, 0, 1) == '=') { |
1619 | - throw new CompilationException($this, 'Unexpected "=" in <em>' . $substr . '</em>'); |
|
1619 | + throw new CompilationException($this, 'Unexpected "=" in <em>'.$substr.'</em>'); |
|
1620 | 1620 | } |
1621 | 1621 | |
1622 | 1622 | if ($pointer !== null) { |
@@ -1637,7 +1637,7 @@ discard block |
||
1637 | 1637 | throw new CompilationException($this, 'Assignments require the "if" plugin to be accessible'); |
1638 | 1638 | } |
1639 | 1639 | |
1640 | - $parts = $this->mapParams($parts, array(Core::NAMESPACE_PLUGINS_BLOCKS . 'PluginIf', 'init'), 1); |
|
1640 | + $parts = $this->mapParams($parts, array(Core::NAMESPACE_PLUGINS_BLOCKS.'PluginIf', 'init'), 1); |
|
1641 | 1641 | $tokens = $this->getParamTokens($parts); |
1642 | 1642 | $parts = $this->getCompiledParams($parts); |
1643 | 1643 | |
@@ -1651,14 +1651,14 @@ discard block |
||
1651 | 1651 | if ($this->autoEscape) { |
1652 | 1652 | $out = preg_replace('#\(is_string\(\$tmp=(.+?)\) \? htmlspecialchars\(\$tmp, ENT_QUOTES, \$this->charset\) : \$tmp\)#', '$1', $out); |
1653 | 1653 | } |
1654 | - $out = self::PHP_OPEN . $echo . $out . $operator . implode(' ', $value) . self::PHP_CLOSE; |
|
1654 | + $out = self::PHP_OPEN.$echo.$out.$operator.implode(' ', $value).self::PHP_CLOSE; |
|
1655 | 1655 | } elseif ($curBlock === 'array' && is_array($parsingParams) && preg_match('#^(\s*=>?\s*)#', $substr, $match)) { |
1656 | 1656 | // parse namedparam with var as name (only for array) |
1657 | 1657 | if ($this->debug) { |
1658 | - echo 'VARIABLE NAMED PARAM (FOR ARRAY) FOUND' . "\n"; |
|
1658 | + echo 'VARIABLE NAMED PARAM (FOR ARRAY) FOUND'."\n"; |
|
1659 | 1659 | } |
1660 | 1660 | $len = strlen($match[1]); |
1661 | - $var = $out[count($out) - 1]; |
|
1661 | + $var = $out[count($out)-1]; |
|
1662 | 1662 | $pointer += $len; |
1663 | 1663 | |
1664 | 1664 | $output = array($var[0], $this->parse($substr, $len, null, false, 'namedparam', $pointer)); |
@@ -1673,16 +1673,16 @@ discard block |
||
1673 | 1673 | // parse modifier on funcs or vars |
1674 | 1674 | $srcPointer = $pointer; |
1675 | 1675 | if (is_array($parsingParams)) { |
1676 | - $tmp = $this->replaceModifiers( |
|
1676 | + $tmp = $this->replaceModifiers( |
|
1677 | 1677 | array( |
1678 | 1678 | null, |
1679 | 1679 | null, |
1680 | - $out[count($out) - 1][0], |
|
1680 | + $out[count($out)-1][0], |
|
1681 | 1681 | $match[0] |
1682 | 1682 | ), $curBlock, $pointer |
1683 | 1683 | ); |
1684 | - $out[count($out) - 1][0] = $tmp; |
|
1685 | - $out[count($out) - 1][1] .= substr($substr, $srcPointer, $srcPointer - $pointer); |
|
1684 | + $out[count($out)-1][0] = $tmp; |
|
1685 | + $out[count($out)-1][1] .= substr($substr, $srcPointer, $srcPointer-$pointer); |
|
1686 | 1686 | } else { |
1687 | 1687 | $out = $this->replaceModifiers(array(null, null, $out, $match[0]), $curBlock, $pointer); |
1688 | 1688 | } |
@@ -1694,10 +1694,10 @@ discard block |
||
1694 | 1694 | $ptr = 0; |
1695 | 1695 | |
1696 | 1696 | if (is_array($parsingParams)) { |
1697 | - $output = $this->parseMethodCall($out[count($out) - 1][1], $match[0], $curBlock, $ptr); |
|
1697 | + $output = $this->parseMethodCall($out[count($out)-1][1], $match[0], $curBlock, $ptr); |
|
1698 | 1698 | |
1699 | - $out[count($out) - 1][0] = $output; |
|
1700 | - $out[count($out) - 1][1] .= substr($match[0], 0, $ptr); |
|
1699 | + $out[count($out)-1][0] = $output; |
|
1700 | + $out[count($out)-1][1] .= substr($match[0], 0, $ptr); |
|
1701 | 1701 | } else { |
1702 | 1702 | $out = $this->parseMethodCall($out, $match[0], $curBlock, $ptr); |
1703 | 1703 | } |
@@ -1706,7 +1706,7 @@ discard block |
||
1706 | 1706 | } |
1707 | 1707 | |
1708 | 1708 | if ($curBlock === 'root' && substr($out, 0, strlen(self::PHP_OPEN)) !== self::PHP_OPEN) { |
1709 | - return self::PHP_OPEN . 'echo ' . $out . ';' . self::PHP_CLOSE; |
|
1709 | + return self::PHP_OPEN.'echo '.$out.';'.self::PHP_CLOSE; |
|
1710 | 1710 | } |
1711 | 1711 | |
1712 | 1712 | return $out; |
@@ -1732,11 +1732,11 @@ discard block |
||
1732 | 1732 | protected function parseFunction($in, $from, $to, $parsingParams = false, $curBlock = '', &$pointer = null) |
1733 | 1733 | { |
1734 | 1734 | $output = ''; |
1735 | - $cmdstr = substr($in, $from, $to - $from); |
|
1736 | - preg_match('/^(\\\\?[a-z_](?:\\\\?[a-z0-9_]+)*(?:::[a-z_][a-z0-9_]*)?)(\s*' . $this->rdr . '|\s*;)?/i', $cmdstr, $match); |
|
1735 | + $cmdstr = substr($in, $from, $to-$from); |
|
1736 | + preg_match('/^(\\\\?[a-z_](?:\\\\?[a-z0-9_]+)*(?:::[a-z_][a-z0-9_]*)?)(\s*'.$this->rdr.'|\s*;)?/i', $cmdstr, $match); |
|
1737 | 1737 | |
1738 | 1738 | if (empty($match[1])) { |
1739 | - throw new CompilationException($this, 'Parse error, invalid function name : ' . substr($cmdstr, 0, 15)); |
|
1739 | + throw new CompilationException($this, 'Parse error, invalid function name : '.substr($cmdstr, 0, 15)); |
|
1740 | 1740 | } |
1741 | 1741 | |
1742 | 1742 | $func = $match[1]; |
@@ -1746,7 +1746,7 @@ discard block |
||
1746 | 1746 | } |
1747 | 1747 | |
1748 | 1748 | if ($this->debug) { |
1749 | - echo 'FUNC FOUND (' . $func . ')' . "\n"; |
|
1749 | + echo 'FUNC FOUND ('.$func.')'."\n"; |
|
1750 | 1750 | } |
1751 | 1751 | |
1752 | 1752 | $paramsep = ''; |
@@ -1758,11 +1758,11 @@ discard block |
||
1758 | 1758 | $paramspos = $match[1][0][1]; |
1759 | 1759 | $paramsep = substr($match[1][0][0], - 1) === '(' ? ')' : ''; |
1760 | 1760 | if ($paramsep === ')') { |
1761 | - $paramspos += strlen($match[1][0][0]) - 1; |
|
1761 | + $paramspos += strlen($match[1][0][0])-1; |
|
1762 | 1762 | if (substr($cmdstr, 0, 2) === 'if' || substr($cmdstr, 0, 6) === 'elseif') { |
1763 | 1763 | $paramsep = ''; |
1764 | 1764 | if (strlen($match[1][0][0]) > 1) { |
1765 | - -- $paramspos; |
|
1765 | + --$paramspos; |
|
1766 | 1766 | } |
1767 | 1767 | } |
1768 | 1768 | } |
@@ -1787,8 +1787,8 @@ discard block |
||
1787 | 1787 | return $this->parseOthers($in, $from, $to, $parsingParams, $curBlock, $pointer); |
1788 | 1788 | } |
1789 | 1789 | } |
1790 | - $whitespace = strlen(substr($cmdstr, strlen($func), $paramspos - strlen($func))); |
|
1791 | - $paramstr = substr($cmdstr, $paramspos + 1); |
|
1790 | + $whitespace = strlen(substr($cmdstr, strlen($func), $paramspos-strlen($func))); |
|
1791 | + $paramstr = substr($cmdstr, $paramspos+1); |
|
1792 | 1792 | if (substr($paramstr, - 1, 1) === $paramsep) { |
1793 | 1793 | $paramstr = substr($paramstr, 0, - 1); |
1794 | 1794 | } |
@@ -1810,36 +1810,36 @@ discard block |
||
1810 | 1810 | |
1811 | 1811 | if ($func !== 'if' && $func !== 'elseif' && $paramstr[$ptr] === ')') { |
1812 | 1812 | if ($this->debug) { |
1813 | - echo 'PARAM PARSING ENDED, ")" FOUND, POINTER AT ' . $ptr . "\n"; |
|
1813 | + echo 'PARAM PARSING ENDED, ")" FOUND, POINTER AT '.$ptr."\n"; |
|
1814 | 1814 | } |
1815 | 1815 | break 2; |
1816 | 1816 | } elseif ($paramstr[$ptr] === ';') { |
1817 | - ++ $ptr; |
|
1817 | + ++$ptr; |
|
1818 | 1818 | if ($this->debug) { |
1819 | - echo 'PARAM PARSING ENDED, ";" FOUND, POINTER AT ' . $ptr . "\n"; |
|
1819 | + echo 'PARAM PARSING ENDED, ";" FOUND, POINTER AT '.$ptr."\n"; |
|
1820 | 1820 | } |
1821 | 1821 | break 2; |
1822 | 1822 | } elseif ($func !== 'if' && $func !== 'elseif' && $paramstr[$ptr] === '/') { |
1823 | 1823 | if ($this->debug) { |
1824 | - echo 'PARAM PARSING ENDED, "/" FOUND, POINTER AT ' . $ptr . "\n"; |
|
1824 | + echo 'PARAM PARSING ENDED, "/" FOUND, POINTER AT '.$ptr."\n"; |
|
1825 | 1825 | } |
1826 | 1826 | break 2; |
1827 | 1827 | } elseif (substr($paramstr, $ptr, strlen($this->rd)) === $this->rd) { |
1828 | 1828 | if ($this->debug) { |
1829 | - echo 'PARAM PARSING ENDED, RIGHT DELIMITER FOUND, POINTER AT ' . $ptr . "\n"; |
|
1829 | + echo 'PARAM PARSING ENDED, RIGHT DELIMITER FOUND, POINTER AT '.$ptr."\n"; |
|
1830 | 1830 | } |
1831 | 1831 | break 2; |
1832 | 1832 | } |
1833 | 1833 | |
1834 | 1834 | if ($paramstr[$ptr] === ' ' || $paramstr[$ptr] === ',' || $paramstr[$ptr] === "\r" || $paramstr[$ptr] === "\n" || $paramstr[$ptr] === "\t") { |
1835 | - ++ $ptr; |
|
1835 | + ++$ptr; |
|
1836 | 1836 | } else { |
1837 | 1837 | break; |
1838 | 1838 | } |
1839 | 1839 | } |
1840 | 1840 | |
1841 | 1841 | if ($this->debug) { |
1842 | - echo 'FUNC START PARAM PARSING WITH POINTER AT ' . $ptr . "\n"; |
|
1842 | + echo 'FUNC START PARAM PARSING WITH POINTER AT '.$ptr."\n"; |
|
1843 | 1843 | } |
1844 | 1844 | |
1845 | 1845 | if ($func === 'if' || $func === 'elseif' || $func === 'tif') { |
@@ -1851,7 +1851,7 @@ discard block |
||
1851 | 1851 | } |
1852 | 1852 | |
1853 | 1853 | if ($this->debug) { |
1854 | - echo 'PARAM PARSED, POINTER AT ' . $ptr . ' (' . substr($paramstr, $ptr - 1, 3) . ')' . "\n"; |
|
1854 | + echo 'PARAM PARSED, POINTER AT '.$ptr.' ('.substr($paramstr, $ptr-1, 3).')'."\n"; |
|
1855 | 1855 | } |
1856 | 1856 | } |
1857 | 1857 | } |
@@ -1875,16 +1875,16 @@ discard block |
||
1875 | 1875 | } |
1876 | 1876 | |
1877 | 1877 | if ($pointer !== null) { |
1878 | - $pointer += (isset($paramstr) ? strlen($paramstr) : 0) + (')' === $paramsep ? 2 : ($paramspos === false ? 0 : 1)) + strlen($func) + (isset($whitespace) ? $whitespace : 0); |
|
1878 | + $pointer += (isset($paramstr) ? strlen($paramstr) : 0)+(')' === $paramsep ? 2 : ($paramspos === false ? 0 : 1))+strlen($func)+(isset($whitespace) ? $whitespace : 0); |
|
1879 | 1879 | if ($this->debug) { |
1880 | - echo 'FUNC ADDS ' . ((isset($paramstr) ? strlen($paramstr) : 0) + (')' === $paramsep ? 2 : ($paramspos === false ? 0 : 1)) + strlen($func)) . ' TO POINTER' . "\n"; |
|
1880 | + echo 'FUNC ADDS '.((isset($paramstr) ? strlen($paramstr) : 0)+(')' === $paramsep ? 2 : ($paramspos === false ? 0 : 1))+strlen($func)).' TO POINTER'."\n"; |
|
1881 | 1881 | } |
1882 | 1882 | } |
1883 | 1883 | |
1884 | 1884 | if ($curBlock === 'method' || $func === 'do' || strstr($func, '::') !== false) { |
1885 | 1885 | // handle static method calls with security policy |
1886 | 1886 | if (strstr($func, '::') !== false && $this->securityPolicy !== null && $this->securityPolicy->isMethodAllowed(explode('::', strtolower($func))) !== true) { |
1887 | - throw new SecurityException('Call to a disallowed php function : ' . $func); |
|
1887 | + throw new SecurityException('Call to a disallowed php function : '.$func); |
|
1888 | 1888 | } |
1889 | 1889 | $pluginType = Core::NATIVE_PLUGIN; |
1890 | 1890 | } else { |
@@ -1929,19 +1929,19 @@ discard block |
||
1929 | 1929 | $this->customPlugins[$func]['function'] |
1930 | 1930 | ), $state); |
1931 | 1931 | } else { |
1932 | - if (class_exists('Plugin' . Core::toCamelCase($func)) !== false) { |
|
1932 | + if (class_exists('Plugin'.Core::toCamelCase($func)) !== false) { |
|
1933 | 1933 | $params = $this->mapParams($params, array( |
1934 | - 'Plugin' . Core::toCamelCase($func), |
|
1934 | + 'Plugin'.Core::toCamelCase($func), |
|
1935 | 1935 | ($pluginType & Core::COMPILABLE_PLUGIN) ? 'compile' : 'process' |
1936 | 1936 | ), $state); |
1937 | - } elseif (class_exists(Core::NAMESPACE_PLUGINS_HELPERS . 'Plugin' . Core::toCamelCase($func)) !== false) { |
|
1937 | + } elseif (class_exists(Core::NAMESPACE_PLUGINS_HELPERS.'Plugin'.Core::toCamelCase($func)) !== false) { |
|
1938 | 1938 | $params = $this->mapParams($params, array( |
1939 | - Core::NAMESPACE_PLUGINS_HELPERS . 'Plugin' . Core::toCamelCase($func), |
|
1939 | + Core::NAMESPACE_PLUGINS_HELPERS.'Plugin'.Core::toCamelCase($func), |
|
1940 | 1940 | ($pluginType & Core::COMPILABLE_PLUGIN) ? 'compile' : 'process' |
1941 | 1941 | ), $state); |
1942 | 1942 | } else { |
1943 | 1943 | $params = $this->mapParams($params, array( |
1944 | - Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin' . Core::toCamelCase($func), |
|
1944 | + Core::NAMESPACE_PLUGINS_FUNCTIONS.'Plugin'.Core::toCamelCase($func), |
|
1945 | 1945 | ($pluginType & Core::COMPILABLE_PLUGIN) ? 'compile' : 'process' |
1946 | 1946 | ), $state); |
1947 | 1947 | } |
@@ -1952,24 +1952,22 @@ discard block |
||
1952 | 1952 | $params = $this->mapParams($params, $this->customPlugins[$func]['callback'], $state); |
1953 | 1953 | } else { |
1954 | 1954 | // Custom plugin |
1955 | - if (function_exists('Plugin' . Core::toCamelCase($func) . (($pluginType & Core::COMPILABLE_PLUGIN) ? |
|
1955 | + if (function_exists('Plugin'.Core::toCamelCase($func).(($pluginType & Core::COMPILABLE_PLUGIN) ? |
|
1956 | 1956 | 'Compile' : '')) !== false) { |
1957 | - $params = $this->mapParams($params, 'Plugin' . Core::toCamelCase($func) . (($pluginType & |
|
1957 | + $params = $this->mapParams($params, 'Plugin'.Core::toCamelCase($func).(($pluginType & |
|
1958 | 1958 | Core::COMPILABLE_PLUGIN) ? 'Compile' : ''), $state); |
1959 | 1959 | } // Builtin helper plugin |
1960 | - elseif (function_exists(Core::NAMESPACE_PLUGINS_HELPERS . 'Plugin' . Core::toCamelCase($func) . ( |
|
1960 | + elseif (function_exists(Core::NAMESPACE_PLUGINS_HELPERS.'Plugin'.Core::toCamelCase($func).( |
|
1961 | 1961 | ($pluginType & Core::COMPILABLE_PLUGIN) ? 'Compile' : '')) !== false) { |
1962 | - $params = $this->mapParams($params, Core::NAMESPACE_PLUGINS_HELPERS . 'Plugin' . Core::toCamelCase |
|
1963 | - ($func) . (($pluginType & Core::COMPILABLE_PLUGIN) ? 'Compile' : ''), $state); |
|
1962 | + $params = $this->mapParams($params, Core::NAMESPACE_PLUGINS_HELPERS.'Plugin'.Core::toCamelCase($func).(($pluginType & Core::COMPILABLE_PLUGIN) ? 'Compile' : ''), $state); |
|
1964 | 1963 | } // Builtin function plugin |
1965 | 1964 | else { |
1966 | - $params = $this->mapParams($params, Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin' . Core::toCamelCase |
|
1967 | - ($func) . (($pluginType & Core::COMPILABLE_PLUGIN) ? 'Compile' : ''), $state); |
|
1965 | + $params = $this->mapParams($params, Core::NAMESPACE_PLUGINS_FUNCTIONS.'Plugin'.Core::toCamelCase($func).(($pluginType & Core::COMPILABLE_PLUGIN) ? 'Compile' : ''), $state); |
|
1968 | 1966 | } |
1969 | 1967 | } |
1970 | 1968 | } // Smarty modifier |
1971 | 1969 | elseif ($pluginType & Core::SMARTY_MODIFIER) { |
1972 | - $output = 'smarty_modifier_' . $func . '(' . implode(', ', $params) . ')'; |
|
1970 | + $output = 'smarty_modifier_'.$func.'('.implode(', ', $params).')'; |
|
1973 | 1971 | } // Proxy plugin |
1974 | 1972 | elseif ($pluginType & Core::PROXY_PLUGIN) { |
1975 | 1973 | $params = $this->mapParams($params, $this->getCore()->getPluginProxy()->getCallback($func), $state); |
@@ -2009,19 +2007,19 @@ discard block |
||
2009 | 2007 | if ($func === 'do') { |
2010 | 2008 | $output = ''; |
2011 | 2009 | if (isset($params['*'])) { |
2012 | - $output = implode(';', $params['*']) . ';'; |
|
2010 | + $output = implode(';', $params['*']).';'; |
|
2013 | 2011 | } |
2014 | 2012 | |
2015 | 2013 | if (is_array($parsingParams) || $curBlock !== 'root') { |
2016 | 2014 | throw new CompilationException($this, 'Do can not be used inside another function or block'); |
2017 | 2015 | } |
2018 | 2016 | |
2019 | - return self::PHP_OPEN . $output . self::PHP_CLOSE; |
|
2017 | + return self::PHP_OPEN.$output.self::PHP_CLOSE; |
|
2020 | 2018 | } else { |
2021 | 2019 | if (isset($params['*'])) { |
2022 | - $output = $func . '(' . implode(', ', $params['*']) . ')'; |
|
2020 | + $output = $func.'('.implode(', ', $params['*']).')'; |
|
2023 | 2021 | } else { |
2024 | - $output = $func . '()'; |
|
2022 | + $output = $func.'()'; |
|
2025 | 2023 | } |
2026 | 2024 | } |
2027 | 2025 | } // Block class OR Function class |
@@ -2031,7 +2029,7 @@ discard block |
||
2031 | 2029 | $callback = $this->customPlugins[$func]['callback']; |
2032 | 2030 | if (!is_array($callback)) { |
2033 | 2031 | if (!method_exists($callback, 'compile')) { |
2034 | - throw new Exception('Custom plugin ' . $func . ' must implement the "compile" method to be compilable, or you should provide a full callback to the method to use'); |
|
2032 | + throw new Exception('Custom plugin '.$func.' must implement the "compile" method to be compilable, or you should provide a full callback to the method to use'); |
|
2035 | 2033 | } |
2036 | 2034 | if (($ref = new ReflectionMethod($callback, 'compile')) && $ref->isStatic()) { |
2037 | 2035 | $funcCompiler = array($callback, 'compile'); |
@@ -2042,13 +2040,13 @@ discard block |
||
2042 | 2040 | $funcCompiler = $callback; |
2043 | 2041 | } |
2044 | 2042 | } else { |
2045 | - if (class_exists('Plugin' . Core::toCamelCase($func)) !== false) { |
|
2046 | - $funcCompiler = array('Plugin' . Core::toCamelCase($func), 'compile'); |
|
2047 | - } elseif (class_exists(Core::NAMESPACE_PLUGINS_HELPERS . 'Plugin' . Core::toCamelCase($func)) !== false) { |
|
2048 | - $funcCompiler = array(Core::NAMESPACE_PLUGINS_HELPERS . 'Plugin' . Core::toCamelCase($func), 'compile'); |
|
2043 | + if (class_exists('Plugin'.Core::toCamelCase($func)) !== false) { |
|
2044 | + $funcCompiler = array('Plugin'.Core::toCamelCase($func), 'compile'); |
|
2045 | + } elseif (class_exists(Core::NAMESPACE_PLUGINS_HELPERS.'Plugin'.Core::toCamelCase($func)) !== false) { |
|
2046 | + $funcCompiler = array(Core::NAMESPACE_PLUGINS_HELPERS.'Plugin'.Core::toCamelCase($func), 'compile'); |
|
2049 | 2047 | } else { |
2050 | 2048 | $funcCompiler = array( |
2051 | - Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin' . Core::toCamelCase($func), |
|
2049 | + Core::NAMESPACE_PLUGINS_FUNCTIONS.'Plugin'.Core::toCamelCase($func), |
|
2052 | 2050 | 'compile' |
2053 | 2051 | ); |
2054 | 2052 | } |
@@ -2065,34 +2063,34 @@ discard block |
||
2065 | 2063 | $callback = $this->customPlugins[$func]['callback']; |
2066 | 2064 | if (!is_array($callback)) { |
2067 | 2065 | if (!method_exists($callback, 'process')) { |
2068 | - throw new Exception('Custom plugin ' . $func . ' must implement the "process" method to be usable, or you should provide a full callback to the method to use'); |
|
2066 | + throw new Exception('Custom plugin '.$func.' must implement the "process" method to be usable, or you should provide a full callback to the method to use'); |
|
2069 | 2067 | } |
2070 | 2068 | if (is_object($callback)) { |
2071 | 2069 | $callback = get_class($callback); |
2072 | 2070 | } |
2073 | 2071 | if (($ref = new ReflectionMethod($callback, 'process')) && $ref->isStatic()) { |
2074 | - $output = 'call_user_func(array(\'' . $callback . '\', \'process\'), ' . $params . ')'; |
|
2072 | + $output = 'call_user_func(array(\''.$callback.'\', \'process\'), '.$params.')'; |
|
2075 | 2073 | } else { |
2076 | - $output = 'call_user_func(array($this->getObjectPlugin(\'' . $callback . '\'), \'process\'), ' . $params . ')'; |
|
2074 | + $output = 'call_user_func(array($this->getObjectPlugin(\''.$callback.'\'), \'process\'), '.$params.')'; |
|
2077 | 2075 | } |
2078 | 2076 | } elseif (is_object($callback[0])) { |
2079 | - $output = 'call_user_func(array($this->plugins[\'' . $func . '\'][\'callback\'][0], \'' . $callback[1] . '\'), ' . $params . ')'; |
|
2077 | + $output = 'call_user_func(array($this->plugins[\''.$func.'\'][\'callback\'][0], \''.$callback[1].'\'), '.$params.')'; |
|
2080 | 2078 | } elseif (($ref = new ReflectionMethod($callback[0], $callback[1])) && $ref->isStatic()) { |
2081 | - $output = 'call_user_func(array(\'' . $callback[0] . '\', \'' . $callback[1] . '\'), ' . $params . ')'; |
|
2079 | + $output = 'call_user_func(array(\''.$callback[0].'\', \''.$callback[1].'\'), '.$params.')'; |
|
2082 | 2080 | } else { |
2083 | - $output = 'call_user_func(array($this->getObjectPlugin(\'' . $callback[0] . '\'), \'' . $callback[1] . '\'), ' . $params . ')'; |
|
2081 | + $output = 'call_user_func(array($this->getObjectPlugin(\''.$callback[0].'\'), \''.$callback[1].'\'), '.$params.')'; |
|
2084 | 2082 | } |
2085 | 2083 | if (empty($params)) { |
2086 | - $output = substr($output, 0, - 3) . ')'; |
|
2084 | + $output = substr($output, 0, - 3).')'; |
|
2087 | 2085 | } |
2088 | 2086 | } else { |
2089 | - if (class_exists('Plugin' . Core::toCamelCase($func)) !== false) { |
|
2090 | - $output = '$this->classCall(\'Plugin' . $func . '\', array(' . $params . '))'; |
|
2091 | - } elseif (class_exists(Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin' . Core::toCamelCase($func)) !== false) { |
|
2092 | - $output = '$this->classCall(\'' . Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin' . $func . '\', |
|
2093 | - array(' . $params . '))'; |
|
2087 | + if (class_exists('Plugin'.Core::toCamelCase($func)) !== false) { |
|
2088 | + $output = '$this->classCall(\'Plugin'.$func.'\', array('.$params.'))'; |
|
2089 | + } elseif (class_exists(Core::NAMESPACE_PLUGINS_FUNCTIONS.'Plugin'.Core::toCamelCase($func)) !== false) { |
|
2090 | + $output = '$this->classCall(\''.Core::NAMESPACE_PLUGINS_FUNCTIONS.'Plugin'.$func.'\', |
|
2091 | + array(' . $params.'))'; |
|
2094 | 2092 | } else { |
2095 | - $output = '$this->classCall(\'' . $func . '\', array(' . $params . '))'; |
|
2093 | + $output = '$this->classCall(\''.$func.'\', array('.$params.'))'; |
|
2096 | 2094 | } |
2097 | 2095 | } |
2098 | 2096 | } |
@@ -2103,15 +2101,15 @@ discard block |
||
2103 | 2101 | $funcCompiler = $this->customPlugins[$func]['callback']; |
2104 | 2102 | } else { |
2105 | 2103 | // Custom plugin |
2106 | - if (function_exists('Plugin' . Core::toCamelCase($func) . 'Compile') !== false) { |
|
2107 | - $funcCompiler = 'Plugin' . Core::toCamelCase($func) . 'Compile'; |
|
2104 | + if (function_exists('Plugin'.Core::toCamelCase($func).'Compile') !== false) { |
|
2105 | + $funcCompiler = 'Plugin'.Core::toCamelCase($func).'Compile'; |
|
2108 | 2106 | } // Builtin helper plugin |
2109 | - elseif (function_exists(Core::NAMESPACE_PLUGINS_HELPERS . 'Plugin' . Core::toCamelCase($func) . 'Compile') !== false) { |
|
2110 | - $funcCompiler = Core::NAMESPACE_PLUGINS_HELPERS . 'Plugin' . Core::toCamelCase($func) . |
|
2107 | + elseif (function_exists(Core::NAMESPACE_PLUGINS_HELPERS.'Plugin'.Core::toCamelCase($func).'Compile') !== false) { |
|
2108 | + $funcCompiler = Core::NAMESPACE_PLUGINS_HELPERS.'Plugin'.Core::toCamelCase($func). |
|
2111 | 2109 | 'Compile'; |
2112 | 2110 | } // Builtin function plugin |
2113 | 2111 | else { |
2114 | - $funcCompiler = Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin' . Core::toCamelCase($func) . |
|
2112 | + $funcCompiler = Core::NAMESPACE_PLUGINS_FUNCTIONS.'Plugin'.Core::toCamelCase($func). |
|
2115 | 2113 | 'Compile'; |
2116 | 2114 | } |
2117 | 2115 | } |
@@ -2127,24 +2125,24 @@ discard block |
||
2127 | 2125 | if ($pluginType & Core::CUSTOM_PLUGIN) { |
2128 | 2126 | $callback = $this->customPlugins[$func]['callback']; |
2129 | 2127 | if ($callback instanceof Closure) { |
2130 | - $output = 'call_user_func($this->getCustomPlugin(\'' . $func . '\'), ' . $params . ')'; |
|
2128 | + $output = 'call_user_func($this->getCustomPlugin(\''.$func.'\'), '.$params.')'; |
|
2131 | 2129 | } else { |
2132 | - $output = 'call_user_func(\'' . $callback . '\', ' . $params . ')'; |
|
2130 | + $output = 'call_user_func(\''.$callback.'\', '.$params.')'; |
|
2133 | 2131 | } |
2134 | 2132 | } else { |
2135 | 2133 | // Custom plugin |
2136 | - if (function_exists('Plugin' . Core::toCamelCase($func)) !== false) { |
|
2137 | - $output = 'Plugin' . Core::toCamelCase($func) . '(' . $params . |
|
2134 | + if (function_exists('Plugin'.Core::toCamelCase($func)) !== false) { |
|
2135 | + $output = 'Plugin'.Core::toCamelCase($func).'('.$params. |
|
2138 | 2136 | ')'; |
2139 | 2137 | } // Builtin helper plugin |
2140 | - elseif(function_exists(Core::NAMESPACE_PLUGINS_HELPERS . 'Plugin' . Core::toCamelCase($func)) !== |
|
2138 | + elseif (function_exists(Core::NAMESPACE_PLUGINS_HELPERS.'Plugin'.Core::toCamelCase($func)) !== |
|
2141 | 2139 | false) { |
2142 | - $output = Core::NAMESPACE_PLUGINS_HELPERS . 'Plugin' . Core::toCamelCase($func) . '(' . |
|
2143 | - $params . ')'; |
|
2140 | + $output = Core::NAMESPACE_PLUGINS_HELPERS.'Plugin'.Core::toCamelCase($func).'('. |
|
2141 | + $params.')'; |
|
2144 | 2142 | } // Builtin function plugin |
2145 | 2143 | else { |
2146 | - $output = Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin' . Core::toCamelCase($func) . '(' . |
|
2147 | - $params . ')'; |
|
2144 | + $output = Core::NAMESPACE_PLUGINS_FUNCTIONS.'Plugin'.Core::toCamelCase($func).'('. |
|
2145 | + $params.')'; |
|
2148 | 2146 | } |
2149 | 2147 | } |
2150 | 2148 | } |
@@ -2162,22 +2160,22 @@ discard block |
||
2162 | 2160 | $callback = $this->customPlugins[$func]['callback']; |
2163 | 2161 | if (is_array($callback)) { |
2164 | 2162 | if (is_object($callback[0])) { |
2165 | - $output = 'call_user_func_array(array($this->getCustomPlugin(\'' . $func . '\'), \'' . $callback[1] . '\'), array(array(' . $params . '), $this))'; |
|
2163 | + $output = 'call_user_func_array(array($this->getCustomPlugin(\''.$func.'\'), \''.$callback[1].'\'), array(array('.$params.'), $this))'; |
|
2166 | 2164 | } else { |
2167 | - $output = 'call_user_func_array(array(\'' . $callback[0] . '\', \'' . $callback[1] . '\'), array(array(' . $params . '), $this))'; |
|
2165 | + $output = 'call_user_func_array(array(\''.$callback[0].'\', \''.$callback[1].'\'), array(array('.$params.'), $this))'; |
|
2168 | 2166 | } |
2169 | 2167 | } else { |
2170 | - $output = $callback . '(array(' . $params . '), $this)'; |
|
2168 | + $output = $callback.'(array('.$params.'), $this)'; |
|
2171 | 2169 | } |
2172 | 2170 | } else { |
2173 | - $output = 'smarty_function_' . $func . '(array(' . $params . '), $this)'; |
|
2171 | + $output = 'smarty_function_'.$func.'(array('.$params.'), $this)'; |
|
2174 | 2172 | } |
2175 | 2173 | } // Template plugin |
2176 | 2174 | elseif ($pluginType & Core::TEMPLATE_PLUGIN) { |
2177 | 2175 | array_unshift($params, '$this'); |
2178 | 2176 | $params = self::implode_r($params); |
2179 | - $output = 'Plugin' . Core::toCamelCase($func) . |
|
2180 | - $this->templatePlugins[$func]['uuid'] . '(' . $params . ')'; |
|
2177 | + $output = 'Plugin'.Core::toCamelCase($func). |
|
2178 | + $this->templatePlugins[$func]['uuid'].'('.$params.')'; |
|
2181 | 2179 | $this->templatePlugins[$func]['called'] = true; |
2182 | 2180 | } |
2183 | 2181 | |
@@ -2209,29 +2207,29 @@ discard block |
||
2209 | 2207 | */ |
2210 | 2208 | protected function parseString($in, $from, $to, $parsingParams = false, $curBlock = '', &$pointer = null) |
2211 | 2209 | { |
2212 | - $substr = substr($in, $from, $to - $from); |
|
2210 | + $substr = substr($in, $from, $to-$from); |
|
2213 | 2211 | $first = $substr[0]; |
2214 | 2212 | |
2215 | 2213 | if ($this->debug) { |
2216 | - echo 'STRING FOUND (in ' . htmlentities(substr($in, $from, min($to - $from, 50))) . (($to - $from) > 50 ? '...' : '') . ')' . "\n"; |
|
2214 | + echo 'STRING FOUND (in '.htmlentities(substr($in, $from, min($to-$from, 50))).(($to-$from) > 50 ? '...' : '').')'."\n"; |
|
2217 | 2215 | } |
2218 | 2216 | $strend = false; |
2219 | - $o = $from + 1; |
|
2217 | + $o = $from+1; |
|
2220 | 2218 | while ($strend === false) { |
2221 | 2219 | $strend = strpos($in, $first, $o); |
2222 | 2220 | if ($strend === false) { |
2223 | - throw new CompilationException($this, 'Unfinished string, started with ' . substr($in, $from, $to - $from)); |
|
2221 | + throw new CompilationException($this, 'Unfinished string, started with '.substr($in, $from, $to-$from)); |
|
2224 | 2222 | } |
2225 | - if (substr($in, $strend - 1, 1) === '\\') { |
|
2226 | - $o = $strend + 1; |
|
2223 | + if (substr($in, $strend-1, 1) === '\\') { |
|
2224 | + $o = $strend+1; |
|
2227 | 2225 | $strend = false; |
2228 | 2226 | } |
2229 | 2227 | } |
2230 | 2228 | if ($this->debug) { |
2231 | - echo 'STRING DELIMITED: ' . substr($in, $from, $strend + 1 - $from) . "\n"; |
|
2229 | + echo 'STRING DELIMITED: '.substr($in, $from, $strend+1-$from)."\n"; |
|
2232 | 2230 | } |
2233 | 2231 | |
2234 | - $srcOutput = substr($in, $from, $strend + 1 - $from); |
|
2232 | + $srcOutput = substr($in, $from, $strend+1-$from); |
|
2235 | 2233 | |
2236 | 2234 | if ($pointer !== null) { |
2237 | 2235 | $pointer += strlen($srcOutput); |
@@ -2240,13 +2238,13 @@ discard block |
||
2240 | 2238 | $output = $this->replaceStringVars($srcOutput, $first); |
2241 | 2239 | |
2242 | 2240 | // handle modifiers |
2243 | - if ($curBlock !== 'modifier' && preg_match('#^((?:\|(?:@?[a-z0-9_]+(?::.*)*))+)#i', substr($substr, $strend + 1 - $from), $match)) { |
|
2241 | + if ($curBlock !== 'modifier' && preg_match('#^((?:\|(?:@?[a-z0-9_]+(?::.*)*))+)#i', substr($substr, $strend+1-$from), $match)) { |
|
2244 | 2242 | $modstr = $match[1]; |
2245 | 2243 | |
2246 | 2244 | if ($curBlock === 'root' && substr($modstr, - 1) === '}') { |
2247 | 2245 | $modstr = substr($modstr, 0, - 1); |
2248 | 2246 | } |
2249 | - $modstr = str_replace('\\' . $first, $first, $modstr); |
|
2247 | + $modstr = str_replace('\\'.$first, $first, $modstr); |
|
2250 | 2248 | $ptr = 0; |
2251 | 2249 | $output = $this->replaceModifiers(array(null, null, $output, $modstr), 'string', $ptr); |
2252 | 2250 | |
@@ -2254,7 +2252,7 @@ discard block |
||
2254 | 2252 | if ($pointer !== null) { |
2255 | 2253 | $pointer += $ptr; |
2256 | 2254 | } |
2257 | - $srcOutput .= substr($substr, $strend + 1 - $from, $ptr); |
|
2255 | + $srcOutput .= substr($substr, $strend+1-$from, $ptr); |
|
2258 | 2256 | } |
2259 | 2257 | |
2260 | 2258 | if (is_array($parsingParams)) { |
@@ -2285,10 +2283,10 @@ discard block |
||
2285 | 2283 | */ |
2286 | 2284 | protected function parseConst($in, $from, $to, $parsingParams = false, $curBlock = '', &$pointer = null) |
2287 | 2285 | { |
2288 | - $substr = substr($in, $from, $to - $from); |
|
2286 | + $substr = substr($in, $from, $to-$from); |
|
2289 | 2287 | |
2290 | 2288 | if ($this->debug) { |
2291 | - echo 'CONST FOUND : ' . $substr . "\n"; |
|
2289 | + echo 'CONST FOUND : '.$substr."\n"; |
|
2292 | 2290 | } |
2293 | 2291 | |
2294 | 2292 | if (!preg_match('#^%([\\\\a-z0-9_:]+)#i', $substr, $m)) { |
@@ -2329,7 +2327,7 @@ discard block |
||
2329 | 2327 | } |
2330 | 2328 | |
2331 | 2329 | if ($curBlock !== 'root') { |
2332 | - return '(defined("' . $key . '") ? ' . $key . ' : null)'; |
|
2330 | + return '(defined("'.$key.'") ? '.$key.' : null)'; |
|
2333 | 2331 | } |
2334 | 2332 | |
2335 | 2333 | return $key; |
@@ -2352,7 +2350,7 @@ discard block |
||
2352 | 2350 | */ |
2353 | 2351 | protected function parseVar($in, $from, $to, $parsingParams = false, $curBlock = '', &$pointer = null) |
2354 | 2352 | { |
2355 | - $substr = substr($in, $from, $to - $from); |
|
2353 | + $substr = substr($in, $from, $to-$from); |
|
2356 | 2354 | |
2357 | 2355 | // var key |
2358 | 2356 | $varRegex = '(\\$?\\.?[a-z0-9\\\\_:]*(?:(?:(?:\\.|->)(?:[a-z0-9\\\\_:]+|(?R))|\\[(?:[a-z0-9\\\\_:]+|(?R)|(["\'])[^\\2]*?\\2)\\]))*)'; |
@@ -2380,13 +2378,13 @@ discard block |
||
2380 | 2378 | |
2381 | 2379 | if (substr($key, - 1) == '.') { |
2382 | 2380 | $key = substr($key, 0, - 1); |
2383 | - -- $matchedLength; |
|
2381 | + --$matchedLength; |
|
2384 | 2382 | } |
2385 | 2383 | |
2386 | 2384 | if ($hasMethodCall) { |
2387 | - $matchedLength -= strlen($match[3]) + strlen(substr($match[1], strrpos($match[1], '->'))); |
|
2388 | - $key = substr($match[1], 1, strrpos($match[1], '->') - 1); |
|
2389 | - $methodCall = substr($match[1], strrpos($match[1], '->')) . $match[3]; |
|
2385 | + $matchedLength -= strlen($match[3])+strlen(substr($match[1], strrpos($match[1], '->'))); |
|
2386 | + $key = substr($match[1], 1, strrpos($match[1], '->')-1); |
|
2387 | + $methodCall = substr($match[1], strrpos($match[1], '->')).$match[3]; |
|
2390 | 2388 | } |
2391 | 2389 | |
2392 | 2390 | if ($hasModifiers) { |
@@ -2402,9 +2400,9 @@ discard block |
||
2402 | 2400 | |
2403 | 2401 | if ($this->debug) { |
2404 | 2402 | if ($hasMethodCall) { |
2405 | - echo 'METHOD CALL FOUND : $' . $key . substr($methodCall, 0, 30) . "\n"; |
|
2403 | + echo 'METHOD CALL FOUND : $'.$key.substr($methodCall, 0, 30)."\n"; |
|
2406 | 2404 | } else { |
2407 | - echo 'VAR FOUND : $' . $key . "\n"; |
|
2405 | + echo 'VAR FOUND : $'.$key."\n"; |
|
2408 | 2406 | } |
2409 | 2407 | } |
2410 | 2408 | |
@@ -2415,7 +2413,7 @@ discard block |
||
2415 | 2413 | $uid = 0; |
2416 | 2414 | $parsed = array($uid => ''); |
2417 | 2415 | $current = &$parsed; |
2418 | - $curTxt = &$parsed[$uid ++]; |
|
2416 | + $curTxt = &$parsed[$uid++]; |
|
2419 | 2417 | $tree = array(); |
2420 | 2418 | $chars = str_split($key, 1); |
2421 | 2419 | $inSplittedVar = false; |
@@ -2424,33 +2422,33 @@ discard block |
||
2424 | 2422 | while (($char = array_shift($chars)) !== null) { |
2425 | 2423 | if ($char === '[') { |
2426 | 2424 | if (count($tree) > 0) { |
2427 | - ++ $bracketCount; |
|
2425 | + ++$bracketCount; |
|
2428 | 2426 | } else { |
2429 | 2427 | $tree[] = &$current; |
2430 | - $current[$uid] = array($uid + 1 => ''); |
|
2431 | - $current = &$current[$uid ++]; |
|
2432 | - $curTxt = &$current[$uid ++]; |
|
2428 | + $current[$uid] = array($uid+1 => ''); |
|
2429 | + $current = &$current[$uid++]; |
|
2430 | + $curTxt = &$current[$uid++]; |
|
2433 | 2431 | continue; |
2434 | 2432 | } |
2435 | 2433 | } elseif ($char === ']') { |
2436 | 2434 | if ($bracketCount > 0) { |
2437 | - -- $bracketCount; |
|
2435 | + --$bracketCount; |
|
2438 | 2436 | } else { |
2439 | - $current = &$tree[count($tree) - 1]; |
|
2437 | + $current = &$tree[count($tree)-1]; |
|
2440 | 2438 | array_pop($tree); |
2441 | 2439 | if (current($chars) !== '[' && current($chars) !== false && current($chars) !== ']') { |
2442 | 2440 | $current[$uid] = ''; |
2443 | - $curTxt = &$current[$uid ++]; |
|
2441 | + $curTxt = &$current[$uid++]; |
|
2444 | 2442 | } |
2445 | 2443 | continue; |
2446 | 2444 | } |
2447 | 2445 | } elseif ($char === '$') { |
2448 | 2446 | if (count($tree) == 0) { |
2449 | - $curTxt = &$current[$uid ++]; |
|
2447 | + $curTxt = &$current[$uid++]; |
|
2450 | 2448 | $inSplittedVar = true; |
2451 | 2449 | } |
2452 | 2450 | } elseif (($char === '.' || $char === '-') && count($tree) == 0 && $inSplittedVar) { |
2453 | - $curTxt = &$current[$uid ++]; |
|
2451 | + $curTxt = &$current[$uid++]; |
|
2454 | 2452 | $inSplittedVar = false; |
2455 | 2453 | } |
2456 | 2454 | |
@@ -2459,16 +2457,16 @@ discard block |
||
2459 | 2457 | unset($uid, $current, $curTxt, $tree, $chars); |
2460 | 2458 | |
2461 | 2459 | if ($this->debug) { |
2462 | - echo 'RECURSIVE VAR REPLACEMENT : ' . $key . "\n"; |
|
2460 | + echo 'RECURSIVE VAR REPLACEMENT : '.$key."\n"; |
|
2463 | 2461 | } |
2464 | 2462 | |
2465 | 2463 | $key = $this->flattenVarTree($parsed); |
2466 | 2464 | |
2467 | 2465 | if ($this->debug) { |
2468 | - echo 'RECURSIVE VAR REPLACEMENT DONE : ' . $key . "\n"; |
|
2466 | + echo 'RECURSIVE VAR REPLACEMENT DONE : '.$key."\n"; |
|
2469 | 2467 | } |
2470 | 2468 | |
2471 | - $output = preg_replace('#(^""\.|""\.|\.""$|(\()""\.|\.""(\)))#', '$2$3', '$this->readVar("' . $key . '")'); |
|
2469 | + $output = preg_replace('#(^""\.|""\.|\.""$|(\()""\.|\.""(\)))#', '$2$3', '$this->readVar("'.$key.'")'); |
|
2472 | 2470 | } else { |
2473 | 2471 | $output = $this->parseVarKey($key, $hasModifiers ? 'modifier' : $curBlock); |
2474 | 2472 | } |
@@ -2493,10 +2491,10 @@ discard block |
||
2493 | 2491 | if (substr($expMatch[2][$k], 0, 1) === '=') { |
2494 | 2492 | $assign = true; |
2495 | 2493 | if ($operator === '=') { |
2496 | - throw new CompilationException($this, 'Invalid expression <em>' . $substr . '</em>, can not use "==" in expressions'); |
|
2494 | + throw new CompilationException($this, 'Invalid expression <em>'.$substr.'</em>, can not use "==" in expressions'); |
|
2497 | 2495 | } |
2498 | 2496 | if ($curBlock !== 'root') { |
2499 | - throw new CompilationException($this, 'Invalid expression <em>' . $substr . '</em>, assignments can only be used in top level expressions like {$foo+=3} or {$foo="bar"}'); |
|
2497 | + throw new CompilationException($this, 'Invalid expression <em>'.$substr.'</em>, assignments can only be used in top level expressions like {$foo+=3} or {$foo="bar"}'); |
|
2500 | 2498 | } |
2501 | 2499 | $operator .= '='; |
2502 | 2500 | $expMatch[2][$k] = substr($expMatch[2][$k], 1); |
@@ -2507,22 +2505,22 @@ discard block |
||
2507 | 2505 | $expMatch[2][$k] = substr($expMatch[2][$k], 1); |
2508 | 2506 | } |
2509 | 2507 | if (($operator === '+' || $operator === '-') && $expMatch[2][$k] === $operator) { |
2510 | - $output = '(' . $output . $operator . $operator . ')'; |
|
2508 | + $output = '('.$output.$operator.$operator.')'; |
|
2511 | 2509 | break; |
2512 | 2510 | } elseif (substr($expMatch[2][$k], 0, 1) === '$') { |
2513 | - $output = '(' . $output . ' ' . $operator . ' ' . $this->parseVar($expMatch[2][$k], 0, strlen($expMatch[2][$k]), false, 'expression') . ')'; |
|
2511 | + $output = '('.$output.' '.$operator.' '.$this->parseVar($expMatch[2][$k], 0, strlen($expMatch[2][$k]), false, 'expression').')'; |
|
2514 | 2512 | } elseif (substr($expMatch[2][$k], 0, 1) === '%') { |
2515 | - $output = '(' . $output . ' ' . $operator . ' ' . $this->parseConst($expMatch[2][$k], 0, strlen($expMatch[2][$k]), false, 'expression') . ')'; |
|
2513 | + $output = '('.$output.' '.$operator.' '.$this->parseConst($expMatch[2][$k], 0, strlen($expMatch[2][$k]), false, 'expression').')'; |
|
2516 | 2514 | } elseif (!empty($expMatch[2][$k])) { |
2517 | - $output = '(' . $output . ' ' . $operator . ' ' . str_replace(',', '.', $expMatch[2][$k]) . ')'; |
|
2515 | + $output = '('.$output.' '.$operator.' '.str_replace(',', '.', $expMatch[2][$k]).')'; |
|
2518 | 2516 | } else { |
2519 | - throw new CompilationException($this, 'Unfinished expression <em>' . $substr . '</em>, missing var or number after math operator'); |
|
2517 | + throw new CompilationException($this, 'Unfinished expression <em>'.$substr.'</em>, missing var or number after math operator'); |
|
2520 | 2518 | } |
2521 | 2519 | } |
2522 | 2520 | } |
2523 | 2521 | |
2524 | 2522 | if ($this->autoEscape === true && $curBlock !== 'condition') { |
2525 | - $output = '(is_string($tmp=' . $output . ') ? htmlspecialchars($tmp, ENT_QUOTES, $this->charset) : $tmp)'; |
|
2523 | + $output = '(is_string($tmp='.$output.') ? htmlspecialchars($tmp, ENT_QUOTES, $this->charset) : $tmp)'; |
|
2526 | 2524 | } |
2527 | 2525 | |
2528 | 2526 | // handle modifiers |
@@ -2546,7 +2544,7 @@ discard block |
||
2546 | 2544 | } elseif ($curBlock === 'expression' || $curBlock === 'variable') { |
2547 | 2545 | return $output; |
2548 | 2546 | } elseif (isset($assign)) { |
2549 | - return self::PHP_OPEN . $output . ';' . self::PHP_CLOSE; |
|
2547 | + return self::PHP_OPEN.$output.';'.self::PHP_CLOSE; |
|
2550 | 2548 | } |
2551 | 2549 | |
2552 | 2550 | return $output; |
@@ -2554,7 +2552,7 @@ discard block |
||
2554 | 2552 | if ($curBlock === 'string' || $curBlock === 'delimited_string') { |
2555 | 2553 | return array(0, ''); |
2556 | 2554 | } |
2557 | - throw new CompilationException($this, 'Invalid variable name <em>' . $substr . '</em>'); |
|
2555 | + throw new CompilationException($this, 'Invalid variable name <em>'.$substr.'</em>'); |
|
2558 | 2556 | } |
2559 | 2557 | } |
2560 | 2558 | |
@@ -2608,16 +2606,16 @@ discard block |
||
2608 | 2606 | if (empty($methMatch[2])) { |
2609 | 2607 | // property |
2610 | 2608 | if ($curBlock === 'root') { |
2611 | - $output .= '->' . $methMatch[1]; |
|
2609 | + $output .= '->'.$methMatch[1]; |
|
2612 | 2610 | } else { |
2613 | - $output = '(($tmp = ' . $output . ') ? $tmp->' . $methMatch[1] . ' : null)'; |
|
2611 | + $output = '(($tmp = '.$output.') ? $tmp->'.$methMatch[1].' : null)'; |
|
2614 | 2612 | } |
2615 | 2613 | $ptr += strlen($methMatch[1]); |
2616 | 2614 | } else { |
2617 | 2615 | // method |
2618 | 2616 | if (substr($methMatch[2], 0, 2) === '()') { |
2619 | - $parsedCall = $methMatch[1] . '()'; |
|
2620 | - $ptr += strlen($methMatch[1]) + 2; |
|
2617 | + $parsedCall = $methMatch[1].'()'; |
|
2618 | + $ptr += strlen($methMatch[1])+2; |
|
2621 | 2619 | } else { |
2622 | 2620 | $parsedCall = $this->parseFunction($methodCall, $ptr, strlen($methodCall), false, 'method', $ptr); |
2623 | 2621 | } |
@@ -2626,15 +2624,15 @@ discard block |
||
2626 | 2624 | $method = strtolower(substr($parsedCall, 0, $argPos)); |
2627 | 2625 | $args = substr($parsedCall, $argPos); |
2628 | 2626 | if ($curBlock === 'root') { |
2629 | - $output = '$this->getSecurityPolicy()->callMethod($this, ' . $output . ', ' . var_export($method, true) . ', array' . $args . ')'; |
|
2627 | + $output = '$this->getSecurityPolicy()->callMethod($this, '.$output.', '.var_export($method, true).', array'.$args.')'; |
|
2630 | 2628 | } else { |
2631 | - $output = '(($tmp = ' . $output . ') ? $this->getSecurityPolicy()->callMethod($this, $tmp, ' . var_export($method, true) . ', array' . $args . ') : null)'; |
|
2629 | + $output = '(($tmp = '.$output.') ? $this->getSecurityPolicy()->callMethod($this, $tmp, '.var_export($method, true).', array'.$args.') : null)'; |
|
2632 | 2630 | } |
2633 | 2631 | } else { |
2634 | 2632 | if ($curBlock === 'root') { |
2635 | - $output .= '->' . $parsedCall; |
|
2633 | + $output .= '->'.$parsedCall; |
|
2636 | 2634 | } else { |
2637 | - $output = '(($tmp = ' . $output . ') ? $tmp->' . $parsedCall . ' : null)'; |
|
2635 | + $output = '(($tmp = '.$output.') ? $tmp->'.$parsedCall.' : null)'; |
|
2638 | 2636 | } |
2639 | 2637 | } |
2640 | 2638 | } |
@@ -2660,21 +2658,21 @@ discard block |
||
2660 | 2658 | return '$this->scope'; |
2661 | 2659 | } |
2662 | 2660 | if (substr($key, 0, 1) === '.') { |
2663 | - $key = 'dwoo' . $key; |
|
2661 | + $key = 'dwoo'.$key; |
|
2664 | 2662 | } |
2665 | 2663 | if (preg_match('#dwoo\.(get|post|server|cookies|session|env|request)((?:\.[a-z0-9_-]+)+)#i', $key, $m)) { |
2666 | 2664 | $global = strtoupper($m[1]); |
2667 | 2665 | if ($global === 'COOKIES') { |
2668 | 2666 | $global = 'COOKIE'; |
2669 | 2667 | } |
2670 | - $key = '$_' . $global; |
|
2668 | + $key = '$_'.$global; |
|
2671 | 2669 | foreach (explode('.', ltrim($m[2], '.')) as $part) { |
2672 | - $key .= '[' . var_export($part, true) . ']'; |
|
2670 | + $key .= '['.var_export($part, true).']'; |
|
2673 | 2671 | } |
2674 | 2672 | if ($curBlock === 'root') { |
2675 | 2673 | $output = $key; |
2676 | 2674 | } else { |
2677 | - $output = '(isset(' . $key . ')?' . $key . ':null)'; |
|
2675 | + $output = '(isset('.$key.')?'.$key.':null)'; |
|
2678 | 2676 | } |
2679 | 2677 | } elseif (preg_match('#dwoo\\.const\\.([a-z0-9\\\\_:]+)#i', $key, $m)) { |
2680 | 2678 | return $this->parseConstKey($m[1], $curBlock); |
@@ -2690,9 +2688,9 @@ discard block |
||
2690 | 2688 | $output = '$tmp_key'; |
2691 | 2689 | } else { |
2692 | 2690 | if ($curBlock === 'root') { |
2693 | - $output = '$this->scope["' . $key . '"]'; |
|
2691 | + $output = '$this->scope["'.$key.'"]'; |
|
2694 | 2692 | } else { |
2695 | - $output = '(isset($this->scope["' . $key . '"]) ? $this->scope["' . $key . '"] : null)'; |
|
2693 | + $output = '(isset($this->scope["'.$key.'"]) ? $this->scope["'.$key.'"] : null)'; |
|
2696 | 2694 | } |
2697 | 2695 | } |
2698 | 2696 | } else { |
@@ -2703,7 +2701,7 @@ discard block |
||
2703 | 2701 | $parentCnt = 0; |
2704 | 2702 | |
2705 | 2703 | while (true) { |
2706 | - ++ $parentCnt; |
|
2704 | + ++$parentCnt; |
|
2707 | 2705 | array_shift($m[2]); |
2708 | 2706 | array_shift($m[1]); |
2709 | 2707 | if (current($m[2]) === '_parent') { |
@@ -2712,7 +2710,7 @@ discard block |
||
2712 | 2710 | break; |
2713 | 2711 | } |
2714 | 2712 | |
2715 | - $output = '$this->readParentVar(' . $parentCnt . ')'; |
|
2713 | + $output = '$this->readParentVar('.$parentCnt.')'; |
|
2716 | 2714 | } else { |
2717 | 2715 | if ($i === 'dwoo') { |
2718 | 2716 | $output = '$this->globals'; |
@@ -2731,28 +2729,28 @@ discard block |
||
2731 | 2729 | while (count($m[1]) && $m[1][0] !== '->') { |
2732 | 2730 | $m[2][0] = preg_replace('/(^\\\([\'"])|\\\([\'"])$)/x', '$2$3', $m[2][0]); |
2733 | 2731 | if (substr($m[2][0], 0, 1) == '"' || substr($m[2][0], 0, 1) == "'") { |
2734 | - $output .= '[' . $m[2][0] . ']'; |
|
2732 | + $output .= '['.$m[2][0].']'; |
|
2735 | 2733 | } else { |
2736 | - $output .= '["' . $m[2][0] . '"]'; |
|
2734 | + $output .= '["'.$m[2][0].'"]'; |
|
2737 | 2735 | } |
2738 | 2736 | array_shift($m[2]); |
2739 | 2737 | array_shift($m[1]); |
2740 | 2738 | } |
2741 | 2739 | |
2742 | 2740 | if ($curBlock !== 'root') { |
2743 | - $output = '(isset(' . $output . ') ? ' . $output . ':null)'; |
|
2741 | + $output = '(isset('.$output.') ? '.$output.':null)'; |
|
2744 | 2742 | } |
2745 | 2743 | } |
2746 | 2744 | |
2747 | 2745 | if (count($m[2])) { |
2748 | 2746 | unset($m[0]); |
2749 | - $output = '$this->readVarInto(' . str_replace("\n", '', var_export($m, true)) . ', ' . $output . ', ' . ($curBlock == 'root' ? 'false' : 'true') . ')'; |
|
2747 | + $output = '$this->readVarInto('.str_replace("\n", '', var_export($m, true)).', '.$output.', '.($curBlock == 'root' ? 'false' : 'true').')'; |
|
2750 | 2748 | } |
2751 | 2749 | } |
2752 | 2750 | } else { |
2753 | 2751 | preg_match_all('#(\[|->|\.)?((?:[a-z0-9_]|-(?!>))+)\]?#i', $key, $m); |
2754 | 2752 | unset($m[0]); |
2755 | - $output = '$this->readVar(' . str_replace("\n", '', var_export($m, true)) . ')'; |
|
2753 | + $output = '$this->readVar('.str_replace("\n", '', var_export($m, true)).')'; |
|
2756 | 2754 | } |
2757 | 2755 | |
2758 | 2756 | return $output; |
@@ -2772,38 +2770,38 @@ discard block |
||
2772 | 2770 | $out = $recursed ? '".$this->readVarInto(' : ''; |
2773 | 2771 | foreach ($tree as $bit) { |
2774 | 2772 | if (is_array($bit)) { |
2775 | - $out .= '.' . $this->flattenVarTree($bit, false); |
|
2773 | + $out .= '.'.$this->flattenVarTree($bit, false); |
|
2776 | 2774 | } else { |
2777 | 2775 | $key = str_replace('"', '\\"', $bit); |
2778 | 2776 | |
2779 | 2777 | if (substr($key, 0, 1) === '$') { |
2780 | - $out .= '".' . $this->parseVar($key, 0, strlen($key), false, 'variable') . '."'; |
|
2778 | + $out .= '".'.$this->parseVar($key, 0, strlen($key), false, 'variable').'."'; |
|
2781 | 2779 | } else { |
2782 | 2780 | $cnt = substr_count($key, '$'); |
2783 | 2781 | |
2784 | 2782 | if ($this->debug) { |
2785 | - echo 'PARSING SUBVARS IN : ' . $key . "\n"; |
|
2783 | + echo 'PARSING SUBVARS IN : '.$key."\n"; |
|
2786 | 2784 | } |
2787 | 2785 | if ($cnt > 0) { |
2788 | - while (-- $cnt >= 0) { |
|
2786 | + while (--$cnt >= 0) { |
|
2789 | 2787 | if (isset($last)) { |
2790 | - $last = strrpos($key, '$', - (strlen($key) - $last + 1)); |
|
2788 | + $last = strrpos($key, '$', - (strlen($key)-$last+1)); |
|
2791 | 2789 | } else { |
2792 | 2790 | $last = strrpos($key, '$'); |
2793 | 2791 | } |
2794 | - preg_match('#\$[a-z0-9_]+((?:(?:\.|->)(?:[a-z0-9_]+|(?R))|\[(?:[a-z0-9_]+|(?R))\]))*' . '((?:(?:[+/*%-])(?:\$[a-z0-9.[\]>_:-]+(?:\([^)]*\))?|[0-9.,]*))*)#i', substr($key, $last), $submatch); |
|
2792 | + preg_match('#\$[a-z0-9_]+((?:(?:\.|->)(?:[a-z0-9_]+|(?R))|\[(?:[a-z0-9_]+|(?R))\]))*'.'((?:(?:[+/*%-])(?:\$[a-z0-9.[\]>_:-]+(?:\([^)]*\))?|[0-9.,]*))*)#i', substr($key, $last), $submatch); |
|
2795 | 2793 | |
2796 | 2794 | $len = strlen($submatch[0]); |
2797 | 2795 | $key = substr_replace( |
2798 | 2796 | $key, preg_replace_callback( |
2799 | - '#(\$[a-z0-9_]+((?:(?:\.|->)(?:[a-z0-9_]+|(?R))|\[(?:[a-z0-9_]+|(?R))\]))*)' . '((?:(?:[+/*%-])(?:\$[a-z0-9.[\]>_:-]+(?:\([^)]*\))?|[0-9.,]*))*)#i', array( |
|
2797 | + '#(\$[a-z0-9_]+((?:(?:\.|->)(?:[a-z0-9_]+|(?R))|\[(?:[a-z0-9_]+|(?R))\]))*)'.'((?:(?:[+/*%-])(?:\$[a-z0-9.[\]>_:-]+(?:\([^)]*\))?|[0-9.,]*))*)#i', array( |
|
2800 | 2798 | $this, |
2801 | 2799 | 'replaceVarKeyHelper' |
2802 | 2800 | ), substr($key, $last, $len) |
2803 | 2801 | ), $last, $len |
2804 | 2802 | ); |
2805 | 2803 | if ($this->debug) { |
2806 | - echo 'RECURSIVE VAR REPLACEMENT DONE : ' . $key . "\n"; |
|
2804 | + echo 'RECURSIVE VAR REPLACEMENT DONE : '.$key."\n"; |
|
2807 | 2805 | } |
2808 | 2806 | } |
2809 | 2807 | unset($last); |
@@ -2829,7 +2827,7 @@ discard block |
||
2829 | 2827 | */ |
2830 | 2828 | protected function replaceVarKeyHelper($match) |
2831 | 2829 | { |
2832 | - return '".' . $this->parseVar($match[0], 0, strlen($match[0]), false, 'variable') . '."'; |
|
2830 | + return '".'.$this->parseVar($match[0], 0, strlen($match[0]), false, 'variable').'."'; |
|
2833 | 2831 | } |
2834 | 2832 | |
2835 | 2833 | /** |
@@ -2849,7 +2847,7 @@ discard block |
||
2849 | 2847 | */ |
2850 | 2848 | protected function parseOthers($in, $from, $to, $parsingParams = false, $curBlock = '', &$pointer = null) |
2851 | 2849 | { |
2852 | - $substr = substr($in, $from, $to - $from); |
|
2850 | + $substr = substr($in, $from, $to-$from); |
|
2853 | 2851 | |
2854 | 2852 | $end = strlen($substr); |
2855 | 2853 | |
@@ -2923,48 +2921,48 @@ discard block |
||
2923 | 2921 | |
2924 | 2922 | if (strtolower($substr) === 'false' || strtolower($substr) === 'no' || strtolower($substr) === 'off') { |
2925 | 2923 | if ($this->debug) { |
2926 | - echo 'BOOLEAN(FALSE) PARSED' . "\n"; |
|
2924 | + echo 'BOOLEAN(FALSE) PARSED'."\n"; |
|
2927 | 2925 | } |
2928 | 2926 | $substr = 'false'; |
2929 | 2927 | $type = self::T_BOOL; |
2930 | 2928 | } elseif (strtolower($substr) === 'true' || strtolower($substr) === 'yes' || strtolower($substr) === 'on') { |
2931 | 2929 | if ($this->debug) { |
2932 | - echo 'BOOLEAN(TRUE) PARSED' . "\n"; |
|
2930 | + echo 'BOOLEAN(TRUE) PARSED'."\n"; |
|
2933 | 2931 | } |
2934 | 2932 | $substr = 'true'; |
2935 | 2933 | $type = self::T_BOOL; |
2936 | 2934 | } elseif ($substr === 'null' || $substr === 'NULL') { |
2937 | 2935 | if ($this->debug) { |
2938 | - echo 'NULL PARSED' . "\n"; |
|
2936 | + echo 'NULL PARSED'."\n"; |
|
2939 | 2937 | } |
2940 | 2938 | $substr = 'null'; |
2941 | 2939 | $type = self::T_NULL; |
2942 | 2940 | } elseif (is_numeric($substr)) { |
2943 | - $substr = (float)$substr; |
|
2944 | - if ((int)$substr == $substr) { |
|
2945 | - $substr = (int)$substr; |
|
2941 | + $substr = (float) $substr; |
|
2942 | + if ((int) $substr == $substr) { |
|
2943 | + $substr = (int) $substr; |
|
2946 | 2944 | } |
2947 | 2945 | $type = self::T_NUMERIC; |
2948 | 2946 | if ($this->debug) { |
2949 | - echo 'NUMBER (' . $substr . ') PARSED' . "\n"; |
|
2947 | + echo 'NUMBER ('.$substr.') PARSED'."\n"; |
|
2950 | 2948 | } |
2951 | 2949 | } elseif (preg_match('{^-?(\d+|\d*(\.\d+))\s*([/*%+-]\s*-?(\d+|\d*(\.\d+)))+$}', $substr)) { |
2952 | 2950 | if ($this->debug) { |
2953 | 2951 | echo 'SIMPLE MATH PARSED . "\n"'; |
2954 | 2952 | } |
2955 | 2953 | $type = self::T_MATH; |
2956 | - $substr = '(' . $substr . ')'; |
|
2954 | + $substr = '('.$substr.')'; |
|
2957 | 2955 | } elseif ($curBlock === 'condition' && array_search($substr, $breakChars, true) !== false) { |
2958 | 2956 | if ($this->debug) { |
2959 | - echo 'BREAKCHAR (' . $substr . ') PARSED' . "\n"; |
|
2957 | + echo 'BREAKCHAR ('.$substr.') PARSED'."\n"; |
|
2960 | 2958 | } |
2961 | 2959 | $type = self::T_BREAKCHAR; |
2962 | 2960 | //$substr = '"'.$substr.'"'; |
2963 | 2961 | } else { |
2964 | - $substr = $this->replaceStringVars('\'' . str_replace('\'', '\\\'', $substr) . '\'', '\'', $curBlock); |
|
2962 | + $substr = $this->replaceStringVars('\''.str_replace('\'', '\\\'', $substr).'\'', '\'', $curBlock); |
|
2965 | 2963 | $type = self::T_UNQUOTED_STRING; |
2966 | 2964 | if ($this->debug) { |
2967 | - echo 'BLABBER (' . $substr . ') CASTED AS STRING' . "\n"; |
|
2965 | + echo 'BLABBER ('.$substr.') CASTED AS STRING'."\n"; |
|
2968 | 2966 | } |
2969 | 2967 | } |
2970 | 2968 | |
@@ -2994,28 +2992,28 @@ discard block |
||
2994 | 2992 | { |
2995 | 2993 | $pos = 0; |
2996 | 2994 | if ($this->debug) { |
2997 | - echo 'STRING VAR REPLACEMENT : ' . $string . "\n"; |
|
2995 | + echo 'STRING VAR REPLACEMENT : '.$string."\n"; |
|
2998 | 2996 | } |
2999 | 2997 | // replace vars |
3000 | 2998 | while (($pos = strpos($string, '$', $pos)) !== false) { |
3001 | - $prev = substr($string, $pos - 1, 1); |
|
2999 | + $prev = substr($string, $pos-1, 1); |
|
3002 | 3000 | if ($prev === '\\') { |
3003 | - ++ $pos; |
|
3001 | + ++$pos; |
|
3004 | 3002 | continue; |
3005 | 3003 | } |
3006 | 3004 | |
3007 | 3005 | $var = $this->parse($string, $pos, null, false, ($curBlock === 'modifier' ? 'modifier' : ($prev === '`' ? 'delimited_string' : 'string'))); |
3008 | 3006 | $len = $var[0]; |
3009 | - $var = $this->parse(str_replace('\\' . $first, $first, $string), $pos, null, false, ($curBlock === 'modifier' ? 'modifier' : ($prev === '`' ? 'delimited_string' : 'string'))); |
|
3007 | + $var = $this->parse(str_replace('\\'.$first, $first, $string), $pos, null, false, ($curBlock === 'modifier' ? 'modifier' : ($prev === '`' ? 'delimited_string' : 'string'))); |
|
3010 | 3008 | |
3011 | - if ($prev === '`' && substr($string, $pos + $len, 1) === '`') { |
|
3012 | - $string = substr_replace($string, $first . '.' . $var[1] . '.' . $first, $pos - 1, $len + 2); |
|
3009 | + if ($prev === '`' && substr($string, $pos+$len, 1) === '`') { |
|
3010 | + $string = substr_replace($string, $first.'.'.$var[1].'.'.$first, $pos-1, $len+2); |
|
3013 | 3011 | } else { |
3014 | - $string = substr_replace($string, $first . '.' . $var[1] . '.' . $first, $pos, $len); |
|
3012 | + $string = substr_replace($string, $first.'.'.$var[1].'.'.$first, $pos, $len); |
|
3015 | 3013 | } |
3016 | - $pos += strlen($var[1]) + 2; |
|
3014 | + $pos += strlen($var[1])+2; |
|
3017 | 3015 | if ($this->debug) { |
3018 | - echo 'STRING VAR REPLACEMENT DONE : ' . $string . "\n"; |
|
3016 | + echo 'STRING VAR REPLACEMENT DONE : '.$string."\n"; |
|
3019 | 3017 | } |
3020 | 3018 | } |
3021 | 3019 | |
@@ -3051,7 +3049,7 @@ discard block |
||
3051 | 3049 | protected function replaceModifiers(array $m, $curBlock = null, &$pointer = null) |
3052 | 3050 | { |
3053 | 3051 | if ($this->debug) { |
3054 | - echo 'PARSING MODIFIERS : ' . $m[3] . "\n"; |
|
3052 | + echo 'PARSING MODIFIERS : '.$m[3]."\n"; |
|
3055 | 3053 | } |
3056 | 3054 | |
3057 | 3055 | if ($pointer !== null) { |
@@ -3075,7 +3073,7 @@ discard block |
||
3075 | 3073 | } |
3076 | 3074 | if ($cmdstrsrc[0] === ' ' || $cmdstrsrc[0] === ';' || substr($cmdstrsrc, 0, strlen($this->rd)) === $this->rd) { |
3077 | 3075 | if ($this->debug) { |
3078 | - echo 'MODIFIER PARSING ENDED, RIGHT DELIMITER or ";" FOUND' . "\n"; |
|
3076 | + echo 'MODIFIER PARSING ENDED, RIGHT DELIMITER or ";" FOUND'."\n"; |
|
3079 | 3077 | } |
3080 | 3078 | $continue = false; |
3081 | 3079 | if ($pointer !== null) { |
@@ -3086,7 +3084,7 @@ discard block |
||
3086 | 3084 | $cmdstr = $cmdstrsrc; |
3087 | 3085 | $paramsep = ':'; |
3088 | 3086 | if (!preg_match('/^(@{0,2}[a-z_][a-z0-9_]*)(:)?/i', $cmdstr, $match)) { |
3089 | - throw new CompilationException($this, 'Invalid modifier name, started with : ' . substr($cmdstr, 0, 10)); |
|
3087 | + throw new CompilationException($this, 'Invalid modifier name, started with : '.substr($cmdstr, 0, 10)); |
|
3090 | 3088 | } |
3091 | 3089 | $paramspos = !empty($match[2]) ? strlen($match[1]) : false; |
3092 | 3090 | $func = $match[1]; |
@@ -3096,10 +3094,10 @@ discard block |
||
3096 | 3094 | $cmdstrsrc = substr($cmdstrsrc, strlen($func)); |
3097 | 3095 | $params = array(); |
3098 | 3096 | if ($this->debug) { |
3099 | - echo 'MODIFIER (' . $func . ') CALLED WITH NO PARAMS' . "\n"; |
|
3097 | + echo 'MODIFIER ('.$func.') CALLED WITH NO PARAMS'."\n"; |
|
3100 | 3098 | } |
3101 | 3099 | } else { |
3102 | - $paramstr = substr($cmdstr, $paramspos + 1); |
|
3100 | + $paramstr = substr($cmdstr, $paramspos+1); |
|
3103 | 3101 | if (substr($paramstr, - 1, 1) === $paramsep) { |
3104 | 3102 | $paramstr = substr($paramstr, 0, - 1); |
3105 | 3103 | } |
@@ -3108,41 +3106,41 @@ discard block |
||
3108 | 3106 | $params = array(); |
3109 | 3107 | while ($ptr < strlen($paramstr)) { |
3110 | 3108 | if ($this->debug) { |
3111 | - echo 'MODIFIER (' . $func . ') START PARAM PARSING WITH POINTER AT ' . $ptr . "\n"; |
|
3109 | + echo 'MODIFIER ('.$func.') START PARAM PARSING WITH POINTER AT '.$ptr."\n"; |
|
3112 | 3110 | } |
3113 | 3111 | if ($this->debug) { |
3114 | - echo $paramstr . '--' . $ptr . '--' . strlen($paramstr) . '--modifier' . "\n"; |
|
3112 | + echo $paramstr.'--'.$ptr.'--'.strlen($paramstr).'--modifier'."\n"; |
|
3115 | 3113 | } |
3116 | 3114 | $params = $this->parse($paramstr, $ptr, strlen($paramstr), $params, 'modifier', $ptr); |
3117 | 3115 | if ($this->debug) { |
3118 | - echo 'PARAM PARSED, POINTER AT ' . $ptr . "\n"; |
|
3116 | + echo 'PARAM PARSED, POINTER AT '.$ptr."\n"; |
|
3119 | 3117 | } |
3120 | 3118 | |
3121 | 3119 | if ($ptr >= strlen($paramstr)) { |
3122 | 3120 | if ($this->debug) { |
3123 | - echo 'PARAM PARSING ENDED, PARAM STRING CONSUMED' . "\n"; |
|
3121 | + echo 'PARAM PARSING ENDED, PARAM STRING CONSUMED'."\n"; |
|
3124 | 3122 | } |
3125 | 3123 | break; |
3126 | 3124 | } |
3127 | 3125 | |
3128 | 3126 | if ($paramstr[$ptr] === ' ' || $paramstr[$ptr] === '|' || $paramstr[$ptr] === ';' || substr($paramstr, $ptr, strlen($this->rd)) === $this->rd) { |
3129 | 3127 | if ($this->debug) { |
3130 | - echo 'PARAM PARSING ENDED, " ", "|", RIGHT DELIMITER or ";" FOUND, POINTER AT ' . $ptr . "\n"; |
|
3128 | + echo 'PARAM PARSING ENDED, " ", "|", RIGHT DELIMITER or ";" FOUND, POINTER AT '.$ptr."\n"; |
|
3131 | 3129 | } |
3132 | 3130 | if ($paramstr[$ptr] !== '|') { |
3133 | 3131 | $continue = false; |
3134 | 3132 | if ($pointer !== null) { |
3135 | - $pointer -= strlen($paramstr) - $ptr; |
|
3133 | + $pointer -= strlen($paramstr)-$ptr; |
|
3136 | 3134 | } |
3137 | 3135 | } |
3138 | - ++ $ptr; |
|
3136 | + ++$ptr; |
|
3139 | 3137 | break; |
3140 | 3138 | } |
3141 | 3139 | if ($ptr < strlen($paramstr) && $paramstr[$ptr] === ':') { |
3142 | - ++ $ptr; |
|
3140 | + ++$ptr; |
|
3143 | 3141 | } |
3144 | 3142 | } |
3145 | - $cmdstrsrc = substr($cmdstrsrc, strlen($func) + 1 + $ptr); |
|
3143 | + $cmdstrsrc = substr($cmdstrsrc, strlen($func)+1+$ptr); |
|
3146 | 3144 | foreach ($params as $k => $p) { |
3147 | 3145 | if (is_array($p) && is_array($p[1])) { |
3148 | 3146 | $state |= 2; |
@@ -3182,9 +3180,9 @@ discard block |
||
3182 | 3180 | $params = self::implode_r($params); |
3183 | 3181 | |
3184 | 3182 | if ($mapped) { |
3185 | - $output = '$this->arrayMap(\'' . $func . '\', array(' . $params . '))'; |
|
3183 | + $output = '$this->arrayMap(\''.$func.'\', array('.$params.'))'; |
|
3186 | 3184 | } else { |
3187 | - $output = $func . '(' . $params . ')'; |
|
3185 | + $output = $func.'('.$params.')'; |
|
3188 | 3186 | } |
3189 | 3187 | } elseif ($pluginType & Core::PROXY_PLUGIN) { |
3190 | 3188 | $params = $this->mapParams($params, $this->getCore()->getPluginProxy()->getCallback($func), $state); |
@@ -3202,19 +3200,19 @@ discard block |
||
3202 | 3200 | $callback = $this->customPlugins[$func]['callback']; |
3203 | 3201 | if (is_array($callback)) { |
3204 | 3202 | if (is_object($callback[0])) { |
3205 | - $output = ($mapped ? '$this->arrayMap' : 'call_user_func_array') . '(array($this->getCustomPlugin(\'' . $func . '\'), \'' . $callback[1] . '\'), array(' . $params . '))'; |
|
3203 | + $output = ($mapped ? '$this->arrayMap' : 'call_user_func_array').'(array($this->getCustomPlugin(\''.$func.'\'), \''.$callback[1].'\'), array('.$params.'))'; |
|
3206 | 3204 | } else { |
3207 | - $output = ($mapped ? '$this->arrayMap' : 'call_user_func_array') . '(array(\'' . $callback[0] . '\', \'' . $callback[1] . '\'), array(' . $params . '))'; |
|
3205 | + $output = ($mapped ? '$this->arrayMap' : 'call_user_func_array').'(array(\''.$callback[0].'\', \''.$callback[1].'\'), array('.$params.'))'; |
|
3208 | 3206 | } |
3209 | 3207 | } elseif ($mapped) { |
3210 | - $output = '$this->arrayMap(\'' . $callback . '\', array(' . $params . '))'; |
|
3208 | + $output = '$this->arrayMap(\''.$callback.'\', array('.$params.'))'; |
|
3211 | 3209 | } else { |
3212 | - $output = $callback . '(' . $params . ')'; |
|
3210 | + $output = $callback.'('.$params.')'; |
|
3213 | 3211 | } |
3214 | 3212 | } elseif ($mapped) { |
3215 | - $output = '$this->arrayMap(\'smarty_modifier_' . $func . '\', array(' . $params . '))'; |
|
3213 | + $output = '$this->arrayMap(\'smarty_modifier_'.$func.'\', array('.$params.'))'; |
|
3216 | 3214 | } else { |
3217 | - $output = 'smarty_modifier_' . $func . '(' . $params . ')'; |
|
3215 | + $output = 'smarty_modifier_'.$func.'('.$params.')'; |
|
3218 | 3216 | } |
3219 | 3217 | } else { |
3220 | 3218 | if ($pluginType & Core::CUSTOM_PLUGIN) { |
@@ -3224,17 +3222,17 @@ discard block |
||
3224 | 3222 | $callback = array($pluginName, ($pluginType & Core::COMPILABLE_PLUGIN) ? 'compile' : 'process'); |
3225 | 3223 | } |
3226 | 3224 | } else { |
3227 | - if (class_exists('Plugin' . Core::toCamelCase($func)) !== false || function_exists('Plugin' . |
|
3228 | - Core::toCamelCase($func) . (($pluginType & Core::COMPILABLE_PLUGIN) ? 'Compile' : '')) |
|
3225 | + if (class_exists('Plugin'.Core::toCamelCase($func)) !== false || function_exists('Plugin'. |
|
3226 | + Core::toCamelCase($func).(($pluginType & Core::COMPILABLE_PLUGIN) ? 'Compile' : '')) |
|
3229 | 3227 | !== false) { |
3230 | - $pluginName = 'Plugin' . Core::toCamelCase($func); |
|
3228 | + $pluginName = 'Plugin'.Core::toCamelCase($func); |
|
3231 | 3229 | } else { |
3232 | - $pluginName = Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin' . Core::toCamelCase($func); |
|
3230 | + $pluginName = Core::NAMESPACE_PLUGINS_FUNCTIONS.'Plugin'.Core::toCamelCase($func); |
|
3233 | 3231 | } |
3234 | 3232 | if ($pluginType & Core::CLASS_PLUGIN) { |
3235 | 3233 | $callback = array($pluginName, ($pluginType & Core::COMPILABLE_PLUGIN) ? 'compile' : 'process'); |
3236 | 3234 | } else { |
3237 | - $callback = $pluginName . (($pluginType & Core::COMPILABLE_PLUGIN) ? 'Compile' : ''); |
|
3235 | + $callback = $pluginName.(($pluginType & Core::COMPILABLE_PLUGIN) ? 'Compile' : ''); |
|
3238 | 3236 | } |
3239 | 3237 | } |
3240 | 3238 | $params = $this->mapParams($params, $callback, $state); |
@@ -3252,10 +3250,10 @@ discard block |
||
3252 | 3250 | if ($pluginType & Core::CUSTOM_PLUGIN) { |
3253 | 3251 | $funcCompiler = $this->customPlugins[$func]['callback']; |
3254 | 3252 | } else { |
3255 | - if (function_exists('Plugin' . Core::toCamelCase($func) . 'Compile') !== false) { |
|
3256 | - $funcCompiler = 'Plugin' . Core::toCamelCase($func) . 'Compile'; |
|
3253 | + if (function_exists('Plugin'.Core::toCamelCase($func).'Compile') !== false) { |
|
3254 | + $funcCompiler = 'Plugin'.Core::toCamelCase($func).'Compile'; |
|
3257 | 3255 | } else { |
3258 | - $funcCompiler = Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin' . Core::toCamelCase($func) . |
|
3256 | + $funcCompiler = Core::NAMESPACE_PLUGINS_FUNCTIONS.'Plugin'.Core::toCamelCase($func). |
|
3259 | 3257 | 'Compile'; |
3260 | 3258 | } |
3261 | 3259 | } |
@@ -3266,9 +3264,9 @@ discard block |
||
3266 | 3264 | |
3267 | 3265 | $params = self::implode_r($params); |
3268 | 3266 | if ($mapped) { |
3269 | - $output = '$this->arrayMap(\'' . $pluginName . '\', array(' . $params . '))'; |
|
3267 | + $output = '$this->arrayMap(\''.$pluginName.'\', array('.$params.'))'; |
|
3270 | 3268 | } else { |
3271 | - $output = $pluginName . '(' . $params . ')'; |
|
3269 | + $output = $pluginName.'('.$params.')'; |
|
3272 | 3270 | } |
3273 | 3271 | } |
3274 | 3272 | } else { |
@@ -3280,7 +3278,7 @@ discard block |
||
3280 | 3278 | $callback = $this->customPlugins[$func]['callback']; |
3281 | 3279 | if (!is_array($callback)) { |
3282 | 3280 | if (!method_exists($callback, 'compile')) { |
3283 | - throw new Exception('Custom plugin ' . $func . ' must implement the "compile" method to be compilable, or you should provide a full callback to the method to use'); |
|
3281 | + throw new Exception('Custom plugin '.$func.' must implement the "compile" method to be compilable, or you should provide a full callback to the method to use'); |
|
3284 | 3282 | } |
3285 | 3283 | if (($ref = new ReflectionMethod($callback, 'compile')) && $ref->isStatic()) { |
3286 | 3284 | $funcCompiler = array($callback, 'compile'); |
@@ -3291,10 +3289,10 @@ discard block |
||
3291 | 3289 | $funcCompiler = $callback; |
3292 | 3290 | } |
3293 | 3291 | } else { |
3294 | - if (class_exists('Plugin' . Core::toCamelCase($func)) !== false) { |
|
3295 | - $funcCompiler = array('Plugin' . Core::toCamelCase($func), 'compile'); |
|
3292 | + if (class_exists('Plugin'.Core::toCamelCase($func)) !== false) { |
|
3293 | + $funcCompiler = array('Plugin'.Core::toCamelCase($func), 'compile'); |
|
3296 | 3294 | } else { |
3297 | - $funcCompiler = array(Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin' . Core::toCamelCase($func), 'compile'); |
|
3295 | + $funcCompiler = array(Core::NAMESPACE_PLUGINS_FUNCTIONS.'Plugin'.Core::toCamelCase($func), 'compile'); |
|
3298 | 3296 | } |
3299 | 3297 | array_unshift($params, $this); |
3300 | 3298 | } |
@@ -3305,26 +3303,26 @@ discard block |
||
3305 | 3303 | if ($pluginType & Core::CUSTOM_PLUGIN) { |
3306 | 3304 | if (is_object($callback[0])) { |
3307 | 3305 | if (is_array($this->getCore()->getCustomPlugin($func))) { |
3308 | - $output = ($mapped ? '$this->arrayMap' : 'call_user_func_array') . '(array($this->plugins[\'' . $func . '\'][\'callback\'][0], \'' . $callback[1] . '\'), array(' . $params . '))'; |
|
3306 | + $output = ($mapped ? '$this->arrayMap' : 'call_user_func_array').'(array($this->plugins[\''.$func.'\'][\'callback\'][0], \''.$callback[1].'\'), array('.$params.'))'; |
|
3309 | 3307 | } else { |
3310 | - $output = ($mapped ? '$this->arrayMap' : 'call_user_func_array') . '(array($this->getCustomPlugin(\'' . $func . '\'), \'' . $callback[1] . '\'), array(' . $params . '))'; |
|
3308 | + $output = ($mapped ? '$this->arrayMap' : 'call_user_func_array').'(array($this->getCustomPlugin(\''.$func.'\'), \''.$callback[1].'\'), array('.$params.'))'; |
|
3311 | 3309 | } |
3312 | 3310 | } else { |
3313 | - $output = ($mapped ? '$this->arrayMap' : 'call_user_func_array') . '(array(\'' . $callback[0] . '\', \'' . $callback[1] . '\'), array(' . $params . '))'; |
|
3311 | + $output = ($mapped ? '$this->arrayMap' : 'call_user_func_array').'(array(\''.$callback[0].'\', \''.$callback[1].'\'), array('.$params.'))'; |
|
3314 | 3312 | } |
3315 | 3313 | } elseif ($mapped) { |
3316 | 3314 | $output = '$this->arrayMap(array($this->getObjectPlugin(\''. |
3317 | - Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin' . Core::toCamelCase($func) . '\'), |
|
3318 | - \'process\'), array(' . $params . '))'; |
|
3315 | + Core::NAMESPACE_PLUGINS_FUNCTIONS.'Plugin'.Core::toCamelCase($func).'\'), |
|
3316 | + \'process\'), array(' . $params.'))'; |
|
3319 | 3317 | } else { |
3320 | - if (class_exists('Plugin' . Core::toCamelCase($func)) !== false) { |
|
3321 | - $output = '$this->classCall(\'Plugin' . Core::toCamelCase($func) . '\', array(' . $params . '))'; |
|
3322 | - } elseif (class_exists(Core::NAMESPACE_PLUGINS_BLOCKS . 'Plugin' . Core::toCamelCase($func)) !== false) { |
|
3323 | - $output = '$this->classCall(\'' . Core::NAMESPACE_PLUGINS_BLOCKS . 'Plugin' . $func . '\', array(' . $params . '))'; |
|
3324 | - } elseif (class_exists(Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin' . Core::toCamelCase($func)) !== false) { |
|
3325 | - $output = '$this->classCall(\'' . Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin' . $func . '\', array(' . $params . '))'; |
|
3318 | + if (class_exists('Plugin'.Core::toCamelCase($func)) !== false) { |
|
3319 | + $output = '$this->classCall(\'Plugin'.Core::toCamelCase($func).'\', array('.$params.'))'; |
|
3320 | + } elseif (class_exists(Core::NAMESPACE_PLUGINS_BLOCKS.'Plugin'.Core::toCamelCase($func)) !== false) { |
|
3321 | + $output = '$this->classCall(\''.Core::NAMESPACE_PLUGINS_BLOCKS.'Plugin'.$func.'\', array('.$params.'))'; |
|
3322 | + } elseif (class_exists(Core::NAMESPACE_PLUGINS_FUNCTIONS.'Plugin'.Core::toCamelCase($func)) !== false) { |
|
3323 | + $output = '$this->classCall(\''.Core::NAMESPACE_PLUGINS_FUNCTIONS.'Plugin'.$func.'\', array('.$params.'))'; |
|
3326 | 3324 | } else { |
3327 | - $output = '$this->classCall(\'' . $func . '\', array(' . $params . '))'; |
|
3325 | + $output = '$this->classCall(\''.$func.'\', array('.$params.'))'; |
|
3328 | 3326 | } |
3329 | 3327 | } |
3330 | 3328 | } |
@@ -3337,7 +3335,7 @@ discard block |
||
3337 | 3335 | } elseif ($curBlock === 'var' || $m[1] === null) { |
3338 | 3336 | return $output; |
3339 | 3337 | } elseif ($curBlock === 'string' || $curBlock === 'root') { |
3340 | - return $m[1] . '.' . $output . '.' . $m[1] . (isset($add) ? $add : null); |
|
3338 | + return $m[1].'.'.$output.'.'.$m[1].(isset($add) ? $add : null); |
|
3341 | 3339 | } |
3342 | 3340 | |
3343 | 3341 | return ''; |
@@ -3360,14 +3358,14 @@ discard block |
||
3360 | 3358 | if (is_array($p)) { |
3361 | 3359 | $out2 = 'array('; |
3362 | 3360 | foreach ($p as $k2 => $v) { |
3363 | - $out2 .= var_export($k2, true) . ' => ' . (is_array($v) ? 'array(' . self::implode_r($v, true) . ')' : $v) . ', '; |
|
3361 | + $out2 .= var_export($k2, true).' => '.(is_array($v) ? 'array('.self::implode_r($v, true).')' : $v).', '; |
|
3364 | 3362 | } |
3365 | - $p = rtrim($out2, ', ') . ')'; |
|
3363 | + $p = rtrim($out2, ', ').')'; |
|
3366 | 3364 | } |
3367 | 3365 | if ($recursiveCall) { |
3368 | - $out .= var_export($k, true) . ' => ' . $p . ', '; |
|
3366 | + $out .= var_export($k, true).' => '.$p.', '; |
|
3369 | 3367 | } else { |
3370 | - $out .= $p . ', '; |
|
3368 | + $out .= $p.', '; |
|
3371 | 3369 | } |
3372 | 3370 | } |
3373 | 3371 | |
@@ -3391,7 +3389,7 @@ discard block |
||
3391 | 3389 | if (($this->securityPolicy === null && (function_exists($name) || strtolower($name) === 'isset' || strtolower($name) === 'empty')) || ($this->securityPolicy !== null && array_key_exists(strtolower($name), $this->securityPolicy->getAllowedPhpFunctions()) !== false)) { |
3392 | 3390 | $phpFunc = true; |
3393 | 3391 | } elseif ($this->securityPolicy !== null && function_exists($name) && array_key_exists(strtolower($name), $this->securityPolicy->getAllowedPhpFunctions()) === false) { |
3394 | - throw new SecurityException('Call to a disallowed php function : ' . $name); |
|
3392 | + throw new SecurityException('Call to a disallowed php function : '.$name); |
|
3395 | 3393 | } |
3396 | 3394 | |
3397 | 3395 | while ($pluginType <= 0) { |
@@ -3402,58 +3400,58 @@ discard block |
||
3402 | 3400 | elseif (isset($this->customPlugins[$name])) { |
3403 | 3401 | $pluginType = $this->customPlugins[$name]['type'] | Core::CUSTOM_PLUGIN; |
3404 | 3402 | } // Class blocks plugin |
3405 | - elseif (class_exists(Core::NAMESPACE_PLUGINS_BLOCKS . 'Plugin' . Core::toCamelCase($name)) !== false) { |
|
3403 | + elseif (class_exists(Core::NAMESPACE_PLUGINS_BLOCKS.'Plugin'.Core::toCamelCase($name)) !== false) { |
|
3406 | 3404 | $pluginType = Core::CLASS_PLUGIN; |
3407 | - if (is_subclass_of(Core::NAMESPACE_PLUGINS_BLOCKS . 'Plugin' . Core::toCamelCase($name), 'Dwoo\Block\Plugin')) { |
|
3405 | + if (is_subclass_of(Core::NAMESPACE_PLUGINS_BLOCKS.'Plugin'.Core::toCamelCase($name), 'Dwoo\Block\Plugin')) { |
|
3408 | 3406 | $pluginType += Core::BLOCK_PLUGIN; |
3409 | 3407 | } |
3410 | - $interfaces = class_implements(Core::NAMESPACE_PLUGINS_BLOCKS . 'Plugin' . Core::toCamelCase($name)); |
|
3408 | + $interfaces = class_implements(Core::NAMESPACE_PLUGINS_BLOCKS.'Plugin'.Core::toCamelCase($name)); |
|
3411 | 3409 | if (in_array('Dwoo\ICompilable', $interfaces) !== false || in_array('Dwoo\ICompilable\Block', $interfaces) !== false) { |
3412 | 3410 | $pluginType |= Core::COMPILABLE_PLUGIN; |
3413 | 3411 | } |
3414 | 3412 | } // Class functions plugin |
3415 | - elseif (class_exists(Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin' . Core::toCamelCase($name)) !== false) { |
|
3416 | - $pluginType = Core::FUNC_PLUGIN + Core::CLASS_PLUGIN; |
|
3417 | - $interfaces = class_implements(Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin' . Core::toCamelCase($name)); |
|
3413 | + elseif (class_exists(Core::NAMESPACE_PLUGINS_FUNCTIONS.'Plugin'.Core::toCamelCase($name)) !== false) { |
|
3414 | + $pluginType = Core::FUNC_PLUGIN+Core::CLASS_PLUGIN; |
|
3415 | + $interfaces = class_implements(Core::NAMESPACE_PLUGINS_FUNCTIONS.'Plugin'.Core::toCamelCase($name)); |
|
3418 | 3416 | if (in_array('Dwoo\ICompilable', $interfaces) !== false || in_array('Dwoo\ICompilable\Block', $interfaces) !== false) { |
3419 | 3417 | $pluginType |= Core::COMPILABLE_PLUGIN; |
3420 | 3418 | } |
3421 | 3419 | } // Class without namespace |
3422 | - elseif (class_exists('Plugin' . Core::toCamelCase($name)) !== false) { |
|
3420 | + elseif (class_exists('Plugin'.Core::toCamelCase($name)) !== false) { |
|
3423 | 3421 | $pluginType = Core::CLASS_PLUGIN; |
3424 | - $interfaces = class_implements('Plugin' . Core::toCamelCase($name)); |
|
3422 | + $interfaces = class_implements('Plugin'.Core::toCamelCase($name)); |
|
3425 | 3423 | if (in_array('Dwoo\ICompilable', $interfaces) !== false || in_array('Dwoo\ICompilable\Block', $interfaces) !== false) { |
3426 | 3424 | $pluginType |= Core::COMPILABLE_PLUGIN; |
3427 | 3425 | } |
3428 | 3426 | } // Function plugin (with/without namespaces) |
3429 | - elseif (function_exists(Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin' . Core::toCamelCase ($name)) !== |
|
3430 | - false || function_exists('Plugin' . Core::toCamelCase($name)) !== false) { |
|
3427 | + elseif (function_exists(Core::NAMESPACE_PLUGINS_FUNCTIONS.'Plugin'.Core::toCamelCase($name)) !== |
|
3428 | + false || function_exists('Plugin'.Core::toCamelCase($name)) !== false) { |
|
3431 | 3429 | $pluginType = Core::FUNC_PLUGIN; |
3432 | 3430 | } // Function plugin compile (with/without namespaces) |
3433 | - elseif (function_exists(Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin' . Core::toCamelCase($name) . |
|
3434 | - 'Compile') !== false || function_exists('Plugin' . Core::toCamelCase($name) . 'Compile') !== |
|
3431 | + elseif (function_exists(Core::NAMESPACE_PLUGINS_FUNCTIONS.'Plugin'.Core::toCamelCase($name). |
|
3432 | + 'Compile') !== false || function_exists('Plugin'.Core::toCamelCase($name).'Compile') !== |
|
3435 | 3433 | false) { |
3436 | 3434 | $pluginType = Core::FUNC_PLUGIN | Core::COMPILABLE_PLUGIN; |
3437 | 3435 | } // Helper plugin class compile |
3438 | - elseif (class_exists(Core::NAMESPACE_PLUGINS_HELPERS . 'Plugin' . Core::toCamelCase($name)) !== false) { |
|
3436 | + elseif (class_exists(Core::NAMESPACE_PLUGINS_HELPERS.'Plugin'.Core::toCamelCase($name)) !== false) { |
|
3439 | 3437 | $pluginType = Core::CLASS_PLUGIN | Core::COMPILABLE_PLUGIN; |
3440 | 3438 | } // Helper plugin function compile |
3441 | - elseif (function_exists(Core::NAMESPACE_PLUGINS_HELPERS . 'Plugin' . Core::toCamelCase($name) . 'Compile') !== false) { |
|
3439 | + elseif (function_exists(Core::NAMESPACE_PLUGINS_HELPERS.'Plugin'.Core::toCamelCase($name).'Compile') !== false) { |
|
3442 | 3440 | $pluginType = Core::FUNC_PLUGIN | Core::COMPILABLE_PLUGIN; |
3443 | 3441 | } // Smarty modifier |
3444 | - elseif (function_exists('smarty_modifier_' . $name) !== false) { |
|
3442 | + elseif (function_exists('smarty_modifier_'.$name) !== false) { |
|
3445 | 3443 | $pluginType = Core::SMARTY_MODIFIER; |
3446 | 3444 | } // Smarty function |
3447 | - elseif (function_exists('smarty_function_' . $name) !== false) { |
|
3445 | + elseif (function_exists('smarty_function_'.$name) !== false) { |
|
3448 | 3446 | $pluginType = Core::SMARTY_FUNCTION; |
3449 | 3447 | } // Smarty block |
3450 | - elseif (function_exists('smarty_block_' . $name) !== false) { |
|
3448 | + elseif (function_exists('smarty_block_'.$name) !== false) { |
|
3451 | 3449 | $pluginType = Core::SMARTY_BLOCK; |
3452 | 3450 | } // Everything else |
3453 | 3451 | else { |
3454 | 3452 | if ($pluginType === - 1) { |
3455 | 3453 | try { |
3456 | - $this->getCore()->getLoader()->loadPlugin('Plugin' . Core::toCamelCase($name)); |
|
3454 | + $this->getCore()->getLoader()->loadPlugin('Plugin'.Core::toCamelCase($name)); |
|
3457 | 3455 | } |
3458 | 3456 | catch (Exception $e) { |
3459 | 3457 | if (isset($phpFunc)) { |
@@ -3466,9 +3464,9 @@ discard block |
||
3466 | 3464 | } |
3467 | 3465 | } |
3468 | 3466 | } else { |
3469 | - throw new Exception('Plugin "' . $name . '" could not be found, type:' . $pluginType); |
|
3467 | + throw new Exception('Plugin "'.$name.'" could not be found, type:'.$pluginType); |
|
3470 | 3468 | } |
3471 | - ++ $pluginType; |
|
3469 | + ++$pluginType; |
|
3472 | 3470 | } |
3473 | 3471 | } |
3474 | 3472 | |
@@ -3537,15 +3535,15 @@ discard block |
||
3537 | 3535 | } |
3538 | 3536 | |
3539 | 3537 | // loops over the param map and assigns values from the template or default value for unset optional params |
3540 | - foreach ($map as $k => $v){ |
|
3538 | + foreach ($map as $k => $v) { |
|
3541 | 3539 | if ($v[0] === '*') { |
3542 | 3540 | // "rest" array parameter, fill every remaining params in it and then break |
3543 | 3541 | if (count($ps) === 0) { |
3544 | 3542 | if ($v[1] === false) { |
3545 | 3543 | throw new CompilationException( |
3546 | - $this, 'Rest argument missing for ' . str_replace( |
|
3544 | + $this, 'Rest argument missing for '.str_replace( |
|
3547 | 3545 | array( |
3548 | - Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin', |
|
3546 | + Core::NAMESPACE_PLUGINS_FUNCTIONS.'Plugin', |
|
3549 | 3547 | 'Compile' |
3550 | 3548 | ), '', (is_array($callback) ? $callback[0] : $callback) |
3551 | 3549 | ) |
@@ -3578,7 +3576,7 @@ discard block |
||
3578 | 3576 | // parameter is not defined and not optional, throw error |
3579 | 3577 | if (is_array($callback)) { |
3580 | 3578 | if (is_object($callback[0])) { |
3581 | - $name = get_class($callback[0]) . '::' . $callback[1]; |
|
3579 | + $name = get_class($callback[0]).'::'.$callback[1]; |
|
3582 | 3580 | } else { |
3583 | 3581 | $name = $callback[0]; |
3584 | 3582 | } |
@@ -3587,9 +3585,9 @@ discard block |
||
3587 | 3585 | } |
3588 | 3586 | |
3589 | 3587 | throw new CompilationException( |
3590 | - $this, 'Argument ' . $k . '/' . $v[0] . ' missing for ' . str_replace( |
|
3588 | + $this, 'Argument '.$k.'/'.$v[0].' missing for '.str_replace( |
|
3591 | 3589 | array( |
3592 | - Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin', |
|
3590 | + Core::NAMESPACE_PLUGINS_FUNCTIONS.'Plugin', |
|
3593 | 3591 | 'Compile' |
3594 | 3592 | ), '', $name |
3595 | 3593 | ) |