@@ -25,81 +25,81 @@ |
||
25 | 25 | */ |
26 | 26 | abstract class Plugin |
27 | 27 | { |
28 | - /** |
|
29 | - * The dwoo instance that runs this plugin. |
|
30 | - * |
|
31 | - * @var Core |
|
32 | - */ |
|
33 | - protected $core; |
|
28 | + /** |
|
29 | + * The dwoo instance that runs this plugin. |
|
30 | + * |
|
31 | + * @var Core |
|
32 | + */ |
|
33 | + protected $core; |
|
34 | 34 | |
35 | - /** |
|
36 | - * Constructor, if you override it, call parent::__construct($core); or assign |
|
37 | - * the dwoo instance yourself if you need it. |
|
38 | - * |
|
39 | - * @param Core $core the dwoo instance that runs this plugin |
|
40 | - */ |
|
41 | - public function __construct(Core $core) |
|
42 | - { |
|
43 | - $this->core = $core; |
|
44 | - } |
|
35 | + /** |
|
36 | + * Constructor, if you override it, call parent::__construct($core); or assign |
|
37 | + * the dwoo instance yourself if you need it. |
|
38 | + * |
|
39 | + * @param Core $core the dwoo instance that runs this plugin |
|
40 | + */ |
|
41 | + public function __construct(Core $core) |
|
42 | + { |
|
43 | + $this->core = $core; |
|
44 | + } |
|
45 | 45 | |
46 | - // plugins should always implement : |
|
47 | - // public function process($arg, $arg, ...) |
|
48 | - // or for block plugins : |
|
49 | - // public function init($arg, $arg, ...) |
|
46 | + // plugins should always implement : |
|
47 | + // public function process($arg, $arg, ...) |
|
48 | + // or for block plugins : |
|
49 | + // public function init($arg, $arg, ...) |
|
50 | 50 | |
51 | - // this could be enforced with : |
|
52 | - // abstract public function process(...); |
|
53 | - // if my feature request gets enough interest one day |
|
54 | - // see => http://bugs.php.net/bug.php?id=44043 |
|
51 | + // this could be enforced with : |
|
52 | + // abstract public function process(...); |
|
53 | + // if my feature request gets enough interest one day |
|
54 | + // see => http://bugs.php.net/bug.php?id=44043 |
|
55 | 55 | |
56 | - /** |
|
57 | - * Utility function that converts an array of compiled parameters (or rest array) to a string of xml/html tag |
|
58 | - * attributes. this is to be used in preProcessing or postProcessing functions, example : |
|
59 | - * $p = $compiler->getCompiledParams($params); |
|
60 | - * // get only the rest array as attributes |
|
61 | - * $attributes = Plugin::paramsToAttributes($p['*']); |
|
62 | - * // get all the parameters as attributes (if there is a rest array, it will be included) |
|
63 | - * $attributes = Plugin::paramsToAttributes($p); |
|
64 | - * |
|
65 | - * @param array $params an array of attributeName=>value items that will be compiled to be ready for inclusion in a php string |
|
66 | - * inclusion in a php string |
|
67 | - * @param string $delim the string delimiter you want to use (defaults to ') |
|
68 | - * @param Compiler $compiler the compiler instance (optional for BC, but recommended to pass it for proper escaping behavior) |
|
69 | - * escaping behavior) |
|
70 | - * |
|
71 | - * @return string |
|
72 | - */ |
|
73 | - public static function paramsToAttributes(array $params, $delim = '\'', Compiler $compiler = null) |
|
74 | - { |
|
75 | - if (isset($params['*'])) { |
|
76 | - $params = array_merge($params, $params['*']); |
|
77 | - unset($params['*']); |
|
78 | - } |
|
56 | + /** |
|
57 | + * Utility function that converts an array of compiled parameters (or rest array) to a string of xml/html tag |
|
58 | + * attributes. this is to be used in preProcessing or postProcessing functions, example : |
|
59 | + * $p = $compiler->getCompiledParams($params); |
|
60 | + * // get only the rest array as attributes |
|
61 | + * $attributes = Plugin::paramsToAttributes($p['*']); |
|
62 | + * // get all the parameters as attributes (if there is a rest array, it will be included) |
|
63 | + * $attributes = Plugin::paramsToAttributes($p); |
|
64 | + * |
|
65 | + * @param array $params an array of attributeName=>value items that will be compiled to be ready for inclusion in a php string |
|
66 | + * inclusion in a php string |
|
67 | + * @param string $delim the string delimiter you want to use (defaults to ') |
|
68 | + * @param Compiler $compiler the compiler instance (optional for BC, but recommended to pass it for proper escaping behavior) |
|
69 | + * escaping behavior) |
|
70 | + * |
|
71 | + * @return string |
|
72 | + */ |
|
73 | + public static function paramsToAttributes(array $params, $delim = '\'', Compiler $compiler = null) |
|
74 | + { |
|
75 | + if (isset($params['*'])) { |
|
76 | + $params = array_merge($params, $params['*']); |
|
77 | + unset($params['*']); |
|
78 | + } |
|
79 | 79 | |
80 | - $out = ''; |
|
81 | - foreach ($params as $attr => $val) { |
|
82 | - $out .= ' ' . $attr . '='; |
|
83 | - if (trim($val, '"\'') == '' || $val == 'null') { |
|
84 | - $out .= str_replace($delim, '\\' . $delim, '""'); |
|
85 | - } elseif (substr($val, 0, 1) === $delim && substr($val, - 1) === $delim) { |
|
86 | - $out .= str_replace($delim, '\\' . $delim, '"' . substr($val, 1, - 1) . '"'); |
|
87 | - } else { |
|
88 | - if (!$compiler) { |
|
89 | - // disable double encoding since it can not be determined if it was encoded |
|
90 | - $escapedVal = '.(is_string($tmp2=' . $val . ') ? htmlspecialchars($tmp2, ENT_QUOTES, $this->charset, false) : $tmp2).'; |
|
91 | - } elseif (!$compiler->getAutoEscape() || false === strpos($val, 'isset($this->scope')) { |
|
92 | - // escape if auto escaping is disabled, or there was no variable in the string |
|
93 | - $escapedVal = '.(is_string($tmp2=' . $val . ') ? htmlspecialchars($tmp2, ENT_QUOTES, $this->charset) : $tmp2).'; |
|
94 | - } else { |
|
95 | - // print as is |
|
96 | - $escapedVal = '.' . $val . '.'; |
|
97 | - } |
|
80 | + $out = ''; |
|
81 | + foreach ($params as $attr => $val) { |
|
82 | + $out .= ' ' . $attr . '='; |
|
83 | + if (trim($val, '"\'') == '' || $val == 'null') { |
|
84 | + $out .= str_replace($delim, '\\' . $delim, '""'); |
|
85 | + } elseif (substr($val, 0, 1) === $delim && substr($val, - 1) === $delim) { |
|
86 | + $out .= str_replace($delim, '\\' . $delim, '"' . substr($val, 1, - 1) . '"'); |
|
87 | + } else { |
|
88 | + if (!$compiler) { |
|
89 | + // disable double encoding since it can not be determined if it was encoded |
|
90 | + $escapedVal = '.(is_string($tmp2=' . $val . ') ? htmlspecialchars($tmp2, ENT_QUOTES, $this->charset, false) : $tmp2).'; |
|
91 | + } elseif (!$compiler->getAutoEscape() || false === strpos($val, 'isset($this->scope')) { |
|
92 | + // escape if auto escaping is disabled, or there was no variable in the string |
|
93 | + $escapedVal = '.(is_string($tmp2=' . $val . ') ? htmlspecialchars($tmp2, ENT_QUOTES, $this->charset) : $tmp2).'; |
|
94 | + } else { |
|
95 | + // print as is |
|
96 | + $escapedVal = '.' . $val . '.'; |
|
97 | + } |
|
98 | 98 | |
99 | - $out .= str_replace($delim, '\\' . $delim, '"') . $delim . $escapedVal . $delim . str_replace($delim, '\\' . $delim, '"'); |
|
100 | - } |
|
101 | - } |
|
99 | + $out .= str_replace($delim, '\\' . $delim, '"') . $delim . $escapedVal . $delim . str_replace($delim, '\\' . $delim, '"'); |
|
100 | + } |
|
101 | + } |
|
102 | 102 | |
103 | - return ltrim($out); |
|
104 | - } |
|
103 | + return ltrim($out); |
|
104 | + } |
|
105 | 105 | } |
@@ -79,24 +79,24 @@ |
||
79 | 79 | |
80 | 80 | $out = ''; |
81 | 81 | foreach ($params as $attr => $val) { |
82 | - $out .= ' ' . $attr . '='; |
|
82 | + $out .= ' '.$attr.'='; |
|
83 | 83 | if (trim($val, '"\'') == '' || $val == 'null') { |
84 | - $out .= str_replace($delim, '\\' . $delim, '""'); |
|
84 | + $out .= str_replace($delim, '\\'.$delim, '""'); |
|
85 | 85 | } elseif (substr($val, 0, 1) === $delim && substr($val, - 1) === $delim) { |
86 | - $out .= str_replace($delim, '\\' . $delim, '"' . substr($val, 1, - 1) . '"'); |
|
86 | + $out .= str_replace($delim, '\\'.$delim, '"'.substr($val, 1, - 1).'"'); |
|
87 | 87 | } else { |
88 | 88 | if (!$compiler) { |
89 | 89 | // disable double encoding since it can not be determined if it was encoded |
90 | - $escapedVal = '.(is_string($tmp2=' . $val . ') ? htmlspecialchars($tmp2, ENT_QUOTES, $this->charset, false) : $tmp2).'; |
|
90 | + $escapedVal = '.(is_string($tmp2='.$val.') ? htmlspecialchars($tmp2, ENT_QUOTES, $this->charset, false) : $tmp2).'; |
|
91 | 91 | } elseif (!$compiler->getAutoEscape() || false === strpos($val, 'isset($this->scope')) { |
92 | 92 | // escape if auto escaping is disabled, or there was no variable in the string |
93 | - $escapedVal = '.(is_string($tmp2=' . $val . ') ? htmlspecialchars($tmp2, ENT_QUOTES, $this->charset) : $tmp2).'; |
|
93 | + $escapedVal = '.(is_string($tmp2='.$val.') ? htmlspecialchars($tmp2, ENT_QUOTES, $this->charset) : $tmp2).'; |
|
94 | 94 | } else { |
95 | 95 | // print as is |
96 | - $escapedVal = '.' . $val . '.'; |
|
96 | + $escapedVal = '.'.$val.'.'; |
|
97 | 97 | } |
98 | 98 | |
99 | - $out .= str_replace($delim, '\\' . $delim, '"') . $delim . $escapedVal . $delim . str_replace($delim, '\\' . $delim, '"'); |
|
99 | + $out .= str_replace($delim, '\\'.$delim, '"').$delim.$escapedVal.$delim.str_replace($delim, '\\'.$delim, '"'); |
|
100 | 100 | } |
101 | 101 | } |
102 | 102 |
@@ -23,10 +23,10 @@ |
||
23 | 23 | */ |
24 | 24 | interface IDataProvider |
25 | 25 | { |
26 | - /** |
|
27 | - * Returns the data as an associative array that will be used in the template. |
|
28 | - * |
|
29 | - * @return array |
|
30 | - */ |
|
31 | - public function getData(); |
|
26 | + /** |
|
27 | + * Returns the data as an associative array that will be used in the template. |
|
28 | + * |
|
29 | + * @return array |
|
30 | + */ |
|
31 | + public function getData(); |
|
32 | 32 | } |
@@ -28,92 +28,92 @@ |
||
28 | 28 | */ |
29 | 29 | abstract class Plugin extends DwooPlugin |
30 | 30 | { |
31 | - /** |
|
32 | - * Stores the contents of the block while it runs. |
|
33 | - * |
|
34 | - * @var string |
|
35 | - */ |
|
36 | - protected $buffer = ''; |
|
31 | + /** |
|
32 | + * Stores the contents of the block while it runs. |
|
33 | + * |
|
34 | + * @var string |
|
35 | + */ |
|
36 | + protected $buffer = ''; |
|
37 | 37 | |
38 | - /** |
|
39 | - * Buffers input, override only if necessary. |
|
40 | - * |
|
41 | - * @var string the content that must be buffered |
|
42 | - */ |
|
43 | - public function buffer($input) |
|
44 | - { |
|
45 | - $this->buffer .= $input; |
|
46 | - } |
|
38 | + /** |
|
39 | + * Buffers input, override only if necessary. |
|
40 | + * |
|
41 | + * @var string the content that must be buffered |
|
42 | + */ |
|
43 | + public function buffer($input) |
|
44 | + { |
|
45 | + $this->buffer .= $input; |
|
46 | + } |
|
47 | 47 | |
48 | - // initialization code, receives the parameters from {block param1 param2} |
|
49 | - // public function init($arg, $arg, ...); |
|
48 | + // initialization code, receives the parameters from {block param1 param2} |
|
49 | + // public function init($arg, $arg, ...); |
|
50 | 50 | |
51 | - /** |
|
52 | - * Called when the block ends, this is most of the time followed right away by a call |
|
53 | - * of <em>process()</em> but not always, so this should be used to do any shutdown operations on the |
|
54 | - * block object, if required. |
|
55 | - */ |
|
56 | - public function end() |
|
57 | - { |
|
58 | - } |
|
51 | + /** |
|
52 | + * Called when the block ends, this is most of the time followed right away by a call |
|
53 | + * of <em>process()</em> but not always, so this should be used to do any shutdown operations on the |
|
54 | + * block object, if required. |
|
55 | + */ |
|
56 | + public function end() |
|
57 | + { |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * Called when the block output is required by a parent block. |
|
62 | - * this must read $this->buffer and return it processed |
|
63 | - * |
|
64 | - * @return string |
|
65 | - */ |
|
66 | - public function process() |
|
67 | - { |
|
68 | - return $this->buffer; |
|
69 | - } |
|
60 | + /** |
|
61 | + * Called when the block output is required by a parent block. |
|
62 | + * this must read $this->buffer and return it processed |
|
63 | + * |
|
64 | + * @return string |
|
65 | + */ |
|
66 | + public function process() |
|
67 | + { |
|
68 | + return $this->buffer; |
|
69 | + } |
|
70 | 70 | |
71 | - /** |
|
72 | - * Called at compile time to define what the block should output in the compiled template code, happens when the |
|
73 | - * block is declared basically this will replace the {block arg arg arg} tag in the template. |
|
74 | - * |
|
75 | - * @param DwooCompiler $compiler the compiler instance that calls this function |
|
76 | - * @param array $params an array containing original and compiled parameters |
|
77 | - * @param string $prepend that is just meant to allow a child class to call |
|
78 | - * parent::postProcessing($compiler, $params, "foo();") to add a command before the |
|
79 | - * default commands are executed parent::postProcessing($compiler, $params, "foo();") |
|
80 | - * to add a command before the default commands are executed |
|
81 | - * @param string $append that is just meant to allow a child class to call |
|
82 | - * parent::postProcessing($compiler, $params, null, "foo();") to add a command after |
|
83 | - * the default commands are executed parent::postProcessing($compiler, $params, null, |
|
84 | - * "foo();") to add a command after the default commands are executed |
|
85 | - * @param string $type the type is the plugin class name used |
|
86 | - * |
|
87 | - * @return string |
|
88 | - */ |
|
89 | - public static function preProcessing(DwooCompiler $compiler, array $params, $prepend, $append, $type) |
|
90 | - { |
|
91 | - return DwooCompiler::PHP_OPEN . $prepend . '$this->addStack("' . $type . '", array(' . DwooCompiler::implode_r($compiler->getCompiledParams($params)) . '));' . $append . DwooCompiler::PHP_CLOSE; |
|
92 | - } |
|
71 | + /** |
|
72 | + * Called at compile time to define what the block should output in the compiled template code, happens when the |
|
73 | + * block is declared basically this will replace the {block arg arg arg} tag in the template. |
|
74 | + * |
|
75 | + * @param DwooCompiler $compiler the compiler instance that calls this function |
|
76 | + * @param array $params an array containing original and compiled parameters |
|
77 | + * @param string $prepend that is just meant to allow a child class to call |
|
78 | + * parent::postProcessing($compiler, $params, "foo();") to add a command before the |
|
79 | + * default commands are executed parent::postProcessing($compiler, $params, "foo();") |
|
80 | + * to add a command before the default commands are executed |
|
81 | + * @param string $append that is just meant to allow a child class to call |
|
82 | + * parent::postProcessing($compiler, $params, null, "foo();") to add a command after |
|
83 | + * the default commands are executed parent::postProcessing($compiler, $params, null, |
|
84 | + * "foo();") to add a command after the default commands are executed |
|
85 | + * @param string $type the type is the plugin class name used |
|
86 | + * |
|
87 | + * @return string |
|
88 | + */ |
|
89 | + public static function preProcessing(DwooCompiler $compiler, array $params, $prepend, $append, $type) |
|
90 | + { |
|
91 | + return DwooCompiler::PHP_OPEN . $prepend . '$this->addStack("' . $type . '", array(' . DwooCompiler::implode_r($compiler->getCompiledParams($params)) . '));' . $append . DwooCompiler::PHP_CLOSE; |
|
92 | + } |
|
93 | 93 | |
94 | - /** |
|
95 | - * Called at compile time to define what the block should output in the compiled template code, happens when the |
|
96 | - * block is ended basically this will replace the {/block} tag in the template. |
|
97 | - * |
|
98 | - * @see preProcessing |
|
99 | - * |
|
100 | - * @param DwooCompiler $compiler the compiler instance that calls this function |
|
101 | - * @param array $params an array containing original and compiled parameters, see preProcessing() for more |
|
102 | - * details more details |
|
103 | - * @param string $prepend that is just meant to allow a child class to call |
|
104 | - * parent::postProcessing($compiler, $params, "foo();") to add a command before the |
|
105 | - * default commands are executed parent::postProcessing($compiler, $params, "foo();") |
|
106 | - * to add a command before the default commands are executed |
|
107 | - * @param string $append that is just meant to allow a child class to call |
|
108 | - * parent::postProcessing($compiler, $params, null, "foo();") to add a command after |
|
109 | - * the default commands are executed parent::postProcessing($compiler, $params, null, |
|
110 | - * "foo();") to add a command after the default commands are executed |
|
111 | - * @param string $content the entire content of the block being closed |
|
112 | - * |
|
113 | - * @return string |
|
114 | - */ |
|
115 | - public static function postProcessing(DwooCompiler $compiler, array $params, $prepend, $append, $content) |
|
116 | - { |
|
117 | - return $content . DwooCompiler::PHP_OPEN . $prepend . '$this->delStack();' . $append . DwooCompiler::PHP_CLOSE; |
|
118 | - } |
|
94 | + /** |
|
95 | + * Called at compile time to define what the block should output in the compiled template code, happens when the |
|
96 | + * block is ended basically this will replace the {/block} tag in the template. |
|
97 | + * |
|
98 | + * @see preProcessing |
|
99 | + * |
|
100 | + * @param DwooCompiler $compiler the compiler instance that calls this function |
|
101 | + * @param array $params an array containing original and compiled parameters, see preProcessing() for more |
|
102 | + * details more details |
|
103 | + * @param string $prepend that is just meant to allow a child class to call |
|
104 | + * parent::postProcessing($compiler, $params, "foo();") to add a command before the |
|
105 | + * default commands are executed parent::postProcessing($compiler, $params, "foo();") |
|
106 | + * to add a command before the default commands are executed |
|
107 | + * @param string $append that is just meant to allow a child class to call |
|
108 | + * parent::postProcessing($compiler, $params, null, "foo();") to add a command after |
|
109 | + * the default commands are executed parent::postProcessing($compiler, $params, null, |
|
110 | + * "foo();") to add a command after the default commands are executed |
|
111 | + * @param string $content the entire content of the block being closed |
|
112 | + * |
|
113 | + * @return string |
|
114 | + */ |
|
115 | + public static function postProcessing(DwooCompiler $compiler, array $params, $prepend, $append, $content) |
|
116 | + { |
|
117 | + return $content . DwooCompiler::PHP_OPEN . $prepend . '$this->delStack();' . $append . DwooCompiler::PHP_CLOSE; |
|
118 | + } |
|
119 | 119 | } |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | */ |
89 | 89 | public static function preProcessing(DwooCompiler $compiler, array $params, $prepend, $append, $type) |
90 | 90 | { |
91 | - return DwooCompiler::PHP_OPEN . $prepend . '$this->addStack("' . $type . '", array(' . DwooCompiler::implode_r($compiler->getCompiledParams($params)) . '));' . $append . DwooCompiler::PHP_CLOSE; |
|
91 | + return DwooCompiler::PHP_OPEN.$prepend.'$this->addStack("'.$type.'", array('.DwooCompiler::implode_r($compiler->getCompiledParams($params)).'));'.$append.DwooCompiler::PHP_CLOSE; |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | /** |
@@ -114,6 +114,6 @@ discard block |
||
114 | 114 | */ |
115 | 115 | public static function postProcessing(DwooCompiler $compiler, array $params, $prepend, $append, $content) |
116 | 116 | { |
117 | - return $content . DwooCompiler::PHP_OPEN . $prepend . '$this->delStack();' . $append . DwooCompiler::PHP_CLOSE; |
|
117 | + return $content.DwooCompiler::PHP_OPEN.$prepend.'$this->delStack();'.$append.DwooCompiler::PHP_CLOSE; |
|
118 | 118 | } |
119 | 119 | } |
@@ -25,5 +25,5 @@ |
||
25 | 25 | */ |
26 | 26 | function PluginEolCompile(Compiler $compiler) |
27 | 27 | { |
28 | - return 'PHP_EOL'; |
|
28 | + return 'PHP_EOL'; |
|
29 | 29 | } |
@@ -29,19 +29,19 @@ |
||
29 | 29 | */ |
30 | 30 | function PluginCapitalize(Core $dwoo, $value, $numwords = false) |
31 | 31 | { |
32 | - if ($numwords || preg_match('#^[^0-9]+$#', $value)) { |
|
33 | - return mb_convert_case((string)$value, MB_CASE_TITLE, $dwoo->getCharset()); |
|
34 | - } else { |
|
35 | - $bits = explode(' ', (string)$value); |
|
36 | - $out = ''; |
|
37 | - while (list(, $v) = each($bits)) { |
|
38 | - if (preg_match('#^[^0-9]+$#', $v)) { |
|
39 | - $out .= ' ' . mb_convert_case($v, MB_CASE_TITLE, $dwoo->getCharset()); |
|
40 | - } else { |
|
41 | - $out .= ' ' . $v; |
|
42 | - } |
|
43 | - } |
|
32 | + if ($numwords || preg_match('#^[^0-9]+$#', $value)) { |
|
33 | + return mb_convert_case((string)$value, MB_CASE_TITLE, $dwoo->getCharset()); |
|
34 | + } else { |
|
35 | + $bits = explode(' ', (string)$value); |
|
36 | + $out = ''; |
|
37 | + while (list(, $v) = each($bits)) { |
|
38 | + if (preg_match('#^[^0-9]+$#', $v)) { |
|
39 | + $out .= ' ' . mb_convert_case($v, MB_CASE_TITLE, $dwoo->getCharset()); |
|
40 | + } else { |
|
41 | + $out .= ' ' . $v; |
|
42 | + } |
|
43 | + } |
|
44 | 44 | |
45 | - return substr($out, 1); |
|
46 | - } |
|
45 | + return substr($out, 1); |
|
46 | + } |
|
47 | 47 | } |
@@ -30,15 +30,15 @@ |
||
30 | 30 | function PluginCapitalize(Core $dwoo, $value, $numwords = false) |
31 | 31 | { |
32 | 32 | if ($numwords || preg_match('#^[^0-9]+$#', $value)) { |
33 | - return mb_convert_case((string)$value, MB_CASE_TITLE, $dwoo->getCharset()); |
|
33 | + return mb_convert_case((string) $value, MB_CASE_TITLE, $dwoo->getCharset()); |
|
34 | 34 | } else { |
35 | - $bits = explode(' ', (string)$value); |
|
35 | + $bits = explode(' ', (string) $value); |
|
36 | 36 | $out = ''; |
37 | 37 | while (list(, $v) = each($bits)) { |
38 | 38 | if (preg_match('#^[^0-9]+$#', $v)) { |
39 | - $out .= ' ' . mb_convert_case($v, MB_CASE_TITLE, $dwoo->getCharset()); |
|
39 | + $out .= ' '.mb_convert_case($v, MB_CASE_TITLE, $dwoo->getCharset()); |
|
40 | 40 | } else { |
41 | - $out .= ' ' . $v; |
|
41 | + $out .= ' '.$v; |
|
42 | 42 | } |
43 | 43 | } |
44 | 44 |
@@ -36,58 +36,58 @@ |
||
36 | 36 | */ |
37 | 37 | function PluginInclude(Core $dwoo, $file, $cache_time = null, $cache_id = null, $compile_id = null, $data = '_root', $assign = null, array $rest = array()) |
38 | 38 | { |
39 | - if ($file === '') { |
|
40 | - return ''; |
|
41 | - } |
|
39 | + if ($file === '') { |
|
40 | + return ''; |
|
41 | + } |
|
42 | 42 | |
43 | - if (preg_match('#^([a-z]{2,}):(.*)$#i', $file, $m)) { |
|
44 | - // resource:identifier given, extract them |
|
45 | - $resource = $m[1]; |
|
46 | - $identifier = $m[2]; |
|
47 | - } else { |
|
48 | - // get the current template's resource |
|
49 | - $resource = $dwoo->getTemplate()->getResourceName(); |
|
50 | - $identifier = $file; |
|
51 | - } |
|
43 | + if (preg_match('#^([a-z]{2,}):(.*)$#i', $file, $m)) { |
|
44 | + // resource:identifier given, extract them |
|
45 | + $resource = $m[1]; |
|
46 | + $identifier = $m[2]; |
|
47 | + } else { |
|
48 | + // get the current template's resource |
|
49 | + $resource = $dwoo->getTemplate()->getResourceName(); |
|
50 | + $identifier = $file; |
|
51 | + } |
|
52 | 52 | |
53 | - try { |
|
54 | - $include = $dwoo->templateFactory($resource, $identifier, $cache_time, $cache_id, $compile_id); |
|
55 | - } |
|
56 | - catch (SecurityException $e) { |
|
57 | - $dwoo->triggerError('Include : Security restriction : ' . $e->getMessage(), E_USER_WARNING); |
|
58 | - } |
|
59 | - catch (Exception $e) { |
|
60 | - $dwoo->triggerError('Include : ' . $e->getMessage(), E_USER_WARNING); |
|
61 | - } |
|
53 | + try { |
|
54 | + $include = $dwoo->templateFactory($resource, $identifier, $cache_time, $cache_id, $compile_id); |
|
55 | + } |
|
56 | + catch (SecurityException $e) { |
|
57 | + $dwoo->triggerError('Include : Security restriction : ' . $e->getMessage(), E_USER_WARNING); |
|
58 | + } |
|
59 | + catch (Exception $e) { |
|
60 | + $dwoo->triggerError('Include : ' . $e->getMessage(), E_USER_WARNING); |
|
61 | + } |
|
62 | 62 | |
63 | - if ($include === null) { |
|
64 | - $dwoo->triggerError('Include : Resource "' . $resource . ':' . $identifier . '" not found.', E_USER_WARNING); |
|
65 | - } elseif ($include === false) { |
|
66 | - $dwoo->triggerError('Include : Resource "' . $resource . '" does not support includes.', E_USER_WARNING); |
|
67 | - } |
|
63 | + if ($include === null) { |
|
64 | + $dwoo->triggerError('Include : Resource "' . $resource . ':' . $identifier . '" not found.', E_USER_WARNING); |
|
65 | + } elseif ($include === false) { |
|
66 | + $dwoo->triggerError('Include : Resource "' . $resource . '" does not support includes.', E_USER_WARNING); |
|
67 | + } |
|
68 | 68 | |
69 | - if (is_string($data)) { |
|
70 | - $vars = $dwoo->readVar($data); |
|
71 | - } else { |
|
72 | - $vars = $data; |
|
73 | - } |
|
69 | + if (is_string($data)) { |
|
70 | + $vars = $dwoo->readVar($data); |
|
71 | + } else { |
|
72 | + $vars = $data; |
|
73 | + } |
|
74 | 74 | |
75 | - if (count($rest)) { |
|
76 | - $vars = $rest + $vars; |
|
77 | - } |
|
75 | + if (count($rest)) { |
|
76 | + $vars = $rest + $vars; |
|
77 | + } |
|
78 | 78 | |
79 | - $clone = clone $dwoo; |
|
80 | - $out = $clone->get($include, $vars); |
|
79 | + $clone = clone $dwoo; |
|
80 | + $out = $clone->get($include, $vars); |
|
81 | 81 | |
82 | - if ($assign !== null) { |
|
83 | - $dwoo->assignInScope($out, $assign); |
|
84 | - } |
|
82 | + if ($assign !== null) { |
|
83 | + $dwoo->assignInScope($out, $assign); |
|
84 | + } |
|
85 | 85 | |
86 | - foreach ($clone->getReturnValues() as $name => $value) { |
|
87 | - $dwoo->assignInScope($value, $name); |
|
88 | - } |
|
86 | + foreach ($clone->getReturnValues() as $name => $value) { |
|
87 | + $dwoo->assignInScope($value, $name); |
|
88 | + } |
|
89 | 89 | |
90 | - if ($assign === null) { |
|
91 | - return $out; |
|
92 | - } |
|
90 | + if ($assign === null) { |
|
91 | + return $out; |
|
92 | + } |
|
93 | 93 | } |
@@ -54,16 +54,16 @@ discard block |
||
54 | 54 | $include = $dwoo->templateFactory($resource, $identifier, $cache_time, $cache_id, $compile_id); |
55 | 55 | } |
56 | 56 | catch (SecurityException $e) { |
57 | - $dwoo->triggerError('Include : Security restriction : ' . $e->getMessage(), E_USER_WARNING); |
|
57 | + $dwoo->triggerError('Include : Security restriction : '.$e->getMessage(), E_USER_WARNING); |
|
58 | 58 | } |
59 | 59 | catch (Exception $e) { |
60 | - $dwoo->triggerError('Include : ' . $e->getMessage(), E_USER_WARNING); |
|
60 | + $dwoo->triggerError('Include : '.$e->getMessage(), E_USER_WARNING); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | if ($include === null) { |
64 | - $dwoo->triggerError('Include : Resource "' . $resource . ':' . $identifier . '" not found.', E_USER_WARNING); |
|
64 | + $dwoo->triggerError('Include : Resource "'.$resource.':'.$identifier.'" not found.', E_USER_WARNING); |
|
65 | 65 | } elseif ($include === false) { |
66 | - $dwoo->triggerError('Include : Resource "' . $resource . '" does not support includes.', E_USER_WARNING); |
|
66 | + $dwoo->triggerError('Include : Resource "'.$resource.'" does not support includes.', E_USER_WARNING); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | if (is_string($data)) { |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | } |
74 | 74 | |
75 | 75 | if (count($rest)) { |
76 | - $vars = $rest + $vars; |
|
76 | + $vars = $rest+$vars; |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | $clone = clone $dwoo; |
@@ -52,11 +52,9 @@ |
||
52 | 52 | |
53 | 53 | try { |
54 | 54 | $include = $dwoo->templateFactory($resource, $identifier, $cache_time, $cache_id, $compile_id); |
55 | - } |
|
56 | - catch (SecurityException $e) { |
|
55 | + } catch (SecurityException $e) { |
|
57 | 56 | $dwoo->triggerError('Include : Security restriction : ' . $e->getMessage(), E_USER_WARNING); |
58 | - } |
|
59 | - catch (Exception $e) { |
|
57 | + } catch (Exception $e) { |
|
60 | 58 | $dwoo->triggerError('Include : ' . $e->getMessage(), E_USER_WARNING); |
61 | 59 | } |
62 | 60 |
@@ -28,5 +28,5 @@ |
||
28 | 28 | */ |
29 | 29 | function PluginCountWordsCompile(Compiler $compiler, $value) |
30 | 30 | { |
31 | - return 'preg_match_all(strcasecmp($this->charset, \'utf-8\')===0 ? \'#[\w\pL]+#u\' : \'#\w+#\', ' . $value . ', $tmp)'; |
|
31 | + return 'preg_match_all(strcasecmp($this->charset, \'utf-8\')===0 ? \'#[\w\pL]+#u\' : \'#\w+#\', ' . $value . ', $tmp)'; |
|
32 | 32 | } |
@@ -28,5 +28,5 @@ |
||
28 | 28 | */ |
29 | 29 | function PluginCountWordsCompile(Compiler $compiler, $value) |
30 | 30 | { |
31 | - return 'preg_match_all(strcasecmp($this->charset, \'utf-8\')===0 ? \'#[\w\pL]+#u\' : \'#\w+#\', ' . $value . ', $tmp)'; |
|
31 | + return 'preg_match_all(strcasecmp($this->charset, \'utf-8\')===0 ? \'#[\w\pL]+#u\' : \'#\w+#\', '.$value.', $tmp)'; |
|
32 | 32 | } |
@@ -30,5 +30,5 @@ |
||
30 | 30 | */ |
31 | 31 | function PluginIndentCompile(Compiler $compiler, $value, $by = 4, $char = ' ') |
32 | 32 | { |
33 | - return "preg_replace('#^#m', '" . str_repeat(substr($char, 1, - 1), trim($by, '"\'')) . "', $value)"; |
|
33 | + return "preg_replace('#^#m', '" . str_repeat(substr($char, 1, - 1), trim($by, '"\'')) . "', $value)"; |
|
34 | 34 | } |
@@ -30,5 +30,5 @@ |
||
30 | 30 | */ |
31 | 31 | function PluginIndentCompile(Compiler $compiler, $value, $by = 4, $char = ' ') |
32 | 32 | { |
33 | - return "preg_replace('#^#m', '" . str_repeat(substr($char, 1, - 1), trim($by, '"\'')) . "', $value)"; |
|
33 | + return "preg_replace('#^#m', '".str_repeat(substr($char, 1, - 1), trim($by, '"\''))."', $value)"; |
|
34 | 34 | } |
@@ -29,9 +29,9 @@ |
||
29 | 29 | */ |
30 | 30 | function PluginCountCharactersCompile(Compiler $compiler, $value, $count_spaces = false) |
31 | 31 | { |
32 | - if ($count_spaces === 'false') { |
|
33 | - return 'preg_match_all(\'#[^\s\pZ]#u\', ' . $value . ', $tmp)'; |
|
34 | - } else { |
|
35 | - return 'mb_strlen(' . $value . ', $this->charset)'; |
|
36 | - } |
|
32 | + if ($count_spaces === 'false') { |
|
33 | + return 'preg_match_all(\'#[^\s\pZ]#u\', ' . $value . ', $tmp)'; |
|
34 | + } else { |
|
35 | + return 'mb_strlen(' . $value . ', $this->charset)'; |
|
36 | + } |
|
37 | 37 | } |
@@ -30,8 +30,8 @@ |
||
30 | 30 | function PluginCountCharactersCompile(Compiler $compiler, $value, $count_spaces = false) |
31 | 31 | { |
32 | 32 | if ($count_spaces === 'false') { |
33 | - return 'preg_match_all(\'#[^\s\pZ]#u\', ' . $value . ', $tmp)'; |
|
33 | + return 'preg_match_all(\'#[^\s\pZ]#u\', '.$value.', $tmp)'; |
|
34 | 34 | } else { |
35 | - return 'mb_strlen(' . $value . ', $this->charset)'; |
|
35 | + return 'mb_strlen('.$value.', $this->charset)'; |
|
36 | 36 | } |
37 | 37 | } |