mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 02:14:26 +02:00
- reformating for PSR-2 coding standards https://github.com/smarty-php/smarty/pull/483
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
===== 3.1.33-dev-9 =====
|
===== 3.1.33-dev-10 =====
|
||||||
31.08.2018
|
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
|
- 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
|
like C:/ at Smarty > 3.1.33-dev-5 https://github.com/smarty-php/smarty/issues/451
|
||||||
|
|
||||||
|
@@ -4,31 +4,32 @@
|
|||||||
*
|
*
|
||||||
* @package Example-application
|
* @package Example-application
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require '../libs/Smarty.class.php';
|
require '../libs/Smarty.class.php';
|
||||||
|
|
||||||
$smarty = new Smarty;
|
$smarty = new Smarty;
|
||||||
|
|
||||||
//$smarty->force_compile = true;
|
//$smarty->force_compile = true;
|
||||||
$smarty->debugging = true;
|
$smarty->debugging = true;
|
||||||
$smarty->caching = true;
|
$smarty->caching = true;
|
||||||
$smarty->cache_lifetime = 120;
|
$smarty->cache_lifetime = 120;
|
||||||
|
|
||||||
$smarty->assign("Name", "Fred Irving Johnathan Bradley Peppergill", true);
|
$smarty->assign("Name", "Fred Irving Johnathan Bradley Peppergill", true);
|
||||||
$smarty->assign("FirstName", array("John", "Mary", "James", "Henry"));
|
$smarty->assign("FirstName", array("John", "Mary", "James", "Henry"));
|
||||||
$smarty->assign("LastName", array("Doe", "Smith", "Johnson", "Case"));
|
$smarty->assign("LastName", array("Doe", "Smith", "Johnson", "Case"));
|
||||||
$smarty->assign(
|
$smarty->assign(
|
||||||
"Class", array(array("A", "B", "C", "D"), array("E", "F", "G", "H"), array("I", "J", "K", "L"),
|
"Class",
|
||||||
array("M", "N", "O", "P"))
|
array(
|
||||||
|
array("A", "B", "C", "D"),
|
||||||
|
array("E", "F", "G", "H"),
|
||||||
|
array("I", "J", "K", "L"),
|
||||||
|
array("M", "N", "O", "P")
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$smarty->assign(
|
$smarty->assign(
|
||||||
"contacts", array(array("phone" => "1", "fax" => "2", "cell" => "3"),
|
"contacts",
|
||||||
array("phone" => "555-4444", "fax" => "555-3333", "cell" => "760-1234"))
|
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_values", array("NY", "NE", "KS", "IA", "OK", "TX"));
|
||||||
$smarty->assign("option_output", array("New York", "Nebraska", "Kansas", "Iowa", "Oklahoma", "Texas"));
|
$smarty->assign("option_output", array("New York", "Nebraska", "Kansas", "Iowa", "Oklahoma", "Texas"));
|
||||||
$smarty->assign("option_selected", "NE");
|
$smarty->assign("option_selected", "NE");
|
||||||
|
|
||||||
$smarty->display('index.tpl');
|
$smarty->display('index.tpl');
|
||||||
|
@@ -39,7 +39,6 @@ class Smarty_CacheResource_Apc extends Smarty_CacheResource_KeyValueStore
|
|||||||
foreach ($res as $k => $v) {
|
foreach ($res as $k => $v) {
|
||||||
$_res[ $k ] = $v;
|
$_res[ $k ] = $v;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $_res;
|
return $_res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,7 +55,6 @@ class Smarty_CacheResource_Apc extends Smarty_CacheResource_KeyValueStore
|
|||||||
foreach ($keys as $k => $v) {
|
foreach ($keys as $k => $v) {
|
||||||
apc_store($k, $v, $expire);
|
apc_store($k, $v, $expire);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,7 +70,6 @@ class Smarty_CacheResource_Apc extends Smarty_CacheResource_KeyValueStore
|
|||||||
foreach ($keys as $k) {
|
foreach ($keys as $k) {
|
||||||
apc_delete($k);
|
apc_delete($k);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -19,6 +19,9 @@ class Smarty_CacheResource_Memcache extends Smarty_CacheResource_KeyValueStore
|
|||||||
*/
|
*/
|
||||||
protected $memcache = null;
|
protected $memcache = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smarty_CacheResource_Memcache constructor.
|
||||||
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
if (class_exists('Memcached')) {
|
if (class_exists('Memcached')) {
|
||||||
@@ -50,7 +53,6 @@ class Smarty_CacheResource_Memcache extends Smarty_CacheResource_KeyValueStore
|
|||||||
foreach ($res as $k => $v) {
|
foreach ($res as $k => $v) {
|
||||||
$_res[ $lookup[ $k ] ] = $v;
|
$_res[ $lookup[ $k ] ] = $v;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $_res;
|
return $_res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,7 +70,6 @@ class Smarty_CacheResource_Memcache extends Smarty_CacheResource_KeyValueStore
|
|||||||
$k = sha1($k);
|
$k = sha1($k);
|
||||||
$this->memcache->set($k, $v, 0, $expire);
|
$this->memcache->set($k, $v, 0, $expire);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,7 +86,6 @@ class Smarty_CacheResource_Memcache extends Smarty_CacheResource_KeyValueStore
|
|||||||
$k = sha1($k);
|
$k = sha1($k);
|
||||||
$this->memcache->delete($k);
|
$this->memcache->delete($k);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -24,13 +24,24 @@
|
|||||||
*/
|
*/
|
||||||
class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom
|
class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom
|
||||||
{
|
{
|
||||||
// PDO instance
|
/**
|
||||||
|
* @var \PDO
|
||||||
|
*/
|
||||||
protected $db;
|
protected $db;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var \PDOStatement
|
||||||
|
*/
|
||||||
protected $fetch;
|
protected $fetch;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var \PDOStatement
|
||||||
|
*/
|
||||||
protected $fetchTimestamp;
|
protected $fetchTimestamp;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var \PDOStatement
|
||||||
|
*/
|
||||||
protected $save;
|
protected $save;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -42,8 +53,7 @@ class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$this->db = new PDO("mysql:dbname=test;host=127.0.0.1", "smarty");
|
$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());
|
throw new SmartyException('Mysql Resource failed: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
$this->fetch = $this->db->prepare('SELECT modified, content FROM output_cache WHERE id = :id');
|
$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
|
* 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 $id unique cache content identifier
|
||||||
* @param string $name template name
|
* @param string $name template name
|
||||||
@@ -97,7 +108,6 @@ class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom
|
|||||||
$this->fetchTimestamp->execute(array('id' => $id));
|
$this->fetchTimestamp->execute(array('id' => $id));
|
||||||
$mtime = strtotime($this->fetchTimestamp->fetchColumn());
|
$mtime = strtotime($this->fetchTimestamp->fetchColumn());
|
||||||
$this->fetchTimestamp->closeCursor();
|
$this->fetchTimestamp->closeCursor();
|
||||||
|
|
||||||
return $mtime;
|
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)
|
protected function save($id, $name, $cache_id, $compile_id, $exp_time, $content)
|
||||||
{
|
{
|
||||||
$this->save->execute(
|
$this->save->execute(
|
||||||
array('id' => $id, 'name' => $name, 'cache_id' => $cache_id, 'compile_id' => $compile_id,
|
array('id' => $id,
|
||||||
'content' => $content,)
|
'name' => $name,
|
||||||
|
'cache_id' => $cache_id,
|
||||||
|
'compile_id' => $compile_id,
|
||||||
|
'content' => $content,)
|
||||||
);
|
);
|
||||||
|
|
||||||
return !!$this->save->rowCount();
|
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) {
|
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
|
||||||
$query = $this->db->query('TRUNCATE TABLE output_cache');
|
$query = $this->db->query('TRUNCATE TABLE output_cache');
|
||||||
|
return -1;
|
||||||
return - 1;
|
|
||||||
}
|
}
|
||||||
// build the filter
|
// build the filter
|
||||||
$where = array();
|
$where = array();
|
||||||
@@ -158,12 +169,15 @@ class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom
|
|||||||
}
|
}
|
||||||
// equal test cache_id and match sub-groups
|
// equal test cache_id and match sub-groups
|
||||||
if ($cache_id !== null) {
|
if ($cache_id !== null) {
|
||||||
$where[] = '(cache_id = ' . $this->db->quote($cache_id) . ' OR cache_id LIKE ' .
|
$where[] =
|
||||||
$this->db->quote($cache_id . '|%') . ')';
|
'(cache_id = ' .
|
||||||
|
$this->db->quote($cache_id) .
|
||||||
|
' OR cache_id LIKE ' .
|
||||||
|
$this->db->quote($cache_id . '|%') .
|
||||||
|
')';
|
||||||
}
|
}
|
||||||
// run delete query
|
// run delete query
|
||||||
$query = $this->db->query('DELETE FROM output_cache WHERE ' . join(' AND ', $where));
|
$query = $this->db->query('DELETE FROM output_cache WHERE ' . join(' AND ', $where));
|
||||||
|
|
||||||
return $query->rowCount();
|
return $query->rowCount();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -29,7 +29,10 @@
|
|||||||
*/
|
*/
|
||||||
class Smarty_CacheResource_Pdo extends Smarty_CacheResource_Custom
|
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
|
FROM %1$s
|
||||||
WHERE 1
|
WHERE 1
|
||||||
AND id = :id
|
AND id = :id
|
||||||
@@ -53,6 +56,10 @@ class Smarty_CacheResource_Pdo extends Smarty_CacheResource_Custom
|
|||||||
AND id = :id
|
AND id = :id
|
||||||
AND cache_id = :cache_id
|
AND cache_id = :cache_id
|
||||||
AND compile_id = :compile_id');
|
AND compile_id = :compile_id');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
protected $insertStatement = 'INSERT INTO %s
|
protected $insertStatement = 'INSERT INTO %s
|
||||||
|
|
||||||
SET id = :id,
|
SET id = :id,
|
||||||
@@ -70,25 +77,48 @@ class Smarty_CacheResource_Pdo extends Smarty_CacheResource_Custom
|
|||||||
modified = CURRENT_TIMESTAMP,
|
modified = CURRENT_TIMESTAMP,
|
||||||
expire = DATE_ADD(CURRENT_TIMESTAMP, INTERVAL :expire SECOND),
|
expire = DATE_ADD(CURRENT_TIMESTAMP, INTERVAL :expire SECOND),
|
||||||
content = :content';
|
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;
|
|
||||||
|
|
||||||
/*
|
/**
|
||||||
|
* @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
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param PDO $pdo PDO : active connection
|
* @param PDO $pdo PDO : active connection
|
||||||
* @param string $table : table (or view) name
|
* @param string $table : table (or view) name
|
||||||
* @param string $database : optional - if table is located in another db
|
* @param string $database : optional - if table is located in another db
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* Smarty_CacheResource_Pdo constructor.
|
|
||||||
*
|
|
||||||
* @param \PDO $pdo
|
|
||||||
* @param $table
|
|
||||||
* @param null $database
|
|
||||||
*
|
*
|
||||||
* @throws \SmartyException
|
* @throws \SmartyException
|
||||||
*/
|
*/
|
||||||
@@ -103,15 +133,15 @@ class Smarty_CacheResource_Pdo extends Smarty_CacheResource_Custom
|
|||||||
$this->fillStatementsWithTableName();
|
$this->fillStatementsWithTableName();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Fills the table name into the statements.
|
* Fills the table name into the statements.
|
||||||
*
|
*
|
||||||
* @return Current Instance
|
* @return $this Current Instance
|
||||||
* @access protected
|
* @access protected
|
||||||
*/
|
*/
|
||||||
protected function fillStatementsWithTableName()
|
protected function fillStatementsWithTableName()
|
||||||
{
|
{
|
||||||
foreach ($this->fetchStatements AS &$statement) {
|
foreach ($this->fetchStatements as &$statement) {
|
||||||
$statement = sprintf($statement, $this->getTableName(), '%s');
|
$statement = sprintf($statement, $this->getTableName(), '%s');
|
||||||
}
|
}
|
||||||
$this->insertStatement = sprintf($this->insertStatement, $this->getTableName());
|
$this->insertStatement = sprintf($this->insertStatement, $this->getTableName());
|
||||||
@@ -120,31 +150,34 @@ class Smarty_CacheResource_Pdo extends Smarty_CacheResource_Custom
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Gets the fetch statement, depending on what you specify
|
* 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 $columns : the column(s) name(s) you want to retrieve from the database
|
||||||
* @param string $id unique cache content identifier
|
* @param string $id unique cache content identifier
|
||||||
* @param string|null $cache_id cache id
|
* @param string|null $cache_id cache id
|
||||||
* @param string|null $compile_id compile id
|
* @param string|null $compile_id compile id
|
||||||
|
*
|
||||||
* @access protected
|
* @access protected
|
||||||
|
* @return \PDOStatement
|
||||||
*/
|
*/
|
||||||
protected function getFetchStatement($columns, $id, $cache_id = null, $compile_id = null)
|
protected function getFetchStatement($columns, $id, $cache_id = null, $compile_id = null)
|
||||||
{
|
{
|
||||||
|
$args = array();
|
||||||
if (!is_null($cache_id) && !is_null($compile_id)) {
|
if (!is_null($cache_id) && !is_null($compile_id)) {
|
||||||
$query = $this->fetchStatements[ 'withCacheIdAndCompileId' ] AND
|
$query = $this->fetchStatements[ 'withCacheIdAndCompileId' ] and
|
||||||
$args = Array('id' => $id, 'cache_id' => $cache_id, 'compile_id' => $compile_id);
|
$args = array('id' => $id, 'cache_id' => $cache_id, 'compile_id' => $compile_id);
|
||||||
} elseif (is_null($cache_id) && !is_null($compile_id)) {
|
} elseif (is_null($cache_id) && !is_null($compile_id)) {
|
||||||
$query = $this->fetchStatements[ 'withCompileId' ] AND
|
$query = $this->fetchStatements[ 'withCompileId' ] and
|
||||||
$args = Array('id' => $id, 'compile_id' => $compile_id);
|
$args = array('id' => $id, 'compile_id' => $compile_id);
|
||||||
} elseif (!is_null($cache_id) && is_null($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 {
|
} else {
|
||||||
$query = $this->fetchStatements[ 'default' ] AND $args = Array('id' => $id);
|
$query = $this->fetchStatements[ 'default' ] and $args = array('id' => $id);
|
||||||
}
|
}
|
||||||
$query = sprintf($query, $columns);
|
$query = sprintf($query, $columns);
|
||||||
$stmt = $this->pdo->prepare($query);
|
$stmt = $this->pdo->prepare($query);
|
||||||
foreach ($args AS $key => $value) {
|
foreach ($args as $key => $value) {
|
||||||
$stmt->bindValue($key, $value);
|
$stmt->bindValue($key, $value);
|
||||||
}
|
}
|
||||||
return $stmt;
|
return $stmt;
|
||||||
@@ -224,10 +257,11 @@ class Smarty_CacheResource_Pdo extends Smarty_CacheResource_Custom
|
|||||||
return !!$stmt->rowCount();
|
return !!$stmt->rowCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Encodes the content before saving to database
|
* Encodes the content before saving to database
|
||||||
*
|
*
|
||||||
* @param string $content
|
* @param string $content
|
||||||
|
*
|
||||||
* @return string $content
|
* @return string $content
|
||||||
* @access protected
|
* @access protected
|
||||||
*/
|
*/
|
||||||
@@ -236,10 +270,11 @@ class Smarty_CacheResource_Pdo extends Smarty_CacheResource_Custom
|
|||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Decodes the content before saving to database
|
* Decodes the content before saving to database
|
||||||
*
|
*
|
||||||
* @param string $content
|
* @param string $content
|
||||||
|
*
|
||||||
* @return string $content
|
* @return string $content
|
||||||
* @access protected
|
* @access protected
|
||||||
*/
|
*/
|
||||||
@@ -254,7 +289,7 @@ class Smarty_CacheResource_Pdo extends Smarty_CacheResource_Custom
|
|||||||
* @param string|null $name template name
|
* @param string|null $name template name
|
||||||
* @param string|null $cache_id cache id
|
* @param string|null $cache_id cache id
|
||||||
* @param string|null $compile_id compile 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
|
* @return integer number of deleted caches
|
||||||
* @access protected
|
* @access protected
|
||||||
@@ -275,8 +310,12 @@ class Smarty_CacheResource_Pdo extends Smarty_CacheResource_Custom
|
|||||||
}
|
}
|
||||||
// equal test cache_id and match sub-groups
|
// equal test cache_id and match sub-groups
|
||||||
if ($cache_id !== null) {
|
if ($cache_id !== null) {
|
||||||
$where[] = '(cache_id = ' . $this->pdo->quote($cache_id) . ' OR cache_id LIKE ' .
|
$where[] =
|
||||||
$this->pdo->quote($cache_id . '|%') . ')';
|
'(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) {
|
if ($compile_id !== null) {
|
||||||
@@ -305,4 +344,3 @@ class Smarty_CacheResource_Pdo extends Smarty_CacheResource_Custom
|
|||||||
return (is_null($this->database)) ? "`{$this->table}`" : "`{$this->database}`.`{$this->table}`";
|
return (is_null($this->database)) ? "`{$this->table}`" : "`{$this->database}`.`{$this->table}`";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
require_once 'cacheresource.pdo.php';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PDO Cache Handler with GZIP support
|
* PDO Cache Handler with GZIP support
|
||||||
@@ -11,15 +12,13 @@
|
|||||||
* @require Smarty_CacheResource_Pdo class
|
* @require Smarty_CacheResource_Pdo class
|
||||||
* @author Beno!t POLASZEK - 2014
|
* @author Beno!t POLASZEK - 2014
|
||||||
*/
|
*/
|
||||||
require_once 'cacheresource.pdo.php';
|
|
||||||
|
|
||||||
class Smarty_CacheResource_Pdo_Gzip extends Smarty_CacheResource_Pdo
|
class Smarty_CacheResource_Pdo_Gzip extends Smarty_CacheResource_Pdo
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
/*
|
|
||||||
* Encodes the content before saving to database
|
* Encodes the content before saving to database
|
||||||
*
|
*
|
||||||
* @param string $content
|
* @param string $content
|
||||||
|
*
|
||||||
* @return string $content
|
* @return string $content
|
||||||
* @access protected
|
* @access protected
|
||||||
*/
|
*/
|
||||||
@@ -28,10 +27,11 @@ class Smarty_CacheResource_Pdo_Gzip extends Smarty_CacheResource_Pdo
|
|||||||
return gzdeflate($content);
|
return gzdeflate($content);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Decodes the content before saving to database
|
* Decodes the content before saving to database
|
||||||
*
|
*
|
||||||
* @param string $content
|
* @param string $content
|
||||||
|
*
|
||||||
* @return string $content
|
* @return string $content
|
||||||
* @access protected
|
* @access protected
|
||||||
*/
|
*/
|
||||||
@@ -40,4 +40,3 @@ class Smarty_CacheResource_Pdo_Gzip extends Smarty_CacheResource_Pdo
|
|||||||
return gzinflate($content);
|
return gzinflate($content);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -32,15 +32,13 @@ class Smarty_Resource_Extendsall extends Smarty_Internal_Resource_Extends
|
|||||||
$sources[ $s->uid ] = $s;
|
$sources[ $s->uid ] = $s;
|
||||||
$uid .= $s->filepath;
|
$uid .= $s->filepath;
|
||||||
$timestamp = $s->timestamp > $timestamp ? $s->timestamp : $timestamp;
|
$timestamp = $s->timestamp > $timestamp ? $s->timestamp : $timestamp;
|
||||||
}
|
} catch (SmartyException $e) {
|
||||||
catch (SmartyException $e) {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!$sources) {
|
if (!$sources) {
|
||||||
$source->exists = false;
|
$source->exists = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sources = array_reverse($sources, true);
|
$sources = array_reverse($sources, true);
|
||||||
reset($sources);
|
reset($sources);
|
||||||
$s = current($sources);
|
$s = current($sources);
|
||||||
@@ -51,15 +49,14 @@ class Smarty_Resource_Extendsall extends Smarty_Internal_Resource_Extends
|
|||||||
$source->timestamp = $timestamp;
|
$source->timestamp = $timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Disable timestamp checks for extendsall resource.
|
* Disable timestamp checks for extendsall resource.
|
||||||
* The individual source components will be checked.
|
* The individual source components will be checked.
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool false
|
||||||
*/
|
*/
|
||||||
public function checkTimestamps()
|
public function checkTimestamps()
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -12,20 +12,34 @@
|
|||||||
* PRIMARY KEY (`name`)
|
* PRIMARY KEY (`name`)
|
||||||
* ) ENGINE=InnoDB DEFAULT CHARSET=utf8;</pre>
|
* ) ENGINE=InnoDB DEFAULT CHARSET=utf8;</pre>
|
||||||
* Demo data:
|
* Demo data:
|
||||||
* <pre>INSERT INTO `templates` (`name`, `modified`, `source`) VALUES ('test.tpl', "2010-12-25 22:00:00", '{$x="hello world"}{$x}');</pre>
|
* <pre>INSERT INTO `templates` (`name`, `modified`, `source`) VALUES ('test.tpl', "2010-12-25 22:00:00", '{$x="hello
|
||||||
|
* world"}{$x}');</pre>
|
||||||
|
*
|
||||||
*
|
*
|
||||||
* @package Resource-examples
|
* @package Resource-examples
|
||||||
* @author Rodney Rehm
|
* @author Rodney Rehm
|
||||||
*/
|
*/
|
||||||
class Smarty_Resource_Mysql extends Smarty_Resource_Custom
|
class Smarty_Resource_Mysql extends Smarty_Resource_Custom
|
||||||
{
|
{
|
||||||
// PDO instance
|
/**
|
||||||
|
* PDO instance
|
||||||
|
*
|
||||||
|
* @var \PDO
|
||||||
|
*/
|
||||||
protected $db;
|
protected $db;
|
||||||
|
|
||||||
// prepared fetch() statement
|
/**
|
||||||
|
* prepared fetch() statement
|
||||||
|
*
|
||||||
|
* @var \PDOStatement
|
||||||
|
*/
|
||||||
protected $fetch;
|
protected $fetch;
|
||||||
|
|
||||||
// prepared fetchTimestamp() statement
|
/**
|
||||||
|
* prepared fetchTimestamp() statement
|
||||||
|
*
|
||||||
|
* @var \PDOStatement
|
||||||
|
*/
|
||||||
protected $mtime;
|
protected $mtime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -37,8 +51,7 @@ class Smarty_Resource_Mysql extends Smarty_Resource_Custom
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$this->db = new PDO("mysql:dbname=test;host=127.0.0.1", "smarty");
|
$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());
|
throw new SmartyException('Mysql Resource failed: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
$this->fetch = $this->db->prepare('SELECT modified, source FROM templates WHERE name = :name');
|
$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
|
* 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
|
||||||
*
|
*
|
||||||
@@ -82,7 +96,6 @@ class Smarty_Resource_Mysql extends Smarty_Resource_Custom
|
|||||||
$this->mtime->execute(array('name' => $name));
|
$this->mtime->execute(array('name' => $name));
|
||||||
$mtime = $this->mtime->fetchColumn();
|
$mtime = $this->mtime->fetchColumn();
|
||||||
$this->mtime->closeCursor();
|
$this->mtime->closeCursor();
|
||||||
|
|
||||||
return strtotime($mtime);
|
return strtotime($mtime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -14,17 +14,27 @@
|
|||||||
* PRIMARY KEY (`name`)
|
* PRIMARY KEY (`name`)
|
||||||
* ) ENGINE=InnoDB DEFAULT CHARSET=utf8;</pre>
|
* ) ENGINE=InnoDB DEFAULT CHARSET=utf8;</pre>
|
||||||
* Demo data:
|
* Demo data:
|
||||||
* <pre>INSERT INTO `templates` (`name`, `modified`, `source`) VALUES ('test.tpl', "2010-12-25 22:00:00", '{$x="hello world"}{$x}');</pre>
|
* <pre>INSERT INTO `templates` (`name`, `modified`, `source`) VALUES ('test.tpl', "2010-12-25 22:00:00", '{$x="hello
|
||||||
|
* world"}{$x}');</pre>
|
||||||
|
*
|
||||||
*
|
*
|
||||||
* @package Resource-examples
|
* @package Resource-examples
|
||||||
* @author Rodney Rehm
|
* @author Rodney Rehm
|
||||||
*/
|
*/
|
||||||
class Smarty_Resource_Mysqls extends Smarty_Resource_Custom
|
class Smarty_Resource_Mysqls extends Smarty_Resource_Custom
|
||||||
{
|
{
|
||||||
// PDO instance
|
/**
|
||||||
|
* PDO instance
|
||||||
|
*
|
||||||
|
* @var \PDO
|
||||||
|
*/
|
||||||
protected $db;
|
protected $db;
|
||||||
|
|
||||||
// prepared fetch() statement
|
/**
|
||||||
|
* prepared fetch() statement
|
||||||
|
*
|
||||||
|
* @var \PDOStatement
|
||||||
|
*/
|
||||||
protected $fetch;
|
protected $fetch;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -36,8 +46,7 @@ class Smarty_Resource_Mysqls extends Smarty_Resource_Custom
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$this->db = new PDO("mysql:dbname=test;host=127.0.0.1", "smarty");
|
$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());
|
throw new SmartyException('Mysql Resource failed: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
$this->fetch = $this->db->prepare('SELECT modified, source FROM templates WHERE name = :name');
|
$this->fetch = $this->db->prepare('SELECT modified, source FROM templates WHERE name = :name');
|
||||||
|
@@ -112,7 +112,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
|||||||
/**
|
/**
|
||||||
* smarty version
|
* smarty version
|
||||||
*/
|
*/
|
||||||
const SMARTY_VERSION = '3.1.33-dev-9';
|
const SMARTY_VERSION = '3.1.33-dev-10';
|
||||||
/**
|
/**
|
||||||
* define variable scopes
|
* define variable scopes
|
||||||
*/
|
*/
|
||||||
@@ -650,18 +650,22 @@ class Smarty extends Smarty_Internal_TemplateBase
|
|||||||
*
|
*
|
||||||
* @var string[]
|
* @var string[]
|
||||||
*/
|
*/
|
||||||
protected $obsoleteProperties = array('resource_caching', 'template_resource_caching', 'direct_access_security',
|
protected $obsoleteProperties = array(
|
||||||
'_dir_perms', '_file_perms', 'plugin_search_order',
|
'resource_caching', 'template_resource_caching', 'direct_access_security',
|
||||||
'inheritance_merge_compiled_includes', 'resource_cache_mode',);
|
'_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
|
* List of private properties which will call getter/setter on a direct access
|
||||||
*
|
*
|
||||||
* @var string[]
|
* @var string[]
|
||||||
*/
|
*/
|
||||||
protected $accessMap = array('template_dir' => 'TemplateDir', 'config_dir' => 'ConfigDir',
|
protected $accessMap = array(
|
||||||
'plugins_dir' => 'PluginsDir', 'compile_dir' => 'CompileDir',
|
'template_dir' => 'TemplateDir', 'config_dir' => 'ConfigDir',
|
||||||
'cache_dir' => 'CacheDir',);
|
'plugins_dir' => 'PluginsDir', 'compile_dir' => 'CompileDir',
|
||||||
|
'cache_dir' => 'CacheDir',
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize new Smarty object
|
* Initialize new Smarty object
|
||||||
@@ -1074,13 +1078,13 @@ class Smarty extends Smarty_Internal_TemplateBase
|
|||||||
* @return string
|
* @return string
|
||||||
* @throws \SmartyException
|
* @throws \SmartyException
|
||||||
*/
|
*/
|
||||||
public function _getTemplateId($template_name,
|
public function _getTemplateId(
|
||||||
$cache_id = null,
|
$template_name,
|
||||||
$compile_id = null,
|
$cache_id = null,
|
||||||
$caching = null,
|
$compile_id = null,
|
||||||
Smarty_Internal_Template $template = null
|
$caching = null,
|
||||||
)
|
Smarty_Internal_Template $template = null
|
||||||
{
|
) {
|
||||||
$template_name = (strpos($template_name, ':') === false) ? "{$this->default_resource_type}:{$template_name}" :
|
$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;
|
$cache_id = $cache_id === null ? $this->cache_id : $cache_id;
|
||||||
@@ -1129,8 +1133,8 @@ class Smarty extends Smarty_Internal_TemplateBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// normalize DIRECTORY_SEPARATOR
|
// normalize DIRECTORY_SEPARATOR
|
||||||
$path = str_replace($nds[DIRECTORY_SEPARATOR], DIRECTORY_SEPARATOR, $path);
|
$path = str_replace($nds[ DIRECTORY_SEPARATOR ], DIRECTORY_SEPARATOR, $path);
|
||||||
$parts[ 'root' ] = str_replace($nds[DIRECTORY_SEPARATOR], DIRECTORY_SEPARATOR, $parts[ 'root' ]);
|
$parts[ 'root' ] = str_replace($nds[ DIRECTORY_SEPARATOR ], DIRECTORY_SEPARATOR, $parts[ 'root' ]);
|
||||||
do {
|
do {
|
||||||
$path = preg_replace(
|
$path = preg_replace(
|
||||||
array('#[\\\\/]{2}#', '#[\\\\/][.][\\\\/]#', '#[\\\\/]([^\\\\/.]+)[\\\\/][.][.][\\\\/]#'),
|
array('#[\\\\/]{2}#', '#[\\\\/][.][\\\\/]#', '#[\\\\/]([^\\\\/.]+)[\\\\/][.][.][\\\\/]#'),
|
||||||
|
@@ -129,7 +129,11 @@ class SmartyBC extends Smarty
|
|||||||
* @throws SmartyException
|
* @throws SmartyException
|
||||||
* @internal param array $block_functs list of methods that are block format
|
* @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()
|
$block_methods = array()
|
||||||
) {
|
) {
|
||||||
settype($allowed, 'array');
|
settype($allowed, 'array');
|
||||||
@@ -150,8 +154,8 @@ class SmartyBC extends Smarty
|
|||||||
/**
|
/**
|
||||||
* Registers block function to be used in templates
|
* Registers block function to be used in templates
|
||||||
*
|
*
|
||||||
* @param string $block name of template block
|
* @param string $block name of template block
|
||||||
* @param string $block_impl PHP function to register
|
* @param string $block_impl PHP function to register
|
||||||
* @param bool $cacheable
|
* @param bool $cacheable
|
||||||
* @param mixed $cache_attrs
|
* @param mixed $cache_attrs
|
||||||
*
|
*
|
||||||
@@ -352,7 +356,7 @@ class SmartyBC extends Smarty
|
|||||||
/**
|
/**
|
||||||
* test to see if valid cache exists for this template
|
* 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 $cache_id
|
||||||
* @param string $compile_id
|
* @param string $compile_id
|
||||||
*
|
*
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/**
|
||||||
* This file is part of the Smarty package.
|
* This file is part of the Smarty package.
|
||||||
*
|
*
|
||||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||||
@@ -7,8 +7,7 @@
|
|||||||
* For the full copyright and license information, please view the LICENSE
|
* For the full copyright and license information, please view the LICENSE
|
||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
/*
|
|
||||||
* Load and register Smarty Autoloader
|
* Load and register Smarty Autoloader
|
||||||
*/
|
*/
|
||||||
if (!class_exists('Smarty_Autoloader')) {
|
if (!class_exists('Smarty_Autoloader')) {
|
||||||
|
@@ -113,10 +113,10 @@
|
|||||||
<div>
|
<div>
|
||||||
{foreach $template_data as $template}
|
{foreach $template_data as $template}
|
||||||
<font color=brown>{$template.name}</font>
|
<font color=brown>{$template.name}</font>
|
||||||
<br> <span class="exectime">
|
<br /> <span class="exectime">
|
||||||
(compile {$template['compile_time']|string_format:"%.5f"}) (render {$template['render_time']|string_format:"%.5f"}) (cache {$template['cache_time']|string_format:"%.5f"})
|
(compile {$template['compile_time']|string_format:"%.5f"}) (render {$template['render_time']|string_format:"%.5f"}) (cache {$template['cache_time']|string_format:"%.5f"})
|
||||||
</span>
|
</span>
|
||||||
<br>
|
<br />
|
||||||
{/foreach}
|
{/foreach}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
@@ -127,7 +127,7 @@
|
|||||||
{foreach $assigned_vars as $vars}
|
{foreach $assigned_vars as $vars}
|
||||||
<tr class="{if $vars@iteration % 2 eq 0}odd{else}even{/if}">
|
<tr class="{if $vars@iteration % 2 eq 0}odd{else}even{/if}">
|
||||||
<td><h3><font color=blue>${$vars@key}</font></h3>
|
<td><h3><font color=blue>${$vars@key}</font></h3>
|
||||||
{if isset($vars['nocache'])}<b>Nocache</b><br>{/if}
|
{if isset($vars['nocache'])}<b>Nocache</b><br />{/if}
|
||||||
{if isset($vars['scope'])}<b>Origin:</b> {$vars['scope']|debug_print_var nofilter}{/if}
|
{if isset($vars['scope'])}<b>Origin:</b> {$vars['scope']|debug_print_var nofilter}{/if}
|
||||||
</td>
|
</td>
|
||||||
<td><h3>Value</h3>{$vars['value']|debug_print_var:10:80 nofilter}</td>
|
<td><h3>Value</h3>{$vars['value']|debug_print_var:10:80 nofilter}</td>
|
||||||
|
@@ -39,8 +39,12 @@ function smarty_block_textformat($params, $content, Smarty_Internal_Template $te
|
|||||||
}
|
}
|
||||||
if (Smarty::$_MBSTRING) {
|
if (Smarty::$_MBSTRING) {
|
||||||
$template->_checkPlugins(
|
$template->_checkPlugins(
|
||||||
array(array('function' => 'smarty_modifier_mb_wordwrap',
|
array(
|
||||||
'file' => SMARTY_PLUGINS_DIR . 'modifier.mb_wordwrap.php'))
|
array(
|
||||||
|
'function' => 'smarty_modifier_mb_wordwrap',
|
||||||
|
'file' => SMARTY_PLUGINS_DIR . 'modifier.mb_wordwrap.php'
|
||||||
|
)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$style = null;
|
$style = null;
|
||||||
@@ -83,10 +87,14 @@ function smarty_block_textformat($params, $content, Smarty_Internal_Template $te
|
|||||||
// convert mult. spaces & special chars to single space
|
// convert mult. spaces & special chars to single space
|
||||||
$_paragraph =
|
$_paragraph =
|
||||||
preg_replace(
|
preg_replace(
|
||||||
array('!\s+!' . Smarty::$_UTF8_MODIFIER,
|
array(
|
||||||
'!(^\s+)|(\s+$)!' . Smarty::$_UTF8_MODIFIER),
|
'!\s+!' . Smarty::$_UTF8_MODIFIER,
|
||||||
array(' ',
|
'!(^\s+)|(\s+$)!' . Smarty::$_UTF8_MODIFIER
|
||||||
''),
|
),
|
||||||
|
array(
|
||||||
|
' ',
|
||||||
|
''
|
||||||
|
),
|
||||||
$_paragraph
|
$_paragraph
|
||||||
);
|
);
|
||||||
// indent first line
|
// indent first line
|
||||||
|
@@ -5,7 +5,6 @@
|
|||||||
* @package Smarty
|
* @package Smarty
|
||||||
* @subpackage PluginsFunction
|
* @subpackage PluginsFunction
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty {counter} function plugin
|
* Smarty {counter} function plugin
|
||||||
* Type: function
|
* Type: function
|
||||||
@@ -24,50 +23,40 @@
|
|||||||
function smarty_function_counter($params, $template)
|
function smarty_function_counter($params, $template)
|
||||||
{
|
{
|
||||||
static $counters = array();
|
static $counters = array();
|
||||||
|
|
||||||
$name = (isset($params[ 'name' ])) ? $params[ 'name' ] : 'default';
|
$name = (isset($params[ 'name' ])) ? $params[ 'name' ] : 'default';
|
||||||
if (!isset($counters[ $name ])) {
|
if (!isset($counters[ $name ])) {
|
||||||
$counters[ $name ] = array('start' => 1, 'skip' => 1, 'direction' => 'up', 'count' => 1);
|
$counters[ $name ] = array('start' => 1, 'skip' => 1, 'direction' => 'up', 'count' => 1);
|
||||||
}
|
}
|
||||||
$counter =& $counters[ $name ];
|
$counter =& $counters[ $name ];
|
||||||
|
|
||||||
if (isset($params[ 'start' ])) {
|
if (isset($params[ 'start' ])) {
|
||||||
$counter[ 'start' ] = $counter[ 'count' ] = (int) $params[ 'start' ];
|
$counter[ 'start' ] = $counter[ 'count' ] = (int)$params[ 'start' ];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($params[ 'assign' ])) {
|
if (!empty($params[ 'assign' ])) {
|
||||||
$counter[ 'assign' ] = $params[ 'assign' ];
|
$counter[ 'assign' ] = $params[ 'assign' ];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($counter[ 'assign' ])) {
|
if (isset($counter[ 'assign' ])) {
|
||||||
$template->assign($counter[ 'assign' ], $counter[ 'count' ]);
|
$template->assign($counter[ 'assign' ], $counter[ 'count' ]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($params[ 'print' ])) {
|
if (isset($params[ 'print' ])) {
|
||||||
$print = (bool) $params[ 'print' ];
|
$print = (bool)$params[ 'print' ];
|
||||||
} else {
|
} else {
|
||||||
$print = empty($counter[ 'assign' ]);
|
$print = empty($counter[ 'assign' ]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($print) {
|
if ($print) {
|
||||||
$retval = $counter[ 'count' ];
|
$retval = $counter[ 'count' ];
|
||||||
} else {
|
} else {
|
||||||
$retval = null;
|
$retval = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($params[ 'skip' ])) {
|
if (isset($params[ 'skip' ])) {
|
||||||
$counter[ 'skip' ] = $params[ 'skip' ];
|
$counter[ 'skip' ] = $params[ 'skip' ];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($params[ 'direction' ])) {
|
if (isset($params[ 'direction' ])) {
|
||||||
$counter[ 'direction' ] = $params[ 'direction' ];
|
$counter[ 'direction' ] = $params[ 'direction' ];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($counter[ 'direction' ] === 'down') {
|
if ($counter[ 'direction' ] === 'down') {
|
||||||
$counter[ 'count' ] -= $counter[ 'skip' ];
|
$counter[ 'count' ] -= $counter[ 'skip' ];
|
||||||
} else {
|
} else {
|
||||||
$counter[ 'count' ] += $counter[ 'skip' ];
|
$counter[ 'count' ] += $counter[ 'skip' ];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $retval;
|
return $retval;
|
||||||
}
|
}
|
||||||
|
@@ -5,7 +5,6 @@
|
|||||||
* @package Smarty
|
* @package Smarty
|
||||||
* @subpackage PluginsFunction
|
* @subpackage PluginsFunction
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty {cycle} function plugin
|
* Smarty {cycle} function plugin
|
||||||
* Type: function
|
* Type: function
|
||||||
@@ -42,20 +41,16 @@
|
|||||||
*
|
*
|
||||||
* @return string|null
|
* @return string|null
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function smarty_function_cycle($params, $template)
|
function smarty_function_cycle($params, $template)
|
||||||
{
|
{
|
||||||
static $cycle_vars;
|
static $cycle_vars;
|
||||||
|
|
||||||
$name = (empty($params[ 'name' ])) ? 'default' : $params[ 'name' ];
|
$name = (empty($params[ 'name' ])) ? 'default' : $params[ 'name' ];
|
||||||
$print = (isset($params[ 'print' ])) ? (bool) $params[ 'print' ] : true;
|
$print = (isset($params[ 'print' ])) ? (bool)$params[ 'print' ] : true;
|
||||||
$advance = (isset($params[ 'advance' ])) ? (bool) $params[ 'advance' ] : true;
|
$advance = (isset($params[ 'advance' ])) ? (bool)$params[ 'advance' ] : true;
|
||||||
$reset = (isset($params[ 'reset' ])) ? (bool) $params[ 'reset' ] : false;
|
$reset = (isset($params[ 'reset' ])) ? (bool)$params[ 'reset' ] : false;
|
||||||
|
|
||||||
if (!isset($params[ 'values' ])) {
|
if (!isset($params[ 'values' ])) {
|
||||||
if (!isset($cycle_vars[ $name ][ 'values' ])) {
|
if (!isset($cycle_vars[ $name ][ 'values' ])) {
|
||||||
trigger_error('cycle: missing \'values\' parameter');
|
trigger_error('cycle: missing \'values\' parameter');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -64,41 +59,34 @@ function smarty_function_cycle($params, $template)
|
|||||||
}
|
}
|
||||||
$cycle_vars[ $name ][ 'values' ] = $params[ 'values' ];
|
$cycle_vars[ $name ][ 'values' ] = $params[ 'values' ];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($params[ 'delimiter' ])) {
|
if (isset($params[ 'delimiter' ])) {
|
||||||
$cycle_vars[ $name ][ 'delimiter' ] = $params[ 'delimiter' ];
|
$cycle_vars[ $name ][ 'delimiter' ] = $params[ 'delimiter' ];
|
||||||
} elseif (!isset($cycle_vars[ $name ][ 'delimiter' ])) {
|
} elseif (!isset($cycle_vars[ $name ][ 'delimiter' ])) {
|
||||||
$cycle_vars[ $name ][ 'delimiter' ] = ',';
|
$cycle_vars[ $name ][ 'delimiter' ] = ',';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_array($cycle_vars[ $name ][ 'values' ])) {
|
if (is_array($cycle_vars[ $name ][ 'values' ])) {
|
||||||
$cycle_array = $cycle_vars[ $name ][ 'values' ];
|
$cycle_array = $cycle_vars[ $name ][ 'values' ];
|
||||||
} else {
|
} else {
|
||||||
$cycle_array = explode($cycle_vars[ $name ][ 'delimiter' ], $cycle_vars[ $name ][ 'values' ]);
|
$cycle_array = explode($cycle_vars[ $name ][ 'delimiter' ], $cycle_vars[ $name ][ 'values' ]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($cycle_vars[ $name ][ 'index' ]) || $reset) {
|
if (!isset($cycle_vars[ $name ][ 'index' ]) || $reset) {
|
||||||
$cycle_vars[ $name ][ 'index' ] = 0;
|
$cycle_vars[ $name ][ 'index' ] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($params[ 'assign' ])) {
|
if (isset($params[ 'assign' ])) {
|
||||||
$print = false;
|
$print = false;
|
||||||
$template->assign($params[ 'assign' ], $cycle_array[ $cycle_vars[ $name ][ 'index' ] ]);
|
$template->assign($params[ 'assign' ], $cycle_array[ $cycle_vars[ $name ][ 'index' ] ]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($print) {
|
if ($print) {
|
||||||
$retval = $cycle_array[ $cycle_vars[ $name ][ 'index' ] ];
|
$retval = $cycle_array[ $cycle_vars[ $name ][ 'index' ] ];
|
||||||
} else {
|
} else {
|
||||||
$retval = null;
|
$retval = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($advance) {
|
if ($advance) {
|
||||||
if ($cycle_vars[ $name ][ 'index' ] >= count($cycle_array) - 1) {
|
if ($cycle_vars[ $name ][ 'index' ] >= count($cycle_array) - 1) {
|
||||||
$cycle_vars[ $name ][ 'index' ] = 0;
|
$cycle_vars[ $name ][ 'index' ] = 0;
|
||||||
} else {
|
} else {
|
||||||
$cycle_vars[ $name ][ 'index' ] ++;
|
$cycle_vars[ $name ][ 'index' ]++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $retval;
|
return $retval;
|
||||||
}
|
}
|
||||||
|
@@ -45,8 +45,12 @@
|
|||||||
function smarty_function_html_checkboxes($params, Smarty_Internal_Template $template)
|
function smarty_function_html_checkboxes($params, Smarty_Internal_Template $template)
|
||||||
{
|
{
|
||||||
$template->_checkPlugins(
|
$template->_checkPlugins(
|
||||||
array(array('function' => 'smarty_function_escape_special_chars',
|
array(
|
||||||
'file' => SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'))
|
array(
|
||||||
|
'function' => 'smarty_function_escape_special_chars',
|
||||||
|
'file' => SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'
|
||||||
|
)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
$name = 'checkbox';
|
$name = 'checkbox';
|
||||||
$values = null;
|
$values = null;
|
||||||
@@ -137,6 +141,7 @@ function smarty_function_html_checkboxes($params, Smarty_Internal_Template $temp
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// omit break; to fall through!
|
// omit break; to fall through!
|
||||||
|
// no break
|
||||||
default:
|
default:
|
||||||
if (!is_array($_val)) {
|
if (!is_array($_val)) {
|
||||||
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
|
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
|
||||||
@@ -202,17 +207,17 @@ function smarty_function_html_checkboxes($params, Smarty_Internal_Template $temp
|
|||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function smarty_function_html_checkboxes_output($name,
|
function smarty_function_html_checkboxes_output(
|
||||||
$value,
|
$name,
|
||||||
$output,
|
$value,
|
||||||
$selected,
|
$output,
|
||||||
$extra,
|
$selected,
|
||||||
$separator,
|
$extra,
|
||||||
$labels,
|
$separator,
|
||||||
$label_ids,
|
$labels,
|
||||||
$escape = true
|
$label_ids,
|
||||||
)
|
$escape = true
|
||||||
{
|
) {
|
||||||
$_output = '';
|
$_output = '';
|
||||||
if (is_object($value)) {
|
if (is_object($value)) {
|
||||||
if (method_exists($value, '__toString')) {
|
if (method_exists($value, '__toString')) {
|
||||||
|
@@ -37,8 +37,12 @@
|
|||||||
function smarty_function_html_image($params, Smarty_Internal_Template $template)
|
function smarty_function_html_image($params, Smarty_Internal_Template $template)
|
||||||
{
|
{
|
||||||
$template->_checkPlugins(
|
$template->_checkPlugins(
|
||||||
array(array('function' => 'smarty_function_escape_special_chars',
|
array(
|
||||||
'file' => SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'))
|
array(
|
||||||
|
'function' => 'smarty_function_escape_special_chars',
|
||||||
|
'file' => SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'
|
||||||
|
)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
$alt = '';
|
$alt = '';
|
||||||
$file = '';
|
$file = '';
|
||||||
@@ -63,8 +67,10 @@ function smarty_function_html_image($params, Smarty_Internal_Template $template)
|
|||||||
if (!is_array($_val)) {
|
if (!is_array($_val)) {
|
||||||
$$_key = smarty_function_escape_special_chars($_val);
|
$$_key = smarty_function_escape_special_chars($_val);
|
||||||
} else {
|
} else {
|
||||||
throw new SmartyException("html_image: extra attribute '{$_key}' cannot be an array",
|
throw new SmartyException(
|
||||||
E_USER_NOTICE);
|
"html_image: extra attribute '{$_key}' cannot be an array",
|
||||||
|
E_USER_NOTICE
|
||||||
|
);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'link':
|
case 'link':
|
||||||
@@ -76,8 +82,10 @@ function smarty_function_html_image($params, Smarty_Internal_Template $template)
|
|||||||
if (!is_array($_val)) {
|
if (!is_array($_val)) {
|
||||||
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
|
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
|
||||||
} else {
|
} else {
|
||||||
throw new SmartyException("html_image: extra attribute '{$_key}' cannot be an array",
|
throw new SmartyException(
|
||||||
E_USER_NOTICE);
|
"html_image: extra attribute '{$_key}' cannot be an array",
|
||||||
|
E_USER_NOTICE
|
||||||
|
);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@@ -37,8 +37,12 @@
|
|||||||
function smarty_function_html_options($params, Smarty_Internal_Template $template)
|
function smarty_function_html_options($params, Smarty_Internal_Template $template)
|
||||||
{
|
{
|
||||||
$template->_checkPlugins(
|
$template->_checkPlugins(
|
||||||
array(array('function' => 'smarty_function_escape_special_chars',
|
array(
|
||||||
'file' => SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'))
|
array(
|
||||||
|
'function' => 'smarty_function_escape_special_chars',
|
||||||
|
'file' => SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'
|
||||||
|
)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
$name = null;
|
$name = null;
|
||||||
$values = null;
|
$values = null;
|
||||||
@@ -113,6 +117,7 @@ function smarty_function_html_options($params, Smarty_Internal_Template $templat
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// omit break; to fall through!
|
// omit break; to fall through!
|
||||||
|
// no break
|
||||||
default:
|
default:
|
||||||
if (!is_array($_val)) {
|
if (!is_array($_val)) {
|
||||||
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
|
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
|
||||||
|
@@ -45,8 +45,12 @@
|
|||||||
function smarty_function_html_radios($params, Smarty_Internal_Template $template)
|
function smarty_function_html_radios($params, Smarty_Internal_Template $template)
|
||||||
{
|
{
|
||||||
$template->_checkPlugins(
|
$template->_checkPlugins(
|
||||||
array(array('function' => 'smarty_function_escape_special_chars',
|
array(
|
||||||
'file' => SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'))
|
array(
|
||||||
|
'function' => 'smarty_function_escape_special_chars',
|
||||||
|
'file' => SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'
|
||||||
|
)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
$name = 'radio';
|
$name = 'radio';
|
||||||
$values = null;
|
$values = null;
|
||||||
@@ -120,6 +124,7 @@ function smarty_function_html_radios($params, Smarty_Internal_Template $template
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// omit break; to fall through!
|
// omit break; to fall through!
|
||||||
|
// no break
|
||||||
default:
|
default:
|
||||||
if (!is_array($_val)) {
|
if (!is_array($_val)) {
|
||||||
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
|
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
|
||||||
@@ -186,17 +191,17 @@ function smarty_function_html_radios($params, Smarty_Internal_Template $template
|
|||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function smarty_function_html_radios_output($name,
|
function smarty_function_html_radios_output(
|
||||||
$value,
|
$name,
|
||||||
$output,
|
$value,
|
||||||
$selected,
|
$output,
|
||||||
$extra,
|
$selected,
|
||||||
$separator,
|
$extra,
|
||||||
$labels,
|
$separator,
|
||||||
$label_ids,
|
$labels,
|
||||||
$escape
|
$label_ids,
|
||||||
)
|
$escape
|
||||||
{
|
) {
|
||||||
$_output = '';
|
$_output = '';
|
||||||
if (is_object($value)) {
|
if (is_object($value)) {
|
||||||
if (method_exists($value, '__toString')) {
|
if (method_exists($value, '__toString')) {
|
||||||
|
@@ -45,8 +45,12 @@
|
|||||||
function smarty_function_html_select_date($params, Smarty_Internal_Template $template)
|
function smarty_function_html_select_date($params, Smarty_Internal_Template $template)
|
||||||
{
|
{
|
||||||
$template->_checkPlugins(
|
$template->_checkPlugins(
|
||||||
array(array('function' => 'smarty_function_escape_special_chars',
|
array(
|
||||||
'file' => SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'))
|
array(
|
||||||
|
'function' => 'smarty_function_escape_special_chars',
|
||||||
|
'file' => SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'
|
||||||
|
)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
// generate timestamps used for month names only
|
// generate timestamps used for month names only
|
||||||
static $_month_timestamps = null;
|
static $_month_timestamps = null;
|
||||||
@@ -111,8 +115,12 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
|
|||||||
case 'time':
|
case 'time':
|
||||||
if (!is_array($_value) && $_value !== null) {
|
if (!is_array($_value) && $_value !== null) {
|
||||||
$template->_checkPlugins(
|
$template->_checkPlugins(
|
||||||
array(array('function' => 'smarty_make_timestamp',
|
array(
|
||||||
'file' => SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php'))
|
array(
|
||||||
|
'function' => 'smarty_make_timestamp',
|
||||||
|
'file' => SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php'
|
||||||
|
)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
$time = smarty_make_timestamp($_value);
|
$time = smarty_make_timestamp($_value);
|
||||||
}
|
}
|
||||||
@@ -173,9 +181,11 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
|
|||||||
if (isset($params[ 'time' ]) && is_array($params[ 'time' ])) {
|
if (isset($params[ 'time' ]) && is_array($params[ 'time' ])) {
|
||||||
if (isset($params[ 'time' ][ $prefix . 'Year' ])) {
|
if (isset($params[ 'time' ][ $prefix . 'Year' ])) {
|
||||||
// $_REQUEST[$field_array] given
|
// $_REQUEST[$field_array] given
|
||||||
foreach (array('Y' => 'Year',
|
foreach (array(
|
||||||
'm' => 'Month',
|
'Y' => 'Year',
|
||||||
'd' => 'Day') as $_elementKey => $_elementName) {
|
'm' => 'Month',
|
||||||
|
'd' => 'Day'
|
||||||
|
) as $_elementKey => $_elementName) {
|
||||||
$_variableName = '_' . strtolower($_elementName);
|
$_variableName = '_' . strtolower($_elementName);
|
||||||
$$_variableName =
|
$$_variableName =
|
||||||
isset($params[ 'time' ][ $prefix . $_elementName ]) ? $params[ 'time' ][ $prefix . $_elementName ] :
|
isset($params[ 'time' ][ $prefix . $_elementName ]) ? $params[ 'time' ][ $prefix . $_elementName ] :
|
||||||
@@ -183,9 +193,11 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
|
|||||||
}
|
}
|
||||||
} elseif (isset($params[ 'time' ][ $field_array ][ $prefix . 'Year' ])) {
|
} elseif (isset($params[ 'time' ][ $field_array ][ $prefix . 'Year' ])) {
|
||||||
// $_REQUEST given
|
// $_REQUEST given
|
||||||
foreach (array('Y' => 'Year',
|
foreach (array(
|
||||||
'm' => 'Month',
|
'Y' => 'Year',
|
||||||
'd' => 'Day') as $_elementKey => $_elementName) {
|
'm' => 'Month',
|
||||||
|
'd' => 'Day'
|
||||||
|
) as $_elementKey => $_elementName) {
|
||||||
$_variableName = '_' . strtolower($_elementName);
|
$_variableName = '_' . strtolower($_elementName);
|
||||||
$$_variableName = isset($params[ 'time' ][ $field_array ][ $prefix . $_elementName ]) ?
|
$$_variableName = isset($params[ 'time' ][ $field_array ][ $prefix . $_elementName ]) ?
|
||||||
$params[ 'time' ][ $field_array ][ $prefix . $_elementName ] : date($_elementKey);
|
$params[ 'time' ][ $field_array ][ $prefix . $_elementName ] : date($_elementKey);
|
||||||
@@ -205,8 +217,10 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
|
|||||||
}
|
}
|
||||||
// make syntax "+N" or "-N" work with $start_year and $end_year
|
// make syntax "+N" or "-N" work with $start_year and $end_year
|
||||||
// Note preg_match('!^(\+|\-)\s*(\d+)$!', $end_year, $match) is slower than trim+substr
|
// Note preg_match('!^(\+|\-)\s*(\d+)$!', $end_year, $match) is slower than trim+substr
|
||||||
foreach (array('start',
|
foreach (array(
|
||||||
'end') as $key) {
|
'start',
|
||||||
|
'end'
|
||||||
|
) as $key) {
|
||||||
$key .= '_year';
|
$key .= '_year';
|
||||||
$t = $$key;
|
$t = $$key;
|
||||||
if ($t === null) {
|
if ($t === null) {
|
||||||
|
@@ -27,8 +27,12 @@
|
|||||||
function smarty_function_html_select_time($params, Smarty_Internal_Template $template)
|
function smarty_function_html_select_time($params, Smarty_Internal_Template $template)
|
||||||
{
|
{
|
||||||
$template->_checkPlugins(
|
$template->_checkPlugins(
|
||||||
array(array('function' => 'smarty_function_escape_special_chars',
|
array(
|
||||||
'file' => SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'))
|
array(
|
||||||
|
'function' => 'smarty_function_escape_special_chars',
|
||||||
|
'file' => SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'
|
||||||
|
)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
$prefix = 'Time_';
|
$prefix = 'Time_';
|
||||||
$field_array = null;
|
$field_array = null;
|
||||||
@@ -73,8 +77,12 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
|
|||||||
case 'time':
|
case 'time':
|
||||||
if (!is_array($_value) && $_value !== null) {
|
if (!is_array($_value) && $_value !== null) {
|
||||||
$template->_checkPlugins(
|
$template->_checkPlugins(
|
||||||
array(array('function' => 'smarty_make_timestamp',
|
array(
|
||||||
'file' => SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php'))
|
array(
|
||||||
|
'function' => 'smarty_make_timestamp',
|
||||||
|
'file' => SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php'
|
||||||
|
)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
$time = smarty_make_timestamp($_value);
|
$time = smarty_make_timestamp($_value);
|
||||||
}
|
}
|
||||||
@@ -133,9 +141,11 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
|
|||||||
if (isset($params[ 'time' ]) && is_array($params[ 'time' ])) {
|
if (isset($params[ 'time' ]) && is_array($params[ 'time' ])) {
|
||||||
if (isset($params[ 'time' ][ $prefix . 'Hour' ])) {
|
if (isset($params[ 'time' ][ $prefix . 'Hour' ])) {
|
||||||
// $_REQUEST[$field_array] given
|
// $_REQUEST[$field_array] given
|
||||||
foreach (array('H' => 'Hour',
|
foreach (array(
|
||||||
'i' => 'Minute',
|
'H' => 'Hour',
|
||||||
's' => 'Second') as $_elementKey => $_elementName) {
|
'i' => 'Minute',
|
||||||
|
's' => 'Second'
|
||||||
|
) as $_elementKey => $_elementName) {
|
||||||
$_variableName = '_' . strtolower($_elementName);
|
$_variableName = '_' . strtolower($_elementName);
|
||||||
$$_variableName =
|
$$_variableName =
|
||||||
isset($params[ 'time' ][ $prefix . $_elementName ]) ? $params[ 'time' ][ $prefix . $_elementName ] :
|
isset($params[ 'time' ][ $prefix . $_elementName ]) ? $params[ 'time' ][ $prefix . $_elementName ] :
|
||||||
@@ -148,9 +158,11 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
|
|||||||
list($_hour, $_minute, $_second) = $time = explode('-', date('H-i-s', $time));
|
list($_hour, $_minute, $_second) = $time = explode('-', date('H-i-s', $time));
|
||||||
} elseif (isset($params[ 'time' ][ $field_array ][ $prefix . 'Hour' ])) {
|
} elseif (isset($params[ 'time' ][ $field_array ][ $prefix . 'Hour' ])) {
|
||||||
// $_REQUEST given
|
// $_REQUEST given
|
||||||
foreach (array('H' => 'Hour',
|
foreach (array(
|
||||||
'i' => 'Minute',
|
'H' => 'Hour',
|
||||||
's' => 'Second') as $_elementKey => $_elementName) {
|
'i' => 'Minute',
|
||||||
|
's' => 'Second'
|
||||||
|
) as $_elementKey => $_elementName) {
|
||||||
$_variableName = '_' . strtolower($_elementName);
|
$_variableName = '_' . strtolower($_elementName);
|
||||||
$$_variableName = isset($params[ 'time' ][ $field_array ][ $prefix . $_elementName ]) ?
|
$$_variableName = isset($params[ 'time' ][ $field_array ][ $prefix . $_elementName ]) ?
|
||||||
$params[ 'time' ][ $field_array ][ $prefix . $_elementName ] : date($_elementKey);
|
$params[ 'time' ][ $field_array ][ $prefix . $_elementName ] : date($_elementKey);
|
||||||
@@ -325,10 +337,12 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
|
|||||||
'</select>';
|
'</select>';
|
||||||
}
|
}
|
||||||
$_html = '';
|
$_html = '';
|
||||||
foreach (array('_html_hours',
|
foreach (array(
|
||||||
'_html_minutes',
|
'_html_hours',
|
||||||
'_html_seconds',
|
'_html_minutes',
|
||||||
'_html_meridian') as $k) {
|
'_html_seconds',
|
||||||
|
'_html_meridian'
|
||||||
|
) as $k) {
|
||||||
if (isset($$k)) {
|
if (isset($$k)) {
|
||||||
if ($_html) {
|
if ($_html) {
|
||||||
$_html .= $field_separator;
|
$_html .= $field_separator;
|
||||||
|
@@ -79,6 +79,7 @@ function smarty_function_mailto($params)
|
|||||||
case 'extra':
|
case 'extra':
|
||||||
case 'text':
|
case 'text':
|
||||||
$$var = $value;
|
$$var = $value;
|
||||||
|
// no break
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -6,7 +6,6 @@
|
|||||||
* @package Smarty
|
* @package Smarty
|
||||||
* @subpackage PluginsFunction
|
* @subpackage PluginsFunction
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty {math} function plugin
|
* Smarty {math} function plugin
|
||||||
* Type: function
|
* Type: function
|
||||||
@@ -25,66 +24,71 @@
|
|||||||
function smarty_function_math($params, $template)
|
function smarty_function_math($params, $template)
|
||||||
{
|
{
|
||||||
static $_allowed_funcs =
|
static $_allowed_funcs =
|
||||||
array('int' => true, 'abs' => true, 'ceil' => true, 'cos' => true, 'exp' => true, 'floor' => true,
|
array(
|
||||||
'log' => true, 'log10' => true, 'max' => true, 'min' => true, 'pi' => true, 'pow' => true, 'rand' => true,
|
'int' => true,
|
||||||
'round' => true, 'sin' => true, 'sqrt' => true, 'srand' => true, 'tan' => true);
|
'abs' => true,
|
||||||
|
'ceil' => true,
|
||||||
|
'cos' => true,
|
||||||
|
'exp' => true,
|
||||||
|
'floor' => true,
|
||||||
|
'log' => true,
|
||||||
|
'log10' => true,
|
||||||
|
'max' => true,
|
||||||
|
'min' => true,
|
||||||
|
'pi' => true,
|
||||||
|
'pow' => true,
|
||||||
|
'rand' => true,
|
||||||
|
'round' => true,
|
||||||
|
'sin' => true,
|
||||||
|
'sqrt' => true,
|
||||||
|
'srand' => true,
|
||||||
|
'tan' => true
|
||||||
|
);
|
||||||
// be sure equation parameter is present
|
// be sure equation parameter is present
|
||||||
if (empty($params[ 'equation' ])) {
|
if (empty($params[ 'equation' ])) {
|
||||||
trigger_error("math: missing equation parameter", E_USER_WARNING);
|
trigger_error("math: missing equation parameter", E_USER_WARNING);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$equation = $params[ 'equation' ];
|
$equation = $params[ 'equation' ];
|
||||||
|
|
||||||
// make sure parenthesis are balanced
|
// make sure parenthesis are balanced
|
||||||
if (substr_count($equation, '(') !== substr_count($equation, ')')) {
|
if (substr_count($equation, '(') !== substr_count($equation, ')')) {
|
||||||
trigger_error("math: unbalanced parenthesis", E_USER_WARNING);
|
trigger_error("math: unbalanced parenthesis", E_USER_WARNING);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// disallow backticks
|
// disallow backticks
|
||||||
if (strpos($equation, '`') !== false) {
|
if (strpos($equation, '`') !== false) {
|
||||||
trigger_error("math: backtick character not allowed in equation", E_USER_WARNING);
|
trigger_error("math: backtick character not allowed in equation", E_USER_WARNING);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// also disallow dollar signs
|
// also disallow dollar signs
|
||||||
if (strpos($equation, '$') !== false) {
|
if (strpos($equation, '$') !== false) {
|
||||||
trigger_error("math: dollar signs not allowed in equation", E_USER_WARNING);
|
trigger_error("math: dollar signs not allowed in equation", E_USER_WARNING);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($params as $key => $val) {
|
foreach ($params as $key => $val) {
|
||||||
if ($key !== 'equation' && $key !== 'format' && $key !== 'assign') {
|
if ($key !== 'equation' && $key !== 'format' && $key !== 'assign') {
|
||||||
// make sure value is not empty
|
// make sure value is not empty
|
||||||
if (strlen($val) === 0) {
|
if (strlen($val) === 0) {
|
||||||
trigger_error("math: parameter '{$key}' is empty", E_USER_WARNING);
|
trigger_error("math: parameter '{$key}' is empty", E_USER_WARNING);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!is_numeric($val)) {
|
if (!is_numeric($val)) {
|
||||||
trigger_error("math: parameter '{$key}' is not numeric", E_USER_WARNING);
|
trigger_error("math: parameter '{$key}' is not numeric", E_USER_WARNING);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// match all vars in equation, make sure all are passed
|
// match all vars in equation, make sure all are passed
|
||||||
preg_match_all('!(?:0x[a-fA-F0-9]+)|([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)!', $equation, $match);
|
preg_match_all('!(?:0x[a-fA-F0-9]+)|([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)!', $equation, $match);
|
||||||
|
|
||||||
foreach ($match[ 1 ] as $curr_var) {
|
foreach ($match[ 1 ] as $curr_var) {
|
||||||
if ($curr_var && !isset($params[ $curr_var ]) && !isset($_allowed_funcs[ $curr_var ])) {
|
if ($curr_var && !isset($params[ $curr_var ]) && !isset($_allowed_funcs[ $curr_var ])) {
|
||||||
trigger_error("math: function call '{$curr_var}' not allowed, or missing parameter '{$curr_var}'", E_USER_WARNING);
|
trigger_error(
|
||||||
|
"math: function call '{$curr_var}' not allowed, or missing parameter '{$curr_var}'",
|
||||||
|
E_USER_WARNING
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($params as $key => $val) {
|
foreach ($params as $key => $val) {
|
||||||
if ($key !== 'equation' && $key !== 'format' && $key !== 'assign') {
|
if ($key !== 'equation' && $key !== 'format' && $key !== 'assign') {
|
||||||
$equation = preg_replace("/\b$key\b/", " \$params['$key'] ", $equation);
|
$equation = preg_replace("/\b$key\b/", " \$params['$key'] ", $equation);
|
||||||
@@ -92,7 +96,6 @@ function smarty_function_math($params, $template)
|
|||||||
}
|
}
|
||||||
$smarty_math_result = null;
|
$smarty_math_result = null;
|
||||||
eval("\$smarty_math_result = " . $equation . ";");
|
eval("\$smarty_math_result = " . $equation . ";");
|
||||||
|
|
||||||
if (empty($params[ 'format' ])) {
|
if (empty($params[ 'format' ])) {
|
||||||
if (empty($params[ 'assign' ])) {
|
if (empty($params[ 'assign' ])) {
|
||||||
return $smarty_math_result;
|
return $smarty_math_result;
|
||||||
|
@@ -5,7 +5,6 @@
|
|||||||
* @package Smarty
|
* @package Smarty
|
||||||
* @subpackage PluginsModifier
|
* @subpackage PluginsModifier
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty capitalize modifier plugin
|
* Smarty capitalize modifier plugin
|
||||||
* Type: modifier
|
* Type: modifier
|
||||||
@@ -31,20 +30,25 @@ function smarty_modifier_capitalize($string, $uc_digits = false, $lc_rest = fals
|
|||||||
// uppercase word breaks
|
// uppercase word breaks
|
||||||
$upper_string = preg_replace_callback(
|
$upper_string = preg_replace_callback(
|
||||||
"!(^|[^\p{L}'])([\p{Ll}])!S" . Smarty::$_UTF8_MODIFIER,
|
"!(^|[^\p{L}'])([\p{Ll}])!S" . Smarty::$_UTF8_MODIFIER,
|
||||||
'smarty_mod_cap_mbconvert_cb', $string
|
'smarty_mod_cap_mbconvert_cb',
|
||||||
|
$string
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// check uc_digits case
|
// check uc_digits case
|
||||||
if (!$uc_digits) {
|
if (!$uc_digits) {
|
||||||
if (preg_match_all(
|
if (preg_match_all(
|
||||||
"!\b([\p{L}]*[\p{N}]+[\p{L}]*)\b!" . Smarty::$_UTF8_MODIFIER, $string, $matches,
|
"!\b([\p{L}]*[\p{N}]+[\p{L}]*)\b!" . Smarty::$_UTF8_MODIFIER,
|
||||||
|
$string,
|
||||||
|
$matches,
|
||||||
PREG_OFFSET_CAPTURE
|
PREG_OFFSET_CAPTURE
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
foreach ($matches[ 1 ] as $match) {
|
foreach ($matches[ 1 ] as $match) {
|
||||||
$upper_string =
|
$upper_string =
|
||||||
substr_replace(
|
substr_replace(
|
||||||
$upper_string, mb_strtolower($match[ 0 ], Smarty::$_CHARSET), $match[ 1 ],
|
$upper_string,
|
||||||
|
mb_strtolower($match[ 0 ], Smarty::$_CHARSET),
|
||||||
|
$match[ 1 ],
|
||||||
strlen($match[ 0 ])
|
strlen($match[ 0 ])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -52,12 +56,12 @@ function smarty_modifier_capitalize($string, $uc_digits = false, $lc_rest = fals
|
|||||||
}
|
}
|
||||||
$upper_string =
|
$upper_string =
|
||||||
preg_replace_callback(
|
preg_replace_callback(
|
||||||
"!((^|\s)['\"])(\w)!" . Smarty::$_UTF8_MODIFIER, 'smarty_mod_cap_mbconvert2_cb',
|
"!((^|\s)['\"])(\w)!" . Smarty::$_UTF8_MODIFIER,
|
||||||
|
'smarty_mod_cap_mbconvert2_cb',
|
||||||
$upper_string
|
$upper_string
|
||||||
);
|
);
|
||||||
return $upper_string;
|
return $upper_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
// lowercase first
|
// lowercase first
|
||||||
if ($lc_rest) {
|
if ($lc_rest) {
|
||||||
$string = strtolower($string);
|
$string = strtolower($string);
|
||||||
@@ -65,13 +69,16 @@ function smarty_modifier_capitalize($string, $uc_digits = false, $lc_rest = fals
|
|||||||
// uppercase (including hyphenated words)
|
// uppercase (including hyphenated words)
|
||||||
$upper_string =
|
$upper_string =
|
||||||
preg_replace_callback(
|
preg_replace_callback(
|
||||||
"!(^|[^\p{L}'])([\p{Ll}])!S" . Smarty::$_UTF8_MODIFIER, 'smarty_mod_cap_ucfirst_cb',
|
"!(^|[^\p{L}'])([\p{Ll}])!S" . Smarty::$_UTF8_MODIFIER,
|
||||||
|
'smarty_mod_cap_ucfirst_cb',
|
||||||
$string
|
$string
|
||||||
);
|
);
|
||||||
// check uc_digits case
|
// check uc_digits case
|
||||||
if (!$uc_digits) {
|
if (!$uc_digits) {
|
||||||
if (preg_match_all(
|
if (preg_match_all(
|
||||||
"!\b([\p{L}]*[\p{N}]+[\p{L}]*)\b!" . Smarty::$_UTF8_MODIFIER, $string, $matches,
|
"!\b([\p{L}]*[\p{N}]+[\p{L}]*)\b!" . Smarty::$_UTF8_MODIFIER,
|
||||||
|
$string,
|
||||||
|
$matches,
|
||||||
PREG_OFFSET_CAPTURE
|
PREG_OFFSET_CAPTURE
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
@@ -82,13 +89,14 @@ function smarty_modifier_capitalize($string, $uc_digits = false, $lc_rest = fals
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$upper_string = preg_replace_callback(
|
$upper_string = preg_replace_callback(
|
||||||
"!((^|\s)['\"])(\w)!" . Smarty::$_UTF8_MODIFIER, 'smarty_mod_cap_ucfirst2_cb',
|
"!((^|\s)['\"])(\w)!" . Smarty::$_UTF8_MODIFIER,
|
||||||
|
'smarty_mod_cap_ucfirst2_cb',
|
||||||
$upper_string
|
$upper_string
|
||||||
);
|
);
|
||||||
return $upper_string;
|
return $upper_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
*
|
*
|
||||||
* Bug: create_function() use exhausts memory when used in long loops
|
* Bug: create_function() use exhausts memory when used in long loops
|
||||||
* Fix: use declared functions for callbacks instead of using create_function()
|
* Fix: use declared functions for callbacks instead of using create_function()
|
||||||
@@ -105,6 +113,7 @@ function smarty_mod_cap_mbconvert_cb($matches)
|
|||||||
{
|
{
|
||||||
return stripslashes($matches[ 1 ]) . mb_convert_case(stripslashes($matches[ 2 ]), MB_CASE_UPPER, Smarty::$_CHARSET);
|
return stripslashes($matches[ 1 ]) . mb_convert_case(stripslashes($matches[ 2 ]), MB_CASE_UPPER, Smarty::$_CHARSET);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $matches
|
* @param $matches
|
||||||
*
|
*
|
||||||
@@ -114,6 +123,7 @@ function smarty_mod_cap_mbconvert2_cb($matches)
|
|||||||
{
|
{
|
||||||
return stripslashes($matches[ 1 ]) . mb_convert_case(stripslashes($matches[ 3 ]), MB_CASE_UPPER, Smarty::$_CHARSET);
|
return stripslashes($matches[ 1 ]) . mb_convert_case(stripslashes($matches[ 3 ]), MB_CASE_UPPER, Smarty::$_CHARSET);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $matches
|
* @param $matches
|
||||||
*
|
*
|
||||||
@@ -123,6 +133,7 @@ function smarty_mod_cap_ucfirst_cb($matches)
|
|||||||
{
|
{
|
||||||
return stripslashes($matches[ 1 ]) . ucfirst(stripslashes($matches[ 2 ]));
|
return stripslashes($matches[ 1 ]) . ucfirst(stripslashes($matches[ 2 ]));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $matches
|
* @param $matches
|
||||||
*
|
*
|
||||||
|
@@ -5,7 +5,6 @@
|
|||||||
* @package Smarty
|
* @package Smarty
|
||||||
* @subpackage PluginsModifier
|
* @subpackage PluginsModifier
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty date_format modifier plugin
|
* Smarty date_format modifier plugin
|
||||||
* Type: modifier
|
* Type: modifier
|
||||||
@@ -51,20 +50,24 @@ function smarty_modifier_date_format($string, $format = null, $default_date = ''
|
|||||||
}
|
}
|
||||||
if ($formatter === 'strftime' || ($formatter === 'auto' && strpos($format, '%') !== false)) {
|
if ($formatter === 'strftime' || ($formatter === 'auto' && strpos($format, '%') !== false)) {
|
||||||
if (Smarty::$_IS_WINDOWS) {
|
if (Smarty::$_IS_WINDOWS) {
|
||||||
$_win_from = array('%D',
|
$_win_from = array(
|
||||||
'%h',
|
'%D',
|
||||||
'%n',
|
'%h',
|
||||||
'%r',
|
'%n',
|
||||||
'%R',
|
'%r',
|
||||||
'%t',
|
'%R',
|
||||||
'%T');
|
'%t',
|
||||||
$_win_to = array('%m/%d/%y',
|
'%T'
|
||||||
'%b',
|
);
|
||||||
"\n",
|
$_win_to = array(
|
||||||
'%I:%M:%S %p',
|
'%m/%d/%y',
|
||||||
'%H:%M',
|
'%b',
|
||||||
"\t",
|
"\n",
|
||||||
'%H:%M:%S');
|
'%I:%M:%S %p',
|
||||||
|
'%H:%M',
|
||||||
|
"\t",
|
||||||
|
'%H:%M:%S'
|
||||||
|
);
|
||||||
if (strpos($format, '%e') !== false) {
|
if (strpos($format, '%e') !== false) {
|
||||||
$_win_from[] = '%e';
|
$_win_from[] = '%e';
|
||||||
$_win_to[] = sprintf('%\' 2d', date('j', $timestamp));
|
$_win_to[] = sprintf('%\' 2d', date('j', $timestamp));
|
||||||
@@ -75,7 +78,6 @@ function smarty_modifier_date_format($string, $format = null, $default_date = ''
|
|||||||
}
|
}
|
||||||
$format = str_replace($_win_from, $_win_to, $format);
|
$format = str_replace($_win_from, $_win_to, $format);
|
||||||
}
|
}
|
||||||
|
|
||||||
return strftime($format, $timestamp);
|
return strftime($format, $timestamp);
|
||||||
} else {
|
} else {
|
||||||
return date($format, $timestamp);
|
return date($format, $timestamp);
|
||||||
|
@@ -25,7 +25,7 @@ function smarty_modifier_debug_print_var($var, $max = 10, $length = 40, $depth =
|
|||||||
{
|
{
|
||||||
$_replace = array("\n" => '\n', "\r" => '\r', "\t" => '\t');
|
$_replace = array("\n" => '\n', "\r" => '\r', "\t" => '\t');
|
||||||
switch (gettype($var)) {
|
switch (gettype($var)) {
|
||||||
case 'array' :
|
case 'array':
|
||||||
$results = '<b>Array (' . count($var) . ')</b>';
|
$results = '<b>Array (' . count($var) . ')</b>';
|
||||||
if ($depth === $max) {
|
if ($depth === $max) {
|
||||||
break;
|
break;
|
||||||
@@ -37,7 +37,7 @@ function smarty_modifier_debug_print_var($var, $max = 10, $length = 40, $depth =
|
|||||||
$depth--;
|
$depth--;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'object' :
|
case 'object':
|
||||||
$object_vars = get_object_vars($var);
|
$object_vars = get_object_vars($var);
|
||||||
$results = '<b>' . get_class($var) . ' Object (' . count($object_vars) . ')</b>';
|
$results = '<b>' . get_class($var) . ' Object (' . count($object_vars) . ')</b>';
|
||||||
if (in_array($var, $objects)) {
|
if (in_array($var, $objects)) {
|
||||||
@@ -54,9 +54,9 @@ function smarty_modifier_debug_print_var($var, $max = 10, $length = 40, $depth =
|
|||||||
$depth--;
|
$depth--;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'boolean' :
|
case 'boolean':
|
||||||
case 'NULL' :
|
case 'NULL':
|
||||||
case 'resource' :
|
case 'resource':
|
||||||
if (true === $var) {
|
if (true === $var) {
|
||||||
$results = 'true';
|
$results = 'true';
|
||||||
} elseif (false === $var) {
|
} elseif (false === $var) {
|
||||||
@@ -68,11 +68,11 @@ function smarty_modifier_debug_print_var($var, $max = 10, $length = 40, $depth =
|
|||||||
}
|
}
|
||||||
$results = '<i>' . $results . '</i>';
|
$results = '<i>' . $results . '</i>';
|
||||||
break;
|
break;
|
||||||
case 'integer' :
|
case 'integer':
|
||||||
case 'float' :
|
case 'float':
|
||||||
$results = htmlspecialchars((string)$var);
|
$results = htmlspecialchars((string)$var);
|
||||||
break;
|
break;
|
||||||
case 'string' :
|
case 'string':
|
||||||
$results = strtr($var, $_replace);
|
$results = strtr($var, $_replace);
|
||||||
if (Smarty::$_MBSTRING) {
|
if (Smarty::$_MBSTRING) {
|
||||||
if (mb_strlen($var, Smarty::$_CHARSET) > $length) {
|
if (mb_strlen($var, Smarty::$_CHARSET) > $length) {
|
||||||
@@ -85,8 +85,8 @@ function smarty_modifier_debug_print_var($var, $max = 10, $length = 40, $depth =
|
|||||||
}
|
}
|
||||||
$results = htmlspecialchars('"' . $results . '"', ENT_QUOTES, Smarty::$_CHARSET);
|
$results = htmlspecialchars('"' . $results . '"', ENT_QUOTES, Smarty::$_CHARSET);
|
||||||
break;
|
break;
|
||||||
case 'unknown type' :
|
case 'unknown type':
|
||||||
default :
|
default:
|
||||||
$results = strtr((string)$var, $_replace);
|
$results = strtr((string)$var, $_replace);
|
||||||
if (Smarty::$_MBSTRING) {
|
if (Smarty::$_MBSTRING) {
|
||||||
if (mb_strlen($results, Smarty::$_CHARSET) > $length) {
|
if (mb_strlen($results, Smarty::$_CHARSET) > $length) {
|
||||||
|
@@ -46,15 +46,20 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
|
|||||||
$string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string);
|
$string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string);
|
||||||
$string = htmlspecialchars($string, ENT_QUOTES, $char_set);
|
$string = htmlspecialchars($string, ENT_QUOTES, $char_set);
|
||||||
$string = str_replace(
|
$string = str_replace(
|
||||||
array('%%%SMARTY_START%%%',
|
array(
|
||||||
'%%%SMARTY_END%%%'),
|
'%%%SMARTY_START%%%',
|
||||||
array('&',
|
'%%%SMARTY_END%%%'
|
||||||
';'),
|
),
|
||||||
|
array(
|
||||||
|
'&',
|
||||||
|
';'
|
||||||
|
),
|
||||||
$string
|
$string
|
||||||
);
|
);
|
||||||
return $string;
|
return $string;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// no break
|
||||||
case 'htmlall':
|
case 'htmlall':
|
||||||
if (Smarty::$_MBSTRING) {
|
if (Smarty::$_MBSTRING) {
|
||||||
// mb_convert_encoding ignores htmlspecialchars()
|
// mb_convert_encoding ignores htmlspecialchars()
|
||||||
@@ -71,10 +76,14 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
|
|||||||
$string = htmlspecialchars($string, ENT_QUOTES, $char_set);
|
$string = htmlspecialchars($string, ENT_QUOTES, $char_set);
|
||||||
$string =
|
$string =
|
||||||
str_replace(
|
str_replace(
|
||||||
array('%%%SMARTY_START%%%',
|
array(
|
||||||
'%%%SMARTY_END%%%'),
|
'%%%SMARTY_START%%%',
|
||||||
array('&',
|
'%%%SMARTY_END%%%'
|
||||||
';'),
|
),
|
||||||
|
array(
|
||||||
|
'&',
|
||||||
|
';'
|
||||||
|
),
|
||||||
$string
|
$string
|
||||||
);
|
);
|
||||||
return $string;
|
return $string;
|
||||||
@@ -93,15 +102,20 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
|
|||||||
$string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string);
|
$string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string);
|
||||||
$string = htmlentities($string, ENT_QUOTES, $char_set);
|
$string = htmlentities($string, ENT_QUOTES, $char_set);
|
||||||
$string = str_replace(
|
$string = str_replace(
|
||||||
array('%%%SMARTY_START%%%',
|
array(
|
||||||
'%%%SMARTY_END%%%'),
|
'%%%SMARTY_START%%%',
|
||||||
array('&',
|
'%%%SMARTY_END%%%'
|
||||||
';'),
|
),
|
||||||
|
array(
|
||||||
|
'&',
|
||||||
|
';'
|
||||||
|
),
|
||||||
$string
|
$string
|
||||||
);
|
);
|
||||||
return $string;
|
return $string;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// no break
|
||||||
case 'url':
|
case 'url':
|
||||||
return rawurlencode($string);
|
return rawurlencode($string);
|
||||||
case 'urlpathinfo':
|
case 'urlpathinfo':
|
||||||
@@ -164,12 +178,14 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
|
|||||||
// escape quotes and backslashes, newlines, etc.
|
// escape quotes and backslashes, newlines, etc.
|
||||||
return strtr(
|
return strtr(
|
||||||
$string,
|
$string,
|
||||||
array('\\' => '\\\\',
|
array(
|
||||||
"'" => "\\'",
|
'\\' => '\\\\',
|
||||||
'"' => '\\"',
|
"'" => "\\'",
|
||||||
"\r" => '\\r',
|
'"' => '\\"',
|
||||||
"\n" => '\\n',
|
"\r" => '\\r',
|
||||||
'</' => '<\/')
|
"\n" => '\\n',
|
||||||
|
'</' => '<\/'
|
||||||
|
)
|
||||||
);
|
);
|
||||||
case 'mail':
|
case 'mail':
|
||||||
if (Smarty::$_MBSTRING) {
|
if (Smarty::$_MBSTRING) {
|
||||||
@@ -180,19 +196,27 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
|
|||||||
$is_loaded_2 = true;
|
$is_loaded_2 = true;
|
||||||
}
|
}
|
||||||
return smarty_mb_str_replace(
|
return smarty_mb_str_replace(
|
||||||
array('@',
|
array(
|
||||||
'.'),
|
'@',
|
||||||
array(' [AT] ',
|
'.'
|
||||||
' [DOT] '),
|
),
|
||||||
|
array(
|
||||||
|
' [AT] ',
|
||||||
|
' [DOT] '
|
||||||
|
),
|
||||||
$string
|
$string
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// no MBString fallback
|
// no MBString fallback
|
||||||
return str_replace(
|
return str_replace(
|
||||||
array('@',
|
array(
|
||||||
'.'),
|
'@',
|
||||||
array(' [AT] ',
|
'.'
|
||||||
' [DOT] '),
|
),
|
||||||
|
array(
|
||||||
|
' [AT] ',
|
||||||
|
' [DOT] '
|
||||||
|
),
|
||||||
$string
|
$string
|
||||||
);
|
);
|
||||||
case 'nonstd':
|
case 'nonstd':
|
||||||
|
@@ -11,7 +11,7 @@
|
|||||||
* Name: mb_wordwrap
|
* Name: mb_wordwrap
|
||||||
* Purpose: Wrap a string to a given number of characters
|
* Purpose: Wrap a string to a given number of characters
|
||||||
*
|
*
|
||||||
* @link http://php.net/manual/en/function.wordwrap.php for similarity
|
* @link http://php.net/manual/en/function.wordwrap.php for similarity
|
||||||
*
|
*
|
||||||
* @param string $str the string to wrap
|
* @param string $str the string to wrap
|
||||||
* @param int $width the width of the output
|
* @param int $width the width of the output
|
||||||
@@ -29,7 +29,6 @@ function smarty_modifier_mb_wordwrap($str, $width = 75, $break = "\n", $cut = fa
|
|||||||
$t = '';
|
$t = '';
|
||||||
$_previous = false;
|
$_previous = false;
|
||||||
$_space = false;
|
$_space = false;
|
||||||
|
|
||||||
foreach ($tokens as $_token) {
|
foreach ($tokens as $_token) {
|
||||||
$token_length = mb_strlen($_token, Smarty::$_CHARSET);
|
$token_length = mb_strlen($_token, Smarty::$_CHARSET);
|
||||||
$_tokens = array($_token);
|
$_tokens = array($_token);
|
||||||
@@ -43,18 +42,15 @@ function smarty_modifier_mb_wordwrap($str, $width = 75, $break = "\n", $cut = fa
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($_tokens as $token) {
|
foreach ($_tokens as $token) {
|
||||||
$_space = !!preg_match('!^\s$!S' . Smarty::$_UTF8_MODIFIER, $token);
|
$_space = !!preg_match('!^\s$!S' . Smarty::$_UTF8_MODIFIER, $token);
|
||||||
$token_length = mb_strlen($token, Smarty::$_CHARSET);
|
$token_length = mb_strlen($token, Smarty::$_CHARSET);
|
||||||
$length += $token_length;
|
$length += $token_length;
|
||||||
|
|
||||||
if ($length > $width) {
|
if ($length > $width) {
|
||||||
// remove space before inserted break
|
// remove space before inserted break
|
||||||
if ($_previous) {
|
if ($_previous) {
|
||||||
$t = mb_substr($t, 0, -1, Smarty::$_CHARSET);
|
$t = mb_substr($t, 0, -1, Smarty::$_CHARSET);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$_space) {
|
if (!$_space) {
|
||||||
// add the break before the token
|
// add the break before the token
|
||||||
if (!empty($t)) {
|
if (!empty($t)) {
|
||||||
@@ -71,6 +67,5 @@ function smarty_modifier_mb_wordwrap($str, $width = 75, $break = "\n", $cut = fa
|
|||||||
$t .= $token;
|
$t .= $token;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $t;
|
return $t;
|
||||||
}
|
}
|
||||||
|
@@ -5,7 +5,6 @@
|
|||||||
* @package Smarty
|
* @package Smarty
|
||||||
* @subpackage PluginsModifier
|
* @subpackage PluginsModifier
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty regex_replace modifier plugin
|
* Smarty regex_replace modifier plugin
|
||||||
* Type: modifier
|
* Type: modifier
|
||||||
@@ -23,7 +22,7 @@
|
|||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function smarty_modifier_regex_replace($string, $search, $replace, $limit = - 1)
|
function smarty_modifier_regex_replace($string, $search, $replace, $limit = -1)
|
||||||
{
|
{
|
||||||
if (is_array($search)) {
|
if (is_array($search)) {
|
||||||
foreach ($search as $idx => $s) {
|
foreach ($search as $idx => $s) {
|
||||||
@@ -32,7 +31,6 @@ function smarty_modifier_regex_replace($string, $search, $replace, $limit = - 1)
|
|||||||
} else {
|
} else {
|
||||||
$search = _smarty_regex_replace_check($search);
|
$search = _smarty_regex_replace_check($search);
|
||||||
}
|
}
|
||||||
|
|
||||||
return preg_replace($search, $replace, $string, $limit);
|
return preg_replace($search, $replace, $string, $limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,8 +49,7 @@ function _smarty_regex_replace_check($search)
|
|||||||
}
|
}
|
||||||
// remove eval-modifier from $search
|
// remove eval-modifier from $search
|
||||||
if (preg_match('!([a-zA-Z\s]+)$!s', $search, $match) && (strpos($match[ 1 ], 'e') !== false)) {
|
if (preg_match('!([a-zA-Z\s]+)$!s', $search, $match) && (strpos($match[ 1 ], 'e') !== false)) {
|
||||||
$search = substr($search, 0, - strlen($match[ 1 ])) . preg_replace('![e\s]+!', '', $match[ 1 ]);
|
$search = substr($search, 0, -strlen($match[ 1 ])) . preg_replace('![e\s]+!', '', $match[ 1 ]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $search;
|
return $search;
|
||||||
}
|
}
|
||||||
|
@@ -5,7 +5,6 @@
|
|||||||
* @package Smarty
|
* @package Smarty
|
||||||
* @subpackage PluginsModifier
|
* @subpackage PluginsModifier
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty replace modifier plugin
|
* Smarty replace modifier plugin
|
||||||
* Type: modifier
|
* Type: modifier
|
||||||
@@ -32,8 +31,7 @@ function smarty_modifier_replace($string, $search, $replace)
|
|||||||
}
|
}
|
||||||
$is_loaded = true;
|
$is_loaded = true;
|
||||||
}
|
}
|
||||||
return smarty_mb_str_replace($search, $replace, $string);
|
return smarty_mb_str_replace($search, $replace, $string);
|
||||||
}
|
}
|
||||||
|
|
||||||
return str_replace($search, $replace, $string);
|
return str_replace($search, $replace, $string);
|
||||||
}
|
}
|
||||||
|
@@ -5,7 +5,6 @@
|
|||||||
* @package Smarty
|
* @package Smarty
|
||||||
* @subpackage PluginsModifier
|
* @subpackage PluginsModifier
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty spacify modifier plugin
|
* Smarty spacify modifier plugin
|
||||||
* Type: modifier
|
* Type: modifier
|
||||||
@@ -23,5 +22,5 @@
|
|||||||
function smarty_modifier_spacify($string, $spacify_char = ' ')
|
function smarty_modifier_spacify($string, $spacify_char = ' ')
|
||||||
{
|
{
|
||||||
// well… what about charsets besides latin and UTF-8?
|
// well… what about charsets besides latin and UTF-8?
|
||||||
return implode($spacify_char, preg_split('//' . Smarty::$_UTF8_MODIFIER, $string, - 1, PREG_SPLIT_NO_EMPTY));
|
return implode($spacify_char, preg_split('//' . Smarty::$_UTF8_MODIFIER, $string, -1, PREG_SPLIT_NO_EMPTY));
|
||||||
}
|
}
|
||||||
|
@@ -5,7 +5,6 @@
|
|||||||
* @package Smarty
|
* @package Smarty
|
||||||
* @subpackage PluginsModifier
|
* @subpackage PluginsModifier
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty truncate modifier plugin
|
* Smarty truncate modifier plugin
|
||||||
* Type: modifier
|
* Type: modifier
|
||||||
@@ -30,27 +29,24 @@ function smarty_modifier_truncate($string, $length = 80, $etc = '...', $break_wo
|
|||||||
if ($length === 0) {
|
if ($length === 0) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Smarty::$_MBSTRING) {
|
if (Smarty::$_MBSTRING) {
|
||||||
if (mb_strlen($string, Smarty::$_CHARSET) > $length) {
|
if (mb_strlen($string, Smarty::$_CHARSET) > $length) {
|
||||||
$length -= min($length, mb_strlen($etc, Smarty::$_CHARSET));
|
$length -= min($length, mb_strlen($etc, Smarty::$_CHARSET));
|
||||||
if (!$break_words && !$middle) {
|
if (!$break_words && !$middle) {
|
||||||
$string = preg_replace(
|
$string = preg_replace(
|
||||||
'/\s+?(\S+)?$/' . Smarty::$_UTF8_MODIFIER, '',
|
'/\s+?(\S+)?$/' . Smarty::$_UTF8_MODIFIER,
|
||||||
|
'',
|
||||||
mb_substr($string, 0, $length + 1, Smarty::$_CHARSET)
|
mb_substr($string, 0, $length + 1, Smarty::$_CHARSET)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (!$middle) {
|
if (!$middle) {
|
||||||
return mb_substr($string, 0, $length, Smarty::$_CHARSET) . $etc;
|
return mb_substr($string, 0, $length, Smarty::$_CHARSET) . $etc;
|
||||||
}
|
}
|
||||||
|
|
||||||
return mb_substr($string, 0, $length / 2, Smarty::$_CHARSET) . $etc .
|
return mb_substr($string, 0, $length / 2, Smarty::$_CHARSET) . $etc .
|
||||||
mb_substr($string, - $length / 2, $length, Smarty::$_CHARSET);
|
mb_substr($string, -$length / 2, $length, Smarty::$_CHARSET);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $string;
|
return $string;
|
||||||
}
|
}
|
||||||
|
|
||||||
// no MBString fallback
|
// no MBString fallback
|
||||||
if (isset($string[ $length ])) {
|
if (isset($string[ $length ])) {
|
||||||
$length -= min($length, strlen($etc));
|
$length -= min($length, strlen($etc));
|
||||||
@@ -60,9 +56,7 @@ function smarty_modifier_truncate($string, $length = 80, $etc = '...', $break_wo
|
|||||||
if (!$middle) {
|
if (!$middle) {
|
||||||
return substr($string, 0, $length) . $etc;
|
return substr($string, 0, $length) . $etc;
|
||||||
}
|
}
|
||||||
|
return substr($string, 0, $length / 2) . $etc . substr($string, -$length / 2);
|
||||||
return substr($string, 0, $length / 2) . $etc . substr($string, - $length / 2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $string;
|
return $string;
|
||||||
}
|
}
|
||||||
|
@@ -5,7 +5,6 @@
|
|||||||
* @package Smarty
|
* @package Smarty
|
||||||
* @subpackage PluginsModifierCompiler
|
* @subpackage PluginsModifierCompiler
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty cat modifier plugin
|
* Smarty cat modifier plugin
|
||||||
* Type: modifier
|
* Type: modifier
|
||||||
|
@@ -5,14 +5,14 @@
|
|||||||
* @package Smarty
|
* @package Smarty
|
||||||
* @subpackage PluginsModifierCompiler
|
* @subpackage PluginsModifierCompiler
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty count_characters modifier plugin
|
* Smarty count_characters modifier plugin
|
||||||
* Type: modifier
|
* Type: modifier
|
||||||
* Name: count_characters
|
* Name: count_characters
|
||||||
* Purpose: count the number of characters in a text
|
* Purpose: count the number of characters in a text
|
||||||
*
|
*
|
||||||
* @link http://www.smarty.net/manual/en/language.modifier.count.characters.php count_characters (Smarty online manual)
|
* @link http://www.smarty.net/manual/en/language.modifier.count.characters.php count_characters (Smarty online
|
||||||
|
* manual)
|
||||||
* @author Uwe Tews
|
* @author Uwe Tews
|
||||||
*
|
*
|
||||||
* @param array $params parameters
|
* @param array $params parameters
|
||||||
|
@@ -5,7 +5,6 @@
|
|||||||
* @package Smarty
|
* @package Smarty
|
||||||
* @subpackage PluginsModifierCompiler
|
* @subpackage PluginsModifierCompiler
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty count_paragraphs modifier plugin
|
* Smarty count_paragraphs modifier plugin
|
||||||
* Type: modifier
|
* Type: modifier
|
||||||
|
@@ -5,7 +5,6 @@
|
|||||||
* @package Smarty
|
* @package Smarty
|
||||||
* @subpackage PluginsModifierCompiler
|
* @subpackage PluginsModifierCompiler
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty count_sentences modifier plugin
|
* Smarty count_sentences modifier plugin
|
||||||
* Type: modifier
|
* Type: modifier
|
||||||
|
@@ -5,7 +5,6 @@
|
|||||||
* @package Smarty
|
* @package Smarty
|
||||||
* @subpackage PluginsModifierCompiler
|
* @subpackage PluginsModifierCompiler
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty count_words modifier plugin
|
* Smarty count_words modifier plugin
|
||||||
* Type: modifier
|
* Type: modifier
|
||||||
|
@@ -5,7 +5,6 @@
|
|||||||
* @package Smarty
|
* @package Smarty
|
||||||
* @subpackage PluginsModifierCompiler
|
* @subpackage PluginsModifierCompiler
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty default modifier plugin
|
* Smarty default modifier plugin
|
||||||
* Type: modifier
|
* Type: modifier
|
||||||
@@ -25,11 +24,9 @@ function smarty_modifiercompiler_default($params)
|
|||||||
if (!isset($params[ 1 ])) {
|
if (!isset($params[ 1 ])) {
|
||||||
$params[ 1 ] = "''";
|
$params[ 1 ] = "''";
|
||||||
}
|
}
|
||||||
|
|
||||||
array_shift($params);
|
array_shift($params);
|
||||||
foreach ($params as $param) {
|
foreach ($params as $param) {
|
||||||
$output = '(($tmp = @' . $output . ')===null||$tmp===\'\' ? ' . $param . ' : $tmp)';
|
$output = '(($tmp = @' . $output . ')===null||$tmp===\'\' ? ' . $param . ' : $tmp)';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
@@ -25,8 +25,12 @@ function smarty_modifiercompiler_escape($params, Smarty_Internal_TemplateCompile
|
|||||||
static $_double_encode = null;
|
static $_double_encode = null;
|
||||||
static $is_loaded = false;
|
static $is_loaded = false;
|
||||||
$compiler->template->_checkPlugins(
|
$compiler->template->_checkPlugins(
|
||||||
array(array('function' => 'smarty_literal_compiler_param',
|
array(
|
||||||
'file' => SMARTY_PLUGINS_DIR . 'shared.literal_compiler_param.php'))
|
array(
|
||||||
|
'function' => 'smarty_literal_compiler_param',
|
||||||
|
'file' => SMARTY_PLUGINS_DIR . 'shared.literal_compiler_param.php'
|
||||||
|
)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
if ($_double_encode === null) {
|
if ($_double_encode === null) {
|
||||||
$_double_encode = version_compare(PHP_VERSION, '5.2.3', '>=');
|
$_double_encode = version_compare(PHP_VERSION, '5.2.3', '>=');
|
||||||
@@ -48,6 +52,7 @@ function smarty_modifiercompiler_escape($params, Smarty_Internal_TemplateCompile
|
|||||||
} else {
|
} else {
|
||||||
// fall back to modifier.escape.php
|
// fall back to modifier.escape.php
|
||||||
}
|
}
|
||||||
|
// no break
|
||||||
case 'htmlall':
|
case 'htmlall':
|
||||||
if (Smarty::$_MBSTRING) {
|
if (Smarty::$_MBSTRING) {
|
||||||
if ($_double_encode) {
|
if ($_double_encode) {
|
||||||
@@ -74,6 +79,7 @@ function smarty_modifiercompiler_escape($params, Smarty_Internal_TemplateCompile
|
|||||||
} else {
|
} else {
|
||||||
// fall back to modifier.escape.php
|
// fall back to modifier.escape.php
|
||||||
}
|
}
|
||||||
|
// no break
|
||||||
case 'url':
|
case 'url':
|
||||||
return 'rawurlencode(' . $params[ 0 ] . ')';
|
return 'rawurlencode(' . $params[ 0 ] . ')';
|
||||||
case 'urlpathinfo':
|
case 'urlpathinfo':
|
||||||
@@ -87,8 +93,7 @@ function smarty_modifiercompiler_escape($params, Smarty_Internal_TemplateCompile
|
|||||||
$params[ 0 ] .
|
$params[ 0 ] .
|
||||||
', array("\\\\" => "\\\\\\\\", "\'" => "\\\\\'", "\"" => "\\\\\"", "\\r" => "\\\\r", "\\n" => "\\\n", "</" => "<\/" ))';
|
', array("\\\\" => "\\\\\\\\", "\'" => "\\\\\'", "\"" => "\\\\\"", "\\r" => "\\\\r", "\\n" => "\\\n", "</" => "<\/" ))';
|
||||||
}
|
}
|
||||||
}
|
} catch (SmartyException $e) {
|
||||||
catch (SmartyException $e) {
|
|
||||||
// pass through to regular plugin fallback
|
// pass through to regular plugin fallback
|
||||||
}
|
}
|
||||||
// could not optimize |escape call, so fallback to regular plugin
|
// could not optimize |escape call, so fallback to regular plugin
|
||||||
|
@@ -5,7 +5,6 @@
|
|||||||
* @package Smarty
|
* @package Smarty
|
||||||
* @subpackage PluginsModifierCompiler
|
* @subpackage PluginsModifierCompiler
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty from_charset modifier plugin
|
* Smarty from_charset modifier plugin
|
||||||
* Type: modifier
|
* Type: modifier
|
||||||
@@ -24,10 +23,8 @@ function smarty_modifiercompiler_from_charset($params)
|
|||||||
// FIXME: (rodneyrehm) shouldn't this throw an error?
|
// FIXME: (rodneyrehm) shouldn't this throw an error?
|
||||||
return $params[ 0 ];
|
return $params[ 0 ];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($params[ 1 ])) {
|
if (!isset($params[ 1 ])) {
|
||||||
$params[ 1 ] = '"ISO-8859-1"';
|
$params[ 1 ] = '"ISO-8859-1"';
|
||||||
}
|
}
|
||||||
|
|
||||||
return 'mb_convert_encoding(' . $params[ 0 ] . ', "' . addslashes(Smarty::$_CHARSET) . '", ' . $params[ 1 ] . ')';
|
return 'mb_convert_encoding(' . $params[ 0 ] . ', "' . addslashes(Smarty::$_CHARSET) . '", ' . $params[ 1 ] . ')';
|
||||||
}
|
}
|
||||||
|
@@ -5,7 +5,6 @@
|
|||||||
* @package Smarty
|
* @package Smarty
|
||||||
* @subpackage PluginsModifierCompiler
|
* @subpackage PluginsModifierCompiler
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty indent modifier plugin
|
* Smarty indent modifier plugin
|
||||||
* Type: modifier
|
* Type: modifier
|
||||||
@@ -19,7 +18,6 @@
|
|||||||
*
|
*
|
||||||
* @return string with compiled code
|
* @return string with compiled code
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function smarty_modifiercompiler_indent($params)
|
function smarty_modifiercompiler_indent($params)
|
||||||
{
|
{
|
||||||
if (!isset($params[ 1 ])) {
|
if (!isset($params[ 1 ])) {
|
||||||
@@ -28,6 +26,5 @@ function smarty_modifiercompiler_indent($params)
|
|||||||
if (!isset($params[ 2 ])) {
|
if (!isset($params[ 2 ])) {
|
||||||
$params[ 2 ] = "' '";
|
$params[ 2 ] = "' '";
|
||||||
}
|
}
|
||||||
|
|
||||||
return 'preg_replace(\'!^!m\',str_repeat(' . $params[ 2 ] . ',' . $params[ 1 ] . '),' . $params[ 0 ] . ')';
|
return 'preg_replace(\'!^!m\',str_repeat(' . $params[ 2 ] . ',' . $params[ 1 ] . '),' . $params[ 0 ] . ')';
|
||||||
}
|
}
|
||||||
|
@@ -5,7 +5,6 @@
|
|||||||
* @package Smarty
|
* @package Smarty
|
||||||
* @subpackage PluginsModifierCompiler
|
* @subpackage PluginsModifierCompiler
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty lower modifier plugin
|
* Smarty lower modifier plugin
|
||||||
* Type: modifier
|
* Type: modifier
|
||||||
@@ -20,7 +19,6 @@
|
|||||||
*
|
*
|
||||||
* @return string with compiled code
|
* @return string with compiled code
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function smarty_modifiercompiler_lower($params)
|
function smarty_modifiercompiler_lower($params)
|
||||||
{
|
{
|
||||||
if (Smarty::$_MBSTRING) {
|
if (Smarty::$_MBSTRING) {
|
||||||
|
@@ -5,7 +5,6 @@
|
|||||||
* @package Smarty
|
* @package Smarty
|
||||||
* @subpackage PluginsModifierCompiler
|
* @subpackage PluginsModifierCompiler
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty noprint modifier plugin
|
* Smarty noprint modifier plugin
|
||||||
* Type: modifier
|
* Type: modifier
|
||||||
|
@@ -5,7 +5,6 @@
|
|||||||
* @package Smarty
|
* @package Smarty
|
||||||
* @subpackage PluginsModifierCompiler
|
* @subpackage PluginsModifierCompiler
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty string_format modifier plugin
|
* Smarty string_format modifier plugin
|
||||||
* Type: modifier
|
* Type: modifier
|
||||||
|
@@ -5,7 +5,6 @@
|
|||||||
* @package Smarty
|
* @package Smarty
|
||||||
* @subpackage PluginsModifierCompiler
|
* @subpackage PluginsModifierCompiler
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty strip modifier plugin
|
* Smarty strip modifier plugin
|
||||||
* Type: modifier
|
* Type: modifier
|
||||||
@@ -22,12 +21,10 @@
|
|||||||
*
|
*
|
||||||
* @return string with compiled code
|
* @return string with compiled code
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function smarty_modifiercompiler_strip($params)
|
function smarty_modifiercompiler_strip($params)
|
||||||
{
|
{
|
||||||
if (!isset($params[ 1 ])) {
|
if (!isset($params[ 1 ])) {
|
||||||
$params[ 1 ] = "' '";
|
$params[ 1 ] = "' '";
|
||||||
}
|
}
|
||||||
|
|
||||||
return "preg_replace('!\s+!" . Smarty::$_UTF8_MODIFIER . "', {$params[1]},{$params[0]})";
|
return "preg_replace('!\s+!" . Smarty::$_UTF8_MODIFIER . "', {$params[1]},{$params[0]})";
|
||||||
}
|
}
|
||||||
|
@@ -5,7 +5,6 @@
|
|||||||
* @package Smarty
|
* @package Smarty
|
||||||
* @subpackage PluginsModifierCompiler
|
* @subpackage PluginsModifierCompiler
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty strip_tags modifier plugin
|
* Smarty strip_tags modifier plugin
|
||||||
* Type: modifier
|
* Type: modifier
|
||||||
|
@@ -5,7 +5,6 @@
|
|||||||
* @package Smarty
|
* @package Smarty
|
||||||
* @subpackage PluginsModifierCompiler
|
* @subpackage PluginsModifierCompiler
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty to_charset modifier plugin
|
* Smarty to_charset modifier plugin
|
||||||
* Type: modifier
|
* Type: modifier
|
||||||
@@ -24,10 +23,8 @@ function smarty_modifiercompiler_to_charset($params)
|
|||||||
// FIXME: (rodneyrehm) shouldn't this throw an error?
|
// FIXME: (rodneyrehm) shouldn't this throw an error?
|
||||||
return $params[ 0 ];
|
return $params[ 0 ];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($params[ 1 ])) {
|
if (!isset($params[ 1 ])) {
|
||||||
$params[ 1 ] = '"ISO-8859-1"';
|
$params[ 1 ] = '"ISO-8859-1"';
|
||||||
}
|
}
|
||||||
|
|
||||||
return 'mb_convert_encoding(' . $params[ 0 ] . ', ' . $params[ 1 ] . ', "' . addslashes(Smarty::$_CHARSET) . '")';
|
return 'mb_convert_encoding(' . $params[ 0 ] . ', ' . $params[ 1 ] . ', "' . addslashes(Smarty::$_CHARSET) . '")';
|
||||||
}
|
}
|
||||||
|
@@ -5,7 +5,6 @@
|
|||||||
* @package Smarty
|
* @package Smarty
|
||||||
* @subpackage PluginsModifierCompiler
|
* @subpackage PluginsModifierCompiler
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty upper modifier plugin
|
* Smarty upper modifier plugin
|
||||||
* Type: modifier
|
* Type: modifier
|
||||||
|
@@ -14,7 +14,7 @@
|
|||||||
* @link http://smarty.php.net/manual/en/language.modifier.wordwrap.php wordwrap (Smarty online manual)
|
* @link http://smarty.php.net/manual/en/language.modifier.wordwrap.php wordwrap (Smarty online manual)
|
||||||
* @author Uwe Tews
|
* @author Uwe Tews
|
||||||
*
|
*
|
||||||
* @param array $params parameters
|
* @param array $params parameters
|
||||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler
|
* @param \Smarty_Internal_TemplateCompilerBase $compiler
|
||||||
*
|
*
|
||||||
* @return string with compiled code
|
* @return string with compiled code
|
||||||
|
@@ -5,7 +5,6 @@
|
|||||||
* @package Smarty
|
* @package Smarty
|
||||||
* @subpackage PluginsFilter
|
* @subpackage PluginsFilter
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty trimwhitespace outputfilter plugin
|
* Smarty trimwhitespace outputfilter plugin
|
||||||
* Trim unnecessary whitespace from HTML markup.
|
* Trim unnecessary whitespace from HTML markup.
|
||||||
@@ -22,13 +21,13 @@ function smarty_outputfilter_trimwhitespace($source)
|
|||||||
$store = array();
|
$store = array();
|
||||||
$_store = 0;
|
$_store = 0;
|
||||||
$_offset = 0;
|
$_offset = 0;
|
||||||
|
|
||||||
// Unify Line-Breaks to \n
|
// Unify Line-Breaks to \n
|
||||||
$source = preg_replace('/\015\012|\015|\012/', "\n", $source);
|
$source = preg_replace('/\015\012|\015|\012/', "\n", $source);
|
||||||
|
|
||||||
// capture Internet Explorer and KnockoutJS Conditional Comments
|
// capture Internet Explorer and KnockoutJS Conditional Comments
|
||||||
if (preg_match_all(
|
if (preg_match_all(
|
||||||
'#<!--((\[[^\]]+\]>.*?<!\[[^\]]+\])|(\s*/?ko\s+.+))-->#is', $source, $matches,
|
'#<!--((\[[^\]]+\]>.*?<!\[[^\]]+\])|(\s*/?ko\s+.+))-->#is',
|
||||||
|
$source,
|
||||||
|
$matches,
|
||||||
PREG_OFFSET_CAPTURE | PREG_SET_ORDER
|
PREG_OFFSET_CAPTURE | PREG_SET_ORDER
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
@@ -37,21 +36,20 @@ function smarty_outputfilter_trimwhitespace($source)
|
|||||||
$_length = strlen($match[ 0 ][ 0 ]);
|
$_length = strlen($match[ 0 ][ 0 ]);
|
||||||
$replace = '@!@SMARTY:' . $_store . ':SMARTY@!@';
|
$replace = '@!@SMARTY:' . $_store . ':SMARTY@!@';
|
||||||
$source = substr_replace($source, $replace, $match[ 0 ][ 1 ] - $_offset, $_length);
|
$source = substr_replace($source, $replace, $match[ 0 ][ 1 ] - $_offset, $_length);
|
||||||
|
|
||||||
$_offset += $_length - strlen($replace);
|
$_offset += $_length - strlen($replace);
|
||||||
$_store ++;
|
$_store++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Strip all HTML-Comments
|
// Strip all HTML-Comments
|
||||||
// yes, even the ones in <script> - see http://stackoverflow.com/a/808850/515124
|
// yes, even the ones in <script> - see http://stackoverflow.com/a/808850/515124
|
||||||
$source = preg_replace('#<!--.*?-->#ms', '', $source);
|
$source = preg_replace('#<!--.*?-->#ms', '', $source);
|
||||||
|
|
||||||
// capture html elements not to be messed with
|
// capture html elements not to be messed with
|
||||||
$_offset = 0;
|
$_offset = 0;
|
||||||
if (preg_match_all(
|
if (preg_match_all(
|
||||||
'#(<script[^>]*>.*?</script[^>]*>)|(<textarea[^>]*>.*?</textarea[^>]*>)|(<pre[^>]*>.*?</pre[^>]*>)#is',
|
'#(<script[^>]*>.*?</script[^>]*>)|(<textarea[^>]*>.*?</textarea[^>]*>)|(<pre[^>]*>.*?</pre[^>]*>)#is',
|
||||||
$source, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER
|
$source,
|
||||||
|
$matches,
|
||||||
|
PREG_OFFSET_CAPTURE | PREG_SET_ORDER
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
foreach ($matches as $match) {
|
foreach ($matches as $match) {
|
||||||
@@ -59,37 +57,33 @@ function smarty_outputfilter_trimwhitespace($source)
|
|||||||
$_length = strlen($match[ 0 ][ 0 ]);
|
$_length = strlen($match[ 0 ][ 0 ]);
|
||||||
$replace = '@!@SMARTY:' . $_store . ':SMARTY@!@';
|
$replace = '@!@SMARTY:' . $_store . ':SMARTY@!@';
|
||||||
$source = substr_replace($source, $replace, $match[ 0 ][ 1 ] - $_offset, $_length);
|
$source = substr_replace($source, $replace, $match[ 0 ][ 1 ] - $_offset, $_length);
|
||||||
|
|
||||||
$_offset += $_length - strlen($replace);
|
$_offset += $_length - strlen($replace);
|
||||||
$_store ++;
|
$_store++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$expressions = array(// replace multiple spaces between tags by a single space
|
$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
|
// 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!)
|
// remove spaces between attributes (but not in attribute values!)
|
||||||
'#(([a-z0-9]\s*=\s*("[^"]*?")|(\'[^\']*?\'))|<[a-z0-9_]+)\s+([a-z/>])#is' => '\1 \5',
|
'#(([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.
|
// note: for some very weird reason trim() seems to remove spaces inside attributes.
|
||||||
// maybe a \0 byte or something is interfering?
|
// 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);
|
$source = preg_replace(array_keys($expressions), array_values($expressions), $source);
|
||||||
// note: for some very weird reason trim() seems to remove spaces inside attributes.
|
// note: for some very weird reason trim() seems to remove spaces inside attributes.
|
||||||
// maybe a \0 byte or something is interfering?
|
// maybe a \0 byte or something is interfering?
|
||||||
// $source = trim( $source );
|
// $source = trim( $source );
|
||||||
|
|
||||||
$_offset = 0;
|
$_offset = 0;
|
||||||
if (preg_match_all('#@!@SMARTY:([0-9]+):SMARTY@!@#is', $source, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) {
|
if (preg_match_all('#@!@SMARTY:([0-9]+):SMARTY@!@#is', $source, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) {
|
||||||
foreach ($matches as $match) {
|
foreach ($matches as $match) {
|
||||||
$_length = strlen($match[ 0 ][ 0 ]);
|
$_length = strlen($match[ 0 ][ 0 ]);
|
||||||
$replace = $store[ $match[ 1 ][ 0 ] ];
|
$replace = $store[ $match[ 1 ][ 0 ] ];
|
||||||
$source = substr_replace($source, $replace, $match[ 0 ][ 1 ] + $_offset, $_length);
|
$source = substr_replace($source, $replace, $match[ 0 ][ 1 ] + $_offset, $_length);
|
||||||
|
|
||||||
$_offset += strlen($replace) - $_length;
|
$_offset += strlen($replace) - $_length;
|
||||||
$_store ++;
|
$_store++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $source;
|
return $source;
|
||||||
}
|
}
|
||||||
|
@@ -5,7 +5,6 @@
|
|||||||
* @package Smarty
|
* @package Smarty
|
||||||
* @subpackage PluginsShared
|
* @subpackage PluginsShared
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* escape_special_chars common function
|
* escape_special_chars common function
|
||||||
* Function: smarty_function_escape_special_chars
|
* 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);
|
$string = str_replace(array('%%%SMARTY_START%%%', '%%%SMARTY_END%%%'), array('&', ';'), $string);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $string;
|
return $string;
|
||||||
}
|
}
|
||||||
|
@@ -5,7 +5,6 @@
|
|||||||
* @package Smarty
|
* @package Smarty
|
||||||
* @subpackage PluginsShared
|
* @subpackage PluginsShared
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* evaluate compiler parameter
|
* 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'
|
'] is not a literal and is thus not evaluatable at compile time'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$t = null;
|
$t = null;
|
||||||
eval("\$t = " . $params[ $index ] . ";");
|
eval("\$t = " . $params[ $index ] . ";");
|
||||||
|
|
||||||
return $t;
|
return $t;
|
||||||
}
|
}
|
||||||
|
@@ -5,7 +5,6 @@
|
|||||||
* @package Smarty
|
* @package Smarty
|
||||||
* @subpackage PluginsShared
|
* @subpackage PluginsShared
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function: smarty_make_timestamp
|
* Function: smarty_make_timestamp
|
||||||
* Purpose: used by other smarty functions to make a timestamp from a string.
|
* Purpose: used by other smarty functions to make a timestamp from a string.
|
||||||
@@ -22,26 +21,29 @@ function smarty_make_timestamp($string)
|
|||||||
// use "now":
|
// use "now":
|
||||||
return time();
|
return time();
|
||||||
} elseif ($string instanceof DateTime
|
} elseif ($string instanceof DateTime
|
||||||
|| (interface_exists('DateTimeInterface', false) && $string instanceof DateTimeInterface)
|
|| (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)) {
|
} elseif (strlen($string) === 14 && ctype_digit($string)) {
|
||||||
// it is mysql timestamp format of YYYYMMDDHHMMSS?
|
// it is mysql timestamp format of YYYYMMDDHHMMSS?
|
||||||
return mktime(
|
return mktime(
|
||||||
substr($string, 8, 2), substr($string, 10, 2), substr($string, 12, 2), substr($string, 4, 2),
|
substr($string, 8, 2),
|
||||||
substr($string, 6, 2), substr($string, 0, 4)
|
substr($string, 10, 2),
|
||||||
|
substr($string, 12, 2),
|
||||||
|
substr($string, 4, 2),
|
||||||
|
substr($string, 6, 2),
|
||||||
|
substr($string, 0, 4)
|
||||||
);
|
);
|
||||||
} elseif (is_numeric($string)) {
|
} elseif (is_numeric($string)) {
|
||||||
// it is a numeric string, we handle it as timestamp
|
// it is a numeric string, we handle it as timestamp
|
||||||
return (int) $string;
|
return (int)$string;
|
||||||
} else {
|
} else {
|
||||||
// strtotime should handle it
|
// strtotime should handle it
|
||||||
$time = strtotime($string);
|
$time = strtotime($string);
|
||||||
if ($time === - 1 || $time === false) {
|
if ($time === -1 || $time === false) {
|
||||||
// strtotime() was not able to parse $string, use "now":
|
// strtotime() was not able to parse $string, use "now":
|
||||||
return time();
|
return time();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $time;
|
return $time;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -5,11 +5,10 @@
|
|||||||
* @package Smarty
|
* @package Smarty
|
||||||
* @subpackage PluginsShared
|
* @subpackage PluginsShared
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* convert characters to their decimal unicode equivalents
|
* 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 $string characters to calculate unicode of
|
||||||
* @param string $encoding encoding of $string, if null mb_internal_encoding() is used
|
* @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 {
|
} else {
|
||||||
$expanded = mb_convert_encoding($string, 'UTF-32BE');
|
$expanded = mb_convert_encoding($string, 'UTF-32BE');
|
||||||
}
|
}
|
||||||
|
|
||||||
return unpack('N*', $expanded);
|
return unpack('N*', $expanded);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* convert unicodes to the character of given encoding
|
* 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 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
|
* @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) {
|
if (!$encoding) {
|
||||||
$encoding = mb_internal_encoding();
|
$encoding = mb_internal_encoding();
|
||||||
}
|
}
|
||||||
foreach ((array) $unicode as $utf32be) {
|
foreach ((array)$unicode as $utf32be) {
|
||||||
$character = pack('N*', $utf32be);
|
$character = pack('N*', $utf32be);
|
||||||
$t .= mb_convert_encoding($character, $encoding, 'UTF-32BE');
|
$t .= mb_convert_encoding($character, $encoding, 'UTF-32BE');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $t;
|
return $t;
|
||||||
}
|
}
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
/**
|
/**
|
||||||
* Smarty htmlspecialchars variablefilter plugin
|
* Smarty htmlspecialchars variablefilter plugin
|
||||||
*
|
*
|
||||||
* @param string $source input string
|
* @param string $source input string
|
||||||
* @param \Smarty_Internal_Template $template
|
* @param \Smarty_Internal_Template $template
|
||||||
*
|
*
|
||||||
* @return string filtered output
|
* @return string filtered output
|
||||||
|
@@ -25,7 +25,7 @@ abstract class Smarty_CacheResource
|
|||||||
/**
|
/**
|
||||||
* populate Cached Object with meta data from Resource
|
* 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
|
* @param Smarty_Internal_Template $_template template object
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
@@ -50,7 +50,9 @@ abstract class Smarty_CacheResource
|
|||||||
*
|
*
|
||||||
* @return boolean true or false if the cached content does not exist
|
* @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
|
$update = false
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -71,7 +73,7 @@ abstract class Smarty_CacheResource
|
|||||||
*
|
*
|
||||||
* @return string content
|
* @return string content
|
||||||
*/
|
*/
|
||||||
abstract function readCachedContent(Smarty_Internal_Template $_template);
|
abstract public function readCachedContent(Smarty_Internal_Template $_template);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return cached content
|
* Return cached content
|
||||||
@@ -88,7 +90,6 @@ abstract class Smarty_CacheResource
|
|||||||
$unifunc($_template);
|
$unifunc($_template);
|
||||||
return ob_get_clean();
|
return ob_get_clean();
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,7 +135,6 @@ abstract class Smarty_CacheResource
|
|||||||
}
|
}
|
||||||
sleep(1);
|
sleep(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $hadLock;
|
return $hadLock;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,12 +194,10 @@ abstract class Smarty_CacheResource
|
|||||||
if (!isset($type)) {
|
if (!isset($type)) {
|
||||||
$type = $smarty->caching_type;
|
$type = $smarty->caching_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
// try smarty's cache
|
// try smarty's cache
|
||||||
if (isset($smarty->_cache[ 'cacheresource_handlers' ][ $type ])) {
|
if (isset($smarty->_cache[ 'cacheresource_handlers' ][ $type ])) {
|
||||||
return $smarty->_cache[ 'cacheresource_handlers' ][ $type ];
|
return $smarty->_cache[ 'cacheresource_handlers' ][ $type ];
|
||||||
}
|
}
|
||||||
|
|
||||||
// try registered resource
|
// try registered resource
|
||||||
if (isset($smarty->registered_cache_resources[ $type ])) {
|
if (isset($smarty->registered_cache_resources[ $type ])) {
|
||||||
// do not cache these instances as they may vary from instance to instance
|
// do not cache these instances as they may vary from instance to instance
|
||||||
|
@@ -106,12 +106,15 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource
|
|||||||
if ($mtime !== null) {
|
if ($mtime !== null) {
|
||||||
$cached->timestamp = $mtime;
|
$cached->timestamp = $mtime;
|
||||||
$cached->exists = !!$cached->timestamp;
|
$cached->exists = !!$cached->timestamp;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$timestamp = null;
|
$timestamp = null;
|
||||||
$this->fetch(
|
$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
|
$timestamp
|
||||||
);
|
);
|
||||||
$cached->timestamp = isset($timestamp) ? $timestamp : false;
|
$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
|
* @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
|
$update = false
|
||||||
) {
|
) {
|
||||||
if (!$cached) {
|
if (!$cached) {
|
||||||
@@ -137,8 +142,12 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource
|
|||||||
$timestamp = $cached->timestamp ? $cached->timestamp : null;
|
$timestamp = $cached->timestamp ? $cached->timestamp : null;
|
||||||
if ($content === null || !$timestamp) {
|
if ($content === null || !$timestamp) {
|
||||||
$this->fetch(
|
$this->fetch(
|
||||||
$_smarty_tpl->cached->filepath, $_smarty_tpl->source->name, $_smarty_tpl->cache_id,
|
$_smarty_tpl->cached->filepath,
|
||||||
$_smarty_tpl->compile_id, $content, $timestamp
|
$_smarty_tpl->source->name,
|
||||||
|
$_smarty_tpl->cache_id,
|
||||||
|
$_smarty_tpl->compile_id,
|
||||||
|
$content,
|
||||||
|
$timestamp
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (isset($content)) {
|
if (isset($content)) {
|
||||||
@@ -146,7 +155,6 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource
|
|||||||
$cached->content = null;
|
$cached->content = null;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,8 +169,12 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource
|
|||||||
public function writeCachedContent(Smarty_Internal_Template $_template, $content)
|
public function writeCachedContent(Smarty_Internal_Template $_template, $content)
|
||||||
{
|
{
|
||||||
return $this->save(
|
return $this->save(
|
||||||
$_template->cached->filepath, $_template->source->name, $_template->cache_id,
|
$_template->cached->filepath,
|
||||||
$_template->compile_id, $_template->cache_lifetime, $content
|
$_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) {
|
if ($content === null) {
|
||||||
$timestamp = null;
|
$timestamp = null;
|
||||||
$this->fetch(
|
$this->fetch(
|
||||||
$_template->cached->filepath, $_template->source->name, $_template->cache_id,
|
$_template->cached->filepath,
|
||||||
$_template->compile_id, $content, $timestamp
|
$_template->source->name,
|
||||||
|
$_template->cache_id,
|
||||||
|
$_template->compile_id,
|
||||||
|
$content,
|
||||||
|
$timestamp
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (isset($content)) {
|
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)
|
public function clear(Smarty $smarty, $resource_name, $cache_id, $compile_id, $exp_time)
|
||||||
{
|
{
|
||||||
$cache_name = null;
|
$cache_name = null;
|
||||||
|
|
||||||
if (isset($resource_name)) {
|
if (isset($resource_name)) {
|
||||||
$source = Smarty_Template_Source::load(null, $smarty, $resource_name);
|
$source = Smarty_Template_Source::load(null, $smarty, $resource_name);
|
||||||
if ($source->exists) {
|
if ($source->exists) {
|
||||||
@@ -227,7 +242,6 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->delete($cache_name, $cache_id, $compile_id, $exp_time);
|
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;
|
$id = $cached->lock_id;
|
||||||
$name = $cached->source->name . '.lock';
|
$name = $cached->source->name . '.lock';
|
||||||
|
|
||||||
$mtime = $this->fetchTimestamp($id, $name, $cached->cache_id, $cached->compile_id);
|
$mtime = $this->fetchTimestamp($id, $name, $cached->cache_id, $cached->compile_id);
|
||||||
if ($mtime === null) {
|
if ($mtime === null) {
|
||||||
$this->fetch($id, $name, $cached->cache_id, $cached->compile_id, $content, $mtime);
|
$this->fetch($id, $name, $cached->cache_id, $cached->compile_id, $content, $mtime);
|
||||||
|
@@ -56,7 +56,6 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
|
|||||||
{
|
{
|
||||||
$cached->filepath = $_template->source->uid . '#' . $this->sanitize($cached->source->resource) . '#' .
|
$cached->filepath = $_template->source->uid . '#' . $this->sanitize($cached->source->resource) . '#' .
|
||||||
$this->sanitize($cached->cache_id) . '#' . $this->sanitize($cached->compile_id);
|
$this->sanitize($cached->cache_id) . '#' . $this->sanitize($cached->compile_id);
|
||||||
|
|
||||||
$this->populateTimestamp($cached);
|
$this->populateTimestamp($cached);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,14 +69,19 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
|
|||||||
public function populateTimestamp(Smarty_Template_Cached $cached)
|
public function populateTimestamp(Smarty_Template_Cached $cached)
|
||||||
{
|
{
|
||||||
if (!$this->fetch(
|
if (!$this->fetch(
|
||||||
$cached->filepath, $cached->source->name, $cached->cache_id, $cached->compile_id, $content,
|
$cached->filepath,
|
||||||
$timestamp, $cached->source->uid
|
$cached->source->name,
|
||||||
|
$cached->cache_id,
|
||||||
|
$cached->compile_id,
|
||||||
|
$content,
|
||||||
|
$timestamp,
|
||||||
|
$cached->source->uid
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$cached->content = $content;
|
$cached->content = $content;
|
||||||
$cached->timestamp = (int) $timestamp;
|
$cached->timestamp = (int)$timestamp;
|
||||||
$cached->exists = !!$cached->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
|
* @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
|
$update = false
|
||||||
) {
|
) {
|
||||||
if (!$cached) {
|
if (!$cached) {
|
||||||
@@ -100,8 +106,13 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
|
|||||||
$timestamp = $cached->timestamp ? $cached->timestamp : null;
|
$timestamp = $cached->timestamp ? $cached->timestamp : null;
|
||||||
if ($content === null || !$timestamp) {
|
if ($content === null || !$timestamp) {
|
||||||
if (!$this->fetch(
|
if (!$this->fetch(
|
||||||
$_smarty_tpl->cached->filepath, $_smarty_tpl->source->name, $_smarty_tpl->cache_id,
|
$_smarty_tpl->cached->filepath,
|
||||||
$_smarty_tpl->compile_id, $content, $timestamp, $_smarty_tpl->source->uid
|
$_smarty_tpl->source->name,
|
||||||
|
$_smarty_tpl->cache_id,
|
||||||
|
$_smarty_tpl->compile_id,
|
||||||
|
$content,
|
||||||
|
$timestamp,
|
||||||
|
$_smarty_tpl->source->uid
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
return false;
|
return false;
|
||||||
@@ -109,10 +120,8 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
|
|||||||
}
|
}
|
||||||
if (isset($content)) {
|
if (isset($content)) {
|
||||||
eval('?>' . $content);
|
eval('?>' . $content);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,7 +136,6 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
|
|||||||
public function writeCachedContent(Smarty_Internal_Template $_template, $content)
|
public function writeCachedContent(Smarty_Internal_Template $_template, $content)
|
||||||
{
|
{
|
||||||
$this->addMetaTimestamp($content);
|
$this->addMetaTimestamp($content);
|
||||||
|
|
||||||
return $this->write(array($_template->cached->filepath => $content), $_template->cache_lifetime);
|
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;
|
$timestamp = null;
|
||||||
if ($content === null) {
|
if ($content === null) {
|
||||||
if (!$this->fetch(
|
if (!$this->fetch(
|
||||||
$_template->cached->filepath, $_template->source->name, $_template->cache_id,
|
$_template->cached->filepath,
|
||||||
$_template->compile_id, $content, $timestamp, $_template->source->uid
|
$_template->source->name,
|
||||||
|
$_template->cache_id,
|
||||||
|
$_template->compile_id,
|
||||||
|
$content,
|
||||||
|
$timestamp,
|
||||||
|
$_template->source->uid
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
return false;
|
return false;
|
||||||
@@ -173,7 +186,7 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
|
|||||||
if (!$this->purge()) {
|
if (!$this->purge()) {
|
||||||
$this->invalidate(null);
|
$this->invalidate(null);
|
||||||
}
|
}
|
||||||
return - 1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -199,7 +212,7 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
|
|||||||
$this->sanitize($compile_id);
|
$this->sanitize($compile_id);
|
||||||
$this->delete(array($cid));
|
$this->delete(array($cid));
|
||||||
$this->invalidate($cid, $resource_name, $cache_id, $compile_id, $uid);
|
$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
|
* @return boolean success
|
||||||
*/
|
*/
|
||||||
protected function fetch($cid, $resource_name = null, $cache_id = null, $compile_id = null, &$content = null,
|
protected function fetch(
|
||||||
&$timestamp = null, $resource_uid = null
|
$cid,
|
||||||
|
$resource_name = null,
|
||||||
|
$cache_id = null,
|
||||||
|
$compile_id = null,
|
||||||
|
&$content = null,
|
||||||
|
&$timestamp = null,
|
||||||
|
$resource_uid = null
|
||||||
) {
|
) {
|
||||||
$t = $this->read(array($cid));
|
$t = $this->read(array($cid));
|
||||||
$content = !empty($t[ $cid ]) ? $t[ $cid ] : null;
|
$content = !empty($t[ $cid ]) ? $t[ $cid ] : null;
|
||||||
$timestamp = null;
|
$timestamp = null;
|
||||||
|
|
||||||
if ($content && ($timestamp = $this->getMetaTimestamp($content))) {
|
if ($content && ($timestamp = $this->getMetaTimestamp($content))) {
|
||||||
$invalidated =
|
$invalidated =
|
||||||
$this->getLatestInvalidationTimestamp($cid, $resource_name, $cache_id, $compile_id, $resource_uid);
|
$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;
|
$content = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return !!$content;
|
return !!$content;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -279,7 +296,7 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
|
|||||||
protected function addMetaTimestamp(&$content)
|
protected function addMetaTimestamp(&$content)
|
||||||
{
|
{
|
||||||
$mt = explode(' ', microtime());
|
$mt = explode(' ', microtime());
|
||||||
$ts = pack('NN', $mt[ 1 ], (int) ($mt[ 0 ] * 100000000));
|
$ts = pack('NN', $mt[ 1 ], (int)($mt[ 0 ] * 100000000));
|
||||||
$content = $ts . $content;
|
$content = $ts . $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -311,7 +328,11 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
|
|||||||
*
|
*
|
||||||
* @return void
|
* @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
|
$resource_uid = null
|
||||||
) {
|
) {
|
||||||
$now = microtime(true);
|
$now = microtime(true);
|
||||||
@@ -352,7 +373,11 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
|
|||||||
*
|
*
|
||||||
* @return float the microtime the CacheID was invalidated
|
* @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
|
$resource_uid = null
|
||||||
) {
|
) {
|
||||||
// abort if there is no CacheID
|
// 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))) {
|
if (!($_cid = $this->listInvalidationKeys($cid, $resource_name, $cache_id, $compile_id, $resource_uid))) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// there are no InValidationKeys
|
// there are no InValidationKeys
|
||||||
if (!($values = $this->read($_cid))) {
|
if (!($values = $this->read($_cid))) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
// make sure we're dealing with floats
|
// make sure we're dealing with floats
|
||||||
$values = array_map('floatval', $values);
|
$values = array_map('floatval', $values);
|
||||||
|
|
||||||
return max($values);
|
return max($values);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -387,7 +410,11 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
|
|||||||
* @return array list of InvalidationKeys
|
* @return array list of InvalidationKeys
|
||||||
* @uses $invalidationKeyPrefix to prepend to each InvalidationKey
|
* @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
|
$resource_uid = null
|
||||||
) {
|
) {
|
||||||
$t = array('IVK#ALL');
|
$t = array('IVK#ALL');
|
||||||
@@ -421,9 +448,8 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
|
|||||||
$t[] = 'IVK#CACHE#' . $part;
|
$t[] = 'IVK#CACHE#' . $part;
|
||||||
$t[] = 'IVK#CID' . $_name . $part . $_compile;
|
$t[] = 'IVK#CID' . $_name . $part . $_compile;
|
||||||
// skip past delimiter position
|
// skip past delimiter position
|
||||||
$i ++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $t;
|
return $t;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -439,7 +465,6 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
|
|||||||
{
|
{
|
||||||
$key = 'LOCK#' . $cached->filepath;
|
$key = 'LOCK#' . $cached->filepath;
|
||||||
$data = $this->read(array($key));
|
$data = $this->read(array($key));
|
||||||
|
|
||||||
return $data && time() - $data[ $key ] < $smarty->locking_timeout;
|
return $data && time() - $data[ $key ] < $smarty->locking_timeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -22,7 +22,7 @@ class Smarty_Data extends Smarty_Internal_Data
|
|||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
static $count = 0;
|
public static $count = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Data block name
|
* Data block name
|
||||||
@@ -50,7 +50,7 @@ class Smarty_Data extends Smarty_Internal_Data
|
|||||||
public function __construct($_parent = null, $smarty = null, $name = null)
|
public function __construct($_parent = null, $smarty = null, $name = null)
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
self::$count ++;
|
self::$count++;
|
||||||
$this->dataObjectName = 'Data_object ' . (isset($name) ? "'{$name}'" : self::$count);
|
$this->dataObjectName = 'Data_object ' . (isset($name) ? "'{$name}'" : self::$count);
|
||||||
$this->smarty = $smarty;
|
$this->smarty = $smarty;
|
||||||
if (is_object($_parent)) {
|
if (is_object($_parent)) {
|
||||||
|
@@ -7,6 +7,7 @@
|
|||||||
* @author Uwe Tews
|
* @author Uwe Tews
|
||||||
* @author Rodney Rehm
|
* @author Rodney Rehm
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class does contain all necessary methods for the HTML cache on file system
|
* 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.
|
* 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();
|
$cached->filepath = $smarty->getCacheDir();
|
||||||
if (isset($_template->cache_id)) {
|
if (isset($_template->cache_id)) {
|
||||||
$cached->filepath .= preg_replace(
|
$cached->filepath .= preg_replace(
|
||||||
array('![^\w|]+!',
|
array(
|
||||||
'![|]+!'),
|
'![^\w|]+!',
|
||||||
array('_',
|
'![|]+!'
|
||||||
$_compile_dir_sep),
|
),
|
||||||
$_template->cache_id
|
array(
|
||||||
) . $_compile_dir_sep;
|
'_',
|
||||||
|
$_compile_dir_sep
|
||||||
|
),
|
||||||
|
$_template->cache_id
|
||||||
|
) . $_compile_dir_sep;
|
||||||
}
|
}
|
||||||
if (isset($_template->compile_id)) {
|
if (isset($_template->compile_id)) {
|
||||||
$cached->filepath .= preg_replace('![^\w]+!', '_', $_template->compile_id) . $_compile_dir_sep;
|
$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
|
* @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,
|
Smarty_Template_Cached $cached = null,
|
||||||
$update = false
|
$update = false
|
||||||
) {
|
) {
|
||||||
@@ -114,10 +120,10 @@ class Smarty_Internal_CacheResource_File extends Smarty_CacheResource
|
|||||||
public function writeCachedContent(Smarty_Internal_Template $_template, $content)
|
public function writeCachedContent(Smarty_Internal_Template $_template, $content)
|
||||||
{
|
{
|
||||||
if ($_template->smarty->ext->_writeFile->writeFile(
|
if ($_template->smarty->ext->_writeFile->writeFile(
|
||||||
$_template->cached->filepath,
|
$_template->cached->filepath,
|
||||||
$content,
|
$content,
|
||||||
$_template->smarty
|
$_template->smarty
|
||||||
) === true
|
) === true
|
||||||
) {
|
) {
|
||||||
if (function_exists('opcache_invalidate')
|
if (function_exists('opcache_invalidate')
|
||||||
&& (!function_exists('ini_get') || strlen(ini_get('opcache.restrict_api'))) < 1
|
&& (!function_exists('ini_get') || strlen(ini_get('opcache.restrict_api'))) < 1
|
||||||
|
@@ -29,9 +29,11 @@ class Smarty_Internal_Compile_Assign extends Smarty_Internal_CompileBase
|
|||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public $valid_scopes = array('local' => Smarty::SCOPE_LOCAL, 'parent' => Smarty::SCOPE_PARENT,
|
public $valid_scopes = array(
|
||||||
'root' => Smarty::SCOPE_ROOT, 'global' => Smarty::SCOPE_GLOBAL,
|
'local' => Smarty::SCOPE_LOCAL, 'parent' => Smarty::SCOPE_PARENT,
|
||||||
'tpl_root' => Smarty::SCOPE_TPL_ROOT, 'smarty' => Smarty::SCOPE_SMARTY);
|
'root' => Smarty::SCOPE_ROOT, 'global' => Smarty::SCOPE_GLOBAL,
|
||||||
|
'tpl_root' => Smarty::SCOPE_TPL_ROOT, 'smarty' => Smarty::SCOPE_SMARTY
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compiles code for the {assign} tag
|
* Compiles code for the {assign} tag
|
||||||
@@ -66,7 +68,7 @@ class Smarty_Internal_Compile_Assign extends Smarty_Internal_CompileBase
|
|||||||
}
|
}
|
||||||
// scope setup
|
// scope setup
|
||||||
if ($_attr[ 'noscope' ]) {
|
if ($_attr[ 'noscope' ]) {
|
||||||
$_scope = - 1;
|
$_scope = -1;
|
||||||
} else {
|
} else {
|
||||||
$_scope = $compiler->convertScope($_attr, $this->valid_scopes);
|
$_scope = $compiler->convertScope($_attr, $this->valid_scopes);
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/**
|
||||||
* This file is part of Smarty.
|
* This file is part of Smarty.
|
||||||
*
|
*
|
||||||
* (c) 2015 Uwe Tews
|
* (c) 2015 Uwe Tews
|
||||||
@@ -22,6 +22,7 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_Compile_Shared_Inher
|
|||||||
* @see Smarty_Internal_CompileBase
|
* @see Smarty_Internal_CompileBase
|
||||||
*/
|
*/
|
||||||
public $required_attributes = array('name');
|
public $required_attributes = array('name');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attribute definition: Overwrites base class.
|
* Attribute definition: Overwrites base class.
|
||||||
*
|
*
|
||||||
@@ -29,6 +30,7 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_Compile_Shared_Inher
|
|||||||
* @see Smarty_Internal_CompileBase
|
* @see Smarty_Internal_CompileBase
|
||||||
*/
|
*/
|
||||||
public $shorttag_order = array('name');
|
public $shorttag_order = array('name');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attribute definition: Overwrites base class.
|
* Attribute definition: Overwrites base class.
|
||||||
*
|
*
|
||||||
@@ -36,6 +38,7 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_Compile_Shared_Inher
|
|||||||
* @see Smarty_Internal_CompileBase
|
* @see Smarty_Internal_CompileBase
|
||||||
*/
|
*/
|
||||||
public $option_flags = array('hide', 'nocache');
|
public $option_flags = array('hide', 'nocache');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attribute definition: Overwrites base class.
|
* Attribute definition: Overwrites base class.
|
||||||
*
|
*
|
||||||
@@ -74,9 +77,11 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_Compile_Shared_Inher
|
|||||||
$this->openTag(
|
$this->openTag(
|
||||||
$compiler,
|
$compiler,
|
||||||
'block',
|
'block',
|
||||||
array($_attr, $compiler->nocache, $compiler->parser->current_buffer,
|
array(
|
||||||
$compiler->template->compiled->has_nocache_code,
|
$_attr, $compiler->nocache, $compiler->parser->current_buffer,
|
||||||
$compiler->template->caching)
|
$compiler->template->compiled->has_nocache_code,
|
||||||
|
$compiler->template->caching
|
||||||
|
)
|
||||||
);
|
);
|
||||||
$compiler->saveRequiredPlugins(true);
|
$compiler->saveRequiredPlugins(true);
|
||||||
$compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
|
$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;
|
$compiler->suppressNocacheProcessing = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty Internal Plugin Compile BlockClose Class
|
* 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;
|
$_functionCode = $compiler->parser->current_buffer;
|
||||||
// setup buffer for template function code
|
// setup buffer for template function code
|
||||||
$compiler->parser->current_buffer = new Smarty_Internal_ParseTree_Template();
|
$compiler->parser->current_buffer = new Smarty_Internal_ParseTree_Template();
|
||||||
|
|
||||||
$output = "<?php\n";
|
$output = "<?php\n";
|
||||||
$output .= "/* {block {$_name}} */\n";
|
$output .= "/* {block {$_name}} */\n";
|
||||||
$output .= "class {$_className} extends Smarty_Internal_Block\n";
|
$output .= "class {$_className} extends Smarty_Internal_Block\n";
|
||||||
$output .= "{\n";
|
$output .= "{\n";
|
||||||
foreach ($_block as $property => $value) {
|
foreach ($_block as $property => $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 .= "public function callBlock(Smarty_Internal_Template \$_smarty_tpl) {\n";
|
||||||
$output .= $compiler->compileRequiredPlugins();
|
$output .= $compiler->compileRequiredPlugins();
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/**
|
||||||
* This file is part of Smarty.
|
* This file is part of Smarty.
|
||||||
*
|
*
|
||||||
* (c) 2015 Uwe Tews
|
* (c) 2015 Uwe Tews
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/**
|
||||||
* This file is part of Smarty.
|
* This file is part of Smarty.
|
||||||
*
|
*
|
||||||
* (c) 2015 Uwe Tews
|
* (c) 2015 Uwe Tews
|
||||||
|
@@ -78,11 +78,9 @@ class Smarty_Internal_Compile_Break extends Smarty_Internal_CompileBase
|
|||||||
static $_is_loopy = array('for' => true, 'foreach' => true, 'while' => true, 'section' => true);
|
static $_is_loopy = array('for' => true, 'foreach' => true, 'while' => true, 'section' => true);
|
||||||
// check and get attributes
|
// check and get attributes
|
||||||
$_attr = $this->getAttributes($compiler, $args);
|
$_attr = $this->getAttributes($compiler, $args);
|
||||||
|
|
||||||
if ($_attr[ 'nocache' ] === true) {
|
if ($_attr[ 'nocache' ] === true) {
|
||||||
$compiler->trigger_template_error('nocache option not allowed', null, true);
|
$compiler->trigger_template_error('nocache option not allowed', null, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_attr[ 'levels' ])) {
|
if (isset($_attr[ 'levels' ])) {
|
||||||
if (!is_numeric($_attr[ 'levels' ])) {
|
if (!is_numeric($_attr[ 'levels' ])) {
|
||||||
$compiler->trigger_template_error('level attribute must be a numeric constant', null, true);
|
$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) {
|
if ($level_count === 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$level_count --;
|
$level_count--;
|
||||||
if ($compiler->_tag_stack[ $stack_count ][ 0 ] === 'foreach') {
|
if ($compiler->_tag_stack[ $stack_count ][ 0 ] === 'foreach') {
|
||||||
$foreachLevels ++;
|
$foreachLevels++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$stack_count --;
|
$stack_count--;
|
||||||
}
|
}
|
||||||
if ($level_count !== 0) {
|
if ($level_count !== 0) {
|
||||||
$compiler->trigger_template_error("cannot {$this->tag} {$levels} level(s)", null, true);
|
$compiler->trigger_template_error("cannot {$this->tag} {$levels} level(s)", null, true);
|
||||||
}
|
}
|
||||||
if ($lastTag === 'foreach' && $this->tag === 'break' && $foreachLevels > 0) {
|
if ($lastTag === 'foreach' && $this->tag === 'break' && $foreachLevels > 0) {
|
||||||
$foreachLevels --;
|
$foreachLevels--;
|
||||||
}
|
}
|
||||||
return array($levels, $foreachLevels);
|
return array($levels, $foreachLevels);
|
||||||
}
|
}
|
||||||
|
@@ -41,16 +41,20 @@ class Smarty_Internal_Compile_Capture extends Smarty_Internal_CompileBase
|
|||||||
*
|
*
|
||||||
* @return string compiled code
|
* @return string compiled code
|
||||||
*/
|
*/
|
||||||
public static function compileSpecialVariable($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = null)
|
public static function compileSpecialVariable(
|
||||||
{
|
$args,
|
||||||
return '$_smarty_tpl->smarty->ext->_capture->getBuffer($_smarty_tpl'.(isset($parameter[ 1 ])?", {$parameter[ 1 ]})":')');
|
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
|
* Compiles code for the {capture} tag
|
||||||
*
|
*
|
||||||
* @param array $args array with attributes from parser
|
* @param array $args array with attributes from parser
|
||||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||||
* @param null $parameter
|
* @param null $parameter
|
||||||
*
|
*
|
||||||
* @return string compiled code
|
* @return string compiled code
|
||||||
@@ -59,16 +63,13 @@ class Smarty_Internal_Compile_Capture extends Smarty_Internal_CompileBase
|
|||||||
{
|
{
|
||||||
// check and get attributes
|
// check and get attributes
|
||||||
$_attr = $this->getAttributes($compiler, $args, $parameter, 'capture');
|
$_attr = $this->getAttributes($compiler, $args, $parameter, 'capture');
|
||||||
|
|
||||||
$buffer = isset($_attr[ 'name' ]) ? $_attr[ 'name' ] : "'default'";
|
$buffer = isset($_attr[ 'name' ]) ? $_attr[ 'name' ] : "'default'";
|
||||||
$assign = isset($_attr[ 'assign' ]) ? $_attr[ 'assign' ] : 'null';
|
$assign = isset($_attr[ 'assign' ]) ? $_attr[ 'assign' ] : 'null';
|
||||||
$append = isset($_attr[ 'append' ]) ? $_attr[ 'append' ] : 'null';
|
$append = isset($_attr[ 'append' ]) ? $_attr[ 'append' ] : 'null';
|
||||||
|
|
||||||
$compiler->_cache[ 'capture_stack' ][] = array($compiler->nocache);
|
$compiler->_cache[ 'capture_stack' ][] = array($compiler->nocache);
|
||||||
// maybe nocache because of nocache variables
|
// maybe nocache because of nocache variables
|
||||||
$compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
|
$compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
|
||||||
$_output = "<?php \$_smarty_tpl->smarty->ext->_capture->open(\$_smarty_tpl, $buffer, $assign, $append);?>";
|
$_output = "<?php \$_smarty_tpl->smarty->ext->_capture->open(\$_smarty_tpl, $buffer, $assign, $append);?>";
|
||||||
|
|
||||||
return $_output;
|
return $_output;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -84,8 +85,8 @@ class Smarty_Internal_Compile_CaptureClose extends Smarty_Internal_CompileBase
|
|||||||
/**
|
/**
|
||||||
* Compiles code for the {/capture} tag
|
* Compiles code for the {/capture} tag
|
||||||
*
|
*
|
||||||
* @param array $args array with attributes from parser
|
* @param array $args array with attributes from parser
|
||||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||||
* @param null $parameter
|
* @param null $parameter
|
||||||
*
|
*
|
||||||
* @return string compiled code
|
* @return string compiled code
|
||||||
@@ -98,9 +99,7 @@ class Smarty_Internal_Compile_CaptureClose extends Smarty_Internal_CompileBase
|
|||||||
if ($compiler->nocache) {
|
if ($compiler->nocache) {
|
||||||
$compiler->tag_nocache = true;
|
$compiler->tag_nocache = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
list($compiler->nocache) = array_pop($compiler->_cache[ 'capture_stack' ]);
|
list($compiler->nocache) = array_pop($compiler->_cache[ 'capture_stack' ]);
|
||||||
|
|
||||||
return "<?php \$_smarty_tpl->smarty->ext->_capture->close(\$_smarty_tpl);?>";
|
return "<?php \$_smarty_tpl->smarty->ext->_capture->close(\$_smarty_tpl);?>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/**
|
||||||
* This file is part of Smarty.
|
* This file is part of Smarty.
|
||||||
*
|
*
|
||||||
* (c) 2015 Uwe Tews
|
* (c) 2015 Uwe Tews
|
||||||
@@ -51,7 +51,7 @@ class Smarty_Internal_Compile_Child extends Smarty_Internal_CompileBase
|
|||||||
{
|
{
|
||||||
// check and get attributes
|
// check and get attributes
|
||||||
$_attr = $this->getAttributes($compiler, $args);
|
$_attr = $this->getAttributes($compiler, $args);
|
||||||
$tag = isset($parameter[0]) ? "'{$parameter[0]}'" : "'{{$this->tag}}'";
|
$tag = isset($parameter[ 0 ]) ? "'{$parameter[0]}'" : "'{{$this->tag}}'";
|
||||||
if (!isset($compiler->_cache[ 'blockNesting' ])) {
|
if (!isset($compiler->_cache[ 'blockNesting' ])) {
|
||||||
$compiler->trigger_template_error(
|
$compiler->trigger_template_error(
|
||||||
"{$tag} used outside {block} tags ",
|
"{$tag} used outside {block} tags ",
|
||||||
@@ -69,11 +69,11 @@ class Smarty_Internal_Compile_Child extends Smarty_Internal_CompileBase
|
|||||||
$output .= "ob_start();\n";
|
$output .= "ob_start();\n";
|
||||||
}
|
}
|
||||||
$output .= '$_smarty_tpl->inheritance->call' . $this->blockType . '($_smarty_tpl, $this' .
|
$output .= '$_smarty_tpl->inheritance->call' . $this->blockType . '($_smarty_tpl, $this' .
|
||||||
($this->blockType === 'Child' ? '' : ", {$tag}"). ");\n";
|
($this->blockType === 'Child' ? '' : ", {$tag}") . ");\n";
|
||||||
if (isset($_assign)) {
|
if (isset($_assign)) {
|
||||||
$output .= "\$_smarty_tpl->assign({$_assign}, ob_get_clean());\n";
|
$output .= "\$_smarty_tpl->assign({$_assign}, ob_get_clean());\n";
|
||||||
}
|
}
|
||||||
$output .="?>\n";
|
$output .= "?>\n";
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -53,9 +53,11 @@ class Smarty_Internal_Compile_Config_Load extends Smarty_Internal_CompileBase
|
|||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public $valid_scopes = array('local' => Smarty::SCOPE_LOCAL, 'parent' => Smarty::SCOPE_PARENT,
|
public $valid_scopes = array(
|
||||||
'root' => Smarty::SCOPE_ROOT, 'tpl_root' => Smarty::SCOPE_TPL_ROOT,
|
'local' => Smarty::SCOPE_LOCAL, 'parent' => Smarty::SCOPE_PARENT,
|
||||||
'smarty' => Smarty::SCOPE_SMARTY, 'global' => Smarty::SCOPE_SMARTY);
|
'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
|
* 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
|
// check and get attributes
|
||||||
$_attr = $this->getAttributes($compiler, $args);
|
$_attr = $this->getAttributes($compiler, $args);
|
||||||
|
|
||||||
if ($_attr[ 'nocache' ] === true) {
|
if ($_attr[ 'nocache' ] === true) {
|
||||||
$compiler->trigger_template_error('nocache option not allowed', null, true);
|
$compiler->trigger_template_error('nocache option not allowed', null, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// save possible attributes
|
// save possible attributes
|
||||||
$conf_file = $_attr[ 'file' ];
|
$conf_file = $_attr[ 'file' ];
|
||||||
if (isset($_attr[ 'section' ])) {
|
if (isset($_attr[ 'section' ])) {
|
||||||
@@ -84,15 +84,13 @@ class Smarty_Internal_Compile_Config_Load extends Smarty_Internal_CompileBase
|
|||||||
}
|
}
|
||||||
// scope setup
|
// scope setup
|
||||||
if ($_attr[ 'noscope' ]) {
|
if ($_attr[ 'noscope' ]) {
|
||||||
$_scope = - 1;
|
$_scope = -1;
|
||||||
} else {
|
} else {
|
||||||
$_scope = $compiler->convertScope($_attr, $this->valid_scopes);
|
$_scope = $compiler->convertScope($_attr, $this->valid_scopes);
|
||||||
}
|
}
|
||||||
|
|
||||||
// create config object
|
// create config object
|
||||||
$_output =
|
$_output =
|
||||||
"<?php\n\$_smarty_tpl->smarty->ext->configLoad->_loadConfigFile(\$_smarty_tpl, {$conf_file}, {$section}, {$_scope});\n?>\n";
|
"<?php\n\$_smarty_tpl->smarty->ext->configLoad->_loadConfigFile(\$_smarty_tpl, {$conf_file}, {$section}, {$_scope});\n?>\n";
|
||||||
|
|
||||||
return $_output;
|
return $_output;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -29,10 +29,8 @@ class Smarty_Internal_Compile_Debug extends Smarty_Internal_CompileBase
|
|||||||
{
|
{
|
||||||
// check and get attributes
|
// check and get attributes
|
||||||
$_attr = $this->getAttributes($compiler, $args);
|
$_attr = $this->getAttributes($compiler, $args);
|
||||||
|
|
||||||
// compile always as nocache
|
// compile always as nocache
|
||||||
$compiler->tag_nocache = true;
|
$compiler->tag_nocache = true;
|
||||||
|
|
||||||
// display debug template
|
// display debug template
|
||||||
$_output =
|
$_output =
|
||||||
"<?php \$_smarty_debug = new Smarty_Internal_Debug;\n \$_smarty_debug->display_debug(\$_smarty_tpl);\n";
|
"<?php \$_smarty_debug = new Smarty_Internal_Debug;\n \$_smarty_debug->display_debug(\$_smarty_tpl);\n";
|
||||||
|
@@ -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
|
// output will be stored in a smarty variable instead of being displayed
|
||||||
$_assign = $_attr[ 'assign' ];
|
$_assign = $_attr[ 'assign' ];
|
||||||
}
|
}
|
||||||
|
|
||||||
// create template object
|
// 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?
|
//was there an assign attribute?
|
||||||
if (isset($_assign)) {
|
if (isset($_assign)) {
|
||||||
$_output .= "\$_smarty_tpl->assign($_assign,\$_template->fetch());";
|
$_output .= "\$_smarty_tpl->assign($_assign,\$_template->fetch());";
|
||||||
} else {
|
} else {
|
||||||
$_output .= 'echo $_template->fetch();';
|
$_output .= 'echo $_template->fetch();';
|
||||||
}
|
}
|
||||||
|
|
||||||
return "<?php $_output ?>";
|
return "<?php $_output ?>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty Internal Plugin Compile extend
|
* Smarty Internal Plugin Compile extend
|
||||||
* Compiles the {extends} tag
|
* Compiles the {extends} tag
|
||||||
@@ -74,7 +73,7 @@ class Smarty_Internal_Compile_Extends extends Smarty_Internal_Compile_Shared_Inh
|
|||||||
} else {
|
} else {
|
||||||
$file = "'{$file}'";
|
$file = "'{$file}'";
|
||||||
}
|
}
|
||||||
$i ++;
|
$i++;
|
||||||
if ($i === count($files) && isset($_attr[ 'extends_resource' ])) {
|
if ($i === count($files) && isset($_attr[ 'extends_resource' ])) {
|
||||||
$this->compileEndChild($compiler);
|
$this->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->template_postfix[] = new Smarty_Internal_ParseTree_Tag(
|
||||||
$compiler->parser,
|
$compiler->parser,
|
||||||
'<?php $_smarty_tpl->inheritance->endChild($_smarty_tpl' .
|
'<?php $_smarty_tpl->inheritance->endChild($_smarty_tpl' .
|
||||||
(isset($template) ?
|
(isset($template) ?
|
||||||
", {$template}{$inlineUids}" :
|
", {$template}{$inlineUids}" :
|
||||||
'') . ");\n?>"
|
'') . ");\n?>"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,8 +131,10 @@ class Smarty_Internal_Compile_Extends extends Smarty_Internal_Compile_Shared_Inh
|
|||||||
$compiler->parser,
|
$compiler->parser,
|
||||||
$compiler->compileTag(
|
$compiler->compileTag(
|
||||||
'include',
|
'include',
|
||||||
array($template,
|
array(
|
||||||
array('scope' => 'parent'))
|
$template,
|
||||||
|
array('scope' => 'parent')
|
||||||
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@@ -34,7 +34,7 @@ class Smarty_Internal_Compile_For extends Smarty_Internal_CompileBase
|
|||||||
*/
|
*/
|
||||||
public function compile($args, $compiler, $parameter)
|
public function compile($args, $compiler, $parameter)
|
||||||
{
|
{
|
||||||
$compiler->loopNesting ++;
|
$compiler->loopNesting++;
|
||||||
if ($parameter === 0) {
|
if ($parameter === 0) {
|
||||||
$this->required_attributes = array('start', 'to');
|
$this->required_attributes = array('start', 'to');
|
||||||
$this->optional_attributes = array('max', 'step');
|
$this->optional_attributes = array('max', 'step');
|
||||||
@@ -45,7 +45,6 @@ class Smarty_Internal_Compile_For extends Smarty_Internal_CompileBase
|
|||||||
$this->mapCache = array();
|
$this->mapCache = array();
|
||||||
// check and get attributes
|
// check and get attributes
|
||||||
$_attr = $this->getAttributes($compiler, $args);
|
$_attr = $this->getAttributes($compiler, $args);
|
||||||
|
|
||||||
$output = "<?php\n";
|
$output = "<?php\n";
|
||||||
if ($parameter === 1) {
|
if ($parameter === 1) {
|
||||||
foreach ($_attr[ 'start' ] as $_statement) {
|
foreach ($_attr[ 'start' ] as $_statement) {
|
||||||
@@ -93,7 +92,6 @@ class Smarty_Internal_Compile_For extends Smarty_Internal_CompileBase
|
|||||||
$output .= "\$_smarty_tpl->tpl_vars[$var]->last = \$_smarty_tpl->tpl_vars[$var]->iteration === \$_smarty_tpl->tpl_vars[$var]->total;";
|
$output .= "\$_smarty_tpl->tpl_vars[$var]->last = \$_smarty_tpl->tpl_vars[$var]->iteration === \$_smarty_tpl->tpl_vars[$var]->total;";
|
||||||
}
|
}
|
||||||
$output .= '?>';
|
$output .= '?>';
|
||||||
|
|
||||||
$this->openTag($compiler, 'for', array('for', $compiler->nocache));
|
$this->openTag($compiler, 'for', array('for', $compiler->nocache));
|
||||||
// maybe nocache because of nocache variables
|
// maybe nocache because of nocache variables
|
||||||
$compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
|
$compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
|
||||||
@@ -123,10 +121,8 @@ class Smarty_Internal_Compile_Forelse extends Smarty_Internal_CompileBase
|
|||||||
{
|
{
|
||||||
// check and get attributes
|
// check and get attributes
|
||||||
$_attr = $this->getAttributes($compiler, $args);
|
$_attr = $this->getAttributes($compiler, $args);
|
||||||
|
|
||||||
list($openTag, $nocache) = $this->closeTag($compiler, array('for'));
|
list($openTag, $nocache) = $this->closeTag($compiler, array('for'));
|
||||||
$this->openTag($compiler, 'forelse', array('forelse', $nocache));
|
$this->openTag($compiler, 'forelse', array('forelse', $nocache));
|
||||||
|
|
||||||
return "<?php }} else { ?>";
|
return "<?php }} else { ?>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -150,16 +146,14 @@ class Smarty_Internal_Compile_Forclose extends Smarty_Internal_CompileBase
|
|||||||
*/
|
*/
|
||||||
public function compile($args, $compiler, $parameter)
|
public function compile($args, $compiler, $parameter)
|
||||||
{
|
{
|
||||||
$compiler->loopNesting --;
|
$compiler->loopNesting--;
|
||||||
// check and get attributes
|
// check and get attributes
|
||||||
$_attr = $this->getAttributes($compiler, $args);
|
$_attr = $this->getAttributes($compiler, $args);
|
||||||
// must endblock be nocache?
|
// must endblock be nocache?
|
||||||
if ($compiler->nocache) {
|
if ($compiler->nocache) {
|
||||||
$compiler->tag_nocache = true;
|
$compiler->tag_nocache = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
list($openTag, $compiler->nocache) = $this->closeTag($compiler, array('for', 'forelse'));
|
list($openTag, $compiler->nocache) = $this->closeTag($compiler, array('for', 'forelse'));
|
||||||
|
|
||||||
$output = "<?php }\n";
|
$output = "<?php }\n";
|
||||||
if ($openTag !== 'forelse') {
|
if ($openTag !== 'forelse') {
|
||||||
$output .= "}\n";
|
$output .= "}\n";
|
||||||
|
@@ -87,7 +87,7 @@ class Smarty_Internal_Compile_Foreach extends Smarty_Internal_Compile_Private_Fo
|
|||||||
*/
|
*/
|
||||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
|
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
|
||||||
{
|
{
|
||||||
$compiler->loopNesting ++;
|
$compiler->loopNesting++;
|
||||||
// init
|
// init
|
||||||
$this->isNamed = false;
|
$this->isNamed = false;
|
||||||
// check and get attributes
|
// 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) {
|
if (isset($attributes[ $a ]) && $attributes[ $a ] === $fromName) {
|
||||||
$compiler->trigger_template_error(
|
$compiler->trigger_template_error(
|
||||||
"'{$a}' and 'from' may not have same variable name '{$fromName}'",
|
"'{$a}' and 'from' may not have same variable name '{$fromName}'",
|
||||||
null, true
|
null,
|
||||||
|
true
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$itemVar = "\$_smarty_tpl->tpl_vars['{$item}']";
|
$itemVar = "\$_smarty_tpl->tpl_vars['{$item}']";
|
||||||
$local = '$__foreach_' . $attributes[ 'item' ] . '_' . $this->counter ++ . '_';
|
$local = '$__foreach_' . $attributes[ 'item' ] . '_' . $this->counter++ . '_';
|
||||||
// search for used tag attributes
|
// search for used tag attributes
|
||||||
$itemAttr = array();
|
$itemAttr = array();
|
||||||
$namedAttr = array();
|
$namedAttr = array();
|
||||||
@@ -190,7 +190,8 @@ class Smarty_Internal_Compile_Foreach extends Smarty_Internal_Compile_Private_Fo
|
|||||||
$needTotal = isset($itemAttr[ 'total' ]);
|
$needTotal = isset($itemAttr[ 'total' ]);
|
||||||
// Register tag
|
// Register tag
|
||||||
$this->openTag(
|
$this->openTag(
|
||||||
$compiler, 'foreach',
|
$compiler,
|
||||||
|
'foreach',
|
||||||
array('foreach', $compiler->nocache, $local, $itemVar, empty($itemAttr) ? 1 : 2)
|
array('foreach', $compiler->nocache, $local, $itemVar, empty($itemAttr) ? 1 : 2)
|
||||||
);
|
);
|
||||||
// maybe nocache because of nocache variables
|
// 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 .= "{$local}saved = {$itemVar};\n";
|
||||||
}
|
}
|
||||||
$output .= '?>';
|
$output .= '?>';
|
||||||
|
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -290,7 +290,6 @@ class Smarty_Internal_Compile_Foreachelse extends Smarty_Internal_CompileBase
|
|||||||
{
|
{
|
||||||
// check and get attributes
|
// check and get attributes
|
||||||
$_attr = $this->getAttributes($compiler, $args);
|
$_attr = $this->getAttributes($compiler, $args);
|
||||||
|
|
||||||
list($openTag, $nocache, $local, $itemVar, $restore) = $this->closeTag($compiler, array('foreach'));
|
list($openTag, $nocache, $local, $itemVar, $restore) = $this->closeTag($compiler, array('foreach'));
|
||||||
$this->openTag($compiler, 'foreachelse', array('foreachelse', $nocache, $local, $itemVar, 0));
|
$this->openTag($compiler, 'foreachelse', array('foreachelse', $nocache, $local, $itemVar, 0));
|
||||||
$output = "<?php\n";
|
$output = "<?php\n";
|
||||||
@@ -321,16 +320,14 @@ class Smarty_Internal_Compile_Foreachclose extends Smarty_Internal_CompileBase
|
|||||||
*/
|
*/
|
||||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
|
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
|
||||||
{
|
{
|
||||||
$compiler->loopNesting --;
|
$compiler->loopNesting--;
|
||||||
// must endblock be nocache?
|
// must endblock be nocache?
|
||||||
if ($compiler->nocache) {
|
if ($compiler->nocache) {
|
||||||
$compiler->tag_nocache = true;
|
$compiler->tag_nocache = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
list($openTag, $compiler->nocache, $local, $itemVar, $restore) =
|
list($openTag, $compiler->nocache, $local, $itemVar, $restore) =
|
||||||
$this->closeTag($compiler, array('foreach', 'foreachelse'));
|
$this->closeTag($compiler, array('foreach', 'foreachelse'));
|
||||||
$output = "<?php\n";
|
$output = "<?php\n";
|
||||||
|
|
||||||
if ($restore === 2) {
|
if ($restore === 2) {
|
||||||
$output .= "{$itemVar} = {$local}saved;\n";
|
$output .= "{$itemVar} = {$local}saved;\n";
|
||||||
}
|
}
|
||||||
|
@@ -16,7 +16,6 @@
|
|||||||
*/
|
*/
|
||||||
class Smarty_Internal_Compile_Function extends Smarty_Internal_CompileBase
|
class Smarty_Internal_Compile_Function extends Smarty_Internal_CompileBase
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attribute definition: Overwrites base class.
|
* Attribute definition: Overwrites base class.
|
||||||
*
|
*
|
||||||
@@ -54,15 +53,16 @@ class Smarty_Internal_Compile_Function extends Smarty_Internal_CompileBase
|
|||||||
{
|
{
|
||||||
// check and get attributes
|
// check and get attributes
|
||||||
$_attr = $this->getAttributes($compiler, $args);
|
$_attr = $this->getAttributes($compiler, $args);
|
||||||
|
|
||||||
if ($_attr[ 'nocache' ] === true) {
|
if ($_attr[ 'nocache' ] === true) {
|
||||||
$compiler->trigger_template_error('nocache option not allowed', null, true);
|
$compiler->trigger_template_error('nocache option not allowed', null, true);
|
||||||
}
|
}
|
||||||
unset($_attr[ 'nocache' ]);
|
unset($_attr[ 'nocache' ]);
|
||||||
$_name = trim($_attr[ 'name' ], '\'"');
|
$_name = trim($_attr[ 'name' ], '\'"');
|
||||||
$compiler->parent_compiler->tpl_function[ $_name ] = array();
|
$compiler->parent_compiler->tpl_function[ $_name ] = array();
|
||||||
$save = array($_attr, $compiler->parser->current_buffer, $compiler->template->compiled->has_nocache_code,
|
$save = array(
|
||||||
$compiler->template->caching);
|
$_attr, $compiler->parser->current_buffer, $compiler->template->compiled->has_nocache_code,
|
||||||
|
$compiler->template->caching
|
||||||
|
);
|
||||||
$this->openTag($compiler, 'function', $save);
|
$this->openTag($compiler, 'function', $save);
|
||||||
// Init temporary context
|
// Init temporary context
|
||||||
$compiler->parser->current_buffer = new Smarty_Internal_ParseTree_Template();
|
$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
|
class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compiler object
|
* Compiler object
|
||||||
*
|
*
|
||||||
@@ -125,7 +124,6 @@ class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase
|
|||||||
$_functionCode = $compiler->parser->current_buffer;
|
$_functionCode = $compiler->parser->current_buffer;
|
||||||
// setup buffer for template function code
|
// setup buffer for template function code
|
||||||
$compiler->parser->current_buffer = new Smarty_Internal_ParseTree_Template();
|
$compiler->parser->current_buffer = new Smarty_Internal_ParseTree_Template();
|
||||||
|
|
||||||
$_funcName = "smarty_template_function_{$_name}_{$compiler->template->compiled->nocache_hash}";
|
$_funcName = "smarty_template_function_{$_name}_{$compiler->template->compiled->nocache_hash}";
|
||||||
$_funcNameCaching = $_funcName . '_nocache';
|
$_funcNameCaching = $_funcName . '_nocache';
|
||||||
if ($compiler->template->compiled->has_nocache_code) {
|
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 .= "function {$_funcName}(Smarty_Internal_Template \$_smarty_tpl,\$params) {\n";
|
||||||
$output .= $_paramsCode;
|
$output .= $_paramsCode;
|
||||||
$output .= "foreach (\$params as \$key => \$value) {\n\$_smarty_tpl->tpl_vars[\$key] = new Smarty_Variable(\$value, \$_smarty_tpl->isRenderingCache);\n}\n";
|
$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";
|
$output .= "?>\n";
|
||||||
$compiler->parser->current_buffer->append_subtree(
|
$compiler->parser->current_buffer->append_subtree(
|
||||||
$compiler->parser,
|
$compiler->parser,
|
||||||
@@ -218,12 +217,13 @@ class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase
|
|||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function removeNocache($match)
|
public function removeNocache($match)
|
||||||
{
|
{
|
||||||
$code =
|
$code =
|
||||||
preg_replace(
|
preg_replace(
|
||||||
"/((<\?php )?echo '\/\*%%SmartyNocache:{$this->compiler->template->compiled->nocache_hash}%%\*\/)|(\/\*\/%%SmartyNocache:{$this->compiler->template->compiled->nocache_hash}%%\*\/';(\?>\n)?)/",
|
"/((<\?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);
|
$code = str_replace(array('\\\'', '\\\\\''), array('\'', '\\\''), $code);
|
||||||
return $code;
|
return $code;
|
||||||
|
@@ -33,11 +33,9 @@ class Smarty_Internal_Compile_If extends Smarty_Internal_CompileBase
|
|||||||
$this->openTag($compiler, 'if', array(1, $compiler->nocache));
|
$this->openTag($compiler, 'if', array(1, $compiler->nocache));
|
||||||
// must whole block be nocache ?
|
// must whole block be nocache ?
|
||||||
$compiler->nocache = $compiler->nocache | $compiler->tag_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);
|
$compiler->trigger_template_error('missing if condition', null, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_array($parameter[ 'if condition' ])) {
|
if (is_array($parameter[ 'if condition' ])) {
|
||||||
if (is_array($parameter[ 'if condition' ][ 'var' ])) {
|
if (is_array($parameter[ 'if condition' ][ 'var' ])) {
|
||||||
$var = $parameter[ 'if condition' ][ 'var' ][ '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' ])) {
|
if (is_array($parameter[ 'if condition' ][ 'var' ])) {
|
||||||
$assignAttr[][ 'var' ] = $parameter[ 'if condition' ][ 'var' ][ 'var' ];
|
$assignAttr[][ 'var' ] = $parameter[ 'if condition' ][ 'var' ][ 'var' ];
|
||||||
$_output .= $assignCompiler->compile(
|
$_output .= $assignCompiler->compile(
|
||||||
$assignAttr, $compiler,
|
$assignAttr,
|
||||||
|
$compiler,
|
||||||
array('smarty_internal_index' => $parameter[ 'if condition' ][ 'var' ][ 'smarty_internal_index' ])
|
array('smarty_internal_index' => $parameter[ 'if condition' ][ 'var' ][ 'smarty_internal_index' ])
|
||||||
);
|
);
|
||||||
} else {
|
} 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'));
|
list($nesting, $compiler->tag_nocache) = $this->closeTag($compiler, array('if', 'elseif'));
|
||||||
$this->openTag($compiler, 'else', array($nesting, $compiler->tag_nocache));
|
$this->openTag($compiler, 'else', array($nesting, $compiler->tag_nocache));
|
||||||
|
|
||||||
return '<?php } else { ?>';
|
return '<?php } else { ?>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -118,13 +116,10 @@ class Smarty_Internal_Compile_Elseif extends Smarty_Internal_CompileBase
|
|||||||
{
|
{
|
||||||
// check and get attributes
|
// check and get attributes
|
||||||
$_attr = $this->getAttributes($compiler, $args);
|
$_attr = $this->getAttributes($compiler, $args);
|
||||||
|
|
||||||
list($nesting, $compiler->tag_nocache) = $this->closeTag($compiler, array('if', 'elseif'));
|
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);
|
$compiler->trigger_template_error('missing elseif condition', null, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
$assignCode = '';
|
$assignCode = '';
|
||||||
$var = '';
|
$var = '';
|
||||||
if (is_array($parameter[ 'if condition' ])) {
|
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' ])) {
|
if (is_array($parameter[ 'if condition' ][ 'var' ])) {
|
||||||
$assignAttr[][ 'var' ] = $parameter[ 'if condition' ][ 'var' ][ 'var' ];
|
$assignAttr[][ 'var' ] = $parameter[ 'if condition' ][ 'var' ][ 'var' ];
|
||||||
$assignCode .= $assignCompiler->compile(
|
$assignCode .= $assignCompiler->compile(
|
||||||
$assignAttr, $compiler,
|
$assignAttr,
|
||||||
|
$compiler,
|
||||||
array('smarty_internal_index' => $parameter[ 'if condition' ][ 'var' ][ 'smarty_internal_index' ])
|
array('smarty_internal_index' => $parameter[ 'if condition' ][ 'var' ][ 'smarty_internal_index' ])
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
@@ -156,7 +152,6 @@ class Smarty_Internal_Compile_Elseif extends Smarty_Internal_CompileBase
|
|||||||
} else {
|
} else {
|
||||||
$condition_by_assign = false;
|
$condition_by_assign = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$prefixCode = $compiler->getPrefixCode();
|
$prefixCode = $compiler->getPrefixCode();
|
||||||
if (empty($prefixCode)) {
|
if (empty($prefixCode)) {
|
||||||
if ($condition_by_assign) {
|
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'));
|
list($nesting, $compiler->nocache) = $this->closeTag($compiler, array('if', 'else', 'elseif'));
|
||||||
$tmp = '';
|
$tmp = '';
|
||||||
for ($i = 0; $i < $nesting; $i ++) {
|
for ($i = 0; $i < $nesting; $i++) {
|
||||||
$tmp .= '}';
|
$tmp .= '}';
|
||||||
}
|
}
|
||||||
|
|
||||||
return "<?php {$tmp}?>";
|
return "<?php {$tmp}?>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -7,6 +7,7 @@
|
|||||||
* @subpackage Compiler
|
* @subpackage Compiler
|
||||||
* @author Uwe Tews
|
* @author Uwe Tews
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty Internal Plugin Compile Include Class
|
* 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
|
* caching mode to create nocache code but no cache file
|
||||||
*/
|
*/
|
||||||
const CACHING_NOCACHE_CODE = 9999;
|
const CACHING_NOCACHE_CODE = 9999;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attribute definition: Overwrites base class.
|
* Attribute definition: Overwrites base class.
|
||||||
*
|
*
|
||||||
@@ -26,6 +28,7 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase
|
|||||||
* @see Smarty_Internal_CompileBase
|
* @see Smarty_Internal_CompileBase
|
||||||
*/
|
*/
|
||||||
public $required_attributes = array('file');
|
public $required_attributes = array('file');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attribute definition: Overwrites base class.
|
* Attribute definition: Overwrites base class.
|
||||||
*
|
*
|
||||||
@@ -33,6 +36,7 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase
|
|||||||
* @see Smarty_Internal_CompileBase
|
* @see Smarty_Internal_CompileBase
|
||||||
*/
|
*/
|
||||||
public $shorttag_order = array('file');
|
public $shorttag_order = array('file');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attribute definition: Overwrites base class.
|
* Attribute definition: Overwrites base class.
|
||||||
*
|
*
|
||||||
@@ -40,6 +44,7 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase
|
|||||||
* @see Smarty_Internal_CompileBase
|
* @see Smarty_Internal_CompileBase
|
||||||
*/
|
*/
|
||||||
public $option_flags = array('nocache', 'inline', 'caching');
|
public $option_flags = array('nocache', 'inline', 'caching');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attribute definition: Overwrites base class.
|
* Attribute definition: Overwrites base class.
|
||||||
*
|
*
|
||||||
@@ -47,14 +52,17 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase
|
|||||||
* @see Smarty_Internal_CompileBase
|
* @see Smarty_Internal_CompileBase
|
||||||
*/
|
*/
|
||||||
public $optional_attributes = array('_any');
|
public $optional_attributes = array('_any');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Valid scope names
|
* Valid scope names
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public $valid_scopes = array('parent' => Smarty::SCOPE_PARENT, 'root' => Smarty::SCOPE_ROOT,
|
public $valid_scopes = array(
|
||||||
'global' => Smarty::SCOPE_GLOBAL, 'tpl_root' => Smarty::SCOPE_TPL_ROOT,
|
'parent' => Smarty::SCOPE_PARENT, 'root' => Smarty::SCOPE_ROOT,
|
||||||
'smarty' => Smarty::SCOPE_SMARTY);
|
'global' => Smarty::SCOPE_GLOBAL, 'tpl_root' => Smarty::SCOPE_TPL_ROOT,
|
||||||
|
'smarty' => Smarty::SCOPE_SMARTY
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compiles code for the {include} tag
|
* Compiles code for the {include} tag
|
||||||
@@ -91,7 +99,8 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase
|
|||||||
$compiled->includes[ $fullResourceName ]++;
|
$compiled->includes[ $fullResourceName ]++;
|
||||||
$cache_tpl = true;
|
$cache_tpl = true;
|
||||||
} else {
|
} 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
|
// recursive call of current template
|
||||||
$compiled->includes[ $fullResourceName ] = 2;
|
$compiled->includes[ $fullResourceName ] = 2;
|
||||||
@@ -193,8 +202,11 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase
|
|||||||
$compiler->smarty->allow_ambiguous_resources = true;
|
$compiler->smarty->allow_ambiguous_resources = true;
|
||||||
/* @var Smarty_Internal_Template $tpl */
|
/* @var Smarty_Internal_Template $tpl */
|
||||||
$tpl = new $compiler->smarty->template_class(
|
$tpl = new $compiler->smarty->template_class(
|
||||||
trim($fullResourceName, '"\''), $compiler->smarty,
|
trim($fullResourceName, '"\''),
|
||||||
$compiler->template, $compiler->template->cache_id, $c_id,
|
$compiler->smarty,
|
||||||
|
$compiler->template,
|
||||||
|
$compiler->template->cache_id,
|
||||||
|
$c_id,
|
||||||
$_caching
|
$_caching
|
||||||
);
|
);
|
||||||
$uid = $tpl->source->type . $tpl->source->uid;
|
$uid = $tpl->source->type . $tpl->source->uid;
|
||||||
@@ -276,7 +288,8 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase
|
|||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
* @throws \SmartyException
|
* @throws \SmartyException
|
||||||
*/
|
*/
|
||||||
public function compileInlineTemplate(Smarty_Internal_SmartyTemplateCompiler $compiler,
|
public function compileInlineTemplate(
|
||||||
|
Smarty_Internal_SmartyTemplateCompiler $compiler,
|
||||||
Smarty_Internal_Template $tpl,
|
Smarty_Internal_Template $tpl,
|
||||||
$t_hash
|
$t_hash
|
||||||
) {
|
) {
|
||||||
|
@@ -7,6 +7,7 @@
|
|||||||
* @subpackage Compiler
|
* @subpackage Compiler
|
||||||
* @author Uwe Tews
|
* @author Uwe Tews
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty Internal Plugin Compile Insert Class
|
* Smarty Internal Plugin Compile Insert Class
|
||||||
*
|
*
|
||||||
@@ -57,9 +58,9 @@ class Smarty_Internal_Compile_Include_Php extends Smarty_Internal_CompileBase
|
|||||||
// check and get attributes
|
// check and get attributes
|
||||||
$_attr = $this->getAttributes($compiler, $args);
|
$_attr = $this->getAttributes($compiler, $args);
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
*
|
*
|
||||||
* @var Smarty_Internal_Template $_smarty_tpl
|
*
|
||||||
|
* @var Smarty_Internal_Template $_smarty_tpl
|
||||||
* used in evaluated code
|
* used in evaluated code
|
||||||
*/
|
*/
|
||||||
$_smarty_tpl = $compiler->template;
|
$_smarty_tpl = $compiler->template;
|
||||||
|
@@ -23,6 +23,7 @@ class Smarty_Internal_Compile_Insert extends Smarty_Internal_CompileBase
|
|||||||
* @see Smarty_Internal_CompileBase
|
* @see Smarty_Internal_CompileBase
|
||||||
*/
|
*/
|
||||||
public $required_attributes = array('name');
|
public $required_attributes = array('name');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attribute definition: Overwrites base class.
|
* Attribute definition: Overwrites base class.
|
||||||
*
|
*
|
||||||
@@ -30,6 +31,7 @@ class Smarty_Internal_Compile_Insert extends Smarty_Internal_CompileBase
|
|||||||
* @see Smarty_Internal_CompileBase
|
* @see Smarty_Internal_CompileBase
|
||||||
*/
|
*/
|
||||||
public $shorttag_order = array('name');
|
public $shorttag_order = array('name');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attribute definition: Overwrites base class.
|
* Attribute definition: Overwrites base class.
|
||||||
*
|
*
|
||||||
|
@@ -40,7 +40,6 @@ class Smarty_Internal_Compile_Nocache extends Smarty_Internal_CompileBase
|
|||||||
$compiler->nocache = true;
|
$compiler->nocache = true;
|
||||||
// this tag does not return compiled code
|
// this tag does not return compiled code
|
||||||
$compiler->has_code = false;
|
$compiler->has_code = false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -69,7 +68,6 @@ class Smarty_Internal_Compile_Nocacheclose extends Smarty_Internal_CompileBase
|
|||||||
list($compiler->nocache) = $this->closeTag($compiler, array('nocache'));
|
list($compiler->nocache) = $this->closeTag($compiler, array('nocache'));
|
||||||
// this tag does not return compiled code
|
// this tag does not return compiled code
|
||||||
$compiler->has_code = false;
|
$compiler->has_code = false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/**
|
||||||
* This file is part of Smarty.
|
* This file is part of Smarty.
|
||||||
*
|
*
|
||||||
* (c) 2015 Uwe Tews
|
* (c) 2015 Uwe Tews
|
||||||
@@ -15,7 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
class Smarty_Internal_Compile_Parent extends Smarty_Internal_Compile_Child
|
class Smarty_Internal_Compile_Parent extends Smarty_Internal_Compile_Child
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tag name
|
* Tag name
|
||||||
*
|
*
|
||||||
|
@@ -46,15 +46,14 @@ class Smarty_Internal_Compile_Private_Block_Plugin extends Smarty_Internal_Compi
|
|||||||
*/
|
*/
|
||||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter, $tag, $function = null)
|
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter, $tag, $function = null)
|
||||||
{
|
{
|
||||||
if (!isset($tag[ 5 ]) || substr($tag, - 5) !== 'close') {
|
if (!isset($tag[ 5 ]) || substr($tag, -5) !== 'close') {
|
||||||
// opening tag of block plugin
|
// opening tag of block plugin
|
||||||
// check and get attributes
|
// check and get attributes
|
||||||
$_attr = $this->getAttributes($compiler, $args);
|
$_attr = $this->getAttributes($compiler, $args);
|
||||||
$this->nesting ++;
|
$this->nesting++;
|
||||||
unset($_attr[ 'nocache' ]);
|
unset($_attr[ 'nocache' ]);
|
||||||
list($callback, $_paramsArray, $callable) = $this->setup($compiler, $_attr, $tag, $function);
|
list($callback, $_paramsArray, $callable) = $this->setup($compiler, $_attr, $tag, $function);
|
||||||
$_params = 'array(' . implode(',', $_paramsArray) . ')';
|
$_params = 'array(' . implode(',', $_paramsArray) . ')';
|
||||||
|
|
||||||
// compile code
|
// compile code
|
||||||
$output = "<?php ";
|
$output = "<?php ";
|
||||||
if (is_array($callback)) {
|
if (is_array($callback)) {
|
||||||
@@ -75,7 +74,7 @@ class Smarty_Internal_Compile_Private_Block_Plugin extends Smarty_Internal_Compi
|
|||||||
$compiler->tag_nocache = true;
|
$compiler->tag_nocache = true;
|
||||||
}
|
}
|
||||||
// closing tag of block plugin, restore nocache
|
// 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
|
// compile code
|
||||||
if (!isset($parameter[ 'modifier_list' ])) {
|
if (!isset($parameter[ 'modifier_list' ])) {
|
||||||
$mod_pre = $mod_post = $mod_content = '';
|
$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_content = "\$_block_content{$this->nesting} = ob_get_clean();\n";
|
||||||
$mod_pre = "ob_start();\n";
|
$mod_pre = "ob_start();\n";
|
||||||
$mod_post = 'echo ' . $compiler->compileTag(
|
$mod_post = 'echo ' . $compiler->compileTag(
|
||||||
'private_modifier', array(),
|
'private_modifier',
|
||||||
array('modifierlist' => $parameter[ 'modifier_list' ],
|
array(),
|
||||||
'value' => 'ob_get_clean()')
|
array(
|
||||||
) . ";\n";
|
'modifierlist' => $parameter[ 'modifier_list' ],
|
||||||
|
'value' => 'ob_get_clean()'
|
||||||
|
)
|
||||||
|
) . ";\n";
|
||||||
}
|
}
|
||||||
$output = "<?php {$mod_content}\$_block_repeat=false;\n{$mod_pre}echo {$callback}({$_params}, {$mod_content2}, \$_smarty_tpl, \$_block_repeat);\n{$mod_post}}\n";
|
$output =
|
||||||
|
"<?php {$mod_content}\$_block_repeat=false;\n{$mod_pre}echo {$callback}({$_params}, {$mod_content2}, \$_smarty_tpl, \$_block_repeat);\n{$mod_post}}\n";
|
||||||
$output .= 'array_pop($_smarty_tpl->smarty->_cache[\'_tag_stack\']);?>';
|
$output .= 'array_pop($_smarty_tpl->smarty->_cache[\'_tag_stack\']);?>';
|
||||||
}
|
}
|
||||||
return $output;
|
return $output;
|
||||||
@@ -100,7 +103,7 @@ class Smarty_Internal_Compile_Private_Block_Plugin extends Smarty_Internal_Compi
|
|||||||
* Setup callback and parameter array
|
* Setup callback and parameter array
|
||||||
*
|
*
|
||||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler
|
* @param \Smarty_Internal_TemplateCompilerBase $compiler
|
||||||
* @param array $_attr attributes
|
* @param array $_attr attributes
|
||||||
* @param string $tag
|
* @param string $tag
|
||||||
* @param string $function
|
* @param string $function
|
||||||
*
|
*
|
||||||
|
@@ -16,7 +16,6 @@
|
|||||||
*/
|
*/
|
||||||
class Smarty_Internal_Compile_Private_ForeachSection extends Smarty_Internal_CompileBase
|
class Smarty_Internal_Compile_Private_ForeachSection extends Smarty_Internal_CompileBase
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Preg search pattern
|
* Preg search pattern
|
||||||
*
|
*
|
||||||
@@ -113,8 +112,10 @@ class Smarty_Internal_Compile_Private_ForeachSection extends Smarty_Internal_Com
|
|||||||
{
|
{
|
||||||
if ($named) {
|
if ($named) {
|
||||||
$this->resultOffsets[ 'named' ] = $this->startOffset + 4;
|
$this->resultOffsets[ 'named' ] = $this->startOffset + 4;
|
||||||
$this->propertyPreg .= "(([\$]smarty[.]{$this->tagName}[.]" . ($this->tagName === 'section' ? "|[\[]\s*" : '')
|
$this->propertyPreg .= "(([\$]smarty[.]{$this->tagName}[.]" .
|
||||||
. "){$attributes['name']}[.](";
|
($this->tagName === 'section' ? "|[\[]\s*" : '')
|
||||||
|
.
|
||||||
|
"){$attributes['name']}[.](";
|
||||||
$properties = $this->nameProperties;
|
$properties = $this->nameProperties;
|
||||||
} else {
|
} else {
|
||||||
$this->resultOffsets[ 'item' ] = $this->startOffset + 3;
|
$this->resultOffsets[ 'item' ] = $this->startOffset + 3;
|
||||||
@@ -179,10 +180,11 @@ class Smarty_Internal_Compile_Private_ForeachSection extends Smarty_Internal_Com
|
|||||||
if ($_content !== '') {
|
if ($_content !== '') {
|
||||||
// run pre filter if required
|
// run pre filter if required
|
||||||
if ((isset($nextCompiler->smarty->autoload_filters[ 'pre' ])
|
if ((isset($nextCompiler->smarty->autoload_filters[ 'pre' ])
|
||||||
|| isset($nextCompiler->smarty->registered_filters[ 'pre' ]))
|
|| isset($nextCompiler->smarty->registered_filters[ 'pre' ]))
|
||||||
) {
|
) {
|
||||||
$_content = $nextCompiler->smarty->ext->_filterHandler->runFilter(
|
$_content = $nextCompiler->smarty->ext->_filterHandler->runFilter(
|
||||||
'pre', $_content,
|
'pre',
|
||||||
|
$_content,
|
||||||
$nextCompiler->template
|
$nextCompiler->template
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@@ -49,7 +49,6 @@ class Smarty_Internal_Compile_Private_Function_Plugin extends Smarty_Internal_Co
|
|||||||
{
|
{
|
||||||
// check and get attributes
|
// check and get attributes
|
||||||
$_attr = $this->getAttributes($compiler, $args);
|
$_attr = $this->getAttributes($compiler, $args);
|
||||||
|
|
||||||
unset($_attr[ 'nocache' ]);
|
unset($_attr[ 'nocache' ]);
|
||||||
// convert attributes into parameter array string
|
// convert attributes into parameter array string
|
||||||
$_paramsArray = array();
|
$_paramsArray = array();
|
||||||
@@ -65,9 +64,12 @@ class Smarty_Internal_Compile_Private_Function_Plugin extends Smarty_Internal_Co
|
|||||||
$output = "{$function}({$_params},\$_smarty_tpl)";
|
$output = "{$function}({$_params},\$_smarty_tpl)";
|
||||||
if (!empty($parameter[ 'modifierlist' ])) {
|
if (!empty($parameter[ 'modifierlist' ])) {
|
||||||
$output = $compiler->compileTag(
|
$output = $compiler->compileTag(
|
||||||
'private_modifier', array(),
|
'private_modifier',
|
||||||
array('modifierlist' => $parameter[ 'modifierlist' ],
|
array(),
|
||||||
'value' => $output)
|
array(
|
||||||
|
'modifierlist' => $parameter[ 'modifierlist' ],
|
||||||
|
'value' => $output
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$output = "<?php echo {$output};?>\n";
|
$output = "<?php echo {$output};?>\n";
|
||||||
|
@@ -20,7 +20,7 @@ class Smarty_Internal_Compile_Private_Object_Block_Function extends Smarty_Inter
|
|||||||
* Setup callback and parameter array
|
* Setup callback and parameter array
|
||||||
*
|
*
|
||||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler
|
* @param \Smarty_Internal_TemplateCompilerBase $compiler
|
||||||
* @param array $_attr attributes
|
* @param array $_attr attributes
|
||||||
* @param string $tag
|
* @param string $tag
|
||||||
* @param string $method
|
* @param string $method
|
||||||
*
|
*
|
||||||
|
@@ -71,7 +71,8 @@ class Smarty_Internal_Compile_Private_Object_Function extends Smarty_Internal_Co
|
|||||||
}
|
}
|
||||||
if (!empty($parameter[ 'modifierlist' ])) {
|
if (!empty($parameter[ 'modifierlist' ])) {
|
||||||
$output = $compiler->compileTag(
|
$output = $compiler->compileTag(
|
||||||
'private_modifier', array(),
|
'private_modifier',
|
||||||
|
array(),
|
||||||
array('modifierlist' => $parameter[ 'modifierlist' ], 'value' => $output)
|
array('modifierlist' => $parameter[ 'modifierlist' ], 'value' => $output)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@@ -16,7 +16,6 @@
|
|||||||
*/
|
*/
|
||||||
class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase
|
class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attribute definition: Overwrites base class.
|
* Attribute definition: Overwrites base class.
|
||||||
*
|
*
|
||||||
@@ -62,7 +61,8 @@ class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase
|
|||||||
$output =
|
$output =
|
||||||
preg_replace_callback(
|
preg_replace_callback(
|
||||||
'#(<\?(?:php|=)?)|(<%)|(<script\s+language\s*=\s*["\']?\s*php\s*["\']?\s*>)|(\?>)|(%>)|(<\/script>)#i',
|
'#(<\?(?:php|=)?)|(<%)|(<script\s+language\s*=\s*["\']?\s*php\s*["\']?\s*>)|(\?>)|(%>)|(<\/script>)#i',
|
||||||
array($this, 'quote'), $_attr[ 'code' ]
|
array($this, 'quote'),
|
||||||
|
$_attr[ 'code' ]
|
||||||
);
|
);
|
||||||
$compiler->parser->current_buffer->append_subtree(
|
$compiler->parser->current_buffer->append_subtree(
|
||||||
$compiler->parser,
|
$compiler->parser,
|
||||||
@@ -87,7 +87,8 @@ class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase
|
|||||||
if (!($compiler->smarty instanceof SmartyBC)) {
|
if (!($compiler->smarty instanceof SmartyBC)) {
|
||||||
$compiler->trigger_template_error(
|
$compiler->trigger_template_error(
|
||||||
'$smarty->php_handling PHP_ALLOW not allowed. Use SmartyBC to enable it',
|
'$smarty->php_handling PHP_ALLOW not allowed. Use SmartyBC to enable it',
|
||||||
null, true
|
null,
|
||||||
|
true
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$compiler->has_code = true;
|
$compiler->has_code = true;
|
||||||
@@ -99,7 +100,8 @@ class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase
|
|||||||
$compiler->has_code = true;
|
$compiler->has_code = true;
|
||||||
if (!($compiler->smarty instanceof SmartyBC)) {
|
if (!($compiler->smarty instanceof SmartyBC)) {
|
||||||
$compiler->trigger_template_error(
|
$compiler->trigger_template_error(
|
||||||
'{php}{/php} tags not allowed. Use SmartyBC to enable them', null,
|
'{php}{/php} tags not allowed. Use SmartyBC to enable them',
|
||||||
|
null,
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -115,7 +117,8 @@ class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase
|
|||||||
}
|
}
|
||||||
return preg_replace(
|
return preg_replace(
|
||||||
array("#^{$ldel}\\s*php\\s*(.)*?{$rdel}#", "#{$ldel}\\s*/\\s*php\\s*{$rdel}$#"),
|
array("#^{$ldel}\\s*php\\s*(.)*?{$rdel}#", "#{$ldel}\\s*/\\s*php\\s*{$rdel}$#"),
|
||||||
array('<?php ', '?>'), $_attr[ 'code' ]
|
array('<?php ', '?>'),
|
||||||
|
$_attr[ 'code' ]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -171,7 +174,9 @@ class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (($lex->phpType === 'php' || $lex->phpType === 'asp')
|
if (($lex->phpType === 'php' || $lex->phpType === 'asp')
|
||||||
&& ($lex->compiler->php_handling === Smarty::PHP_PASSTHRU || $lex->compiler->php_handling === Smarty::PHP_QUOTE)
|
&&
|
||||||
|
($lex->compiler->php_handling === Smarty::PHP_PASSTHRU ||
|
||||||
|
$lex->compiler->php_handling === Smarty::PHP_QUOTE)
|
||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -185,7 +190,10 @@ class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase
|
|||||||
while ($body) {
|
while ($body) {
|
||||||
if (preg_match(
|
if (preg_match(
|
||||||
'~([/][*])|([/][/][^\n]*)|(\'[^\'\\\\]*(?:\\.[^\'\\\\]*)*\')|("[^"\\\\]*(?:\\.[^"\\\\]*)*")~',
|
'~([/][*])|([/][/][^\n]*)|(\'[^\'\\\\]*(?:\\.[^\'\\\\]*)*\')|("[^"\\\\]*(?:\\.[^"\\\\]*)*")~',
|
||||||
$lex->data, $match, PREG_OFFSET_CAPTURE, $start
|
$lex->data,
|
||||||
|
$match,
|
||||||
|
PREG_OFFSET_CAPTURE,
|
||||||
|
$start
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
$value = $match[ 0 ][ 0 ];
|
$value = $match[ 0 ][ 0 ];
|
||||||
@@ -204,7 +212,10 @@ class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase
|
|||||||
}
|
}
|
||||||
while ($close > $pos && $close < $start) {
|
while ($close > $pos && $close < $start) {
|
||||||
if (preg_match(
|
if (preg_match(
|
||||||
'~' . preg_quote($closeTag, '~') . '~i', $lex->data, $match, PREG_OFFSET_CAPTURE,
|
'~' . preg_quote($closeTag, '~') . '~i',
|
||||||
|
$lex->data,
|
||||||
|
$match,
|
||||||
|
PREG_OFFSET_CAPTURE,
|
||||||
$from
|
$from
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
|
@@ -50,9 +50,12 @@ class Smarty_Internal_Compile_Private_Print_Expression extends Smarty_Internal_C
|
|||||||
// tag modifier
|
// tag modifier
|
||||||
if (!empty($parameter[ 'modifierlist' ])) {
|
if (!empty($parameter[ 'modifierlist' ])) {
|
||||||
$output = $compiler->compileTag(
|
$output = $compiler->compileTag(
|
||||||
'private_modifier', array(),
|
'private_modifier',
|
||||||
array('modifierlist' => $parameter[ 'modifierlist' ],
|
array(),
|
||||||
'value' => $output)
|
array(
|
||||||
|
'modifierlist' => $parameter[ 'modifierlist' ],
|
||||||
|
'value' => $output
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (isset($_attr[ 'assign' ])) {
|
if (isset($_attr[ 'assign' ])) {
|
||||||
@@ -68,9 +71,10 @@ class Smarty_Internal_Compile_Private_Print_Expression extends Smarty_Internal_C
|
|||||||
foreach ($compiler->smarty->default_modifiers as $key => $single_default_modifier) {
|
foreach ($compiler->smarty->default_modifiers as $key => $single_default_modifier) {
|
||||||
preg_match_all(
|
preg_match_all(
|
||||||
'/(\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\'|"[^"\\\\]*(?:\\\\.[^"\\\\]*)*"|:|[^:]+)/',
|
'/(\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\'|"[^"\\\\]*(?:\\\\.[^"\\\\]*)*"|:|[^:]+)/',
|
||||||
$single_default_modifier, $mod_array
|
$single_default_modifier,
|
||||||
|
$mod_array
|
||||||
);
|
);
|
||||||
for ($i = 0, $count = count($mod_array[ 0 ]); $i < $count; $i ++) {
|
for ($i = 0, $count = count($mod_array[ 0 ]); $i < $count; $i++) {
|
||||||
if ($mod_array[ 0 ][ $i ] !== ':') {
|
if ($mod_array[ 0 ][ $i ] !== ':') {
|
||||||
$modifierlist[ $key ][] = $mod_array[ 0 ][ $i ];
|
$modifierlist[ $key ][] = $mod_array[ 0 ][ $i ];
|
||||||
}
|
}
|
||||||
@@ -79,9 +83,12 @@ class Smarty_Internal_Compile_Private_Print_Expression extends Smarty_Internal_C
|
|||||||
$compiler->default_modifier_list = $modifierlist;
|
$compiler->default_modifier_list = $modifierlist;
|
||||||
}
|
}
|
||||||
$output = $compiler->compileTag(
|
$output = $compiler->compileTag(
|
||||||
'private_modifier', array(),
|
'private_modifier',
|
||||||
array('modifierlist' => $compiler->default_modifier_list,
|
array(),
|
||||||
'value' => $output)
|
array(
|
||||||
|
'modifierlist' => $compiler->default_modifier_list,
|
||||||
|
'value' => $output
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// autoescape html
|
// autoescape html
|
||||||
@@ -91,7 +98,7 @@ class Smarty_Internal_Compile_Private_Print_Expression extends Smarty_Internal_C
|
|||||||
// loop over registered filters
|
// loop over registered filters
|
||||||
if (!empty($compiler->template->smarty->registered_filters[ Smarty::FILTER_VARIABLE ])) {
|
if (!empty($compiler->template->smarty->registered_filters[ Smarty::FILTER_VARIABLE ])) {
|
||||||
foreach ($compiler->template->smarty->registered_filters[ Smarty::FILTER_VARIABLE ] as $key =>
|
foreach ($compiler->template->smarty->registered_filters[ Smarty::FILTER_VARIABLE ] as $key =>
|
||||||
$function) {
|
$function) {
|
||||||
if (!is_array($function)) {
|
if (!is_array($function)) {
|
||||||
$output = "{$function}({$output},\$_smarty_tpl)";
|
$output = "{$function}({$output},\$_smarty_tpl)";
|
||||||
} elseif (is_object($function[ 0 ])) {
|
} elseif (is_object($function[ 0 ])) {
|
||||||
@@ -104,8 +111,7 @@ class Smarty_Internal_Compile_Private_Print_Expression extends Smarty_Internal_C
|
|||||||
}
|
}
|
||||||
// auto loaded filters
|
// auto loaded filters
|
||||||
if (isset($compiler->smarty->autoload_filters[ Smarty::FILTER_VARIABLE ])) {
|
if (isset($compiler->smarty->autoload_filters[ Smarty::FILTER_VARIABLE ])) {
|
||||||
foreach ((array) $compiler->template->smarty->autoload_filters[ Smarty::FILTER_VARIABLE ] as $name)
|
foreach ((array)$compiler->template->smarty->autoload_filters[ Smarty::FILTER_VARIABLE ] as $name) {
|
||||||
{
|
|
||||||
$result = $this->compile_variable_filter($compiler, $name, $output);
|
$result = $this->compile_variable_filter($compiler, $name, $output);
|
||||||
if ($result !== false) {
|
if ($result !== false) {
|
||||||
$output = $result;
|
$output = $result;
|
||||||
@@ -122,7 +128,8 @@ class Smarty_Internal_Compile_Private_Print_Expression extends Smarty_Internal_C
|
|||||||
$output = $result;
|
$output = $result;
|
||||||
} else {
|
} else {
|
||||||
$output = $compiler->compileTag(
|
$output = $compiler->compileTag(
|
||||||
'private_modifier', array(),
|
'private_modifier',
|
||||||
|
array(),
|
||||||
array('modifierlist' => array($filter), 'value' => $output)
|
array('modifierlist' => array($filter), 'value' => $output)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -130,7 +137,6 @@ class Smarty_Internal_Compile_Private_Print_Expression extends Smarty_Internal_C
|
|||||||
}
|
}
|
||||||
$output = "<?php echo {$output};?>\n";
|
$output = "<?php echo {$output};?>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,7 +150,7 @@ class Smarty_Internal_Compile_Private_Print_Expression extends Smarty_Internal_C
|
|||||||
*/
|
*/
|
||||||
private function compile_variable_filter(Smarty_Internal_TemplateCompilerBase $compiler, $name, $output)
|
private function compile_variable_filter(Smarty_Internal_TemplateCompilerBase $compiler, $name, $output)
|
||||||
{
|
{
|
||||||
$function= $compiler->getPlugin($name, 'variablefilter');
|
$function = $compiler->getPlugin($name, 'variablefilter');
|
||||||
if ($function) {
|
if ($function) {
|
||||||
return "{$function}({$output},\$_smarty_tpl)";
|
return "{$function}({$output},\$_smarty_tpl)";
|
||||||
} else {
|
} else {
|
||||||
|
@@ -20,7 +20,7 @@ class Smarty_Internal_Compile_Private_Registered_Block extends Smarty_Internal_C
|
|||||||
* Setup callback, parameter array and nocache mode
|
* Setup callback, parameter array and nocache mode
|
||||||
*
|
*
|
||||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler
|
* @param \Smarty_Internal_TemplateCompilerBase $compiler
|
||||||
* @param array $_attr attributes
|
* @param array $_attr attributes
|
||||||
* @param string $tag
|
* @param string $tag
|
||||||
* @param null $function
|
* @param null $function
|
||||||
*
|
*
|
||||||
|
@@ -45,8 +45,8 @@ class Smarty_Internal_Compile_Private_Registered_Function extends Smarty_Interna
|
|||||||
$tag_info = $compiler->smarty->registered_plugins[ Smarty::PLUGIN_FUNCTION ][ $tag ];
|
$tag_info = $compiler->smarty->registered_plugins[ Smarty::PLUGIN_FUNCTION ][ $tag ];
|
||||||
$is_registered = true;
|
$is_registered = true;
|
||||||
} else {
|
} else {
|
||||||
$tag_info = $compiler->default_handler_plugins[ Smarty::PLUGIN_FUNCTION ][ $tag ];
|
$tag_info = $compiler->default_handler_plugins[ Smarty::PLUGIN_FUNCTION ][ $tag ];
|
||||||
$is_registered = false;
|
$is_registered = false;
|
||||||
}
|
}
|
||||||
// not cacheable?
|
// not cacheable?
|
||||||
$compiler->tag_nocache = $compiler->tag_nocache || !$tag_info[ 1 ];
|
$compiler->tag_nocache = $compiler->tag_nocache || !$tag_info[ 1 ];
|
||||||
@@ -77,9 +77,12 @@ class Smarty_Internal_Compile_Private_Registered_Function extends Smarty_Interna
|
|||||||
}
|
}
|
||||||
if (!empty($parameter[ 'modifierlist' ])) {
|
if (!empty($parameter[ 'modifierlist' ])) {
|
||||||
$output = $compiler->compileTag(
|
$output = $compiler->compileTag(
|
||||||
'private_modifier', array(),
|
'private_modifier',
|
||||||
array('modifierlist' => $parameter[ 'modifierlist' ],
|
array(),
|
||||||
'value' => $output)
|
array(
|
||||||
|
'modifierlist' => $parameter[ 'modifierlist' ],
|
||||||
|
'value' => $output
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$output = "<?php echo {$output};?>\n";
|
$output = "<?php echo {$output};?>\n";
|
||||||
|
@@ -43,9 +43,11 @@ class Smarty_Internal_Compile_Private_Special_Variable extends Smarty_Internal_C
|
|||||||
$class = 'Smarty_Internal_Compile_' . ucfirst($variable);
|
$class = 'Smarty_Internal_Compile_' . ucfirst($variable);
|
||||||
Smarty_Internal_TemplateCompilerBase::$_tag_objects[ $variable ] = new $class;
|
Smarty_Internal_TemplateCompilerBase::$_tag_objects[ $variable ] = new $class;
|
||||||
}
|
}
|
||||||
return Smarty_Internal_TemplateCompilerBase::$_tag_objects[ $variable ]->compileSpecialVariable(array(),
|
return Smarty_Internal_TemplateCompilerBase::$_tag_objects[ $variable ]->compileSpecialVariable(
|
||||||
$compiler,
|
array(),
|
||||||
$_index);
|
$compiler,
|
||||||
|
$_index
|
||||||
|
);
|
||||||
case 'capture':
|
case 'capture':
|
||||||
if (class_exists('Smarty_Internal_Compile_Capture')) {
|
if (class_exists('Smarty_Internal_Compile_Capture')) {
|
||||||
return Smarty_Internal_Compile_Capture::compileSpecialVariable(array(), $compiler, $_index);
|
return Smarty_Internal_Compile_Capture::compileSpecialVariable(array(), $compiler, $_index);
|
||||||
@@ -96,12 +98,14 @@ class Smarty_Internal_Compile_Private_Special_Variable extends Smarty_Internal_C
|
|||||||
} else {
|
} else {
|
||||||
return "@constant({$_index[1]})";
|
return "@constant({$_index[1]})";
|
||||||
}
|
}
|
||||||
|
// no break
|
||||||
case 'config':
|
case 'config':
|
||||||
if (isset($_index[ 2 ])) {
|
if (isset($_index[ 2 ])) {
|
||||||
return "(is_array(\$tmp = \$_smarty_tpl->smarty->ext->configload->_getConfigVariable(\$_smarty_tpl, $_index[1])) ? \$tmp[$_index[2]] : null)";
|
return "(is_array(\$tmp = \$_smarty_tpl->smarty->ext->configload->_getConfigVariable(\$_smarty_tpl, $_index[1])) ? \$tmp[$_index[2]] : null)";
|
||||||
} else {
|
} else {
|
||||||
return "\$_smarty_tpl->smarty->ext->configload->_getConfigVariable(\$_smarty_tpl, $_index[1])";
|
return "\$_smarty_tpl->smarty->ext->configload->_getConfigVariable(\$_smarty_tpl, $_index[1])";
|
||||||
}
|
}
|
||||||
|
// no break
|
||||||
case 'ldelim':
|
case 'ldelim':
|
||||||
return "\$_smarty_tpl->smarty->left_delimiter";
|
return "\$_smarty_tpl->smarty->left_delimiter";
|
||||||
case 'rdelim':
|
case 'rdelim':
|
||||||
|
@@ -59,8 +59,10 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_Compile_Private_Fo
|
|||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public $nameProperties = array('first', 'last', 'index', 'iteration', 'show', 'total', 'rownum', 'index_prev',
|
public $nameProperties = array(
|
||||||
'index_next', 'loop');
|
'first', 'last', 'index', 'iteration', 'show', 'total', 'rownum', 'index_prev',
|
||||||
|
'index_next', 'loop'
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {section} tag has no item properties
|
* {section} tag has no item properties
|
||||||
@@ -108,8 +110,9 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_Compile_Private_Fo
|
|||||||
$initFor = array();
|
$initFor = array();
|
||||||
$incFor = array();
|
$incFor = array();
|
||||||
$cmpFor = array();
|
$cmpFor = array();
|
||||||
$propValue = array('index' => "{$sectionVar}->value['index']", 'show' => 'true', 'step' => 1,
|
$propValue = array(
|
||||||
'iteration' => "{$local}iteration",
|
'index' => "{$sectionVar}->value['index']", 'show' => 'true', 'step' => 1,
|
||||||
|
'iteration' => "{$local}iteration",
|
||||||
);
|
);
|
||||||
$propType = array('index' => 2, 'iteration' => 2, 'show' => 0, 'step' => 0,);
|
$propType = array('index' => 2, 'iteration' => 2, 'show' => 0, 'step' => 0,);
|
||||||
// search for used tag attributes
|
// search for used tag attributes
|
||||||
@@ -232,12 +235,14 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_Compile_Private_Fo
|
|||||||
$propValue[ 'start' ] = join('', $start_code);
|
$propValue[ 'start' ] = join('', $start_code);
|
||||||
} else {
|
} else {
|
||||||
$start_code =
|
$start_code =
|
||||||
array(1 => "{$propValue['start']} < 0 ? ", 2 => 'max(', 3 => "{$propValue['step']} > 0 ? ", 4 => '0',
|
array(
|
||||||
5 => ' : ', 6 => '-1', 7 => ', ', 8 => "{$propValue['start']} + {$propValue['loop']}", 10 => ')',
|
1 => "{$propValue['start']} < 0 ? ", 2 => 'max(', 3 => "{$propValue['step']} > 0 ? ", 4 => '0',
|
||||||
11 => ' : ', 12 => 'min(', 13 => $propValue[ 'start' ], 14 => ', ',
|
5 => ' : ', 6 => '-1', 7 => ', ', 8 => "{$propValue['start']} + {$propValue['loop']}", 10 => ')',
|
||||||
15 => "{$propValue['step']} > 0 ? ", 16 => $propValue[ 'loop' ], 17 => ' : ',
|
11 => ' : ', 12 => 'min(', 13 => $propValue[ 'start' ], 14 => ', ',
|
||||||
18 => $propType[ 'loop' ] === 0 ? $propValue[ 'loop' ] - 1 : "{$propValue['loop']} - 1",
|
15 => "{$propValue['step']} > 0 ? ", 16 => $propValue[ 'loop' ], 17 => ' : ',
|
||||||
19 => ')');
|
18 => $propType[ 'loop' ] === 0 ? $propValue[ 'loop' ] - 1 : "{$propValue['loop']} - 1",
|
||||||
|
19 => ')'
|
||||||
|
);
|
||||||
if ($propType[ 'step' ] === 0) {
|
if ($propType[ 'step' ] === 0) {
|
||||||
$start_code[ 3 ] = $start_code[ 5 ] = $start_code[ 15 ] = $start_code[ 17 ] = '';
|
$start_code[ 3 ] = $start_code[ 5 ] = $start_code[ 15 ] = $start_code[ 17 ] = '';
|
||||||
if ($propValue[ 'step' ] > 0) {
|
if ($propValue[ 'step' ] > 0) {
|
||||||
@@ -257,10 +262,12 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_Compile_Private_Fo
|
|||||||
$start_code[ $i ] = '';
|
$start_code[ $i ] = '';
|
||||||
}
|
}
|
||||||
if ($propType[ 'start' ] === 0) {
|
if ($propType[ 'start' ] === 0) {
|
||||||
$start_code = array(max(
|
$start_code = array(
|
||||||
$propValue[ 'step' ] > 0 ? 0 : -1,
|
max(
|
||||||
$propValue[ 'start' ] + $propValue[ 'loop' ]
|
$propValue[ 'step' ] > 0 ? 0 : -1,
|
||||||
));
|
$propValue[ 'start' ] + $propValue[ 'loop' ]
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for ($i = 1; $i <= 11; $i++) {
|
for ($i = 1; $i <= 11; $i++) {
|
||||||
@@ -268,10 +275,12 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_Compile_Private_Fo
|
|||||||
}
|
}
|
||||||
if ($propType[ 'start' ] === 0) {
|
if ($propType[ 'start' ] === 0) {
|
||||||
$start_code =
|
$start_code =
|
||||||
array(min(
|
array(
|
||||||
$propValue[ 'step' ] > 0 ? $propValue[ 'loop' ] : $propValue[ 'loop' ] - 1,
|
min(
|
||||||
$propValue[ 'start' ]
|
$propValue[ 'step' ] > 0 ? $propValue[ 'loop' ] : $propValue[ 'loop' ] - 1,
|
||||||
));
|
$propValue[ 'start' ]
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -298,10 +307,12 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_Compile_Private_Fo
|
|||||||
$propValue[ 'max' ]
|
$propValue[ 'max' ]
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
$total_code = array(1 => 'min(', 2 => 'ceil(', 3 => '(', 4 => "{$propValue['step']} > 0 ? ",
|
$total_code = array(
|
||||||
5 => $propValue[ 'loop' ], 6 => ' - ', 7 => $propValue[ 'start' ], 8 => ' : ',
|
1 => 'min(', 2 => 'ceil(', 3 => '(', 4 => "{$propValue['step']} > 0 ? ",
|
||||||
9 => $propValue[ 'start' ], 10 => '+ 1', 11 => ')', 12 => '/ ', 13 => 'abs(',
|
5 => $propValue[ 'loop' ], 6 => ' - ', 7 => $propValue[ 'start' ], 8 => ' : ',
|
||||||
14 => $propValue[ 'step' ], 15 => ')', 16 => ')', 17 => ", {$propValue['max']})",);
|
9 => $propValue[ 'start' ], 10 => '+ 1', 11 => ')', 12 => '/ ', 13 => 'abs(',
|
||||||
|
14 => $propValue[ 'step' ], 15 => ')', 16 => ')', 17 => ", {$propValue['max']})",
|
||||||
|
);
|
||||||
if (!isset($propValue[ 'max' ])) {
|
if (!isset($propValue[ 'max' ])) {
|
||||||
$total_code[ 1 ] = $total_code[ 17 ] = '';
|
$total_code[ 1 ] = $total_code[ 17 ] = '';
|
||||||
}
|
}
|
||||||
|
@@ -31,7 +31,6 @@ class Smarty_Internal_Compile_Setfilter extends Smarty_Internal_CompileBase
|
|||||||
$compiler->variable_filters = $parameter[ 'modifier_list' ];
|
$compiler->variable_filters = $parameter[ 'modifier_list' ];
|
||||||
// this tag does not return compiled code
|
// this tag does not return compiled code
|
||||||
$compiler->has_code = false;
|
$compiler->has_code = false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -64,7 +63,6 @@ class Smarty_Internal_Compile_Setfilterclose extends Smarty_Internal_CompileBase
|
|||||||
}
|
}
|
||||||
// this tag does not return compiled code
|
// this tag does not return compiled code
|
||||||
$compiler->has_code = false;
|
$compiler->has_code = false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -22,7 +22,7 @@ class Smarty_Internal_Compile_Shared_Inheritance extends Smarty_Internal_Compile
|
|||||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler
|
* @param \Smarty_Internal_TemplateCompilerBase $compiler
|
||||||
* @param bool|false $initChildSequence if true force child template
|
* @param bool|false $initChildSequence if true force child template
|
||||||
*/
|
*/
|
||||||
static function postCompile(Smarty_Internal_TemplateCompilerBase $compiler, $initChildSequence = false)
|
public static function postCompile(Smarty_Internal_TemplateCompilerBase $compiler, $initChildSequence = false)
|
||||||
{
|
{
|
||||||
$compiler->prefixCompiledCode .= "<?php \$_smarty_tpl->_loadInheritance();\n\$_smarty_tpl->inheritance->init(\$_smarty_tpl, " .
|
$compiler->prefixCompiledCode .= "<?php \$_smarty_tpl->_loadInheritance();\n\$_smarty_tpl->inheritance->init(\$_smarty_tpl, " .
|
||||||
var_export($initChildSequence, true) . ");\n?>\n";
|
var_export($initChildSequence, true) . ");\n?>\n";
|
||||||
@@ -36,15 +36,14 @@ class Smarty_Internal_Compile_Shared_Inheritance extends Smarty_Internal_Compile
|
|||||||
*/
|
*/
|
||||||
public function registerInit(Smarty_Internal_TemplateCompilerBase $compiler, $initChildSequence = false)
|
public function registerInit(Smarty_Internal_TemplateCompilerBase $compiler, $initChildSequence = false)
|
||||||
{
|
{
|
||||||
if ($initChildSequence || !isset($compiler->_cache['inheritanceInit'])) {
|
if ($initChildSequence || !isset($compiler->_cache[ 'inheritanceInit' ])) {
|
||||||
$compiler->registerPostCompileCallback(
|
$compiler->registerPostCompileCallback(
|
||||||
array('Smarty_Internal_Compile_Shared_Inheritance', 'postCompile'),
|
array('Smarty_Internal_Compile_Shared_Inheritance', 'postCompile'),
|
||||||
array($initChildSequence),
|
array($initChildSequence),
|
||||||
'inheritanceInit',
|
'inheritanceInit',
|
||||||
$initChildSequence
|
$initChildSequence
|
||||||
);
|
);
|
||||||
|
$compiler->_cache[ 'inheritanceInit' ] = true;
|
||||||
$compiler->_cache['inheritanceInit'] = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -28,15 +28,13 @@ class Smarty_Internal_Compile_While extends Smarty_Internal_CompileBase
|
|||||||
*/
|
*/
|
||||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
|
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
|
||||||
{
|
{
|
||||||
$compiler->loopNesting ++;
|
$compiler->loopNesting++;
|
||||||
// check and get attributes
|
// check and get attributes
|
||||||
$_attr = $this->getAttributes($compiler, $args);
|
$_attr = $this->getAttributes($compiler, $args);
|
||||||
$this->openTag($compiler, 'while', $compiler->nocache);
|
$this->openTag($compiler, 'while', $compiler->nocache);
|
||||||
|
|
||||||
if (!array_key_exists('if condition', $parameter)) {
|
if (!array_key_exists('if condition', $parameter)) {
|
||||||
$compiler->trigger_template_error('missing while condition', null, true);
|
$compiler->trigger_template_error('missing while condition', null, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// maybe nocache because of nocache variables
|
// maybe nocache because of nocache variables
|
||||||
$compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
|
$compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
|
||||||
if (is_array($parameter[ 'if condition' ])) {
|
if (is_array($parameter[ 'if condition' ])) {
|
||||||
@@ -57,7 +55,8 @@ class Smarty_Internal_Compile_While extends Smarty_Internal_CompileBase
|
|||||||
$assignAttr[][ 'var' ] = $parameter[ 'if condition' ][ 'var' ][ 'var' ];
|
$assignAttr[][ 'var' ] = $parameter[ 'if condition' ][ 'var' ][ 'var' ];
|
||||||
$_output = "<?php while ({$prefixVar} = {$parameter[ 'if condition' ][ 'value' ]}) {?>";
|
$_output = "<?php while ({$prefixVar} = {$parameter[ 'if condition' ][ 'value' ]}) {?>";
|
||||||
$_output .= $assignCompiler->compile(
|
$_output .= $assignCompiler->compile(
|
||||||
$assignAttr, $compiler,
|
$assignAttr,
|
||||||
|
$compiler,
|
||||||
array('smarty_internal_index' => $parameter[ 'if condition' ][ 'var' ][ 'smarty_internal_index' ])
|
array('smarty_internal_index' => $parameter[ 'if condition' ][ 'var' ][ 'smarty_internal_index' ])
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
@@ -65,7 +64,6 @@ class Smarty_Internal_Compile_While extends Smarty_Internal_CompileBase
|
|||||||
$_output = "<?php while ({$prefixVar} = {$parameter[ 'if condition' ][ 'value' ]}) {?>";
|
$_output = "<?php while ({$prefixVar} = {$parameter[ 'if condition' ][ 'value' ]}) {?>";
|
||||||
$_output .= $assignCompiler->compile($assignAttr, $compiler, array());
|
$_output .= $assignCompiler->compile($assignAttr, $compiler, array());
|
||||||
}
|
}
|
||||||
|
|
||||||
return $_output;
|
return $_output;
|
||||||
} else {
|
} else {
|
||||||
return "<?php\n while ({$parameter['if condition']}) {?>";
|
return "<?php\n while ({$parameter['if condition']}) {?>";
|
||||||
@@ -91,7 +89,7 @@ class Smarty_Internal_Compile_Whileclose extends Smarty_Internal_CompileBase
|
|||||||
*/
|
*/
|
||||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
|
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
|
||||||
{
|
{
|
||||||
$compiler->loopNesting --;
|
$compiler->loopNesting--;
|
||||||
// must endblock be nocache?
|
// must endblock be nocache?
|
||||||
if ($compiler->nocache) {
|
if ($compiler->nocache) {
|
||||||
$compiler->tag_nocache = true;
|
$compiler->tag_nocache = true;
|
||||||
|
@@ -105,7 +105,9 @@ abstract class Smarty_Internal_CompileBase
|
|||||||
} else {
|
} else {
|
||||||
$compiler->trigger_template_error(
|
$compiler->trigger_template_error(
|
||||||
"illegal value '" . var_export($v, true) .
|
"illegal value '" . var_export($v, true) .
|
||||||
"' for option flag '{$k}'", null, true
|
"' for option flag '{$k}'",
|
||||||
|
null,
|
||||||
|
true
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -128,9 +130,11 @@ abstract class Smarty_Internal_CompileBase
|
|||||||
$this->mapCache[ 'all' ] =
|
$this->mapCache[ 'all' ] =
|
||||||
array_fill_keys(
|
array_fill_keys(
|
||||||
array_merge(
|
array_merge(
|
||||||
$this->required_attributes, $this->optional_attributes,
|
$this->required_attributes,
|
||||||
|
$this->optional_attributes,
|
||||||
$this->option_flags
|
$this->option_flags
|
||||||
), true
|
),
|
||||||
|
true
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
foreach ($_indexed_attr as $key => $dummy) {
|
foreach ($_indexed_attr as $key => $dummy) {
|
||||||
@@ -179,7 +183,7 @@ abstract class Smarty_Internal_CompileBase
|
|||||||
// get stacked info
|
// get stacked info
|
||||||
list($_openTag, $_data) = array_pop($compiler->_tag_stack);
|
list($_openTag, $_data) = array_pop($compiler->_tag_stack);
|
||||||
// open tag must match with the expected ones
|
// open tag must match with the expected ones
|
||||||
if (in_array($_openTag, (array) $expectedTag)) {
|
if (in_array($_openTag, (array)$expectedTag)) {
|
||||||
if (is_null($_data)) {
|
if (is_null($_data)) {
|
||||||
// return opening tag
|
// return opening tag
|
||||||
return $_openTag;
|
return $_openTag;
|
||||||
@@ -190,12 +194,10 @@ abstract class Smarty_Internal_CompileBase
|
|||||||
}
|
}
|
||||||
// wrong nesting of tags
|
// wrong nesting of tags
|
||||||
$compiler->trigger_template_error("unclosed '{$compiler->smarty->left_delimiter}{$_openTag}{$compiler->smarty->right_delimiter}' tag");
|
$compiler->trigger_template_error("unclosed '{$compiler->smarty->left_delimiter}{$_openTag}{$compiler->smarty->right_delimiter}' tag");
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// wrong nesting of tags
|
// wrong nesting of tags
|
||||||
$compiler->trigger_template_error('unexpected closing tag', null, true);
|
$compiler->trigger_template_error('unexpected closing tag', null, true);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -103,9 +103,11 @@ class Smarty_Internal_Config_File_Compiler
|
|||||||
{
|
{
|
||||||
$this->template = $template;
|
$this->template = $template;
|
||||||
$this->template->compiled->file_dependency[ $this->template->source->uid ] =
|
$this->template->compiled->file_dependency[ $this->template->source->uid ] =
|
||||||
array($this->template->source->filepath,
|
array(
|
||||||
$this->template->source->getTimeStamp(),
|
$this->template->source->filepath,
|
||||||
$this->template->source->type);
|
$this->template->source->getTimeStamp(),
|
||||||
|
$this->template->source->type
|
||||||
|
);
|
||||||
if ($this->smarty->debugging) {
|
if ($this->smarty->debugging) {
|
||||||
if (!isset($this->smarty->_debug)) {
|
if (!isset($this->smarty->_debug)) {
|
||||||
$this->smarty->_debug = new Smarty_Internal_Debug();
|
$this->smarty->_debug = new Smarty_Internal_Debug();
|
||||||
@@ -116,17 +118,20 @@ class Smarty_Internal_Config_File_Compiler
|
|||||||
/* @var Smarty_Internal_ConfigFileLexer $this ->lex */
|
/* @var Smarty_Internal_ConfigFileLexer $this ->lex */
|
||||||
$this->lex = new $this->lexer_class(
|
$this->lex = new $this->lexer_class(
|
||||||
str_replace(
|
str_replace(
|
||||||
array("\r\n",
|
array(
|
||||||
"\r"), "\n", $template->source->getContent()
|
"\r\n",
|
||||||
|
"\r"
|
||||||
|
),
|
||||||
|
"\n",
|
||||||
|
$template->source->getContent()
|
||||||
) . "\n",
|
) . "\n",
|
||||||
$this
|
$this
|
||||||
);
|
);
|
||||||
/* @var Smarty_Internal_ConfigFileParser $this ->parser */
|
/* @var Smarty_Internal_ConfigFileParser $this ->parser */
|
||||||
$this->parser = new $this->parser_class($this->lex, $this);
|
$this->parser = new $this->parser_class($this->lex, $this);
|
||||||
|
|
||||||
if (function_exists('mb_internal_encoding')
|
if (function_exists('mb_internal_encoding')
|
||||||
&& function_exists('ini_get')
|
&& function_exists('ini_get')
|
||||||
&& ((int) ini_get('mbstring.func_overload')) & 2
|
&& ((int)ini_get('mbstring.func_overload')) & 2
|
||||||
) {
|
) {
|
||||||
$mbEncoding = mb_internal_encoding();
|
$mbEncoding = mb_internal_encoding();
|
||||||
mb_internal_encoding('ASCII');
|
mb_internal_encoding('ASCII');
|
||||||
@@ -145,7 +150,6 @@ class Smarty_Internal_Config_File_Compiler
|
|||||||
}
|
}
|
||||||
// finish parsing process
|
// finish parsing process
|
||||||
$this->parser->doParse(0, 0);
|
$this->parser->doParse(0, 0);
|
||||||
|
|
||||||
if ($mbEncoding) {
|
if ($mbEncoding) {
|
||||||
mb_internal_encoding($mbEncoding);
|
mb_internal_encoding($mbEncoding);
|
||||||
}
|
}
|
||||||
@@ -157,7 +161,6 @@ class Smarty_Internal_Config_File_Compiler
|
|||||||
"<?php /* Smarty version " . Smarty::SMARTY_VERSION . ", created on " . strftime("%Y-%m-%d %H:%M:%S") .
|
"<?php /* Smarty version " . Smarty::SMARTY_VERSION . ", created on " . strftime("%Y-%m-%d %H:%M:%S") .
|
||||||
"\n";
|
"\n";
|
||||||
$template_header .= " compiled from '{$this->template->source->filepath}' */ ?>\n";
|
$template_header .= " compiled from '{$this->template->source->filepath}' */ ?>\n";
|
||||||
|
|
||||||
$code = '<?php $_smarty_tpl->smarty->ext->configLoad->_loadConfigVars($_smarty_tpl, ' .
|
$code = '<?php $_smarty_tpl->smarty->ext->configLoad->_loadConfigVars($_smarty_tpl, ' .
|
||||||
var_export($this->config_data, true) . '); ?>';
|
var_export($this->config_data, true) . '); ?>';
|
||||||
return $template_header . $this->template->smarty->ext->_codeFrame->create($this->template, $code);
|
return $template_header . $this->template->smarty->ext->_codeFrame->create($this->template, $code);
|
||||||
|
@@ -189,27 +189,43 @@ class Smarty_Internal_Configfilelexer
|
|||||||
public function yypushstate($state)
|
public function yypushstate($state)
|
||||||
{
|
{
|
||||||
if ($this->yyTraceFILE) {
|
if ($this->yyTraceFILE) {
|
||||||
fprintf($this->yyTraceFILE, "%sState push %s\n", $this->yyTracePrompt,
|
fprintf(
|
||||||
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] : $this->_yy_state);
|
$this->yyTraceFILE,
|
||||||
|
"%sState push %s\n",
|
||||||
|
$this->yyTracePrompt,
|
||||||
|
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] : $this->_yy_state
|
||||||
|
);
|
||||||
}
|
}
|
||||||
array_push($this->_yy_stack, $this->_yy_state);
|
array_push($this->_yy_stack, $this->_yy_state);
|
||||||
$this->_yy_state = $state;
|
$this->_yy_state = $state;
|
||||||
if ($this->yyTraceFILE) {
|
if ($this->yyTraceFILE) {
|
||||||
fprintf($this->yyTraceFILE, "%snew State %s\n", $this->yyTracePrompt,
|
fprintf(
|
||||||
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] : $this->_yy_state);
|
$this->yyTraceFILE,
|
||||||
|
"%snew State %s\n",
|
||||||
|
$this->yyTracePrompt,
|
||||||
|
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] : $this->_yy_state
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function yypopstate()
|
public function yypopstate()
|
||||||
{
|
{
|
||||||
if ($this->yyTraceFILE) {
|
if ($this->yyTraceFILE) {
|
||||||
fprintf($this->yyTraceFILE, "%sState pop %s\n", $this->yyTracePrompt,
|
fprintf(
|
||||||
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] : $this->_yy_state);
|
$this->yyTraceFILE,
|
||||||
|
"%sState pop %s\n",
|
||||||
|
$this->yyTracePrompt,
|
||||||
|
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] : $this->_yy_state
|
||||||
|
);
|
||||||
}
|
}
|
||||||
$this->_yy_state = array_pop($this->_yy_stack);
|
$this->_yy_state = array_pop($this->_yy_stack);
|
||||||
if ($this->yyTraceFILE) {
|
if ($this->yyTraceFILE) {
|
||||||
fprintf($this->yyTraceFILE, "%snew State %s\n", $this->yyTracePrompt,
|
fprintf(
|
||||||
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] : $this->_yy_state);
|
$this->yyTraceFILE,
|
||||||
|
"%snew State %s\n",
|
||||||
|
$this->yyTracePrompt,
|
||||||
|
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] : $this->_yy_state
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -217,8 +233,12 @@ class Smarty_Internal_Configfilelexer
|
|||||||
{
|
{
|
||||||
$this->_yy_state = $state;
|
$this->_yy_state = $state;
|
||||||
if ($this->yyTraceFILE) {
|
if ($this->yyTraceFILE) {
|
||||||
fprintf($this->yyTraceFILE, "%sState set %s\n", $this->yyTracePrompt,
|
fprintf(
|
||||||
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] : $this->_yy_state);
|
$this->yyTraceFILE,
|
||||||
|
"%sState set %s\n",
|
||||||
|
$this->yyTracePrompt,
|
||||||
|
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] : $this->_yy_state
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -243,8 +263,11 @@ class Smarty_Internal_Configfilelexer
|
|||||||
}
|
}
|
||||||
if (empty($yymatches)) {
|
if (empty($yymatches)) {
|
||||||
throw new Exception('Error: lexing failed because a rule matched' .
|
throw new Exception('Error: lexing failed because a rule matched' .
|
||||||
' an empty string. Input "' . substr($this->data,
|
' an empty string. Input "' . substr(
|
||||||
$this->counter, 5) . '... state START');
|
$this->data,
|
||||||
|
$this->counter,
|
||||||
|
5
|
||||||
|
) . '... state START');
|
||||||
}
|
}
|
||||||
next($yymatches); // skip global match
|
next($yymatches); // skip global match
|
||||||
$this->token = key($yymatches); // token number
|
$this->token = key($yymatches); // token number
|
||||||
@@ -340,8 +363,11 @@ class Smarty_Internal_Configfilelexer
|
|||||||
}
|
}
|
||||||
if (empty($yymatches)) {
|
if (empty($yymatches)) {
|
||||||
throw new Exception('Error: lexing failed because a rule matched' .
|
throw new Exception('Error: lexing failed because a rule matched' .
|
||||||
' an empty string. Input "' . substr($this->data,
|
' an empty string. Input "' . substr(
|
||||||
$this->counter, 5) . '... state VALUE');
|
$this->data,
|
||||||
|
$this->counter,
|
||||||
|
5
|
||||||
|
) . '... state VALUE');
|
||||||
}
|
}
|
||||||
next($yymatches); // skip global match
|
next($yymatches); // skip global match
|
||||||
$this->token = key($yymatches); // token number
|
$this->token = key($yymatches); // token number
|
||||||
@@ -454,8 +480,11 @@ class Smarty_Internal_Configfilelexer
|
|||||||
}
|
}
|
||||||
if (empty($yymatches)) {
|
if (empty($yymatches)) {
|
||||||
throw new Exception('Error: lexing failed because a rule matched' .
|
throw new Exception('Error: lexing failed because a rule matched' .
|
||||||
' an empty string. Input "' . substr($this->data,
|
' an empty string. Input "' . substr(
|
||||||
$this->counter, 5) . '... state NAKED_STRING_VALUE');
|
$this->data,
|
||||||
|
$this->counter,
|
||||||
|
5
|
||||||
|
) . '... state NAKED_STRING_VALUE');
|
||||||
}
|
}
|
||||||
next($yymatches); // skip global match
|
next($yymatches); // skip global match
|
||||||
$this->token = key($yymatches); // token number
|
$this->token = key($yymatches); // token number
|
||||||
@@ -513,8 +542,11 @@ class Smarty_Internal_Configfilelexer
|
|||||||
}
|
}
|
||||||
if (empty($yymatches)) {
|
if (empty($yymatches)) {
|
||||||
throw new Exception('Error: lexing failed because a rule matched' .
|
throw new Exception('Error: lexing failed because a rule matched' .
|
||||||
' an empty string. Input "' . substr($this->data,
|
' an empty string. Input "' . substr(
|
||||||
$this->counter, 5) . '... state COMMENT');
|
$this->data,
|
||||||
|
$this->counter,
|
||||||
|
5
|
||||||
|
) . '... state COMMENT');
|
||||||
}
|
}
|
||||||
next($yymatches); // skip global match
|
next($yymatches); // skip global match
|
||||||
$this->token = key($yymatches); // token number
|
$this->token = key($yymatches); // token number
|
||||||
@@ -582,8 +614,11 @@ class Smarty_Internal_Configfilelexer
|
|||||||
}
|
}
|
||||||
if (empty($yymatches)) {
|
if (empty($yymatches)) {
|
||||||
throw new Exception('Error: lexing failed because a rule matched' .
|
throw new Exception('Error: lexing failed because a rule matched' .
|
||||||
' an empty string. Input "' . substr($this->data,
|
' an empty string. Input "' . substr(
|
||||||
$this->counter, 5) . '... state SECTION');
|
$this->data,
|
||||||
|
$this->counter,
|
||||||
|
5
|
||||||
|
) . '... state SECTION');
|
||||||
}
|
}
|
||||||
next($yymatches); // skip global match
|
next($yymatches); // skip global match
|
||||||
$this->token = key($yymatches); // token number
|
$this->token = key($yymatches); // token number
|
||||||
@@ -646,8 +681,11 @@ class Smarty_Internal_Configfilelexer
|
|||||||
}
|
}
|
||||||
if (empty($yymatches)) {
|
if (empty($yymatches)) {
|
||||||
throw new Exception('Error: lexing failed because a rule matched' .
|
throw new Exception('Error: lexing failed because a rule matched' .
|
||||||
' an empty string. Input "' . substr($this->data,
|
' an empty string. Input "' . substr(
|
||||||
$this->counter, 5) . '... state TRIPPLE');
|
$this->data,
|
||||||
|
$this->counter,
|
||||||
|
5
|
||||||
|
) . '... state TRIPPLE');
|
||||||
}
|
}
|
||||||
next($yymatches); // skip global match
|
next($yymatches); // skip global match
|
||||||
$this->token = key($yymatches); // token number
|
$this->token = key($yymatches); // token number
|
||||||
|
@@ -404,9 +404,11 @@ class Smarty_Internal_Configfileparser
|
|||||||
}
|
}
|
||||||
$yytos = array_pop($this->yystack);
|
$yytos = array_pop($this->yystack);
|
||||||
if ($this->yyTraceFILE && $this->yyidx >= 0) {
|
if ($this->yyTraceFILE && $this->yyidx >= 0) {
|
||||||
fwrite($this->yyTraceFILE,
|
fwrite(
|
||||||
|
$this->yyTraceFILE,
|
||||||
$this->yyTracePrompt . 'Popping ' . $this->yyTokenName[ $yytos->major ] .
|
$this->yyTracePrompt . 'Popping ' . $this->yyTokenName[ $yytos->major ] .
|
||||||
"\n");
|
"\n"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
$yymajor = $yytos->major;
|
$yymajor = $yytos->major;
|
||||||
self::yy_destructor($yymajor, $yytos->minor);
|
self::yy_destructor($yymajor, $yytos->minor);
|
||||||
@@ -416,7 +418,7 @@ class Smarty_Internal_Configfileparser
|
|||||||
|
|
||||||
public function __destruct()
|
public function __destruct()
|
||||||
{
|
{
|
||||||
while ($this->yystack !== Array()) {
|
while ($this->yystack !== array()) {
|
||||||
$this->yy_pop_parser_stack();
|
$this->yy_pop_parser_stack();
|
||||||
}
|
}
|
||||||
if (is_resource($this->yyTraceFILE)) {
|
if (is_resource($this->yyTraceFILE)) {
|
||||||
@@ -458,7 +460,8 @@ class Smarty_Internal_Configfileparser
|
|||||||
$this->yyidx -= self::$yyRuleInfo[ $yyruleno ][ 1 ];
|
$this->yyidx -= self::$yyRuleInfo[ $yyruleno ][ 1 ];
|
||||||
$nextstate = $this->yy_find_reduce_action(
|
$nextstate = $this->yy_find_reduce_action(
|
||||||
$this->yystack[ $this->yyidx ]->stateno,
|
$this->yystack[ $this->yyidx ]->stateno,
|
||||||
self::$yyRuleInfo[ $yyruleno ][ 0 ]);
|
self::$yyRuleInfo[ $yyruleno ][ 0 ]
|
||||||
|
);
|
||||||
if (isset(self::$yyExpectedTokens[ $nextstate ])) {
|
if (isset(self::$yyExpectedTokens[ $nextstate ])) {
|
||||||
$expected = array_merge($expected, self::$yyExpectedTokens[ $nextstate ]);
|
$expected = array_merge($expected, self::$yyExpectedTokens[ $nextstate ]);
|
||||||
if (isset($res4[ $nextstate ][ $token ])) {
|
if (isset($res4[ $nextstate ][ $token ])) {
|
||||||
@@ -544,7 +547,8 @@ class Smarty_Internal_Configfileparser
|
|||||||
$this->yyidx -= self::$yyRuleInfo[ $yyruleno ][ 1 ];
|
$this->yyidx -= self::$yyRuleInfo[ $yyruleno ][ 1 ];
|
||||||
$nextstate = $this->yy_find_reduce_action(
|
$nextstate = $this->yy_find_reduce_action(
|
||||||
$this->yystack[ $this->yyidx ]->stateno,
|
$this->yystack[ $this->yyidx ]->stateno,
|
||||||
self::$yyRuleInfo[ $yyruleno ][ 0 ]);
|
self::$yyRuleInfo[ $yyruleno ][ 0 ]
|
||||||
|
);
|
||||||
if (isset($res2[ $nextstate ][ $token ])) {
|
if (isset($res2[ $nextstate ][ $token ])) {
|
||||||
if ($res2[ $nextstate ][ $token ]) {
|
if ($res2[ $nextstate ][ $token ]) {
|
||||||
$this->yyidx = $yyidx;
|
$this->yyidx = $yyidx;
|
||||||
@@ -673,12 +677,19 @@ class Smarty_Internal_Configfileparser
|
|||||||
$yytos->minor = $yypMinor;
|
$yytos->minor = $yypMinor;
|
||||||
$this->yystack[] = $yytos;
|
$this->yystack[] = $yytos;
|
||||||
if ($this->yyTraceFILE && $this->yyidx > 0) {
|
if ($this->yyTraceFILE && $this->yyidx > 0) {
|
||||||
fprintf($this->yyTraceFILE, "%sShift %d\n", $this->yyTracePrompt,
|
fprintf(
|
||||||
$yyNewState);
|
$this->yyTraceFILE,
|
||||||
|
"%sShift %d\n",
|
||||||
|
$this->yyTracePrompt,
|
||||||
|
$yyNewState
|
||||||
|
);
|
||||||
fprintf($this->yyTraceFILE, "%sStack:", $this->yyTracePrompt);
|
fprintf($this->yyTraceFILE, "%sStack:", $this->yyTracePrompt);
|
||||||
for ($i = 1; $i <= $this->yyidx; $i++) {
|
for ($i = 1; $i <= $this->yyidx; $i++) {
|
||||||
fprintf($this->yyTraceFILE, " %s",
|
fprintf(
|
||||||
$this->yyTokenName[ $this->yystack[ $i ]->major ]);
|
$this->yyTraceFILE,
|
||||||
|
" %s",
|
||||||
|
$this->yyTokenName[ $this->yystack[ $i ]->major ]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
fwrite($this->yyTraceFILE, "\n");
|
fwrite($this->yyTraceFILE, "\n");
|
||||||
}
|
}
|
||||||
@@ -705,8 +716,10 @@ class Smarty_Internal_Configfileparser
|
|||||||
public function yy_r5()
|
public function yy_r5()
|
||||||
{
|
{
|
||||||
if ($this->configReadHidden) {
|
if ($this->configReadHidden) {
|
||||||
$this->add_section_vars($this->yystack[ $this->yyidx + -3 ]->minor,
|
$this->add_section_vars(
|
||||||
$this->yystack[ $this->yyidx + 0 ]->minor);
|
$this->yystack[ $this->yyidx + -3 ]->minor,
|
||||||
|
$this->yystack[ $this->yyidx + 0 ]->minor
|
||||||
|
);
|
||||||
}
|
}
|
||||||
$this->_retvalue = null;
|
$this->_retvalue = null;
|
||||||
}
|
}
|
||||||
@@ -793,9 +806,13 @@ class Smarty_Internal_Configfileparser
|
|||||||
{
|
{
|
||||||
if ($this->yyTraceFILE && $yyruleno >= 0
|
if ($this->yyTraceFILE && $yyruleno >= 0
|
||||||
&& $yyruleno < count(self::$yyRuleName)) {
|
&& $yyruleno < count(self::$yyRuleName)) {
|
||||||
fprintf($this->yyTraceFILE, "%sReduce (%d) [%s].\n",
|
fprintf(
|
||||||
$this->yyTracePrompt, $yyruleno,
|
$this->yyTraceFILE,
|
||||||
self::$yyRuleName[ $yyruleno ]);
|
"%sReduce (%d) [%s].\n",
|
||||||
|
$this->yyTracePrompt,
|
||||||
|
$yyruleno,
|
||||||
|
self::$yyRuleName[ $yyruleno ]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
$this->_retvalue = $yy_lefthand_side = null;
|
$this->_retvalue = $yy_lefthand_side = null;
|
||||||
if (isset(self::$yyReduceMap[ $yyruleno ])) {
|
if (isset(self::$yyReduceMap[ $yyruleno ])) {
|
||||||
@@ -876,8 +893,12 @@ class Smarty_Internal_Configfileparser
|
|||||||
}
|
}
|
||||||
$yyendofinput = ($yymajor == 0);
|
$yyendofinput = ($yymajor == 0);
|
||||||
if ($this->yyTraceFILE) {
|
if ($this->yyTraceFILE) {
|
||||||
fprintf($this->yyTraceFILE, "%sInput %s\n",
|
fprintf(
|
||||||
$this->yyTracePrompt, $this->yyTokenName[ $yymajor ]);
|
$this->yyTraceFILE,
|
||||||
|
"%sInput %s\n",
|
||||||
|
$this->yyTracePrompt,
|
||||||
|
$this->yyTokenName[ $yymajor ]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
do {
|
do {
|
||||||
$yyact = $this->yy_find_shift_action($yymajor);
|
$yyact = $this->yy_find_shift_action($yymajor);
|
||||||
@@ -898,8 +919,11 @@ class Smarty_Internal_Configfileparser
|
|||||||
$this->yy_reduce($yyact - self::YYNSTATE);
|
$this->yy_reduce($yyact - self::YYNSTATE);
|
||||||
} elseif ($yyact === self::YY_ERROR_ACTION) {
|
} elseif ($yyact === self::YY_ERROR_ACTION) {
|
||||||
if ($this->yyTraceFILE) {
|
if ($this->yyTraceFILE) {
|
||||||
fprintf($this->yyTraceFILE, "%sSyntax Error!\n",
|
fprintf(
|
||||||
$this->yyTracePrompt);
|
$this->yyTraceFILE,
|
||||||
|
"%sSyntax Error!\n",
|
||||||
|
$this->yyTracePrompt
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (self::YYERRORSYMBOL) {
|
if (self::YYERRORSYMBOL) {
|
||||||
if ($this->yyerrcnt < 0) {
|
if ($this->yyerrcnt < 0) {
|
||||||
@@ -908,8 +932,12 @@ class Smarty_Internal_Configfileparser
|
|||||||
$yymx = $this->yystack[ $this->yyidx ]->major;
|
$yymx = $this->yystack[ $this->yyidx ]->major;
|
||||||
if ($yymx === self::YYERRORSYMBOL || $yyerrorhit) {
|
if ($yymx === self::YYERRORSYMBOL || $yyerrorhit) {
|
||||||
if ($this->yyTraceFILE) {
|
if ($this->yyTraceFILE) {
|
||||||
fprintf($this->yyTraceFILE, "%sDiscard input token %s\n",
|
fprintf(
|
||||||
$this->yyTracePrompt, $this->yyTokenName[ $yymajor ]);
|
$this->yyTraceFILE,
|
||||||
|
"%sDiscard input token %s\n",
|
||||||
|
$this->yyTracePrompt,
|
||||||
|
$this->yyTokenName[ $yymajor ]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
$this->yy_destructor($yymajor, $yytokenvalue);
|
$this->yy_destructor($yymajor, $yytokenvalue);
|
||||||
$yymajor = self::YYNOCODE;
|
$yymajor = self::YYNOCODE;
|
||||||
@@ -1016,4 +1044,3 @@ class Smarty_Internal_Configfileparser
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user