diff --git a/change_log.txt b/change_log.txt index b7d7d6c6..7bdf5f05 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,5 +1,7 @@ -===== 3.1.33-dev-9 ===== +===== 3.1.33-dev-10 ===== 31.08.2018 + - reformating for PSR-2 coding standards https://github.com/smarty-php/smarty/pull/483 + - bugfix on Windows absolute filepathes did fail if the drive letter was followed by a linux DIRECTORY_SEPARATOR like C:/ at Smarty > 3.1.33-dev-5 https://github.com/smarty-php/smarty/issues/451 diff --git a/demo/index.php b/demo/index.php index 9db5ce03..3aed3716 100644 --- a/demo/index.php +++ b/demo/index.php @@ -4,31 +4,32 @@ * * @package Example-application */ - require '../libs/Smarty.class.php'; - $smarty = new Smarty; - //$smarty->force_compile = true; $smarty->debugging = true; $smarty->caching = true; $smarty->cache_lifetime = 120; - $smarty->assign("Name", "Fred Irving Johnathan Bradley Peppergill", true); $smarty->assign("FirstName", array("John", "Mary", "James", "Henry")); $smarty->assign("LastName", array("Doe", "Smith", "Johnson", "Case")); $smarty->assign( - "Class", array(array("A", "B", "C", "D"), array("E", "F", "G", "H"), array("I", "J", "K", "L"), - array("M", "N", "O", "P")) + "Class", + array( + array("A", "B", "C", "D"), + array("E", "F", "G", "H"), + array("I", "J", "K", "L"), + array("M", "N", "O", "P") + ) ); - $smarty->assign( - "contacts", array(array("phone" => "1", "fax" => "2", "cell" => "3"), - array("phone" => "555-4444", "fax" => "555-3333", "cell" => "760-1234")) + "contacts", + array( + array("phone" => "1", "fax" => "2", "cell" => "3"), + array("phone" => "555-4444", "fax" => "555-3333", "cell" => "760-1234") + ) ); - $smarty->assign("option_values", array("NY", "NE", "KS", "IA", "OK", "TX")); $smarty->assign("option_output", array("New York", "Nebraska", "Kansas", "Iowa", "Oklahoma", "Texas")); $smarty->assign("option_selected", "NE"); - $smarty->display('index.tpl'); diff --git a/demo/plugins/cacheresource.apc.php b/demo/plugins/cacheresource.apc.php index dad9abaa..7867cc59 100644 --- a/demo/plugins/cacheresource.apc.php +++ b/demo/plugins/cacheresource.apc.php @@ -39,7 +39,6 @@ class Smarty_CacheResource_Apc extends Smarty_CacheResource_KeyValueStore foreach ($res as $k => $v) { $_res[ $k ] = $v; } - return $_res; } @@ -56,7 +55,6 @@ class Smarty_CacheResource_Apc extends Smarty_CacheResource_KeyValueStore foreach ($keys as $k => $v) { apc_store($k, $v, $expire); } - return true; } @@ -72,7 +70,6 @@ class Smarty_CacheResource_Apc extends Smarty_CacheResource_KeyValueStore foreach ($keys as $k) { apc_delete($k); } - return true; } diff --git a/demo/plugins/cacheresource.memcache.php b/demo/plugins/cacheresource.memcache.php index 4a4313ef..9c8855c3 100644 --- a/demo/plugins/cacheresource.memcache.php +++ b/demo/plugins/cacheresource.memcache.php @@ -19,6 +19,9 @@ class Smarty_CacheResource_Memcache extends Smarty_CacheResource_KeyValueStore */ protected $memcache = null; + /** + * Smarty_CacheResource_Memcache constructor. + */ public function __construct() { if (class_exists('Memcached')) { @@ -50,7 +53,6 @@ class Smarty_CacheResource_Memcache extends Smarty_CacheResource_KeyValueStore foreach ($res as $k => $v) { $_res[ $lookup[ $k ] ] = $v; } - return $_res; } @@ -68,7 +70,6 @@ class Smarty_CacheResource_Memcache extends Smarty_CacheResource_KeyValueStore $k = sha1($k); $this->memcache->set($k, $v, 0, $expire); } - return true; } @@ -85,7 +86,6 @@ class Smarty_CacheResource_Memcache extends Smarty_CacheResource_KeyValueStore $k = sha1($k); $this->memcache->delete($k); } - return true; } diff --git a/demo/plugins/cacheresource.mysql.php b/demo/plugins/cacheresource.mysql.php index 208ea435..c5037eb1 100644 --- a/demo/plugins/cacheresource.mysql.php +++ b/demo/plugins/cacheresource.mysql.php @@ -24,13 +24,24 @@ */ class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom { - // PDO instance + /** + * @var \PDO + */ protected $db; + /** + * @var \PDOStatement + */ protected $fetch; + /** + * @var \PDOStatement + */ protected $fetchTimestamp; + /** + * @var \PDOStatement + */ protected $save; /** @@ -42,8 +53,7 @@ class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom { try { $this->db = new PDO("mysql:dbname=test;host=127.0.0.1", "smarty"); - } - catch (PDOException $e) { + } catch (PDOException $e) { throw new SmartyException('Mysql Resource failed: ' . $e->getMessage()); } $this->fetch = $this->db->prepare('SELECT modified, content FROM output_cache WHERE id = :id'); @@ -83,7 +93,8 @@ class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom /** * Fetch cached content's modification timestamp from data source * - * @note implementing this method is optional. Only implement it if modification times can be accessed faster than loading the complete cached content. + * @note implementing this method is optional. Only implement it if modification times can be accessed faster than + * loading the complete cached content. * * @param string $id unique cache content identifier * @param string $name template name @@ -97,7 +108,6 @@ class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom $this->fetchTimestamp->execute(array('id' => $id)); $mtime = strtotime($this->fetchTimestamp->fetchColumn()); $this->fetchTimestamp->closeCursor(); - return $mtime; } @@ -116,10 +126,12 @@ class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom protected function save($id, $name, $cache_id, $compile_id, $exp_time, $content) { $this->save->execute( - array('id' => $id, 'name' => $name, 'cache_id' => $cache_id, 'compile_id' => $compile_id, - 'content' => $content,) + array('id' => $id, + 'name' => $name, + 'cache_id' => $cache_id, + 'compile_id' => $compile_id, + 'content' => $content,) ); - return !!$this->save->rowCount(); } @@ -139,8 +151,7 @@ class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom if ($name === null && $cache_id === null && $compile_id === null && $exp_time === null) { // returning the number of deleted caches would require a second query to count them $query = $this->db->query('TRUNCATE TABLE output_cache'); - - return - 1; + return -1; } // build the filter $where = array(); @@ -158,12 +169,15 @@ class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom } // equal test cache_id and match sub-groups if ($cache_id !== null) { - $where[] = '(cache_id = ' . $this->db->quote($cache_id) . ' OR cache_id LIKE ' . - $this->db->quote($cache_id . '|%') . ')'; + $where[] = + '(cache_id = ' . + $this->db->quote($cache_id) . + ' OR cache_id LIKE ' . + $this->db->quote($cache_id . '|%') . + ')'; } // run delete query $query = $this->db->query('DELETE FROM output_cache WHERE ' . join(' AND ', $where)); - return $query->rowCount(); } } diff --git a/demo/plugins/cacheresource.pdo.php b/demo/plugins/cacheresource.pdo.php index 58ffb557..a80cd698 100644 --- a/demo/plugins/cacheresource.pdo.php +++ b/demo/plugins/cacheresource.pdo.php @@ -29,7 +29,10 @@ */ class Smarty_CacheResource_Pdo extends Smarty_CacheResource_Custom { - protected $fetchStatements = Array('default' => 'SELECT %2$s + /** + * @var string[] + */ + protected $fetchStatements = array('default' => 'SELECT %2$s FROM %1$s WHERE 1 AND id = :id @@ -53,6 +56,10 @@ class Smarty_CacheResource_Pdo extends Smarty_CacheResource_Custom AND id = :id AND cache_id = :cache_id AND compile_id = :compile_id'); + + /** + * @var string + */ protected $insertStatement = 'INSERT INTO %s SET id = :id, @@ -70,25 +77,48 @@ class Smarty_CacheResource_Pdo extends Smarty_CacheResource_Custom modified = CURRENT_TIMESTAMP, expire = DATE_ADD(CURRENT_TIMESTAMP, INTERVAL :expire SECOND), content = :content'; - protected $deleteStatement = 'DELETE FROM %1$s WHERE %2$s'; - protected $truncateStatement = 'TRUNCATE TABLE %s'; - protected $fetchColumns = 'modified, content'; - protected $fetchTimestampColumns = 'modified'; - protected $pdo, $table, $database; - /* - * Constructor - * - * @param PDO $pdo PDO : active connection - * @param string $table : table (or view) name - * @param string $database : optional - if table is located in another db - */ /** - * Smarty_CacheResource_Pdo constructor. + * @var string + */ + protected $deleteStatement = 'DELETE FROM %1$s WHERE %2$s'; + + /** + * @var string + */ + protected $truncateStatement = 'TRUNCATE TABLE %s'; + + /** + * @var string + */ + protected $fetchColumns = 'modified, content'; + + /** + * @var string + */ + protected $fetchTimestampColumns = 'modified'; + + /** + * @var \PDO + */ + protected $pdo; + + /** + * @var + */ + protected $table; + + /** + * @var null + */ + protected $database; + + /** + * Constructor * - * @param \PDO $pdo - * @param $table - * @param null $database + * @param PDO $pdo PDO : active connection + * @param string $table : table (or view) name + * @param string $database : optional - if table is located in another db * * @throws \SmartyException */ @@ -103,15 +133,15 @@ class Smarty_CacheResource_Pdo extends Smarty_CacheResource_Custom $this->fillStatementsWithTableName(); } - /* - * Fills the table name into the statements. - * - * @return Current Instance - * @access protected + /** + * Fills the table name into the statements. + * + * @return $this Current Instance + * @access protected */ protected function fillStatementsWithTableName() { - foreach ($this->fetchStatements AS &$statement) { + foreach ($this->fetchStatements as &$statement) { $statement = sprintf($statement, $this->getTableName(), '%s'); } $this->insertStatement = sprintf($this->insertStatement, $this->getTableName()); @@ -120,31 +150,34 @@ class Smarty_CacheResource_Pdo extends Smarty_CacheResource_Custom return $this; } - /* - * Gets the fetch statement, depending on what you specify - * - * @param string $columns : the column(s) name(s) you want to retrieve from the database - * @param string $id unique cache content identifier - * @param string|null $cache_id cache id - * @param string|null $compile_id compile id - * @access protected + /** + * Gets the fetch statement, depending on what you specify + * + * @param string $columns : the column(s) name(s) you want to retrieve from the database + * @param string $id unique cache content identifier + * @param string|null $cache_id cache id + * @param string|null $compile_id compile id + * + * @access protected + * @return \PDOStatement */ protected function getFetchStatement($columns, $id, $cache_id = null, $compile_id = null) { + $args = array(); if (!is_null($cache_id) && !is_null($compile_id)) { - $query = $this->fetchStatements[ 'withCacheIdAndCompileId' ] AND - $args = Array('id' => $id, 'cache_id' => $cache_id, 'compile_id' => $compile_id); + $query = $this->fetchStatements[ 'withCacheIdAndCompileId' ] and + $args = array('id' => $id, 'cache_id' => $cache_id, 'compile_id' => $compile_id); } elseif (is_null($cache_id) && !is_null($compile_id)) { - $query = $this->fetchStatements[ 'withCompileId' ] AND - $args = Array('id' => $id, 'compile_id' => $compile_id); + $query = $this->fetchStatements[ 'withCompileId' ] and + $args = array('id' => $id, 'compile_id' => $compile_id); } elseif (!is_null($cache_id) && is_null($compile_id)) { - $query = $this->fetchStatements[ 'withCacheId' ] AND $args = Array('id' => $id, 'cache_id' => $cache_id); + $query = $this->fetchStatements[ 'withCacheId' ] and $args = array('id' => $id, 'cache_id' => $cache_id); } else { - $query = $this->fetchStatements[ 'default' ] AND $args = Array('id' => $id); + $query = $this->fetchStatements[ 'default' ] and $args = array('id' => $id); } $query = sprintf($query, $columns); $stmt = $this->pdo->prepare($query); - foreach ($args AS $key => $value) { + foreach ($args as $key => $value) { $stmt->bindValue($key, $value); } return $stmt; @@ -224,24 +257,26 @@ class Smarty_CacheResource_Pdo extends Smarty_CacheResource_Custom return !!$stmt->rowCount(); } - /* - * Encodes the content before saving to database - * - * @param string $content - * @return string $content - * @access protected + /** + * Encodes the content before saving to database + * + * @param string $content + * + * @return string $content + * @access protected */ protected function inputContent($content) { return $content; } - /* - * Decodes the content before saving to database - * - * @param string $content - * @return string $content - * @access protected + /** + * Decodes the content before saving to database + * + * @param string $content + * + * @return string $content + * @access protected */ protected function outputContent($content) { @@ -254,7 +289,7 @@ class Smarty_CacheResource_Pdo extends Smarty_CacheResource_Custom * @param string|null $name template name * @param string|null $cache_id cache id * @param string|null $compile_id compile id - * @param integer|null|-1 $exp_time seconds till expiration or null + * @param integer|null|-1 $exp_time seconds till expiration or null * * @return integer number of deleted caches * @access protected @@ -263,33 +298,37 @@ class Smarty_CacheResource_Pdo extends Smarty_CacheResource_Custom { // delete the whole cache if ($name === null && $cache_id === null && $compile_id === null && $exp_time === null) { - // returning the number of deleted caches would require a second query to count them + // returning the number of deleted caches would require a second query to count them $this->pdo->query($this->truncateStatement); return -1; } - // build the filter + // build the filter $where = array(); - // equal test name + // equal test name if ($name !== null) { $where[] = 'name = ' . $this->pdo->quote($name); } - // equal test cache_id and match sub-groups + // equal test cache_id and match sub-groups if ($cache_id !== null) { - $where[] = '(cache_id = ' . $this->pdo->quote($cache_id) . ' OR cache_id LIKE ' . - $this->pdo->quote($cache_id . '|%') . ')'; + $where[] = + '(cache_id = ' . + $this->pdo->quote($cache_id) . + ' OR cache_id LIKE ' . + $this->pdo->quote($cache_id . '|%') . + ')'; } - // equal test compile_id + // equal test compile_id if ($compile_id !== null) { $where[] = 'compile_id = ' . $this->pdo->quote($compile_id); } - // for clearing expired caches + // for clearing expired caches if ($exp_time === Smarty::CLEAR_EXPIRED) { $where[] = 'expire < CURRENT_TIMESTAMP'; } // range test expiration time elseif ($exp_time !== null) { $where[] = 'modified < DATE_SUB(NOW(), INTERVAL ' . intval($exp_time) . ' SECOND)'; } - // run delete query + // run delete query $query = $this->pdo->query(sprintf($this->deleteStatement, join(' AND ', $where))); return $query->rowCount(); } @@ -305,4 +344,3 @@ class Smarty_CacheResource_Pdo extends Smarty_CacheResource_Custom return (is_null($this->database)) ? "`{$this->table}`" : "`{$this->database}`.`{$this->table}`"; } } - diff --git a/demo/plugins/cacheresource.pdo_gzip.php b/demo/plugins/cacheresource.pdo_gzip.php index 72427c4c..5560b9e3 100644 --- a/demo/plugins/cacheresource.pdo_gzip.php +++ b/demo/plugins/cacheresource.pdo_gzip.php @@ -1,4 +1,5 @@ uid ] = $s; $uid .= $s->filepath; $timestamp = $s->timestamp > $timestamp ? $s->timestamp : $timestamp; - } - catch (SmartyException $e) { + } catch (SmartyException $e) { } } if (!$sources) { $source->exists = false; return; } - $sources = array_reverse($sources, true); reset($sources); $s = current($sources); @@ -51,15 +49,14 @@ class Smarty_Resource_Extendsall extends Smarty_Internal_Resource_Extends $source->timestamp = $timestamp; } - /* + /** * Disable timestamp checks for extendsall resource. * The individual source components will be checked. * - * @return bool + * @return bool false */ public function checkTimestamps() { return false; } - } diff --git a/demo/plugins/resource.mysql.php b/demo/plugins/resource.mysql.php index 0c250b46..95a3c2ba 100644 --- a/demo/plugins/resource.mysql.php +++ b/demo/plugins/resource.mysql.php @@ -12,20 +12,34 @@ * PRIMARY KEY (`name`) * ) ENGINE=InnoDB DEFAULT CHARSET=utf8; * Demo data: - *
INSERT INTO `templates` (`name`, `modified`, `source`) VALUES ('test.tpl', "2010-12-25 22:00:00", '{$x="hello world"}{$x}');+ *
INSERT INTO `templates` (`name`, `modified`, `source`) VALUES ('test.tpl', "2010-12-25 22:00:00", '{$x="hello + * world"}{$x}');+ * * * @package Resource-examples * @author Rodney Rehm */ class Smarty_Resource_Mysql extends Smarty_Resource_Custom { - // PDO instance + /** + * PDO instance + * + * @var \PDO + */ protected $db; - // prepared fetch() statement + /** + * prepared fetch() statement + * + * @var \PDOStatement + */ protected $fetch; - // prepared fetchTimestamp() statement + /** + * prepared fetchTimestamp() statement + * + * @var \PDOStatement + */ protected $mtime; /** @@ -37,8 +51,7 @@ class Smarty_Resource_Mysql extends Smarty_Resource_Custom { try { $this->db = new PDO("mysql:dbname=test;host=127.0.0.1", "smarty"); - } - catch (PDOException $e) { + } catch (PDOException $e) { throw new SmartyException('Mysql Resource failed: ' . $e->getMessage()); } $this->fetch = $this->db->prepare('SELECT modified, source FROM templates WHERE name = :name'); @@ -71,7 +84,8 @@ class Smarty_Resource_Mysql extends Smarty_Resource_Custom /** * Fetch a template's modification time from database * - * @note implementing this method is optional. Only implement it if modification times can be accessed faster than loading the comple template source. + * @note implementing this method is optional. Only implement it if modification times can be accessed faster than + * loading the comple template source. * * @param string $name template name * @@ -82,7 +96,6 @@ class Smarty_Resource_Mysql extends Smarty_Resource_Custom $this->mtime->execute(array('name' => $name)); $mtime = $this->mtime->fetchColumn(); $this->mtime->closeCursor(); - return strtotime($mtime); } } diff --git a/demo/plugins/resource.mysqls.php b/demo/plugins/resource.mysqls.php index c15b9ecb..148a8dd6 100644 --- a/demo/plugins/resource.mysqls.php +++ b/demo/plugins/resource.mysqls.php @@ -14,17 +14,27 @@ * PRIMARY KEY (`name`) * ) ENGINE=InnoDB DEFAULT CHARSET=utf8; * Demo data: - *
INSERT INTO `templates` (`name`, `modified`, `source`) VALUES ('test.tpl', "2010-12-25 22:00:00", '{$x="hello world"}{$x}');+ *
INSERT INTO `templates` (`name`, `modified`, `source`) VALUES ('test.tpl', "2010-12-25 22:00:00", '{$x="hello + * world"}{$x}');+ * * * @package Resource-examples * @author Rodney Rehm */ class Smarty_Resource_Mysqls extends Smarty_Resource_Custom { - // PDO instance + /** + * PDO instance + * + * @var \PDO + */ protected $db; - // prepared fetch() statement + /** + * prepared fetch() statement + * + * @var \PDOStatement + */ protected $fetch; /** @@ -36,8 +46,7 @@ class Smarty_Resource_Mysqls extends Smarty_Resource_Custom { try { $this->db = new PDO("mysql:dbname=test;host=127.0.0.1", "smarty"); - } - catch (PDOException $e) { + } catch (PDOException $e) { throw new SmartyException('Mysql Resource failed: ' . $e->getMessage()); } $this->fetch = $this->db->prepare('SELECT modified, source FROM templates WHERE name = :name'); diff --git a/libs/Autoloader.php b/libs/Autoloader.php index c3186750..e4dc450f 100644 --- a/libs/Autoloader.php +++ b/libs/Autoloader.php @@ -54,7 +54,7 @@ class Smarty_Autoloader if (!defined('SMARTY_SPL_AUTOLOAD')) { define('SMARTY_SPL_AUTOLOAD', 0); } - if (SMARTY_SPL_AUTOLOAD + if (SMARTY_SPL_AUTOLOAD && set_include_path(get_include_path() . PATH_SEPARATOR . SMARTY_SYSPLUGINS_DIR) !== false ) { $registeredAutoLoadFunctions = spl_autoload_functions(); diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index 137c9ca0..2b38e4ce 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -112,7 +112,7 @@ class Smarty extends Smarty_Internal_TemplateBase /** * smarty version */ - const SMARTY_VERSION = '3.1.33-dev-9'; + const SMARTY_VERSION = '3.1.33-dev-10'; /** * define variable scopes */ @@ -650,18 +650,22 @@ class Smarty extends Smarty_Internal_TemplateBase * * @var string[] */ - protected $obsoleteProperties = array('resource_caching', 'template_resource_caching', 'direct_access_security', - '_dir_perms', '_file_perms', 'plugin_search_order', - 'inheritance_merge_compiled_includes', 'resource_cache_mode',); + protected $obsoleteProperties = array( + 'resource_caching', 'template_resource_caching', 'direct_access_security', + '_dir_perms', '_file_perms', 'plugin_search_order', + 'inheritance_merge_compiled_includes', 'resource_cache_mode', + ); /** * List of private properties which will call getter/setter on a direct access * * @var string[] */ - protected $accessMap = array('template_dir' => 'TemplateDir', 'config_dir' => 'ConfigDir', - 'plugins_dir' => 'PluginsDir', 'compile_dir' => 'CompileDir', - 'cache_dir' => 'CacheDir',); + protected $accessMap = array( + 'template_dir' => 'TemplateDir', 'config_dir' => 'ConfigDir', + 'plugins_dir' => 'PluginsDir', 'compile_dir' => 'CompileDir', + 'cache_dir' => 'CacheDir', + ); /** * Initialize new Smarty object @@ -1074,13 +1078,13 @@ class Smarty extends Smarty_Internal_TemplateBase * @return string * @throws \SmartyException */ - public function _getTemplateId($template_name, - $cache_id = null, - $compile_id = null, - $caching = null, - Smarty_Internal_Template $template = null - ) - { + public function _getTemplateId( + $template_name, + $cache_id = null, + $compile_id = null, + $caching = null, + Smarty_Internal_Template $template = null + ) { $template_name = (strpos($template_name, ':') === false) ? "{$this->default_resource_type}:{$template_name}" : $template_name; $cache_id = $cache_id === null ? $this->cache_id : $cache_id; @@ -1129,8 +1133,8 @@ class Smarty extends Smarty_Internal_TemplateBase } } // normalize DIRECTORY_SEPARATOR - $path = str_replace($nds[DIRECTORY_SEPARATOR], DIRECTORY_SEPARATOR, $path); - $parts[ 'root' ] = str_replace($nds[DIRECTORY_SEPARATOR], DIRECTORY_SEPARATOR, $parts[ 'root' ]); + $path = str_replace($nds[ DIRECTORY_SEPARATOR ], DIRECTORY_SEPARATOR, $path); + $parts[ 'root' ] = str_replace($nds[ DIRECTORY_SEPARATOR ], DIRECTORY_SEPARATOR, $parts[ 'root' ]); do { $path = preg_replace( array('#[\\\\/]{2}#', '#[\\\\/][.][\\\\/]#', '#[\\\\/]([^\\\\/.]+)[\\\\/][.][.][\\\\/]#'), diff --git a/libs/SmartyBC.class.php b/libs/SmartyBC.class.php index 1141e488..836f9815 100644 --- a/libs/SmartyBC.class.php +++ b/libs/SmartyBC.class.php @@ -129,7 +129,11 @@ class SmartyBC extends Smarty * @throws SmartyException * @internal param array $block_functs list of methods that are block format */ - public function register_object($object, $object_impl, $allowed = array(), $smarty_args = true, + public function register_object( + $object, + $object_impl, + $allowed = array(), + $smarty_args = true, $block_methods = array() ) { settype($allowed, 'array'); @@ -150,8 +154,8 @@ class SmartyBC extends Smarty /** * Registers block function to be used in templates * - * @param string $block name of template block - * @param string $block_impl PHP function to register + * @param string $block name of template block + * @param string $block_impl PHP function to register * @param bool $cacheable * @param mixed $cache_attrs * @@ -352,7 +356,7 @@ class SmartyBC extends Smarty /** * test to see if valid cache exists for this template * - * @param string $tpl_file name of template file + * @param string $tpl_file name of template file * @param string $cache_id * @param string $compile_id * diff --git a/libs/bootstrap.php b/libs/bootstrap.php index 0b183bf9..2c830468 100644 --- a/libs/bootstrap.php +++ b/libs/bootstrap.php @@ -1,5 +1,5 @@ @@ -7,8 +7,7 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ - -/* +/** * Load and register Smarty Autoloader */ if (!class_exists('Smarty_Autoloader')) { diff --git a/libs/debug.tpl b/libs/debug.tpl index 966376fc..edc7bef9 100644 --- a/libs/debug.tpl +++ b/libs/debug.tpl @@ -113,10 +113,10 @@
]*>.*?]*>)#is', - $source, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER + $source, + $matches, + PREG_OFFSET_CAPTURE | PREG_SET_ORDER ) ) { foreach ($matches as $match) { @@ -59,37 +57,33 @@ function smarty_outputfilter_trimwhitespace($source) $_length = strlen($match[ 0 ][ 0 ]); $replace = '@!@SMARTY:' . $_store . ':SMARTY@!@'; $source = substr_replace($source, $replace, $match[ 0 ][ 1 ] - $_offset, $_length); - $_offset += $_length - strlen($replace); - $_store ++; + $_store++; } } - $expressions = array(// replace multiple spaces between tags by a single space // can't remove them entirely, becaue that might break poorly implemented CSS display:inline-block elements - '#(:SMARTY@!@|>)\s+(?=@!@SMARTY:|<)#s' => '\1 \2', + '#(:SMARTY@!@|>)\s+(?=@!@SMARTY:|<)#s' => '\1 \2', // remove spaces between attributes (but not in attribute values!) '#(([a-z0-9]\s*=\s*("[^"]*?")|(\'[^\']*?\'))|<[a-z0-9_]+)\s+([a-z/>])#is' => '\1 \5', // note: for some very weird reason trim() seems to remove spaces inside attributes. // maybe a \0 byte or something is interfering? - '#^\s+<#Ss' => '<', '#>\s+$#Ss' => '>',); - + '#^\s+<#Ss' => '<', + '#>\s+$#Ss' => '>', + ); $source = preg_replace(array_keys($expressions), array_values($expressions), $source); // note: for some very weird reason trim() seems to remove spaces inside attributes. // maybe a \0 byte or something is interfering? // $source = trim( $source ); - $_offset = 0; if (preg_match_all('#@!@SMARTY:([0-9]+):SMARTY@!@#is', $source, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) { foreach ($matches as $match) { $_length = strlen($match[ 0 ][ 0 ]); $replace = $store[ $match[ 1 ][ 0 ] ]; $source = substr_replace($source, $replace, $match[ 0 ][ 1 ] + $_offset, $_length); - $_offset += strlen($replace) - $_length; - $_store ++; + $_store++; } } - return $source; } diff --git a/libs/plugins/shared.escape_special_chars.php b/libs/plugins/shared.escape_special_chars.php index 9ce66778..6b18d3ee 100644 --- a/libs/plugins/shared.escape_special_chars.php +++ b/libs/plugins/shared.escape_special_chars.php @@ -5,7 +5,6 @@ * @package Smarty * @subpackage PluginsShared */ - /** * escape_special_chars common function * Function: smarty_function_escape_special_chars @@ -29,6 +28,5 @@ function smarty_function_escape_special_chars($string) $string = str_replace(array('%%%SMARTY_START%%%', '%%%SMARTY_END%%%'), array('&', ';'), $string); } } - return $string; } diff --git a/libs/plugins/shared.literal_compiler_param.php b/libs/plugins/shared.literal_compiler_param.php index abac78b7..65caf03c 100644 --- a/libs/plugins/shared.literal_compiler_param.php +++ b/libs/plugins/shared.literal_compiler_param.php @@ -5,7 +5,6 @@ * @package Smarty * @subpackage PluginsShared */ - /** * evaluate compiler parameter * @@ -30,9 +29,7 @@ function smarty_literal_compiler_param($params, $index, $default = null) '] is not a literal and is thus not evaluatable at compile time' ); } - $t = null; eval("\$t = " . $params[ $index ] . ";"); - return $t; } diff --git a/libs/plugins/shared.make_timestamp.php b/libs/plugins/shared.make_timestamp.php index 77577c4c..9626dc68 100644 --- a/libs/plugins/shared.make_timestamp.php +++ b/libs/plugins/shared.make_timestamp.php @@ -5,7 +5,6 @@ * @package Smarty * @subpackage PluginsShared */ - /** * Function: smarty_make_timestamp * Purpose: used by other smarty functions to make a timestamp from a string. @@ -21,27 +20,30 @@ function smarty_make_timestamp($string) if (empty($string)) { // use "now": return time(); - } elseif ($string instanceof DateTime - || (interface_exists('DateTimeInterface', false) && $string instanceof DateTimeInterface) + } elseif ($string instanceof DateTime + || (interface_exists('DateTimeInterface', false) && $string instanceof DateTimeInterface) ) { - return (int) $string->format('U'); // PHP 5.2 BC + return (int)$string->format('U'); // PHP 5.2 BC } elseif (strlen($string) === 14 && ctype_digit($string)) { // it is mysql timestamp format of YYYYMMDDHHMMSS? return mktime( - substr($string, 8, 2), substr($string, 10, 2), substr($string, 12, 2), substr($string, 4, 2), - substr($string, 6, 2), substr($string, 0, 4) + substr($string, 8, 2), + substr($string, 10, 2), + substr($string, 12, 2), + substr($string, 4, 2), + substr($string, 6, 2), + substr($string, 0, 4) ); } elseif (is_numeric($string)) { // it is a numeric string, we handle it as timestamp - return (int) $string; + return (int)$string; } else { // strtotime should handle it $time = strtotime($string); - if ($time === - 1 || $time === false) { + if ($time === -1 || $time === false) { // strtotime() was not able to parse $string, use "now": return time(); } - return $time; } } diff --git a/libs/plugins/shared.mb_unicode.php b/libs/plugins/shared.mb_unicode.php index d8253b0a..7d120650 100644 --- a/libs/plugins/shared.mb_unicode.php +++ b/libs/plugins/shared.mb_unicode.php @@ -5,11 +5,10 @@ * @package Smarty * @subpackage PluginsShared */ - /** * convert characters to their decimal unicode equivalents * - * @link http://www.ibm.com/developerworks/library/os-php-unicode/index.html#listing3 for inspiration + * @link http://www.ibm.com/developerworks/library/os-php-unicode/index.html#listing3 for inspiration * * @param string $string characters to calculate unicode of * @param string $encoding encoding of $string, if null mb_internal_encoding() is used @@ -24,14 +23,13 @@ function smarty_mb_to_unicode($string, $encoding = null) } else { $expanded = mb_convert_encoding($string, 'UTF-32BE'); } - return unpack('N*', $expanded); } /** * convert unicodes to the character of given encoding * - * @link http://www.ibm.com/developerworks/library/os-php-unicode/index.html#listing3 for inspiration + * @link http://www.ibm.com/developerworks/library/os-php-unicode/index.html#listing3 for inspiration * * @param integer|array $unicode single unicode or list of unicodes to convert * @param string $encoding encoding of returned string, if null mb_internal_encoding() is used @@ -45,10 +43,9 @@ function smarty_mb_from_unicode($unicode, $encoding = null) if (!$encoding) { $encoding = mb_internal_encoding(); } - foreach ((array) $unicode as $utf32be) { + foreach ((array)$unicode as $utf32be) { $character = pack('N*', $utf32be); $t .= mb_convert_encoding($character, $encoding, 'UTF-32BE'); } - return $t; } diff --git a/libs/plugins/variablefilter.htmlspecialchars.php b/libs/plugins/variablefilter.htmlspecialchars.php index 97e40075..3c85295d 100644 --- a/libs/plugins/variablefilter.htmlspecialchars.php +++ b/libs/plugins/variablefilter.htmlspecialchars.php @@ -8,7 +8,7 @@ /** * Smarty htmlspecialchars variablefilter plugin * - * @param string $source input string + * @param string $source input string * @param \Smarty_Internal_Template $template * * @return string filtered output diff --git a/libs/sysplugins/smarty_cacheresource.php b/libs/sysplugins/smarty_cacheresource.php index 70fc9343..91e9f392 100644 --- a/libs/sysplugins/smarty_cacheresource.php +++ b/libs/sysplugins/smarty_cacheresource.php @@ -25,7 +25,7 @@ abstract class Smarty_CacheResource /** * populate Cached Object with meta data from Resource * - * @param \Smarty_Template_Cached $cached cached object + * @param \Smarty_Template_Cached $cached cached object * @param Smarty_Internal_Template $_template template object * * @return void @@ -50,7 +50,9 @@ abstract class Smarty_CacheResource * * @return boolean true or false if the cached content does not exist */ - abstract public function process(Smarty_Internal_Template $_template, Smarty_Template_Cached $cached = null, + abstract public function process( + Smarty_Internal_Template $_template, + Smarty_Template_Cached $cached = null, $update = false ); @@ -71,7 +73,7 @@ abstract class Smarty_CacheResource * * @return string content */ - abstract function readCachedContent(Smarty_Internal_Template $_template); + abstract public function readCachedContent(Smarty_Internal_Template $_template); /** * Return cached content @@ -88,7 +90,6 @@ abstract class Smarty_CacheResource $unifunc($_template); return ob_get_clean(); } - return null; } @@ -134,7 +135,6 @@ abstract class Smarty_CacheResource } sleep(1); } - return $hadLock; } @@ -194,12 +194,10 @@ abstract class Smarty_CacheResource if (!isset($type)) { $type = $smarty->caching_type; } - // try smarty's cache if (isset($smarty->_cache[ 'cacheresource_handlers' ][ $type ])) { return $smarty->_cache[ 'cacheresource_handlers' ][ $type ]; } - // try registered resource if (isset($smarty->registered_cache_resources[ $type ])) { // do not cache these instances as they may vary from instance to instance diff --git a/libs/sysplugins/smarty_cacheresource_custom.php b/libs/sysplugins/smarty_cacheresource_custom.php index 15c636bc..68ad1128 100644 --- a/libs/sysplugins/smarty_cacheresource_custom.php +++ b/libs/sysplugins/smarty_cacheresource_custom.php @@ -106,12 +106,15 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource if ($mtime !== null) { $cached->timestamp = $mtime; $cached->exists = !!$cached->timestamp; - return; } $timestamp = null; $this->fetch( - $cached->filepath, $cached->source->name, $cached->cache_id, $cached->compile_id, $cached->content, + $cached->filepath, + $cached->source->name, + $cached->cache_id, + $cached->compile_id, + $cached->content, $timestamp ); $cached->timestamp = isset($timestamp) ? $timestamp : false; @@ -127,7 +130,9 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource * * @return boolean true or false if the cached content does not exist */ - public function process(Smarty_Internal_Template $_smarty_tpl, Smarty_Template_Cached $cached = null, + public function process( + Smarty_Internal_Template $_smarty_tpl, + Smarty_Template_Cached $cached = null, $update = false ) { if (!$cached) { @@ -137,8 +142,12 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource $timestamp = $cached->timestamp ? $cached->timestamp : null; if ($content === null || !$timestamp) { $this->fetch( - $_smarty_tpl->cached->filepath, $_smarty_tpl->source->name, $_smarty_tpl->cache_id, - $_smarty_tpl->compile_id, $content, $timestamp + $_smarty_tpl->cached->filepath, + $_smarty_tpl->source->name, + $_smarty_tpl->cache_id, + $_smarty_tpl->compile_id, + $content, + $timestamp ); } if (isset($content)) { @@ -146,7 +155,6 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource $cached->content = null; return true; } - return false; } @@ -161,8 +169,12 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource public function writeCachedContent(Smarty_Internal_Template $_template, $content) { return $this->save( - $_template->cached->filepath, $_template->source->name, $_template->cache_id, - $_template->compile_id, $_template->cache_lifetime, $content + $_template->cached->filepath, + $_template->source->name, + $_template->cache_id, + $_template->compile_id, + $_template->cache_lifetime, + $content ); } @@ -180,8 +192,12 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource if ($content === null) { $timestamp = null; $this->fetch( - $_template->cached->filepath, $_template->source->name, $_template->cache_id, - $_template->compile_id, $content, $timestamp + $_template->cached->filepath, + $_template->source->name, + $_template->cache_id, + $_template->compile_id, + $content, + $timestamp ); } if (isset($content)) { @@ -218,7 +234,6 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource public function clear(Smarty $smarty, $resource_name, $cache_id, $compile_id, $exp_time) { $cache_name = null; - if (isset($resource_name)) { $source = Smarty_Template_Source::load(null, $smarty, $resource_name); if ($source->exists) { @@ -227,7 +242,6 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource return 0; } } - return $this->delete($cache_name, $cache_id, $compile_id, $exp_time); } @@ -243,7 +257,6 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource { $id = $cached->lock_id; $name = $cached->source->name . '.lock'; - $mtime = $this->fetchTimestamp($id, $name, $cached->cache_id, $cached->compile_id); if ($mtime === null) { $this->fetch($id, $name, $cached->cache_id, $cached->compile_id, $content, $mtime); diff --git a/libs/sysplugins/smarty_cacheresource_keyvaluestore.php b/libs/sysplugins/smarty_cacheresource_keyvaluestore.php index 2be39076..59bf1d4a 100644 --- a/libs/sysplugins/smarty_cacheresource_keyvaluestore.php +++ b/libs/sysplugins/smarty_cacheresource_keyvaluestore.php @@ -56,7 +56,6 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource { $cached->filepath = $_template->source->uid . '#' . $this->sanitize($cached->source->resource) . '#' . $this->sanitize($cached->cache_id) . '#' . $this->sanitize($cached->compile_id); - $this->populateTimestamp($cached); } @@ -70,14 +69,19 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource public function populateTimestamp(Smarty_Template_Cached $cached) { if (!$this->fetch( - $cached->filepath, $cached->source->name, $cached->cache_id, $cached->compile_id, $content, - $timestamp, $cached->source->uid + $cached->filepath, + $cached->source->name, + $cached->cache_id, + $cached->compile_id, + $content, + $timestamp, + $cached->source->uid ) ) { return; } $cached->content = $content; - $cached->timestamp = (int) $timestamp; + $cached->timestamp = (int)$timestamp; $cached->exists = !!$cached->timestamp; } @@ -90,7 +94,9 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource * * @return boolean true or false if the cached content does not exist */ - public function process(Smarty_Internal_Template $_smarty_tpl, Smarty_Template_Cached $cached = null, + public function process( + Smarty_Internal_Template $_smarty_tpl, + Smarty_Template_Cached $cached = null, $update = false ) { if (!$cached) { @@ -100,8 +106,13 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource $timestamp = $cached->timestamp ? $cached->timestamp : null; if ($content === null || !$timestamp) { if (!$this->fetch( - $_smarty_tpl->cached->filepath, $_smarty_tpl->source->name, $_smarty_tpl->cache_id, - $_smarty_tpl->compile_id, $content, $timestamp, $_smarty_tpl->source->uid + $_smarty_tpl->cached->filepath, + $_smarty_tpl->source->name, + $_smarty_tpl->cache_id, + $_smarty_tpl->compile_id, + $content, + $timestamp, + $_smarty_tpl->source->uid ) ) { return false; @@ -109,10 +120,8 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource } if (isset($content)) { eval('?>' . $content); - return true; } - return false; } @@ -127,7 +136,6 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource public function writeCachedContent(Smarty_Internal_Template $_template, $content) { $this->addMetaTimestamp($content); - return $this->write(array($_template->cached->filepath => $content), $_template->cache_lifetime); } @@ -144,8 +152,13 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource $timestamp = null; if ($content === null) { if (!$this->fetch( - $_template->cached->filepath, $_template->source->name, $_template->cache_id, - $_template->compile_id, $content, $timestamp, $_template->source->uid + $_template->cached->filepath, + $_template->source->name, + $_template->cache_id, + $_template->compile_id, + $content, + $timestamp, + $_template->source->uid ) ) { return false; @@ -173,7 +186,7 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource if (!$this->purge()) { $this->invalidate(null); } - return - 1; + return -1; } /** @@ -199,7 +212,7 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource $this->sanitize($compile_id); $this->delete(array($cid)); $this->invalidate($cid, $resource_name, $cache_id, $compile_id, $uid); - return - 1; + return -1; } /** @@ -251,13 +264,18 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource * * @return boolean success */ - protected function fetch($cid, $resource_name = null, $cache_id = null, $compile_id = null, &$content = null, - &$timestamp = null, $resource_uid = null + protected function fetch( + $cid, + $resource_name = null, + $cache_id = null, + $compile_id = null, + &$content = null, + &$timestamp = null, + $resource_uid = null ) { $t = $this->read(array($cid)); $content = !empty($t[ $cid ]) ? $t[ $cid ] : null; $timestamp = null; - if ($content && ($timestamp = $this->getMetaTimestamp($content))) { $invalidated = $this->getLatestInvalidationTimestamp($cid, $resource_name, $cache_id, $compile_id, $resource_uid); @@ -266,7 +284,6 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource $content = null; } } - return !!$content; } @@ -279,7 +296,7 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource protected function addMetaTimestamp(&$content) { $mt = explode(' ', microtime()); - $ts = pack('NN', $mt[ 1 ], (int) ($mt[ 0 ] * 100000000)); + $ts = pack('NN', $mt[ 1 ], (int)($mt[ 0 ] * 100000000)); $content = $ts . $content; } @@ -311,7 +328,11 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource * * @return void */ - protected function invalidate($cid = null, $resource_name = null, $cache_id = null, $compile_id = null, + protected function invalidate( + $cid = null, + $resource_name = null, + $cache_id = null, + $compile_id = null, $resource_uid = null ) { $now = microtime(true); @@ -352,7 +373,11 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource * * @return float the microtime the CacheID was invalidated */ - protected function getLatestInvalidationTimestamp($cid, $resource_name = null, $cache_id = null, $compile_id = null, + protected function getLatestInvalidationTimestamp( + $cid, + $resource_name = null, + $cache_id = null, + $compile_id = null, $resource_uid = null ) { // abort if there is no CacheID @@ -363,14 +388,12 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource if (!($_cid = $this->listInvalidationKeys($cid, $resource_name, $cache_id, $compile_id, $resource_uid))) { return 0; } - // there are no InValidationKeys if (!($values = $this->read($_cid))) { return 0; } // make sure we're dealing with floats $values = array_map('floatval', $values); - return max($values); } @@ -387,7 +410,11 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource * @return array list of InvalidationKeys * @uses $invalidationKeyPrefix to prepend to each InvalidationKey */ - protected function listInvalidationKeys($cid, $resource_name = null, $cache_id = null, $compile_id = null, + protected function listInvalidationKeys( + $cid, + $resource_name = null, + $cache_id = null, + $compile_id = null, $resource_uid = null ) { $t = array('IVK#ALL'); @@ -421,9 +448,8 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource $t[] = 'IVK#CACHE#' . $part; $t[] = 'IVK#CID' . $_name . $part . $_compile; // skip past delimiter position - $i ++; + $i++; } - return $t; } @@ -439,7 +465,6 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource { $key = 'LOCK#' . $cached->filepath; $data = $this->read(array($key)); - return $data && time() - $data[ $key ] < $smarty->locking_timeout; } diff --git a/libs/sysplugins/smarty_data.php b/libs/sysplugins/smarty_data.php index 743b117b..2545ed3a 100644 --- a/libs/sysplugins/smarty_data.php +++ b/libs/sysplugins/smarty_data.php @@ -22,7 +22,7 @@ class Smarty_Data extends Smarty_Internal_Data * * @var int */ - static $count = 0; + public static $count = 0; /** * Data block name @@ -50,7 +50,7 @@ class Smarty_Data extends Smarty_Internal_Data public function __construct($_parent = null, $smarty = null, $name = null) { parent::__construct(); - self::$count ++; + self::$count++; $this->dataObjectName = 'Data_object ' . (isset($name) ? "'{$name}'" : self::$count); $this->smarty = $smarty; if (is_object($_parent)) { diff --git a/libs/sysplugins/smarty_internal_cacheresource_file.php b/libs/sysplugins/smarty_internal_cacheresource_file.php index 8bc50b79..61618449 100644 --- a/libs/sysplugins/smarty_internal_cacheresource_file.php +++ b/libs/sysplugins/smarty_internal_cacheresource_file.php @@ -7,6 +7,7 @@ * @author Uwe Tews * @author Rodney Rehm */ + /** * This class does contain all necessary methods for the HTML cache on file system * Implements the file system as resource for the HTML cache Version ussing nocache inserts. @@ -33,12 +34,16 @@ class Smarty_Internal_CacheResource_File extends Smarty_CacheResource $cached->filepath = $smarty->getCacheDir(); if (isset($_template->cache_id)) { $cached->filepath .= preg_replace( - array('![^\w|]+!', - '![|]+!'), - array('_', - $_compile_dir_sep), - $_template->cache_id - ) . $_compile_dir_sep; + array( + '![^\w|]+!', + '![|]+!' + ), + array( + '_', + $_compile_dir_sep + ), + $_template->cache_id + ) . $_compile_dir_sep; } if (isset($_template->compile_id)) { $cached->filepath .= preg_replace('![^\w]+!', '_', $_template->compile_id) . $_compile_dir_sep; @@ -89,7 +94,8 @@ class Smarty_Internal_CacheResource_File extends Smarty_CacheResource * * @return boolean true or false if the cached content does not exist */ - public function process(Smarty_Internal_Template $_smarty_tpl, + public function process( + Smarty_Internal_Template $_smarty_tpl, Smarty_Template_Cached $cached = null, $update = false ) { @@ -114,12 +120,12 @@ class Smarty_Internal_CacheResource_File extends Smarty_CacheResource public function writeCachedContent(Smarty_Internal_Template $_template, $content) { if ($_template->smarty->ext->_writeFile->writeFile( - $_template->cached->filepath, - $content, - $_template->smarty - ) === true + $_template->cached->filepath, + $content, + $_template->smarty + ) === true ) { - if (function_exists('opcache_invalidate') + if (function_exists('opcache_invalidate') && (!function_exists('ini_get') || strlen(ini_get('opcache.restrict_api'))) < 1 ) { opcache_invalidate($_template->cached->filepath, true); diff --git a/libs/sysplugins/smarty_internal_compile_assign.php b/libs/sysplugins/smarty_internal_compile_assign.php index d2d24afe..4b998488 100644 --- a/libs/sysplugins/smarty_internal_compile_assign.php +++ b/libs/sysplugins/smarty_internal_compile_assign.php @@ -29,9 +29,11 @@ class Smarty_Internal_Compile_Assign extends Smarty_Internal_CompileBase * * @var array */ - public $valid_scopes = array('local' => Smarty::SCOPE_LOCAL, 'parent' => Smarty::SCOPE_PARENT, - 'root' => Smarty::SCOPE_ROOT, 'global' => Smarty::SCOPE_GLOBAL, - 'tpl_root' => Smarty::SCOPE_TPL_ROOT, 'smarty' => Smarty::SCOPE_SMARTY); + public $valid_scopes = array( + 'local' => Smarty::SCOPE_LOCAL, 'parent' => Smarty::SCOPE_PARENT, + 'root' => Smarty::SCOPE_ROOT, 'global' => Smarty::SCOPE_GLOBAL, + 'tpl_root' => Smarty::SCOPE_TPL_ROOT, 'smarty' => Smarty::SCOPE_SMARTY + ); /** * Compiles code for the {assign} tag @@ -66,7 +68,7 @@ class Smarty_Internal_Compile_Assign extends Smarty_Internal_CompileBase } // scope setup if ($_attr[ 'noscope' ]) { - $_scope = - 1; + $_scope = -1; } else { $_scope = $compiler->convertScope($_attr, $this->valid_scopes); } diff --git a/libs/sysplugins/smarty_internal_compile_block.php b/libs/sysplugins/smarty_internal_compile_block.php index f8b84a57..8ff15d8e 100644 --- a/libs/sysplugins/smarty_internal_compile_block.php +++ b/libs/sysplugins/smarty_internal_compile_block.php @@ -1,5 +1,5 @@ openTag( $compiler, 'block', - array($_attr, $compiler->nocache, $compiler->parser->current_buffer, - $compiler->template->compiled->has_nocache_code, - $compiler->template->caching) + array( + $_attr, $compiler->nocache, $compiler->parser->current_buffer, + $compiler->template->compiled->has_nocache_code, + $compiler->template->caching + ) ); $compiler->saveRequiredPlugins(true); $compiler->nocache = $compiler->nocache | $compiler->tag_nocache; @@ -85,6 +90,7 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_Compile_Shared_Inher $compiler->suppressNocacheProcessing = true; } } + /** * Smarty Internal Plugin Compile BlockClose Class */ @@ -118,13 +124,12 @@ class Smarty_Internal_Compile_Blockclose extends Smarty_Internal_Compile_Shared_ $_functionCode = $compiler->parser->current_buffer; // setup buffer for template function code $compiler->parser->current_buffer = new Smarty_Internal_ParseTree_Template(); - $output = " $value) { - $output .= "public \${$property} = " . var_export($value, true) .";\n"; + $output .= "public \${$property} = " . var_export($value, true) . ";\n"; } $output .= "public function callBlock(Smarty_Internal_Template \$_smarty_tpl) {\n"; $output .= $compiler->compileRequiredPlugins(); diff --git a/libs/sysplugins/smarty_internal_compile_block_child.php b/libs/sysplugins/smarty_internal_compile_block_child.php index 5a506157..588d1862 100644 --- a/libs/sysplugins/smarty_internal_compile_block_child.php +++ b/libs/sysplugins/smarty_internal_compile_block_child.php @@ -1,5 +1,5 @@ true, 'foreach' => true, 'while' => true, 'section' => true); // check and get attributes $_attr = $this->getAttributes($compiler, $args); - if ($_attr[ 'nocache' ] === true) { $compiler->trigger_template_error('nocache option not allowed', null, true); } - if (isset($_attr[ 'levels' ])) { if (!is_numeric($_attr[ 'levels' ])) { $compiler->trigger_template_error('level attribute must be a numeric constant', null, true); @@ -101,18 +99,18 @@ class Smarty_Internal_Compile_Break extends Smarty_Internal_CompileBase if ($level_count === 0) { break; } - $level_count --; + $level_count--; if ($compiler->_tag_stack[ $stack_count ][ 0 ] === 'foreach') { - $foreachLevels ++; + $foreachLevels++; } } - $stack_count --; + $stack_count--; } if ($level_count !== 0) { $compiler->trigger_template_error("cannot {$this->tag} {$levels} level(s)", null, true); } if ($lastTag === 'foreach' && $this->tag === 'break' && $foreachLevels > 0) { - $foreachLevels --; + $foreachLevels--; } return array($levels, $foreachLevels); } diff --git a/libs/sysplugins/smarty_internal_compile_capture.php b/libs/sysplugins/smarty_internal_compile_capture.php index ef0f09e4..a4ffbc9e 100644 --- a/libs/sysplugins/smarty_internal_compile_capture.php +++ b/libs/sysplugins/smarty_internal_compile_capture.php @@ -41,16 +41,20 @@ class Smarty_Internal_Compile_Capture extends Smarty_Internal_CompileBase * * @return string compiled code */ - public static function compileSpecialVariable($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = null) - { - return '$_smarty_tpl->smarty->ext->_capture->getBuffer($_smarty_tpl'.(isset($parameter[ 1 ])?", {$parameter[ 1 ]})":')'); + public static function compileSpecialVariable( + $args, + Smarty_Internal_TemplateCompilerBase $compiler, + $parameter = null + ) { + return '$_smarty_tpl->smarty->ext->_capture->getBuffer($_smarty_tpl' . + (isset($parameter[ 1 ]) ? ", {$parameter[ 1 ]})" : ')'); } /** * Compiles code for the {capture} tag * - * @param array $args array with attributes from parser - * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object + * @param array $args array with attributes from parser + * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object * @param null $parameter * * @return string compiled code @@ -59,16 +63,13 @@ class Smarty_Internal_Compile_Capture extends Smarty_Internal_CompileBase { // check and get attributes $_attr = $this->getAttributes($compiler, $args, $parameter, 'capture'); - $buffer = isset($_attr[ 'name' ]) ? $_attr[ 'name' ] : "'default'"; $assign = isset($_attr[ 'assign' ]) ? $_attr[ 'assign' ] : 'null'; $append = isset($_attr[ 'append' ]) ? $_attr[ 'append' ] : 'null'; - $compiler->_cache[ 'capture_stack' ][] = array($compiler->nocache); // maybe nocache because of nocache variables $compiler->nocache = $compiler->nocache | $compiler->tag_nocache; $_output = "smarty->ext->_capture->open(\$_smarty_tpl, $buffer, $assign, $append);?>"; - return $_output; } } @@ -84,8 +85,8 @@ class Smarty_Internal_Compile_CaptureClose extends Smarty_Internal_CompileBase /** * Compiles code for the {/capture} tag * - * @param array $args array with attributes from parser - * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object + * @param array $args array with attributes from parser + * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object * @param null $parameter * * @return string compiled code @@ -98,9 +99,7 @@ class Smarty_Internal_Compile_CaptureClose extends Smarty_Internal_CompileBase if ($compiler->nocache) { $compiler->tag_nocache = true; } - list($compiler->nocache) = array_pop($compiler->_cache[ 'capture_stack' ]); - return "smarty->ext->_capture->close(\$_smarty_tpl);?>"; } } diff --git a/libs/sysplugins/smarty_internal_compile_child.php b/libs/sysplugins/smarty_internal_compile_child.php index 460fdeb7..f728c18b 100644 --- a/libs/sysplugins/smarty_internal_compile_child.php +++ b/libs/sysplugins/smarty_internal_compile_child.php @@ -1,5 +1,5 @@ getAttributes($compiler, $args); - $tag = isset($parameter[0]) ? "'{$parameter[0]}'" : "'{{$this->tag}}'"; + $tag = isset($parameter[ 0 ]) ? "'{$parameter[0]}'" : "'{{$this->tag}}'"; if (!isset($compiler->_cache[ 'blockNesting' ])) { $compiler->trigger_template_error( "{$tag} used outside {block} tags ", @@ -69,11 +69,11 @@ class Smarty_Internal_Compile_Child extends Smarty_Internal_CompileBase $output .= "ob_start();\n"; } $output .= '$_smarty_tpl->inheritance->call' . $this->blockType . '($_smarty_tpl, $this' . - ($this->blockType === 'Child' ? '' : ", {$tag}"). ");\n"; + ($this->blockType === 'Child' ? '' : ", {$tag}") . ");\n"; if (isset($_assign)) { $output .= "\$_smarty_tpl->assign({$_assign}, ob_get_clean());\n"; } - $output .="?>\n"; + $output .= "?>\n"; return $output; } } diff --git a/libs/sysplugins/smarty_internal_compile_config_load.php b/libs/sysplugins/smarty_internal_compile_config_load.php index f94db5a1..8fe64ee1 100644 --- a/libs/sysplugins/smarty_internal_compile_config_load.php +++ b/libs/sysplugins/smarty_internal_compile_config_load.php @@ -53,9 +53,11 @@ class Smarty_Internal_Compile_Config_Load extends Smarty_Internal_CompileBase * * @var array */ - public $valid_scopes = array('local' => Smarty::SCOPE_LOCAL, 'parent' => Smarty::SCOPE_PARENT, - 'root' => Smarty::SCOPE_ROOT, 'tpl_root' => Smarty::SCOPE_TPL_ROOT, - 'smarty' => Smarty::SCOPE_SMARTY, 'global' => Smarty::SCOPE_SMARTY); + public $valid_scopes = array( + 'local' => Smarty::SCOPE_LOCAL, 'parent' => Smarty::SCOPE_PARENT, + 'root' => Smarty::SCOPE_ROOT, 'tpl_root' => Smarty::SCOPE_TPL_ROOT, + 'smarty' => Smarty::SCOPE_SMARTY, 'global' => Smarty::SCOPE_SMARTY + ); /** * Compiles code for the {config_load} tag @@ -70,11 +72,9 @@ class Smarty_Internal_Compile_Config_Load extends Smarty_Internal_CompileBase { // check and get attributes $_attr = $this->getAttributes($compiler, $args); - if ($_attr[ 'nocache' ] === true) { $compiler->trigger_template_error('nocache option not allowed', null, true); } - // save possible attributes $conf_file = $_attr[ 'file' ]; if (isset($_attr[ 'section' ])) { @@ -84,15 +84,13 @@ class Smarty_Internal_Compile_Config_Load extends Smarty_Internal_CompileBase } // scope setup if ($_attr[ 'noscope' ]) { - $_scope = - 1; + $_scope = -1; } else { $_scope = $compiler->convertScope($_attr, $this->valid_scopes); } - // create config object $_output = "smarty->ext->configLoad->_loadConfigFile(\$_smarty_tpl, {$conf_file}, {$section}, {$_scope});\n?>\n"; - return $_output; } } diff --git a/libs/sysplugins/smarty_internal_compile_debug.php b/libs/sysplugins/smarty_internal_compile_debug.php index a7448f5b..79941668 100644 --- a/libs/sysplugins/smarty_internal_compile_debug.php +++ b/libs/sysplugins/smarty_internal_compile_debug.php @@ -29,10 +29,8 @@ class Smarty_Internal_Compile_Debug extends Smarty_Internal_CompileBase { // check and get attributes $_attr = $this->getAttributes($compiler, $args); - // compile always as nocache $compiler->tag_nocache = true; - // display debug template $_output = "display_debug(\$_smarty_tpl);\n"; diff --git a/libs/sysplugins/smarty_internal_compile_eval.php b/libs/sysplugins/smarty_internal_compile_eval.php index daad449c..8e0174e3 100644 --- a/libs/sysplugins/smarty_internal_compile_eval.php +++ b/libs/sysplugins/smarty_internal_compile_eval.php @@ -56,16 +56,15 @@ class Smarty_Internal_Compile_Eval extends Smarty_Internal_CompileBase // output will be stored in a smarty variable instead of being displayed $_assign = $_attr[ 'assign' ]; } - // create template object - $_output = "\$_template = new {$compiler->smarty->template_class}('eval:'.{$_attr[ 'var' ]}, \$_smarty_tpl->smarty, \$_smarty_tpl);"; + $_output = + "\$_template = new {$compiler->smarty->template_class}('eval:'.{$_attr[ 'var' ]}, \$_smarty_tpl->smarty, \$_smarty_tpl);"; //was there an assign attribute? if (isset($_assign)) { $_output .= "\$_smarty_tpl->assign($_assign,\$_template->fetch());"; } else { $_output .= 'echo $_template->fetch();'; } - return ""; } } diff --git a/libs/sysplugins/smarty_internal_compile_extends.php b/libs/sysplugins/smarty_internal_compile_extends.php index bb751811..d72d2b76 100644 --- a/libs/sysplugins/smarty_internal_compile_extends.php +++ b/libs/sysplugins/smarty_internal_compile_extends.php @@ -1,5 +1,4 @@ compileEndChild($compiler); } @@ -111,9 +110,9 @@ class Smarty_Internal_Compile_Extends extends Smarty_Internal_Compile_Shared_Inh $compiler->parser->template_postfix[] = new Smarty_Internal_ParseTree_Tag( $compiler->parser, 'inheritance->endChild($_smarty_tpl' . - (isset($template) ? - ", {$template}{$inlineUids}" : - '') . ");\n?>" + (isset($template) ? + ", {$template}{$inlineUids}" : + '') . ");\n?>" ); } @@ -132,8 +131,10 @@ class Smarty_Internal_Compile_Extends extends Smarty_Internal_Compile_Shared_Inh $compiler->parser, $compiler->compileTag( 'include', - array($template, - array('scope' => 'parent')) + array( + $template, + array('scope' => 'parent') + ) ) ); } diff --git a/libs/sysplugins/smarty_internal_compile_for.php b/libs/sysplugins/smarty_internal_compile_for.php index c98f3163..3f113e56 100644 --- a/libs/sysplugins/smarty_internal_compile_for.php +++ b/libs/sysplugins/smarty_internal_compile_for.php @@ -34,7 +34,7 @@ class Smarty_Internal_Compile_For extends Smarty_Internal_CompileBase */ public function compile($args, $compiler, $parameter) { - $compiler->loopNesting ++; + $compiler->loopNesting++; if ($parameter === 0) { $this->required_attributes = array('start', 'to'); $this->optional_attributes = array('max', 'step'); @@ -45,7 +45,6 @@ class Smarty_Internal_Compile_For extends Smarty_Internal_CompileBase $this->mapCache = array(); // check and get attributes $_attr = $this->getAttributes($compiler, $args); - $output = "tpl_vars[$var]->last = \$_smarty_tpl->tpl_vars[$var]->iteration === \$_smarty_tpl->tpl_vars[$var]->total;"; } $output .= '?>'; - $this->openTag($compiler, 'for', array('for', $compiler->nocache)); // maybe nocache because of nocache variables $compiler->nocache = $compiler->nocache | $compiler->tag_nocache; @@ -123,10 +121,8 @@ class Smarty_Internal_Compile_Forelse extends Smarty_Internal_CompileBase { // check and get attributes $_attr = $this->getAttributes($compiler, $args); - list($openTag, $nocache) = $this->closeTag($compiler, array('for')); $this->openTag($compiler, 'forelse', array('forelse', $nocache)); - return ""; } } @@ -150,16 +146,14 @@ class Smarty_Internal_Compile_Forclose extends Smarty_Internal_CompileBase */ public function compile($args, $compiler, $parameter) { - $compiler->loopNesting --; + $compiler->loopNesting--; // check and get attributes $_attr = $this->getAttributes($compiler, $args); // must endblock be nocache? if ($compiler->nocache) { $compiler->tag_nocache = true; } - list($openTag, $compiler->nocache) = $this->closeTag($compiler, array('for', 'forelse')); - $output = "loopNesting ++; + $compiler->loopNesting++; // init $this->isNamed = false; // check and get attributes @@ -121,14 +121,14 @@ class Smarty_Internal_Compile_Foreach extends Smarty_Internal_Compile_Private_Fo if (isset($attributes[ $a ]) && $attributes[ $a ] === $fromName) { $compiler->trigger_template_error( "'{$a}' and 'from' may not have same variable name '{$fromName}'", - null, true + null, + true ); } } } - $itemVar = "\$_smarty_tpl->tpl_vars['{$item}']"; - $local = '$__foreach_' . $attributes[ 'item' ] . '_' . $this->counter ++ . '_'; + $local = '$__foreach_' . $attributes[ 'item' ] . '_' . $this->counter++ . '_'; // search for used tag attributes $itemAttr = array(); $namedAttr = array(); @@ -190,7 +190,8 @@ class Smarty_Internal_Compile_Foreach extends Smarty_Internal_Compile_Private_Fo $needTotal = isset($itemAttr[ 'total' ]); // Register tag $this->openTag( - $compiler, 'foreach', + $compiler, + 'foreach', array('foreach', $compiler->nocache, $local, $itemVar, empty($itemAttr) ? 1 : 2) ); // maybe nocache because of nocache variables @@ -253,7 +254,6 @@ class Smarty_Internal_Compile_Foreach extends Smarty_Internal_Compile_Private_Fo $output .= "{$local}saved = {$itemVar};\n"; } $output .= '?>'; - return $output; } @@ -290,7 +290,6 @@ class Smarty_Internal_Compile_Foreachelse extends Smarty_Internal_CompileBase { // check and get attributes $_attr = $this->getAttributes($compiler, $args); - list($openTag, $nocache, $local, $itemVar, $restore) = $this->closeTag($compiler, array('foreach')); $this->openTag($compiler, 'foreachelse', array('foreachelse', $nocache, $local, $itemVar, 0)); $output = "loopNesting --; + $compiler->loopNesting--; // must endblock be nocache? if ($compiler->nocache) { $compiler->tag_nocache = true; } - list($openTag, $compiler->nocache, $local, $itemVar, $restore) = $this->closeTag($compiler, array('foreach', 'foreachelse')); $output = "getAttributes($compiler, $args); - if ($_attr[ 'nocache' ] === true) { $compiler->trigger_template_error('nocache option not allowed', null, true); } unset($_attr[ 'nocache' ]); $_name = trim($_attr[ 'name' ], '\'"'); $compiler->parent_compiler->tpl_function[ $_name ] = array(); - $save = array($_attr, $compiler->parser->current_buffer, $compiler->template->compiled->has_nocache_code, - $compiler->template->caching); + $save = array( + $_attr, $compiler->parser->current_buffer, $compiler->template->compiled->has_nocache_code, + $compiler->template->caching + ); $this->openTag($compiler, 'function', $save); // Init temporary context $compiler->parser->current_buffer = new Smarty_Internal_ParseTree_Template(); @@ -80,7 +80,6 @@ class Smarty_Internal_Compile_Function extends Smarty_Internal_CompileBase */ class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase { - /** * Compiler object * @@ -125,7 +124,6 @@ class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase $_functionCode = $compiler->parser->current_buffer; // setup buffer for template function code $compiler->parser->current_buffer = new Smarty_Internal_ParseTree_Template(); - $_funcName = "smarty_template_function_{$_name}_{$compiler->template->compiled->nocache_hash}"; $_funcNameCaching = $_funcName . '_nocache'; if ($compiler->template->compiled->has_nocache_code) { @@ -181,7 +179,8 @@ class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase $output .= "function {$_funcName}(Smarty_Internal_Template \$_smarty_tpl,\$params) {\n"; $output .= $_paramsCode; $output .= "foreach (\$params as \$key => \$value) {\n\$_smarty_tpl->tpl_vars[\$key] = new Smarty_Variable(\$value, \$_smarty_tpl->isRenderingCache);\n}\n"; - $output .= $compiler->compileCheckPlugins(array_merge($compiler->required_plugins[ 'compiled' ], $compiler->required_plugins[ 'nocache' ])); + $output .= $compiler->compileCheckPlugins(array_merge($compiler->required_plugins[ 'compiled' ], + $compiler->required_plugins[ 'nocache' ])); $output .= "?>\n"; $compiler->parser->current_buffer->append_subtree( $compiler->parser, @@ -218,12 +217,13 @@ class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase * * @return string */ - function removeNocache($match) + public function removeNocache($match) { $code = preg_replace( "/((<\?php )?echo '\/\*%%SmartyNocache:{$this->compiler->template->compiled->nocache_hash}%%\*\/)|(\/\*\/%%SmartyNocache:{$this->compiler->template->compiled->nocache_hash}%%\*\/';(\?>\n)?)/", - '', $match[ 0 ] + '', + $match[ 0 ] ); $code = str_replace(array('\\\'', '\\\\\''), array('\'', '\\\''), $code); return $code; diff --git a/libs/sysplugins/smarty_internal_compile_if.php b/libs/sysplugins/smarty_internal_compile_if.php index 9848e2d1..df3dc3fa 100644 --- a/libs/sysplugins/smarty_internal_compile_if.php +++ b/libs/sysplugins/smarty_internal_compile_if.php @@ -33,11 +33,9 @@ class Smarty_Internal_Compile_If extends Smarty_Internal_CompileBase $this->openTag($compiler, 'if', array(1, $compiler->nocache)); // must whole block be nocache ? $compiler->nocache = $compiler->nocache | $compiler->tag_nocache; - - if (!isset($parameter['if condition'])) { + if (!isset($parameter[ 'if condition' ])) { $compiler->trigger_template_error('missing if condition', null, true); } - if (is_array($parameter[ 'if condition' ])) { if (is_array($parameter[ 'if condition' ][ 'var' ])) { $var = $parameter[ 'if condition' ][ 'var' ][ 'var' ]; @@ -56,7 +54,8 @@ class Smarty_Internal_Compile_If extends Smarty_Internal_CompileBase if (is_array($parameter[ 'if condition' ][ 'var' ])) { $assignAttr[][ 'var' ] = $parameter[ 'if condition' ][ 'var' ][ 'var' ]; $_output .= $assignCompiler->compile( - $assignAttr, $compiler, + $assignAttr, + $compiler, array('smarty_internal_index' => $parameter[ 'if condition' ][ 'var' ][ 'smarty_internal_index' ]) ); } else { @@ -91,7 +90,6 @@ class Smarty_Internal_Compile_Else extends Smarty_Internal_CompileBase { list($nesting, $compiler->tag_nocache) = $this->closeTag($compiler, array('if', 'elseif')); $this->openTag($compiler, 'else', array($nesting, $compiler->tag_nocache)); - return ''; } } @@ -118,13 +116,10 @@ class Smarty_Internal_Compile_Elseif extends Smarty_Internal_CompileBase { // check and get attributes $_attr = $this->getAttributes($compiler, $args); - list($nesting, $compiler->tag_nocache) = $this->closeTag($compiler, array('if', 'elseif')); - - if (!isset($parameter['if condition'])) { + if (!isset($parameter[ 'if condition' ])) { $compiler->trigger_template_error('missing elseif condition', null, true); } - $assignCode = ''; $var = ''; if (is_array($parameter[ 'if condition' ])) { @@ -146,7 +141,8 @@ class Smarty_Internal_Compile_Elseif extends Smarty_Internal_CompileBase if (is_array($parameter[ 'if condition' ][ 'var' ])) { $assignAttr[][ 'var' ] = $parameter[ 'if condition' ][ 'var' ][ 'var' ]; $assignCode .= $assignCompiler->compile( - $assignAttr, $compiler, + $assignAttr, + $compiler, array('smarty_internal_index' => $parameter[ 'if condition' ][ 'var' ][ 'smarty_internal_index' ]) ); } else { @@ -156,7 +152,6 @@ class Smarty_Internal_Compile_Elseif extends Smarty_Internal_CompileBase } else { $condition_by_assign = false; } - $prefixCode = $compiler->getPrefixCode(); if (empty($prefixCode)) { if ($condition_by_assign) { @@ -204,10 +199,9 @@ class Smarty_Internal_Compile_Ifclose extends Smarty_Internal_CompileBase } list($nesting, $compiler->nocache) = $this->closeTag($compiler, array('if', 'else', 'elseif')); $tmp = ''; - for ($i = 0; $i < $nesting; $i ++) { + for ($i = 0; $i < $nesting; $i++) { $tmp .= '}'; } - return ""; } } diff --git a/libs/sysplugins/smarty_internal_compile_include.php b/libs/sysplugins/smarty_internal_compile_include.php index 8bf9cb61..716c91d4 100644 --- a/libs/sysplugins/smarty_internal_compile_include.php +++ b/libs/sysplugins/smarty_internal_compile_include.php @@ -7,6 +7,7 @@ * @subpackage Compiler * @author Uwe Tews */ + /** * Smarty Internal Plugin Compile Include Class * @@ -19,6 +20,7 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase * caching mode to create nocache code but no cache file */ const CACHING_NOCACHE_CODE = 9999; + /** * Attribute definition: Overwrites base class. * @@ -26,6 +28,7 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase * @see Smarty_Internal_CompileBase */ public $required_attributes = array('file'); + /** * Attribute definition: Overwrites base class. * @@ -33,6 +36,7 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase * @see Smarty_Internal_CompileBase */ public $shorttag_order = array('file'); + /** * Attribute definition: Overwrites base class. * @@ -40,6 +44,7 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase * @see Smarty_Internal_CompileBase */ public $option_flags = array('nocache', 'inline', 'caching'); + /** * Attribute definition: Overwrites base class. * @@ -47,14 +52,17 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase * @see Smarty_Internal_CompileBase */ public $optional_attributes = array('_any'); + /** * Valid scope names * * @var array */ - public $valid_scopes = array('parent' => Smarty::SCOPE_PARENT, 'root' => Smarty::SCOPE_ROOT, - 'global' => Smarty::SCOPE_GLOBAL, 'tpl_root' => Smarty::SCOPE_TPL_ROOT, - 'smarty' => Smarty::SCOPE_SMARTY); + public $valid_scopes = array( + 'parent' => Smarty::SCOPE_PARENT, 'root' => Smarty::SCOPE_ROOT, + 'global' => Smarty::SCOPE_GLOBAL, 'tpl_root' => Smarty::SCOPE_TPL_ROOT, + 'smarty' => Smarty::SCOPE_SMARTY + ); /** * Compiles code for the {include} tag @@ -91,7 +99,8 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase $compiled->includes[ $fullResourceName ]++; $cache_tpl = true; } else { - if ("{$compiler->template->source->type}:{$compiler->template->source->name}" == $fullResourceName + if ("{$compiler->template->source->type}:{$compiler->template->source->name}" == + $fullResourceName ) { // recursive call of current template $compiled->includes[ $fullResourceName ] = 2; @@ -193,8 +202,11 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase $compiler->smarty->allow_ambiguous_resources = true; /* @var Smarty_Internal_Template $tpl */ $tpl = new $compiler->smarty->template_class( - trim($fullResourceName, '"\''), $compiler->smarty, - $compiler->template, $compiler->template->cache_id, $c_id, + trim($fullResourceName, '"\''), + $compiler->smarty, + $compiler->template, + $compiler->template->cache_id, + $c_id, $_caching ); $uid = $tpl->source->type . $tpl->source->uid; @@ -276,7 +288,8 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase * @throws \Exception * @throws \SmartyException */ - public function compileInlineTemplate(Smarty_Internal_SmartyTemplateCompiler $compiler, + public function compileInlineTemplate( + Smarty_Internal_SmartyTemplateCompiler $compiler, Smarty_Internal_Template $tpl, $t_hash ) { diff --git a/libs/sysplugins/smarty_internal_compile_include_php.php b/libs/sysplugins/smarty_internal_compile_include_php.php index 7fd53809..1b0fdaad 100644 --- a/libs/sysplugins/smarty_internal_compile_include_php.php +++ b/libs/sysplugins/smarty_internal_compile_include_php.php @@ -7,6 +7,7 @@ * @subpackage Compiler * @author Uwe Tews */ + /** * Smarty Internal Plugin Compile Insert Class * @@ -57,9 +58,9 @@ class Smarty_Internal_Compile_Include_Php extends Smarty_Internal_CompileBase // check and get attributes $_attr = $this->getAttributes($compiler, $args); /** -* * - * @var Smarty_Internal_Template $_smarty_tpl + * + * @var Smarty_Internal_Template $_smarty_tpl * used in evaluated code */ $_smarty_tpl = $compiler->template; diff --git a/libs/sysplugins/smarty_internal_compile_insert.php b/libs/sysplugins/smarty_internal_compile_insert.php index 8ac4b716..56fbc561 100644 --- a/libs/sysplugins/smarty_internal_compile_insert.php +++ b/libs/sysplugins/smarty_internal_compile_insert.php @@ -23,6 +23,7 @@ class Smarty_Internal_Compile_Insert extends Smarty_Internal_CompileBase * @see Smarty_Internal_CompileBase */ public $required_attributes = array('name'); + /** * Attribute definition: Overwrites base class. * @@ -30,6 +31,7 @@ class Smarty_Internal_Compile_Insert extends Smarty_Internal_CompileBase * @see Smarty_Internal_CompileBase */ public $shorttag_order = array('name'); + /** * Attribute definition: Overwrites base class. * diff --git a/libs/sysplugins/smarty_internal_compile_nocache.php b/libs/sysplugins/smarty_internal_compile_nocache.php index 825b60bf..12f64ed2 100644 --- a/libs/sysplugins/smarty_internal_compile_nocache.php +++ b/libs/sysplugins/smarty_internal_compile_nocache.php @@ -40,7 +40,6 @@ class Smarty_Internal_Compile_Nocache extends Smarty_Internal_CompileBase $compiler->nocache = true; // this tag does not return compiled code $compiler->has_code = false; - return true; } } @@ -69,7 +68,6 @@ class Smarty_Internal_Compile_Nocacheclose extends Smarty_Internal_CompileBase list($compiler->nocache) = $this->closeTag($compiler, array('nocache')); // this tag does not return compiled code $compiler->has_code = false; - return true; } } diff --git a/libs/sysplugins/smarty_internal_compile_parent.php b/libs/sysplugins/smarty_internal_compile_parent.php index c04689f0..ff23edf7 100644 --- a/libs/sysplugins/smarty_internal_compile_parent.php +++ b/libs/sysplugins/smarty_internal_compile_parent.php @@ -1,5 +1,5 @@ getAttributes($compiler, $args); - $this->nesting ++; + $this->nesting++; unset($_attr[ 'nocache' ]); list($callback, $_paramsArray, $callable) = $this->setup($compiler, $_attr, $tag, $function); $_params = 'array(' . implode(',', $_paramsArray) . ')'; - // compile code $output = "tag_nocache = true; } // closing tag of block plugin, restore nocache - list($_params, $compiler->nocache, $callback) = $this->closeTag($compiler, substr($tag, 0, - 5)); + list($_params, $compiler->nocache, $callback) = $this->closeTag($compiler, substr($tag, 0, -5)); // compile code if (!isset($parameter[ 'modifier_list' ])) { $mod_pre = $mod_post = $mod_content = ''; @@ -85,12 +84,16 @@ class Smarty_Internal_Compile_Private_Block_Plugin extends Smarty_Internal_Compi $mod_content = "\$_block_content{$this->nesting} = ob_get_clean();\n"; $mod_pre = "ob_start();\n"; $mod_post = 'echo ' . $compiler->compileTag( - 'private_modifier', array(), - array('modifierlist' => $parameter[ 'modifier_list' ], - 'value' => 'ob_get_clean()') - ) . ";\n"; + 'private_modifier', + array(), + array( + 'modifierlist' => $parameter[ 'modifier_list' ], + 'value' => 'ob_get_clean()' + ) + ) . ";\n"; } - $output = "smarty->_cache[\'_tag_stack\']);?>'; } return $output; @@ -100,7 +103,7 @@ class Smarty_Internal_Compile_Private_Block_Plugin extends Smarty_Internal_Compi * Setup callback and parameter array * * @param \Smarty_Internal_TemplateCompilerBase $compiler - * @param array $_attr attributes + * @param array $_attr attributes * @param string $tag * @param string $function * diff --git a/libs/sysplugins/smarty_internal_compile_private_foreachsection.php b/libs/sysplugins/smarty_internal_compile_private_foreachsection.php index e8c9b97b..e763dd92 100644 --- a/libs/sysplugins/smarty_internal_compile_private_foreachsection.php +++ b/libs/sysplugins/smarty_internal_compile_private_foreachsection.php @@ -16,7 +16,6 @@ */ class Smarty_Internal_Compile_Private_ForeachSection extends Smarty_Internal_CompileBase { - /** * Preg search pattern * @@ -113,8 +112,10 @@ class Smarty_Internal_Compile_Private_ForeachSection extends Smarty_Internal_Com { if ($named) { $this->resultOffsets[ 'named' ] = $this->startOffset + 4; - $this->propertyPreg .= "(([\$]smarty[.]{$this->tagName}[.]" . ($this->tagName === 'section' ? "|[\[]\s*" : '') - . "){$attributes['name']}[.]("; + $this->propertyPreg .= "(([\$]smarty[.]{$this->tagName}[.]" . + ($this->tagName === 'section' ? "|[\[]\s*" : '') + . + "){$attributes['name']}[.]("; $properties = $this->nameProperties; } else { $this->resultOffsets[ 'item' ] = $this->startOffset + 3; @@ -178,11 +179,12 @@ class Smarty_Internal_Compile_Private_ForeachSection extends Smarty_Internal_Com $_content = $nextCompiler->template->source->getContent(); if ($_content !== '') { // run pre filter if required - if ((isset($nextCompiler->smarty->autoload_filters[ 'pre' ]) - || isset($nextCompiler->smarty->registered_filters[ 'pre' ])) + if ((isset($nextCompiler->smarty->autoload_filters[ 'pre' ]) + || isset($nextCompiler->smarty->registered_filters[ 'pre' ])) ) { $_content = $nextCompiler->smarty->ext->_filterHandler->runFilter( - 'pre', $_content, + 'pre', + $_content, $nextCompiler->template ); } diff --git a/libs/sysplugins/smarty_internal_compile_private_function_plugin.php b/libs/sysplugins/smarty_internal_compile_private_function_plugin.php index 1d9d9058..05582342 100644 --- a/libs/sysplugins/smarty_internal_compile_private_function_plugin.php +++ b/libs/sysplugins/smarty_internal_compile_private_function_plugin.php @@ -49,7 +49,6 @@ class Smarty_Internal_Compile_Private_Function_Plugin extends Smarty_Internal_Co { // check and get attributes $_attr = $this->getAttributes($compiler, $args); - unset($_attr[ 'nocache' ]); // convert attributes into parameter array string $_paramsArray = array(); @@ -65,9 +64,12 @@ class Smarty_Internal_Compile_Private_Function_Plugin extends Smarty_Internal_Co $output = "{$function}({$_params},\$_smarty_tpl)"; if (!empty($parameter[ 'modifierlist' ])) { $output = $compiler->compileTag( - 'private_modifier', array(), - array('modifierlist' => $parameter[ 'modifierlist' ], - 'value' => $output) + 'private_modifier', + array(), + array( + 'modifierlist' => $parameter[ 'modifierlist' ], + 'value' => $output + ) ); } $output = "\n"; diff --git a/libs/sysplugins/smarty_internal_compile_private_object_block_function.php b/libs/sysplugins/smarty_internal_compile_private_object_block_function.php index 8afdc8d0..baac51b2 100644 --- a/libs/sysplugins/smarty_internal_compile_private_object_block_function.php +++ b/libs/sysplugins/smarty_internal_compile_private_object_block_function.php @@ -20,7 +20,7 @@ class Smarty_Internal_Compile_Private_Object_Block_Function extends Smarty_Inter * Setup callback and parameter array * * @param \Smarty_Internal_TemplateCompilerBase $compiler - * @param array $_attr attributes + * @param array $_attr attributes * @param string $tag * @param string $method * diff --git a/libs/sysplugins/smarty_internal_compile_private_object_function.php b/libs/sysplugins/smarty_internal_compile_private_object_function.php index d1d9fe8b..2a763c6e 100644 --- a/libs/sysplugins/smarty_internal_compile_private_object_function.php +++ b/libs/sysplugins/smarty_internal_compile_private_object_function.php @@ -71,7 +71,8 @@ class Smarty_Internal_Compile_Private_Object_Function extends Smarty_Internal_Co } if (!empty($parameter[ 'modifierlist' ])) { $output = $compiler->compileTag( - 'private_modifier', array(), + 'private_modifier', + array(), array('modifierlist' => $parameter[ 'modifierlist' ], 'value' => $output) ); } diff --git a/libs/sysplugins/smarty_internal_compile_private_php.php b/libs/sysplugins/smarty_internal_compile_private_php.php index c01711dc..a3cf0a27 100644 --- a/libs/sysplugins/smarty_internal_compile_private_php.php +++ b/libs/sysplugins/smarty_internal_compile_private_php.php @@ -16,7 +16,6 @@ */ class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase { - /** * Attribute definition: Overwrites base class. * @@ -62,7 +61,8 @@ class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase $output = preg_replace_callback( '#(<\?(?:php|=)?)|(<%)|(]*>)|(]*>)|(
]*>.*?]*>)#is', - $text, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER + $text, + $matches, + PREG_OFFSET_CAPTURE | PREG_SET_ORDER ) ) { foreach ($matches as $match) { @@ -646,24 +701,26 @@ abstract class Smarty_Internal_TemplateCompilerBase $_length = strlen($match[ 0 ][ 0 ]); $replace = '@!@SMARTY:' . $_store . ':SMARTY@!@'; $text = substr_replace($text, $replace, $match[ 0 ][ 1 ] - $_offset, $_length); - $_offset += $_length - strlen($replace); - $_store ++; + $_store++; } } $expressions = array(// replace multiple spaces between tags by a single space - '#(:SMARTY@!@|>)[\040\011]+(?=@!@SMARTY:|<)#s' => '\1 \2', + '#(:SMARTY@!@|>)[\040\011]+(?=@!@SMARTY:|<)#s' => '\1 \2', // remove newline between tags - '#(:SMARTY@!@|>)[\040\011]*[\n]\s*(?=@!@SMARTY:|<)#s' => '\1\2', + '#(:SMARTY@!@|>)[\040\011]*[\n]\s*(?=@!@SMARTY:|<)#s' => '\1\2', // remove multiple spaces between attributes (but not in attribute values!) '#(([a-z0-9]\s*=\s*("[^"]*?")|(\'[^\']*?\'))|<[a-z0-9_]+)\s+([a-z/>])#is' => '\1 \5', - '#>[\040\011]+$#Ss' => '> ', '#>[\040\011]*[\n]\s*$#Ss' => '>', - $this->stripRegEx => '',); - + '#>[\040\011]+$#Ss' => '> ', + '#>[\040\011]*[\n]\s*$#Ss' => '>', + $this->stripRegEx => '', + ); $text = preg_replace(array_keys($expressions), array_values($expressions), $text); $_offset = 0; if (preg_match_all( - '#@!@SMARTY:([0-9]+):SMARTY@!@#is', $text, $matches, + '#@!@SMARTY:([0-9]+):SMARTY@!@#is', + $text, + $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER ) ) { @@ -671,9 +728,8 @@ abstract class Smarty_Internal_TemplateCompilerBase $_length = strlen($match[ 0 ][ 0 ]); $replace = $store[ $match[ 1 ][ 0 ] ]; $text = substr_replace($text, $replace, $match[ 0 ][ 1 ] + $_offset, $_length); - $_offset += strlen($replace) - $_length; - $_store ++; + $_store++; } } } else { @@ -726,7 +782,7 @@ abstract class Smarty_Internal_TemplateCompilerBase $_tag = explode('_', $tag); $_tag = array_map('ucfirst', $_tag); $class_name = 'Smarty_Internal_Compile_' . implode('_', $_tag); - if (class_exists($class_name) + if (class_exists($class_name) && (!isset($this->smarty->security_policy) || $this->smarty->security_policy->isTrustedTag($tag, $this)) ) { self::$_tag_objects[ $tag ] = new $class_name; @@ -740,8 +796,8 @@ abstract class Smarty_Internal_TemplateCompilerBase /** * Check for plugins and return function name * - * @param $plugin_name - * @param string $plugin_type type of plugin + * @param $plugin_name + * @param string $plugin_type type of plugin * * @return string call name of function * @throws \SmartyException @@ -819,12 +875,14 @@ abstract class Smarty_Internal_TemplateCompilerBase $cacheable = true; $result = call_user_func_array( $this->smarty->default_plugin_handler_func, - array($tag, - $plugin_type, - $this->template, - &$callback, - &$script, - &$cacheable,) + array( + $tag, + $plugin_type, + $this->template, + &$callback, + &$script, + &$cacheable, + ) ); if ($result) { $this->tag_nocache = $this->tag_nocache || !$cacheable; @@ -847,9 +905,11 @@ abstract class Smarty_Internal_TemplateCompilerBase } } if (is_callable($callback)) { - $this->default_handler_plugins[ $plugin_type ][ $tag ] = array($callback, - true, - array()); + $this->default_handler_plugins[ $plugin_type ][ $tag ] = array( + $callback, + true, + array() + ); return true; } else { $this->trigger_template_error("Default plugin handler: Returned callback for '{$tag}' not callable"); @@ -893,13 +953,14 @@ abstract class Smarty_Internal_TemplateCompilerBase // If the template is not evaluated and we have a nocache section and or a nocache tag if ($is_code && !empty($content)) { // generate replacement code - if ((!($this->template->source->handler->recompiled) || $this->forceNocache) && $this->caching + if ((!($this->template->source->handler->recompiled) || $this->forceNocache) && $this->caching && !$this->suppressNocacheProcessing && ($this->nocache || $this->tag_nocache) ) { $this->template->compiled->has_nocache_code = true; $_output = addcslashes($content, '\'\\'); $_output = str_replace('^#^', '\'', $_output); - $_output = "nocache_hash}%%*/{$_output}/*/%%SmartyNocache:{$this->nocache_hash}%%*/';?>\n"; + $_output = + "nocache_hash}%%*/{$_output}/*/%%SmartyNocache:{$this->nocache_hash}%%*/';?>\n"; // make sure we include modifier plugins for nocache code foreach ($this->modifier_plugins as $plugin_name => $dummy) { if (isset($this->required_plugins[ 'compiled' ][ $plugin_name ][ 'modifier' ])) { @@ -968,7 +1029,7 @@ abstract class Smarty_Internal_TemplateCompilerBase } /** - * @param array $_attr tag attributes + * @param array $_attr tag attributes * @param array $validScopes * * @return int|string @@ -1035,19 +1096,21 @@ abstract class Smarty_Internal_TemplateCompilerBase } if (in_array( $this->template->source->type, - array('eval', - 'string') + array( + 'eval', + 'string' + ) ) ) { $templateName = $this->template->source->type . ':' . trim( - preg_replace( - '![\t\r\n]+!', - ' ', - strlen($lex->data) > 40 ? - substr($lex->data, 0, 40) . - '...' : $lex->data - ) - ); + preg_replace( + '![\t\r\n]+!', + ' ', + strlen($lex->data) > 40 ? + substr($lex->data, 0, 40) . + '...' : $lex->data + ) + ); } else { $templateName = $this->template->source->type . ':' . $this->template->source->filepath; } @@ -1131,9 +1194,11 @@ abstract class Smarty_Internal_TemplateCompilerBase { return str_replace( array('SMARTYldel', 'SMARTYliteral', 'SMARTYrdel', 'SMARTYautoliteral', 'SMARTYal'), - array($this->ldelPreg, $this->literalPreg, $this->rdelPreg, - $this->smarty->getAutoLiteral() ? '{1,}' : '{9}', - $this->smarty->getAutoLiteral() ? '' : '\\s*'), + array( + $this->ldelPreg, $this->literalPreg, $this->rdelPreg, + $this->smarty->getAutoLiteral() ? '{1,}' : '{9}', + $this->smarty->getAutoLiteral() ? '' : '\\s*' + ), $lexerPreg ); } @@ -1322,7 +1387,7 @@ abstract class Smarty_Internal_TemplateCompilerBase * * @param bool $init if true init required plugins */ - public function saveRequiredPlugins($init=false) + public function saveRequiredPlugins($init = false) { $this->required_plugins_stack[] = $this->required_plugins; if ($init) { @@ -1379,7 +1444,7 @@ abstract class Smarty_Internal_TemplateCompilerBase /** * method to compile a Smarty template * - * @param mixed $_content template source + * @param mixed $_content template source * @param bool $isTemplateSource * * @return bool true if compiling succeeded, false if it failed @@ -1405,8 +1470,10 @@ abstract class Smarty_Internal_TemplateCompilerBase $this->has_code = true; // log tag/attributes if (isset($this->smarty->_cache[ 'get_used_tags' ])) { - $this->template->_cache[ 'used_tags' ][] = array($tag, - $args); + $this->template->_cache[ 'used_tags' ][] = array( + $tag, + $args + ); } // check nocache option flag foreach ($args as $arg) { @@ -1424,9 +1491,9 @@ abstract class Smarty_Internal_TemplateCompilerBase } // compile the smarty tag (required compile classes to compile the tag are auto loaded) if (($_output = $this->callTagCompiler($tag, $args, $parameter)) === false) { - if (isset($this->parent_compiler->tpl_function[ $tag ]) - || (isset($this->template->smarty->ext->_tplFunction) - && $this->template->smarty->ext->_tplFunction->getTplFunction($this->template, $tag) !== false) + if (isset($this->parent_compiler->tpl_function[ $tag ]) + || (isset($this->template->smarty->ext->_tplFunction) + && $this->template->smarty->ext->_tplFunction->getTplFunction($this->template, $tag) !== false) ) { // template defined by {template} tag $args[ '_attr' ][ 'name' ] = "'{$tag}'"; @@ -1457,9 +1524,9 @@ abstract class Smarty_Internal_TemplateCompilerBase // check if tag is a registered object if (isset($this->smarty->registered_objects[ $tag ]) && isset($parameter[ 'object_method' ])) { $method = $parameter[ 'object_method' ]; - if (!in_array($method, $this->smarty->registered_objects[ $tag ][ 3 ]) - && (empty($this->smarty->registered_objects[ $tag ][ 1 ]) - || in_array($method, $this->smarty->registered_objects[ $tag ][ 1 ])) + if (!in_array($method, $this->smarty->registered_objects[ $tag ][ 3 ]) + && (empty($this->smarty->registered_objects[ $tag ][ 1 ]) + || in_array($method, $this->smarty->registered_objects[ $tag ][ 1 ])) ) { return $this->callTagCompiler('private_object_function', $args, $parameter, $tag, $method); } elseif (in_array($method, $this->smarty->registered_objects[ $tag ][ 3 ])) { @@ -1474,16 +1541,18 @@ abstract class Smarty_Internal_TemplateCompilerBase // throw exception $this->trigger_template_error( 'not allowed method "' . $method . '" in registered object "' . - $tag . '"', + $tag . '"', null, true ); } } // check if tag is registered - foreach (array(Smarty::PLUGIN_COMPILER, - Smarty::PLUGIN_FUNCTION, - Smarty::PLUGIN_BLOCK,) as $plugin_type) { + foreach (array( + Smarty::PLUGIN_COMPILER, + Smarty::PLUGIN_FUNCTION, + Smarty::PLUGIN_BLOCK, + ) as $plugin_type) { if (isset($this->smarty->registered_plugins[ $plugin_type ][ $tag ])) { // if compiler function plugin call it now if ($plugin_type === Smarty::PLUGIN_COMPILER) { @@ -1500,8 +1569,10 @@ abstract class Smarty_Internal_TemplateCompilerBase } return call_user_func_array( $this->smarty->registered_plugins[ $plugin_type ][ $tag ][ 0 ], - array($new_args, - $this) + array( + $new_args, + $this + ) ); } // compile registered function or block function @@ -1517,10 +1588,10 @@ abstract class Smarty_Internal_TemplateCompilerBase } // check plugins from plugins folder foreach ($this->plugin_search_order as $plugin_type) { - if ($plugin_type === Smarty::PLUGIN_COMPILER - && $this->smarty->loadPlugin('smarty_compiler_' . $tag) - && (!isset($this->smarty->security_policy) - || $this->smarty->security_policy->isTrustedTag($tag, $this)) + if ($plugin_type === Smarty::PLUGIN_COMPILER + && $this->smarty->loadPlugin('smarty_compiler_' . $tag) + && (!isset($this->smarty->security_policy) + || $this->smarty->security_policy->isTrustedTag($tag, $this)) ) { $plugin = 'smarty_compiler_' . $tag; if (is_callable($plugin)) { @@ -1544,7 +1615,7 @@ abstract class Smarty_Internal_TemplateCompilerBase throw new SmartyException("Plugin '{$tag}' not callable"); } else { if ($function = $this->getPlugin($tag, $plugin_type)) { - if (!isset($this->smarty->security_policy) + if (!isset($this->smarty->security_policy) || $this->smarty->security_policy->isTrustedTag($tag, $this) ) { return $this->callTagCompiler( @@ -1589,8 +1660,10 @@ abstract class Smarty_Internal_TemplateCompilerBase } return call_user_func_array( $this->default_handler_plugins[ $plugin_type ][ $tag ][ 0 ], - array($new_args, - $this) + array( + $new_args, + $this + ) ); } else { return $this->callTagCompiler( @@ -1620,14 +1693,14 @@ abstract class Smarty_Internal_TemplateCompilerBase // throw exception $this->trigger_template_error( 'not allowed closing tag method "' . $method . - '" in registered object "' . $base_tag . '"', + '" in registered object "' . $base_tag . '"', null, true ); } } // registered block tag ? - if (isset($this->smarty->registered_plugins[ Smarty::PLUGIN_BLOCK ][ $base_tag ]) + if (isset($this->smarty->registered_plugins[ Smarty::PLUGIN_BLOCK ][ $base_tag ]) || isset($this->default_handler_plugins[ Smarty::PLUGIN_BLOCK ][ $base_tag ]) ) { return $this->callTagCompiler('private_registered_block', $args, $parameter, $tag); @@ -1642,7 +1715,7 @@ abstract class Smarty_Internal_TemplateCompilerBase } // function plugin? if ($function = $this->getPlugin($tag, Smarty::PLUGIN_FUNCTION)) { - if (!isset($this->smarty->security_policy) + if (!isset($this->smarty->security_policy) || $this->smarty->security_policy->isTrustedTag($tag, $this) ) { return $this->callTagCompiler('private_function_plugin', $args, $parameter, $tag, $function); @@ -1657,8 +1730,10 @@ abstract class Smarty_Internal_TemplateCompilerBase } return call_user_func_array( $this->smarty->registered_plugins[ Smarty::PLUGIN_COMPILER ][ $tag ][ 0 ], - array($args, - $this) + array( + $args, + $this + ) ); } if ($this->smarty->loadPlugin('smarty_compiler_' . $tag)) { diff --git a/libs/sysplugins/smarty_internal_templatelexer.php b/libs/sysplugins/smarty_internal_templatelexer.php index e59729a6..c6c49ef5 100644 --- a/libs/sysplugins/smarty_internal_templatelexer.php +++ b/libs/sysplugins/smarty_internal_templatelexer.php @@ -336,8 +336,11 @@ class Smarty_Internal_Templatelexer } if (empty($yymatches)) { throw new Exception('Error: lexing failed because a rule matched' . - ' an empty string. Input "' . substr($this->data, - $this->counter, 5) . '... state TEXT'); + ' an empty string. Input "' . substr( + $this->data, + $this->counter, + 5 + ) . '... state TEXT'); } next($yymatches); // skip global match $this->token = key($yymatches); // token number @@ -446,8 +449,11 @@ class Smarty_Internal_Templatelexer } if (empty($yymatches)) { throw new Exception('Error: lexing failed because a rule matched' . - ' an empty string. Input "' . substr($this->data, - $this->counter, 5) . '... state TAG'); + ' an empty string. Input "' . substr( + $this->data, + $this->counter, + 5 + ) . '... state TAG'); } next($yymatches); // skip global match $this->token = key($yymatches); // token number @@ -584,8 +590,11 @@ class Smarty_Internal_Templatelexer } if (empty($yymatches)) { throw new Exception('Error: lexing failed because a rule matched' . - ' an empty string. Input "' . substr($this->data, - $this->counter, 5) . '... state TAGBODY'); + ' an empty string. Input "' . substr( + $this->data, + $this->counter, + 5 + ) . '... state TAGBODY'); } next($yymatches); // skip global match $this->token = key($yymatches); // token number @@ -871,8 +880,11 @@ class Smarty_Internal_Templatelexer } if (empty($yymatches)) { throw new Exception('Error: lexing failed because a rule matched' . - ' an empty string. Input "' . substr($this->data, - $this->counter, 5) . '... state LITERAL'); + ' an empty string. Input "' . substr( + $this->data, + $this->counter, + 5 + ) . '... state LITERAL'); } next($yymatches); // skip global match $this->token = key($yymatches); // token number @@ -947,8 +959,11 @@ class Smarty_Internal_Templatelexer } if (empty($yymatches)) { throw new Exception('Error: lexing failed because a rule matched' . - ' an empty string. Input "' . substr($this->data, - $this->counter, 5) . '... state DOUBLEQUOTEDSTRING'); + ' an empty string. Input "' . substr( + $this->data, + $this->counter, + 5 + ) . '... state DOUBLEQUOTEDSTRING'); } next($yymatches); // skip global match $this->token = key($yymatches); // token number @@ -1043,5 +1058,3 @@ class Smarty_Internal_Templatelexer $this->token = Smarty_Internal_Templateparser::TP_TEXT; } } - - \ No newline at end of file diff --git a/libs/sysplugins/smarty_internal_templateparser.php b/libs/sysplugins/smarty_internal_templateparser.php index 4de693e9..b008715f 100644 --- a/libs/sysplugins/smarty_internal_templateparser.php +++ b/libs/sysplugins/smarty_internal_templateparser.php @@ -4,9 +4,11 @@ class TP_yyStackEntry { public $stateno; /* The state-number */ public $major; /* The major token value. This is the code - ** number for the token at this stack level */ - public $minor; /* The user-supplied minor token value. This - ** is the value of the token */ + * number for the token at this stack level + */ + public $minor; /* The user-supplied minor token value. This + * is the value of the token + */ } // line 11 "../smarty/lexer/smarty_internal_templateparser.y" @@ -22,9 +24,9 @@ class TP_yyStackEntry class Smarty_Internal_Templateparser { // line 23 "../smarty/lexer/smarty_internal_templateparser.y" - const Err1 = 'Security error: Call to private object member not allowed'; - const Err2 = 'Security error: Call to dynamic object member not allowed'; - const Err3 = 'PHP in template not allowed. Use SmartyBC to enable it'; + const ERR1 = 'Security error: Call to private object member not allowed'; + const ERR2 = 'Security error: Call to dynamic object member not allowed'; + const ERR3 = 'PHP in template not allowed. Use SmartyBC to enable it'; const TP_VERT = 1; const TP_COLON = 2; const TP_UNIMATH = 3; @@ -1760,9 +1762,11 @@ class Smarty_Internal_Templateparser } $yytos = array_pop($this->yystack); if ($this->yyTraceFILE && $this->yyidx >= 0) { - fwrite($this->yyTraceFILE, + fwrite( + $this->yyTraceFILE, $this->yyTracePrompt . 'Popping ' . $this->yyTokenName[ $yytos->major ] . - "\n"); + "\n" + ); } $yymajor = $yytos->major; self::yy_destructor($yymajor, $yytos->minor); @@ -1772,7 +1776,7 @@ class Smarty_Internal_Templateparser public function __destruct() { - while ($this->yystack !== Array()) { + while ($this->yystack !== array()) { $this->yy_pop_parser_stack(); } if (is_resource($this->yyTraceFILE)) { @@ -1814,7 +1818,8 @@ class Smarty_Internal_Templateparser $this->yyidx -= self::$yyRuleInfo[ $yyruleno ][ 1 ]; $nextstate = $this->yy_find_reduce_action( $this->yystack[ $this->yyidx ]->stateno, - self::$yyRuleInfo[ $yyruleno ][ 0 ]); + self::$yyRuleInfo[ $yyruleno ][ 0 ] + ); if (isset(self::$yyExpectedTokens[ $nextstate ])) { $expected = array_merge($expected, self::$yyExpectedTokens[ $nextstate ]); if (isset($res4[ $nextstate ][ $token ])) { @@ -1900,7 +1905,8 @@ class Smarty_Internal_Templateparser $this->yyidx -= self::$yyRuleInfo[ $yyruleno ][ 1 ]; $nextstate = $this->yy_find_reduce_action( $this->yystack[ $this->yyidx ]->stateno, - self::$yyRuleInfo[ $yyruleno ][ 0 ]); + self::$yyRuleInfo[ $yyruleno ][ 0 ] + ); if (isset($res2[ $nextstate ][ $token ])) { if ($res2[ $nextstate ][ $token ]) { $this->yyidx = $yyidx; @@ -2030,12 +2036,19 @@ class Smarty_Internal_Templateparser $yytos->minor = $yypMinor; $this->yystack[] = $yytos; if ($this->yyTraceFILE && $this->yyidx > 0) { - fprintf($this->yyTraceFILE, "%sShift %d\n", $this->yyTracePrompt, - $yyNewState); + fprintf( + $this->yyTraceFILE, + "%sShift %d\n", + $this->yyTracePrompt, + $yyNewState + ); fprintf($this->yyTraceFILE, "%sStack:", $this->yyTracePrompt); for ($i = 1; $i <= $this->yyidx; $i++) { - fprintf($this->yyTraceFILE, " %s", - $this->yyTokenName[ $this->yystack[ $i ]->major ]); + fprintf( + $this->yyTraceFILE, + " %s", + $this->yyTokenName[ $this->yystack[ $i ]->major ] + ); } fwrite($this->yyTraceFILE, "\n"); } @@ -2178,11 +2191,11 @@ class Smarty_Internal_Templateparser if ($this->yystack[ $this->yyidx + 0 ]->minor[ $j + 1 ] == 'c') { // {$smarty.block.child} $this->_retvalue = - $this->compiler->compileTag('child', array(), array($this->yystack[ $this->yyidx + 0 ]->minor));; + $this->compiler->compileTag('child', array(), array($this->yystack[ $this->yyidx + 0 ]->minor)); } else { // {$smarty.block.parent} $this->_retvalue = - $this->compiler->compileTag('parent', array(), array($this->yystack[ $this->yyidx + 0 ]->minor));; + $this->compiler->compileTag('parent', array(), array($this->yystack[ $this->yyidx + 0 ]->minor)); } } @@ -2983,7 +2996,7 @@ class Smarty_Internal_Templateparser $this->_retvalue = '[' . $this->compiler->compileVariable('\'' . substr($this->yystack[ $this->yyidx + -1 ]->minor, 1) . '\'') . - ']';; + ']'; } // line 950 "../smarty/lexer/smarty_internal_templateparser.y" @@ -3057,7 +3070,7 @@ class Smarty_Internal_Templateparser public function yy_r140() { if ($this->security && substr($this->yystack[ $this->yyidx + -1 ]->minor, 0, 1) === '_') { - $this->compiler->trigger_template_error(self::Err1); + $this->compiler->trigger_template_error(self::ERR1); } $this->_retvalue = '->' . $this->yystack[ $this->yyidx + -1 ]->minor . $this->yystack[ $this->yyidx + 0 ]->minor; @@ -3067,7 +3080,7 @@ class Smarty_Internal_Templateparser public function yy_r141() { if ($this->security) { - $this->compiler->trigger_template_error(self::Err2); + $this->compiler->trigger_template_error(self::ERR2); } $this->_retvalue = '->{' . @@ -3080,7 +3093,7 @@ class Smarty_Internal_Templateparser public function yy_r142() { if ($this->security) { - $this->compiler->trigger_template_error(self::Err2); + $this->compiler->trigger_template_error(self::ERR2); } $this->_retvalue = '->{' . $this->yystack[ $this->yyidx + -2 ]->minor . $this->yystack[ $this->yyidx + 0 ]->minor . '}'; @@ -3090,7 +3103,7 @@ class Smarty_Internal_Templateparser public function yy_r143() { if ($this->security) { - $this->compiler->trigger_template_error(self::Err2); + $this->compiler->trigger_template_error(self::ERR2); } $this->_retvalue = '->{\'' . @@ -3119,7 +3132,7 @@ class Smarty_Internal_Templateparser public function yy_r146() { if ($this->security && substr($this->yystack[ $this->yyidx + -3 ]->minor, 0, 1) === '_') { - $this->compiler->trigger_template_error(self::Err1); + $this->compiler->trigger_template_error(self::ERR1); } $this->_retvalue = $this->yystack[ $this->yyidx + -3 ]->minor . @@ -3132,7 +3145,7 @@ class Smarty_Internal_Templateparser public function yy_r147() { if ($this->security) { - $this->compiler->trigger_template_error(self::Err2); + $this->compiler->trigger_template_error(self::ERR2); } $prefixVar = $this->compiler->getNewPrefixVariable(); $this->compiler->appendPrefixCode("yyTraceFILE && $yyruleno >= 0 && $yyruleno < count(self::$yyRuleName)) { - fprintf($this->yyTraceFILE, "%sReduce (%d) [%s].\n", - $this->yyTracePrompt, $yyruleno, - self::$yyRuleName[ $yyruleno ]); + fprintf( + $this->yyTraceFILE, + "%sReduce (%d) [%s].\n", + $this->yyTracePrompt, + $yyruleno, + self::$yyRuleName[ $yyruleno ] + ); } $this->_retvalue = $yy_lefthand_side = null; if (isset(self::$yyReduceMap[ $yyruleno ])) { @@ -3436,8 +3453,12 @@ class Smarty_Internal_Templateparser } $yyendofinput = ($yymajor == 0); if ($this->yyTraceFILE) { - fprintf($this->yyTraceFILE, "%sInput %s\n", - $this->yyTracePrompt, $this->yyTokenName[ $yymajor ]); + fprintf( + $this->yyTraceFILE, + "%sInput %s\n", + $this->yyTracePrompt, + $this->yyTokenName[ $yymajor ] + ); } do { $yyact = $this->yy_find_shift_action($yymajor); @@ -3458,8 +3479,11 @@ class Smarty_Internal_Templateparser $this->yy_reduce($yyact - self::YYNSTATE); } elseif ($yyact === self::YY_ERROR_ACTION) { if ($this->yyTraceFILE) { - fprintf($this->yyTraceFILE, "%sSyntax Error!\n", - $this->yyTracePrompt); + fprintf( + $this->yyTraceFILE, + "%sSyntax Error!\n", + $this->yyTracePrompt + ); } if (self::YYERRORSYMBOL) { if ($this->yyerrcnt < 0) { @@ -3468,8 +3492,12 @@ class Smarty_Internal_Templateparser $yymx = $this->yystack[ $this->yyidx ]->major; if ($yymx === self::YYERRORSYMBOL || $yyerrorhit) { if ($this->yyTraceFILE) { - fprintf($this->yyTraceFILE, "%sDiscard input token %s\n", - $this->yyTracePrompt, $this->yyTokenName[ $yymajor ]); + fprintf( + $this->yyTraceFILE, + "%sDiscard input token %s\n", + $this->yyTracePrompt, + $this->yyTokenName[ $yymajor ] + ); } $this->yy_destructor($yymajor, $yytokenvalue); $yymajor = self::YYNOCODE; @@ -3509,4 +3537,3 @@ class Smarty_Internal_Templateparser } while ($yymajor !== self::YYNOCODE && $this->yyidx >= 0); } } - diff --git a/libs/sysplugins/smarty_internal_testinstall.php b/libs/sysplugins/smarty_internal_testinstall.php index 9a006d8a..504a4582 100644 --- a/libs/sysplugins/smarty_internal_testinstall.php +++ b/libs/sysplugins/smarty_internal_testinstall.php @@ -332,159 +332,161 @@ class Smarty_Internal_TestInstall // test if sysplugins are available $source = SMARTY_SYSPLUGINS_DIR; if (is_dir($source)) { - $expectedSysplugins = array('smartycompilerexception.php' => true, - 'smartyexception.php' => true, - 'smarty_cacheresource.php' => true, - 'smarty_cacheresource_custom.php' => true, - 'smarty_cacheresource_keyvaluestore.php' => true, - 'smarty_data.php' => true, - 'smarty_internal_block.php' => true, - 'smarty_internal_cacheresource_file.php' => true, - 'smarty_internal_compilebase.php' => true, - 'smarty_internal_compile_append.php' => true, - 'smarty_internal_compile_assign.php' => true, - 'smarty_internal_compile_block.php' => true, - 'smarty_internal_compile_block_child.php' => true, - 'smarty_internal_compile_block_parent.php' => true, - 'smarty_internal_compile_child.php' => true, - 'smarty_internal_compile_parent.php' => true, - 'smarty_internal_compile_break.php' => true, - 'smarty_internal_compile_call.php' => true, - 'smarty_internal_compile_capture.php' => true, - 'smarty_internal_compile_config_load.php' => true, - 'smarty_internal_compile_continue.php' => true, - 'smarty_internal_compile_debug.php' => true, - 'smarty_internal_compile_eval.php' => true, - 'smarty_internal_compile_extends.php' => true, - 'smarty_internal_compile_for.php' => true, - 'smarty_internal_compile_foreach.php' => true, - 'smarty_internal_compile_function.php' => true, - 'smarty_internal_compile_if.php' => true, - 'smarty_internal_compile_include.php' => true, - 'smarty_internal_compile_include_php.php' => true, - 'smarty_internal_compile_insert.php' => true, - 'smarty_internal_compile_ldelim.php' => true, - 'smarty_internal_compile_make_nocache.php' => true, - 'smarty_internal_compile_nocache.php' => true, - 'smarty_internal_compile_private_block_plugin.php' => true, - 'smarty_internal_compile_private_foreachsection.php' => true, - 'smarty_internal_compile_private_function_plugin.php' => true, - 'smarty_internal_compile_private_modifier.php' => true, - 'smarty_internal_compile_private_object_block_function.php' => true, - 'smarty_internal_compile_private_object_function.php' => true, - 'smarty_internal_compile_private_php.php' => true, - 'smarty_internal_compile_private_print_expression.php' => true, - 'smarty_internal_compile_private_registered_block.php' => true, - 'smarty_internal_compile_private_registered_function.php' => true, - 'smarty_internal_compile_private_special_variable.php' => true, - 'smarty_internal_compile_rdelim.php' => true, - 'smarty_internal_compile_section.php' => true, - 'smarty_internal_compile_setfilter.php' => true, - 'smarty_internal_compile_shared_inheritance.php' => true, - 'smarty_internal_compile_while.php' => true, - 'smarty_internal_configfilelexer.php' => true, - 'smarty_internal_configfileparser.php' => true, - 'smarty_internal_config_file_compiler.php' => true, - 'smarty_internal_data.php' => true, - 'smarty_internal_debug.php' => true, - 'smarty_internal_errorhandler.php' => true, - 'smarty_internal_extension_handler.php' => true, - 'smarty_internal_method_addautoloadfilters.php' => true, - 'smarty_internal_method_adddefaultmodifiers.php' => true, - 'smarty_internal_method_append.php' => true, - 'smarty_internal_method_appendbyref.php' => true, - 'smarty_internal_method_assignbyref.php' => true, - 'smarty_internal_method_assignglobal.php' => true, - 'smarty_internal_method_clearallassign.php' => true, - 'smarty_internal_method_clearallcache.php' => true, - 'smarty_internal_method_clearassign.php' => true, - 'smarty_internal_method_clearcache.php' => true, - 'smarty_internal_method_clearcompiledtemplate.php' => true, - 'smarty_internal_method_clearconfig.php' => true, - 'smarty_internal_method_compileallconfig.php' => true, - 'smarty_internal_method_compilealltemplates.php' => true, - 'smarty_internal_method_configload.php' => true, - 'smarty_internal_method_createdata.php' => true, - 'smarty_internal_method_getautoloadfilters.php' => true, - 'smarty_internal_method_getconfigvariable.php' => true, - 'smarty_internal_method_getconfigvars.php' => true, - 'smarty_internal_method_getdebugtemplate.php' => true, - 'smarty_internal_method_getdefaultmodifiers.php' => true, - 'smarty_internal_method_getglobal.php' => true, - 'smarty_internal_method_getregisteredobject.php' => true, - 'smarty_internal_method_getstreamvariable.php' => true, - 'smarty_internal_method_gettags.php' => true, - 'smarty_internal_method_gettemplatevars.php' => true, - 'smarty_internal_method_literals.php' => true, - 'smarty_internal_method_loadfilter.php' => true, - 'smarty_internal_method_loadplugin.php' => true, - 'smarty_internal_method_mustcompile.php' => true, - 'smarty_internal_method_registercacheresource.php' => true, - 'smarty_internal_method_registerclass.php' => true, - 'smarty_internal_method_registerdefaultconfighandler.php' => true, - 'smarty_internal_method_registerdefaultpluginhandler.php' => true, - 'smarty_internal_method_registerdefaulttemplatehandler.php' => true, - 'smarty_internal_method_registerfilter.php' => true, - 'smarty_internal_method_registerobject.php' => true, - 'smarty_internal_method_registerplugin.php' => true, - 'smarty_internal_method_registerresource.php' => true, - 'smarty_internal_method_setautoloadfilters.php' => true, - 'smarty_internal_method_setdebugtemplate.php' => true, - 'smarty_internal_method_setdefaultmodifiers.php' => true, - 'smarty_internal_method_unloadfilter.php' => true, - 'smarty_internal_method_unregistercacheresource.php' => true, - 'smarty_internal_method_unregisterfilter.php' => true, - 'smarty_internal_method_unregisterobject.php' => true, - 'smarty_internal_method_unregisterplugin.php' => true, - 'smarty_internal_method_unregisterresource.php' => true, - 'smarty_internal_nocache_insert.php' => true, - 'smarty_internal_parsetree.php' => true, - 'smarty_internal_parsetree_code.php' => true, - 'smarty_internal_parsetree_dq.php' => true, - 'smarty_internal_parsetree_dqcontent.php' => true, - 'smarty_internal_parsetree_tag.php' => true, - 'smarty_internal_parsetree_template.php' => true, - 'smarty_internal_parsetree_text.php' => true, - 'smarty_internal_resource_eval.php' => true, - 'smarty_internal_resource_extends.php' => true, - 'smarty_internal_resource_file.php' => true, - 'smarty_internal_resource_php.php' => true, - 'smarty_internal_resource_registered.php' => true, - 'smarty_internal_resource_stream.php' => true, - 'smarty_internal_resource_string.php' => true, - 'smarty_internal_runtime_cachemodify.php' => true, - 'smarty_internal_runtime_cacheresourcefile.php' => true, - 'smarty_internal_runtime_capture.php' => true, - 'smarty_internal_runtime_codeframe.php' => true, - 'smarty_internal_runtime_filterhandler.php' => true, - 'smarty_internal_runtime_foreach.php' => true, - 'smarty_internal_runtime_getincludepath.php' => true, - 'smarty_internal_runtime_inheritance.php' => true, - 'smarty_internal_runtime_make_nocache.php' => true, - 'smarty_internal_runtime_tplfunction.php' => true, - 'smarty_internal_runtime_updatecache.php' => true, - 'smarty_internal_runtime_updatescope.php' => true, - 'smarty_internal_runtime_writefile.php' => true, - 'smarty_internal_smartytemplatecompiler.php' => true, - 'smarty_internal_template.php' => true, - 'smarty_internal_templatebase.php' => true, - 'smarty_internal_templatecompilerbase.php' => true, - 'smarty_internal_templatelexer.php' => true, - 'smarty_internal_templateparser.php' => true, - 'smarty_internal_testinstall.php' => true, - 'smarty_internal_undefined.php' => true, - 'smarty_resource.php' => true, - 'smarty_resource_custom.php' => true, - 'smarty_resource_recompiled.php' => true, - 'smarty_resource_uncompiled.php' => true, - 'smarty_security.php' => true, - 'smarty_template_cached.php' => true, - 'smarty_template_compiled.php' => true, - 'smarty_template_config.php' => true, - 'smarty_template_resource_base.php' => true, - 'smarty_template_source.php' => true, - 'smarty_undefined_variable.php' => true, - 'smarty_variable.php' => true,); + $expectedSysplugins = array( + 'smartycompilerexception.php' => true, + 'smartyexception.php' => true, + 'smarty_cacheresource.php' => true, + 'smarty_cacheresource_custom.php' => true, + 'smarty_cacheresource_keyvaluestore.php' => true, + 'smarty_data.php' => true, + 'smarty_internal_block.php' => true, + 'smarty_internal_cacheresource_file.php' => true, + 'smarty_internal_compilebase.php' => true, + 'smarty_internal_compile_append.php' => true, + 'smarty_internal_compile_assign.php' => true, + 'smarty_internal_compile_block.php' => true, + 'smarty_internal_compile_block_child.php' => true, + 'smarty_internal_compile_block_parent.php' => true, + 'smarty_internal_compile_child.php' => true, + 'smarty_internal_compile_parent.php' => true, + 'smarty_internal_compile_break.php' => true, + 'smarty_internal_compile_call.php' => true, + 'smarty_internal_compile_capture.php' => true, + 'smarty_internal_compile_config_load.php' => true, + 'smarty_internal_compile_continue.php' => true, + 'smarty_internal_compile_debug.php' => true, + 'smarty_internal_compile_eval.php' => true, + 'smarty_internal_compile_extends.php' => true, + 'smarty_internal_compile_for.php' => true, + 'smarty_internal_compile_foreach.php' => true, + 'smarty_internal_compile_function.php' => true, + 'smarty_internal_compile_if.php' => true, + 'smarty_internal_compile_include.php' => true, + 'smarty_internal_compile_include_php.php' => true, + 'smarty_internal_compile_insert.php' => true, + 'smarty_internal_compile_ldelim.php' => true, + 'smarty_internal_compile_make_nocache.php' => true, + 'smarty_internal_compile_nocache.php' => true, + 'smarty_internal_compile_private_block_plugin.php' => true, + 'smarty_internal_compile_private_foreachsection.php' => true, + 'smarty_internal_compile_private_function_plugin.php' => true, + 'smarty_internal_compile_private_modifier.php' => true, + 'smarty_internal_compile_private_object_block_function.php' => true, + 'smarty_internal_compile_private_object_function.php' => true, + 'smarty_internal_compile_private_php.php' => true, + 'smarty_internal_compile_private_print_expression.php' => true, + 'smarty_internal_compile_private_registered_block.php' => true, + 'smarty_internal_compile_private_registered_function.php' => true, + 'smarty_internal_compile_private_special_variable.php' => true, + 'smarty_internal_compile_rdelim.php' => true, + 'smarty_internal_compile_section.php' => true, + 'smarty_internal_compile_setfilter.php' => true, + 'smarty_internal_compile_shared_inheritance.php' => true, + 'smarty_internal_compile_while.php' => true, + 'smarty_internal_configfilelexer.php' => true, + 'smarty_internal_configfileparser.php' => true, + 'smarty_internal_config_file_compiler.php' => true, + 'smarty_internal_data.php' => true, + 'smarty_internal_debug.php' => true, + 'smarty_internal_errorhandler.php' => true, + 'smarty_internal_extension_handler.php' => true, + 'smarty_internal_method_addautoloadfilters.php' => true, + 'smarty_internal_method_adddefaultmodifiers.php' => true, + 'smarty_internal_method_append.php' => true, + 'smarty_internal_method_appendbyref.php' => true, + 'smarty_internal_method_assignbyref.php' => true, + 'smarty_internal_method_assignglobal.php' => true, + 'smarty_internal_method_clearallassign.php' => true, + 'smarty_internal_method_clearallcache.php' => true, + 'smarty_internal_method_clearassign.php' => true, + 'smarty_internal_method_clearcache.php' => true, + 'smarty_internal_method_clearcompiledtemplate.php' => true, + 'smarty_internal_method_clearconfig.php' => true, + 'smarty_internal_method_compileallconfig.php' => true, + 'smarty_internal_method_compilealltemplates.php' => true, + 'smarty_internal_method_configload.php' => true, + 'smarty_internal_method_createdata.php' => true, + 'smarty_internal_method_getautoloadfilters.php' => true, + 'smarty_internal_method_getconfigvariable.php' => true, + 'smarty_internal_method_getconfigvars.php' => true, + 'smarty_internal_method_getdebugtemplate.php' => true, + 'smarty_internal_method_getdefaultmodifiers.php' => true, + 'smarty_internal_method_getglobal.php' => true, + 'smarty_internal_method_getregisteredobject.php' => true, + 'smarty_internal_method_getstreamvariable.php' => true, + 'smarty_internal_method_gettags.php' => true, + 'smarty_internal_method_gettemplatevars.php' => true, + 'smarty_internal_method_literals.php' => true, + 'smarty_internal_method_loadfilter.php' => true, + 'smarty_internal_method_loadplugin.php' => true, + 'smarty_internal_method_mustcompile.php' => true, + 'smarty_internal_method_registercacheresource.php' => true, + 'smarty_internal_method_registerclass.php' => true, + 'smarty_internal_method_registerdefaultconfighandler.php' => true, + 'smarty_internal_method_registerdefaultpluginhandler.php' => true, + 'smarty_internal_method_registerdefaulttemplatehandler.php' => true, + 'smarty_internal_method_registerfilter.php' => true, + 'smarty_internal_method_registerobject.php' => true, + 'smarty_internal_method_registerplugin.php' => true, + 'smarty_internal_method_registerresource.php' => true, + 'smarty_internal_method_setautoloadfilters.php' => true, + 'smarty_internal_method_setdebugtemplate.php' => true, + 'smarty_internal_method_setdefaultmodifiers.php' => true, + 'smarty_internal_method_unloadfilter.php' => true, + 'smarty_internal_method_unregistercacheresource.php' => true, + 'smarty_internal_method_unregisterfilter.php' => true, + 'smarty_internal_method_unregisterobject.php' => true, + 'smarty_internal_method_unregisterplugin.php' => true, + 'smarty_internal_method_unregisterresource.php' => true, + 'smarty_internal_nocache_insert.php' => true, + 'smarty_internal_parsetree.php' => true, + 'smarty_internal_parsetree_code.php' => true, + 'smarty_internal_parsetree_dq.php' => true, + 'smarty_internal_parsetree_dqcontent.php' => true, + 'smarty_internal_parsetree_tag.php' => true, + 'smarty_internal_parsetree_template.php' => true, + 'smarty_internal_parsetree_text.php' => true, + 'smarty_internal_resource_eval.php' => true, + 'smarty_internal_resource_extends.php' => true, + 'smarty_internal_resource_file.php' => true, + 'smarty_internal_resource_php.php' => true, + 'smarty_internal_resource_registered.php' => true, + 'smarty_internal_resource_stream.php' => true, + 'smarty_internal_resource_string.php' => true, + 'smarty_internal_runtime_cachemodify.php' => true, + 'smarty_internal_runtime_cacheresourcefile.php' => true, + 'smarty_internal_runtime_capture.php' => true, + 'smarty_internal_runtime_codeframe.php' => true, + 'smarty_internal_runtime_filterhandler.php' => true, + 'smarty_internal_runtime_foreach.php' => true, + 'smarty_internal_runtime_getincludepath.php' => true, + 'smarty_internal_runtime_inheritance.php' => true, + 'smarty_internal_runtime_make_nocache.php' => true, + 'smarty_internal_runtime_tplfunction.php' => true, + 'smarty_internal_runtime_updatecache.php' => true, + 'smarty_internal_runtime_updatescope.php' => true, + 'smarty_internal_runtime_writefile.php' => true, + 'smarty_internal_smartytemplatecompiler.php' => true, + 'smarty_internal_template.php' => true, + 'smarty_internal_templatebase.php' => true, + 'smarty_internal_templatecompilerbase.php' => true, + 'smarty_internal_templatelexer.php' => true, + 'smarty_internal_templateparser.php' => true, + 'smarty_internal_testinstall.php' => true, + 'smarty_internal_undefined.php' => true, + 'smarty_resource.php' => true, + 'smarty_resource_custom.php' => true, + 'smarty_resource_recompiled.php' => true, + 'smarty_resource_uncompiled.php' => true, + 'smarty_security.php' => true, + 'smarty_template_cached.php' => true, + 'smarty_template_compiled.php' => true, + 'smarty_template_config.php' => true, + 'smarty_template_resource_base.php' => true, + 'smarty_template_source.php' => true, + 'smarty_undefined_variable.php' => true, + 'smarty_variable.php' => true, + ); $iterator = new DirectoryIterator($source); foreach ($iterator as $file) { if (!$file->isDot()) { diff --git a/libs/sysplugins/smarty_internal_undefined.php b/libs/sysplugins/smarty_internal_undefined.php index b5d35075..7df0acc2 100644 --- a/libs/sysplugins/smarty_internal_undefined.php +++ b/libs/sysplugins/smarty_internal_undefined.php @@ -11,7 +11,6 @@ */ class Smarty_Internal_Undefined { - /** * Name of undefined extension class * diff --git a/libs/sysplugins/smarty_resource.php b/libs/sysplugins/smarty_resource.php index fa1c1e42..aae7e42f 100644 --- a/libs/sysplugins/smarty_resource.php +++ b/libs/sysplugins/smarty_resource.php @@ -25,24 +25,29 @@ abstract class Smarty_Resource * * @var array */ - public static $sysplugins = array('file' => 'smarty_internal_resource_file.php', - 'string' => 'smarty_internal_resource_string.php', - 'extends' => 'smarty_internal_resource_extends.php', - 'stream' => 'smarty_internal_resource_stream.php', - 'eval' => 'smarty_internal_resource_eval.php', - 'php' => 'smarty_internal_resource_php.php'); + public static $sysplugins = array( + 'file' => 'smarty_internal_resource_file.php', + 'string' => 'smarty_internal_resource_string.php', + 'extends' => 'smarty_internal_resource_extends.php', + 'stream' => 'smarty_internal_resource_stream.php', + 'eval' => 'smarty_internal_resource_eval.php', + 'php' => 'smarty_internal_resource_php.php' + ); + /** * Source is bypassing compiler * * @var boolean */ public $uncompiled = false; + /** * Source must be recompiled on every occasion * * @var boolean */ public $recompiled = false; + /** * Flag if resource does implement populateCompiledFilepath() method * @@ -84,8 +89,10 @@ abstract class Smarty_Resource } else { $smarty->registerResource( $type, - array("smarty_resource_{$type}_source", "smarty_resource_{$type}_timestamp", - "smarty_resource_{$type}_secure", "smarty_resource_{$type}_trusted") + array( + "smarty_resource_{$type}_source", "smarty_resource_{$type}_timestamp", + "smarty_resource_{$type}_secure", "smarty_resource_{$type}_trusted" + ) ); // give it another try, now that the resource is registered properly return self::load($smarty, $type); @@ -133,7 +140,8 @@ abstract class Smarty_Resource * modify template_resource according to resource handlers specifications * * @param \Smarty_Internal_Template|\Smarty $obj Smarty instance - * @param string $template_resource template_resource to extract resource handler and name of + * @param string $template_resource template_resource to extract resource handler and + * name of * * @return string unique resource name * @throws \SmartyException @@ -146,7 +154,7 @@ abstract class Smarty_Resource $resource = Smarty_Resource::load($smarty, $type); // go relative to a given template? $_file_is_dotted = $name[ 0 ] === '.' && ($name[ 1 ] === '.' || $name[ 1 ] === '/'); - if ($obj->_isTplObj() && $_file_is_dotted + if ($obj->_isTplObj() && $_file_is_dotted && ($obj->source->type === 'file' || $obj->parent->source->type === 'extends') ) { $name = $smarty->_realpath(dirname($obj->parent->source->filepath) . DIRECTORY_SEPARATOR . $name); @@ -166,7 +174,8 @@ abstract class Smarty_Resource * @return \Smarty_Template_Source Source Object * @throws \SmartyException */ - public static function source(Smarty_Internal_Template $_template = null, + public static function source( + Smarty_Internal_Template $_template = null, Smarty $smarty = null, $template_resource = null ) { @@ -231,7 +240,6 @@ abstract class Smarty_Resource * * @return bool */ - /** * Determine basename for compiled filename * @@ -252,4 +260,3 @@ abstract class Smarty_Resource return true; } } - diff --git a/libs/sysplugins/smarty_resource_custom.php b/libs/sysplugins/smarty_resource_custom.php index 37580a1b..8d66be3a 100644 --- a/libs/sysplugins/smarty_resource_custom.php +++ b/libs/sysplugins/smarty_resource_custom.php @@ -49,7 +49,6 @@ abstract class Smarty_Resource_Custom extends Smarty_Resource { $source->filepath = $source->type . ':' . substr(preg_replace('/[^A-Za-z0-9.]/', '', $source->name), 0, 25); $source->uid = sha1($source->type . ':' . $source->name); - $mtime = $this->fetchTimestamp($source->name); if ($mtime !== null) { $source->timestamp = $mtime; @@ -77,7 +76,6 @@ abstract class Smarty_Resource_Custom extends Smarty_Resource if (isset($content)) { return $content; } - throw new SmartyException("Unable to read template {$source->type} '{$source->name}'"); } diff --git a/libs/sysplugins/smarty_resource_recompiled.php b/libs/sysplugins/smarty_resource_recompiled.php index 2d909e5c..760c4dd3 100644 --- a/libs/sysplugins/smarty_resource_recompiled.php +++ b/libs/sysplugins/smarty_resource_recompiled.php @@ -50,8 +50,7 @@ abstract class Smarty_Resource_Recompiled extends Smarty_Resource // call compiler try { eval('?>' . $_smarty_tpl->compiler->compileTemplate($_smarty_tpl)); - } - catch (Exception $e) { + } catch (Exception $e) { unset($_smarty_tpl->compiler); while (ob_get_level() > $level) { ob_end_clean(); diff --git a/libs/sysplugins/smarty_security.php b/libs/sysplugins/smarty_security.php index 02eabae2..441a7e28 100644 --- a/libs/sysplugins/smarty_security.php +++ b/libs/sysplugins/smarty_security.php @@ -6,12 +6,12 @@ * @subpackage Security * @author Uwe Tews */ - -/* +/** * FIXME: Smarty_Security API * - getter and setter instead of public properties would allow cultivating an internal cache properly - * - current implementation of isTrustedResourceDir() assumes that Smarty::$template_dir and Smarty::$config_dir are immutable - * the cache is killed every time either of the variables change. That means that two distinct Smarty objects with differing + * - current implementation of isTrustedResourceDir() assumes that Smarty::$template_dir and Smarty::$config_dir + * are immutable the cache is killed every time either of the variables change. That means that two distinct + * Smarty objects with differing * $template_dir or $config_dir should NOT share the same Smarty_Security instance, * as this would lead to (severe) performance penalty! how should this be handled? */ @@ -270,14 +270,12 @@ class Smarty_Security */ public function isTrustedPhpFunction($function_name, $compiler) { - if (isset($this->php_functions) + if (isset($this->php_functions) && (empty($this->php_functions) || in_array($function_name, $this->php_functions)) ) { return true; } - $compiler->trigger_template_error("PHP function '{$function_name}' not allowed by security setting"); - return false; // should not, but who knows what happens to the compiler in the future? } @@ -291,14 +289,12 @@ class Smarty_Security */ public function isTrustedStaticClass($class_name, $compiler) { - if (isset($this->static_classes) + if (isset($this->static_classes) && (empty($this->static_classes) || in_array($class_name, $this->static_classes)) ) { return true; } - $compiler->trigger_template_error("access to static class '{$class_name}' not allowed by security setting"); - return false; // should not, but who knows what happens to the compiler in the future? } @@ -330,7 +326,7 @@ class Smarty_Security // fall back return $this->isTrustedStaticClass($class_name, $compiler); } - if (isset($allowed[ $class_name ]) + if (isset($allowed[ $class_name ]) && (empty($allowed[ $class_name ]) || in_array($name, $allowed[ $class_name ])) ) { return true; @@ -350,14 +346,12 @@ class Smarty_Security */ public function isTrustedPhpModifier($modifier_name, $compiler) { - if (isset($this->php_modifiers) + if (isset($this->php_modifiers) && (empty($this->php_modifiers) || in_array($modifier_name, $this->php_modifiers)) ) { return true; } - $compiler->trigger_template_error("modifier '{$modifier_name}' not allowed by security setting"); - return false; // should not, but who knows what happens to the compiler in the future? } @@ -374,10 +368,12 @@ class Smarty_Security // check for internal always required tags if (in_array( $tag_name, - array('assign', 'call', 'private_filter', 'private_block_plugin', 'private_function_plugin', - 'private_object_block_function', 'private_object_function', 'private_registered_function', - 'private_registered_block', 'private_special_variable', 'private_print_expression', - 'private_modifier') + array( + 'assign', 'call', 'private_filter', 'private_block_plugin', 'private_function_plugin', + 'private_object_block_function', 'private_object_function', 'private_registered_function', + 'private_registered_block', 'private_special_variable', 'private_print_expression', + 'private_modifier' + ) ) ) { return true; @@ -394,7 +390,6 @@ class Smarty_Security } else { $compiler->trigger_template_error("tag '{$tag_name}' not allowed by security setting", null, true); } - return false; // should not, but who knows what happens to the compiler in the future? } @@ -413,10 +408,10 @@ class Smarty_Security } else { $compiler->trigger_template_error( "special variable '\$smarty.{$var_name}' not allowed by security setting", - null, true + null, + true ); } - return false; // should not, but who knows what happens to the compiler in the future? } @@ -440,21 +435,22 @@ class Smarty_Security return true; } else { $compiler->trigger_template_error( - "modifier '{$modifier_name}' disabled by security setting", null, + "modifier '{$modifier_name}' disabled by security setting", + null, true ); } - } elseif (in_array($modifier_name, $this->allowed_modifiers) - && !in_array($modifier_name, $this->disabled_modifiers) + } elseif (in_array($modifier_name, $this->allowed_modifiers) + && !in_array($modifier_name, $this->disabled_modifiers) ) { return true; } else { $compiler->trigger_template_error( - "modifier '{$modifier_name}' not allowed by security setting", null, + "modifier '{$modifier_name}' not allowed by security setting", + null, true ); } - return false; // should not, but who knows what happens to the compiler in the future? } @@ -498,7 +494,6 @@ class Smarty_Security if (isset($this->streams) && (empty($this->streams) || in_array($stream_name, $this->streams))) { return true; } - throw new SmartyException("stream '{$stream_name}' not allowed by security setting"); } @@ -514,35 +509,33 @@ class Smarty_Security public function isTrustedResourceDir($filepath, $isConfig = null) { if ($this->_include_path_status !== $this->smarty->use_include_path) { - $_dir = $this->smarty->use_include_path ? $this->smarty->ext->_getIncludePath->getIncludePathDirs($this->smarty) : array(); + $_dir = + $this->smarty->use_include_path ? $this->smarty->ext->_getIncludePath->getIncludePathDirs($this->smarty) : array(); if ($this->_include_dir !== $_dir) { $this->_updateResourceDir($this->_include_dir, $_dir); $this->_include_dir = $_dir; } $this->_include_path_status = $this->smarty->use_include_path; } - - $_dir = $this->smarty->getTemplateDir(); + $_dir = $this->smarty->getTemplateDir(); if ($this->_template_dir !== $_dir) { $this->_updateResourceDir($this->_template_dir, $_dir); $this->_template_dir = $_dir; } - - $_dir = $this->smarty->getConfigDir(); + $_dir = $this->smarty->getConfigDir(); if ($this->_config_dir !== $_dir) { $this->_updateResourceDir($this->_config_dir, $_dir); $this->_config_dir = $_dir; } - if ($this->_secure_dir !== $this->secure_dir) { $this->secure_dir = (array)$this->secure_dir; - foreach($this->secure_dir as $k => $d) { - $this->secure_dir[$k] = $this->smarty->_realpath($d. DIRECTORY_SEPARATOR, true); + foreach ($this->secure_dir as $k => $d) { + $this->secure_dir[ $k ] = $this->smarty->_realpath($d . DIRECTORY_SEPARATOR, true); } $this->_updateResourceDir($this->_secure_dir, $this->secure_dir); $this->_secure_dir = $this->secure_dir; } - $addPath = $this->_checkDir($filepath, $this->_resource_dir); + $addPath = $this->_checkDir($filepath, $this->_resource_dir); if ($addPath !== false) { $this->_resource_dir = array_merge($this->_resource_dir, $addPath); } @@ -572,7 +565,6 @@ class Smarty_Security } } } - throw new SmartyException("URI '{$uri}' not allowed by security setting"); } @@ -589,22 +581,20 @@ class Smarty_Security if (empty($this->trusted_dir)) { throw new SmartyException("directory '{$filepath}' not allowed by security setting (no trusted_dir specified)"); } - // check if index is outdated if (!$this->_trusted_dir || $this->_trusted_dir !== $this->trusted_dir) { $this->_php_resource_dir = array(); - $this->_trusted_dir = $this->trusted_dir; - foreach ((array) $this->trusted_dir as $directory) { + foreach ((array)$this->trusted_dir as $directory) { $directory = $this->smarty->_realpath($directory . '/', true); $this->_php_resource_dir[ $directory ] = true; } } - $addPath = $this->_checkDir($filepath, $this->_php_resource_dir); + $addPath = $this->_checkDir($filepath, $this->_php_resource_dir); if ($addPath !== false) { $this->_php_resource_dir = array_merge($this->_php_resource_dir, $addPath); } - return true; + return true; } /** @@ -613,7 +603,7 @@ class Smarty_Security * @param array $oldDir * @param array $newDir */ - private function _updateResourceDir($oldDir, $newDir) + private function _updateResourceDir($oldDir, $newDir) { foreach ($oldDir as $directory) { // $directory = $this->smarty->_realpath($directory, true); @@ -629,11 +619,12 @@ class Smarty_Security $this->_resource_dir[ $directory ] = true; } } + /** * Check if file is inside a valid directory * * @param string $filepath - * @param array $dirs valid directories + * @param array $dirs valid directories * * @return array|bool * @throws \SmartyException @@ -692,6 +683,7 @@ class Smarty_Security } return $smarty; } + /** * Start template processing * @@ -701,7 +693,7 @@ class Smarty_Security */ public function startTemplate($template) { - if ($this->max_template_nesting > 0 && $this->_current_template_nesting ++ >= $this->max_template_nesting) { + if ($this->max_template_nesting > 0 && $this->_current_template_nesting++ >= $this->max_template_nesting) { throw new SmartyException("maximum template nesting level of '{$this->max_template_nesting}' exceeded when calling '{$template->template_resource}'"); } } @@ -712,7 +704,7 @@ class Smarty_Security public function endTemplate() { if ($this->max_template_nesting > 0) { - $this->_current_template_nesting --; + $this->_current_template_nesting--; } } diff --git a/libs/sysplugins/smarty_template_cached.php b/libs/sysplugins/smarty_template_cached.php index 981d527c..508d27f3 100644 --- a/libs/sysplugins/smarty_template_cached.php +++ b/libs/sysplugins/smarty_template_cached.php @@ -102,7 +102,7 @@ class Smarty_Template_Cached extends Smarty_Template_Resource_Base * * @return Smarty_Template_Cached */ - static function load(Smarty_Internal_Template $_template) + public static function load(Smarty_Internal_Template $_template) { $_template->cached = new Smarty_Template_Cached($_template); $_template->cached->handler->populate($_template->cached, $_template); @@ -163,13 +163,13 @@ class Smarty_Template_Cached extends Smarty_Template_Resource_Base } else { $this->valid = true; } - if ($this->valid && $_template->caching === Smarty::CACHING_LIFETIME_CURRENT + if ($this->valid && $_template->caching === Smarty::CACHING_LIFETIME_CURRENT && $_template->cache_lifetime >= 0 && time() > ($this->timestamp + $_template->cache_lifetime) ) { // lifetime expired $this->valid = false; } - if ($this->valid && $_template->compile_check === Smarty::COMPILECHECK_ON + if ($this->valid && $_template->compile_check === Smarty::COMPILECHECK_ON && $_template->source->getTimeStamp() > $this->timestamp ) { $this->valid = false; @@ -204,8 +204,8 @@ class Smarty_Template_Cached extends Smarty_Template_Resource_Base } else { return $this->valid; } - if ($this->valid && $_template->caching === Smarty::CACHING_LIFETIME_SAVED - && $_template->cached->cache_lifetime >= 0 + if ($this->valid && $_template->caching === Smarty::CACHING_LIFETIME_SAVED + && $_template->cached->cache_lifetime >= 0 && (time() > ($_template->cached->timestamp + $_template->cached->cache_lifetime)) ) { $this->valid = false; diff --git a/libs/sysplugins/smarty_template_compiled.php b/libs/sysplugins/smarty_template_compiled.php index 567ca094..37d8f0a9 100644 --- a/libs/sysplugins/smarty_template_compiled.php +++ b/libs/sysplugins/smarty_template_compiled.php @@ -25,7 +25,7 @@ class Smarty_Template_Compiled extends Smarty_Template_Resource_Base * * @return Smarty_Template_Compiled compiled object */ - static function load($_template) + public static function load($_template) { $compiled = new Smarty_Template_Compiled(); if ($_template->source->handler->hasCompiledHandler) { @@ -135,7 +135,7 @@ class Smarty_Template_Compiled extends Smarty_Template_Resource_Base if ($source->handler->recompiled) { $source->handler->process($_smarty_tpl); } elseif (!$source->handler->uncompiled) { - if (!$this->exists || $smarty->force_compile + if (!$this->exists || $smarty->force_compile || ($_smarty_tpl->compile_check && $source->getTimeStamp() > $this->getTimeStamp()) ) { $this->compileTemplateSource($_smarty_tpl); @@ -182,8 +182,7 @@ class Smarty_Template_Compiled extends Smarty_Template_Resource_Base // call compiler $_template->loadCompiler(); $this->write($_template, $_template->compiler->compileTemplate($_template)); - } - catch (Exception $e) { + } catch (Exception $e) { // restore old timestamp in case of error if ($saved_timestamp && is_file($this->filepath)) { touch($this->filepath, $saved_timestamp); diff --git a/libs/sysplugins/smarty_template_config.php b/libs/sysplugins/smarty_template_config.php index c61d0d95..850ae32e 100644 --- a/libs/sysplugins/smarty_template_config.php +++ b/libs/sysplugins/smarty_template_config.php @@ -70,7 +70,9 @@ class Smarty_Template_Config extends Smarty_Template_Source * @return Smarty_Template_Config Source Object * @throws SmartyException */ - public static function load(Smarty_Internal_Template $_template = null, Smarty $smarty = null, + public static function load( + Smarty_Internal_Template $_template = null, + Smarty $smarty = null, $template_resource = null ) { static $_incompatible_resources = array('extends' => true, 'php' => true); @@ -81,7 +83,7 @@ class Smarty_Template_Config extends Smarty_Template_Source if (empty($template_resource)) { throw new SmartyException('Source: Missing name'); } - // parse resource_name, load resource handler + // parse resource_name, load resource handler list($name, $type) = Smarty_Resource::parseResourceName($template_resource, $smarty->default_config_type); // make sure configs are not loaded via anything smarty can't handle if (isset($_incompatible_resources[ $type ])) { diff --git a/libs/sysplugins/smarty_template_resource_base.php b/libs/sysplugins/smarty_template_resource_base.php index 8b4a3313..52bfba25 100644 --- a/libs/sysplugins/smarty_template_resource_base.php +++ b/libs/sysplugins/smarty_template_resource_base.php @@ -99,7 +99,7 @@ abstract class Smarty_Template_Resource_Base * get rendered template content by calling compiled or cached template code * * @param \Smarty_Internal_Template $_template - * @param string $unifunc function with template code + * @param string $unifunc function with template code * * @throws \Exception */ @@ -125,8 +125,7 @@ abstract class Smarty_Template_Resource_Base call_user_func($callback, $_template); } $_template->isRenderingCache = false; - } - catch (Exception $e) { + } catch (Exception $e) { $_template->isRenderingCache = false; while (ob_get_level() > $level) { ob_end_clean(); diff --git a/libs/sysplugins/smarty_template_source.php b/libs/sysplugins/smarty_template_source.php index 4ba188ec..16b47f23 100644 --- a/libs/sysplugins/smarty_template_source.php +++ b/libs/sysplugins/smarty_template_source.php @@ -155,7 +155,9 @@ class Smarty_Template_Source * @return Smarty_Template_Source Source Object * @throws SmartyException */ - public static function load(Smarty_Internal_Template $_template = null, Smarty $smarty = null, + public static function load( + Smarty_Internal_Template $_template = null, + Smarty $smarty = null, $template_resource = null ) { if ($_template) { diff --git a/libs/sysplugins/smarty_undefined_variable.php b/libs/sysplugins/smarty_undefined_variable.php index ee6c8fcb..6d31a8a0 100644 --- a/libs/sysplugins/smarty_undefined_variable.php +++ b/libs/sysplugins/smarty_undefined_variable.php @@ -18,7 +18,7 @@ class Smarty_Undefined_Variable extends Smarty_Variable */ public function __get($name) { - return null; + return null; } /** diff --git a/libs/sysplugins/smarty_variable.php b/libs/sysplugins/smarty_variable.php index 0b17bc7c..914d99bd 100644 --- a/libs/sysplugins/smarty_variable.php +++ b/libs/sysplugins/smarty_variable.php @@ -42,7 +42,6 @@ class Smarty_Variable */ public function __toString() { - return (string) $this->value; + return (string)$this->value; } } - diff --git a/utilities/BuildExpectedFiles.php b/utilities/BuildExpectedFiles.php index b664d0c1..ee33a30d 100644 --- a/utilities/BuildExpectedFiles.php +++ b/utilities/BuildExpectedFiles.php @@ -27,4 +27,3 @@ $code = preg_replace('#\$expectedPlugins =[^;]+#', $expectedPlugins, $code); $expectedSysplugins = '$expectedSysplugins = ' . var_export($sysplugins, true); $code = preg_replace('#\$expectedSysplugins =[^;]+#', $expectedSysplugins, $code); file_put_contents(dirname(__FILE__) . '/../libs/sysplugins/smarty_internal_testinstall.php', $code); -