@@ -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 | } |
@@ -44,14 +44,14 @@ discard block |
||
| 44 | 44 | |
| 45 | 45 | public function __construct($cacheDir) |
| 46 | 46 | { |
| 47 | - $this->corePluginDir = DWOO_DIRECTORY . 'plugins'; |
|
| 48 | - $this->cacheDir = rtrim($cacheDir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; |
|
| 47 | + $this->corePluginDir = DWOO_DIRECTORY.'plugins'; |
|
| 48 | + $this->cacheDir = rtrim($cacheDir, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR; |
|
| 49 | 49 | |
| 50 | 50 | // include class paths or rebuild paths if the cache file isn't there |
| 51 | 51 | $cacheFile = $this->cacheDir.'classpath.cache.d'.Dwoo_Core::RELEASE_TAG.'.php'; |
| 52 | 52 | if (file_exists($cacheFile)) { |
| 53 | 53 | $classpath = file_get_contents($cacheFile); |
| 54 | - $this->classPath = unserialize($classpath) + $this->classPath; |
|
| 54 | + $this->classPath = unserialize($classpath)+$this->classPath; |
|
| 55 | 55 | } else { |
| 56 | 56 | $this->rebuildClassPathCache($this->corePluginDir, $cacheFile); |
| 57 | 57 | } |
@@ -65,25 +65,25 @@ discard block |
||
| 65 | 65 | */ |
| 66 | 66 | protected function rebuildClassPathCache($path, $cacheFile) |
| 67 | 67 | { |
| 68 | - if ($cacheFile!==false) { |
|
| 68 | + if ($cacheFile !== false) { |
|
| 69 | 69 | $tmp = $this->classPath; |
| 70 | 70 | $this->classPath = array(); |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | // iterates over all files/folders |
| 74 | - $list = glob(rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . '*'); |
|
| 74 | + $list = glob(rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'*'); |
|
| 75 | 75 | if (is_array($list)) { |
| 76 | 76 | foreach ($list as $f) { |
| 77 | 77 | if (is_dir($f)) { |
| 78 | 78 | $this->rebuildClassPathCache($f, false); |
| 79 | 79 | } else { |
| 80 | - $this->classPath[str_replace(array('function.','block.','modifier.','outputfilter.','filter.','prefilter.','postfilter.','pre.','post.','output.','shared.','helper.'), '', basename($f, '.php'))] = $f; |
|
| 80 | + $this->classPath[str_replace(array('function.', 'block.', 'modifier.', 'outputfilter.', 'filter.', 'prefilter.', 'postfilter.', 'pre.', 'post.', 'output.', 'shared.', 'helper.'), '', basename($f, '.php'))] = $f; |
|
| 81 | 81 | } |
| 82 | 82 | } |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | // save in file if it's the first call (not recursed) |
| 86 | - if ($cacheFile!==false) { |
|
| 86 | + if ($cacheFile !== false) { |
|
| 87 | 87 | if (!file_put_contents($cacheFile, serialize($this->classPath))) { |
| 88 | 88 | throw new Dwoo_Exception('Could not write into '.$cacheFile.', either because the folder is not there (create it) or because of the chmod configuration (please ensure this directory is writable by php), alternatively you can change the directory used with $dwoo->setCompileDir() or provide a custom loader object with $dwoo->setLoader()'); |
| 89 | 89 | } |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | !(include $this->classPath[$class])) |
| 110 | 110 | { |
| 111 | 111 | if ($forceRehash) { |
| 112 | - $this->rebuildClassPathCache($this->corePluginDir, $this->cacheDir . 'classpath.cache.d'.Dwoo_Core::RELEASE_TAG.'.php'); |
|
| 112 | + $this->rebuildClassPathCache($this->corePluginDir, $this->cacheDir.'classpath.cache.d'.Dwoo_Core::RELEASE_TAG.'.php'); |
|
| 113 | 113 | foreach ($this->paths as $path=>$file) { |
| 114 | 114 | $this->rebuildClassPathCache($path, $file); |
| 115 | 115 | } |
@@ -142,11 +142,11 @@ discard block |
||
| 142 | 142 | if (!$pluginDir) { |
| 143 | 143 | throw new Dwoo_Exception('Plugin directory does not exist or can not be read : '.$pluginDirectory); |
| 144 | 144 | } |
| 145 | - $cacheFile = $this->cacheDir . 'classpath-'.substr(strtr($pluginDir, '/\\:'.PATH_SEPARATOR, '----'), strlen($pluginDir) > 80 ? -80 : 0).'.d'.Dwoo_Core::RELEASE_TAG.'.php'; |
|
| 145 | + $cacheFile = $this->cacheDir.'classpath-'.substr(strtr($pluginDir, '/\\:'.PATH_SEPARATOR, '----'), strlen($pluginDir) > 80 ? -80 : 0).'.d'.Dwoo_Core::RELEASE_TAG.'.php'; |
|
| 146 | 146 | $this->paths[$pluginDir] = $cacheFile; |
| 147 | 147 | if (file_exists($cacheFile)) { |
| 148 | 148 | $classpath = file_get_contents($cacheFile); |
| 149 | - $this->classPath = unserialize($classpath) + $this->classPath; |
|
| 149 | + $this->classPath = unserialize($classpath)+$this->classPath; |
|
| 150 | 150 | } else { |
| 151 | 151 | $this->rebuildClassPathCache($pluginDir, $cacheFile); |
| 152 | 152 | } |
@@ -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,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, |
@@ -97,14 +97,14 @@ |
||
| 97 | 97 | $CI->benchmark->mark('dwoo_parse_start'); |
| 98 | 98 | |
| 99 | 99 | // Check if file exists |
| 100 | - if ( !file_exists($this->template_dir . $sTemplate ) ) { |
|
| 100 | + if (!file_exists($this->template_dir.$sTemplate)) { |
|
| 101 | 101 | $message = sprintf('Template file \'%s\' not found.', $sTemplate); |
| 102 | 102 | show_error($message); |
| 103 | 103 | log_message('error', $message); |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | // Create new template |
| 107 | - $tpl = new Dwoo_Template_File($this->template_dir . $sTemplate); |
|
| 107 | + $tpl = new Dwoo_Template_File($this->template_dir.$sTemplate); |
|
| 108 | 108 | |
| 109 | 109 | // render the template |
| 110 | 110 | $template = $this->get($tpl, $this->dwoo_data); |
@@ -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; |
@@ -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 |