@@ -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 |
@@ -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 | } |
@@ -5,10 +5,10 @@ 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 | /** |
@@ -32,11 +32,11 @@ discard block |
||
32 | 32 | // magic get/set/call functions that handle unsupported features |
33 | 33 | public function __set($p, $v) |
34 | 34 | { |
35 | - if ($p==='scope') { |
|
35 | + if ($p === 'scope') { |
|
36 | 36 | $this->scope = $v; |
37 | 37 | return; |
38 | 38 | } |
39 | - if ($p==='data') { |
|
39 | + if ($p === 'data') { |
|
40 | 40 | $this->data = $v; |
41 | 41 | return; |
42 | 42 | } |
@@ -80,15 +80,12 @@ discard block |
||
80 | 80 | } |
81 | 81 | |
82 | 82 | // list of unsupported properties and methods |
83 | - protected $compat = array |
|
84 | - ( |
|
85 | - 'methods' => array |
|
86 | - ( |
|
83 | + protected $compat = array( |
|
84 | + 'methods' => array( |
|
87 | 85 | 'register_resource', 'unregister_resource', 'load_filter', 'clear_compiled_tpl', |
88 | 86 | 'clear_config', 'get_config_vars', 'config_load' |
89 | 87 | ), |
90 | - 'properties' => array |
|
91 | - ( |
|
88 | + 'properties' => array( |
|
92 | 89 | 'cache_handler_func' => null, |
93 | 90 | 'debugging' => false, |
94 | 91 | 'error_reporting' => null, |
@@ -115,11 +112,9 @@ discard block |
||
115 | 112 | public $trusted_dir = array(); |
116 | 113 | public $secure_dir = array(); |
117 | 114 | public $php_handling = SMARTY_PHP_PASSTHRU; |
118 | - public $security_settings = array |
|
119 | - ( |
|
115 | + public $security_settings = array( |
|
120 | 116 | 'PHP_HANDLING' => false, |
121 | - 'IF_FUNCS' => array |
|
122 | - ( |
|
117 | + 'IF_FUNCS' => array( |
|
123 | 118 | 'list', 'empty', 'count', 'sizeof', |
124 | 119 | 'in_array', 'is_array', |
125 | 120 | ), |
@@ -162,12 +157,12 @@ discard block |
||
162 | 157 | $this->compiler = new Dwoo_Compiler(); |
163 | 158 | } |
164 | 159 | |
165 | - public function display($filename, $cacheId=null, $compileId=null) |
|
160 | + public function display($filename, $cacheId = null, $compileId = null) |
|
166 | 161 | { |
167 | 162 | $this->fetch($filename, $cacheId, $compileId, true); |
168 | 163 | } |
169 | 164 | |
170 | - public function fetch($filename, $cacheId=null, $compileId=null, $display=false) |
|
165 | + public function fetch($filename, $cacheId = null, $compileId = null, $display = false) |
|
171 | 166 | { |
172 | 167 | $this->setCacheDir($this->cache_dir); |
173 | 168 | $this->setCompileDir($this->compile_dir); |
@@ -180,7 +175,7 @@ discard block |
||
180 | 175 | if ($this->security_settings['PHP_TAGS']) { |
181 | 176 | $phpTags = SMARTY_PHP_ALLOW; |
182 | 177 | } |
183 | - switch($phpTags) { |
|
178 | + switch ($phpTags) { |
|
184 | 179 | case SMARTY_PHP_ALLOW: |
185 | 180 | case SMARTY_PHP_PASSTHRU: |
186 | 181 | $phpTags = Dwoo_Security_Policy::PHP_ALLOW; |
@@ -235,7 +230,7 @@ discard block |
||
235 | 230 | |
236 | 231 | $this->compiler->setDelimiters($this->left_delimiter, $this->right_delimiter); |
237 | 232 | |
238 | - return $this->get($tpl, $this->dataProvider, $this->compiler, $display===true); |
|
233 | + return $this->get($tpl, $this->dataProvider, $this->compiler, $display === true); |
|
239 | 234 | } |
240 | 235 | |
241 | 236 | public function get($_tpl, $data = array(), $_compiler = null, $_output = false) |
@@ -246,7 +241,7 @@ discard block |
||
246 | 241 | return parent::get($_tpl, $data, $_compiler, $_output); |
247 | 242 | } |
248 | 243 | |
249 | - public function register_function($name, $callback, $cacheable=true, $cache_attrs=null) |
|
244 | + public function register_function($name, $callback, $cacheable = true, $cache_attrs = null) |
|
250 | 245 | { |
251 | 246 | if (isset($this->plugins[$name]) && $this->plugins[$name][0] !== self::SMARTY_FUNCTION) { |
252 | 247 | throw new Dwoo_Exception('Multiple plugins of different types can not share the same name'); |
@@ -259,7 +254,7 @@ discard block |
||
259 | 254 | unset($this->plugins[$name]); |
260 | 255 | } |
261 | 256 | |
262 | - public function register_block($name, $callback, $cacheable=true, $cache_attrs=null) |
|
257 | + public function register_block($name, $callback, $cacheable = true, $cache_attrs = null) |
|
263 | 258 | { |
264 | 259 | if (isset($this->plugins[$name]) && $this->plugins[$name][0] !== self::SMARTY_BLOCK) { |
265 | 260 | throw new Dwoo_Exception('Multiple plugins of different types can not share the same name'); |
@@ -390,7 +385,7 @@ discard block |
||
390 | 385 | return $this->isCached($this->makeTemplate($tpl, $cacheId, $compileId)); |
391 | 386 | } |
392 | 387 | |
393 | - public function append_by_ref($var, &$value, $merge=false) |
|
388 | + public function append_by_ref($var, &$value, $merge = false) |
|
394 | 389 | { |
395 | 390 | $this->dataProvider->appendByRef($var, $value, $merge); |
396 | 391 | } |
@@ -410,7 +405,7 @@ discard block |
||
410 | 405 | $this->dataProvider->clear(); |
411 | 406 | } |
412 | 407 | |
413 | - public function get_template_vars($name=null) |
|
408 | + public function get_template_vars($name = null) |
|
414 | 409 | { |
415 | 410 | if ($this->show_compat_errors) { |
416 | 411 | 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); |
@@ -465,7 +460,7 @@ discard block |
||
465 | 460 | return self::$tplCache[$hash]; |
466 | 461 | } |
467 | 462 | |
468 | - public function triggerError($message, $level=E_USER_NOTICE) |
|
463 | + public function triggerError($message, $level = E_USER_NOTICE) |
|
469 | 464 | { |
470 | 465 | if (is_object($this->template)) { |
471 | 466 | return parent::triggerError($message, $level); |
@@ -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 |
@@ -31,9 +31,9 @@ |
||
31 | 31 | return $this->getPluginProxy()->view->$name; |
32 | 32 | } |
33 | 33 | $trace = debug_backtrace(); |
34 | - trigger_error('Undefined property via __get(): ' . $name . |
|
35 | - ' in ' . $trace[0]['file'] . |
|
36 | - ' on line ' . $trace[0]['line'], E_USER_NOTICE); |
|
34 | + trigger_error('Undefined property via __get(): '.$name. |
|
35 | + ' in '.$trace[0]['file']. |
|
36 | + ' on line '.$trace[0]['line'], E_USER_NOTICE); |
|
37 | 37 | return null; |
38 | 38 | } |
39 | 39 | } |
40 | 40 | \ No newline at end of file |
@@ -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 |
@@ -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 | } |
@@ -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 | { |
@@ -430,7 +430,6 @@ discard block |
||
430 | 430 | * Processes a view script and outputs it. Output is then |
431 | 431 | * passed through filters. |
432 | 432 | * |
433 | - * @param string $name The script script name to process. |
|
434 | 433 | * @return string The script output. |
435 | 434 | */ |
436 | 435 | public function _run() |
@@ -64,7 +64,7 @@ |
||
64 | 64 | $this->_sv_compile_id = $controller->name; |
65 | 65 | |
66 | 66 | $this->_dwoo->sv_this = $this; |
67 | - $this->_dwoo->setSecurityPolicy(); |
|
67 | + $this->_dwoo->setSecurityPolicy(); |
|
68 | 68 | |
69 | 69 | return; |
70 | 70 | } |
@@ -43,21 +43,19 @@ discard block |
||
43 | 43 | |
44 | 44 | $this->ext = '.tpl'; |
45 | 45 | |
46 | - $this->_sv_template_dir = array |
|
47 | - ( |
|
48 | - VIEWS . $this->viewPath . DS . $this->subDir, |
|
49 | - VIEWS . $this->viewPath, |
|
46 | + $this->_sv_template_dir = array( |
|
47 | + VIEWS.$this->viewPath.DS.$this->subDir, |
|
48 | + VIEWS.$this->viewPath, |
|
50 | 49 | VIEWS |
51 | 50 | ); |
52 | 51 | |
53 | - $this->_sv_layout_dir = array |
|
54 | - ( |
|
55 | - LAYOUTS . $this->subDir, |
|
52 | + $this->_sv_layout_dir = array( |
|
53 | + LAYOUTS.$this->subDir, |
|
56 | 54 | VIEWS |
57 | 55 | ); |
58 | 56 | |
59 | - $this->_sv_compile_dir = TMP . 'dwoo' . DS . 'compile'; |
|
60 | - $this->_sv_cache_dir = TMP . 'dwoo' . DS . 'cache'; |
|
57 | + $this->_sv_compile_dir = TMP.'dwoo'.DS.'compile'; |
|
58 | + $this->_sv_cache_dir = TMP.'dwoo'.DS.'cache'; |
|
61 | 59 | |
62 | 60 | $this->_dwoo = new Dwoo_Core($this->_sv_compile_dir, $this->_sv_cache_dir); |
63 | 61 | |
@@ -74,13 +72,13 @@ discard block |
||
74 | 72 | */ |
75 | 73 | public function setTemplateDir($path = VIEW) { |
76 | 74 | $old = $this->_sv_template_dir; |
77 | - $this->_sv_template_dir = $path; |
|
75 | + $this->_sv_template_dir = $path; |
|
78 | 76 | |
79 | 77 | return $old; |
80 | 78 | } |
81 | 79 | |
82 | 80 | public function getTemplateDir() { |
83 | - return $this->_sv_template_dir ; |
|
81 | + return $this->_sv_template_dir; |
|
84 | 82 | } |
85 | 83 | |
86 | 84 | public function _render($___viewFn, $___data_for_view, $___play_safe = true, $loadHelpers = true) |
@@ -88,7 +86,7 @@ discard block |
||
88 | 86 | // let's determine if this is a layout call or a template call |
89 | 87 | // and change the template dir accordingly |
90 | 88 | $layout = false; |
91 | - if(isset($___data_for_view['content_for_layout'])) { |
|
89 | + if (isset($___data_for_view['content_for_layout'])) { |
|
92 | 90 | $this->_sv_template_dir = $this->_sv_layout_dir; |
93 | 91 | $layout = true; |
94 | 92 | } |
@@ -103,7 +101,7 @@ discard block |
||
103 | 101 | $loadedHelpers = $this->_loadHelpers($loadedHelpers, $this->helpers); |
104 | 102 | |
105 | 103 | foreach (array_keys($loadedHelpers) as $helper) { |
106 | - $camelBackedHelper = strtolower(substr($helper, 0, 1)) . substr($helper, 1); |
|
104 | + $camelBackedHelper = strtolower(substr($helper, 0, 1)).substr($helper, 1); |
|
107 | 105 | |
108 | 106 | ${$camelBackedHelper} = $loadedHelpers[$helper]; |
109 | 107 | |
@@ -114,7 +112,7 @@ discard block |
||
114 | 112 | } |
115 | 113 | } |
116 | 114 | |
117 | - if(isset($this->passedArgs)) { |
|
115 | + if (isset($this->passedArgs)) { |
|
118 | 116 | ${$camelBackedHelper}->passedArgs = $this->passedArgs; |
119 | 117 | } |
120 | 118 | |
@@ -137,7 +135,7 @@ discard block |
||
137 | 135 | return $this->_dwoo->get($tpl, $data); |
138 | 136 | } |
139 | 137 | |
140 | - public function get(){ |
|
138 | + public function get() { |
|
141 | 139 | return $this->_dwoo; |
142 | 140 | } |
143 | 141 | } |
144 | 142 | \ No newline at end of file |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | |
23 | 23 | public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $type) |
24 | 24 | { |
25 | - $with =& $compiler->findBlock('for', true); |
|
25 | + $with = & $compiler->findBlock('for', true); |
|
26 | 26 | |
27 | 27 | $params['initialized'] = true; |
28 | 28 | $compiler->injectBlock($type, $params); |
@@ -36,8 +36,8 @@ discard block |
||
36 | 36 | return ''; |
37 | 37 | } |
38 | 38 | |
39 | - $block =& $compiler->getCurrentBlock(); |
|
40 | - $block['params']['hasElse'] = Dwoo_Compiler::PHP_OPEN."else {\n".Dwoo_Compiler::PHP_CLOSE . $content . Dwoo_Compiler::PHP_OPEN."\n}".Dwoo_Compiler::PHP_CLOSE; |
|
39 | + $block = & $compiler->getCurrentBlock(); |
|
40 | + $block['params']['hasElse'] = Dwoo_Compiler::PHP_OPEN."else {\n".Dwoo_Compiler::PHP_CLOSE.$content.Dwoo_Compiler::PHP_OPEN."\n}".Dwoo_Compiler::PHP_CLOSE; |
|
41 | 41 | return ''; |
42 | 42 | } |
43 | 43 | } |