@@ -89,7 +89,7 @@ |
||
89 | 89 | * |
90 | 90 | * @param string $sTemplate |
91 | 91 | * @param boolean $return |
92 | - * @return mixed |
|
92 | + * @return null|string |
|
93 | 93 | */ |
94 | 94 | public function display($sTemplate, $return = FALSE) { |
95 | 95 | // Start benchmark |
@@ -97,14 +97,14 @@ |
||
97 | 97 | $CI->benchmark->mark('dwoo_parse_start'); |
98 | 98 | |
99 | 99 | // Check if file exists |
100 | - if ( !file_exists($this->template_dir . $sTemplate ) ) { |
|
100 | + if (!file_exists($this->template_dir.$sTemplate)) { |
|
101 | 101 | $message = sprintf('Template file \'%s\' not found.', $sTemplate); |
102 | 102 | show_error($message); |
103 | 103 | log_message('error', $message); |
104 | 104 | } |
105 | 105 | |
106 | 106 | // Create new template |
107 | - $tpl = new Dwoo_Template_File($this->template_dir . $sTemplate); |
|
107 | + $tpl = new Dwoo_Template_File($this->template_dir.$sTemplate); |
|
108 | 108 | |
109 | 109 | // render the template |
110 | 110 | $template = $this->get($tpl, $this->dwoo_data); |
@@ -28,7 +28,7 @@ |
||
28 | 28 | /** |
29 | 29 | * Dwoo_Adapters_ZendFramework_PluginProxy's constructor. |
30 | 30 | * |
31 | - * @param Zend_View_Interface $view |
|
31 | + * @param Dwoo_Adapters_ZendFramework_View $view |
|
32 | 32 | */ |
33 | 33 | public function __construct(Zend_View_Interface $view) { |
34 | 34 | $this->view = $view; |
@@ -59,7 +59,7 @@ |
||
59 | 59 | * @return string |
60 | 60 | */ |
61 | 61 | public function getCode($name, $params) { |
62 | - return '$this->getPluginProxy()->view->'. $name .'('.Dwoo_Compiler::implode_r($params).')'; |
|
62 | + return '$this->getPluginProxy()->view->'.$name.'('.Dwoo_Compiler::implode_r($params).')'; |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | /** |
@@ -87,7 +87,6 @@ discard block |
||
87 | 87 | * - type class name or object for engine, dataProvider or compiler |
88 | 88 | * - any set* method (compileDir for setCompileDir ...) |
89 | 89 | * |
90 | - * @param array $options |
|
91 | 90 | * @return Dwoo_Adapters_ZendFramework_View |
92 | 91 | */ |
93 | 92 | public function setOptions(array $opt = array()) |
@@ -272,6 +271,7 @@ discard block |
||
272 | 271 | * Sets Dwoo data object |
273 | 272 | * |
274 | 273 | * @param string|Dwoo_Data Object or name of the class |
274 | + * @param Dwoo_Data $data |
|
275 | 275 | */ |
276 | 276 | public function setDataProvider($data) |
277 | 277 | { |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | /** |
330 | 330 | * Return the Dwoo compiler object |
331 | 331 | * |
332 | - * @return Dwoo_Data |
|
332 | + * @return Dwoo_Compiler |
|
333 | 333 | */ |
334 | 334 | public function getCompiler() |
335 | 335 | { |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | * Clears all variables assigned to Zend_View either via {@link assign()} or |
405 | 405 | * property overloading ({@link __get()}/{@link __set()}). |
406 | 406 | * |
407 | - * @return void |
|
407 | + * @return Dwoo_Adapters_ZendFramework_View |
|
408 | 408 | * @return Dwoo_Adapters_ZendFramework_View |
409 | 409 | */ |
410 | 410 | public function clearVars() |
@@ -431,7 +431,6 @@ discard block |
||
431 | 431 | * Processes a view script and outputs it. Output is then |
432 | 432 | * passed through filters. |
433 | 433 | * |
434 | - * @param string $name The script script name to process. |
|
435 | 434 | * @return string The script output. |
436 | 435 | */ |
437 | 436 | public function _run() |
@@ -97,26 +97,26 @@ discard block |
||
97 | 97 | |
98 | 98 | // Setting options to Dwoo objects... |
99 | 99 | foreach ($opt as $type => $settings) { |
100 | - if (!method_exists($this, 'set' . $type)) { |
|
100 | + if (!method_exists($this, 'set'.$type)) { |
|
101 | 101 | throw new Dwoo_Exception("Unknown type $type"); |
102 | 102 | } |
103 | 103 | |
104 | 104 | if (is_string($settings) || is_object($settings)) { |
105 | - call_user_func(array($this, 'set' . $type), $settings); |
|
105 | + call_user_func(array($this, 'set'.$type), $settings); |
|
106 | 106 | } elseif (is_array($settings)) { |
107 | 107 | // Set requested class |
108 | 108 | if (array_key_exists('type', $settings)) { |
109 | - call_user_func(array($this, 'set' . $type), $settings['type']); |
|
109 | + call_user_func(array($this, 'set'.$type), $settings['type']); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | if (in_array($type, $classes)) { |
113 | 113 | // Call get so that the class is initialized |
114 | - $rel = call_user_func(array($this, 'get' . $type)); |
|
114 | + $rel = call_user_func(array($this, 'get'.$type)); |
|
115 | 115 | |
116 | 116 | // Call set*() methods so that all the settings are set. |
117 | 117 | foreach ($settings as $method => $value) { |
118 | - if (method_exists($rel, 'set' . $method)) { |
|
119 | - call_user_func(array($rel, 'set' . $method), $value); |
|
118 | + if (method_exists($rel, 'set'.$method)) { |
|
119 | + call_user_func(array($rel, 'set'.$method), $value); |
|
120 | 120 | } |
121 | 121 | } |
122 | 122 | } elseif ('templateFile' == $type) { |
@@ -356,8 +356,8 @@ discard block |
||
356 | 356 | } |
357 | 357 | |
358 | 358 | foreach ($this->_templateFileSettings as $method => $value) { |
359 | - if (method_exists($dwooTemplateFile, 'set' . $method)) { |
|
360 | - call_user_func(array($dwooTemplateFile, 'set' . $method), $value); |
|
359 | + if (method_exists($dwooTemplateFile, 'set'.$method)) { |
|
360 | + call_user_func(array($dwooTemplateFile, 'set'.$method), $value); |
|
361 | 361 | } |
362 | 362 | } |
363 | 363 |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | /** |
271 | 271 | * returns the left and right template delimiters |
272 | 272 | * |
273 | - * @return array containing the left and the right delimiters |
|
273 | + * @return string[] containing the left and the right delimiters |
|
274 | 274 | */ |
275 | 275 | public function getDelimiters() |
276 | 276 | { |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | * adds a preprocessor to the compiler, it will be called |
359 | 359 | * before the template is compiled |
360 | 360 | * |
361 | - * @param mixed $callback either a valid callback to the preprocessor or a simple name if the autoload is set to true |
|
361 | + * @param string $callback either a valid callback to the preprocessor or a simple name if the autoload is set to true |
|
362 | 362 | * @param bool $autoload if set to true, the preprocessor is auto-loaded from one of the plugin directories, else you must provide a valid callback |
363 | 363 | */ |
364 | 364 | public function addPreProcessor($callback, $autoload = false) |
@@ -685,7 +685,6 @@ discard block |
||
685 | 685 | /** |
686 | 686 | * compiles the provided string down to php code |
687 | 687 | * |
688 | - * @param string $tpl the template to compile |
|
689 | 688 | * @return string a compiled php string |
690 | 689 | */ |
691 | 690 | public function compile(Dwoo_Core $dwoo, Dwoo_ITemplate $template) |
@@ -1215,7 +1214,7 @@ discard block |
||
1215 | 1214 | * returns the token of each parameter out of the given parameter array |
1216 | 1215 | * |
1217 | 1216 | * @param array $params parameter array |
1218 | - * @return array tokens |
|
1217 | + * @return Dwoo_Compiler tokens |
|
1219 | 1218 | */ |
1220 | 1219 | public function getParamTokens(array $params) |
1221 | 1220 | { |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | } elseif (($index = array_search('Dwoo_Processor_'.str_replace('Dwoo_Processor_', '', $callback), $this->processors['pre'], true)) !== false) { |
394 | 394 | unset($this->processors['pre'][$index]); |
395 | 395 | } else { |
396 | - $class = 'Dwoo_Processor_' . str_replace('Dwoo_Processor_', '', $callback); |
|
396 | + $class = 'Dwoo_Processor_'.str_replace('Dwoo_Processor_', '', $callback); |
|
397 | 397 | foreach ($this->processors['pre'] as $index=>$proc) { |
398 | 398 | if (is_array($proc) && ($proc[0] instanceof $class) || (isset($proc['class']) && $proc['class'] == $class)) { |
399 | 399 | unset($this->processors['pre'][$index]); |
@@ -441,8 +441,8 @@ discard block |
||
441 | 441 | unset($this->processors['post'][$index]); |
442 | 442 | } elseif (($index = array_search('Dwoo_Processor_'.str_replace('Dwoo_Processor_', '', $callback), $this->processors['post'], true)) !== false) { |
443 | 443 | unset($this->processors['post'][$index]); |
444 | - } else { |
|
445 | - $class = 'Dwoo_Processor_' . str_replace('Dwoo_Processor_', '', $callback); |
|
444 | + } else { |
|
445 | + $class = 'Dwoo_Processor_'.str_replace('Dwoo_Processor_', '', $callback); |
|
446 | 446 | foreach ($this->processors['post'] as $index=>$proc) { |
447 | 447 | if (is_array($proc) && ($proc[0] instanceof $class) || (isset($proc['class']) && $proc['class'] == $class)) { |
448 | 448 | unset($this->processors['post'][$index]); |
@@ -648,7 +648,7 @@ discard block |
||
648 | 648 | public function setTemplateSource($newSource, $fromPointer = false) |
649 | 649 | { |
650 | 650 | if ($fromPointer === true) { |
651 | - $this->templateSource = substr($this->templateSource, 0, $this->pointer) . $newSource; |
|
651 | + $this->templateSource = substr($this->templateSource, 0, $this->pointer).$newSource; |
|
652 | 652 | } else { |
653 | 653 | $this->templateSource = $newSource; |
654 | 654 | } |
@@ -695,16 +695,16 @@ discard block |
||
695 | 695 | $ptr = 0; |
696 | 696 | $this->dwoo = $dwoo; |
697 | 697 | $this->template = $template; |
698 | - $this->templateSource =& $tpl; |
|
699 | - $this->pointer =& $ptr; |
|
698 | + $this->templateSource = & $tpl; |
|
699 | + $this->pointer = & $ptr; |
|
700 | 700 | |
701 | 701 | while (true) { |
702 | 702 | // if pointer is at the beginning, reset everything, that allows a plugin to externally reset the compiler if everything must be reparsed |
703 | - if ($ptr===0) { |
|
703 | + if ($ptr === 0) { |
|
704 | 704 | // resets variables |
705 | 705 | $this->usedPlugins = array(); |
706 | 706 | $this->data = array(); |
707 | - $this->scope =& $this->data; |
|
707 | + $this->scope = & $this->data; |
|
708 | 708 | $this->scopeTree = array(); |
709 | 709 | $this->stack = array(); |
710 | 710 | $this->line = 1; |
@@ -739,7 +739,7 @@ discard block |
||
739 | 739 | if (ini_get('short_open_tags')) { |
740 | 740 | $search = array('{<\?.*?\?>}', '{<%.*?%>}'); |
741 | 741 | } |
742 | - switch($this->securityPolicy->getPhpHandling()) { |
|
742 | + switch ($this->securityPolicy->getPhpHandling()) { |
|
743 | 743 | |
744 | 744 | case Dwoo_Security_Policy::PHP_ALLOW: |
745 | 745 | break; |
@@ -759,14 +759,14 @@ discard block |
||
759 | 759 | $this->push(substr($tpl, $ptr), 0); |
760 | 760 | break; |
761 | 761 | } elseif (substr($tpl, $pos-1, 1) === '\\' && substr($tpl, $pos-2, 1) !== '\\') { |
762 | - $this->push(substr($tpl, $ptr, $pos-$ptr-1) . $this->ld); |
|
762 | + $this->push(substr($tpl, $ptr, $pos-$ptr-1).$this->ld); |
|
763 | 763 | $ptr = $pos+strlen($this->ld); |
764 | - } elseif (preg_match('/^'.$this->ldr . ($this->allowLooseOpenings ? '\s*' : '') . 'literal' . ($this->allowLooseOpenings ? '\s*' : '') . $this->rdr.'/s', substr($tpl, $pos), $litOpen)) { |
|
765 | - if (!preg_match('/'.$this->ldr . ($this->allowLooseOpenings ? '\s*' : '') . '\/literal' . ($this->allowLooseOpenings ? '\s*' : '') . $this->rdr.'/s', $tpl, $litClose, PREG_OFFSET_CAPTURE, $pos)) { |
|
764 | + } elseif (preg_match('/^'.$this->ldr.($this->allowLooseOpenings ? '\s*' : '').'literal'.($this->allowLooseOpenings ? '\s*' : '').$this->rdr.'/s', substr($tpl, $pos), $litOpen)) { |
|
765 | + if (!preg_match('/'.$this->ldr.($this->allowLooseOpenings ? '\s*' : '').'\/literal'.($this->allowLooseOpenings ? '\s*' : '').$this->rdr.'/s', $tpl, $litClose, PREG_OFFSET_CAPTURE, $pos)) { |
|
766 | 766 | throw new Dwoo_Compilation_Exception($this, 'The {literal} blocks must be closed explicitly with {/literal}'); |
767 | 767 | } |
768 | 768 | $endpos = $litClose[0][1]; |
769 | - $this->push(substr($tpl, $ptr, $pos-$ptr) . substr($tpl, $pos + strlen($litOpen[0]), $endpos-$pos-strlen($litOpen[0]))); |
|
769 | + $this->push(substr($tpl, $ptr, $pos-$ptr).substr($tpl, $pos+strlen($litOpen[0]), $endpos-$pos-strlen($litOpen[0]))); |
|
770 | 770 | $ptr = $endpos+strlen($litClose[0][0]); |
771 | 771 | } else { |
772 | 772 | if (substr($tpl, $pos-2, 1) === '\\' && substr($tpl, $pos-1, 1) === '\\') { |
@@ -780,7 +780,7 @@ discard block |
||
780 | 780 | $pos += strlen($this->ld); |
781 | 781 | if ($this->allowLooseOpenings) { |
782 | 782 | while (substr($tpl, $pos, 1) === ' ') { |
783 | - $pos+=1; |
|
783 | + $pos += 1; |
|
784 | 784 | } |
785 | 785 | } else { |
786 | 786 | if (substr($tpl, $pos, 1) === ' ' || substr($tpl, $pos, 1) === "\r" || substr($tpl, $pos, 1) === "\n" || substr($tpl, $pos, 1) === "\t") { |
@@ -807,7 +807,7 @@ discard block |
||
807 | 807 | continue 2; |
808 | 808 | } |
809 | 809 | |
810 | - $len = $subptr - $ptr; |
|
810 | + $len = $subptr-$ptr; |
|
811 | 811 | $this->push($parsed, substr_count(substr($tpl, $ptr, $len), "\n")); |
812 | 812 | $ptr += $len; |
813 | 813 | |
@@ -844,7 +844,7 @@ discard block |
||
844 | 844 | continue; |
845 | 845 | } |
846 | 846 | |
847 | - switch($type) { |
|
847 | + switch ($type) { |
|
848 | 848 | |
849 | 849 | case Dwoo_Core::BLOCK_PLUGIN: |
850 | 850 | case Dwoo_Core::CLASS_PLUGIN: |
@@ -884,15 +884,15 @@ discard block |
||
884 | 884 | |
885 | 885 | $output .= $compiled."\n?>"; |
886 | 886 | |
887 | - $output = preg_replace('/(?<!;|\}|\*\/|\n|\{)(\s*'.preg_quote(self::PHP_CLOSE, '/') . preg_quote(self::PHP_OPEN, '/').')/', ";\n", $output); |
|
888 | - $output = str_replace(self::PHP_CLOSE . self::PHP_OPEN, "\n", $output); |
|
887 | + $output = preg_replace('/(?<!;|\}|\*\/|\n|\{)(\s*'.preg_quote(self::PHP_CLOSE, '/').preg_quote(self::PHP_OPEN, '/').')/', ";\n", $output); |
|
888 | + $output = str_replace(self::PHP_CLOSE.self::PHP_OPEN, "\n", $output); |
|
889 | 889 | |
890 | 890 | // handle <?xml tag at the beginning |
891 | 891 | $output = preg_replace('#(/\* template body \*/ \?>\s*)<\?xml#is', '$1<?php echo \'<?xml\'; ?>', $output); |
892 | 892 | |
893 | 893 | // add another line break after PHP closing tags that have a line break following, |
894 | 894 | // as we do not know whether it's intended, and PHP will strip it otherwise |
895 | - $output = preg_replace('/(?<!"|<\?xml)\s*\?>\n/', '$0' . "\n", $output); |
|
895 | + $output = preg_replace('/(?<!"|<\?xml)\s*\?>\n/', '$0'."\n", $output); |
|
896 | 896 | |
897 | 897 | if ($this->debug) { |
898 | 898 | echo '<hr><pre>'; |
@@ -967,17 +967,17 @@ discard block |
||
967 | 967 | { |
968 | 968 | $old = $this->scopeTree; |
969 | 969 | |
970 | - if ($scope===null) { |
|
970 | + if ($scope === null) { |
|
971 | 971 | unset($this->scope); |
972 | 972 | $this->scope = null; |
973 | 973 | } |
974 | 974 | |
975 | - if (is_array($scope)===false) { |
|
975 | + if (is_array($scope) === false) { |
|
976 | 976 | $scope = explode('.', $scope); |
977 | 977 | } |
978 | 978 | |
979 | - if ($absolute===true) { |
|
980 | - $this->scope =& $this->data; |
|
979 | + if ($absolute === true) { |
|
980 | + $this->scope = & $this->data; |
|
981 | 981 | $this->scopeTree = array(); |
982 | 982 | } |
983 | 983 | |
@@ -985,19 +985,19 @@ discard block |
||
985 | 985 | if ($bit === '_parent' || $bit === '_') { |
986 | 986 | array_pop($this->scopeTree); |
987 | 987 | reset($this->scopeTree); |
988 | - $this->scope =& $this->data; |
|
988 | + $this->scope = & $this->data; |
|
989 | 989 | $cnt = count($this->scopeTree); |
990 | - for ($i=0;$i<$cnt;$i++) |
|
991 | - $this->scope =& $this->scope[$this->scopeTree[$i]]; |
|
990 | + for ($i = 0; $i < $cnt; $i++) |
|
991 | + $this->scope = & $this->scope[$this->scopeTree[$i]]; |
|
992 | 992 | } elseif ($bit === '_root' || $bit === '__') { |
993 | - $this->scope =& $this->data; |
|
993 | + $this->scope = & $this->data; |
|
994 | 994 | $this->scopeTree = array(); |
995 | 995 | } elseif (isset($this->scope[$bit])) { |
996 | - $this->scope =& $this->scope[$bit]; |
|
996 | + $this->scope = & $this->scope[$bit]; |
|
997 | 997 | $this->scopeTree[] = $bit; |
998 | 998 | } else { |
999 | 999 | $this->scope[$bit] = array(); |
1000 | - $this->scope =& $this->scope[$bit]; |
|
1000 | + $this->scope = & $this->scope[$bit]; |
|
1001 | 1001 | $this->scopeTree[] = $bit; |
1002 | 1002 | } |
1003 | 1003 | } |
@@ -1023,8 +1023,8 @@ discard block |
||
1023 | 1023 | $params = $this->mapParams($params, array($class, 'init'), $paramtype); |
1024 | 1024 | |
1025 | 1025 | $this->stack[] = array('type' => $type, 'params' => $params, 'custom' => false, 'class' => $class, 'buffer' => null); |
1026 | - $this->curBlock =& $this->stack[count($this->stack)-1]; |
|
1027 | - return call_user_func(array($class,'preProcessing'), $this, $params, '', '', $type); |
|
1026 | + $this->curBlock = & $this->stack[count($this->stack)-1]; |
|
1027 | + return call_user_func(array($class, 'preProcessing'), $this, $params, '', '', $type); |
|
1028 | 1028 | } |
1029 | 1029 | |
1030 | 1030 | /** |
@@ -1047,8 +1047,8 @@ discard block |
||
1047 | 1047 | $params = $this->mapParams($params, array($class, 'init'), $paramtype); |
1048 | 1048 | |
1049 | 1049 | $this->stack[] = array('type' => $type, 'params' => $params, 'custom' => true, 'class' => $class, 'buffer' => null); |
1050 | - $this->curBlock =& $this->stack[count($this->stack)-1]; |
|
1051 | - return call_user_func(array($class,'preProcessing'), $this, $params, '', '', $type); |
|
1050 | + $this->curBlock = & $this->stack[count($this->stack)-1]; |
|
1051 | + return call_user_func(array($class, 'preProcessing'), $this, $params, '', '', $type); |
|
1052 | 1052 | } |
1053 | 1053 | |
1054 | 1054 | /** |
@@ -1066,7 +1066,7 @@ discard block |
||
1066 | 1066 | $this->dwoo->getLoader()->loadPlugin($type); |
1067 | 1067 | } |
1068 | 1068 | $this->stack[] = array('type' => $type, 'params' => $params, 'custom' => false, 'class' => $class, 'buffer' => null); |
1069 | - $this->curBlock =& $this->stack[count($this->stack)-1]; |
|
1069 | + $this->curBlock = & $this->stack[count($this->stack)-1]; |
|
1070 | 1070 | } |
1071 | 1071 | |
1072 | 1072 | /** |
@@ -1092,11 +1092,11 @@ discard block |
||
1092 | 1092 | $class = 'Dwoo_Plugin_'.$top['type']; |
1093 | 1093 | } |
1094 | 1094 | if (count($this->stack)) { |
1095 | - $this->curBlock =& $this->stack[count($this->stack)-1]; |
|
1095 | + $this->curBlock = & $this->stack[count($this->stack)-1]; |
|
1096 | 1096 | $this->push(call_user_func(array($class, 'postProcessing'), $this, $top['params'], '', '', $top['buffer']), 0); |
1097 | 1097 | } else { |
1098 | 1098 | $null = null; |
1099 | - $this->curBlock =& $null; |
|
1099 | + $this->curBlock = & $null; |
|
1100 | 1100 | $output = call_user_func(array($class, 'postProcessing'), $this, $top['params'], '', '', $top['buffer']); |
1101 | 1101 | } |
1102 | 1102 | |
@@ -1126,9 +1126,9 @@ discard block |
||
1126 | 1126 | */ |
1127 | 1127 | public function &findBlock($type, $closeAlong = false) |
1128 | 1128 | { |
1129 | - if ($closeAlong===true) { |
|
1129 | + if ($closeAlong === true) { |
|
1130 | 1130 | while ($b = end($this->stack)) { |
1131 | - if ($b['type']===$type) { |
|
1131 | + if ($b['type'] === $type) { |
|
1132 | 1132 | return $this->stack[key($this->stack)]; |
1133 | 1133 | } |
1134 | 1134 | $this->push($this->removeTopBlock(), 0); |
@@ -1136,7 +1136,7 @@ discard block |
||
1136 | 1136 | } else { |
1137 | 1137 | end($this->stack); |
1138 | 1138 | while ($b = current($this->stack)) { |
1139 | - if ($b['type']===$type) { |
|
1139 | + if ($b['type'] === $type) { |
|
1140 | 1140 | return $this->stack[key($this->stack)]; |
1141 | 1141 | } |
1142 | 1142 | prev($this->stack); |
@@ -1174,7 +1174,7 @@ discard block |
||
1174 | 1174 | $class = 'Dwoo_Plugin_'.$o['type']; |
1175 | 1175 | } |
1176 | 1176 | |
1177 | - $this->curBlock =& $this->stack[count($this->stack)-1]; |
|
1177 | + $this->curBlock = & $this->stack[count($this->stack)-1]; |
|
1178 | 1178 | |
1179 | 1179 | return call_user_func(array($class, 'postProcessing'), $this, $o['params'], '', '', $o['buffer']); |
1180 | 1180 | } |
@@ -1238,7 +1238,7 @@ discard block |
||
1238 | 1238 | * @param mixed $pointer a reference to a pointer that will be increased by the amount of characters parsed, or null by default |
1239 | 1239 | * @return string parsed values |
1240 | 1240 | */ |
1241 | - protected function parse($in, $from, $to, $parsingParams = false, $curBlock='', &$pointer = null) |
|
1241 | + protected function parse($in, $from, $to, $parsingParams = false, $curBlock = '', &$pointer = null) |
|
1242 | 1242 | { |
1243 | 1243 | if ($to === null) { |
1244 | 1244 | $to = strlen($in); |
@@ -1249,7 +1249,7 @@ discard block |
||
1249 | 1249 | throw new Dwoo_Compilation_Exception($this, 'Unexpected EOF, a template tag was not closed'); |
1250 | 1250 | } |
1251 | 1251 | |
1252 | - while ($first===" " || $first==="\n" || $first==="\t" || $first==="\r") { |
|
1252 | + while ($first === " " || $first === "\n" || $first === "\t" || $first === "\r") { |
|
1253 | 1253 | if ($curBlock === 'root' && substr($in, $from, strlen($this->rd)) === $this->rd) { |
1254 | 1254 | // end template tag |
1255 | 1255 | $pointer += strlen($this->rd); |
@@ -1272,12 +1272,12 @@ discard block |
||
1272 | 1272 | |
1273 | 1273 | $substr = substr($in, $from, $to-$from); |
1274 | 1274 | |
1275 | - if ($this->debug) echo '<br />PARSE CALL : PARSING "<b>'.htmlentities(substr($in, $from, min($to-$from, 50))).(($to-$from) > 50 ? '...':'').'</b>" @ '.$from.':'.$to.' in '.$curBlock.' : pointer='.$pointer.'<br/>'; |
|
1275 | + if ($this->debug) echo '<br />PARSE CALL : PARSING "<b>'.htmlentities(substr($in, $from, min($to-$from, 50))).(($to-$from) > 50 ? '...' : '').'</b>" @ '.$from.':'.$to.' in '.$curBlock.' : pointer='.$pointer.'<br/>'; |
|
1276 | 1276 | $parsed = ""; |
1277 | 1277 | |
1278 | 1278 | if ($curBlock === 'root' && $first === '*') { |
1279 | 1279 | $src = $this->getTemplateSource(); |
1280 | - $startpos = $this->getPointer() - strlen($this->ld); |
|
1280 | + $startpos = $this->getPointer()-strlen($this->ld); |
|
1281 | 1281 | if (substr($src, $startpos, strlen($this->ld)) === $this->ld) { |
1282 | 1282 | if ($startpos > 0) { |
1283 | 1283 | do { |
@@ -1293,7 +1293,7 @@ discard block |
||
1293 | 1293 | if (!isset($whitespaceStart)) { |
1294 | 1294 | $startpos = $this->getPointer(); |
1295 | 1295 | } else { |
1296 | - $pointer -= $this->getPointer() - $startpos; |
|
1296 | + $pointer -= $this->getPointer()-$startpos; |
|
1297 | 1297 | } |
1298 | 1298 | |
1299 | 1299 | if ($this->allowNestedComments && strpos($src, $this->ld.'*', $this->getPointer()) !== false) { |
@@ -1301,7 +1301,7 @@ discard block |
||
1301 | 1301 | $comClose = '*'.$this->rd; |
1302 | 1302 | $level = 1; |
1303 | 1303 | $start = $startpos; |
1304 | - $ptr = $this->getPointer() + '*'; |
|
1304 | + $ptr = $this->getPointer()+'*'; |
|
1305 | 1305 | |
1306 | 1306 | while ($level > 0 && $ptr < strlen($src)) { |
1307 | 1307 | $open = strpos($src, $comOpen, $ptr); |
@@ -1309,49 +1309,49 @@ discard block |
||
1309 | 1309 | |
1310 | 1310 | if ($open !== false && $close !== false) { |
1311 | 1311 | if ($open < $close) { |
1312 | - $ptr = $open + strlen($comOpen); |
|
1312 | + $ptr = $open+strlen($comOpen); |
|
1313 | 1313 | $level++; |
1314 | 1314 | } else { |
1315 | - $ptr = $close + strlen($comClose); |
|
1315 | + $ptr = $close+strlen($comClose); |
|
1316 | 1316 | $level--; |
1317 | 1317 | } |
1318 | 1318 | } elseif ($open !== false) { |
1319 | - $ptr = $open + strlen($comOpen); |
|
1319 | + $ptr = $open+strlen($comOpen); |
|
1320 | 1320 | $level++; |
1321 | 1321 | } elseif ($close !== false) { |
1322 | - $ptr = $close + strlen($comClose); |
|
1322 | + $ptr = $close+strlen($comClose); |
|
1323 | 1323 | $level--; |
1324 | 1324 | } else { |
1325 | 1325 | $ptr = strlen($src); |
1326 | 1326 | } |
1327 | 1327 | } |
1328 | - $endpos = $ptr - strlen('*'.$this->rd); |
|
1328 | + $endpos = $ptr-strlen('*'.$this->rd); |
|
1329 | 1329 | } else { |
1330 | 1330 | $endpos = strpos($src, '*'.$this->rd, $startpos); |
1331 | 1331 | if ($endpos == false) { |
1332 | 1332 | throw new Dwoo_Compilation_Exception($this, 'Un-ended comment'); |
1333 | 1333 | } |
1334 | 1334 | } |
1335 | - $pointer += $endpos - $startpos + strlen('*'.$this->rd); |
|
1335 | + $pointer += $endpos-$startpos+strlen('*'.$this->rd); |
|
1336 | 1336 | if (isset($whitespaceStart) && preg_match('#^[\t ]*\r?\n#', substr($src, $endpos+strlen('*'.$this->rd)), $m)) { |
1337 | 1337 | $pointer += strlen($m[0]); |
1338 | - $this->curBlock['buffer'] = substr($this->curBlock['buffer'], 0, strlen($this->curBlock['buffer']) - ($this->getPointer() - $startpos - strlen($this->ld))); |
|
1338 | + $this->curBlock['buffer'] = substr($this->curBlock['buffer'], 0, strlen($this->curBlock['buffer'])-($this->getPointer()-$startpos-strlen($this->ld))); |
|
1339 | 1339 | } |
1340 | 1340 | return false; |
1341 | 1341 | } |
1342 | 1342 | } |
1343 | 1343 | |
1344 | - if ($first==='$') { |
|
1344 | + if ($first === '$') { |
|
1345 | 1345 | // var |
1346 | 1346 | $out = $this->parseVar($in, $from, $to, $parsingParams, $curBlock, $pointer); |
1347 | 1347 | $parsed = 'var'; |
1348 | - } elseif ($first==='%' && preg_match('#^%[a-z_]#i', $substr)) { |
|
1348 | + } elseif ($first === '%' && preg_match('#^%[a-z_]#i', $substr)) { |
|
1349 | 1349 | // const |
1350 | 1350 | $out = $this->parseConst($in, $from, $to, $parsingParams, $curBlock, $pointer); |
1351 | - } elseif (($first==='"' || $first==="'") && !(is_array($parsingParams) && preg_match('#^([\'"])[a-z0-9_]+\1\s*=>?(?:\s+|[^=])#i', $substr))) { |
|
1351 | + } elseif (($first === '"' || $first === "'") && !(is_array($parsingParams) && preg_match('#^([\'"])[a-z0-9_]+\1\s*=>?(?:\s+|[^=])#i', $substr))) { |
|
1352 | 1352 | // string |
1353 | 1353 | $out = $this->parseString($in, $from, $to, $parsingParams, $curBlock, $pointer); |
1354 | - } 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)) { |
|
1354 | + } 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)) { |
|
1355 | 1355 | // func |
1356 | 1356 | $out = $this->parseFunction($in, $from, $to, $parsingParams, $curBlock, $pointer); |
1357 | 1357 | $parsed = 'func'; |
@@ -1388,11 +1388,11 @@ discard block |
||
1388 | 1388 | if ($this->debug) echo 'TAG PARSING ENDED<br />'; |
1389 | 1389 | $pointer += strlen($this->rd); |
1390 | 1390 | return false; |
1391 | - } elseif (is_array($parsingParams) && preg_match('#^(([\'"]?)[a-z0-9_]+\2\s*='.($curBlock === 'array' ? '>?':'').')(?:\s+|[^=]).*#i', $substr, $match)) { |
|
1391 | + } elseif (is_array($parsingParams) && preg_match('#^(([\'"]?)[a-z0-9_]+\2\s*='.($curBlock === 'array' ? '>?' : '').')(?:\s+|[^=]).*#i', $substr, $match)) { |
|
1392 | 1392 | // named parameter |
1393 | 1393 | if ($this->debug) echo 'NAMED PARAM FOUND<br />'; |
1394 | 1394 | $len = strlen($match[1]); |
1395 | - while (substr($in, $from+$len, 1)===' ') { |
|
1395 | + while (substr($in, $from+$len, 1) === ' ') { |
|
1396 | 1396 | $len++; |
1397 | 1397 | } |
1398 | 1398 | if ($pointer !== null) { |
@@ -1413,7 +1413,7 @@ discard block |
||
1413 | 1413 | $out = $match[1]; |
1414 | 1414 | } |
1415 | 1415 | $pointer += strlen($match[1]); |
1416 | - } elseif ($substr!=='' && (is_array($parsingParams) || $curBlock === 'namedparam' || $curBlock === 'condition' || $curBlock === 'expression')) { |
|
1416 | + } elseif ($substr !== '' && (is_array($parsingParams) || $curBlock === 'namedparam' || $curBlock === 'condition' || $curBlock === 'expression')) { |
|
1417 | 1417 | // unquoted string, bool or number |
1418 | 1418 | $out = $this->parseOthers($in, $from, $to, $parsingParams, $curBlock, $pointer); |
1419 | 1419 | } else { |
@@ -1428,19 +1428,19 @@ discard block |
||
1428 | 1428 | $substr = substr($in, $pointer, $to-$pointer); |
1429 | 1429 | |
1430 | 1430 | // var parsed, check if any var-extension applies |
1431 | - if ($parsed==='var') { |
|
1431 | + if ($parsed === 'var') { |
|
1432 | 1432 | if (preg_match('#^\s*([/%+*-])\s*([a-z0-9]|\$)#i', $substr, $match)) { |
1433 | - if($this->debug) echo 'PARSING POST-VAR EXPRESSION '.$substr.'<br />'; |
|
1433 | + if ($this->debug) echo 'PARSING POST-VAR EXPRESSION '.$substr.'<br />'; |
|
1434 | 1434 | // parse expressions |
1435 | - $pointer += strlen($match[0]) - 1; |
|
1435 | + $pointer += strlen($match[0])-1; |
|
1436 | 1436 | if (is_array($parsingParams)) { |
1437 | 1437 | if ($match[2] == '$') { |
1438 | 1438 | $expr = $this->parseVar($in, $pointer, $to, array(), $curBlock, $pointer); |
1439 | 1439 | } else { |
1440 | 1440 | $expr = $this->parse($in, $pointer, $to, array(), 'expression', $pointer); |
1441 | 1441 | } |
1442 | - $out[count($out)-1][0] .= $match[1] . $expr[0][0]; |
|
1443 | - $out[count($out)-1][1] .= $match[1] . $expr[0][1]; |
|
1442 | + $out[count($out)-1][0] .= $match[1].$expr[0][0]; |
|
1443 | + $out[count($out)-1][1] .= $match[1].$expr[0][1]; |
|
1444 | 1444 | } else { |
1445 | 1445 | if ($match[2] == '$') { |
1446 | 1446 | $expr = $this->parseVar($in, $pointer, $to, false, $curBlock, $pointer); |
@@ -1448,19 +1448,19 @@ discard block |
||
1448 | 1448 | $expr = $this->parse($in, $pointer, $to, false, 'expression', $pointer); |
1449 | 1449 | } |
1450 | 1450 | if (is_array($out) && is_array($expr)) { |
1451 | - $out[0] .= $match[1] . $expr[0]; |
|
1452 | - $out[1] .= $match[1] . $expr[1]; |
|
1451 | + $out[0] .= $match[1].$expr[0]; |
|
1452 | + $out[1] .= $match[1].$expr[1]; |
|
1453 | 1453 | } elseif (is_array($out)) { |
1454 | - $out[0] .= $match[1] . $expr; |
|
1455 | - $out[1] .= $match[1] . $expr; |
|
1454 | + $out[0] .= $match[1].$expr; |
|
1455 | + $out[1] .= $match[1].$expr; |
|
1456 | 1456 | } elseif (is_array($expr)) { |
1457 | - $out .= $match[1] . $expr[0]; |
|
1457 | + $out .= $match[1].$expr[0]; |
|
1458 | 1458 | } else { |
1459 | - $out .= $match[1] . $expr; |
|
1459 | + $out .= $match[1].$expr; |
|
1460 | 1460 | } |
1461 | 1461 | } |
1462 | 1462 | } else if ($curBlock === 'root' && preg_match('#^(\s*(?:[+/*%-.]=|=|\+\+|--)\s*)(.*)#s', $substr, $match)) { |
1463 | - if($this->debug) echo 'PARSING POST-VAR ASSIGNMENT '.$substr.'<br />'; |
|
1463 | + if ($this->debug) echo 'PARSING POST-VAR ASSIGNMENT '.$substr.'<br />'; |
|
1464 | 1464 | // parse assignment |
1465 | 1465 | $value = $match[2]; |
1466 | 1466 | $operator = trim($match[1]); |
@@ -1499,7 +1499,7 @@ discard block |
||
1499 | 1499 | if ($this->autoEscape) { |
1500 | 1500 | $out = preg_replace('#\(is_string\(\$tmp=(.+?)\) \? htmlspecialchars\(\$tmp, ENT_QUOTES, \$this->charset\) : \$tmp\)#', '$1', $out); |
1501 | 1501 | } |
1502 | - $out = Dwoo_Compiler::PHP_OPEN. $echo . $out . $operator . implode(' ', $value) . Dwoo_Compiler::PHP_CLOSE; |
|
1502 | + $out = Dwoo_Compiler::PHP_OPEN.$echo.$out.$operator.implode(' ', $value).Dwoo_Compiler::PHP_CLOSE; |
|
1503 | 1503 | } else if ($curBlock === 'array' && is_array($parsingParams) && preg_match('#^(\s*=>?\s*)#', $substr, $match)) { |
1504 | 1504 | // parse namedparam with var as name (only for array) |
1505 | 1505 | if ($this->debug) echo 'VARIABLE NAMED PARAM (FOR ARRAY) FOUND<br />'; |
@@ -1520,14 +1520,14 @@ discard block |
||
1520 | 1520 | if (is_array($parsingParams)) { |
1521 | 1521 | $tmp = $this->replaceModifiers(array(null, null, $out[count($out)-1][0], $match[0]), $curBlock, $pointer); |
1522 | 1522 | $out[count($out)-1][0] = $tmp; |
1523 | - $out[count($out)-1][1] .= substr($substr, $srcPointer, $srcPointer - $pointer); |
|
1523 | + $out[count($out)-1][1] .= substr($substr, $srcPointer, $srcPointer-$pointer); |
|
1524 | 1524 | } else { |
1525 | 1525 | $out = $this->replaceModifiers(array(null, null, $out, $match[0]), $curBlock, $pointer); |
1526 | 1526 | } |
1527 | 1527 | } |
1528 | 1528 | |
1529 | 1529 | // func parsed, check if any func-extension applies |
1530 | - if ($parsed==='func' && preg_match('#^->[a-z0-9_]+(\s*\(.+|->[a-z_].*)?#is', $substr, $match)) { |
|
1530 | + if ($parsed === 'func' && preg_match('#^->[a-z0-9_]+(\s*\(.+|->[a-z_].*)?#is', $substr, $match)) { |
|
1531 | 1531 | // parse method call or property read |
1532 | 1532 | $ptr = 0; |
1533 | 1533 | |
@@ -1544,7 +1544,7 @@ discard block |
||
1544 | 1544 | } |
1545 | 1545 | |
1546 | 1546 | if ($curBlock === 'root' && substr($out, 0, strlen(self::PHP_OPEN)) !== self::PHP_OPEN) { |
1547 | - return self::PHP_OPEN .'echo '.$out.';'. self::PHP_CLOSE; |
|
1547 | + return self::PHP_OPEN.'echo '.$out.';'.self::PHP_CLOSE; |
|
1548 | 1548 | } else { |
1549 | 1549 | return $out; |
1550 | 1550 | } |
@@ -1561,7 +1561,7 @@ discard block |
||
1561 | 1561 | * @param mixed $pointer a reference to a pointer that will be increased by the amount of characters parsed, or null by default |
1562 | 1562 | * @return string parsed values |
1563 | 1563 | */ |
1564 | - protected function parseFunction($in, $from, $to, $parsingParams = false, $curBlock='', &$pointer = null) |
|
1564 | + protected function parseFunction($in, $from, $to, $parsingParams = false, $curBlock = '', &$pointer = null) |
|
1565 | 1565 | { |
1566 | 1566 | $cmdstr = substr($in, $from, $to-$from); |
1567 | 1567 | preg_match('/^(\\\\?[a-z_](?:\\\\?[a-z0-9_]+)*(?:::[a-z_][a-z0-9_]*)?)(\s*'.$this->rdr.'|\s*;)?/i', $cmdstr, $match); |
@@ -1583,14 +1583,14 @@ discard block |
||
1583 | 1583 | if (is_array($parsingParams) || $curBlock != 'root') { |
1584 | 1584 | $paramspos = strpos($cmdstr, '('); |
1585 | 1585 | $paramsep = ')'; |
1586 | - } elseif(preg_match_all('#^\s*[\\\\:a-z0-9_]+(\s*\(|\s+[^(])#i', $cmdstr, $match, PREG_OFFSET_CAPTURE)) { |
|
1586 | + } elseif (preg_match_all('#^\s*[\\\\:a-z0-9_]+(\s*\(|\s+[^(])#i', $cmdstr, $match, PREG_OFFSET_CAPTURE)) { |
|
1587 | 1587 | $paramspos = $match[1][0][1]; |
1588 | - $paramsep = substr($match[1][0][0], -1) === '(' ? ')':''; |
|
1589 | - if($paramsep === ')') { |
|
1590 | - $paramspos += strlen($match[1][0][0]) - 1; |
|
1591 | - if(substr($cmdstr, 0, 2) === 'if' || substr($cmdstr, 0, 6) === 'elseif') { |
|
1588 | + $paramsep = substr($match[1][0][0], -1) === '(' ? ')' : ''; |
|
1589 | + if ($paramsep === ')') { |
|
1590 | + $paramspos += strlen($match[1][0][0])-1; |
|
1591 | + if (substr($cmdstr, 0, 2) === 'if' || substr($cmdstr, 0, 6) === 'elseif') { |
|
1592 | 1592 | $paramsep = ''; |
1593 | - if(strlen($match[1][0][0]) > 1) { |
|
1593 | + if (strlen($match[1][0][0]) > 1) { |
|
1594 | 1594 | $paramspos--; |
1595 | 1595 | } |
1596 | 1596 | } |
@@ -1622,7 +1622,7 @@ discard block |
||
1622 | 1622 | $paramstr = substr($paramstr, 0, -1); |
1623 | 1623 | } |
1624 | 1624 | |
1625 | - if (strlen($paramstr)===0) { |
|
1625 | + if (strlen($paramstr) === 0) { |
|
1626 | 1626 | $params = array(); |
1627 | 1627 | $paramstr = ''; |
1628 | 1628 | } else { |
@@ -1692,8 +1692,8 @@ discard block |
||
1692 | 1692 | } |
1693 | 1693 | |
1694 | 1694 | if ($pointer !== null) { |
1695 | - $pointer += (isset($paramstr) ? strlen($paramstr) : 0) + (')' === $paramsep ? 2 : ($paramspos === false ? 0 : 1)) + strlen($func) + (isset($whitespace) ? $whitespace : 0); |
|
1696 | - if ($this->debug) echo 'FUNC ADDS '.((isset($paramstr) ? strlen($paramstr) : 0) + (')' === $paramsep ? 2 : ($paramspos === false ? 0 : 1)) + strlen($func)).' TO POINTER<br/>'; |
|
1695 | + $pointer += (isset($paramstr) ? strlen($paramstr) : 0)+(')' === $paramsep ? 2 : ($paramspos === false ? 0 : 1))+strlen($func)+(isset($whitespace) ? $whitespace : 0); |
|
1696 | + if ($this->debug) echo 'FUNC ADDS '.((isset($paramstr) ? strlen($paramstr) : 0)+(')' === $paramsep ? 2 : ($paramspos === false ? 0 : 1))+strlen($func)).' TO POINTER<br/>'; |
|
1697 | 1697 | } |
1698 | 1698 | |
1699 | 1699 | if ($curBlock === 'method' || $func === 'do' || strstr($func, '::') !== false) { |
@@ -1926,12 +1926,12 @@ discard block |
||
1926 | 1926 | * @param mixed $pointer a reference to a pointer that will be increased by the amount of characters parsed, or null by default |
1927 | 1927 | * @return string parsed values |
1928 | 1928 | */ |
1929 | - protected function parseString($in, $from, $to, $parsingParams = false, $curBlock='', &$pointer = null) |
|
1929 | + protected function parseString($in, $from, $to, $parsingParams = false, $curBlock = '', &$pointer = null) |
|
1930 | 1930 | { |
1931 | 1931 | $substr = substr($in, $from, $to-$from); |
1932 | 1932 | $first = $substr[0]; |
1933 | 1933 | |
1934 | - if ($this->debug) echo 'STRING FOUND (in '.htmlentities(substr($in, $from, min($to-$from, 50))).(($to-$from) > 50 ? '...':'').')<br />'; |
|
1934 | + if ($this->debug) echo 'STRING FOUND (in '.htmlentities(substr($in, $from, min($to-$from, 50))).(($to-$from) > 50 ? '...' : '').')<br />'; |
|
1935 | 1935 | $strend = false; |
1936 | 1936 | $o = $from+1; |
1937 | 1937 | while ($strend === false) { |
@@ -1993,7 +1993,7 @@ discard block |
||
1993 | 1993 | * @param mixed $pointer a reference to a pointer that will be increased by the amount of characters parsed, or null by default |
1994 | 1994 | * @return string parsed values |
1995 | 1995 | */ |
1996 | - protected function parseConst($in, $from, $to, $parsingParams = false, $curBlock='', &$pointer = null) |
|
1996 | + protected function parseConst($in, $from, $to, $parsingParams = false, $curBlock = '', &$pointer = null) |
|
1997 | 1997 | { |
1998 | 1998 | $substr = substr($in, $from, $to-$from); |
1999 | 1999 | |
@@ -2054,14 +2054,14 @@ discard block |
||
2054 | 2054 | * @param mixed $pointer a reference to a pointer that will be increased by the amount of characters parsed, or null by default |
2055 | 2055 | * @return string parsed values |
2056 | 2056 | */ |
2057 | - protected function parseVar($in, $from, $to, $parsingParams = false, $curBlock='', &$pointer = null) |
|
2057 | + protected function parseVar($in, $from, $to, $parsingParams = false, $curBlock = '', &$pointer = null) |
|
2058 | 2058 | { |
2059 | 2059 | $substr = substr($in, $from, $to-$from); |
2060 | 2060 | |
2061 | - if (preg_match('#(\$?\.?[a-z0-9_:]*(?:(?:(?:\.|->)(?:[a-z0-9_:]+|(?R))|\[(?:[a-z0-9_:]+|(?R)|(["\'])[^\2]*?\2)\]))*)' . // var key |
|
2062 | - ($curBlock==='root' || $curBlock==='function' || $curBlock==='namedparam' || $curBlock==='condition' || $curBlock==='variable' || $curBlock==='expression' || $curBlock==='delimited_string' ? '(\(.*)?' : '()') . // method call |
|
2063 | - ($curBlock==='root' || $curBlock==='function' || $curBlock==='namedparam' || $curBlock==='condition' || $curBlock==='variable' || $curBlock==='delimited_string' ? '((?:(?:[+/*%=-])(?:(?<!=)=?-?[$%][a-z0-9.[\]>_:-]+(?:\([^)]*\))?|(?<!=)=?-?[0-9.,]*|[+-]))*)':'()') . // simple math expressions |
|
2064 | - ($curBlock!=='modifier' ? '((?:\|(?:@?[a-z0-9_]+(?:(?::("|\').*?\5|:[^`]*))*))+)?':'(())') . // modifiers |
|
2061 | + if (preg_match('#(\$?\.?[a-z0-9_:]*(?:(?:(?:\.|->)(?:[a-z0-9_:]+|(?R))|\[(?:[a-z0-9_:]+|(?R)|(["\'])[^\2]*?\2)\]))*)'.// var key |
|
2062 | + ($curBlock === 'root' || $curBlock === 'function' || $curBlock === 'namedparam' || $curBlock === 'condition' || $curBlock === 'variable' || $curBlock === 'expression' || $curBlock === 'delimited_string' ? '(\(.*)?' : '()').// method call |
|
2063 | + ($curBlock === 'root' || $curBlock === 'function' || $curBlock === 'namedparam' || $curBlock === 'condition' || $curBlock === 'variable' || $curBlock === 'delimited_string' ? '((?:(?:[+/*%=-])(?:(?<!=)=?-?[$%][a-z0-9.[\]>_:-]+(?:\([^)]*\))?|(?<!=)=?-?[0-9.,]*|[+-]))*)' : '()').// simple math expressions |
|
2064 | + ($curBlock !== 'modifier' ? '((?:\|(?:@?[a-z0-9_]+(?:(?::("|\').*?\5|:[^`]*))*))+)?' : '(())').// modifiers |
|
2065 | 2065 | '#i', $substr, $match)) { |
2066 | 2066 | $key = substr($match[1], 1); |
2067 | 2067 | |
@@ -2076,9 +2076,9 @@ discard block |
||
2076 | 2076 | } |
2077 | 2077 | |
2078 | 2078 | if ($hasMethodCall) { |
2079 | - $matchedLength -= strlen($match[3]) + strlen(substr($match[1], strrpos($match[1], '->'))); |
|
2079 | + $matchedLength -= strlen($match[3])+strlen(substr($match[1], strrpos($match[1], '->'))); |
|
2080 | 2080 | $key = substr($match[1], 1, strrpos($match[1], '->')-1); |
2081 | - $methodCall = substr($match[1], strrpos($match[1], '->')) . $match[3]; |
|
2081 | + $methodCall = substr($match[1], strrpos($match[1], '->')).$match[3]; |
|
2082 | 2082 | } |
2083 | 2083 | |
2084 | 2084 | if ($hasModifiers) { |
@@ -2102,12 +2102,12 @@ discard block |
||
2102 | 2102 | |
2103 | 2103 | $key = str_replace('"', '\\"', $key); |
2104 | 2104 | |
2105 | - $cnt=substr_count($key, '$'); |
|
2105 | + $cnt = substr_count($key, '$'); |
|
2106 | 2106 | if ($cnt > 0) { |
2107 | 2107 | $uid = 0; |
2108 | 2108 | $parsed = array($uid => ''); |
2109 | - $current =& $parsed; |
|
2110 | - $curTxt =& $parsed[$uid++]; |
|
2109 | + $current = & $parsed; |
|
2110 | + $curTxt = & $parsed[$uid++]; |
|
2111 | 2111 | $tree = array(); |
2112 | 2112 | $chars = str_split($key, 1); |
2113 | 2113 | $inSplittedVar = false; |
@@ -2118,31 +2118,31 @@ discard block |
||
2118 | 2118 | if (count($tree) > 0) { |
2119 | 2119 | $bracketCount++; |
2120 | 2120 | } else { |
2121 | - $tree[] =& $current; |
|
2121 | + $tree[] = & $current; |
|
2122 | 2122 | $current[$uid] = array($uid+1 => ''); |
2123 | - $current =& $current[$uid++]; |
|
2124 | - $curTxt =& $current[$uid++]; |
|
2123 | + $current = & $current[$uid++]; |
|
2124 | + $curTxt = & $current[$uid++]; |
|
2125 | 2125 | continue; |
2126 | 2126 | } |
2127 | 2127 | } elseif ($char === ']') { |
2128 | 2128 | if ($bracketCount > 0) { |
2129 | 2129 | $bracketCount--; |
2130 | 2130 | } else { |
2131 | - $current =& $tree[count($tree)-1]; |
|
2131 | + $current = & $tree[count($tree)-1]; |
|
2132 | 2132 | array_pop($tree); |
2133 | 2133 | if (current($chars) !== '[' && current($chars) !== false && current($chars) !== ']') { |
2134 | 2134 | $current[$uid] = ''; |
2135 | - $curTxt =& $current[$uid++]; |
|
2135 | + $curTxt = & $current[$uid++]; |
|
2136 | 2136 | } |
2137 | 2137 | continue; |
2138 | 2138 | } |
2139 | 2139 | } elseif ($char === '$') { |
2140 | 2140 | if (count($tree) == 0) { |
2141 | - $curTxt =& $current[$uid++]; |
|
2141 | + $curTxt = & $current[$uid++]; |
|
2142 | 2142 | $inSplittedVar = true; |
2143 | 2143 | } |
2144 | 2144 | } elseif (($char === '.' || $char === '-') && count($tree) == 0 && $inSplittedVar) { |
2145 | - $curTxt =& $current[$uid++]; |
|
2145 | + $curTxt = & $current[$uid++]; |
|
2146 | 2146 | $inSplittedVar = false; |
2147 | 2147 | } |
2148 | 2148 | |
@@ -2178,7 +2178,7 @@ discard block |
||
2178 | 2178 | preg_match_all('#(?:([+/*%=-])(=?-?[%$][a-z0-9.[\]>_:-]+(?:\([^)]*\))?|=?-?[0-9.,]+|\1))#i', $match[4], $expMatch); |
2179 | 2179 | |
2180 | 2180 | foreach ($expMatch[1] as $k=>$operator) { |
2181 | - if (substr($expMatch[2][$k], 0, 1)==='=') { |
|
2181 | + if (substr($expMatch[2][$k], 0, 1) === '=') { |
|
2182 | 2182 | $assign = true; |
2183 | 2183 | if ($operator === '=') { |
2184 | 2184 | throw new Dwoo_Compilation_Exception($this, 'Invalid expression <em>'.$substr.'</em>, can not use "==" in expressions'); |
@@ -2190,11 +2190,11 @@ discard block |
||
2190 | 2190 | $expMatch[2][$k] = substr($expMatch[2][$k], 1); |
2191 | 2191 | } |
2192 | 2192 | |
2193 | - if (substr($expMatch[2][$k], 0, 1)==='-' && strlen($expMatch[2][$k]) > 1) { |
|
2193 | + if (substr($expMatch[2][$k], 0, 1) === '-' && strlen($expMatch[2][$k]) > 1) { |
|
2194 | 2194 | $operator .= '-'; |
2195 | 2195 | $expMatch[2][$k] = substr($expMatch[2][$k], 1); |
2196 | 2196 | } |
2197 | - if (($operator==='+'||$operator==='-') && $expMatch[2][$k]===$operator) { |
|
2197 | + if (($operator === '+' || $operator === '-') && $expMatch[2][$k] === $operator) { |
|
2198 | 2198 | $output = '('.$output.$operator.$operator.')'; |
2199 | 2199 | break; |
2200 | 2200 | } elseif (substr($expMatch[2][$k], 0, 1) === '$') { |
@@ -2270,7 +2270,7 @@ discard block |
||
2270 | 2270 | break; |
2271 | 2271 | } |
2272 | 2272 | |
2273 | - if(!preg_match('/^([a-z0-9_]+)(\(.*?\))?/i', substr($methodCall, $ptr), $methMatch)) { |
|
2273 | + if (!preg_match('/^([a-z0-9_]+)(\(.*?\))?/i', substr($methodCall, $ptr), $methMatch)) { |
|
2274 | 2274 | break; |
2275 | 2275 | } |
2276 | 2276 | |
@@ -2286,7 +2286,7 @@ discard block |
||
2286 | 2286 | // method |
2287 | 2287 | if (substr($methMatch[2], 0, 2) === '()') { |
2288 | 2288 | $parsedCall = $methMatch[1].'()'; |
2289 | - $ptr += strlen($methMatch[1]) + 2; |
|
2289 | + $ptr += strlen($methMatch[1])+2; |
|
2290 | 2290 | } else { |
2291 | 2291 | $parsedCall = $this->parseFunction($methodCall, $ptr, strlen($methodCall), false, 'method', $ptr); |
2292 | 2292 | } |
@@ -2395,7 +2395,7 @@ discard block |
||
2395 | 2395 | |
2396 | 2396 | while (count($m[1]) && $m[1][0] !== '->') { |
2397 | 2397 | $m[2][0] = preg_replace('/(^\\\([\'"])|\\\([\'"])$)/x', '$2$3', $m[2][0]); |
2398 | - if(substr($m[2][0], 0, 1) == '"' || substr($m[2][0], 0, 1) == "'") { |
|
2398 | + if (substr($m[2][0], 0, 1) == '"' || substr($m[2][0], 0, 1) == "'") { |
|
2399 | 2399 | $output .= '['.$m[2][0].']'; |
2400 | 2400 | } else { |
2401 | 2401 | $output .= '["'.$m[2][0].'"]'; |
@@ -2411,7 +2411,7 @@ discard block |
||
2411 | 2411 | |
2412 | 2412 | if (count($m[2])) { |
2413 | 2413 | unset($m[0]); |
2414 | - $output = '$this->readVarInto('.str_replace("\n", '', var_export($m, true)).', '.$output.', '.($curBlock == 'root' ? 'false': 'true').')'; |
|
2414 | + $output = '$this->readVarInto('.str_replace("\n", '', var_export($m, true)).', '.$output.', '.($curBlock == 'root' ? 'false' : 'true').')'; |
|
2415 | 2415 | } |
2416 | 2416 | } |
2417 | 2417 | } else { |
@@ -2431,16 +2431,16 @@ discard block |
||
2431 | 2431 | * @param bool $recursed leave that to false by default, it is only for internal use |
2432 | 2432 | * @return string flattened tree |
2433 | 2433 | */ |
2434 | - protected function flattenVarTree(array $tree, $recursed=false) |
|
2434 | + protected function flattenVarTree(array $tree, $recursed = false) |
|
2435 | 2435 | { |
2436 | - $out = $recursed ? '".$this->readVarInto(' : ''; |
|
2436 | + $out = $recursed ? '".$this->readVarInto(' : ''; |
|
2437 | 2437 | foreach ($tree as $bit) { |
2438 | 2438 | if (is_array($bit)) { |
2439 | - $out.='.'.$this->flattenVarTree($bit, false); |
|
2439 | + $out .= '.'.$this->flattenVarTree($bit, false); |
|
2440 | 2440 | } else { |
2441 | 2441 | $key = str_replace('"', '\\"', $bit); |
2442 | 2442 | |
2443 | - if (substr($key, 0, 1)==='$') { |
|
2443 | + if (substr($key, 0, 1) === '$') { |
|
2444 | 2444 | $out .= '".'.$this->parseVar($key, 0, strlen($key), false, 'variable').'."'; |
2445 | 2445 | } else { |
2446 | 2446 | $cnt = substr_count($key, '$'); |
@@ -2449,7 +2449,7 @@ discard block |
||
2449 | 2449 | if ($cnt > 0) { |
2450 | 2450 | while (--$cnt >= 0) { |
2451 | 2451 | if (isset($last)) { |
2452 | - $last = strrpos($key, '$', - (strlen($key) - $last + 1)); |
|
2452 | + $last = strrpos($key, '$', - (strlen($key)-$last+1)); |
|
2453 | 2453 | } else { |
2454 | 2454 | $last = strrpos($key, '$'); |
2455 | 2455 | } |
@@ -2504,7 +2504,7 @@ discard block |
||
2504 | 2504 | * @param mixed $pointer a reference to a pointer that will be increased by the amount of characters parsed, or null by default |
2505 | 2505 | * @return string parsed values |
2506 | 2506 | */ |
2507 | - protected function parseOthers($in, $from, $to, $parsingParams = false, $curBlock='', &$pointer = null) |
|
2507 | + protected function parseOthers($in, $from, $to, $parsingParams = false, $curBlock = '', &$pointer = null) |
|
2508 | 2508 | { |
2509 | 2509 | $first = $in[$from]; |
2510 | 2510 | $substr = substr($in, $from, $to-$from); |
@@ -2522,7 +2522,7 @@ discard block |
||
2522 | 2522 | } |
2523 | 2523 | |
2524 | 2524 | $breaker = false; |
2525 | - while (list($k,$char) = each($breakChars)) { |
|
2525 | + while (list($k, $char) = each($breakChars)) { |
|
2526 | 2526 | $test = strpos($substr, $char); |
2527 | 2527 | if ($test !== false && $test < $end) { |
2528 | 2528 | $end = $test; |
@@ -2600,7 +2600,7 @@ discard block |
||
2600 | 2600 | * @param string $curBlock the current parser-block being processed |
2601 | 2601 | * @return string the original string with variables replaced |
2602 | 2602 | */ |
2603 | - protected function replaceStringVars($string, $first, $curBlock='') |
|
2603 | + protected function replaceStringVars($string, $first, $curBlock = '') |
|
2604 | 2604 | { |
2605 | 2605 | $pos = 0; |
2606 | 2606 | if ($this->debug) echo 'STRING VAR REPLACEMENT : '.$string.'<br>'; |
@@ -2612,16 +2612,16 @@ discard block |
||
2612 | 2612 | continue; |
2613 | 2613 | } |
2614 | 2614 | |
2615 | - $var = $this->parse($string, $pos, null, false, ($curBlock === 'modifier' ? 'modifier' : ($prev === '`' ? 'delimited_string':'string'))); |
|
2615 | + $var = $this->parse($string, $pos, null, false, ($curBlock === 'modifier' ? 'modifier' : ($prev === '`' ? 'delimited_string' : 'string'))); |
|
2616 | 2616 | $len = $var[0]; |
2617 | - $var = $this->parse(str_replace('\\'.$first, $first, $string), $pos, null, false, ($curBlock === 'modifier' ? 'modifier' : ($prev === '`' ? 'delimited_string':'string'))); |
|
2617 | + $var = $this->parse(str_replace('\\'.$first, $first, $string), $pos, null, false, ($curBlock === 'modifier' ? 'modifier' : ($prev === '`' ? 'delimited_string' : 'string'))); |
|
2618 | 2618 | |
2619 | 2619 | if ($prev === '`' && substr($string, $pos+$len, 1) === '`') { |
2620 | 2620 | $string = substr_replace($string, $first.'.'.$var[1].'.'.$first, $pos-1, $len+2); |
2621 | 2621 | } else { |
2622 | 2622 | $string = substr_replace($string, $first.'.'.$var[1].'.'.$first, $pos, $len); |
2623 | 2623 | } |
2624 | - $pos += strlen($var[1]) + 2; |
|
2624 | + $pos += strlen($var[1])+2; |
|
2625 | 2625 | if ($this->debug) echo 'STRING VAR REPLACEMENT DONE : '.$string.'<br>'; |
2626 | 2626 | } |
2627 | 2627 | |
@@ -2630,7 +2630,7 @@ discard block |
||
2630 | 2630 | $string = preg_replace_callback('#("|\')\.(.+?)\.\1((?:\|(?:@?[a-z0-9_]+(?:(?::("|\').+?\4|:[^`]*))*))+)#i', array($this, 'replaceModifiers'), $string); |
2631 | 2631 | |
2632 | 2632 | // replace escaped dollar operators by unescaped ones if required |
2633 | - if ($first==="'") { |
|
2633 | + if ($first === "'") { |
|
2634 | 2634 | $string = str_replace('\\$', '$', $string); |
2635 | 2635 | } |
2636 | 2636 | |
@@ -2712,7 +2712,7 @@ discard block |
||
2712 | 2712 | if ($paramstr[$ptr] !== '|') { |
2713 | 2713 | $continue = false; |
2714 | 2714 | if ($pointer !== null) { |
2715 | - $pointer -= strlen($paramstr) - $ptr; |
|
2715 | + $pointer -= strlen($paramstr)-$ptr; |
|
2716 | 2716 | } |
2717 | 2717 | } |
2718 | 2718 | $ptr++; |
@@ -2806,7 +2806,7 @@ discard block |
||
2806 | 2806 | if ($pluginType & Dwoo_Core::CLASS_PLUGIN) { |
2807 | 2807 | $callback = array($pluginName, ($pluginType & Dwoo_Core::COMPILABLE_PLUGIN) ? 'compile' : 'process'); |
2808 | 2808 | } else { |
2809 | - $callback = $pluginName . (($pluginType & Dwoo_Core::COMPILABLE_PLUGIN) ? '_compile' : ''); |
|
2809 | + $callback = $pluginName.(($pluginType & Dwoo_Core::COMPILABLE_PLUGIN) ? '_compile' : ''); |
|
2810 | 2810 | } |
2811 | 2811 | } |
2812 | 2812 | |
@@ -2885,7 +2885,7 @@ discard block |
||
2885 | 2885 | } elseif ($curBlock === 'var' || $m[1] === null) { |
2886 | 2886 | return $output; |
2887 | 2887 | } elseif ($curBlock === 'string' || $curBlock === 'root') { |
2888 | - return $m[1].'.'.$output.'.'.$m[1].(isset($add)?$add:null); |
|
2888 | + return $m[1].'.'.$output.'.'.$m[1].(isset($add) ? $add : null); |
|
2889 | 2889 | } |
2890 | 2890 | } |
2891 | 2891 | |
@@ -2960,9 +2960,9 @@ discard block |
||
2960 | 2960 | } elseif (function_exists('smarty_block_'.$name) !== false) { |
2961 | 2961 | $pluginType = Dwoo_Core::SMARTY_BLOCK; |
2962 | 2962 | } else { |
2963 | - if ($pluginType===-1) { |
|
2963 | + if ($pluginType === -1) { |
|
2964 | 2964 | try { |
2965 | - $this->dwoo->getLoader()->loadPlugin($name, isset($phpFunc)===false); |
|
2965 | + $this->dwoo->getLoader()->loadPlugin($name, isset($phpFunc) === false); |
|
2966 | 2966 | } catch (Exception $e) { |
2967 | 2967 | if (isset($phpFunc)) { |
2968 | 2968 | $pluginType = Dwoo_Core::NATIVE_PLUGIN; |
@@ -3019,7 +3019,7 @@ discard block |
||
3019 | 3019 | * @param array $map the parameter map to use, if not provided it will be built from the callback |
3020 | 3020 | * @return array parameters sorted in the correct order with missing optional parameters filled |
3021 | 3021 | */ |
3022 | - protected function mapParams(array $params, $callback, $callType=2, $map = null) |
|
3022 | + protected function mapParams(array $params, $callback, $callType = 2, $map = null) |
|
3023 | 3023 | { |
3024 | 3024 | if (!$map) { |
3025 | 3025 | $map = $this->getParamMap($callback); |
@@ -3038,11 +3038,11 @@ discard block |
||
3038 | 3038 | } |
3039 | 3039 | |
3040 | 3040 | // loops over the param map and assigns values from the template or default value for unset optional params |
3041 | - while (list($k,$v) = each($map)) { |
|
3041 | + while (list($k, $v) = each($map)) { |
|
3042 | 3042 | if ($v[0] === '*') { |
3043 | 3043 | // "rest" array parameter, fill every remaining params in it and then break |
3044 | 3044 | if (count($ps) === 0) { |
3045 | - if ($v[1]===false) { |
|
3045 | + if ($v[1] === false) { |
|
3046 | 3046 | throw new Dwoo_Compilation_Exception($this, 'Rest argument missing for '.str_replace(array('Dwoo_Plugin_', '_compile'), '', (is_array($callback) ? $callback[0] : $callback))); |
3047 | 3047 | } else { |
3048 | 3048 | break; |
@@ -3068,11 +3068,11 @@ discard block |
||
3068 | 3068 | // parameter is defined as ordered param |
3069 | 3069 | $paramlist[$v[0]] = $ps[$k]; |
3070 | 3070 | unset($ps[$k]); |
3071 | - } elseif ($v[1]===false) { |
|
3071 | + } elseif ($v[1] === false) { |
|
3072 | 3072 | // parameter is not defined and not optional, throw error |
3073 | 3073 | if (is_array($callback)) { |
3074 | 3074 | if (is_object($callback[0])) { |
3075 | - $name = get_class($callback[0]) . '::' . $callback[1]; |
|
3075 | + $name = get_class($callback[0]).'::'.$callback[1]; |
|
3076 | 3076 | } else { |
3077 | 3077 | $name = $callback[0]; |
3078 | 3078 | } |
@@ -3081,7 +3081,7 @@ discard block |
||
3081 | 3081 | } |
3082 | 3082 | |
3083 | 3083 | throw new Dwoo_Compilation_Exception($this, 'Argument '.$k.'/'.$v[0].' missing for '.str_replace(array('Dwoo_Plugin_', '_compile'), '', $name)); |
3084 | - } elseif ($v[2]===null) { |
|
3084 | + } elseif ($v[2] === null) { |
|
3085 | 3085 | // enforce lowercased null if default value is null (php outputs NULL with var export) |
3086 | 3086 | $paramlist[$v[0]] = array('null', null, self::T_NULL); |
3087 | 3087 | } else { |
@@ -303,14 +303,14 @@ discard block |
||
303 | 303 | /** |
304 | 304 | * returns the given template rendered using the provided data and optional compiler |
305 | 305 | * |
306 | - * @param mixed $tpl template, can either be a Dwoo_ITemplate object (i.e. Dwoo_Template_File), a valid path to a template, or |
|
306 | + * @param mixed $_tpl template, can either be a Dwoo_ITemplate object (i.e. Dwoo_Template_File), a valid path to a template, or |
|
307 | 307 | * a template as a string it is recommended to provide a Dwoo_ITemplate as it will probably make things faster, |
308 | 308 | * especially if you render a template multiple times |
309 | 309 | * @param mixed $data the data to use, can either be a Dwoo_IDataProvider object (i.e. Dwoo_Data) or an associative array. if you're |
310 | 310 | * rendering the template from cache, it can be left null |
311 | - * @param Dwoo_ICompiler $compiler the compiler that must be used to compile the template, if left empty a default |
|
311 | + * @param Dwoo_ICompiler $_compiler the compiler that must be used to compile the template, if left empty a default |
|
312 | 312 | * Dwoo_Compiler will be used. |
313 | - * @param bool $output flag that defines whether the function returns the output of the template (false, default) or echoes it directly (true) |
|
313 | + * @param bool $_output flag that defines whether the function returns the output of the template (false, default) or echoes it directly (true) |
|
314 | 314 | * @return string nothing or the template output if $output is false |
315 | 315 | */ |
316 | 316 | public function get($_tpl, $data = array(), $_compiler = null, $_output = false) |
@@ -1462,7 +1462,7 @@ discard block |
||
1462 | 1462 | * |
1463 | 1463 | * @param mixed $value the value to assign |
1464 | 1464 | * @param string $scope the variable string, using dwoo variable syntax (i.e. "var.subvar[subsubvar]->property") |
1465 | - * @return bool true if assigned correctly or false if a problem occured while parsing the var string |
|
1465 | + * @return null|false true if assigned correctly or false if a problem occured while parsing the var string |
|
1466 | 1466 | */ |
1467 | 1467 | public function assignInScope($value, $scope) |
1468 | 1468 | { |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | if (!defined('DWOO_DIRECTORY')) { |
4 | - define('DWOO_DIRECTORY', dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR); |
|
4 | + define('DWOO_DIRECTORY', dirname(dirname(__FILE__)).DIRECTORY_SEPARATOR); |
|
5 | 5 | } |
6 | 6 | /** |
7 | 7 | * main dwoo class, allows communication between the compiler, template and data classes |
@@ -160,15 +160,12 @@ discard block |
||
160 | 160 | * |
161 | 161 | * @var array |
162 | 162 | */ |
163 | - protected $resources = array |
|
164 | - ( |
|
165 | - 'file' => array |
|
166 | - ( |
|
163 | + protected $resources = array( |
|
164 | + 'file' => array( |
|
167 | 165 | 'class' => 'Dwoo_Template_File', |
168 | 166 | 'compiler' => null |
169 | 167 | ), |
170 | - 'string' => array |
|
171 | - ( |
|
168 | + 'string' => array( |
|
172 | 169 | 'class' => 'Dwoo_Template_String', |
173 | 170 | 'compiler' => null |
174 | 171 | ) |
@@ -434,8 +431,7 @@ discard block |
||
434 | 431 | */ |
435 | 432 | protected function initGlobals() |
436 | 433 | { |
437 | - $this->globals = array |
|
438 | - ( |
|
434 | + $this->globals = array( |
|
439 | 435 | 'version' => self::VERSION, |
440 | 436 | 'ad' => '<a href="http://dwoo.org/">Powered by Dwoo</a>', |
441 | 437 | 'now' => $_SERVER['REQUEST_TIME'], |
@@ -454,7 +450,7 @@ discard block |
||
454 | 450 | protected function initRuntimeVars(Dwoo_ITemplate $tpl) |
455 | 451 | { |
456 | 452 | $this->runtimePlugins = array(); |
457 | - $this->scope =& $this->data; |
|
453 | + $this->scope = & $this->data; |
|
458 | 454 | $this->scopeTree = array(); |
459 | 455 | $this->stack = array(); |
460 | 456 | $this->curBlock = null; |
@@ -484,7 +480,7 @@ discard block |
||
484 | 480 | } else { |
485 | 481 | $this->plugins[$name] = array('type'=>self::CLASS_PLUGIN | $compilable, 'callback'=>$callback, 'class'=>(is_object($callback[0]) ? get_class($callback[0]) : $callback[0]), 'function'=>$callback[1]); |
486 | 482 | } |
487 | - } elseif(is_string($callback)) { |
|
483 | + } elseif (is_string($callback)) { |
|
488 | 484 | if (class_exists($callback, false)) { |
489 | 485 | if (is_subclass_of($callback, 'Dwoo_Block_Plugin')) { |
490 | 486 | $this->plugins[$name] = array('type'=>self::BLOCK_PLUGIN | $compilable, 'callback'=>$callback, 'class'=>$callback); |
@@ -496,7 +492,7 @@ discard block |
||
496 | 492 | } else { |
497 | 493 | throw new Dwoo_Exception('Callback could not be processed correctly, please check that the function/class you used exists'); |
498 | 494 | } |
499 | - } elseif(is_callable($callback)) { |
|
495 | + } elseif (is_callable($callback)) { |
|
500 | 496 | $this->plugins[$name] = array('type'=>self::FUNC_PLUGIN | $compilable, 'callback'=>$callback); |
501 | 497 | } else { |
502 | 498 | throw new Dwoo_Exception('Callback could not be processed correctly, please check that the function/class you used exists'); |
@@ -563,8 +559,8 @@ discard block |
||
563 | 559 | unset($this->filters[$index]); |
564 | 560 | } elseif (($index = array_search($callback, $this->filters, true)) !== false) { |
565 | 561 | unset($this->filters[$index]); |
566 | - } else { |
|
567 | - $class = 'Dwoo_Filter_' . $callback; |
|
562 | + } else { |
|
563 | + $class = 'Dwoo_Filter_'.$callback; |
|
568 | 564 | foreach ($this->filters as $index=>$filter) { |
569 | 565 | if (is_array($filter) && $filter[0] instanceof $class) { |
570 | 566 | unset($this->filters[$index]); |
@@ -607,7 +603,7 @@ discard block |
||
607 | 603 | public function removeResource($name) |
608 | 604 | { |
609 | 605 | unset($this->resources[$name]); |
610 | - if ($name==='file') { |
|
606 | + if ($name === 'file') { |
|
611 | 607 | $this->resources['file'] = array('class'=>'Dwoo_Template_File', 'compiler'=>null); |
612 | 608 | } |
613 | 609 | } |
@@ -856,11 +852,11 @@ discard block |
||
856 | 852 | * @param int $olderThan minimum time (in seconds) required for a cached template to be cleared |
857 | 853 | * @return int the amount of templates cleared |
858 | 854 | */ |
859 | - public function clearCache($olderThan=-1) |
|
855 | + public function clearCache($olderThan = -1) |
|
860 | 856 | { |
861 | 857 | $cacheDirs = new RecursiveDirectoryIterator($this->getCacheDir()); |
862 | 858 | $cache = new RecursiveIteratorIterator($cacheDirs); |
863 | - $expired = time() - $olderThan; |
|
859 | + $expired = time()-$olderThan; |
|
864 | 860 | $count = 0; |
865 | 861 | foreach ($cache as $file) { |
866 | 862 | if ($cache->isDot() || $cache->isDir() || substr($file, -5) !== '.html') { |
@@ -901,7 +897,7 @@ discard block |
||
901 | 897 | * and return true only if it's not empty |
902 | 898 | * @return int|bool true if it's an array|arrayaccess (or the item count if $checkIsEmpty is true) or false if it's not an array|arrayaccess (or 0 if $checkIsEmpty is true) |
903 | 899 | */ |
904 | - public function isArray($value, $checkIsEmpty=false) |
|
900 | + public function isArray($value, $checkIsEmpty = false) |
|
905 | 901 | { |
906 | 902 | if (is_array($value) === true || $value instanceof ArrayAccess) { |
907 | 903 | if ($checkIsEmpty === false) { |
@@ -920,7 +916,7 @@ discard block |
||
920 | 916 | * and return true only if it's not empty |
921 | 917 | * @return int|bool true if it's an array|traversable (or the item count if $checkIsEmpty is true) or false if it's not an array|traversable (or 0 if $checkIsEmpty is true) |
922 | 918 | */ |
923 | - public function isTraversable($value, $checkIsEmpty=false) |
|
919 | + public function isTraversable($value, $checkIsEmpty = false) |
|
924 | 920 | { |
925 | 921 | if (is_array($value) === true) { |
926 | 922 | if ($checkIsEmpty === false) { |
@@ -970,7 +966,7 @@ discard block |
||
970 | 966 | * @param string $message the error message |
971 | 967 | * @param int $level the error level, one of the PHP's E_* constants |
972 | 968 | */ |
973 | - public function triggerError($message, $level=E_USER_NOTICE) |
|
969 | + public function triggerError($message, $level = E_USER_NOTICE) |
|
974 | 970 | { |
975 | 971 | if (!($tplIdentifier = $this->template->getResourceIdentifier())) { |
976 | 972 | $tplIdentifier = $this->template->getResourceName(); |
@@ -989,7 +985,7 @@ discard block |
||
989 | 985 | * @param array $args the arguments to be passed to the block's init() function |
990 | 986 | * @return Dwoo_Block_Plugin the newly created block |
991 | 987 | */ |
992 | - public function addStack($blockName, array $args=array()) |
|
988 | + public function addStack($blockName, array $args = array()) |
|
993 | 989 | { |
994 | 990 | if (isset($this->plugins[$blockName])) { |
995 | 991 | $class = $this->plugins[$blockName]['class']; |
@@ -1008,18 +1004,18 @@ discard block |
||
1008 | 1004 | $block = new $class($this); |
1009 | 1005 | |
1010 | 1006 | $cnt = count($args); |
1011 | - if ($cnt===0) { |
|
1007 | + if ($cnt === 0) { |
|
1012 | 1008 | $block->init(); |
1013 | - } elseif ($cnt===1) { |
|
1009 | + } elseif ($cnt === 1) { |
|
1014 | 1010 | $block->init($args[0]); |
1015 | - } elseif ($cnt===2) { |
|
1011 | + } elseif ($cnt === 2) { |
|
1016 | 1012 | $block->init($args[0], $args[1]); |
1017 | - } elseif ($cnt===3) { |
|
1013 | + } elseif ($cnt === 3) { |
|
1018 | 1014 | $block->init($args[0], $args[1], $args[2]); |
1019 | - } elseif ($cnt===4) { |
|
1015 | + } elseif ($cnt === 4) { |
|
1020 | 1016 | $block->init($args[0], $args[1], $args[2], $args[3]); |
1021 | 1017 | } else { |
1022 | - call_user_func_array(array($block,'init'), $args); |
|
1018 | + call_user_func_array(array($block, 'init'), $args); |
|
1023 | 1019 | } |
1024 | 1020 | |
1025 | 1021 | $this->stack[] = $this->curBlock = $block; |
@@ -1040,15 +1036,15 @@ discard block |
||
1040 | 1036 | ob_clean(); |
1041 | 1037 | |
1042 | 1038 | $cnt = count($args); |
1043 | - if ($cnt===0) { |
|
1039 | + if ($cnt === 0) { |
|
1044 | 1040 | $this->curBlock->end(); |
1045 | - } elseif ($cnt===1) { |
|
1041 | + } elseif ($cnt === 1) { |
|
1046 | 1042 | $this->curBlock->end($args[0]); |
1047 | - } elseif ($cnt===2) { |
|
1043 | + } elseif ($cnt === 2) { |
|
1048 | 1044 | $this->curBlock->end($args[0], $args[1]); |
1049 | - } elseif ($cnt===3) { |
|
1045 | + } elseif ($cnt === 3) { |
|
1050 | 1046 | $this->curBlock->end($args[0], $args[1], $args[2]); |
1051 | - } elseif ($cnt===4) { |
|
1047 | + } elseif ($cnt === 4) { |
|
1052 | 1048 | $this->curBlock->end($args[0], $args[1], $args[2], $args[3]); |
1053 | 1049 | } else { |
1054 | 1050 | call_user_func_array(array($this->curBlock, 'end'), $args); |
@@ -1060,7 +1056,7 @@ discard block |
||
1060 | 1056 | $this->curBlock = end($this->stack); |
1061 | 1057 | $this->curBlock->buffer($tmp->process()); |
1062 | 1058 | } else { |
1063 | - if($this->buffer !== '') { |
|
1059 | + if ($this->buffer !== '') { |
|
1064 | 1060 | echo $this->buffer; |
1065 | 1061 | $this->buffer = ''; |
1066 | 1062 | } |
@@ -1141,15 +1137,15 @@ discard block |
||
1141 | 1137 | $plugin = $this->getObjectPlugin($class); |
1142 | 1138 | |
1143 | 1139 | $cnt = count($params); |
1144 | - if ($cnt===0) { |
|
1140 | + if ($cnt === 0) { |
|
1145 | 1141 | return $plugin->process(); |
1146 | - } elseif ($cnt===1) { |
|
1142 | + } elseif ($cnt === 1) { |
|
1147 | 1143 | return $plugin->process($params[0]); |
1148 | - } elseif ($cnt===2) { |
|
1144 | + } elseif ($cnt === 2) { |
|
1149 | 1145 | return $plugin->process($params[0], $params[1]); |
1150 | - } elseif ($cnt===3) { |
|
1146 | + } elseif ($cnt === 3) { |
|
1151 | 1147 | return $plugin->process($params[0], $params[1], $params[2]); |
1152 | - } elseif ($cnt===4) { |
|
1148 | + } elseif ($cnt === 4) { |
|
1153 | 1149 | return $plugin->process($params[0], $params[1], $params[2], $params[3]); |
1154 | 1150 | } else { |
1155 | 1151 | return call_user_func_array(array($plugin, 'process'), $params); |
@@ -1185,23 +1181,23 @@ discard block |
||
1185 | 1181 | |
1186 | 1182 | if (is_string($callback) === false) { |
1187 | 1183 | while (($i = array_shift($keys)) !== null) { |
1188 | - $out[] = call_user_func_array($callback, array(1=>$items[$i]) + $params); |
|
1184 | + $out[] = call_user_func_array($callback, array(1=>$items[$i])+$params); |
|
1189 | 1185 | } |
1190 | - } elseif ($cnt===1) { |
|
1186 | + } elseif ($cnt === 1) { |
|
1191 | 1187 | while (($i = array_shift($keys)) !== null) { |
1192 | 1188 | $out[] = $callback($this, $items[$i]); |
1193 | 1189 | } |
1194 | - } elseif ($cnt===2) { |
|
1190 | + } elseif ($cnt === 2) { |
|
1195 | 1191 | while (($i = array_shift($keys)) !== null) { |
1196 | 1192 | $out[] = $callback($this, $items[$i], $params[2]); |
1197 | 1193 | } |
1198 | - } elseif ($cnt===3) { |
|
1194 | + } elseif ($cnt === 3) { |
|
1199 | 1195 | while (($i = array_shift($keys)) !== null) { |
1200 | 1196 | $out[] = $callback($this, $items[$i], $params[2], $params[3]); |
1201 | 1197 | } |
1202 | 1198 | } else { |
1203 | 1199 | while (($i = array_shift($keys)) !== null) { |
1204 | - $out[] = call_user_func_array($callback, array(1=>$items[$i]) + $params); |
|
1200 | + $out[] = call_user_func_array($callback, array(1=>$items[$i])+$params); |
|
1205 | 1201 | } |
1206 | 1202 | } |
1207 | 1203 | } else { |
@@ -1210,27 +1206,27 @@ discard block |
||
1210 | 1206 | |
1211 | 1207 | if (is_string($callback) === false) { |
1212 | 1208 | while (($i = array_shift($keys)) !== null) { |
1213 | - $out[] = call_user_func_array($callback, array($items[$i]) + $params); |
|
1209 | + $out[] = call_user_func_array($callback, array($items[$i])+$params); |
|
1214 | 1210 | } |
1215 | - } elseif ($cnt===1) { |
|
1211 | + } elseif ($cnt === 1) { |
|
1216 | 1212 | while (($i = array_shift($keys)) !== null) { |
1217 | 1213 | $out[] = $callback($items[$i]); |
1218 | 1214 | } |
1219 | - } elseif ($cnt===2) { |
|
1215 | + } elseif ($cnt === 2) { |
|
1220 | 1216 | while (($i = array_shift($keys)) !== null) { |
1221 | 1217 | $out[] = $callback($items[$i], $params[1]); |
1222 | 1218 | } |
1223 | - } elseif ($cnt===3) { |
|
1219 | + } elseif ($cnt === 3) { |
|
1224 | 1220 | while (($i = array_shift($keys)) !== null) { |
1225 | 1221 | $out[] = $callback($items[$i], $params[1], $params[2]); |
1226 | 1222 | } |
1227 | - } elseif ($cnt===4) { |
|
1223 | + } elseif ($cnt === 4) { |
|
1228 | 1224 | while (($i = array_shift($keys)) !== null) { |
1229 | 1225 | $out[] = $callback($items[$i], $params[1], $params[2], $params[3]); |
1230 | 1226 | } |
1231 | 1227 | } else { |
1232 | 1228 | while (($i = array_shift($keys)) !== null) { |
1233 | - $out[] = call_user_func_array($callback, array($items[$i]) + $params); |
|
1229 | + $out[] = call_user_func_array($callback, array($items[$i])+$params); |
|
1234 | 1230 | } |
1235 | 1231 | } |
1236 | 1232 | } |
@@ -1295,7 +1291,7 @@ discard block |
||
1295 | 1291 | $tree = $this->scopeTree; |
1296 | 1292 | $cur = $this->data; |
1297 | 1293 | |
1298 | - while ($parentLevels--!==0) { |
|
1294 | + while ($parentLevels-- !== 0) { |
|
1299 | 1295 | array_pop($tree); |
1300 | 1296 | } |
1301 | 1297 | |
@@ -1307,7 +1303,7 @@ discard block |
||
1307 | 1303 | } |
1308 | 1304 | } |
1309 | 1305 | |
1310 | - if ($varstr!==null) { |
|
1306 | + if ($varstr !== null) { |
|
1311 | 1307 | return $this->readVarInto($varstr, $cur); |
1312 | 1308 | } else { |
1313 | 1309 | return $cur; |
@@ -1322,14 +1318,14 @@ discard block |
||
1322 | 1318 | */ |
1323 | 1319 | public function readVar($varstr) |
1324 | 1320 | { |
1325 | - if (is_array($varstr)===true) { |
|
1321 | + if (is_array($varstr) === true) { |
|
1326 | 1322 | $m = $varstr; |
1327 | 1323 | unset($varstr); |
1328 | 1324 | } else { |
1329 | 1325 | if (strstr($varstr, '.') === false && strstr($varstr, '[') === false && strstr($varstr, '->') === false) { |
1330 | 1326 | if ($varstr === 'dwoo') { |
1331 | 1327 | return $this->globals; |
1332 | - } elseif ($varstr === '__' || $varstr === '_root' ) { |
|
1328 | + } elseif ($varstr === '__' || $varstr === '_root') { |
|
1333 | 1329 | return $this->data; |
1334 | 1330 | $varstr = substr($varstr, 6); |
1335 | 1331 | } elseif ($varstr === '_' || $varstr === '_parent') { |
@@ -1466,8 +1462,8 @@ discard block |
||
1466 | 1462 | */ |
1467 | 1463 | public function assignInScope($value, $scope) |
1468 | 1464 | { |
1469 | - $tree =& $this->scopeTree; |
|
1470 | - $data =& $this->data; |
|
1465 | + $tree = & $this->scopeTree; |
|
1466 | + $data = & $this->data; |
|
1471 | 1467 | |
1472 | 1468 | if (!is_string($scope)) { |
1473 | 1469 | return $this->triggerError('Assignments must be done into strings, ('.gettype($scope).') '.var_export($scope, true).' given', E_USER_ERROR); |
@@ -1478,7 +1474,7 @@ discard block |
||
1478 | 1474 | // TODO handle _root/_parent scopes ? |
1479 | 1475 | preg_match_all('#(\[|->|\.)?([^.[\]-]+)\]?#i', $scope, $m); |
1480 | 1476 | |
1481 | - $cur =& $this->scope; |
|
1477 | + $cur = & $this->scope; |
|
1482 | 1478 | $last = array(array_pop($m[1]), array_pop($m[2])); |
1483 | 1479 | |
1484 | 1480 | while (list($k, $sep) = each($m[1])) { |
@@ -1486,12 +1482,12 @@ discard block |
||
1486 | 1482 | if (is_array($cur) === false) { |
1487 | 1483 | $cur = array(); |
1488 | 1484 | } |
1489 | - $cur =& $cur[$m[2][$k]]; |
|
1485 | + $cur = & $cur[$m[2][$k]]; |
|
1490 | 1486 | } elseif ($sep === '->') { |
1491 | 1487 | if (is_object($cur) === false) { |
1492 | 1488 | $cur = new stdClass; |
1493 | 1489 | } |
1494 | - $cur =& $cur->$m[2][$k]; |
|
1490 | + $cur = & $cur->$m[2][$k]; |
|
1495 | 1491 | } else { |
1496 | 1492 | return false; |
1497 | 1493 | } |
@@ -1524,31 +1520,31 @@ discard block |
||
1524 | 1520 | { |
1525 | 1521 | $old = $this->scopeTree; |
1526 | 1522 | |
1527 | - if (is_string($scope)===true) { |
|
1523 | + if (is_string($scope) === true) { |
|
1528 | 1524 | $scope = explode('.', $scope); |
1529 | 1525 | } |
1530 | 1526 | |
1531 | - if ($absolute===true) { |
|
1532 | - $this->scope =& $this->data; |
|
1527 | + if ($absolute === true) { |
|
1528 | + $this->scope = & $this->data; |
|
1533 | 1529 | $this->scopeTree = array(); |
1534 | 1530 | } |
1535 | 1531 | |
1536 | 1532 | while (($bit = array_shift($scope)) !== null) { |
1537 | 1533 | if ($bit === '_' || $bit === '_parent') { |
1538 | 1534 | array_pop($this->scopeTree); |
1539 | - $this->scope =& $this->data; |
|
1535 | + $this->scope = & $this->data; |
|
1540 | 1536 | $cnt = count($this->scopeTree); |
1541 | - for ($i=0;$i<$cnt;$i++) |
|
1542 | - $this->scope =& $this->scope[$this->scopeTree[$i]]; |
|
1537 | + for ($i = 0; $i < $cnt; $i++) |
|
1538 | + $this->scope = & $this->scope[$this->scopeTree[$i]]; |
|
1543 | 1539 | } elseif ($bit === '__' || $bit === '_root') { |
1544 | - $this->scope =& $this->data; |
|
1540 | + $this->scope = & $this->data; |
|
1545 | 1541 | $this->scopeTree = array(); |
1546 | 1542 | } elseif (isset($this->scope[$bit])) { |
1547 | - if($this->scope instanceof ArrayAccess) { |
|
1543 | + if ($this->scope instanceof ArrayAccess) { |
|
1548 | 1544 | $tmp = $this->scope[$bit]; |
1549 | - $this->scope =& $tmp; |
|
1545 | + $this->scope = & $tmp; |
|
1550 | 1546 | } else { |
1551 | - $this->scope =& $this->scope[$bit]; |
|
1547 | + $this->scope = & $this->scope[$bit]; |
|
1552 | 1548 | } |
1553 | 1549 | $this->scopeTree[] = $bit; |
1554 | 1550 | } else { |
@@ -66,7 +66,6 @@ |
||
66 | 66 | * merges the given array(s) with the current data with array_merge |
67 | 67 | * |
68 | 68 | * @param array $data the array to merge |
69 | - * @param array $data2 $data3 ... other arrays to merge, optional, etc. |
|
70 | 69 | */ |
71 | 70 | public function mergeData(array $data) |
72 | 71 | { |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | { |
91 | 91 | if (is_array($name)) { |
92 | 92 | reset($name); |
93 | - while (list($k,$v) = each($name)) |
|
93 | + while (list($k, $v) = each($name)) |
|
94 | 94 | $this->data[$k] = $v; |
95 | 95 | } else { |
96 | 96 | $this->data[$name] = $val; |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | */ |
118 | 118 | public function assignByRef($name, &$val) |
119 | 119 | { |
120 | - $this->data[$name] =& $val; |
|
120 | + $this->data[$name] = & $val; |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | } |
139 | 139 | |
140 | 140 | if ($merge === true && is_array($val)) { |
141 | - $this->data[$key] = $val + $this->data[$key]; |
|
141 | + $this->data[$key] = $val+$this->data[$key]; |
|
142 | 142 | } else { |
143 | 143 | $this->data[$key][] = $val; |
144 | 144 | } |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | } |
152 | 152 | |
153 | 153 | if ($merge === true && is_array($val)) { |
154 | - $this->data[$name] = $val + $this->data[$name]; |
|
154 | + $this->data[$name] = $val+$this->data[$name]; |
|
155 | 155 | } else { |
156 | 156 | $this->data[$name][] = $val; |
157 | 157 | } |
@@ -174,10 +174,10 @@ discard block |
||
174 | 174 | |
175 | 175 | if ($merge === true && is_array($val)) { |
176 | 176 | foreach ($val as $key => &$val) { |
177 | - $this->data[$name][$key] =& $val; |
|
177 | + $this->data[$name][$key] = & $val; |
|
178 | 178 | } |
179 | 179 | } else { |
180 | - $this->data[$name][] =& $val; |
|
180 | + $this->data[$name][] = & $val; |
|
181 | 181 | } |
182 | 182 | } |
183 | 183 |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | /** |
25 | 25 | * compiles the provided string down to php code |
26 | 26 | * |
27 | - * @param string $templateStr the template to compile |
|
27 | + * @param string $template the template to compile |
|
28 | 28 | * @return string a compiled php code string |
29 | 29 | */ |
30 | 30 | public function compile(Dwoo_Core $dwoo, Dwoo_ITemplate $template); |
@@ -34,6 +34,7 @@ discard block |
||
34 | 34 | * |
35 | 35 | * @see Dwoo_Core::addPlugin |
36 | 36 | * @param array $customPlugins an array of custom plugins |
37 | + * @return void |
|
37 | 38 | */ |
38 | 39 | public function setCustomPlugins(array $customPlugins); |
39 | 40 | |
@@ -44,6 +45,7 @@ discard block |
||
44 | 45 | * set it on the Dwoo object as it will be passed onto the compiler automatically |
45 | 46 | * |
46 | 47 | * @param Dwoo_Security_Policy $policy the security policy object |
48 | + * @return void |
|
47 | 49 | */ |
48 | 50 | public function setSecurityPolicy(Dwoo_Security_Policy $policy = null); |
49 | 51 | } |
@@ -42,6 +42,9 @@ |
||
42 | 42 | |
43 | 43 | protected $corePluginDir; |
44 | 44 | |
45 | + /** |
|
46 | + * @param string $cacheDir |
|
47 | + */ |
|
45 | 48 | public function __construct($cacheDir) |
46 | 49 | { |
47 | 50 | $this->corePluginDir = DWOO_DIRECTORY . 'plugins'; |
@@ -44,14 +44,14 @@ discard block |
||
44 | 44 | |
45 | 45 | public function __construct($cacheDir) |
46 | 46 | { |
47 | - $this->corePluginDir = DWOO_DIRECTORY . 'plugins'; |
|
48 | - $this->cacheDir = rtrim($cacheDir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; |
|
47 | + $this->corePluginDir = DWOO_DIRECTORY.'plugins'; |
|
48 | + $this->cacheDir = rtrim($cacheDir, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR; |
|
49 | 49 | |
50 | 50 | // include class paths or rebuild paths if the cache file isn't there |
51 | 51 | $cacheFile = $this->cacheDir.'classpath.cache.d'.Dwoo_Core::RELEASE_TAG.'.php'; |
52 | 52 | if (file_exists($cacheFile)) { |
53 | 53 | $classpath = file_get_contents($cacheFile); |
54 | - $this->classPath = unserialize($classpath) + $this->classPath; |
|
54 | + $this->classPath = unserialize($classpath)+$this->classPath; |
|
55 | 55 | } else { |
56 | 56 | $this->rebuildClassPathCache($this->corePluginDir, $cacheFile); |
57 | 57 | } |
@@ -65,25 +65,25 @@ discard block |
||
65 | 65 | */ |
66 | 66 | protected function rebuildClassPathCache($path, $cacheFile) |
67 | 67 | { |
68 | - if ($cacheFile!==false) { |
|
68 | + if ($cacheFile !== false) { |
|
69 | 69 | $tmp = $this->classPath; |
70 | 70 | $this->classPath = array(); |
71 | 71 | } |
72 | 72 | |
73 | 73 | // iterates over all files/folders |
74 | - $list = glob(rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . '*'); |
|
74 | + $list = glob(rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'*'); |
|
75 | 75 | if (is_array($list)) { |
76 | 76 | foreach ($list as $f) { |
77 | 77 | if (is_dir($f)) { |
78 | 78 | $this->rebuildClassPathCache($f, false); |
79 | 79 | } else { |
80 | - $this->classPath[str_replace(array('function.','block.','modifier.','outputfilter.','filter.','prefilter.','postfilter.','pre.','post.','output.','shared.','helper.'), '', basename($f, '.php'))] = $f; |
|
80 | + $this->classPath[str_replace(array('function.', 'block.', 'modifier.', 'outputfilter.', 'filter.', 'prefilter.', 'postfilter.', 'pre.', 'post.', 'output.', 'shared.', 'helper.'), '', basename($f, '.php'))] = $f; |
|
81 | 81 | } |
82 | 82 | } |
83 | 83 | } |
84 | 84 | |
85 | 85 | // save in file if it's the first call (not recursed) |
86 | - if ($cacheFile!==false) { |
|
86 | + if ($cacheFile !== false) { |
|
87 | 87 | if (!file_put_contents($cacheFile, serialize($this->classPath))) { |
88 | 88 | throw new Dwoo_Exception('Could not write into '.$cacheFile.', either because the folder is not there (create it) or because of the chmod configuration (please ensure this directory is writable by php), alternatively you can change the directory used with $dwoo->setCompileDir() or provide a custom loader object with $dwoo->setLoader()'); |
89 | 89 | } |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | !(include $this->classPath[$class])) |
110 | 110 | { |
111 | 111 | if ($forceRehash) { |
112 | - $this->rebuildClassPathCache($this->corePluginDir, $this->cacheDir . 'classpath.cache.d'.Dwoo_Core::RELEASE_TAG.'.php'); |
|
112 | + $this->rebuildClassPathCache($this->corePluginDir, $this->cacheDir.'classpath.cache.d'.Dwoo_Core::RELEASE_TAG.'.php'); |
|
113 | 113 | foreach ($this->paths as $path=>$file) { |
114 | 114 | $this->rebuildClassPathCache($path, $file); |
115 | 115 | } |
@@ -142,11 +142,11 @@ discard block |
||
142 | 142 | if (!$pluginDir) { |
143 | 143 | throw new Dwoo_Exception('Plugin directory does not exist or can not be read : '.$pluginDirectory); |
144 | 144 | } |
145 | - $cacheFile = $this->cacheDir . 'classpath-'.substr(strtr($pluginDir, '/\\:'.PATH_SEPARATOR, '----'), strlen($pluginDir) > 80 ? -80 : 0).'.d'.Dwoo_Core::RELEASE_TAG.'.php'; |
|
145 | + $cacheFile = $this->cacheDir.'classpath-'.substr(strtr($pluginDir, '/\\:'.PATH_SEPARATOR, '----'), strlen($pluginDir) > 80 ? -80 : 0).'.d'.Dwoo_Core::RELEASE_TAG.'.php'; |
|
146 | 146 | $this->paths[$pluginDir] = $cacheFile; |
147 | 147 | if (file_exists($cacheFile)) { |
148 | 148 | $classpath = file_get_contents($cacheFile); |
149 | - $this->classPath = unserialize($classpath) + $this->classPath; |
|
149 | + $this->classPath = unserialize($classpath)+$this->classPath; |
|
150 | 150 | } else { |
151 | 151 | $this->rebuildClassPathCache($pluginDir, $cacheFile); |
152 | 152 | } |
@@ -27,7 +27,6 @@ |
||
27 | 27 | * constructor, if you override it, call parent::__construct($dwoo); or assign |
28 | 28 | * the dwoo instance yourself if you need it |
29 | 29 | * |
30 | - * @param Dwoo_Core $dwoo the dwoo instance that runs this plugin |
|
31 | 30 | */ |
32 | 31 | public function __construct(Dwoo_Compiler $compiler) |
33 | 32 | { |