diff --git a/.gitattributes b/.gitattributes
index 4d3c3d8c..eedcfa37 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1,6 +1,11 @@
# Auto detect text files and perform LF normalization
* text=auto
+*.php text eol=lf
+*.y text eol=lf
+*.lex text eol=lf
+
+
# exclude from git export
/travis.ini export-ignore
/myconfig.ini export-ignore
diff --git a/.travis.yml b/.travis.yml
index 3cc39a58..c1fb0b36 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -10,7 +10,8 @@ matrix:
- php: 5.3
dist: precise
- php: 5.4
- - php: 5.5
+ dist: precise
+ - php: 5.5
- php: 5.6
- php: 7.0
- php: 7.1
diff --git a/NEW_FEATURES.txt b/NEW_FEATURES.txt
index 7632b07e..b3289dfc 100644
--- a/NEW_FEATURES.txt
+++ b/NEW_FEATURES.txt
@@ -2,7 +2,14 @@
This file contains a brief description of new features which have been added to Smarty 3.1
-Smarty 3.1.32 New tags for inheritance parent and child
+Smarty 3.1.33-dev
+ Variable capture name in Smarty special variable
+ ================================================
+ {$smarty.capture.$foo} can now be used to access the content of a named
+ capture block
+
+Smarty 3.1.32
+ New tags for inheritance parent and child
=========================================
{parent} == {$smarty.block.parent}
{child} == {$smarty.block.child}
diff --git a/change_log.txt b/change_log.txt
index 982a7e8e..70762eda 100644
--- a/change_log.txt
+++ b/change_log.txt
@@ -1,4 +1,34 @@
-===== 3.1.33-dev-4 =====
+===== 3.1.33 release ===== 12.09.2018
+===== 3.1.33-dev-12 =====
+03.09.2018
+ - bugfix {foreach} using new style property access like {$item@property} on
+ Smarty 2 style named foreach loop could produce errors https://github.com/smarty-php/smarty/issues/484
+
+31.08.2018
+ - bugfix some custom left and right delimiters like '{^' '^}' did not work
+ https://github.com/smarty-php/smarty/issues/450 https://github.com/smarty-php/smarty/pull/482
+
+ - 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
+
+ - PSR-2 code style fixes for config and template file Lexer/Parser generated with
+ the Smarty Lexer/Parser generator from https://github.com/smarty-php/smarty-lexer
+ https://github.com/smarty-php/smarty/pull/483
+
+26.08.2018
+ - bugfix/enhancement {capture} allow variable as capture block name in Smarty special variable
+ like $smarty.capture.$foo https://github.com/smarty-php/smarty/issues/478 https://github.com/smarty-php/smarty/pull/481
+
+===== 3.1.33-dev-6 =====
+19.08.2018
+ - fix PSR-2 coding standards and PHPDoc blocks https://github.com/smarty-php/smarty/pull/452
+ https://github.com/smarty-php/smarty/pull/475
+ https://github.com/smarty-php/smarty/pull/473
+ - bugfix PHP5.2 compatibility https://github.com/smarty-php/smarty/pull/472
+
+===== 3.1.33-dev-4 =====
17.05.2018
- bugfix strip-block produces different output in Smarty v3.1.32 https://github.com/smarty-php/smarty/issues/436
- bugfix Smarty::compileAllTemplates ignores `$extension` parameter https://github.com/smarty-php/smarty/issues/437
@@ -8,6 +38,7 @@
26.04.2018
- bugfix regarding Security Vulnerability did not solve the problem under Linux.
+ Security issue CVE-2018-16831
===== 3.1.32 ===== (24.04.2018)
24.04.2018
diff --git a/composer.json b/composer.json
index 92f00d05..6c0582f0 100644
--- a/composer.json
+++ b/composer.json
@@ -2,7 +2,9 @@
"name": "smarty/smarty",
"type": "library",
"description": "Smarty - the compiling PHP template engine",
- "keywords": ["templating"],
+ "keywords": [
+ "templating"
+ ],
"homepage": "http://www.smarty.net",
"license": "LGPL-3.0",
"authors": [
diff --git a/demo/index.php b/demo/index.php
index b67c217b..3aed3716 100644
--- a/demo/index.php
+++ b/demo/index.php
@@ -4,27 +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")));
-
-$smarty->assign("contacts", array(array("phone" => "1", "fax" => "2", "cell" => "3"),
- array("phone" => "555-4444", "fax" => "555-3333", "cell" => "760-1234")));
-
+$smarty->assign(
+ "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")
+ )
+);
$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 ed55ec84..7867cc59 100644
--- a/demo/plugins/cacheresource.apc.php
+++ b/demo/plugins/cacheresource.apc.php
@@ -11,6 +11,11 @@
*/
class Smarty_CacheResource_Apc extends Smarty_CacheResource_KeyValueStore
{
+ /**
+ * Smarty_CacheResource_Apc constructor.
+ *
+ * @throws \Exception
+ */
public function __construct()
{
// test if APC is present
@@ -22,7 +27,7 @@ class Smarty_CacheResource_Apc extends Smarty_CacheResource_KeyValueStore
/**
* Read values for a set of keys from cache
*
- * @param array $keys list of keys to fetch
+ * @param array $keys list of keys to fetch
*
* @return array list of values with the given keys used as indexes
* @return boolean true on success, false on failure
@@ -34,15 +39,14 @@ class Smarty_CacheResource_Apc extends Smarty_CacheResource_KeyValueStore
foreach ($res as $k => $v) {
$_res[ $k ] = $v;
}
-
return $_res;
}
/**
* Save values for a set of keys to cache
*
- * @param array $keys list of values to save
- * @param int $expire expiration time
+ * @param array $keys list of values to save
+ * @param int $expire expiration time
*
* @return boolean true on success, false on failure
*/
@@ -51,14 +55,13 @@ class Smarty_CacheResource_Apc extends Smarty_CacheResource_KeyValueStore
foreach ($keys as $k => $v) {
apc_store($k, $v, $expire);
}
-
return true;
}
/**
* Remove values from cache
*
- * @param array $keys list of keys to delete
+ * @param array $keys list of keys to delete
*
* @return boolean true on success, false on failure
*/
@@ -67,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 945beb34..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')) {
@@ -32,7 +35,7 @@ class Smarty_CacheResource_Memcache extends Smarty_CacheResource_KeyValueStore
/**
* Read values for a set of keys from cache
*
- * @param array $keys list of keys to fetch
+ * @param array $keys list of keys to fetch
*
* @return array list of values with the given keys used as indexes
* @return boolean true on success, false on failure
@@ -50,15 +53,14 @@ class Smarty_CacheResource_Memcache extends Smarty_CacheResource_KeyValueStore
foreach ($res as $k => $v) {
$_res[ $lookup[ $k ] ] = $v;
}
-
return $_res;
}
/**
* Save values for a set of keys to cache
*
- * @param array $keys list of values to save
- * @param int $expire expiration time
+ * @param array $keys list of values to save
+ * @param int $expire expiration time
*
* @return boolean true on success, false on failure
*/
@@ -68,14 +70,13 @@ class Smarty_CacheResource_Memcache extends Smarty_CacheResource_KeyValueStore
$k = sha1($k);
$this->memcache->set($k, $v, 0, $expire);
}
-
return true;
}
/**
* Remove values from cache
*
- * @param array $keys list of keys to delete
+ * @param array $keys list of keys to delete
*
* @return boolean true on success, false on failure
*/
@@ -85,7 +86,6 @@ class Smarty_CacheResource_Memcache extends Smarty_CacheResource_KeyValueStore
$k = sha1($k);
$this->memcache->delete($k);
}
-
return true;
}
@@ -96,6 +96,6 @@ class Smarty_CacheResource_Memcache extends Smarty_CacheResource_KeyValueStore
*/
protected function purge()
{
- $this->memcache->flush();
+ return $this->memcache->flush();
}
}
diff --git a/demo/plugins/cacheresource.mysql.php b/demo/plugins/cacheresource.mysql.php
index 027b9376..c5037eb1 100644
--- a/demo/plugins/cacheresource.mysql.php
+++ b/demo/plugins/cacheresource.mysql.php
@@ -24,38 +24,55 @@
*/
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;
+ /**
+ * Smarty_CacheResource_Mysql constructor.
+ *
+ * @throws \SmartyException
+ */
public function __construct()
{
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');
$this->fetchTimestamp = $this->db->prepare('SELECT modified FROM output_cache WHERE id = :id');
- $this->save = $this->db->prepare('REPLACE INTO output_cache (id, name, cache_id, compile_id, content)
- VALUES (:id, :name, :cache_id, :compile_id, :content)');
+ $this->save = $this->db->prepare(
+ 'REPLACE INTO output_cache (id, name, cache_id, compile_id, content)
+ VALUES (:id, :name, :cache_id, :compile_id, :content)'
+ );
}
/**
* fetch cached content and its modification time from data source
*
- * @param string $id unique cache content identifier
- * @param string $name template name
- * @param string $cache_id cache id
- * @param string $compile_id compile id
- * @param string $content cached content
- * @param integer $mtime cache modification timestamp (epoch)
+ * @param string $id unique cache content identifier
+ * @param string $name template name
+ * @param string $cache_id cache id
+ * @param string $compile_id compile id
+ * @param string $content cached content
+ * @param integer $mtime cache modification timestamp (epoch)
*
* @return void
*/
@@ -76,12 +93,13 @@ 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
- * @param string $cache_id cache id
- * @param string $compile_id compile id
+ * @param string $id unique cache content identifier
+ * @param string $name template name
+ * @param string $cache_id cache id
+ * @param string $compile_id compile id
*
* @return integer|boolean timestamp (epoch) the template was modified, or false if not found
*/
@@ -90,37 +108,40 @@ class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom
$this->fetchTimestamp->execute(array('id' => $id));
$mtime = strtotime($this->fetchTimestamp->fetchColumn());
$this->fetchTimestamp->closeCursor();
-
return $mtime;
}
/**
* Save content to cache
*
- * @param string $id unique cache content identifier
- * @param string $name template name
- * @param string $cache_id cache id
- * @param string $compile_id compile id
- * @param integer|null $exp_time seconds till expiration time in seconds or null
- * @param string $content content to cache
+ * @param string $id unique cache content identifier
+ * @param string $name template name
+ * @param string $cache_id cache id
+ * @param string $compile_id compile id
+ * @param integer|null $exp_time seconds till expiration time in seconds or null
+ * @param string $content content to cache
*
* @return boolean success
*/
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,));
-
+ $this->save->execute(
+ array('id' => $id,
+ 'name' => $name,
+ 'cache_id' => $cache_id,
+ 'compile_id' => $compile_id,
+ 'content' => $content,)
+ );
return !!$this->save->rowCount();
}
/**
* Delete content from cache
*
- * @param string $name template name
- * @param string $cache_id cache id
- * @param string $compile_id compile id
- * @param integer|null $exp_time seconds till expiration or null
+ * @param string $name template name
+ * @param string $cache_id cache id
+ * @param string $compile_id compile id
+ * @param integer|null $exp_time seconds till expiration or null
*
* @return integer number of deleted caches
*/
@@ -130,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();
@@ -149,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 24a94c1a..a80cd698 100644
--- a/demo/plugins/cacheresource.pdo.php
+++ b/demo/plugins/cacheresource.pdo.php
@@ -29,28 +29,27 @@
*/
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
AND cache_id IS NULL
AND compile_id IS NULL',
-
'withCacheId' => 'SELECT %2$s
FROM %1$s
WHERE 1
AND id = :id
AND cache_id = :cache_id
AND compile_id IS NULL',
-
'withCompileId' => 'SELECT %2$s
FROM %1$s
WHERE 1
AND id = :id
AND compile_id = :compile_id
AND cache_id IS NULL',
-
'withCacheIdAndCompileId' => 'SELECT %2$s
FROM %1$s
WHERE 1
@@ -58,6 +57,9 @@ class Smarty_CacheResource_Pdo extends Smarty_CacheResource_Custom
AND cache_id = :cache_id
AND compile_id = :compile_id');
+ /**
+ * @var string
+ */
protected $insertStatement = 'INSERT INTO %s
SET id = :id,
@@ -76,113 +78,130 @@ class Smarty_CacheResource_Pdo extends Smarty_CacheResource_Custom
expire = DATE_ADD(CURRENT_TIMESTAMP, INTERVAL :expire SECOND),
content = :content';
+ /**
+ * @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';
- protected $pdo, $table, $database;
+ /**
+ * @var \PDO
+ */
+ protected $pdo;
- /*
- * 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
+ /**
+ * @var
+ */
+ protected $table;
+
+ /**
+ * @var null
+ */
+ protected $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
+ *
+ * @throws \SmartyException
*/
public function __construct(PDO $pdo, $table, $database = null)
{
-
if (is_null($table)) {
throw new SmartyException("Table name for caching can't be null");
}
-
$this->pdo = $pdo;
$this->table = $table;
$this->database = $database;
-
$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());
$this->deleteStatement = sprintf($this->deleteStatement, $this->getTableName(), '%s');
$this->truncateStatement = sprintf($this->truncateStatement, $this->getTableName());
-
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;
}
/**
* fetch cached content and its modification time from data source
*
- * @param string $id unique cache content identifier
- * @param string $name template name
- * @param string|null $cache_id cache id
- * @param string|null $compile_id compile id
- * @param string $content cached content
- * @param integer $mtime cache modification timestamp (epoch)
+ * @param string $id unique cache content identifier
+ * @param string $name template name
+ * @param string|null $cache_id cache id
+ * @param string|null $compile_id compile id
+ * @param string $content cached content
+ * @param integer $mtime cache modification timestamp (epoch)
*
* @return void
* @access protected
*/
protected function fetch($id, $name, $cache_id = null, $compile_id = null, &$content, &$mtime)
{
-
$stmt = $this->getFetchStatement($this->fetchColumns, $id, $cache_id, $compile_id);
$stmt->execute();
$row = $stmt->fetch();
$stmt->closeCursor();
-
if ($row) {
$content = $this->outputContent($row[ 'content' ]);
$mtime = strtotime($row[ 'modified' ]);
@@ -197,10 +216,10 @@ class Smarty_CacheResource_Pdo extends Smarty_CacheResource_Custom
* {@internal 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
- * @param string|null $cache_id cache id
- * @param string|null $compile_id compile id
+ * @param string $id unique cache content identifier
+ * @param string $name template name
+ * @param string|null $cache_id cache id
+ * @param string|null $compile_id compile id
*
* @return integer|boolean timestamp (epoch) the template was modified, or false if not found
* @access protected
@@ -212,7 +231,6 @@ class Smarty_CacheResource_Pdo extends Smarty_CacheResource_Custom
// $stmt -> closeCursor();
// return $mtime;
// }
-
/**
* Save content to cache
*
@@ -228,38 +246,37 @@ class Smarty_CacheResource_Pdo extends Smarty_CacheResource_Custom
*/
protected function save($id, $name, $cache_id = null, $compile_id = null, $exp_time, $content)
{
-
$stmt = $this->pdo->prepare($this->insertStatement);
-
$stmt->bindValue('id', $id);
$stmt->bindValue('name', $name);
$stmt->bindValue('cache_id', $cache_id, (is_null($cache_id)) ? PDO::PARAM_NULL : PDO::PARAM_STR);
$stmt->bindValue('compile_id', $compile_id, (is_null($compile_id)) ? PDO::PARAM_NULL : PDO::PARAM_STR);
- $stmt->bindValue('expire', (int) $exp_time, PDO::PARAM_INT);
+ $stmt->bindValue('expire', (int)$exp_time, PDO::PARAM_INT);
$stmt->bindValue('content', $this->inputContent($content));
$stmt->execute();
-
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)
{
@@ -272,43 +289,46 @@ 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
+ * @access protected
*/
protected function delete($name = null, $cache_id = null, $compile_id = null, $exp_time = null)
{
-
- // delete the whole cache
+ // 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;
+ 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();
}
@@ -324,4 +344,3 @@ class Smarty_CacheResource_Pdo extends Smarty_CacheResource_Custom
return (is_null($this->database)) ? "`{$this->table}`" : "`{$this->database}`.`{$this->table}`";
}
}
-
\ No newline at end of file
diff --git a/demo/plugins/cacheresource.pdo_gzip.php b/demo/plugins/cacheresource.pdo_gzip.php
index 8a9e0a5d..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 619707e7..95a3c2ba 100644
--- a/demo/plugins/resource.mysql.php
+++ b/demo/plugins/resource.mysql.php
@@ -12,28 +12,46 @@
* 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;
+ /**
+ * Smarty_Resource_Mysql constructor.
+ *
+ * @throws \SmartyException
+ */
public function __construct()
{
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');
@@ -43,9 +61,9 @@ class Smarty_Resource_Mysql extends Smarty_Resource_Custom
/**
* Fetch a template and its modification time from database
*
- * @param string $name template name
- * @param string $source template source
- * @param integer $mtime template modification timestamp (epoch)
+ * @param string $name template name
+ * @param string $source template source
+ * @param integer $mtime template modification timestamp (epoch)
*
* @return void
*/
@@ -66,9 +84,10 @@ 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
+ * @param string $name template name
*
* @return integer timestamp (epoch) the template was modified
*/
@@ -77,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 d85aecf3..148a8dd6 100644
--- a/demo/plugins/resource.mysqls.php
+++ b/demo/plugins/resource.mysqls.php
@@ -14,25 +14,39 @@
* 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;
+ /**
+ * Smarty_Resource_Mysqls constructor.
+ *
+ * @throws \SmartyException
+ */
public function __construct()
{
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');
@@ -41,9 +55,9 @@ class Smarty_Resource_Mysqls extends Smarty_Resource_Custom
/**
* Fetch a template and its modification time from database
*
- * @param string $name template name
- * @param string $source template source
- * @param integer $mtime template modification timestamp (epoch)
+ * @param string $name template name
+ * @param string $source template source
+ * @param integer $mtime template modification timestamp (epoch)
*
* @return void
*/
diff --git a/lexer/smarty_internal_configfilelexer.plex b/lexer/smarty_internal_configfilelexer.plex
index 67887a4a..7a86fadc 100644
--- a/lexer/smarty_internal_configfilelexer.plex
+++ b/lexer/smarty_internal_configfilelexer.plex
@@ -124,7 +124,7 @@ class Smarty_Internal_Configfilelexer
* @param string $data template source
* @param Smarty_Internal_Config_File_Compiler $compiler
*/
- function __construct($data, Smarty_Internal_Config_File_Compiler $compiler)
+ public function __construct($data, Smarty_Internal_Config_File_Compiler $compiler)
{
$this->data = $data . "\n"; //now all lines are \n-terminated
$this->dataLength = strlen($data);
@@ -308,7 +308,7 @@ text {
if (isset($match[0][1])) {
$to = $match[0][1];
} else {
- $this->compiler->trigger_template_error ('missing or misspelled literal closing tag');
+ $this->compiler->trigger_config_file_error ('missing or misspelled literal closing tag');
}
$this->value = substr($this->data,$this->counter,$to-$this->counter);
$this->token = Smarty_Internal_Configfileparser::TPC_TRIPPLE_TEXT;
diff --git a/lexer/smarty_internal_configfileparser.y b/lexer/smarty_internal_configfileparser.y
index f5e70737..c981b58e 100644
--- a/lexer/smarty_internal_configfileparser.y
+++ b/lexer/smarty_internal_configfileparser.y
@@ -89,7 +89,7 @@ class Smarty_Internal_Configfileparser
* @param Smarty_Internal_Configfilelexer $lex
* @param Smarty_Internal_Config_File_Compiler $compiler
*/
- function __construct(Smarty_Internal_Configfilelexer $lex, Smarty_Internal_Config_File_Compiler $compiler)
+ public function __construct(Smarty_Internal_Configfilelexer $lex, Smarty_Internal_Config_File_Compiler $compiler)
{
$this->lex = $lex;
$this->smarty = $compiler->smarty;
diff --git a/lexer/smarty_internal_templatelexer.plex b/lexer/smarty_internal_templatelexer.plex
index 52ee2d7b..64a39310 100644
--- a/lexer/smarty_internal_templatelexer.plex
+++ b/lexer/smarty_internal_templatelexer.plex
@@ -215,7 +215,7 @@ class Smarty_Internal_Templatelexer
* @param string $source template source
* @param Smarty_Internal_TemplateCompilerBase $compiler
*/
- function __construct($source, Smarty_Internal_TemplateCompilerBase $compiler)
+ public function __construct($source, Smarty_Internal_TemplateCompilerBase $compiler)
{
$this->data = $source;
$this->dataLength = strlen($this->data);
diff --git a/lexer/smarty_internal_templateparser.y b/lexer/smarty_internal_templateparser.y
index d53cdf2d..ede1718b 100644
--- a/lexer/smarty_internal_templateparser.y
+++ b/lexer/smarty_internal_templateparser.y
@@ -21,9 +21,9 @@ class Smarty_Internal_Templateparser
}
%include_class
{
- 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';
/**
* result status
@@ -61,7 +61,7 @@ class Smarty_Internal_Templateparser
/**
* root parse tree buffer
*
- * @var Smarty_Internal_ParseTree
+ * @var Smarty_Internal_ParseTree_Template
*/
public $root_buffer;
@@ -147,7 +147,7 @@ class Smarty_Internal_Templateparser
* @param Smarty_Internal_Templatelexer $lex
* @param Smarty_Internal_TemplateCompilerBase $compiler
*/
- function __construct(Smarty_Internal_Templatelexer $lex, Smarty_Internal_TemplateCompilerBase $compiler)
+ public function __construct(Smarty_Internal_Templatelexer $lex, Smarty_Internal_TemplateCompilerBase $compiler)
{
$this->lex = $lex;
$this->compiler = $compiler;
@@ -329,10 +329,10 @@ smartytag(A) ::= SMARTYBLOCKCHILDPARENT(i). {
$j = strrpos(i,'.');
if (i[$j+1] == 'c') {
// {$smarty.block.child}
- A = $this->compiler->compileTag('child',array(),array(i));;
+ A = $this->compiler->compileTag('child',array(),array(i));
} else {
// {$smarty.block.parent}
- A = $this->compiler->compileTag('parent',array(),array(i));;
+ A = $this->compiler->compileTag('parent',array(),array(i));
}
}
@@ -922,7 +922,7 @@ indexdef(res) ::= OPENB INTEGER(n) CLOSEB. {
res = '['.n.']';
}
indexdef(res) ::= OPENB DOLLARID(i) CLOSEB. {
- res = '['.$this->compiler->compileVariable('\''.substr(i,1).'\'').']';;
+ res = '['.$this->compiler->compileVariable('\''.substr(i,1).'\'').']';
}
indexdef(res) ::= OPENB variable(v) CLOSEB. {
res = '['.v.']';
@@ -998,28 +998,28 @@ objectchain(res) ::= objectchain(oc) objectelement(oe). {
// variable
objectelement(res)::= PTR ID(i) arrayindex(a). {
if ($this->security && substr(i,0,1) === '_') {
- $this->compiler->trigger_template_error (self::Err1);
+ $this->compiler->trigger_template_error (self::ERR1);
}
res = '->'.i.a;
}
objectelement(res)::= PTR varvar(v) arrayindex(a). {
if ($this->security) {
- $this->compiler->trigger_template_error (self::Err2);
+ $this->compiler->trigger_template_error (self::ERR2);
}
res = '->{'.$this->compiler->compileVariable(v).a.'}';
}
objectelement(res)::= PTR LDEL expr(e) RDEL arrayindex(a). {
if ($this->security) {
- $this->compiler->trigger_template_error (self::Err2);
+ $this->compiler->trigger_template_error (self::ERR2);
}
res = '->{'.e.a.'}';
}
objectelement(res)::= PTR ID(ii) LDEL expr(e) RDEL arrayindex(a). {
if ($this->security) {
- $this->compiler->trigger_template_error (self::Err2);
+ $this->compiler->trigger_template_error (self::ERR2);
}
res = '->{\''.ii.'\'.'.e.a.'}';
}
@@ -1043,14 +1043,14 @@ function(res) ::= ns1(f) OPENP params(p) CLOSEP. {
//
method(res) ::= ID(f) OPENP params(p) CLOSEP. {
if ($this->security && substr(f,0,1) === '_') {
- $this->compiler->trigger_template_error (self::Err1);
+ $this->compiler->trigger_template_error (self::ERR1);
}
res = f . '('. implode(',',p) .')';
}
method(res) ::= DOLLARID(f) OPENP params(p) CLOSEP. {
if ($this->security) {
- $this->compiler->trigger_template_error (self::Err2);
+ $this->compiler->trigger_template_error (self::ERR2);
}
$prefixVar = $this->compiler->getNewPrefixVariable();
$this->compiler->appendPrefixCode("compiler->compileVariable('\''.substr(f,1).'\'').';?>');
diff --git a/libs/Autoloader.php b/libs/Autoloader.php
index 3a0da8fa..e4dc450f 100644
--- a/libs/Autoloader.php
+++ b/libs/Autoloader.php
@@ -2,14 +2,14 @@
/**
* Smarty Autoloader
*
- * @package Smarty
+ * @package Smarty
*/
/**
* Smarty Autoloader
*
- * @package Smarty
- * @author Uwe Tews
+ * @package Smarty
+ * @author Uwe Tews
* Usage:
* require_once '...path/Autoloader.php';
* Smarty_Autoloader::register();
@@ -20,7 +20,7 @@
*/
class Smarty_Autoloader
{
- /**
+ /**
* Filepath to Smarty root
*
* @var string
@@ -54,8 +54,8 @@ class Smarty_Autoloader
if (!defined('SMARTY_SPL_AUTOLOAD')) {
define('SMARTY_SPL_AUTOLOAD', 0);
}
- if (SMARTY_SPL_AUTOLOAD &&
- set_include_path(get_include_path() . PATH_SEPARATOR . SMARTY_SYSPLUGINS_DIR) !== false
+ if (SMARTY_SPL_AUTOLOAD
+ && set_include_path(get_include_path() . PATH_SEPARATOR . SMARTY_SYSPLUGINS_DIR) !== false
) {
$registeredAutoLoadFunctions = spl_autoload_functions();
if (!isset($registeredAutoLoadFunctions[ 'spl_autoload' ])) {
diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php
index 4d307547..a8969926 100644
--- a/libs/Smarty.class.php
+++ b/libs/Smarty.class.php
@@ -27,7 +27,7 @@
* @author Uwe Tews
* @author Rodney Rehm
* @package Smarty
- * @version 3.1.33-dev
+ * @version 3.1.33
*/
/**
* set SMARTY_DIR to absolute path to Smarty library files.
@@ -112,7 +112,7 @@ class Smarty extends Smarty_Internal_TemplateBase
/**
* smarty version
*/
- const SMARTY_VERSION = '3.1.33-dev-5';
+ const SMARTY_VERSION = '3.1.33';
/**
* define variable scopes
*/
@@ -166,133 +166,157 @@ class Smarty extends Smarty_Internal_TemplateBase
const PLUGIN_COMPILER = 'compiler';
const PLUGIN_MODIFIER = 'modifier';
const PLUGIN_MODIFIERCOMPILER = 'modifiercompiler';
+
/**
* assigned global tpl vars
*/
public static $global_tpl_vars = array();
+
/**
* Flag denoting if Multibyte String functions are available
*/
public static $_MBSTRING = SMARTY_MBSTRING;
+
/**
* The character set to adhere to (e.g. "UTF-8")
*/
public static $_CHARSET = SMARTY_RESOURCE_CHAR_SET;
+
/**
* The date format to be used internally
* (accepts date() and strftime())
*/
public static $_DATE_FORMAT = SMARTY_RESOURCE_DATE_FORMAT;
+
/**
* Flag denoting if PCRE should run in UTF-8 mode
*/
public static $_UTF8_MODIFIER = 'u';
+
/**
* Flag denoting if operating system is windows
*/
public static $_IS_WINDOWS = false;
+
/**
* auto literal on delimiters with whitespace
*
* @var boolean
*/
public $auto_literal = true;
+
/**
* display error on not assigned variables
*
* @var boolean
*/
public $error_unassigned = false;
+
/**
* look up relative file path in include_path
*
* @var boolean
*/
public $use_include_path = false;
+
/**
* flag if template_dir is normalized
*
* @var bool
*/
public $_templateDirNormalized = false;
+
/**
* joined template directory string used in cache keys
*
* @var string
*/
public $_joined_template_dir = null;
+
/**
* flag if config_dir is normalized
*
* @var bool
*/
public $_configDirNormalized = false;
+
/**
* joined config directory string used in cache keys
*
* @var string
*/
public $_joined_config_dir = null;
+
/**
* default template handler
*
* @var callable
*/
public $default_template_handler_func = null;
+
/**
* default config handler
*
* @var callable
*/
public $default_config_handler_func = null;
+
/**
* default plugin handler
*
* @var callable
*/
public $default_plugin_handler_func = null;
+
/**
* flag if template_dir is normalized
*
* @var bool
*/
public $_compileDirNormalized = false;
+
/**
* flag if plugins_dir is normalized
*
* @var bool
*/
public $_pluginsDirNormalized = false;
+
/**
* flag if template_dir is normalized
*
* @var bool
*/
public $_cacheDirNormalized = false;
+
/**
* force template compiling?
*
* @var boolean
*/
public $force_compile = false;
- /**
+
+ /**
* use sub dirs for compiled/cached files?
*
* @var boolean
*/
public $use_sub_dirs = false;
+
/**
* allow ambiguous resources (that are made unique by the resource handler)
*
* @var boolean
*/
public $allow_ambiguous_resources = false;
+
/**
* merge compiled includes
*
* @var boolean
*/
public $merge_compiled_includes = false;
+
/*
* flag for behaviour when extends: resource and {extends} tag are used simultaneous
* if false disable execution of {extends} in templates called by extends resource.
@@ -301,30 +325,35 @@ class Smarty extends Smarty_Internal_TemplateBase
* @var boolean
*/
public $extends_recursion = true;
+
/**
* force cache file creation
*
* @var boolean
*/
public $force_cache = false;
+
/**
* template left-delimiter
*
* @var string
*/
public $left_delimiter = "{";
+
/**
* template right-delimiter
*
* @var string
*/
public $right_delimiter = "}";
+
/**
* array of strings which shall be treated as literal by compiler
*
* @var array string
*/
public $literals = array();
+
/**
* class name
* This should be instance of Smarty_Security.
@@ -333,24 +362,28 @@ class Smarty extends Smarty_Internal_TemplateBase
* @see Smarty_Security
*/
public $security_class = 'Smarty_Security';
+
/**
* implementation of security class
*
* @var Smarty_Security
*/
public $security_policy = null;
+
/**
* controls handling of PHP-blocks
*
* @var integer
*/
public $php_handling = self::PHP_PASSTHRU;
+
/**
* controls if the php template file resource is allowed
*
* @var bool
*/
public $allow_php_templates = false;
+
/**
* debug mode
* Setting this to true enables the debug-console.
@@ -358,6 +391,7 @@ class Smarty extends Smarty_Internal_TemplateBase
* @var boolean
*/
public $debugging = false;
+
/**
* This determines if debugging is enable-able from the browser.
*
@@ -368,6 +402,7 @@ class Smarty extends Smarty_Internal_TemplateBase
* @var string
*/
public $debugging_ctrl = 'NONE';
+
/**
* Name of debugging URL-param.
* Only used when $debugging_ctrl is set to 'URL'.
@@ -376,54 +411,63 @@ class Smarty extends Smarty_Internal_TemplateBase
* @var string
*/
public $smarty_debug_id = 'SMARTY_DEBUG';
+
/**
* Path of debug template.
*
* @var string
*/
public $debug_tpl = null;
+
/**
* When set, smarty uses this value as error_reporting-level.
*
* @var int
*/
public $error_reporting = null;
+
/**
* Controls whether variables with the same name overwrite each other.
*
* @var boolean
*/
public $config_overwrite = true;
+
/**
* Controls whether config values of on/true/yes and off/false/no get converted to boolean.
*
* @var boolean
*/
public $config_booleanize = true;
+
/**
* Controls whether hidden config sections/vars are read from the file.
*
* @var boolean
*/
public $config_read_hidden = false;
+
/**
* locking concurrent compiles
*
* @var boolean
*/
public $compile_locking = true;
+
/**
* Controls whether cache resources should use locking mechanism
*
* @var boolean
*/
public $cache_locking = false;
+
/**
* seconds to wait for acquiring a lock before ignoring the write lock
*
* @var float
*/
public $locking_timeout = 10;
+
/**
* resource type used if none given
* Must be an valid key of $registered_resources.
@@ -431,6 +475,7 @@ class Smarty extends Smarty_Internal_TemplateBase
* @var string
*/
public $default_resource_type = 'file';
+
/**
* caching type
* Must be an element of $cache_resource_types.
@@ -438,160 +483,189 @@ class Smarty extends Smarty_Internal_TemplateBase
* @var string
*/
public $caching_type = 'file';
+
/**
* config type
*
* @var string
*/
public $default_config_type = 'file';
+
/**
* check If-Modified-Since headers
*
* @var boolean
*/
public $cache_modified_check = false;
+
/**
* registered plugins
*
* @var array
*/
public $registered_plugins = array();
+
/**
* registered objects
*
* @var array
*/
public $registered_objects = array();
+
/**
* registered classes
*
* @var array
*/
public $registered_classes = array();
+
/**
* registered filters
*
* @var array
*/
public $registered_filters = array();
+
/**
* registered resources
*
* @var array
*/
public $registered_resources = array();
+
/**
* registered cache resources
*
* @var array
*/
public $registered_cache_resources = array();
+
/**
* autoload filter
*
* @var array
*/
public $autoload_filters = array();
+
/**
* default modifier
*
* @var array
*/
public $default_modifiers = array();
+
/**
* autoescape variable output
*
* @var boolean
*/
public $escape_html = false;
+
/**
* start time for execution time calculation
*
* @var int
*/
public $start_time = 0;
+
/**
* required by the compiler for BC
*
* @var string
*/
public $_current_file = null;
+
/**
* internal flag to enable parser debugging
*
* @var bool
*/
public $_parserdebug = false;
+
/**
* This object type (Smarty = 1, template = 2, data = 4)
*
* @var int
*/
public $_objType = 1;
+
/**
* Debug object
*
* @var Smarty_Internal_Debug
*/
public $_debug = null;
+
/**
* template directory
*
* @var array
*/
protected $template_dir = array('./templates/');
+
/**
* flags for normalized template directory entries
*
* @var array
*/
protected $_processedTemplateDir = array();
+
/**
* config directory
*
* @var array
*/
protected $config_dir = array('./configs/');
+
/**
* flags for normalized template directory entries
*
* @var array
*/
protected $_processedConfigDir = array();
+
/**
* compile directory
*
* @var string
*/
protected $compile_dir = './templates_c/';
+
/**
* plugins directory
*
* @var array
*/
protected $plugins_dir = array();
+
/**
* cache directory
*
* @var string
*/
protected $cache_dir = './cache/';
+
/**
* removed properties
*
* @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
@@ -618,7 +692,7 @@ class Smarty extends Smarty_Internal_TemplateBase
/**
* Enable error handler to mute expected messages
*
- * @return boolean
+ * @return boolean
* @deprecated
*/
public static function muteExpectedErrors()
@@ -639,7 +713,7 @@ class Smarty extends Smarty_Internal_TemplateBase
/**
* Check if a template resource exists
*
- * @param string $resource_name template name
+ * @param string $resource_name template name
*
* @return bool status
* @throws \SmartyException
@@ -654,10 +728,10 @@ class Smarty extends Smarty_Internal_TemplateBase
/**
* Loads security class and enables security
*
- * @param string|Smarty_Security $security_class if a string is used, it must be class-name
+ * @param string|Smarty_Security $security_class if a string is used, it must be class-name
*
* @return Smarty current Smarty instance for chaining
- * @throws SmartyException when an invalid class name is provided
+ * @throws \SmartyException
*/
public function enableSecurity($security_class = null)
{
@@ -679,9 +753,9 @@ class Smarty extends Smarty_Internal_TemplateBase
/**
* Add template directory(s)
*
- * @param string|array $template_dir directory(s) of template sources
- * @param string $key of the array element to assign the template dir to
- * @param bool $isConfig true for config_dir
+ * @param string|array $template_dir directory(s) of template sources
+ * @param string $key of the array element to assign the template dir to
+ * @param bool $isConfig true for config_dir
*
* @return Smarty current Smarty instance for chaining
*/
@@ -747,8 +821,8 @@ class Smarty extends Smarty_Internal_TemplateBase
/**
* Set template directory
*
- * @param string|array $template_dir directory(s) of template sources
- * @param bool $isConfig true for config_dir
+ * @param string|array $template_dir directory(s) of template sources
+ * @param bool $isConfig true for config_dir
*
* @return \Smarty current Smarty instance for chaining
*/
@@ -846,7 +920,7 @@ class Smarty extends Smarty_Internal_TemplateBase
/**
* Set plugins directory
*
- * @param string|array $plugins_dir directory(s) of plugins
+ * @param string|array $plugins_dir directory(s) of plugins
*
* @return Smarty current Smarty instance for chaining
*/
@@ -901,7 +975,7 @@ class Smarty extends Smarty_Internal_TemplateBase
/**
* Set cache directory
*
- * @param string $cache_dir directory to store cached templates in
+ * @param string $cache_dir directory to store cached templates in
*
* @return Smarty current Smarty instance for chaining
*/
@@ -915,11 +989,11 @@ class Smarty extends Smarty_Internal_TemplateBase
/**
* creates a template object
*
- * @param string $template the resource handle of the template file
- * @param mixed $cache_id cache id to be used with this template
- * @param mixed $compile_id compile id to be used with this template
- * @param object $parent next higher level of Smarty variables
- * @param boolean $do_clone flag is Smarty object shall be cloned
+ * @param string $template the resource handle of the template file
+ * @param mixed $cache_id cache id to be used with this template
+ * @param mixed $compile_id compile id to be used with this template
+ * @param object $parent next higher level of Smarty variables
+ * @param boolean $do_clone flag is Smarty object shall be cloned
*
* @return \Smarty_Internal_Template template object
* @throws \SmartyException
@@ -946,7 +1020,7 @@ class Smarty extends Smarty_Internal_TemplateBase
Smarty_Internal_Template::$isCacheTplObj[ $_templateId ];
$tpl->inheritance = null;
$tpl->tpl_vars = $tpl->config_vars = array();
- } else if (!$do_clone && isset(Smarty_Internal_Template::$tplObjCache[ $_templateId ])) {
+ } elseif (!$do_clone && isset(Smarty_Internal_Template::$tplObjCache[ $_templateId ])) {
$tpl = clone Smarty_Internal_Template::$tplObjCache[ $_templateId ];
$tpl->inheritance = null;
$tpl->tpl_vars = $tpl->config_vars = array();
@@ -981,11 +1055,11 @@ class Smarty extends Smarty_Internal_TemplateBase
* class name format: Smarty_PluginType_PluginName
* plugin filename format: plugintype.pluginname.php
*
- * @param string $plugin_name class plugin name to load
- * @param bool $check check if already loaded
+ * @param string $plugin_name class plugin name to load
+ * @param bool $check check if already loaded
*
- * @throws SmartyException
* @return string |boolean filepath of loaded file or false
+ * @throws \SmartyException
*/
public function loadPlugin($plugin_name, $check = true)
{
@@ -1004,14 +1078,15 @@ 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;
+ $template_name;
$cache_id = $cache_id === null ? $this->cache_id : $cache_id;
$compile_id = $compile_id === null ? $this->compile_id : $compile_id;
$caching = (int)($caching === null ? $this->caching : $caching);
@@ -1033,21 +1108,22 @@ class Smarty extends Smarty_Internal_TemplateBase
* - remove /./ and /../
* - make it absolute if required
*
- * @param string $path file path
- * @param bool $realpath if true - convert to absolute
- * false - convert to relative
- * null - keep as it is but remove /./ /../
+ * @param string $path file path
+ * @param bool $realpath if true - convert to absolute
+ * false - convert to relative
+ * null - keep as it is but
+ * remove /./ /../
*
* @return string
*/
public function _realpath($path, $realpath = null)
{
$nds = array('/' => '\\', '\\' => '/');
- // normalize DIRECTORY_SEPARATOR
- //$path = str_replace(array($nds[DIRECTORY_SEPARATOR], DIRECTORY_SEPARATOR . '.' . DIRECTORY_SEPARATOR), DIRECTORY_SEPARATOR, $path);
- preg_match('%^(?(?:[[:alpha:]]:[\\\\]|/|[\\\\]{2}[[:alpha:]]+|[[:print:]]{2,}:[/]{2}|[\\\\])?)(?(.*))$%u',
- $path,
- $parts);
+ preg_match(
+ '%^(?(?:[[:alpha:]]:[\\\\/]|/|[\\\\]{2}[[:alpha:]]+|[[:print:]]{2,}:[/]{2}|[\\\\])?)(?(.*))$%u',
+ $path,
+ $parts
+ );
$path = $parts[ 'path' ];
if ($parts[ 'root' ] === '\\') {
$parts[ 'root' ] = substr(getcwd(), 0, 2) . $parts[ 'root' ];
@@ -1056,11 +1132,18 @@ class Smarty extends Smarty_Internal_TemplateBase
$path = getcwd() . DIRECTORY_SEPARATOR . $path;
}
}
+ // normalize DIRECTORY_SEPARATOR
+ $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}#', '#[\\\\/][.][\\\\/]#', '#[\\\\/]([^\\\\/.]+)[\\\\/][.][.][\\\\/]#'),
- DIRECTORY_SEPARATOR, $path, -1, $count);
- } while($count > 0);
+ array('#[\\\\/]{2}#', '#[\\\\/][.][\\\\/]#', '#[\\\\/]([^\\\\/.]+)[\\\\/][.][.][\\\\/]#'),
+ DIRECTORY_SEPARATOR,
+ $path,
+ -1,
+ $count
+ );
+ } while ($count > 0);
return $realpath !== false ? $parts[ 'root' ] . $path : str_ireplace(getcwd(), '.', $parts[ 'root' ] . $path);
}
@@ -1254,23 +1337,22 @@ class Smarty extends Smarty_Internal_TemplateBase
* Calls the appropriate getter function.
* Issues an E_USER_NOTICE if no valid getter is found.
*
- * @param string $name property name
+ * @param string $name property name
*
* @return mixed
- * @throws \SmartyException
*/
public function __get($name)
{
if (isset($this->accessMap[ $name ])) {
$method = 'get' . $this->accessMap[ $name ];
return $this->{$method}();
- } else {if (isset($this->_cache[ $name ])) {
+ } elseif (isset($this->_cache[ $name ])) {
return $this->_cache[ $name ];
- } else {if (in_array($name, $this->obsoleteProperties)) {
+ } elseif (in_array($name, $this->obsoleteProperties)) {
return null;
} else {
trigger_error('Undefined property: ' . get_class($this) . '::$' . $name, E_USER_NOTICE);
- }}}
+ }
return null;
}
@@ -1282,22 +1364,19 @@ class Smarty extends Smarty_Internal_TemplateBase
* @param string $name property name
* @param mixed $value parameter passed to setter
*
- * @throws \SmartyException
*/
public function __set($name, $value)
{
if (isset($this->accessMap[ $name ])) {
$method = 'set' . $this->accessMap[ $name ];
$this->{$method}($value);
- } else {if (in_array($name, $this->obsoleteProperties)) {
+ } elseif (in_array($name, $this->obsoleteProperties)) {
return;
+ } elseif (is_object($value) && method_exists($value, $name)) {
+ $this->$name = $value;
} else {
- if (is_object($value) && method_exists($value, $name)) {
- $this->$name = $value;
- } else {
- trigger_error('Undefined property: ' . get_class($this) . '::$' . $name, E_USER_NOTICE);
- }
- }}
+ trigger_error('Undefined property: ' . get_class($this) . '::$' . $name, E_USER_NOTICE);
+ }
}
/**
@@ -1320,7 +1399,6 @@ class Smarty extends Smarty_Internal_TemplateBase
* Normalize template_dir or config_dir
*
* @param bool $isConfig true for config_dir
- *
*/
private function _normalizeTemplateConfig($isConfig)
{
diff --git a/libs/SmartyBC.class.php b/libs/SmartyBC.class.php
index f2230fc9..836f9815 100644
--- a/libs/SmartyBC.class.php
+++ b/libs/SmartyBC.class.php
@@ -28,7 +28,7 @@
/**
* @ignore
*/
-require_once(dirname(__FILE__) . '/Smarty.class.php');
+require_once dirname(__FILE__) . '/Smarty.class.php';
/**
* Smarty Backward Compatibility Wrapper Class
@@ -53,7 +53,6 @@ class SmartyBC extends Smarty
/**
* Initialize new SmartyBC object
- *
*/
public function __construct()
{
@@ -127,12 +126,16 @@ class SmartyBC extends Smarty
* @param boolean $smarty_args smarty argument format, else traditional
* @param array $block_methods list of methods that are block format
*
- * @throws SmartyException
+ * @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,
- $block_methods = array())
- {
+ public function register_object(
+ $object,
+ $object_impl,
+ $allowed = array(),
+ $smarty_args = true,
+ $block_methods = array()
+ ) {
settype($allowed, 'array');
settype($smarty_args, 'boolean');
$this->registerObject($object, $object_impl, $allowed, $smarty_args, $block_methods);
@@ -326,10 +329,10 @@ class SmartyBC extends Smarty
/**
* clear cached content for the given template and cache id
*
- * @param string $tpl_file name of template file
- * @param string $cache_id name of cache_id
- * @param string $compile_id name of compile_id
- * @param string $exp_time expiration time
+ * @param string $tpl_file name of template file
+ * @param string $cache_id name of cache_id
+ * @param string $compile_id name of compile_id
+ * @param string $exp_time expiration time
*
* @return boolean
*/
@@ -341,7 +344,7 @@ class SmartyBC extends Smarty
/**
* clear the entire contents of cache (all templates)
*
- * @param string $exp_time expire time
+ * @param string $exp_time expire time
*
* @return boolean
*/
@@ -353,9 +356,9 @@ class SmartyBC extends Smarty
/**
* test to see if valid cache exists for this template
*
- * @param string $tpl_file name of template file
- * @param string $cache_id
- * @param string $compile_id
+ * @param string $tpl_file name of template file
+ * @param string $cache_id
+ * @param string $compile_id
*
* @return bool
* @throws \Exception
@@ -379,9 +382,9 @@ class SmartyBC extends Smarty
* or all compiled template files if one is not specified.
* This function is for advanced use only, not normally needed.
*
- * @param string $tpl_file
- * @param string $compile_id
- * @param string $exp_time
+ * @param string $tpl_file
+ * @param string $compile_id
+ * @param string $exp_time
*
* @return boolean results of {@link smarty_core_rm_auto()}
*/
@@ -393,7 +396,7 @@ class SmartyBC extends Smarty
/**
* Checks whether requested template exists.
*
- * @param string $tpl_file
+ * @param string $tpl_file
*
* @return bool
* @throws \SmartyException
@@ -406,7 +409,7 @@ class SmartyBC extends Smarty
/**
* Returns an array containing template variables
*
- * @param string $name
+ * @param string $name
*
* @return array
*/
@@ -418,7 +421,7 @@ class SmartyBC extends Smarty
/**
* Returns an array containing config variables
*
- * @param string $name
+ * @param string $name
*
* @return array
*/
@@ -442,7 +445,7 @@ class SmartyBC extends Smarty
/**
* return a reference to a registered object
*
- * @param string $name
+ * @param string $name
*
* @return object
*/
diff --git a/libs/bootstrap.php b/libs/bootstrap.php
index dad72fcb..2c830468 100644
--- a/libs/bootstrap.php
+++ b/libs/bootstrap.php
@@ -1,5 +1,5 @@
@@ -7,11 +7,10 @@
* 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')) {
- require dirname(__FILE__) . '/Autoloader.php';
+ include dirname(__FILE__) . '/Autoloader.php';
}
Smarty_Autoloader::register(true);
diff --git a/libs/debug.tpl b/libs/debug.tpl
index 5526cbca..edc7bef9 100644
--- a/libs/debug.tpl
+++ b/libs/debug.tpl
@@ -113,10 +113,10 @@
{foreach $template_data as $template}
{$template.name}
-
+
(compile {$template['compile_time']|string_format:"%.5f"}) (render {$template['render_time']|string_format:"%.5f"}) (cache {$template['cache_time']|string_format:"%.5f"})
-
+
{/foreach}
{/if}
@@ -127,7 +127,7 @@
{foreach $assigned_vars as $vars}
${$vars@key}
- {if isset($vars['nocache'])}Nocache{/if}
+ {if isset($vars['nocache'])}Nocache {/if}
{if isset($vars['scope'])}Origin: {$vars['scope']|debug_print_var nofilter}{/if}
|
Value{$vars['value']|debug_print_var:10:80 nofilter} |
diff --git a/libs/plugins/block.textformat.php b/libs/plugins/block.textformat.php
index 310a420e..5e494637 100644
--- a/libs/plugins/block.textformat.php
+++ b/libs/plugins/block.textformat.php
@@ -20,7 +20,6 @@
* - indent_char - string (" ")
* - wrap_boundary - boolean (true)
*
- *
* @link http://www.smarty.net/manual/en/language.function.textformat.php {textformat}
* (Smarty online manual)
*
@@ -39,10 +38,15 @@ function smarty_block_textformat($params, $content, Smarty_Internal_Template $te
return;
}
if (Smarty::$_MBSTRING) {
- $template->_checkPlugins(array(array('function' => 'smarty_modifier_mb_wordwrap',
- 'file' => SMARTY_PLUGINS_DIR . 'modifier.mb_wordwrap.php')));
+ $template->_checkPlugins(
+ array(
+ array(
+ 'function' => 'smarty_modifier_mb_wordwrap',
+ 'file' => SMARTY_PLUGINS_DIR . 'modifier.mb_wordwrap.php'
+ )
+ )
+ );
}
-
$style = null;
$indent = 0;
$indent_first = 0;
@@ -51,47 +55,48 @@ function smarty_block_textformat($params, $content, Smarty_Internal_Template $te
$wrap_char = "\n";
$wrap_cut = false;
$assign = null;
-
foreach ($params as $_key => $_val) {
switch ($_key) {
case 'style':
case 'indent_char':
case 'wrap_char':
case 'assign':
- $$_key = (string) $_val;
+ $$_key = (string)$_val;
break;
-
case 'indent':
case 'indent_first':
case 'wrap':
- $$_key = (int) $_val;
+ $$_key = (int)$_val;
break;
-
case 'wrap_cut':
- $$_key = (bool) $_val;
+ $$_key = (bool)$_val;
break;
-
default:
trigger_error("textformat: unknown attribute '{$_key}'");
}
}
-
if ($style === 'email') {
$wrap = 72;
}
// split into paragraphs
$_paragraphs = preg_split('![\r\n]{2}!', $content);
-
foreach ($_paragraphs as &$_paragraph) {
if (!$_paragraph) {
continue;
}
// convert mult. spaces & special chars to single space
$_paragraph =
- preg_replace(array('!\s+!' . Smarty::$_UTF8_MODIFIER,
- '!(^\s+)|(\s+$)!' . Smarty::$_UTF8_MODIFIER),
- array(' ',
- ''), $_paragraph);
+ preg_replace(
+ array(
+ '!\s+!' . Smarty::$_UTF8_MODIFIER,
+ '!(^\s+)|(\s+$)!' . Smarty::$_UTF8_MODIFIER
+ ),
+ array(
+ ' ',
+ ''
+ ),
+ $_paragraph
+ );
// indent first line
if ($indent_first > 0) {
$_paragraph = str_repeat($indent_char, $indent_first) . $_paragraph;
@@ -108,7 +113,6 @@ function smarty_block_textformat($params, $content, Smarty_Internal_Template $te
}
}
$_output = implode($wrap_char . $wrap_char, $_paragraphs);
-
if ($assign) {
$template->assign($assign, $_output);
} else {
diff --git a/libs/plugins/function.counter.php b/libs/plugins/function.counter.php
index 9610362d..a4129e77 100644
--- a/libs/plugins/function.counter.php
+++ b/libs/plugins/function.counter.php
@@ -5,7 +5,6 @@
* @package Smarty
* @subpackage PluginsFunction
*/
-
/**
* Smarty {counter} function plugin
* Type: function
@@ -24,50 +23,40 @@
function smarty_function_counter($params, $template)
{
static $counters = array();
-
$name = (isset($params[ 'name' ])) ? $params[ 'name' ] : 'default';
if (!isset($counters[ $name ])) {
$counters[ $name ] = array('start' => 1, 'skip' => 1, 'direction' => 'up', 'count' => 1);
}
$counter =& $counters[ $name ];
-
if (isset($params[ 'start' ])) {
- $counter[ 'start' ] = $counter[ 'count' ] = (int) $params[ 'start' ];
+ $counter[ 'start' ] = $counter[ 'count' ] = (int)$params[ 'start' ];
}
-
if (!empty($params[ 'assign' ])) {
$counter[ 'assign' ] = $params[ 'assign' ];
}
-
if (isset($counter[ 'assign' ])) {
$template->assign($counter[ 'assign' ], $counter[ 'count' ]);
}
-
if (isset($params[ 'print' ])) {
- $print = (bool) $params[ 'print' ];
+ $print = (bool)$params[ 'print' ];
} else {
$print = empty($counter[ 'assign' ]);
}
-
if ($print) {
$retval = $counter[ 'count' ];
} else {
$retval = null;
}
-
if (isset($params[ 'skip' ])) {
$counter[ 'skip' ] = $params[ 'skip' ];
}
-
if (isset($params[ 'direction' ])) {
$counter[ 'direction' ] = $params[ 'direction' ];
}
-
if ($counter[ 'direction' ] === 'down') {
$counter[ 'count' ] -= $counter[ 'skip' ];
} else {
$counter[ 'count' ] += $counter[ 'skip' ];
}
-
return $retval;
}
diff --git a/libs/plugins/function.cycle.php b/libs/plugins/function.cycle.php
index b871524f..07ffcc5e 100644
--- a/libs/plugins/function.cycle.php
+++ b/libs/plugins/function.cycle.php
@@ -5,7 +5,6 @@
* @package Smarty
* @subpackage PluginsFunction
*/
-
/**
* Smarty {cycle} function plugin
* Type: function
@@ -29,34 +28,29 @@
* {cycle name=row values="one,two,three" reset=true}
* {cycle name=row}
*
- *
- * @link http://www.smarty.net/manual/en/language.function.cycle.php {cycle}
+ * @link http://www.smarty.net/manual/en/language.function.cycle.php {cycle}
* (Smarty online manual)
- * @author Monte Ohrt
- * @author credit to Mark Priatel
- * @author credit to Gerard
- * @author credit to Jason Sweat
- * @version 1.3
+ * @author Monte Ohrt
+ * @author credit to Mark Priatel
+ * @author credit to Gerard
+ * @author credit to Jason Sweat
+ * @version 1.3
*
* @param array $params parameters
* @param Smarty_Internal_Template $template template object
*
* @return string|null
*/
-
function smarty_function_cycle($params, $template)
{
static $cycle_vars;
-
$name = (empty($params[ 'name' ])) ? 'default' : $params[ 'name' ];
- $print = (isset($params[ 'print' ])) ? (bool) $params[ 'print' ] : true;
- $advance = (isset($params[ 'advance' ])) ? (bool) $params[ 'advance' ] : true;
- $reset = (isset($params[ 'reset' ])) ? (bool) $params[ 'reset' ] : false;
-
+ $print = (isset($params[ 'print' ])) ? (bool)$params[ 'print' ] : true;
+ $advance = (isset($params[ 'advance' ])) ? (bool)$params[ 'advance' ] : true;
+ $reset = (isset($params[ 'reset' ])) ? (bool)$params[ 'reset' ] : false;
if (!isset($params[ 'values' ])) {
if (!isset($cycle_vars[ $name ][ 'values' ])) {
trigger_error('cycle: missing \'values\' parameter');
-
return;
}
} else {
@@ -65,41 +59,34 @@ function smarty_function_cycle($params, $template)
}
$cycle_vars[ $name ][ 'values' ] = $params[ 'values' ];
}
-
if (isset($params[ 'delimiter' ])) {
$cycle_vars[ $name ][ 'delimiter' ] = $params[ 'delimiter' ];
} elseif (!isset($cycle_vars[ $name ][ 'delimiter' ])) {
$cycle_vars[ $name ][ 'delimiter' ] = ',';
}
-
if (is_array($cycle_vars[ $name ][ 'values' ])) {
$cycle_array = $cycle_vars[ $name ][ 'values' ];
} else {
$cycle_array = explode($cycle_vars[ $name ][ 'delimiter' ], $cycle_vars[ $name ][ 'values' ]);
}
-
if (!isset($cycle_vars[ $name ][ 'index' ]) || $reset) {
$cycle_vars[ $name ][ 'index' ] = 0;
}
-
if (isset($params[ 'assign' ])) {
$print = false;
$template->assign($params[ 'assign' ], $cycle_array[ $cycle_vars[ $name ][ 'index' ] ]);
}
-
if ($print) {
$retval = $cycle_array[ $cycle_vars[ $name ][ 'index' ] ];
} else {
$retval = null;
}
-
if ($advance) {
if ($cycle_vars[ $name ][ 'index' ] >= count($cycle_array) - 1) {
$cycle_vars[ $name ][ 'index' ] = 0;
} else {
- $cycle_vars[ $name ][ 'index' ] ++;
+ $cycle_vars[ $name ][ 'index' ]++;
}
}
-
return $retval;
}
diff --git a/libs/plugins/function.fetch.php b/libs/plugins/function.fetch.php
index 9539e1fc..768761b2 100644
--- a/libs/plugins/function.fetch.php
+++ b/libs/plugins/function.fetch.php
@@ -5,7 +5,6 @@
* @package Smarty
* @subpackage PluginsFunction
*/
-
/**
* Smarty {fetch} plugin
* Type: function
@@ -26,20 +25,16 @@ function smarty_function_fetch($params, $template)
{
if (empty($params[ 'file' ])) {
trigger_error('[plugin] fetch parameter \'file\' cannot be empty', E_USER_NOTICE);
-
return;
}
-
// strip file protocol
if (stripos($params[ 'file' ], 'file://') === 0) {
$params[ 'file' ] = substr($params[ 'file' ], 7);
}
-
$protocol = strpos($params[ 'file' ], '://');
if ($protocol !== false) {
$protocol = strtolower(substr($params[ 'file' ], 0, $protocol));
}
-
if (isset($template->smarty->security_policy)) {
if ($protocol) {
// remote resource (or php stream, …)
@@ -53,7 +48,6 @@ function smarty_function_fetch($params, $template)
}
}
}
-
$content = '';
if ($protocol === 'http') {
// http fetch
@@ -104,7 +98,6 @@ function smarty_function_fetch($params, $template)
if (!empty($param_value)) {
if (!preg_match('![\w\d-]+: .+!', $param_value)) {
trigger_error("[plugin] invalid header format '{$param_value}'", E_USER_NOTICE);
-
return;
} else {
$extra_headers[] = $param_value;
@@ -118,10 +111,9 @@ function smarty_function_fetch($params, $template)
break;
case 'proxy_port':
if (!preg_match('!\D!', $param_value)) {
- $proxy_port = (int) $param_value;
+ $proxy_port = (int)$param_value;
} else {
trigger_error("[plugin] invalid value for attribute '{$param_key }'", E_USER_NOTICE);
-
return;
}
break;
@@ -137,16 +129,14 @@ function smarty_function_fetch($params, $template)
break;
case 'timeout':
if (!preg_match('!\D!', $param_value)) {
- $timeout = (int) $param_value;
+ $timeout = (int)$param_value;
} else {
trigger_error("[plugin] invalid value for attribute '{$param_key}'", E_USER_NOTICE);
-
return;
}
break;
default:
trigger_error("[plugin] unrecognized attribute '{$param_key}'", E_USER_NOTICE);
-
return;
}
}
@@ -156,10 +146,8 @@ function smarty_function_fetch($params, $template)
} else {
$fp = fsockopen($server_name, $port, $errno, $errstr, $timeout);
}
-
if (!$fp) {
trigger_error("[plugin] unable to fetch: $errstr ($errno)", E_USER_NOTICE);
-
return;
} else {
if ($_is_proxy) {
@@ -187,23 +175,19 @@ function smarty_function_fetch($params, $template)
if (!empty($user) && !empty($pass)) {
fputs($fp, 'Authorization: BASIC ' . base64_encode("$user:$pass") . "\r\n");
}
-
fputs($fp, "\r\n");
while (!feof($fp)) {
$content .= fgets($fp, 4096);
}
fclose($fp);
$csplit = preg_split("!\r\n\r\n!", $content, 2);
-
$content = $csplit[ 1 ];
-
if (!empty($params[ 'assign_headers' ])) {
$template->assign($params[ 'assign_headers' ], preg_split("!\r\n!", $csplit[ 0 ]));
}
}
} else {
trigger_error("[plugin fetch] unable to parse URL, check syntax", E_USER_NOTICE);
-
return;
}
} else {
@@ -212,7 +196,6 @@ function smarty_function_fetch($params, $template)
throw new SmartyException("{fetch} cannot read resource '" . $params[ 'file' ] . "'");
}
}
-
if (!empty($params[ 'assign' ])) {
$template->assign($params[ 'assign' ], $content);
} else {
diff --git a/libs/plugins/function.html_checkboxes.php b/libs/plugins/function.html_checkboxes.php
index d654caba..302358ed 100644
--- a/libs/plugins/function.html_checkboxes.php
+++ b/libs/plugins/function.html_checkboxes.php
@@ -29,25 +29,29 @@
* - assign (optional) - assign the output as an array to this variable
* - escape (optional) - escape the content (not value), defaults to true
*
- *
- * @link http://www.smarty.net/manual/en/language.function.html.checkboxes.php {html_checkboxes}
+ * @link http://www.smarty.net/manual/en/language.function.html.checkboxes.php {html_checkboxes}
* (Smarty online manual)
- * @author Christopher Kvarme
- * @author credits to Monte Ohrt
- * @version 1.0
+ * @author Christopher Kvarme
+ * @author credits to Monte Ohrt
+ * @version 1.0
*
* @param array $params parameters
* @param Smarty_Internal_Template $template template object
*
* @return string
- * @uses smarty_function_escape_special_chars()
+ * @uses smarty_function_escape_special_chars()
* @throws \SmartyException
*/
function smarty_function_html_checkboxes($params, Smarty_Internal_Template $template)
{
- $template->_checkPlugins(array(array('function' => 'smarty_function_escape_special_chars',
- 'file' => SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php')));
-
+ $template->_checkPlugins(
+ array(
+ array(
+ 'function' => 'smarty_function_escape_special_chars',
+ 'file' => SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'
+ )
+ )
+ );
$name = 'checkbox';
$values = null;
$options = null;
@@ -57,31 +61,25 @@ function smarty_function_html_checkboxes($params, Smarty_Internal_Template $temp
$labels = true;
$label_ids = false;
$output = null;
-
$extra = '';
-
foreach ($params as $_key => $_val) {
switch ($_key) {
case 'name':
case 'separator':
- $$_key = (string) $_val;
+ $$_key = (string)$_val;
break;
-
case 'escape':
case 'labels':
case 'label_ids':
- $$_key = (bool) $_val;
+ $$_key = (bool)$_val;
break;
-
case 'options':
- $$_key = (array) $_val;
+ $$_key = (array)$_val;
break;
-
case 'values':
case 'output':
- $$_key = array_values((array) $_val);
+ $$_key = array_values((array)$_val);
break;
-
case 'checked':
case 'selected':
if (is_array($_val)) {
@@ -89,57 +87,61 @@ function smarty_function_html_checkboxes($params, Smarty_Internal_Template $temp
foreach ($_val as $_sel) {
if (is_object($_sel)) {
if (method_exists($_sel, '__toString')) {
- $_sel = smarty_function_escape_special_chars((string) $_sel->__toString());
+ $_sel = smarty_function_escape_special_chars((string)$_sel->__toString());
} else {
- trigger_error('html_checkboxes: selected attribute contains an object of class \'' .
- get_class($_sel) . '\' without __toString() method', E_USER_NOTICE);
+ trigger_error(
+ 'html_checkboxes: selected attribute contains an object of class \'' .
+ get_class($_sel) . '\' without __toString() method',
+ E_USER_NOTICE
+ );
continue;
}
} else {
- $_sel = smarty_function_escape_special_chars((string) $_sel);
+ $_sel = smarty_function_escape_special_chars((string)$_sel);
}
$selected[ $_sel ] = true;
}
} elseif (is_object($_val)) {
if (method_exists($_val, '__toString')) {
- $selected = smarty_function_escape_special_chars((string) $_val->__toString());
+ $selected = smarty_function_escape_special_chars((string)$_val->__toString());
} else {
- trigger_error('html_checkboxes: selected attribute is an object of class \'' . get_class($_val) .
- '\' without __toString() method', E_USER_NOTICE);
+ trigger_error(
+ 'html_checkboxes: selected attribute is an object of class \'' . get_class($_val) .
+ '\' without __toString() method',
+ E_USER_NOTICE
+ );
}
} else {
- $selected = smarty_function_escape_special_chars((string) $_val);
+ $selected = smarty_function_escape_special_chars((string)$_val);
}
break;
-
case 'checkboxes':
- trigger_error('html_checkboxes: the use of the "checkboxes" attribute is deprecated, use "options" instead',
- E_USER_WARNING);
- $options = (array) $_val;
+ trigger_error(
+ 'html_checkboxes: the use of the "checkboxes" attribute is deprecated, use "options" instead',
+ E_USER_WARNING
+ );
+ $options = (array)$_val;
break;
-
case 'assign':
break;
-
case 'strict':
break;
-
case 'disabled':
case 'readonly':
if (!empty($params[ 'strict' ])) {
if (!is_scalar($_val)) {
- trigger_error("html_options: {$_key} attribute must be a scalar, only boolean true or string '{$_key}' will actually add the attribute",
- E_USER_NOTICE);
+ trigger_error(
+ "html_options: {$_key} attribute must be a scalar, only boolean true or string '{$_key}' will actually add the attribute",
+ E_USER_NOTICE
+ );
}
-
if ($_val === true || $_val === $_key) {
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_key) . '"';
}
-
break;
}
// omit break; to fall through!
-
+ // no break
default:
if (!is_array($_val)) {
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
@@ -149,34 +151,49 @@ function smarty_function_html_checkboxes($params, Smarty_Internal_Template $temp
break;
}
}
-
if (!isset($options) && !isset($values)) {
return '';
} /* raise error here? */
-
$_html_result = array();
-
if (isset($options)) {
foreach ($options as $_key => $_val) {
$_html_result[] =
- smarty_function_html_checkboxes_output($name, $_key, $_val, $selected, $extra, $separator, $labels,
- $label_ids, $escape);
+ smarty_function_html_checkboxes_output(
+ $name,
+ $_key,
+ $_val,
+ $selected,
+ $extra,
+ $separator,
+ $labels,
+ $label_ids,
+ $escape
+ );
}
} else {
foreach ($values as $_i => $_key) {
$_val = isset($output[ $_i ]) ? $output[ $_i ] : '';
$_html_result[] =
- smarty_function_html_checkboxes_output($name, $_key, $_val, $selected, $extra, $separator, $labels,
- $label_ids, $escape);
+ smarty_function_html_checkboxes_output(
+ $name,
+ $_key,
+ $_val,
+ $selected,
+ $extra,
+ $separator,
+ $labels,
+ $label_ids,
+ $escape
+ );
}
}
-
if (!empty($params[ 'assign' ])) {
$template->assign($params[ 'assign' ], $_html_result);
} else {
return implode("\n", $_html_result);
}
}
+
/**
* @param $name
* @param $value
@@ -190,59 +207,69 @@ function smarty_function_html_checkboxes($params, Smarty_Internal_Template $temp
*
* @return string
*/
-function smarty_function_html_checkboxes_output($name, $value, $output, $selected, $extra, $separator, $labels,
- $label_ids, $escape = true)
-{
+function smarty_function_html_checkboxes_output(
+ $name,
+ $value,
+ $output,
+ $selected,
+ $extra,
+ $separator,
+ $labels,
+ $label_ids,
+ $escape = true
+) {
$_output = '';
-
if (is_object($value)) {
if (method_exists($value, '__toString')) {
- $value = (string) $value->__toString();
+ $value = (string)$value->__toString();
} else {
- trigger_error('html_options: value is an object of class \'' . get_class($value) .
- '\' without __toString() method', E_USER_NOTICE);
-
+ trigger_error(
+ 'html_options: value is an object of class \'' . get_class($value) .
+ '\' without __toString() method',
+ E_USER_NOTICE
+ );
return '';
}
} else {
- $value = (string) $value;
+ $value = (string)$value;
}
-
if (is_object($output)) {
if (method_exists($output, '__toString')) {
- $output = (string) $output->__toString();
+ $output = (string)$output->__toString();
} else {
- trigger_error('html_options: output is an object of class \'' . get_class($output) .
- '\' without __toString() method', E_USER_NOTICE);
-
+ trigger_error(
+ 'html_options: output is an object of class \'' . get_class($output) .
+ '\' without __toString() method',
+ E_USER_NOTICE
+ );
return '';
}
} else {
- $output = (string) $output;
+ $output = (string)$output;
}
-
if ($labels) {
if ($label_ids) {
- $_id = smarty_function_escape_special_chars(preg_replace('![^\w\-\.]!' . Smarty::$_UTF8_MODIFIER, '_',
- $name . '_' . $value));
+ $_id = smarty_function_escape_special_chars(
+ preg_replace(
+ '![^\w\-\.]!' . Smarty::$_UTF8_MODIFIER,
+ '_',
+ $name . '_' . $value
+ )
+ );
$_output .= '