@@ -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 |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); |
|
1 | +<?php if (!defined('BASEPATH')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | |
3 | 5 | require "dwoo/dwooAutoload.php"; |
4 | 6 |
@@ -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; |
@@ -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() |
@@ -248,8 +248,7 @@ discard block |
||
248 | 248 | // |
249 | 249 | elseif (is_subclass_of($engine, 'Dwoo') || 'Dwoo' === $engine) { |
250 | 250 | $this->_engine = new $engine(); |
251 | - } |
|
252 | - else { |
|
251 | + } else { |
|
253 | 252 | throw new Dwoo_Exception("Custom engine must be a subclass of Dwoo"); |
254 | 253 | } |
255 | 254 | } |
@@ -277,11 +276,9 @@ discard block |
||
277 | 276 | { |
278 | 277 | if ($data instanceof Dwoo_IDataProvider) { |
279 | 278 | $this->_dataProvider = $data; |
280 | - } |
|
281 | - elseif (is_subclass_of($data, 'Dwoo_Data') || 'Dwoo_Data' == $data) { |
|
279 | + } elseif (is_subclass_of($data, 'Dwoo_Data') || 'Dwoo_Data' == $data) { |
|
282 | 280 | $this->_dataProvider = new $data(); |
283 | - } |
|
284 | - else { |
|
281 | + } else { |
|
285 | 282 | throw new Dwoo_Exception("Custom data provider must be a subclass of Dwoo_Data or instance of Dwoo_IDataProvider"); |
286 | 283 | } |
287 | 284 | } |
@@ -320,8 +317,7 @@ discard block |
||
320 | 317 | // if param given as a string |
321 | 318 | elseif (is_subclass_of($compiler, 'Dwoo_Compiler') || 'Dwoo_Compiler' == $compiler) { |
322 | 319 | $this->_compiler = new $compiler; |
323 | - } |
|
324 | - else { |
|
320 | + } else { |
|
325 | 321 | throw new Dwoo_Exception("Custom compiler must be a subclass of Dwoo_Compiler or instance of Dwoo_ICompiler"); |
326 | 322 | } |
327 | 323 | } |
@@ -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 | { |
@@ -713,9 +713,13 @@ discard block |
||
713 | 713 | $compiled = $this->addBlock('topLevelBlock', array(), 0); |
714 | 714 | $this->stack[0]['buffer'] = ''; |
715 | 715 | |
716 | - if ($this->debug) echo 'COMPILER INIT<br />'; |
|
716 | + if ($this->debug) { |
|
717 | + echo 'COMPILER INIT<br />'; |
|
718 | + } |
|
717 | 719 | |
718 | - if ($this->debug) echo 'PROCESSING PREPROCESSORS ('.count($this->processors['pre']).')<br>'; |
|
720 | + if ($this->debug) { |
|
721 | + echo 'PROCESSING PREPROCESSORS ('.count($this->processors['pre']).')<br>'; |
|
722 | + } |
|
719 | 723 | |
720 | 724 | // runs preprocessors |
721 | 725 | foreach ($this->processors['pre'] as $preProc) { |
@@ -731,7 +735,9 @@ discard block |
||
731 | 735 | unset($preProc); |
732 | 736 | |
733 | 737 | // show template source if debug |
734 | - if ($this->debug) echo '<pre>'.print_r(htmlentities($tpl), true).'</pre><hr />'; |
|
738 | + if ($this->debug) { |
|
739 | + echo '<pre>'.print_r(htmlentities($tpl), true).'</pre><hr />'; |
|
740 | + } |
|
735 | 741 | |
736 | 742 | // strips php tags if required by the security policy |
737 | 743 | if ($this->securityPolicy !== null) { |
@@ -820,7 +826,9 @@ discard block |
||
820 | 826 | |
821 | 827 | $compiled .= $this->removeBlock('topLevelBlock'); |
822 | 828 | |
823 | - if ($this->debug) echo 'PROCESSING POSTPROCESSORS<br>'; |
|
829 | + if ($this->debug) { |
|
830 | + echo 'PROCESSING POSTPROCESSORS<br>'; |
|
831 | + } |
|
824 | 832 | |
825 | 833 | foreach ($this->processors['post'] as $postProc) { |
826 | 834 | if (is_array($postProc) && isset($postProc['autoload'])) { |
@@ -834,7 +842,9 @@ discard block |
||
834 | 842 | } |
835 | 843 | unset($postProc); |
836 | 844 | |
837 | - if ($this->debug) echo 'COMPILATION COMPLETE : MEM USAGE : '.memory_get_usage().'<br>'; |
|
845 | + if ($this->debug) { |
|
846 | + echo 'COMPILATION COMPLETE : MEM USAGE : '.memory_get_usage().'<br>'; |
|
847 | + } |
|
838 | 848 | |
839 | 849 | $output = "<?php\n/* template head */\n"; |
840 | 850 | |
@@ -902,7 +912,9 @@ discard block |
||
902 | 912 | echo ($i+1).'. '.$line."\r\n"; |
903 | 913 | } |
904 | 914 | } |
905 | - if ($this->debug) echo '<hr></pre></pre>'; |
|
915 | + if ($this->debug) { |
|
916 | + echo '<hr></pre></pre>'; |
|
917 | + } |
|
906 | 918 | |
907 | 919 | $this->template = $this->dwoo = null; |
908 | 920 | $tpl = null; |
@@ -987,8 +999,9 @@ discard block |
||
987 | 999 | reset($this->scopeTree); |
988 | 1000 | $this->scope =& $this->data; |
989 | 1001 | $cnt = count($this->scopeTree); |
990 | - for ($i=0;$i<$cnt;$i++) |
|
991 | - $this->scope =& $this->scope[$this->scopeTree[$i]]; |
|
1002 | + for ($i=0;$i<$cnt;$i++) { |
|
1003 | + $this->scope =& $this->scope[$this->scopeTree[$i]]; |
|
1004 | + } |
|
992 | 1005 | } elseif ($bit === '_root' || $bit === '__') { |
993 | 1006 | $this->scope =& $this->data; |
994 | 1007 | $this->scopeTree = array(); |
@@ -1253,7 +1266,9 @@ discard block |
||
1253 | 1266 | if ($curBlock === 'root' && substr($in, $from, strlen($this->rd)) === $this->rd) { |
1254 | 1267 | // end template tag |
1255 | 1268 | $pointer += strlen($this->rd); |
1256 | - if ($this->debug) echo 'TEMPLATE PARSING ENDED<br />'; |
|
1269 | + if ($this->debug) { |
|
1270 | + echo 'TEMPLATE PARSING ENDED<br />'; |
|
1271 | + } |
|
1257 | 1272 | return false; |
1258 | 1273 | } |
1259 | 1274 | $from++; |
@@ -1272,7 +1287,9 @@ discard block |
||
1272 | 1287 | |
1273 | 1288 | $substr = substr($in, $from, $to-$from); |
1274 | 1289 | |
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/>'; |
|
1290 | + if ($this->debug) { |
|
1291 | + 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/>'; |
|
1292 | + } |
|
1276 | 1293 | $parsed = ""; |
1277 | 1294 | |
1278 | 1295 | if ($curBlock === 'root' && $first === '*') { |
@@ -1357,7 +1374,9 @@ discard block |
||
1357 | 1374 | $parsed = 'func'; |
1358 | 1375 | } elseif ($first === ';') { |
1359 | 1376 | // instruction end |
1360 | - if ($this->debug) echo 'END OF INSTRUCTION<br />'; |
|
1377 | + if ($this->debug) { |
|
1378 | + echo 'END OF INSTRUCTION<br />'; |
|
1379 | + } |
|
1361 | 1380 | if ($pointer !== null) { |
1362 | 1381 | $pointer++; |
1363 | 1382 | } |
@@ -1377,20 +1396,28 @@ discard block |
||
1377 | 1396 | if ($this->curBlock['type'] == 'else' || $this->curBlock['type'] == 'elseif') { |
1378 | 1397 | $pointer -= strlen($match[0]); |
1379 | 1398 | } |
1380 | - if ($this->debug) echo 'TOP BLOCK CLOSED<br />'; |
|
1399 | + if ($this->debug) { |
|
1400 | + echo 'TOP BLOCK CLOSED<br />'; |
|
1401 | + } |
|
1381 | 1402 | return $this->removeTopBlock(); |
1382 | 1403 | } else { |
1383 | - if ($this->debug) echo 'BLOCK OF TYPE '.$match[1].' CLOSED<br />'; |
|
1404 | + if ($this->debug) { |
|
1405 | + echo 'BLOCK OF TYPE '.$match[1].' CLOSED<br />'; |
|
1406 | + } |
|
1384 | 1407 | return $this->removeBlock($match[1]); |
1385 | 1408 | } |
1386 | 1409 | } elseif ($curBlock === 'root' && substr($substr, 0, strlen($this->rd)) === $this->rd) { |
1387 | 1410 | // end template tag |
1388 | - if ($this->debug) echo 'TAG PARSING ENDED<br />'; |
|
1411 | + if ($this->debug) { |
|
1412 | + echo 'TAG PARSING ENDED<br />'; |
|
1413 | + } |
|
1389 | 1414 | $pointer += strlen($this->rd); |
1390 | 1415 | return false; |
1391 | 1416 | } elseif (is_array($parsingParams) && preg_match('#^(([\'"]?)[a-z0-9_]+\2\s*='.($curBlock === 'array' ? '>?':'').')(?:\s+|[^=]).*#i', $substr, $match)) { |
1392 | 1417 | // named parameter |
1393 | - if ($this->debug) echo 'NAMED PARAM FOUND<br />'; |
|
1418 | + if ($this->debug) { |
|
1419 | + echo 'NAMED PARAM FOUND<br />'; |
|
1420 | + } |
|
1394 | 1421 | $len = strlen($match[1]); |
1395 | 1422 | while (substr($in, $from+$len, 1)===' ') { |
1396 | 1423 | $len++; |
@@ -1430,7 +1457,9 @@ discard block |
||
1430 | 1457 | // var parsed, check if any var-extension applies |
1431 | 1458 | if ($parsed==='var') { |
1432 | 1459 | if (preg_match('#^\s*([/%+*-])\s*([a-z0-9]|\$)#i', $substr, $match)) { |
1433 | - if($this->debug) echo 'PARSING POST-VAR EXPRESSION '.$substr.'<br />'; |
|
1460 | + if($this->debug) { |
|
1461 | + echo 'PARSING POST-VAR EXPRESSION '.$substr.'<br />'; |
|
1462 | + } |
|
1434 | 1463 | // parse expressions |
1435 | 1464 | $pointer += strlen($match[0]) - 1; |
1436 | 1465 | if (is_array($parsingParams)) { |
@@ -1460,7 +1489,9 @@ discard block |
||
1460 | 1489 | } |
1461 | 1490 | } |
1462 | 1491 | } else if ($curBlock === 'root' && preg_match('#^(\s*(?:[+/*%-.]=|=|\+\+|--)\s*)(.*)#s', $substr, $match)) { |
1463 | - if($this->debug) echo 'PARSING POST-VAR ASSIGNMENT '.$substr.'<br />'; |
|
1492 | + if($this->debug) { |
|
1493 | + echo 'PARSING POST-VAR ASSIGNMENT '.$substr.'<br />'; |
|
1494 | + } |
|
1464 | 1495 | // parse assignment |
1465 | 1496 | $value = $match[2]; |
1466 | 1497 | $operator = trim($match[1]); |
@@ -1502,7 +1533,9 @@ discard block |
||
1502 | 1533 | $out = Dwoo_Compiler::PHP_OPEN. $echo . $out . $operator . implode(' ', $value) . Dwoo_Compiler::PHP_CLOSE; |
1503 | 1534 | } else if ($curBlock === 'array' && is_array($parsingParams) && preg_match('#^(\s*=>?\s*)#', $substr, $match)) { |
1504 | 1535 | // parse namedparam with var as name (only for array) |
1505 | - if ($this->debug) echo 'VARIABLE NAMED PARAM (FOR ARRAY) FOUND<br />'; |
|
1536 | + if ($this->debug) { |
|
1537 | + echo 'VARIABLE NAMED PARAM (FOR ARRAY) FOUND<br />'; |
|
1538 | + } |
|
1506 | 1539 | $len = strlen($match[1]); |
1507 | 1540 | $var = $out[count($out)-1]; |
1508 | 1541 | $pointer += $len; |
@@ -1576,7 +1609,9 @@ discard block |
||
1576 | 1609 | $cmdstr = $match[1]; |
1577 | 1610 | } |
1578 | 1611 | |
1579 | - if ($this->debug) echo 'FUNC FOUND ('.$func.')<br />'; |
|
1612 | + if ($this->debug) { |
|
1613 | + echo 'FUNC FOUND ('.$func.')<br />'; |
|
1614 | + } |
|
1580 | 1615 | |
1581 | 1616 | $paramsep = ''; |
1582 | 1617 | |
@@ -1638,17 +1673,25 @@ discard block |
||
1638 | 1673 | } |
1639 | 1674 | |
1640 | 1675 | if ($func !== 'if' && $func !== 'elseif' && $paramstr[$ptr] === ')') { |
1641 | - if ($this->debug) echo 'PARAM PARSING ENDED, ")" FOUND, POINTER AT '.$ptr.'<br/>'; |
|
1676 | + if ($this->debug) { |
|
1677 | + echo 'PARAM PARSING ENDED, ")" FOUND, POINTER AT '.$ptr.'<br/>'; |
|
1678 | + } |
|
1642 | 1679 | break 2; |
1643 | 1680 | } elseif ($paramstr[$ptr] === ';') { |
1644 | 1681 | $ptr++; |
1645 | - if ($this->debug) echo 'PARAM PARSING ENDED, ";" FOUND, POINTER AT '.$ptr.'<br/>'; |
|
1682 | + if ($this->debug) { |
|
1683 | + echo 'PARAM PARSING ENDED, ";" FOUND, POINTER AT '.$ptr.'<br/>'; |
|
1684 | + } |
|
1646 | 1685 | break 2; |
1647 | 1686 | } elseif ($func !== 'if' && $func !== 'elseif' && $paramstr[$ptr] === '/') { |
1648 | - if ($this->debug) echo 'PARAM PARSING ENDED, "/" FOUND, POINTER AT '.$ptr.'<br/>'; |
|
1687 | + if ($this->debug) { |
|
1688 | + echo 'PARAM PARSING ENDED, "/" FOUND, POINTER AT '.$ptr.'<br/>'; |
|
1689 | + } |
|
1649 | 1690 | break 2; |
1650 | 1691 | } elseif (substr($paramstr, $ptr, strlen($this->rd)) === $this->rd) { |
1651 | - if ($this->debug) echo 'PARAM PARSING ENDED, RIGHT DELIMITER FOUND, POINTER AT '.$ptr.'<br/>'; |
|
1692 | + if ($this->debug) { |
|
1693 | + echo 'PARAM PARSING ENDED, RIGHT DELIMITER FOUND, POINTER AT '.$ptr.'<br/>'; |
|
1694 | + } |
|
1652 | 1695 | break 2; |
1653 | 1696 | } |
1654 | 1697 | |
@@ -1659,7 +1702,9 @@ discard block |
||
1659 | 1702 | } |
1660 | 1703 | } |
1661 | 1704 | |
1662 | - if ($this->debug) echo 'FUNC START PARAM PARSING WITH POINTER AT '.$ptr.'<br/>'; |
|
1705 | + if ($this->debug) { |
|
1706 | + echo 'FUNC START PARAM PARSING WITH POINTER AT '.$ptr.'<br/>'; |
|
1707 | + } |
|
1663 | 1708 | |
1664 | 1709 | if ($func === 'if' || $func === 'elseif' || $func === 'tif') { |
1665 | 1710 | $params = $this->parse($paramstr, $ptr, strlen($paramstr), $params, 'condition', $ptr); |
@@ -1669,7 +1714,9 @@ discard block |
||
1669 | 1714 | $params = $this->parse($paramstr, $ptr, strlen($paramstr), $params, 'function', $ptr); |
1670 | 1715 | } |
1671 | 1716 | |
1672 | - if ($this->debug) echo 'PARAM PARSED, POINTER AT '.$ptr.' ('.substr($paramstr, $ptr-1, 3).')<br/>'; |
|
1717 | + if ($this->debug) { |
|
1718 | + echo 'PARAM PARSED, POINTER AT '.$ptr.' ('.substr($paramstr, $ptr-1, 3).')<br/>'; |
|
1719 | + } |
|
1673 | 1720 | } |
1674 | 1721 | } |
1675 | 1722 | $paramstr = substr($paramstr, 0, $ptr); |
@@ -1693,7 +1740,9 @@ discard block |
||
1693 | 1740 | |
1694 | 1741 | if ($pointer !== null) { |
1695 | 1742 | $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/>'; |
|
1743 | + if ($this->debug) { |
|
1744 | + echo 'FUNC ADDS '.((isset($paramstr) ? strlen($paramstr) : 0) + (')' === $paramsep ? 2 : ($paramspos === false ? 0 : 1)) + strlen($func)).' TO POINTER<br/>'; |
|
1745 | + } |
|
1697 | 1746 | } |
1698 | 1747 | |
1699 | 1748 | if ($curBlock === 'method' || $func === 'do' || strstr($func, '::') !== false) { |
@@ -1931,7 +1980,9 @@ discard block |
||
1931 | 1980 | $substr = substr($in, $from, $to-$from); |
1932 | 1981 | $first = $substr[0]; |
1933 | 1982 | |
1934 | - if ($this->debug) echo 'STRING FOUND (in '.htmlentities(substr($in, $from, min($to-$from, 50))).(($to-$from) > 50 ? '...':'').')<br />'; |
|
1983 | + if ($this->debug) { |
|
1984 | + echo 'STRING FOUND (in '.htmlentities(substr($in, $from, min($to-$from, 50))).(($to-$from) > 50 ? '...':'').')<br />'; |
|
1985 | + } |
|
1935 | 1986 | $strend = false; |
1936 | 1987 | $o = $from+1; |
1937 | 1988 | while ($strend === false) { |
@@ -1944,7 +1995,9 @@ discard block |
||
1944 | 1995 | $strend = false; |
1945 | 1996 | } |
1946 | 1997 | } |
1947 | - if ($this->debug) echo 'STRING DELIMITED: '.substr($in, $from, $strend+1-$from).'<br/>'; |
|
1998 | + if ($this->debug) { |
|
1999 | + echo 'STRING DELIMITED: '.substr($in, $from, $strend+1-$from).'<br/>'; |
|
2000 | + } |
|
1948 | 2001 | |
1949 | 2002 | $srcOutput = substr($in, $from, $strend+1-$from); |
1950 | 2003 | |
@@ -2150,11 +2203,15 @@ discard block |
||
2150 | 2203 | } |
2151 | 2204 | unset($uid, $current, $curTxt, $tree, $chars); |
2152 | 2205 | |
2153 | - if ($this->debug) echo 'RECURSIVE VAR REPLACEMENT : '.$key.'<br>'; |
|
2206 | + if ($this->debug) { |
|
2207 | + echo 'RECURSIVE VAR REPLACEMENT : '.$key.'<br>'; |
|
2208 | + } |
|
2154 | 2209 | |
2155 | 2210 | $key = $this->flattenVarTree($parsed); |
2156 | 2211 | |
2157 | - if ($this->debug) echo 'RECURSIVE VAR REPLACEMENT DONE : '.$key.'<br>'; |
|
2212 | + if ($this->debug) { |
|
2213 | + echo 'RECURSIVE VAR REPLACEMENT DONE : '.$key.'<br>'; |
|
2214 | + } |
|
2158 | 2215 | |
2159 | 2216 | $output = preg_replace('#(^""\.|""\.|\.""$|(\()""\.|\.""(\)))#', '$2$3', '$this->readVar("'.$key.'")'); |
2160 | 2217 | } else { |
@@ -2334,8 +2391,9 @@ discard block |
||
2334 | 2391 | $global = 'COOKIE'; |
2335 | 2392 | } |
2336 | 2393 | $key = '$_'.$global; |
2337 | - foreach (explode('.', ltrim($m[2], '.')) as $part) |
|
2338 | - $key .= '['.var_export($part, true).']'; |
|
2394 | + foreach (explode('.', ltrim($m[2], '.')) as $part) { |
|
2395 | + $key .= '['.var_export($part, true).']'; |
|
2396 | + } |
|
2339 | 2397 | if ($curBlock === 'root') { |
2340 | 2398 | $output = $key; |
2341 | 2399 | } else { |
@@ -2445,7 +2503,9 @@ discard block |
||
2445 | 2503 | } else { |
2446 | 2504 | $cnt = substr_count($key, '$'); |
2447 | 2505 | |
2448 | - if ($this->debug) echo 'PARSING SUBVARS IN : '.$key.'<br>'; |
|
2506 | + if ($this->debug) { |
|
2507 | + echo 'PARSING SUBVARS IN : '.$key.'<br>'; |
|
2508 | + } |
|
2449 | 2509 | if ($cnt > 0) { |
2450 | 2510 | while (--$cnt >= 0) { |
2451 | 2511 | if (isset($last)) { |
@@ -2467,7 +2527,9 @@ discard block |
||
2467 | 2527 | $last, |
2468 | 2528 | $len |
2469 | 2529 | ); |
2470 | - if ($this->debug) echo 'RECURSIVE VAR REPLACEMENT DONE : '.$key.'<br>'; |
|
2530 | + if ($this->debug) { |
|
2531 | + echo 'RECURSIVE VAR REPLACEMENT DONE : '.$key.'<br>'; |
|
2532 | + } |
|
2471 | 2533 | } |
2472 | 2534 | unset($last); |
2473 | 2535 | |
@@ -2548,15 +2610,21 @@ discard block |
||
2548 | 2610 | $substr = trim($substr); |
2549 | 2611 | |
2550 | 2612 | if (strtolower($substr) === 'false' || strtolower($substr) === 'no' || strtolower($substr) === 'off') { |
2551 | - if ($this->debug) echo 'BOOLEAN(FALSE) PARSED<br />'; |
|
2613 | + if ($this->debug) { |
|
2614 | + echo 'BOOLEAN(FALSE) PARSED<br />'; |
|
2615 | + } |
|
2552 | 2616 | $substr = 'false'; |
2553 | 2617 | $type = self::T_BOOL; |
2554 | 2618 | } elseif (strtolower($substr) === 'true' || strtolower($substr) === 'yes' || strtolower($substr) === 'on') { |
2555 | - if ($this->debug) echo 'BOOLEAN(TRUE) PARSED<br />'; |
|
2619 | + if ($this->debug) { |
|
2620 | + echo 'BOOLEAN(TRUE) PARSED<br />'; |
|
2621 | + } |
|
2556 | 2622 | $substr = 'true'; |
2557 | 2623 | $type = self::T_BOOL; |
2558 | 2624 | } elseif ($substr === 'null' || $substr === 'NULL') { |
2559 | - if ($this->debug) echo 'NULL PARSED<br />'; |
|
2625 | + if ($this->debug) { |
|
2626 | + echo 'NULL PARSED<br />'; |
|
2627 | + } |
|
2560 | 2628 | $substr = 'null'; |
2561 | 2629 | $type = self::T_NULL; |
2562 | 2630 | } elseif (is_numeric($substr)) { |
@@ -2565,19 +2633,27 @@ discard block |
||
2565 | 2633 | $substr = (int) $substr; |
2566 | 2634 | } |
2567 | 2635 | $type = self::T_NUMERIC; |
2568 | - if ($this->debug) echo 'NUMBER ('.$substr.') PARSED<br />'; |
|
2636 | + if ($this->debug) { |
|
2637 | + echo 'NUMBER ('.$substr.') PARSED<br />'; |
|
2638 | + } |
|
2569 | 2639 | } elseif (preg_match('{^-?(\d+|\d*(\.\d+))\s*([/*%+-]\s*-?(\d+|\d*(\.\d+)))+$}', $substr)) { |
2570 | - if ($this->debug) echo 'SIMPLE MATH PARSED<br />'; |
|
2640 | + if ($this->debug) { |
|
2641 | + echo 'SIMPLE MATH PARSED<br />'; |
|
2642 | + } |
|
2571 | 2643 | $type = self::T_MATH; |
2572 | 2644 | $substr = '('.$substr.')'; |
2573 | 2645 | } elseif ($curBlock === 'condition' && array_search($substr, $breakChars, true) !== false) { |
2574 | - if ($this->debug) echo 'BREAKCHAR ('.$substr.') PARSED<br />'; |
|
2646 | + if ($this->debug) { |
|
2647 | + echo 'BREAKCHAR ('.$substr.') PARSED<br />'; |
|
2648 | + } |
|
2575 | 2649 | $type = self::T_BREAKCHAR; |
2576 | 2650 | //$substr = '"'.$substr.'"'; |
2577 | 2651 | } else { |
2578 | 2652 | $substr = $this->replaceStringVars('\''.str_replace('\'', '\\\'', $substr).'\'', '\'', $curBlock); |
2579 | 2653 | $type = self::T_UNQUOTED_STRING; |
2580 | - if ($this->debug) echo 'BLABBER ('.$substr.') CASTED AS STRING<br />'; |
|
2654 | + if ($this->debug) { |
|
2655 | + echo 'BLABBER ('.$substr.') CASTED AS STRING<br />'; |
|
2656 | + } |
|
2581 | 2657 | } |
2582 | 2658 | |
2583 | 2659 | if (is_array($parsingParams)) { |
@@ -2603,7 +2679,9 @@ discard block |
||
2603 | 2679 | protected function replaceStringVars($string, $first, $curBlock='') |
2604 | 2680 | { |
2605 | 2681 | $pos = 0; |
2606 | - if ($this->debug) echo 'STRING VAR REPLACEMENT : '.$string.'<br>'; |
|
2682 | + if ($this->debug) { |
|
2683 | + echo 'STRING VAR REPLACEMENT : '.$string.'<br>'; |
|
2684 | + } |
|
2607 | 2685 | // replace vars |
2608 | 2686 | while (($pos = strpos($string, '$', $pos)) !== false) { |
2609 | 2687 | $prev = substr($string, $pos-1, 1); |
@@ -2622,7 +2700,9 @@ discard block |
||
2622 | 2700 | $string = substr_replace($string, $first.'.'.$var[1].'.'.$first, $pos, $len); |
2623 | 2701 | } |
2624 | 2702 | $pos += strlen($var[1]) + 2; |
2625 | - if ($this->debug) echo 'STRING VAR REPLACEMENT DONE : '.$string.'<br>'; |
|
2703 | + if ($this->debug) { |
|
2704 | + echo 'STRING VAR REPLACEMENT DONE : '.$string.'<br>'; |
|
2705 | + } |
|
2626 | 2706 | } |
2627 | 2707 | |
2628 | 2708 | // handle modifiers |
@@ -2646,7 +2726,9 @@ discard block |
||
2646 | 2726 | */ |
2647 | 2727 | protected function replaceModifiers(array $m, $curBlock = null, &$pointer = null) |
2648 | 2728 | { |
2649 | - if ($this->debug) echo 'PARSING MODIFIERS : '.$m[3].'<br />'; |
|
2729 | + if ($this->debug) { |
|
2730 | + echo 'PARSING MODIFIERS : '.$m[3].'<br />'; |
|
2731 | + } |
|
2650 | 2732 | |
2651 | 2733 | if ($pointer !== null) { |
2652 | 2734 | $pointer += strlen($m[3]); |
@@ -2668,7 +2750,9 @@ discard block |
||
2668 | 2750 | continue; |
2669 | 2751 | } |
2670 | 2752 | if ($cmdstrsrc[0] === ' ' || $cmdstrsrc[0] === ';' || substr($cmdstrsrc, 0, strlen($this->rd)) === $this->rd) { |
2671 | - if ($this->debug) echo 'MODIFIER PARSING ENDED, RIGHT DELIMITER or ";" FOUND<br/>'; |
|
2753 | + if ($this->debug) { |
|
2754 | + echo 'MODIFIER PARSING ENDED, RIGHT DELIMITER or ";" FOUND<br/>'; |
|
2755 | + } |
|
2672 | 2756 | $continue = false; |
2673 | 2757 | if ($pointer !== null) { |
2674 | 2758 | $pointer -= strlen($cmdstrsrc); |
@@ -2687,7 +2771,9 @@ discard block |
||
2687 | 2771 | if ($paramspos === false) { |
2688 | 2772 | $cmdstrsrc = substr($cmdstrsrc, strlen($func)); |
2689 | 2773 | $params = array(); |
2690 | - if ($this->debug) echo 'MODIFIER ('.$func.') CALLED WITH NO PARAMS<br/>'; |
|
2774 | + if ($this->debug) { |
|
2775 | + echo 'MODIFIER ('.$func.') CALLED WITH NO PARAMS<br/>'; |
|
2776 | + } |
|
2691 | 2777 | } else { |
2692 | 2778 | $paramstr = substr($cmdstr, $paramspos+1); |
2693 | 2779 | if (substr($paramstr, -1, 1) === $paramsep) { |
@@ -2697,18 +2783,28 @@ discard block |
||
2697 | 2783 | $ptr = 0; |
2698 | 2784 | $params = array(); |
2699 | 2785 | while ($ptr < strlen($paramstr)) { |
2700 | - if ($this->debug) echo 'MODIFIER ('.$func.') START PARAM PARSING WITH POINTER AT '.$ptr.'<br/>'; |
|
2701 | - if ($this->debug) echo $paramstr.'--'.$ptr.'--'.strlen($paramstr).'--modifier<br/>'; |
|
2786 | + if ($this->debug) { |
|
2787 | + echo 'MODIFIER ('.$func.') START PARAM PARSING WITH POINTER AT '.$ptr.'<br/>'; |
|
2788 | + } |
|
2789 | + if ($this->debug) { |
|
2790 | + echo $paramstr.'--'.$ptr.'--'.strlen($paramstr).'--modifier<br/>'; |
|
2791 | + } |
|
2702 | 2792 | $params = $this->parse($paramstr, $ptr, strlen($paramstr), $params, 'modifier', $ptr); |
2703 | - if ($this->debug) echo 'PARAM PARSED, POINTER AT '.$ptr.'<br/>'; |
|
2793 | + if ($this->debug) { |
|
2794 | + echo 'PARAM PARSED, POINTER AT '.$ptr.'<br/>'; |
|
2795 | + } |
|
2704 | 2796 | |
2705 | 2797 | if ($ptr >= strlen($paramstr)) { |
2706 | - if ($this->debug) echo 'PARAM PARSING ENDED, PARAM STRING CONSUMED<br/>'; |
|
2798 | + if ($this->debug) { |
|
2799 | + echo 'PARAM PARSING ENDED, PARAM STRING CONSUMED<br/>'; |
|
2800 | + } |
|
2707 | 2801 | break; |
2708 | 2802 | } |
2709 | 2803 | |
2710 | 2804 | if ($paramstr[$ptr] === ' ' || $paramstr[$ptr] === '|' || $paramstr[$ptr] === ';' || substr($paramstr, $ptr, strlen($this->rd)) === $this->rd) { |
2711 | - if ($this->debug) echo 'PARAM PARSING ENDED, " ", "|", RIGHT DELIMITER or ";" FOUND, POINTER AT '.$ptr.'<br/>'; |
|
2805 | + if ($this->debug) { |
|
2806 | + echo 'PARAM PARSING ENDED, " ", "|", RIGHT DELIMITER or ";" FOUND, POINTER AT '.$ptr.'<br/>'; |
|
2807 | + } |
|
2712 | 2808 | if ($paramstr[$ptr] !== '|') { |
2713 | 2809 | $continue = false; |
2714 | 2810 | if ($pointer !== null) { |
@@ -2769,8 +2865,9 @@ discard block |
||
2769 | 2865 | } |
2770 | 2866 | } elseif ($pluginType & Dwoo_Core::PROXY_PLUGIN) { |
2771 | 2867 | $params = $this->mapParams($params, $this->getDwoo()->getPluginProxy()->getCallback($func), $state); |
2772 | - foreach ($params as &$p) |
|
2773 | - $p = $p[0]; |
|
2868 | + foreach ($params as &$p) { |
|
2869 | + $p = $p[0]; |
|
2870 | + } |
|
2774 | 2871 | $output = call_user_func(array($this->dwoo->getPluginProxy(), 'getCode'), $func, $params); |
2775 | 2872 | } elseif ($pluginType & Dwoo_Core::SMARTY_MODIFIER) { |
2776 | 2873 | $params = $this->mapParams($params, null, $state); |
@@ -2812,8 +2909,9 @@ discard block |
||
2812 | 2909 | |
2813 | 2910 | $params = $this->mapParams($params, $callback, $state); |
2814 | 2911 | |
2815 | - foreach ($params as &$p) |
|
2816 | - $p = $p[0]; |
|
2912 | + foreach ($params as &$p) { |
|
2913 | + $p = $p[0]; |
|
2914 | + } |
|
2817 | 2915 | |
2818 | 2916 | if ($pluginType & Dwoo_Core::FUNC_PLUGIN) { |
2819 | 2917 | if ($pluginType & Dwoo_Core::COMPILABLE_PLUGIN) { |
@@ -2904,8 +3002,9 @@ discard block |
||
2904 | 3002 | foreach ($params as $k=>$p) { |
2905 | 3003 | if (is_array($p)) { |
2906 | 3004 | $out2 = 'array('; |
2907 | - foreach ($p as $k2=>$v) |
|
2908 | - $out2 .= var_export($k2, true).' => '.(is_array($v) ? 'array('.self::implode_r($v, true).')' : $v).', '; |
|
3005 | + foreach ($p as $k2=>$v) { |
|
3006 | + $out2 .= var_export($k2, true).' => '.(is_array($v) ? 'array('.self::implode_r($v, true).')' : $v).', '; |
|
3007 | + } |
|
2909 | 3008 | $p = rtrim($out2, ', ').')'; |
2910 | 3009 | } |
2911 | 3010 | if ($recursiveCall) { |
@@ -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 | { |
@@ -1538,8 +1538,9 @@ |
||
1538 | 1538 | array_pop($this->scopeTree); |
1539 | 1539 | $this->scope =& $this->data; |
1540 | 1540 | $cnt = count($this->scopeTree); |
1541 | - for ($i=0;$i<$cnt;$i++) |
|
1542 | - $this->scope =& $this->scope[$this->scopeTree[$i]]; |
|
1541 | + for ($i=0;$i<$cnt;$i++) { |
|
1542 | + $this->scope =& $this->scope[$this->scopeTree[$i]]; |
|
1543 | + } |
|
1543 | 1544 | } elseif ($bit === '__' || $bit === '_root') { |
1544 | 1545 | $this->scope =& $this->data; |
1545 | 1546 | $this->scopeTree = array(); |
@@ -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 | { |
@@ -45,8 +45,9 @@ discard block |
||
45 | 45 | if ($name === null) { |
46 | 46 | $this->data = array(); |
47 | 47 | } elseif (is_array($name)) { |
48 | - foreach ($name as $index) |
|
49 | - unset($this->data[$index]); |
|
48 | + foreach ($name as $index) { |
|
49 | + unset($this->data[$index]); |
|
50 | + } |
|
50 | 51 | } else { |
51 | 52 | unset($this->data[$name]); |
52 | 53 | } |
@@ -90,8 +91,9 @@ discard block |
||
90 | 91 | { |
91 | 92 | if (is_array($name)) { |
92 | 93 | reset($name); |
93 | - while (list($k,$v) = each($name)) |
|
94 | - $this->data[$k] = $v; |
|
94 | + while (list($k,$v) = each($name)) { |
|
95 | + $this->data[$k] = $v; |
|
96 | + } |
|
95 | 97 | } else { |
96 | 98 | $this->data[$name] = $val; |
97 | 99 | } |
@@ -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'; |
@@ -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 | { |