@@ -53,6 +53,10 @@ |
||
53 | 53 | return $output; |
54 | 54 | } |
55 | 55 | |
56 | + /** |
|
57 | + * @param string $dynamicId |
|
58 | + * @param string $compiledFile |
|
59 | + */ |
|
56 | 60 | public static function unescape($output, $dynamicId, $compiledFile) |
57 | 61 | { |
58 | 62 | $output = preg_replace_callback('/<dwoo:dynamic_('.$dynamicId.')>(.+?)<\/dwoo:dynamic_'.$dynamicId.'>/s', array('self', 'unescapePhp'), $output, -1, $count); |
@@ -32,23 +32,23 @@ |
||
32 | 32 | return $content; |
33 | 33 | } catch (Dwoo_Compilation_Exception $e) { |
34 | 34 | } |
35 | - $output = Dwoo_Compiler::PHP_OPEN . |
|
35 | + $output = Dwoo_Compiler::PHP_OPEN. |
|
36 | 36 | 'if($doCache) {'."\n\t". |
37 | 37 | 'echo \'<dwoo:dynamic_\'.$dynamicId.\'>'. |
38 | - str_replace('\'', '\\\'', $content) . |
|
38 | + str_replace('\'', '\\\'', $content). |
|
39 | 39 | '</dwoo:dynamic_\'.$dynamicId.\'>\';'. |
40 | 40 | "\n} else {\n\t"; |
41 | - if(substr($content, 0, strlen(Dwoo_Compiler::PHP_OPEN)) == Dwoo_Compiler::PHP_OPEN) { |
|
41 | + if (substr($content, 0, strlen(Dwoo_Compiler::PHP_OPEN)) == Dwoo_Compiler::PHP_OPEN) { |
|
42 | 42 | $output .= substr($content, strlen(Dwoo_Compiler::PHP_OPEN)); |
43 | 43 | } else { |
44 | - $output .= Dwoo_Compiler::PHP_CLOSE . $content; |
|
44 | + $output .= Dwoo_Compiler::PHP_CLOSE.$content; |
|
45 | 45 | } |
46 | - if(substr($output, -strlen(Dwoo_Compiler::PHP_CLOSE)) == Dwoo_Compiler::PHP_CLOSE) { |
|
46 | + if (substr($output, -strlen(Dwoo_Compiler::PHP_CLOSE)) == Dwoo_Compiler::PHP_CLOSE) { |
|
47 | 47 | $output = substr($output, 0, -strlen(Dwoo_Compiler::PHP_CLOSE)); |
48 | 48 | } else { |
49 | 49 | $output .= Dwoo_Compiler::PHP_OPEN; |
50 | 50 | } |
51 | - $output .= "\n}". Dwoo_Compiler::PHP_CLOSE; |
|
51 | + $output .= "\n}".Dwoo_Compiler::PHP_CLOSE; |
|
52 | 52 | |
53 | 53 | return $output; |
54 | 54 | } |
@@ -43,7 +43,6 @@ |
||
43 | 43 | * Those tags must however contain only htmlentities-escaped text for everything to work properly. |
44 | 44 | * Inline tags are presented on a single line with their content |
45 | 45 | * |
46 | - * @param Dwoo_Core $dwoo the dwoo instance rendering this |
|
47 | 46 | * @param string $input the xhtml to format |
48 | 47 | * @return string formatted xhtml |
49 | 48 | */ |
@@ -66,19 +66,19 @@ discard block |
||
66 | 66 | protected static function tagDispatcher($input) |
67 | 67 | { |
68 | 68 | // textarea, pre, code tags and comments are to be left alone to avoid any non-wanted whitespace inside them so it just outputs them as they were |
69 | - if (substr($input[1],0,9) == "<textarea" || substr($input[1],0,4) == "<pre" || substr($input[1],0,5) == "<code" || substr($input[1],0,4) == "<!--" || substr($input[1],0,9) == "<![CDATA[") { |
|
70 | - return $input[1] . $input[3]; |
|
69 | + if (substr($input[1], 0, 9) == "<textarea" || substr($input[1], 0, 4) == "<pre" || substr($input[1], 0, 5) == "<code" || substr($input[1], 0, 4) == "<!--" || substr($input[1], 0, 9) == "<![CDATA[") { |
|
70 | + return $input[1].$input[3]; |
|
71 | 71 | } |
72 | 72 | // closing textarea, code and pre tags and self-closed tags (i.e. <br />) are printed as singleTags because we didn't use openTag for the formers and the latter is a single tag |
73 | - if (substr($input[1],0,10) == "</textarea" || substr($input[1],0,5) == "</pre" || substr($input[1],0,6) == "</code" || substr($input[1],-2) == "/>") { |
|
74 | - return self::singleTag($input[1],$input[3],$input[2]); |
|
73 | + if (substr($input[1], 0, 10) == "</textarea" || substr($input[1], 0, 5) == "</pre" || substr($input[1], 0, 6) == "</code" || substr($input[1], -2) == "/>") { |
|
74 | + return self::singleTag($input[1], $input[3], $input[2]); |
|
75 | 75 | } |
76 | 76 | // it's the closing tag |
77 | - if ($input[0][1]=="/"){ |
|
78 | - return self::closeTag($input[1],$input[3],$input[2]); |
|
77 | + if ($input[0][1] == "/") { |
|
78 | + return self::closeTag($input[1], $input[3], $input[2]); |
|
79 | 79 | } |
80 | 80 | // opening tag |
81 | - return self::openTag($input[1],$input[3],$input[2]); |
|
81 | + return self::openTag($input[1], $input[3], $input[2]); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
@@ -89,22 +89,22 @@ discard block |
||
89 | 89 | * @param string $whitespace white space between the tag and the additional data |
90 | 90 | * @return string |
91 | 91 | */ |
92 | - protected static function openTag($tag,$add,$whitespace) |
|
92 | + protected static function openTag($tag, $add, $whitespace) |
|
93 | 93 | { |
94 | - $tabs = str_pad('',self::$tabCount++,"\t"); |
|
94 | + $tabs = str_pad('', self::$tabCount++, "\t"); |
|
95 | 95 | |
96 | 96 | if (preg_match('#^<(a|label|option|textarea|h1|h2|h3|h4|h5|h6|strong|b|em|i|abbr|acronym|cite|span|sub|sup|u|s|title)(?: [^>]*|)>#', $tag)) { |
97 | 97 | // if it's one of those tag it's inline so it does not require a leading line break |
98 | - $result = $tag . $whitespace . str_replace("\n","\n".$tabs,$add); |
|
99 | - } elseif (substr($tag,0,9) == '<!DOCTYPE') { |
|
98 | + $result = $tag.$whitespace.str_replace("\n", "\n".$tabs, $add); |
|
99 | + } elseif (substr($tag, 0, 9) == '<!DOCTYPE') { |
|
100 | 100 | // it's the doctype declaration so no line break here either |
101 | - $result = $tabs . $tag; |
|
101 | + $result = $tabs.$tag; |
|
102 | 102 | } else { |
103 | 103 | // normal block tag |
104 | - $result = "\n".$tabs . $tag; |
|
104 | + $result = "\n".$tabs.$tag; |
|
105 | 105 | |
106 | 106 | if (!empty($add)) { |
107 | - $result .= "\n".$tabs."\t".str_replace("\n","\n\t".$tabs,$add); |
|
107 | + $result .= "\n".$tabs."\t".str_replace("\n", "\n\t".$tabs, $add); |
|
108 | 108 | } |
109 | 109 | } |
110 | 110 | |
@@ -121,18 +121,18 @@ discard block |
||
121 | 121 | * @param string $whitespace white space between the tag and the additional data |
122 | 122 | * @return string |
123 | 123 | */ |
124 | - protected static function closeTag($tag,$add,$whitespace) |
|
124 | + protected static function closeTag($tag, $add, $whitespace) |
|
125 | 125 | { |
126 | - $tabs = str_pad('',--self::$tabCount,"\t"); |
|
126 | + $tabs = str_pad('', --self::$tabCount, "\t"); |
|
127 | 127 | |
128 | 128 | // if it's one of those tag it's inline so it does not require a leading line break |
129 | 129 | if (preg_match('#^</(a|label|option|textarea|h1|h2|h3|h4|h5|h6|strong|b|em|i|abbr|acronym|cite|span|sub|sup|u|s|title)>#', $tag)) { |
130 | - $result = $tag . $whitespace . str_replace("\n","\n".$tabs,$add); |
|
130 | + $result = $tag.$whitespace.str_replace("\n", "\n".$tabs, $add); |
|
131 | 131 | } else { |
132 | 132 | $result = "\n".$tabs.$tag; |
133 | 133 | |
134 | 134 | if (!empty($add)) { |
135 | - $result .= "\n".$tabs."\t".str_replace("\n","\n\t".$tabs,$add); |
|
135 | + $result .= "\n".$tabs."\t".str_replace("\n", "\n\t".$tabs, $add); |
|
136 | 136 | } |
137 | 137 | } |
138 | 138 | |
@@ -148,9 +148,9 @@ discard block |
||
148 | 148 | * @param string $add additional data (anything before the following tag) |
149 | 149 | * @return string |
150 | 150 | */ |
151 | - protected static function singleTag($tag,$add,$whitespace) |
|
151 | + protected static function singleTag($tag, $add, $whitespace) |
|
152 | 152 | { |
153 | - $tabs = str_pad('',self::$tabCount,"\t"); |
|
153 | + $tabs = str_pad('', self::$tabCount, "\t"); |
|
154 | 154 | |
155 | 155 | // if it's img, br it's inline so it does not require a leading line break |
156 | 156 | // if it's a closing textarea, code or pre tag, it does not require a leading line break either or it creates whitespace at the end of those blocks |
@@ -158,13 +158,13 @@ discard block |
||
158 | 158 | $result = $tag.$whitespace; |
159 | 159 | |
160 | 160 | if (!empty($add)) { |
161 | - $result .= str_replace("\n","\n".$tabs,$add); |
|
161 | + $result .= str_replace("\n", "\n".$tabs, $add); |
|
162 | 162 | } |
163 | 163 | } else { |
164 | 164 | $result = "\n".$tabs.$tag; |
165 | 165 | |
166 | 166 | if (!empty($add)) { |
167 | - $result .= "\n".$tabs.str_replace("\n","\n".$tabs,$add); |
|
167 | + $result .= "\n".$tabs.str_replace("\n", "\n".$tabs, $add); |
|
168 | 168 | } |
169 | 169 | } |
170 | 170 |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | * @return boolean True cache file existance and it's modification time |
108 | 108 | */ |
109 | 109 | protected function isValidCompiledFile($file) { |
110 | - return parent::isValidCompiledFile($file) && (int)$this->getUid() <= filemtime($file); |
|
110 | + return parent::isValidCompiledFile($file) && (int) $this->getUid() <= filemtime($file); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | /** |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | foreach ($this->includePath as $path) { |
146 | 146 | $path = rtrim($path, DIRECTORY_SEPARATOR); |
147 | 147 | if (file_exists($path.DIRECTORY_SEPARATOR.$this->file) === true) { |
148 | - $this->resolvedPath = $path . DIRECTORY_SEPARATOR . $this->file; |
|
148 | + $this->resolvedPath = $path.DIRECTORY_SEPARATOR.$this->file; |
|
149 | 149 | return $this->resolvedPath; |
150 | 150 | } |
151 | 151 | } |
@@ -250,10 +250,10 @@ discard block |
||
250 | 250 | protected function getCompiledFilename(Dwoo_Core $dwoo) |
251 | 251 | { |
252 | 252 | // no compile id was provided, set default |
253 | - if ($this->compileId===null) { |
|
253 | + if ($this->compileId === null) { |
|
254 | 254 | $this->compileId = str_replace('../', '__', strtr($this->getResourceIdentifier(), '\\:', '/-')); |
255 | 255 | } |
256 | - return $dwoo->getCompileDir() . $this->compileId.'.d'.Dwoo_Core::RELEASE_TAG.'.php'; |
|
256 | + return $dwoo->getCompileDir().$this->compileId.'.d'.Dwoo_Core::RELEASE_TAG.'.php'; |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | /** |
@@ -98,6 +98,6 @@ |
||
98 | 98 | */ |
99 | 99 | public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $content) |
100 | 100 | { |
101 | - return $content . Dwoo_Compiler::PHP_OPEN.$prepend.'$this->delStack();'.$append.Dwoo_Compiler::PHP_CLOSE; |
|
101 | + return $content.Dwoo_Compiler::PHP_OPEN.$prepend.'$this->delStack();'.$append.Dwoo_Compiler::PHP_CLOSE; |
|
102 | 102 | } |
103 | 103 | } |
@@ -183,17 +183,17 @@ |
||
183 | 183 | $phpTags = SMARTY_PHP_ALLOW; |
184 | 184 | } |
185 | 185 | switch($phpTags) { |
186 | - case SMARTY_PHP_ALLOW: |
|
187 | - case SMARTY_PHP_PASSTHRU: |
|
188 | - $phpTags = Dwoo_Security_Policy::PHP_ALLOW; |
|
189 | - break; |
|
190 | - case SMARTY_PHP_QUOTE: |
|
191 | - $phpTags = Dwoo_Security_Policy::PHP_ENCODE; |
|
192 | - break; |
|
193 | - case SMARTY_PHP_REMOVE: |
|
194 | - default: |
|
195 | - $phpTags = Dwoo_Security_Policy::PHP_REMOVE; |
|
196 | - break; |
|
186 | + case SMARTY_PHP_ALLOW: |
|
187 | + case SMARTY_PHP_PASSTHRU: |
|
188 | + $phpTags = Dwoo_Security_Policy::PHP_ALLOW; |
|
189 | + break; |
|
190 | + case SMARTY_PHP_QUOTE: |
|
191 | + $phpTags = Dwoo_Security_Policy::PHP_ENCODE; |
|
192 | + break; |
|
193 | + case SMARTY_PHP_REMOVE: |
|
194 | + default: |
|
195 | + $phpTags = Dwoo_Security_Policy::PHP_REMOVE; |
|
196 | + break; |
|
197 | 197 | } |
198 | 198 | $policy->setPhpHandling($phpTags); |
199 | 199 |
@@ -5,14 +5,14 @@ discard block |
||
5 | 5 | } |
6 | 6 | |
7 | 7 | if (!defined('SMARTY_PHP_PASSTHRU')) { |
8 | - define('SMARTY_PHP_PASSTHRU', 0); |
|
9 | - define('SMARTY_PHP_QUOTE', 1); |
|
10 | - define('SMARTY_PHP_REMOVE', 2); |
|
11 | - define('SMARTY_PHP_ALLOW', 3); |
|
8 | + define('SMARTY_PHP_PASSTHRU', 0); |
|
9 | + define('SMARTY_PHP_QUOTE', 1); |
|
10 | + define('SMARTY_PHP_REMOVE', 2); |
|
11 | + define('SMARTY_PHP_ALLOW', 3); |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | if (class_exists('Dwoo_Compiler', false) === false) { |
15 | - require dirname(dirname(__FILE__)) . '/Compiler.php'; |
|
15 | + require dirname(dirname(__FILE__)).'/Compiler.php'; |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | /** |
@@ -34,11 +34,11 @@ discard block |
||
34 | 34 | // magic get/set/call functions that handle unsupported features |
35 | 35 | public function __set($p, $v) |
36 | 36 | { |
37 | - if ($p==='scope') { |
|
37 | + if ($p === 'scope') { |
|
38 | 38 | $this->scope = $v; |
39 | 39 | return; |
40 | 40 | } |
41 | - if ($p==='data') { |
|
41 | + if ($p === 'data') { |
|
42 | 42 | $this->data = $v; |
43 | 43 | return; |
44 | 44 | } |
@@ -82,15 +82,12 @@ discard block |
||
82 | 82 | } |
83 | 83 | |
84 | 84 | // list of unsupported properties and methods |
85 | - protected $compat = array |
|
86 | - ( |
|
87 | - 'methods' => array |
|
88 | - ( |
|
85 | + protected $compat = array( |
|
86 | + 'methods' => array( |
|
89 | 87 | 'register_resource', 'unregister_resource', 'load_filter', 'clear_compiled_tpl', |
90 | 88 | 'clear_config', 'get_config_vars', 'config_load' |
91 | 89 | ), |
92 | - 'properties' => array |
|
93 | - ( |
|
90 | + 'properties' => array( |
|
94 | 91 | 'cache_handler_func' => null, |
95 | 92 | 'debugging' => false, |
96 | 93 | 'error_reporting' => null, |
@@ -117,11 +114,9 @@ discard block |
||
117 | 114 | public $trusted_dir = array(); |
118 | 115 | public $secure_dir = array(); |
119 | 116 | public $php_handling = SMARTY_PHP_PASSTHRU; |
120 | - public $security_settings = array |
|
121 | - ( |
|
117 | + public $security_settings = array( |
|
122 | 118 | 'PHP_HANDLING' => false, |
123 | - 'IF_FUNCS' => array |
|
124 | - ( |
|
119 | + 'IF_FUNCS' => array( |
|
125 | 120 | 'list', 'empty', 'count', 'sizeof', |
126 | 121 | 'in_array', 'is_array', |
127 | 122 | ), |
@@ -164,12 +159,12 @@ discard block |
||
164 | 159 | $this->compiler = new Dwoo_Compiler(); |
165 | 160 | } |
166 | 161 | |
167 | - public function display($filename, $cacheId=null, $compileId=null) |
|
162 | + public function display($filename, $cacheId = null, $compileId = null) |
|
168 | 163 | { |
169 | 164 | $this->fetch($filename, $cacheId, $compileId, true); |
170 | 165 | } |
171 | 166 | |
172 | - public function fetch($filename, $cacheId=null, $compileId=null, $display=false) |
|
167 | + public function fetch($filename, $cacheId = null, $compileId = null, $display = false) |
|
173 | 168 | { |
174 | 169 | $this->setCacheDir($this->cache_dir); |
175 | 170 | $this->setCompileDir($this->compile_dir); |
@@ -182,7 +177,7 @@ discard block |
||
182 | 177 | if ($this->security_settings['PHP_TAGS']) { |
183 | 178 | $phpTags = SMARTY_PHP_ALLOW; |
184 | 179 | } |
185 | - switch($phpTags) { |
|
180 | + switch ($phpTags) { |
|
186 | 181 | case SMARTY_PHP_ALLOW: |
187 | 182 | case SMARTY_PHP_PASSTHRU: |
188 | 183 | $phpTags = Dwoo_Security_Policy::PHP_ALLOW; |
@@ -237,7 +232,7 @@ discard block |
||
237 | 232 | |
238 | 233 | $this->compiler->setDelimiters($this->left_delimiter, $this->right_delimiter); |
239 | 234 | |
240 | - return $this->get($tpl, $this->dataProvider, $this->compiler, $display===true); |
|
235 | + return $this->get($tpl, $this->dataProvider, $this->compiler, $display === true); |
|
241 | 236 | } |
242 | 237 | |
243 | 238 | public function get($_tpl, $data = array(), $_compiler = null, $_output = false) |
@@ -248,7 +243,7 @@ discard block |
||
248 | 243 | return parent::get($_tpl, $data, $_compiler, $_output); |
249 | 244 | } |
250 | 245 | |
251 | - public function register_function($name, $callback, $cacheable=true, $cache_attrs=null) |
|
246 | + public function register_function($name, $callback, $cacheable = true, $cache_attrs = null) |
|
252 | 247 | { |
253 | 248 | if (isset($this->plugins[$name]) && $this->plugins[$name][0] !== self::SMARTY_FUNCTION) { |
254 | 249 | throw new Dwoo_Exception('Multiple plugins of different types can not share the same name'); |
@@ -261,7 +256,7 @@ discard block |
||
261 | 256 | unset($this->plugins[$name]); |
262 | 257 | } |
263 | 258 | |
264 | - public function register_block($name, $callback, $cacheable=true, $cache_attrs=null) |
|
259 | + public function register_block($name, $callback, $cacheable = true, $cache_attrs = null) |
|
265 | 260 | { |
266 | 261 | if (isset($this->plugins[$name]) && $this->plugins[$name][0] !== self::SMARTY_BLOCK) { |
267 | 262 | throw new Dwoo_Exception('Multiple plugins of different types can not share the same name'); |
@@ -392,7 +387,7 @@ discard block |
||
392 | 387 | return $this->isCached($this->makeTemplate($tpl, $cacheId, $compileId)); |
393 | 388 | } |
394 | 389 | |
395 | - public function append_by_ref($var, &$value, $merge=false) |
|
390 | + public function append_by_ref($var, &$value, $merge = false) |
|
396 | 391 | { |
397 | 392 | $this->dataProvider->appendByRef($var, $value, $merge); |
398 | 393 | } |
@@ -412,7 +407,7 @@ discard block |
||
412 | 407 | $this->dataProvider->clear(); |
413 | 408 | } |
414 | 409 | |
415 | - public function get_template_vars($name=null) |
|
410 | + public function get_template_vars($name = null) |
|
416 | 411 | { |
417 | 412 | if ($this->show_compat_errors) { |
418 | 413 | trigger_error('get_template_vars does not return values by reference, if you try to modify the data that way you should modify your code.', E_USER_NOTICE); |
@@ -467,7 +462,7 @@ discard block |
||
467 | 462 | return self::$tplCache[$hash]; |
468 | 463 | } |
469 | 464 | |
470 | - public function triggerError($message, $level=E_USER_NOTICE) |
|
465 | + public function triggerError($message, $level = E_USER_NOTICE) |
|
471 | 466 | { |
472 | 467 | if (is_object($this->template)) { |
473 | 468 | return parent::triggerError($message, $level); |
@@ -297,9 +297,10 @@ discard block |
||
297 | 297 | |
298 | 298 | public function unregister_prefilter($callback) |
299 | 299 | { |
300 | - foreach ($this->_filters['pre'] as $index => $processor) |
|
301 | - if ($processor->callback === $callback) { |
|
300 | + foreach ($this->_filters['pre'] as $index => $processor) { |
|
301 | + if ($processor->callback === $callback) { |
|
302 | 302 | $this->compiler->removePostProcessor($processor); |
303 | + } |
|
303 | 304 | unset($this->_filters['pre'][$index]); |
304 | 305 | } |
305 | 306 | } |
@@ -314,9 +315,10 @@ discard block |
||
314 | 315 | |
315 | 316 | public function unregister_postfilter($callback) |
316 | 317 | { |
317 | - foreach ($this->_filters['post'] as $index => $processor) |
|
318 | - if ($processor->callback === $callback) { |
|
318 | + foreach ($this->_filters['post'] as $index => $processor) { |
|
319 | + if ($processor->callback === $callback) { |
|
319 | 320 | $this->compiler->removePostProcessor($processor); |
321 | + } |
|
320 | 322 | unset($this->_filters['post'][$index]); |
321 | 323 | } |
322 | 324 | } |
@@ -331,9 +333,10 @@ discard block |
||
331 | 333 | |
332 | 334 | public function unregister_outputfilter($callback) |
333 | 335 | { |
334 | - foreach ($this->_filters['output'] as $index => $filter) |
|
335 | - if ($filter->callback === $callback) { |
|
336 | + foreach ($this->_filters['output'] as $index => $filter) { |
|
337 | + if ($filter->callback === $callback) { |
|
336 | 338 | $this->removeOutputFilter($filter); |
339 | + } |
|
337 | 340 | unset($this->_filters['output'][$index]); |
338 | 341 | } |
339 | 342 | } |
@@ -419,10 +422,11 @@ discard block |
||
419 | 422 | } |
420 | 423 | |
421 | 424 | $data = $this->dataProvider->getData(); |
422 | - if ($name === null) |
|
423 | - return $data; |
|
424 | - elseif (isset($data[$name])) |
|
425 | - return $data[$name]; |
|
425 | + if ($name === null) { |
|
426 | + return $data; |
|
427 | + } elseif (isset($data[$name])) { |
|
428 | + return $data[$name]; |
|
429 | + } |
|
426 | 430 | return null; |
427 | 431 | } |
428 | 432 | |
@@ -450,8 +454,9 @@ discard block |
||
450 | 454 | |
451 | 455 | protected function makeTemplate($file, $cacheId, $compileId) |
452 | 456 | { |
453 | - if ($compileId === null) |
|
454 | - $compileId = $this->compile_id; |
|
457 | + if ($compileId === null) { |
|
458 | + $compileId = $this->compile_id; |
|
459 | + } |
|
455 | 460 | |
456 | 461 | $hash = bin2hex(md5($file.$cacheId.$compileId, true)); |
457 | 462 | if (!isset(self::$tplCache[$hash])) { |
@@ -511,8 +516,7 @@ discard block |
||
511 | 516 | { |
512 | 517 | interface Smarty {} |
513 | 518 | class Dwoo_Smarty_Adapter extends Dwoo_Smarty__Adapter implements Smarty {} |
514 | -} |
|
515 | -else |
|
519 | +} else |
|
516 | 520 | { |
517 | 521 | class Dwoo_Smarty_Adapter extends Dwoo_Smarty__Adapter {} |
518 | 522 | } |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | $out = ''; |
73 | 73 | foreach ($params as $attr=>$val) { |
74 | 74 | $out .= ' '.$attr.'='; |
75 | - if (trim($val, '"\'')=='' || $val=='null') { |
|
75 | + if (trim($val, '"\'') == '' || $val == 'null') { |
|
76 | 76 | $out .= str_replace($delim, '\\'.$delim, '""'); |
77 | 77 | } elseif (substr($val, 0, 1) === $delim && substr($val, -1) === $delim) { |
78 | 78 | $out .= str_replace($delim, '\\'.$delim, '"'.substr($val, 1, -1).'"'); |
@@ -88,8 +88,8 @@ discard block |
||
88 | 88 | $escapedVal = '.'.$val.'.'; |
89 | 89 | } |
90 | 90 | |
91 | - $out .= str_replace($delim, '\\'.$delim, '"') . |
|
92 | - $delim . $escapedVal . $delim . |
|
91 | + $out .= str_replace($delim, '\\'.$delim, '"'). |
|
92 | + $delim.$escapedVal.$delim. |
|
93 | 93 | str_replace($delim, '\\'.$delim, '"'); |
94 | 94 | } |
95 | 95 | } |
@@ -45,8 +45,7 @@ |
||
45 | 45 | * |
46 | 46 | * @var array |
47 | 47 | */ |
48 | - protected $allowedPhpFunctions = array |
|
49 | - ( |
|
48 | + protected $allowedPhpFunctions = array( |
|
50 | 49 | 'str_repeat' => true, |
51 | 50 | 'number_format' => true, |
52 | 51 | 'htmlentities' => true, |
@@ -100,11 +100,12 @@ discard block |
||
100 | 100 | */ |
101 | 101 | public function allowPhpFunction($func) |
102 | 102 | { |
103 | - if (is_array($func)) |
|
104 | - foreach ($func as $fname) |
|
103 | + if (is_array($func)) { |
|
104 | + foreach ($func as $fname) |
|
105 | 105 | $this->allowedPhpFunctions[strtolower($fname)] = true; |
106 | - else |
|
107 | - $this->allowedPhpFunctions[strtolower($func)] = true; |
|
106 | + } else { |
|
107 | + $this->allowedPhpFunctions[strtolower($func)] = true; |
|
108 | + } |
|
108 | 109 | } |
109 | 110 | |
110 | 111 | /** |
@@ -114,11 +115,12 @@ discard block |
||
114 | 115 | */ |
115 | 116 | public function disallowPhpFunction($func) |
116 | 117 | { |
117 | - if (is_array($func)) |
|
118 | - foreach ($func as $fname) |
|
118 | + if (is_array($func)) { |
|
119 | + foreach ($func as $fname) |
|
119 | 120 | unset($this->allowedPhpFunctions[strtolower($fname)]); |
120 | - else |
|
121 | - unset($this->allowedPhpFunctions[strtolower($func)]); |
|
121 | + } else { |
|
122 | + unset($this->allowedPhpFunctions[strtolower($func)]); |
|
123 | + } |
|
122 | 124 | } |
123 | 125 | |
124 | 126 | /** |
@@ -142,11 +144,12 @@ discard block |
||
142 | 144 | */ |
143 | 145 | public function allowMethod($class, $method = null) |
144 | 146 | { |
145 | - if (is_array($class)) |
|
146 | - foreach ($class as $elem) |
|
147 | + if (is_array($class)) { |
|
148 | + foreach ($class as $elem) |
|
147 | 149 | $this->allowedMethods[strtolower($elem[0])][strtolower($elem[1])] = true; |
148 | - else |
|
149 | - $this->allowedMethods[strtolower($class)][strtolower($method)] = true; |
|
150 | + } else { |
|
151 | + $this->allowedMethods[strtolower($class)][strtolower($method)] = true; |
|
152 | + } |
|
150 | 153 | } |
151 | 154 | |
152 | 155 | /** |
@@ -157,11 +160,12 @@ discard block |
||
157 | 160 | */ |
158 | 161 | public function disallowMethod($class, $method = null) |
159 | 162 | { |
160 | - if (is_array($class)) |
|
161 | - foreach ($class as $elem) |
|
163 | + if (is_array($class)) { |
|
164 | + foreach ($class as $elem) |
|
162 | 165 | unset($this->allowedMethods[strtolower($elem[0])][strtolower($elem[1])]); |
163 | - else |
|
164 | - unset($this->allowedMethods[strtolower($class)][strtolower($method)]); |
|
166 | + } else { |
|
167 | + unset($this->allowedMethods[strtolower($class)][strtolower($method)]); |
|
168 | + } |
|
165 | 169 | } |
166 | 170 | |
167 | 171 | /** |
@@ -185,11 +189,12 @@ discard block |
||
185 | 189 | */ |
186 | 190 | public function allowDirectory($path) |
187 | 191 | { |
188 | - if (is_array($path)) |
|
189 | - foreach ($path as $dir) |
|
192 | + if (is_array($path)) { |
|
193 | + foreach ($path as $dir) |
|
190 | 194 | $this->allowedDirectories[realpath($dir)] = true; |
191 | - else |
|
192 | - $this->allowedDirectories[realpath($path)] = true; |
|
195 | + } else { |
|
196 | + $this->allowedDirectories[realpath($path)] = true; |
|
197 | + } |
|
193 | 198 | } |
194 | 199 | |
195 | 200 | /** |
@@ -199,11 +204,12 @@ discard block |
||
199 | 204 | */ |
200 | 205 | public function disallowDirectory($path) |
201 | 206 | { |
202 | - if (is_array($path)) |
|
203 | - foreach ($path as $dir) |
|
207 | + if (is_array($path)) { |
|
208 | + foreach ($path as $dir) |
|
204 | 209 | unset($this->allowedDirectories[realpath($dir)]); |
205 | - else |
|
206 | - unset($this->allowedDirectories[realpath($path)]); |
|
210 | + } else { |
|
211 | + unset($this->allowedDirectories[realpath($path)]); |
|
212 | + } |
|
207 | 213 | } |
208 | 214 | |
209 | 215 | /** |
@@ -1,12 +1,12 @@ |
||
1 | 1 | <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); |
2 | 2 | |
3 | 3 | // The name of the directory where templates are located. |
4 | -$config['template_dir'] = dirname(FCPATH) . '/../application/views/'; |
|
4 | +$config['template_dir'] = dirname(FCPATH).'/../application/views/'; |
|
5 | 5 | |
6 | 6 | // The directory where compiled templates are located |
7 | -$config['compileDir'] = dirname(FCPATH) . '/../compile/'; |
|
7 | +$config['compileDir'] = dirname(FCPATH).'/../compile/'; |
|
8 | 8 | |
9 | 9 | //This tells Dwoo whether or not to cache the output of the templates to the $cache_dir. |
10 | 10 | $config['caching'] = 0; |
11 | -$config['cacheDir'] = dirname(FCPATH) . '/../cache/'; |
|
11 | +$config['cacheDir'] = dirname(FCPATH).'/../cache/'; |
|
12 | 12 | $config['cacheTime'] = 0; |
@@ -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 | // The name of the directory where templates are located. |
4 | 6 | $config['template_dir'] = dirname(FCPATH) . '/../application/views/'; |
@@ -2,15 +2,15 @@ |
||
2 | 2 | |
3 | 3 | class Dwoowelcome extends Controller { |
4 | 4 | |
5 | - function __construct() |
|
6 | - { |
|
7 | - parent::Controller(); |
|
8 | - } |
|
5 | + function __construct() |
|
6 | + { |
|
7 | + parent::Controller(); |
|
8 | + } |
|
9 | 9 | |
10 | - function index() |
|
11 | - { |
|
12 | - $this->load->library('Dwootemplate'); |
|
13 | - $this->dwootemplate->assign('itshowlate', date('H:i:s')); |
|
14 | - $this->dwootemplate->display('dwoowelcome.tpl'); |
|
15 | - } |
|
10 | + function index() |
|
11 | + { |
|
12 | + $this->load->library('Dwootemplate'); |
|
13 | + $this->dwootemplate->assign('itshowlate', date('H:i:s')); |
|
14 | + $this->dwootemplate->display('dwoowelcome.tpl'); |
|
15 | + } |
|
16 | 16 | } |
17 | 17 | \ No newline at end of file |