mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 18:34:27 +02:00
- reformat all code for unique style
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
===== 3.1.30-dev ===== (xx.xx.xx)
|
||||
09.02.2016
|
||||
- move some code from parser into compiler
|
||||
- reformat all code for unique style
|
||||
|
||||
05.02.2016
|
||||
- improvement internal compiler changes
|
||||
|
@@ -17,8 +17,8 @@ $smarty->cache_lifetime = 120;
|
||||
$smarty->assign("Name", "Fred Irving Johnathan Bradley Peppergill", true);
|
||||
$smarty->assign("FirstName", array("John", "Mary", "James", "Henry"));
|
||||
$smarty->assign("LastName", array("Doe", "Smith", "Johnson", "Case"));
|
||||
$smarty->assign("Class", array(array("A", "B", "C", "D"), array("E", "F", "G", "H"),
|
||||
array("I", "J", "K", "L"), array("M", "N", "O", "P")));
|
||||
$smarty->assign("Class", array(array("A", "B", "C", "D"), array("E", "F", "G", "H"), array("I", "J", "K", "L"),
|
||||
array("M", "N", "O", "P")));
|
||||
|
||||
$smarty->assign("contacts", array(array("phone" => "1", "fax" => "2", "cell" => "3"),
|
||||
array("phone" => "555-4444", "fax" => "555-3333", "cell" => "760-1234")));
|
||||
|
@@ -32,7 +32,7 @@ class Smarty_CacheResource_Apc extends Smarty_CacheResource_KeyValueStore
|
||||
$_res = array();
|
||||
$res = apc_fetch($keys);
|
||||
foreach ($res as $k => $v) {
|
||||
$_res[$k] = $v;
|
||||
$_res[ $k ] = $v;
|
||||
}
|
||||
|
||||
return $_res;
|
||||
|
@@ -43,12 +43,12 @@ class Smarty_CacheResource_Memcache extends Smarty_CacheResource_KeyValueStore
|
||||
foreach ($keys as $k) {
|
||||
$_k = sha1($k);
|
||||
$_keys[] = $_k;
|
||||
$lookup[$_k] = $k;
|
||||
$lookup[ $_k ] = $k;
|
||||
}
|
||||
$_res = array();
|
||||
$res = $this->memcache->get($_keys);
|
||||
foreach ($res as $k => $v) {
|
||||
$_res[$lookup[$k]] = $v;
|
||||
$_res[ $lookup[ $k ] ] = $v;
|
||||
}
|
||||
|
||||
return $_res;
|
||||
|
@@ -26,8 +26,11 @@ class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom
|
||||
{
|
||||
// PDO instance
|
||||
protected $db;
|
||||
|
||||
protected $fetch;
|
||||
|
||||
protected $fetchTimestamp;
|
||||
|
||||
protected $save;
|
||||
|
||||
public function __construct()
|
||||
@@ -62,8 +65,8 @@ class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom
|
||||
$row = $this->fetch->fetch();
|
||||
$this->fetch->closeCursor();
|
||||
if ($row) {
|
||||
$content = $row['content'];
|
||||
$mtime = strtotime($row['modified']);
|
||||
$content = $row[ 'content' ];
|
||||
$mtime = strtotime($row[ 'modified' ]);
|
||||
} else {
|
||||
$content = null;
|
||||
$mtime = null;
|
||||
@@ -105,13 +108,8 @@ class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom
|
||||
*/
|
||||
protected function save($id, $name, $cache_id, $compile_id, $exp_time, $content)
|
||||
{
|
||||
$this->save->execute(array(
|
||||
'id' => $id,
|
||||
'name' => $name,
|
||||
'cache_id' => $cache_id,
|
||||
'compile_id' => $compile_id,
|
||||
'content' => $content,
|
||||
));
|
||||
$this->save->execute(array('id' => $id, 'name' => $name, 'cache_id' => $cache_id, 'compile_id' => $compile_id,
|
||||
'content' => $content,));
|
||||
|
||||
return !!$this->save->rowCount();
|
||||
}
|
||||
@@ -151,8 +149,8 @@ class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom
|
||||
}
|
||||
// equal test cache_id and match sub-groups
|
||||
if ($cache_id !== null) {
|
||||
$where[] = '(cache_id = ' . $this->db->quote($cache_id)
|
||||
. ' OR cache_id LIKE ' . $this->db->quote($cache_id . '|%') . ')';
|
||||
$where[] = '(cache_id = ' . $this->db->quote($cache_id) . ' OR cache_id LIKE ' .
|
||||
$this->db->quote($cache_id . '|%') . ')';
|
||||
}
|
||||
// run delete query
|
||||
$query = $this->db->query('DELETE FROM output_cache WHERE ' . join(' AND ', $where));
|
||||
|
@@ -57,6 +57,7 @@ class Smarty_CacheResource_Pdo extends Smarty_CacheResource_Custom
|
||||
AND id = :id
|
||||
AND cache_id = :cache_id
|
||||
AND compile_id = :compile_id');
|
||||
|
||||
protected $insertStatement = 'INSERT INTO %s
|
||||
|
||||
SET id = :id,
|
||||
@@ -76,9 +77,11 @@ class Smarty_CacheResource_Pdo extends Smarty_CacheResource_Custom
|
||||
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;
|
||||
@@ -137,13 +140,15 @@ class Smarty_CacheResource_Pdo extends Smarty_CacheResource_Custom
|
||||
{
|
||||
|
||||
if (!is_null($cache_id) && !is_null($compile_id)) {
|
||||
$query = $this->fetchStatements['withCacheIdAndCompileId'] AND $args = Array('id' => $id, 'cache_id' => $cache_id, 'compile_id' => $compile_id);
|
||||
$query = $this->fetchStatements[ 'withCacheIdAndCompileId' ] AND
|
||||
$args = Array('id' => $id, 'cache_id' => $cache_id, 'compile_id' => $compile_id);
|
||||
} elseif (is_null($cache_id) && !is_null($compile_id)) {
|
||||
$query = $this->fetchStatements['withCompileId'] AND $args = Array('id' => $id, 'compile_id' => $compile_id);
|
||||
$query = $this->fetchStatements[ 'withCompileId' ] AND
|
||||
$args = Array('id' => $id, 'compile_id' => $compile_id);
|
||||
} elseif (!is_null($cache_id) && is_null($compile_id)) {
|
||||
$query = $this->fetchStatements['withCacheId'] AND $args = Array('id' => $id, 'cache_id' => $cache_id);
|
||||
$query = $this->fetchStatements[ 'withCacheId' ] AND $args = Array('id' => $id, 'cache_id' => $cache_id);
|
||||
} else {
|
||||
$query = $this->fetchStatements['default'] AND $args = Array('id' => $id);
|
||||
$query = $this->fetchStatements[ 'default' ] AND $args = Array('id' => $id);
|
||||
}
|
||||
|
||||
$query = sprintf($query, $columns);
|
||||
@@ -174,13 +179,13 @@ class Smarty_CacheResource_Pdo extends Smarty_CacheResource_Custom
|
||||
{
|
||||
|
||||
$stmt = $this->getFetchStatement($this->fetchColumns, $id, $cache_id, $compile_id);
|
||||
$stmt ->execute();
|
||||
$stmt->execute();
|
||||
$row = $stmt->fetch();
|
||||
$stmt ->closeCursor();
|
||||
$stmt->closeCursor();
|
||||
|
||||
if ($row) {
|
||||
$content = $this->outputContent($row['content']);
|
||||
$mtime = strtotime($row['modified']);
|
||||
$content = $this->outputContent($row[ 'content' ]);
|
||||
$mtime = strtotime($row[ 'modified' ]);
|
||||
} else {
|
||||
$content = null;
|
||||
$mtime = null;
|
||||
@@ -226,13 +231,13 @@ class Smarty_CacheResource_Pdo extends Smarty_CacheResource_Custom
|
||||
|
||||
$stmt = $this->pdo->prepare($this->insertStatement);
|
||||
|
||||
$stmt ->bindValue('id', $id);
|
||||
$stmt ->bindValue('name', $name);
|
||||
$stmt ->bindValue('cache_id', $cache_id, (is_null($cache_id)) ? PDO::PARAM_NULL : PDO::PARAM_STR);
|
||||
$stmt ->bindValue('compile_id', $compile_id, (is_null($compile_id)) ? PDO::PARAM_NULL : PDO::PARAM_STR);
|
||||
$stmt ->bindValue('expire', (int) $exp_time, PDO::PARAM_INT);
|
||||
$stmt ->bindValue('content', $this->inputContent($content));
|
||||
$stmt ->execute();
|
||||
$stmt->bindValue('id', $id);
|
||||
$stmt->bindValue('name', $name);
|
||||
$stmt->bindValue('cache_id', $cache_id, (is_null($cache_id)) ? PDO::PARAM_NULL : PDO::PARAM_STR);
|
||||
$stmt->bindValue('compile_id', $compile_id, (is_null($compile_id)) ? PDO::PARAM_NULL : PDO::PARAM_STR);
|
||||
$stmt->bindValue('expire', (int) $exp_time, PDO::PARAM_INT);
|
||||
$stmt->bindValue('content', $this->inputContent($content));
|
||||
$stmt->execute();
|
||||
|
||||
return !!$stmt->rowCount();
|
||||
}
|
||||
@@ -289,8 +294,8 @@ class Smarty_CacheResource_Pdo extends Smarty_CacheResource_Custom
|
||||
}
|
||||
// equal test cache_id and match sub-groups
|
||||
if ($cache_id !== null) {
|
||||
$where[] = '(cache_id = ' . $this->pdo->quote($cache_id)
|
||||
. ' OR cache_id LIKE ' . $this->pdo->quote($cache_id . '|%') . ')';
|
||||
$where[] = '(cache_id = ' . $this->pdo->quote($cache_id) . ' OR cache_id LIKE ' .
|
||||
$this->pdo->quote($cache_id . '|%') . ')';
|
||||
}
|
||||
// equal test compile_id
|
||||
if ($compile_id !== null) {
|
||||
|
@@ -21,8 +21,10 @@ class Smarty_Resource_Mysql extends Smarty_Resource_Custom
|
||||
{
|
||||
// PDO instance
|
||||
protected $db;
|
||||
|
||||
// prepared fetch() statement
|
||||
protected $fetch;
|
||||
|
||||
// prepared fetchTimestamp() statement
|
||||
protected $mtime;
|
||||
|
||||
@@ -53,8 +55,8 @@ class Smarty_Resource_Mysql extends Smarty_Resource_Custom
|
||||
$row = $this->fetch->fetch();
|
||||
$this->fetch->closeCursor();
|
||||
if ($row) {
|
||||
$source = $row['source'];
|
||||
$mtime = strtotime($row['modified']);
|
||||
$source = $row[ 'source' ];
|
||||
$mtime = strtotime($row[ 'modified' ]);
|
||||
} else {
|
||||
$source = null;
|
||||
$mtime = null;
|
||||
|
@@ -23,6 +23,7 @@ class Smarty_Resource_Mysqls extends Smarty_Resource_Custom
|
||||
{
|
||||
// PDO instance
|
||||
protected $db;
|
||||
|
||||
// prepared fetch() statement
|
||||
protected $fetch;
|
||||
|
||||
@@ -52,8 +53,8 @@ class Smarty_Resource_Mysqls extends Smarty_Resource_Custom
|
||||
$row = $this->fetch->fetch();
|
||||
$this->fetch->closeCursor();
|
||||
if ($row) {
|
||||
$source = $row['source'];
|
||||
$mtime = strtotime($row['modified']);
|
||||
$source = $row[ 'source' ];
|
||||
$mtime = strtotime($row[ 'modified' ]);
|
||||
} else {
|
||||
$source = null;
|
||||
$mtime = null;
|
||||
|
@@ -57,7 +57,7 @@ class Smarty_Autoloader
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . SMARTY_SYSPLUGINS_DIR) !== false
|
||||
) {
|
||||
$registeredAutoLoadFunctions = spl_autoload_functions();
|
||||
if (!isset($registeredAutoLoadFunctions['spl_autoload'])) {
|
||||
if (!isset($registeredAutoLoadFunctions[ 'spl_autoload' ])) {
|
||||
spl_autoload_register();
|
||||
}
|
||||
} else {
|
||||
@@ -103,11 +103,11 @@ class Smarty_Autoloader
|
||||
}
|
||||
if (preg_match('/^(smarty_(((template_(source|config|cache|compiled|resource_base))|((cached|compiled)?resource)|(variable|security)))|(smarty(bc)?)$)/',
|
||||
$_class, $match)) {
|
||||
if (!empty($match[3])) {
|
||||
if (!empty($match[ 3 ])) {
|
||||
@include $file;
|
||||
return;
|
||||
} elseif (!empty($match[9]) && isset(self::$rootClasses[$_class])) {
|
||||
$file = self::$rootClasses[$_class];
|
||||
} elseif (!empty($match[ 9 ]) && isset(self::$rootClasses[ $_class ])) {
|
||||
$file = self::$rootClasses[ $_class ];
|
||||
require $file;
|
||||
return;
|
||||
}
|
||||
|
@@ -1144,12 +1144,13 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
if (strpos($path, $nds) !== false) {
|
||||
$path = str_replace($nds, DS, $path);
|
||||
}
|
||||
preg_match('%^(?<root>(?:[[:alpha:]]:[\\\\]|/|[\\\\]{2}[[:alpha:]]+|[[:print:]]{2,}:[/]{2}|[\\\\])?)(?<path>(?:[[:print:]]*))$%', $path, $parts);
|
||||
$path = $parts['path'];
|
||||
if ($parts['root'] == '\\') {
|
||||
$parts['root'] = substr(getcwd(), 0, 2) . $parts['root'];
|
||||
preg_match('%^(?<root>(?:[[:alpha:]]:[\\\\]|/|[\\\\]{2}[[:alpha:]]+|[[:print:]]{2,}:[/]{2}|[\\\\])?)(?<path>(?:[[:print:]]*))$%',
|
||||
$path, $parts);
|
||||
$path = $parts[ 'path' ];
|
||||
if ($parts[ 'root' ] == '\\') {
|
||||
$parts[ 'root' ] = substr(getcwd(), 0, 2) . $parts[ 'root' ];
|
||||
} else {
|
||||
if ($realpath !== null && !$parts['root']) {
|
||||
if ($realpath !== null && !$parts[ 'root' ]) {
|
||||
$path = getcwd() . DS . $path;
|
||||
}
|
||||
}
|
||||
@@ -1159,15 +1160,16 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
preg_replace('#([\\\\/][^\\\\/]+[\\\\/]([.]?[\\\\/])*[.][.][\\\\/]([.]?[\\\\/])*)+|([\\\\/]([.]?[\\\\/])+)#',
|
||||
DS, $path, - 1, $count);
|
||||
}
|
||||
return $parts['root'] . $path;
|
||||
return $parts[ 'root' ] . $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Empty template objects cache
|
||||
*/
|
||||
public function _clearTemplateCache() {
|
||||
$this->_cache['isCached'] = array();
|
||||
$this->_cache['tplObjects'] = array();
|
||||
public function _clearTemplateCache()
|
||||
{
|
||||
$this->_cache[ 'isCached' ] = array();
|
||||
$this->_cache[ 'tplObjects' ] = array();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -128,7 +128,8 @@ class SmartyBC extends Smarty
|
||||
* @throws SmartyException
|
||||
* @internal param array $block_functs list of methods that are block format
|
||||
*/
|
||||
public function register_object($object, $object_impl, $allowed = array(), $smarty_args = true, $block_methods = array())
|
||||
public function register_object($object, $object_impl, $allowed = array(), $smarty_args = true,
|
||||
$block_methods = array())
|
||||
{
|
||||
settype($allowed, 'array');
|
||||
settype($smarty_args, 'boolean');
|
||||
|
@@ -83,7 +83,9 @@ function smarty_block_textformat($params, $content, $template, &$repeat)
|
||||
continue;
|
||||
}
|
||||
// convert mult. spaces & special chars to single space
|
||||
$_paragraph = preg_replace(array('!\s+!' . Smarty::$_UTF8_MODIFIER, '!(^\s+)|(\s+$)!' . Smarty::$_UTF8_MODIFIER), array(' ', ''), $_paragraph);
|
||||
$_paragraph =
|
||||
preg_replace(array('!\s+!' . Smarty::$_UTF8_MODIFIER, '!(^\s+)|(\s+$)!' . Smarty::$_UTF8_MODIFIER),
|
||||
array(' ', ''), $_paragraph);
|
||||
// indent first line
|
||||
if ($indent_first > 0) {
|
||||
$_paragraph = str_repeat($indent_char, $indent_first) . $_paragraph;
|
||||
|
@@ -25,53 +25,48 @@ function smarty_function_counter($params, $template)
|
||||
{
|
||||
static $counters = array();
|
||||
|
||||
$name = (isset($params['name'])) ? $params['name'] : 'default';
|
||||
if (!isset($counters[$name])) {
|
||||
$counters[$name] = array(
|
||||
'start' => 1,
|
||||
'skip' => 1,
|
||||
'direction' => 'up',
|
||||
'count' => 1
|
||||
);
|
||||
$name = (isset($params[ 'name' ])) ? $params[ 'name' ] : 'default';
|
||||
if (!isset($counters[ $name ])) {
|
||||
$counters[ $name ] = array('start' => 1, 'skip' => 1, 'direction' => 'up', 'count' => 1);
|
||||
}
|
||||
$counter =& $counters[$name];
|
||||
$counter =& $counters[ $name ];
|
||||
|
||||
if (isset($params['start'])) {
|
||||
$counter['start'] = $counter['count'] = (int) $params['start'];
|
||||
if (isset($params[ 'start' ])) {
|
||||
$counter[ 'start' ] = $counter[ 'count' ] = (int) $params[ 'start' ];
|
||||
}
|
||||
|
||||
if (!empty($params['assign'])) {
|
||||
$counter['assign'] = $params['assign'];
|
||||
if (!empty($params[ 'assign' ])) {
|
||||
$counter[ 'assign' ] = $params[ 'assign' ];
|
||||
}
|
||||
|
||||
if (isset($counter['assign'])) {
|
||||
$template->assign($counter['assign'], $counter['count']);
|
||||
if (isset($counter[ 'assign' ])) {
|
||||
$template->assign($counter[ 'assign' ], $counter[ 'count' ]);
|
||||
}
|
||||
|
||||
if (isset($params['print'])) {
|
||||
$print = (bool) $params['print'];
|
||||
if (isset($params[ 'print' ])) {
|
||||
$print = (bool) $params[ 'print' ];
|
||||
} else {
|
||||
$print = empty($counter['assign']);
|
||||
$print = empty($counter[ 'assign' ]);
|
||||
}
|
||||
|
||||
if ($print) {
|
||||
$retval = $counter['count'];
|
||||
$retval = $counter[ 'count' ];
|
||||
} else {
|
||||
$retval = null;
|
||||
}
|
||||
|
||||
if (isset($params['skip'])) {
|
||||
$counter['skip'] = $params['skip'];
|
||||
if (isset($params[ 'skip' ])) {
|
||||
$counter[ 'skip' ] = $params[ 'skip' ];
|
||||
}
|
||||
|
||||
if (isset($params['direction'])) {
|
||||
$counter['direction'] = $params['direction'];
|
||||
if (isset($params[ 'direction' ])) {
|
||||
$counter[ 'direction' ] = $params[ 'direction' ];
|
||||
}
|
||||
|
||||
if ($counter['direction'] == "down") {
|
||||
$counter['count'] -= $counter['skip'];
|
||||
if ($counter[ 'direction' ] == "down") {
|
||||
$counter[ 'count' ] -= $counter[ 'skip' ];
|
||||
} else {
|
||||
$counter['count'] += $counter['skip'];
|
||||
$counter[ 'count' ] += $counter[ 'skip' ];
|
||||
}
|
||||
|
||||
return $retval;
|
||||
|
@@ -48,58 +48,56 @@ function smarty_function_cycle($params, $template)
|
||||
{
|
||||
static $cycle_vars;
|
||||
|
||||
$name = (empty($params['name'])) ? 'default' : $params['name'];
|
||||
$print = (isset($params['print'])) ? (bool) $params['print'] : true;
|
||||
$advance = (isset($params['advance'])) ? (bool) $params['advance'] : true;
|
||||
$reset = (isset($params['reset'])) ? (bool) $params['reset'] : false;
|
||||
$name = (empty($params[ 'name' ])) ? 'default' : $params[ 'name' ];
|
||||
$print = (isset($params[ 'print' ])) ? (bool) $params[ 'print' ] : true;
|
||||
$advance = (isset($params[ 'advance' ])) ? (bool) $params[ 'advance' ] : true;
|
||||
$reset = (isset($params[ 'reset' ])) ? (bool) $params[ 'reset' ] : false;
|
||||
|
||||
if (!isset($params['values'])) {
|
||||
if (!isset($cycle_vars[$name]['values'])) {
|
||||
if (!isset($params[ 'values' ])) {
|
||||
if (!isset($cycle_vars[ $name ][ 'values' ])) {
|
||||
trigger_error("cycle: missing 'values' parameter");
|
||||
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (isset($cycle_vars[$name]['values'])
|
||||
&& $cycle_vars[$name]['values'] != $params['values']
|
||||
) {
|
||||
$cycle_vars[$name]['index'] = 0;
|
||||
if (isset($cycle_vars[ $name ][ 'values' ]) && $cycle_vars[ $name ][ 'values' ] != $params[ 'values' ]) {
|
||||
$cycle_vars[ $name ][ 'index' ] = 0;
|
||||
}
|
||||
$cycle_vars[$name]['values'] = $params['values'];
|
||||
$cycle_vars[ $name ][ 'values' ] = $params[ 'values' ];
|
||||
}
|
||||
|
||||
if (isset($params['delimiter'])) {
|
||||
$cycle_vars[$name]['delimiter'] = $params['delimiter'];
|
||||
} elseif (!isset($cycle_vars[$name]['delimiter'])) {
|
||||
$cycle_vars[$name]['delimiter'] = ',';
|
||||
if (isset($params[ 'delimiter' ])) {
|
||||
$cycle_vars[ $name ][ 'delimiter' ] = $params[ 'delimiter' ];
|
||||
} elseif (!isset($cycle_vars[ $name ][ 'delimiter' ])) {
|
||||
$cycle_vars[ $name ][ 'delimiter' ] = ',';
|
||||
}
|
||||
|
||||
if (is_array($cycle_vars[$name]['values'])) {
|
||||
$cycle_array = $cycle_vars[$name]['values'];
|
||||
if (is_array($cycle_vars[ $name ][ 'values' ])) {
|
||||
$cycle_array = $cycle_vars[ $name ][ 'values' ];
|
||||
} else {
|
||||
$cycle_array = explode($cycle_vars[$name]['delimiter'], $cycle_vars[$name]['values']);
|
||||
$cycle_array = explode($cycle_vars[ $name ][ 'delimiter' ], $cycle_vars[ $name ][ 'values' ]);
|
||||
}
|
||||
|
||||
if (!isset($cycle_vars[$name]['index']) || $reset) {
|
||||
$cycle_vars[$name]['index'] = 0;
|
||||
if (!isset($cycle_vars[ $name ][ 'index' ]) || $reset) {
|
||||
$cycle_vars[ $name ][ 'index' ] = 0;
|
||||
}
|
||||
|
||||
if (isset($params['assign'])) {
|
||||
if (isset($params[ 'assign' ])) {
|
||||
$print = false;
|
||||
$template->assign($params['assign'], $cycle_array[$cycle_vars[$name]['index']]);
|
||||
$template->assign($params[ 'assign' ], $cycle_array[ $cycle_vars[ $name ][ 'index' ] ]);
|
||||
}
|
||||
|
||||
if ($print) {
|
||||
$retval = $cycle_array[$cycle_vars[$name]['index']];
|
||||
$retval = $cycle_array[ $cycle_vars[ $name ][ 'index' ] ];
|
||||
} else {
|
||||
$retval = null;
|
||||
}
|
||||
|
||||
if ($advance) {
|
||||
if ($cycle_vars[$name]['index'] >= count($cycle_array) - 1) {
|
||||
$cycle_vars[$name]['index'] = 0;
|
||||
if ($cycle_vars[ $name ][ 'index' ] >= count($cycle_array) - 1) {
|
||||
$cycle_vars[ $name ][ 'index' ] = 0;
|
||||
} else {
|
||||
$cycle_vars[$name]['index'] ++;
|
||||
$cycle_vars[ $name ][ 'index' ] ++;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -24,31 +24,31 @@
|
||||
*/
|
||||
function smarty_function_fetch($params, $template)
|
||||
{
|
||||
if (empty($params['file'])) {
|
||||
if (empty($params[ 'file' ])) {
|
||||
trigger_error("[plugin] fetch parameter 'file' cannot be empty", E_USER_NOTICE);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// strip file protocol
|
||||
if (stripos($params['file'], 'file://') === 0) {
|
||||
$params['file'] = substr($params['file'], 7);
|
||||
if (stripos($params[ 'file' ], 'file://') === 0) {
|
||||
$params[ 'file' ] = substr($params[ 'file' ], 7);
|
||||
}
|
||||
|
||||
$protocol = strpos($params['file'], '://');
|
||||
$protocol = strpos($params[ 'file' ], '://');
|
||||
if ($protocol !== false) {
|
||||
$protocol = strtolower(substr($params['file'], 0, $protocol));
|
||||
$protocol = strtolower(substr($params[ 'file' ], 0, $protocol));
|
||||
}
|
||||
|
||||
if (isset($template->smarty->security_policy)) {
|
||||
if ($protocol) {
|
||||
// remote resource (or php stream, …)
|
||||
if (!$template->smarty->security_policy->isTrustedUri($params['file'])) {
|
||||
if (!$template->smarty->security_policy->isTrustedUri($params[ 'file' ])) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// local file
|
||||
if (!$template->smarty->security_policy->isTrustedResourceDir($params['file'])) {
|
||||
if (!$template->smarty->security_policy->isTrustedResourceDir($params[ 'file' ])) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -57,26 +57,26 @@ function smarty_function_fetch($params, $template)
|
||||
$content = '';
|
||||
if ($protocol == 'http') {
|
||||
// http fetch
|
||||
if ($uri_parts = parse_url($params['file'])) {
|
||||
if ($uri_parts = parse_url($params[ 'file' ])) {
|
||||
// set defaults
|
||||
$host = $server_name = $uri_parts['host'];
|
||||
$host = $server_name = $uri_parts[ 'host' ];
|
||||
$timeout = 30;
|
||||
$accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*";
|
||||
$agent = "Smarty Template Engine " . Smarty::SMARTY_VERSION;
|
||||
$referer = "";
|
||||
$uri = !empty($uri_parts['path']) ? $uri_parts['path'] : '/';
|
||||
$uri .= !empty($uri_parts['query']) ? '?' . $uri_parts['query'] : '';
|
||||
$uri = !empty($uri_parts[ 'path' ]) ? $uri_parts[ 'path' ] : '/';
|
||||
$uri .= !empty($uri_parts[ 'query' ]) ? '?' . $uri_parts[ 'query' ] : '';
|
||||
$_is_proxy = false;
|
||||
if (empty($uri_parts['port'])) {
|
||||
if (empty($uri_parts[ 'port' ])) {
|
||||
$port = 80;
|
||||
} else {
|
||||
$port = $uri_parts['port'];
|
||||
$port = $uri_parts[ 'port' ];
|
||||
}
|
||||
if (!empty($uri_parts['user'])) {
|
||||
$user = $uri_parts['user'];
|
||||
if (!empty($uri_parts[ 'user' ])) {
|
||||
$user = $uri_parts[ 'user' ];
|
||||
}
|
||||
if (!empty($uri_parts['pass'])) {
|
||||
$pass = $uri_parts['pass'];
|
||||
if (!empty($uri_parts[ 'pass' ])) {
|
||||
$pass = $uri_parts[ 'pass' ];
|
||||
}
|
||||
// loop through parameters, setup headers
|
||||
foreach ($params as $param_key => $param_value) {
|
||||
@@ -163,7 +163,7 @@ function smarty_function_fetch($params, $template)
|
||||
return;
|
||||
} else {
|
||||
if ($_is_proxy) {
|
||||
fputs($fp, 'GET ' . $params['file'] . " HTTP/1.0\r\n");
|
||||
fputs($fp, 'GET ' . $params[ 'file' ] . " HTTP/1.0\r\n");
|
||||
} else {
|
||||
fputs($fp, "GET $uri HTTP/1.0\r\n");
|
||||
}
|
||||
@@ -195,10 +195,10 @@ function smarty_function_fetch($params, $template)
|
||||
fclose($fp);
|
||||
$csplit = preg_split("!\r\n\r\n!", $content, 2);
|
||||
|
||||
$content = $csplit[1];
|
||||
$content = $csplit[ 1 ];
|
||||
|
||||
if (!empty($params['assign_headers'])) {
|
||||
$template->assign($params['assign_headers'], preg_split("!\r\n!", $csplit[0]));
|
||||
if (!empty($params[ 'assign_headers' ])) {
|
||||
$template->assign($params[ 'assign_headers' ], preg_split("!\r\n!", $csplit[ 0 ]));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -207,14 +207,14 @@ function smarty_function_fetch($params, $template)
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
$content = @file_get_contents($params['file']);
|
||||
$content = @file_get_contents($params[ 'file' ]);
|
||||
if ($content === false) {
|
||||
throw new SmartyException("{fetch} cannot read resource '" . $params['file'] . "'");
|
||||
throw new SmartyException("{fetch} cannot read resource '" . $params[ 'file' ] . "'");
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($params['assign'])) {
|
||||
$template->assign($params['assign'], $content);
|
||||
if (!empty($params[ 'assign' ])) {
|
||||
$template->assign($params[ 'assign' ], $content);
|
||||
} else {
|
||||
return $content;
|
||||
}
|
||||
|
@@ -90,19 +90,21 @@ function smarty_function_html_checkboxes($params, $template)
|
||||
if (method_exists($_sel, "__toString")) {
|
||||
$_sel = smarty_function_escape_special_chars((string) $_sel->__toString());
|
||||
} else {
|
||||
trigger_error("html_checkboxes: selected attribute contains an object of class '" . get_class($_sel) . "' without __toString() method", E_USER_NOTICE);
|
||||
trigger_error("html_checkboxes: selected attribute contains an object of class '" .
|
||||
get_class($_sel) . "' without __toString() method", E_USER_NOTICE);
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
$_sel = smarty_function_escape_special_chars((string) $_sel);
|
||||
}
|
||||
$selected[$_sel] = true;
|
||||
$selected[ $_sel ] = true;
|
||||
}
|
||||
} elseif (is_object($_val)) {
|
||||
if (method_exists($_val, "__toString")) {
|
||||
$selected = smarty_function_escape_special_chars((string) $_val->__toString());
|
||||
} else {
|
||||
trigger_error("html_checkboxes: selected attribute is an object of class '" . get_class($_val) . "' without __toString() method", E_USER_NOTICE);
|
||||
trigger_error("html_checkboxes: selected attribute is an object of class '" . get_class($_val) .
|
||||
"' without __toString() method", E_USER_NOTICE);
|
||||
}
|
||||
} else {
|
||||
$selected = smarty_function_escape_special_chars((string) $_val);
|
||||
@@ -110,7 +112,8 @@ function smarty_function_html_checkboxes($params, $template)
|
||||
break;
|
||||
|
||||
case 'checkboxes':
|
||||
trigger_error('html_checkboxes: the use of the "checkboxes" attribute is deprecated, use "options" instead', E_USER_WARNING);
|
||||
trigger_error('html_checkboxes: the use of the "checkboxes" attribute is deprecated, use "options" instead',
|
||||
E_USER_WARNING);
|
||||
$options = (array) $_val;
|
||||
break;
|
||||
|
||||
@@ -122,9 +125,10 @@ function smarty_function_html_checkboxes($params, $template)
|
||||
|
||||
case 'disabled':
|
||||
case 'readonly':
|
||||
if (!empty($params['strict'])) {
|
||||
if (!empty($params[ 'strict' ])) {
|
||||
if (!is_scalar($_val)) {
|
||||
trigger_error("html_options: $_key attribute must be a scalar, only boolean true or string '$_key' will actually add the attribute", E_USER_NOTICE);
|
||||
trigger_error("html_options: $_key attribute must be a scalar, only boolean true or string '$_key' will actually add the attribute",
|
||||
E_USER_NOTICE);
|
||||
}
|
||||
|
||||
if ($_val === true || $_val === $_key) {
|
||||
@@ -153,23 +157,28 @@ function smarty_function_html_checkboxes($params, $template)
|
||||
|
||||
if (isset($options)) {
|
||||
foreach ($options as $_key => $_val) {
|
||||
$_html_result[] = smarty_function_html_checkboxes_output($name, $_key, $_val, $selected, $extra, $separator, $labels, $label_ids, $escape);
|
||||
$_html_result[] =
|
||||
smarty_function_html_checkboxes_output($name, $_key, $_val, $selected, $extra, $separator, $labels,
|
||||
$label_ids, $escape);
|
||||
}
|
||||
} else {
|
||||
foreach ($values as $_i => $_key) {
|
||||
$_val = isset($output[$_i]) ? $output[$_i] : '';
|
||||
$_html_result[] = smarty_function_html_checkboxes_output($name, $_key, $_val, $selected, $extra, $separator, $labels, $label_ids, $escape);
|
||||
$_val = isset($output[ $_i ]) ? $output[ $_i ] : '';
|
||||
$_html_result[] =
|
||||
smarty_function_html_checkboxes_output($name, $_key, $_val, $selected, $extra, $separator, $labels,
|
||||
$label_ids, $escape);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($params['assign'])) {
|
||||
$template->assign($params['assign'], $_html_result);
|
||||
if (!empty($params[ 'assign' ])) {
|
||||
$template->assign($params[ 'assign' ], $_html_result);
|
||||
} else {
|
||||
return implode("\n", $_html_result);
|
||||
}
|
||||
}
|
||||
|
||||
function smarty_function_html_checkboxes_output($name, $value, $output, $selected, $extra, $separator, $labels, $label_ids, $escape = true)
|
||||
function smarty_function_html_checkboxes_output($name, $value, $output, $selected, $extra, $separator, $labels,
|
||||
$label_ids, $escape = true)
|
||||
{
|
||||
$_output = '';
|
||||
|
||||
@@ -177,7 +186,8 @@ function smarty_function_html_checkboxes_output($name, $value, $output, $selecte
|
||||
if (method_exists($value, "__toString")) {
|
||||
$value = (string) $value->__toString();
|
||||
} else {
|
||||
trigger_error("html_options: value is an object of class '" . get_class($value) . "' without __toString() method", E_USER_NOTICE);
|
||||
trigger_error("html_options: value is an object of class '" . get_class($value) .
|
||||
"' without __toString() method", E_USER_NOTICE);
|
||||
|
||||
return '';
|
||||
}
|
||||
@@ -189,7 +199,8 @@ function smarty_function_html_checkboxes_output($name, $value, $output, $selecte
|
||||
if (method_exists($output, "__toString")) {
|
||||
$output = (string) $output->__toString();
|
||||
} else {
|
||||
trigger_error("html_options: output is an object of class '" . get_class($output) . "' without __toString() method", E_USER_NOTICE);
|
||||
trigger_error("html_options: output is an object of class '" . get_class($output) .
|
||||
"' without __toString() method", E_USER_NOTICE);
|
||||
|
||||
return '';
|
||||
}
|
||||
@@ -199,7 +210,8 @@ function smarty_function_html_checkboxes_output($name, $value, $output, $selecte
|
||||
|
||||
if ($labels) {
|
||||
if ($label_ids) {
|
||||
$_id = smarty_function_escape_special_chars(preg_replace('![^\w\-\.]!' . Smarty::$_UTF8_MODIFIER, '_', $name . '_' . $value));
|
||||
$_id = smarty_function_escape_special_chars(preg_replace('![^\w\-\.]!' . Smarty::$_UTF8_MODIFIER, '_',
|
||||
$name . '_' . $value));
|
||||
$_output .= '<label for="' . $_id . '">';
|
||||
} else {
|
||||
$_output .= '<label>';
|
||||
@@ -219,7 +231,7 @@ function smarty_function_html_checkboxes_output($name, $value, $output, $selecte
|
||||
}
|
||||
|
||||
if (is_array($selected)) {
|
||||
if (isset($selected[$value])) {
|
||||
if (isset($selected[ $value ])) {
|
||||
$_output .= ' checked="checked"';
|
||||
}
|
||||
} elseif ($value === $selected) {
|
||||
|
@@ -48,7 +48,7 @@ function smarty_function_html_image($params, $template)
|
||||
$prefix = '';
|
||||
$suffix = '';
|
||||
$path_prefix = '';
|
||||
$basedir = isset($_SERVER['DOCUMENT_ROOT']) ? $_SERVER['DOCUMENT_ROOT'] : '';
|
||||
$basedir = isset($_SERVER[ 'DOCUMENT_ROOT' ]) ? $_SERVER[ 'DOCUMENT_ROOT' ] : '';
|
||||
foreach ($params as $_key => $_val) {
|
||||
switch ($_key) {
|
||||
case 'file':
|
||||
@@ -90,26 +90,26 @@ function smarty_function_html_image($params, $template)
|
||||
return;
|
||||
}
|
||||
|
||||
if ($file[0] == '/') {
|
||||
if ($file[ 0 ] == '/') {
|
||||
$_image_path = $basedir . $file;
|
||||
} else {
|
||||
$_image_path = $file;
|
||||
}
|
||||
|
||||
// strip file protocol
|
||||
if (stripos($params['file'], 'file://') === 0) {
|
||||
$params['file'] = substr($params['file'], 7);
|
||||
if (stripos($params[ 'file' ], 'file://') === 0) {
|
||||
$params[ 'file' ] = substr($params[ 'file' ], 7);
|
||||
}
|
||||
|
||||
$protocol = strpos($params['file'], '://');
|
||||
$protocol = strpos($params[ 'file' ], '://');
|
||||
if ($protocol !== false) {
|
||||
$protocol = strtolower(substr($params['file'], 0, $protocol));
|
||||
$protocol = strtolower(substr($params[ 'file' ], 0, $protocol));
|
||||
}
|
||||
|
||||
if (isset($template->smarty->security_policy)) {
|
||||
if ($protocol) {
|
||||
// remote resource (or php stream, …)
|
||||
if (!$template->smarty->security_policy->isTrustedUri($params['file'])) {
|
||||
if (!$template->smarty->security_policy->isTrustedUri($params[ 'file' ])) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
@@ -120,7 +120,7 @@ function smarty_function_html_image($params, $template)
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($params['width']) || !isset($params['height'])) {
|
||||
if (!isset($params[ 'width' ]) || !isset($params[ 'height' ])) {
|
||||
// FIXME: (rodneyrehm) getimagesize() loads the complete file off a remote resource, use custom [jpg,png,gif]header reader!
|
||||
if (!$_image_data = @getimagesize($_image_path)) {
|
||||
if (!file_exists($_image_path)) {
|
||||
@@ -138,26 +138,27 @@ function smarty_function_html_image($params, $template)
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($params['width'])) {
|
||||
$width = $_image_data[0];
|
||||
if (!isset($params[ 'width' ])) {
|
||||
$width = $_image_data[ 0 ];
|
||||
}
|
||||
if (!isset($params['height'])) {
|
||||
$height = $_image_data[1];
|
||||
if (!isset($params[ 'height' ])) {
|
||||
$height = $_image_data[ 1 ];
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($params['dpi'])) {
|
||||
if (strstr($_SERVER['HTTP_USER_AGENT'], 'Mac')) {
|
||||
if (isset($params[ 'dpi' ])) {
|
||||
if (strstr($_SERVER[ 'HTTP_USER_AGENT' ], 'Mac')) {
|
||||
// FIXME: (rodneyrehm) wrong dpi assumption
|
||||
// don't know who thought this up… even if it was true in 1998, it's definitely wrong in 2011.
|
||||
$dpi_default = 72;
|
||||
} else {
|
||||
$dpi_default = 96;
|
||||
}
|
||||
$_resize = $dpi_default / $params['dpi'];
|
||||
$_resize = $dpi_default / $params[ 'dpi' ];
|
||||
$width = round($width * $_resize);
|
||||
$height = round($height * $_resize);
|
||||
}
|
||||
|
||||
return $prefix . '<img src="' . $path_prefix . $file . '" alt="' . $alt . '" width="' . $width . '" height="' . $height . '"' . $extra . ' />' . $suffix;
|
||||
return $prefix . '<img src="' . $path_prefix . $file . '" alt="' . $alt . '" width="' . $width . '" height="' .
|
||||
$height . '"' . $extra . ' />' . $suffix;
|
||||
}
|
||||
|
@@ -72,19 +72,21 @@ function smarty_function_html_options($params)
|
||||
if (method_exists($_sel, "__toString")) {
|
||||
$_sel = smarty_function_escape_special_chars((string) $_sel->__toString());
|
||||
} else {
|
||||
trigger_error("html_options: selected attribute contains an object of class '" . get_class($_sel) . "' without __toString() method", E_USER_NOTICE);
|
||||
trigger_error("html_options: selected attribute contains an object of class '" .
|
||||
get_class($_sel) . "' without __toString() method", E_USER_NOTICE);
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
$_sel = smarty_function_escape_special_chars((string) $_sel);
|
||||
}
|
||||
$selected[$_sel] = true;
|
||||
$selected[ $_sel ] = true;
|
||||
}
|
||||
} elseif (is_object($_val)) {
|
||||
if (method_exists($_val, "__toString")) {
|
||||
$selected = smarty_function_escape_special_chars((string) $_val->__toString());
|
||||
} else {
|
||||
trigger_error("html_options: selected attribute is an object of class '" . get_class($_val) . "' without __toString() method", E_USER_NOTICE);
|
||||
trigger_error("html_options: selected attribute is an object of class '" . get_class($_val) .
|
||||
"' without __toString() method", E_USER_NOTICE);
|
||||
}
|
||||
} else {
|
||||
$selected = smarty_function_escape_special_chars((string) $_val);
|
||||
@@ -96,9 +98,10 @@ function smarty_function_html_options($params)
|
||||
|
||||
case 'disabled':
|
||||
case 'readonly':
|
||||
if (!empty($params['strict'])) {
|
||||
if (!empty($params[ 'strict' ])) {
|
||||
if (!is_scalar($_val)) {
|
||||
trigger_error("html_options: $_key attribute must be a scalar, only boolean true or string '$_key' will actually add the attribute", E_USER_NOTICE);
|
||||
trigger_error("html_options: $_key attribute must be a scalar, only boolean true or string '$_key' will actually add the attribute",
|
||||
E_USER_NOTICE);
|
||||
}
|
||||
|
||||
if ($_val === true || $_val === $_key) {
|
||||
@@ -134,7 +137,7 @@ function smarty_function_html_options($params)
|
||||
}
|
||||
} else {
|
||||
foreach ($values as $_i => $_key) {
|
||||
$_val = isset($output[$_i]) ? $output[$_i] : '';
|
||||
$_val = isset($output[ $_i ]) ? $output[ $_i ] : '';
|
||||
$_html_result .= smarty_function_html_options_optoutput($_key, $_val, $selected, $id, $class, $_idx);
|
||||
}
|
||||
}
|
||||
@@ -142,7 +145,9 @@ function smarty_function_html_options($params)
|
||||
if (!empty($name)) {
|
||||
$_html_class = !empty($class) ? ' class="' . $class . '"' : '';
|
||||
$_html_id = !empty($id) ? ' id="' . $id . '"' : '';
|
||||
$_html_result = '<select name="' . $name . '"' . $_html_class . $_html_id . $extra . '>' . "\n" . $_html_result . '</select>' . "\n";
|
||||
$_html_result =
|
||||
'<select name="' . $name . '"' . $_html_class . $_html_id . $extra . '>' . "\n" . $_html_result .
|
||||
'</select>' . "\n";
|
||||
}
|
||||
|
||||
return $_html_result;
|
||||
@@ -154,7 +159,7 @@ function smarty_function_html_options_optoutput($key, $value, $selected, $id, $c
|
||||
$_key = smarty_function_escape_special_chars($key);
|
||||
$_html_result = '<option value="' . $_key . '"';
|
||||
if (is_array($selected)) {
|
||||
if (isset($selected[$_key])) {
|
||||
if (isset($selected[ $_key ])) {
|
||||
$_html_result .= ' selected="selected"';
|
||||
}
|
||||
} elseif ($_key === $selected) {
|
||||
@@ -166,7 +171,8 @@ function smarty_function_html_options_optoutput($key, $value, $selected, $id, $c
|
||||
if (method_exists($value, "__toString")) {
|
||||
$value = smarty_function_escape_special_chars((string) $value->__toString());
|
||||
} else {
|
||||
trigger_error("html_options: value is an object of class '" . get_class($value) . "' without __toString() method", E_USER_NOTICE);
|
||||
trigger_error("html_options: value is an object of class '" . get_class($value) .
|
||||
"' without __toString() method", E_USER_NOTICE);
|
||||
|
||||
return '';
|
||||
}
|
||||
@@ -177,7 +183,9 @@ function smarty_function_html_options_optoutput($key, $value, $selected, $id, $c
|
||||
$idx ++;
|
||||
} else {
|
||||
$_idx = 0;
|
||||
$_html_result = smarty_function_html_options_optgroup($key, $value, $selected, !empty($id) ? ($id . '-' . $idx) : null, $class, $_idx);
|
||||
$_html_result =
|
||||
smarty_function_html_options_optgroup($key, $value, $selected, !empty($id) ? ($id . '-' . $idx) : null,
|
||||
$class, $_idx);
|
||||
$idx ++;
|
||||
}
|
||||
|
||||
|
@@ -73,7 +73,8 @@ function smarty_function_html_radios($params, $template)
|
||||
if (method_exists($_val, "__toString")) {
|
||||
$selected = smarty_function_escape_special_chars((string) $_val->__toString());
|
||||
} else {
|
||||
trigger_error("html_radios: selected attribute is an object of class '" . get_class($_val) . "' without __toString() method", E_USER_NOTICE);
|
||||
trigger_error("html_radios: selected attribute is an object of class '" . get_class($_val) .
|
||||
"' without __toString() method", E_USER_NOTICE);
|
||||
}
|
||||
} else {
|
||||
$selected = (string) $_val;
|
||||
@@ -96,7 +97,8 @@ function smarty_function_html_radios($params, $template)
|
||||
break;
|
||||
|
||||
case 'radios':
|
||||
trigger_error('html_radios: the use of the "radios" attribute is deprecated, use "options" instead', E_USER_WARNING);
|
||||
trigger_error('html_radios: the use of the "radios" attribute is deprecated, use "options" instead',
|
||||
E_USER_WARNING);
|
||||
$options = (array) $_val;
|
||||
break;
|
||||
|
||||
@@ -108,9 +110,10 @@ function smarty_function_html_radios($params, $template)
|
||||
|
||||
case 'disabled':
|
||||
case 'readonly':
|
||||
if (!empty($params['strict'])) {
|
||||
if (!empty($params[ 'strict' ])) {
|
||||
if (!is_scalar($_val)) {
|
||||
trigger_error("html_options: $_key attribute must be a scalar, only boolean true or string '$_key' will actually add the attribute", E_USER_NOTICE);
|
||||
trigger_error("html_options: $_key attribute must be a scalar, only boolean true or string '$_key' will actually add the attribute",
|
||||
E_USER_NOTICE);
|
||||
}
|
||||
|
||||
if ($_val === true || $_val === $_key) {
|
||||
@@ -141,23 +144,28 @@ function smarty_function_html_radios($params, $template)
|
||||
|
||||
if (isset($options)) {
|
||||
foreach ($options as $_key => $_val) {
|
||||
$_html_result[] = smarty_function_html_radios_output($name, $_key, $_val, $selected, $extra, $separator, $labels, $label_ids, $escape);
|
||||
$_html_result[] =
|
||||
smarty_function_html_radios_output($name, $_key, $_val, $selected, $extra, $separator, $labels,
|
||||
$label_ids, $escape);
|
||||
}
|
||||
} else {
|
||||
foreach ($values as $_i => $_key) {
|
||||
$_val = isset($output[$_i]) ? $output[$_i] : '';
|
||||
$_html_result[] = smarty_function_html_radios_output($name, $_key, $_val, $selected, $extra, $separator, $labels, $label_ids, $escape);
|
||||
$_val = isset($output[ $_i ]) ? $output[ $_i ] : '';
|
||||
$_html_result[] =
|
||||
smarty_function_html_radios_output($name, $_key, $_val, $selected, $extra, $separator, $labels,
|
||||
$label_ids, $escape);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($params['assign'])) {
|
||||
$template->assign($params['assign'], $_html_result);
|
||||
if (!empty($params[ 'assign' ])) {
|
||||
$template->assign($params[ 'assign' ], $_html_result);
|
||||
} else {
|
||||
return implode("\n", $_html_result);
|
||||
}
|
||||
}
|
||||
|
||||
function smarty_function_html_radios_output($name, $value, $output, $selected, $extra, $separator, $labels, $label_ids, $escape)
|
||||
function smarty_function_html_radios_output($name, $value, $output, $selected, $extra, $separator, $labels, $label_ids,
|
||||
$escape)
|
||||
{
|
||||
$_output = '';
|
||||
|
||||
@@ -165,7 +173,8 @@ function smarty_function_html_radios_output($name, $value, $output, $selected, $
|
||||
if (method_exists($value, "__toString")) {
|
||||
$value = (string) $value->__toString();
|
||||
} else {
|
||||
trigger_error("html_options: value is an object of class '" . get_class($value) . "' without __toString() method", E_USER_NOTICE);
|
||||
trigger_error("html_options: value is an object of class '" . get_class($value) .
|
||||
"' without __toString() method", E_USER_NOTICE);
|
||||
|
||||
return '';
|
||||
}
|
||||
@@ -177,7 +186,8 @@ function smarty_function_html_radios_output($name, $value, $output, $selected, $
|
||||
if (method_exists($output, "__toString")) {
|
||||
$output = (string) $output->__toString();
|
||||
} else {
|
||||
trigger_error("html_options: output is an object of class '" . get_class($output) . "' without __toString() method", E_USER_NOTICE);
|
||||
trigger_error("html_options: output is an object of class '" . get_class($output) .
|
||||
"' without __toString() method", E_USER_NOTICE);
|
||||
|
||||
return '';
|
||||
}
|
||||
@@ -187,7 +197,8 @@ function smarty_function_html_radios_output($name, $value, $output, $selected, $
|
||||
|
||||
if ($labels) {
|
||||
if ($label_ids) {
|
||||
$_id = smarty_function_escape_special_chars(preg_replace('![^\w\-\.]!' . Smarty::$_UTF8_MODIFIER, '_', $name . '_' . $value));
|
||||
$_id = smarty_function_escape_special_chars(preg_replace('![^\w\-\.]!' . Smarty::$_UTF8_MODIFIER, '_',
|
||||
$name . '_' . $value));
|
||||
$_output .= '<label for="' . $_id . '">';
|
||||
} else {
|
||||
$_output .= '<label>';
|
||||
|
@@ -59,7 +59,7 @@ function smarty_function_html_select_date($params)
|
||||
$_current_year = date('Y');
|
||||
$_month_timestamps = array();
|
||||
for ($i = 1; $i <= 12; $i ++) {
|
||||
$_month_timestamps[$i] = mktime(0, 0, 0, $i, 1, 2000);
|
||||
$_month_timestamps[ $i ] = mktime(0, 0, 0, $i, 1, 2000);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -177,22 +177,21 @@ function smarty_function_html_select_date($params)
|
||||
|
||||
// Note: date() is faster than strftime()
|
||||
// Note: explode(date()) is faster than date() date() date()
|
||||
if (isset($params['time']) && is_array($params['time'])) {
|
||||
if (isset($params['time'][$prefix . 'Year'])) {
|
||||
if (isset($params[ 'time' ]) && is_array($params[ 'time' ])) {
|
||||
if (isset($params[ 'time' ][ $prefix . 'Year' ])) {
|
||||
// $_REQUEST[$field_array] given
|
||||
foreach (array('Y' => 'Year', 'm' => 'Month', 'd' => 'Day') as $_elementKey => $_elementName) {
|
||||
$_variableName = '_' . strtolower($_elementName);
|
||||
$$_variableName = isset($params['time'][$prefix . $_elementName])
|
||||
? $params['time'][$prefix . $_elementName]
|
||||
: date($_elementKey);
|
||||
$$_variableName =
|
||||
isset($params[ 'time' ][ $prefix . $_elementName ]) ? $params[ 'time' ][ $prefix . $_elementName ] :
|
||||
date($_elementKey);
|
||||
}
|
||||
} elseif (isset($params['time'][$field_array][$prefix . 'Year'])) {
|
||||
} elseif (isset($params[ 'time' ][ $field_array ][ $prefix . 'Year' ])) {
|
||||
// $_REQUEST given
|
||||
foreach (array('Y' => 'Year', 'm' => 'Month', 'd' => 'Day') as $_elementKey => $_elementName) {
|
||||
$_variableName = '_' . strtolower($_elementName);
|
||||
$$_variableName = isset($params['time'][$field_array][$prefix . $_elementName])
|
||||
? $params['time'][$field_array][$prefix . $_elementName]
|
||||
: date($_elementKey);
|
||||
$$_variableName = isset($params[ 'time' ][ $field_array ][ $prefix . $_elementName ]) ?
|
||||
$params[ 'time' ][ $field_array ][ $prefix . $_elementName ] : date($_elementKey);
|
||||
}
|
||||
} else {
|
||||
// no date found, use NOW
|
||||
@@ -215,10 +214,10 @@ function smarty_function_html_select_date($params)
|
||||
$t = $$key;
|
||||
if ($t === null) {
|
||||
$$key = (int) $_current_year;
|
||||
} elseif ($t[0] == '+') {
|
||||
$$key = (int) ($_current_year + (int)trim(substr($t, 1)));
|
||||
} elseif ($t[0] == '-') {
|
||||
$$key = (int) ($_current_year - (int)trim(substr($t, 1)));
|
||||
} elseif ($t[ 0 ] == '+') {
|
||||
$$key = (int) ($_current_year + (int) trim(substr($t, 1)));
|
||||
} elseif ($t[ 0 ] == '-') {
|
||||
$$key = (int) ($_current_year - (int) trim(substr($t, 1)));
|
||||
} else {
|
||||
$$key = (int) $$key;
|
||||
}
|
||||
@@ -243,13 +242,16 @@ function smarty_function_html_select_date($params)
|
||||
}
|
||||
|
||||
if ($year_as_text) {
|
||||
$_html_years = '<input type="text" name="' . $_name . '" value="' . $_year . '" size="4" maxlength="4"' . $_extra . $extra_attrs . ' />';
|
||||
$_html_years =
|
||||
'<input type="text" name="' . $_name . '" value="' . $_year . '" size="4" maxlength="4"' . $_extra .
|
||||
$extra_attrs . ' />';
|
||||
} else {
|
||||
$_html_years = '<select name="' . $_name . '"';
|
||||
if ($year_id !== null || $all_id !== null) {
|
||||
$_html_years .= ' id="' . smarty_function_escape_special_chars(
|
||||
$year_id !== null ? ($year_id ? $year_id : $_name) : ($all_id ? ($all_id . $_name) : $_name)
|
||||
) . '"';
|
||||
$_html_years .= ' id="' . smarty_function_escape_special_chars($year_id !== null ?
|
||||
($year_id ? $year_id : $_name) :
|
||||
($all_id ? ($all_id . $_name) :
|
||||
$_name)) . '"';
|
||||
}
|
||||
if ($year_size) {
|
||||
$_html_years .= ' size="' . $year_size . '"';
|
||||
@@ -257,14 +259,14 @@ function smarty_function_html_select_date($params)
|
||||
$_html_years .= $_extra . $extra_attrs . '>' . $option_separator;
|
||||
|
||||
if (isset($year_empty) || isset($all_empty)) {
|
||||
$_html_years .= '<option value="">' . (isset($year_empty) ? $year_empty : $all_empty) . '</option>' . $option_separator;
|
||||
$_html_years .= '<option value="">' . (isset($year_empty) ? $year_empty : $all_empty) . '</option>' .
|
||||
$option_separator;
|
||||
}
|
||||
|
||||
$op = $start_year > $end_year ? - 1 : 1;
|
||||
for ($i = $start_year; $op > 0 ? $i <= $end_year : $i >= $end_year; $i += $op) {
|
||||
$_html_years .= '<option value="' . $i . '"'
|
||||
. ($_year == $i ? ' selected="selected"' : '')
|
||||
. '>' . $i . '</option>' . $option_separator;
|
||||
$_html_years .= '<option value="' . $i . '"' . ($_year == $i ? ' selected="selected"' : '') . '>' . $i .
|
||||
'</option>' . $option_separator;
|
||||
}
|
||||
|
||||
$_html_years .= '</select>';
|
||||
@@ -284,9 +286,10 @@ function smarty_function_html_select_date($params)
|
||||
|
||||
$_html_months = '<select name="' . $_name . '"';
|
||||
if ($month_id !== null || $all_id !== null) {
|
||||
$_html_months .= ' id="' . smarty_function_escape_special_chars(
|
||||
$month_id !== null ? ($month_id ? $month_id : $_name) : ($all_id ? ($all_id . $_name) : $_name)
|
||||
) . '"';
|
||||
$_html_months .= ' id="' . smarty_function_escape_special_chars($month_id !== null ?
|
||||
($month_id ? $month_id : $_name) :
|
||||
($all_id ? ($all_id . $_name) :
|
||||
$_name)) . '"';
|
||||
}
|
||||
if ($month_size) {
|
||||
$_html_months .= ' size="' . $month_size . '"';
|
||||
@@ -294,16 +297,17 @@ function smarty_function_html_select_date($params)
|
||||
$_html_months .= $_extra . $extra_attrs . '>' . $option_separator;
|
||||
|
||||
if (isset($month_empty) || isset($all_empty)) {
|
||||
$_html_months .= '<option value="">' . (isset($month_empty) ? $month_empty : $all_empty) . '</option>' . $option_separator;
|
||||
$_html_months .= '<option value="">' . (isset($month_empty) ? $month_empty : $all_empty) . '</option>' .
|
||||
$option_separator;
|
||||
}
|
||||
|
||||
for ($i = 1; $i <= 12; $i ++) {
|
||||
$_val = sprintf('%02d', $i);
|
||||
$_text = isset($month_names) ? smarty_function_escape_special_chars($month_names[$i]) : ($month_format == "%m" ? $_val : strftime($month_format, $_month_timestamps[$i]));
|
||||
$_value = $month_value_format == "%m" ? $_val : strftime($month_value_format, $_month_timestamps[$i]);
|
||||
$_html_months .= '<option value="' . $_value . '"'
|
||||
. ($_val == $_month ? ' selected="selected"' : '')
|
||||
. '>' . $_text . '</option>' . $option_separator;
|
||||
$_text = isset($month_names) ? smarty_function_escape_special_chars($month_names[ $i ]) :
|
||||
($month_format == "%m" ? $_val : strftime($month_format, $_month_timestamps[ $i ]));
|
||||
$_value = $month_value_format == "%m" ? $_val : strftime($month_value_format, $_month_timestamps[ $i ]);
|
||||
$_html_months .= '<option value="' . $_value . '"' . ($_val == $_month ? ' selected="selected"' : '') .
|
||||
'>' . $_text . '</option>' . $option_separator;
|
||||
}
|
||||
|
||||
$_html_months .= '</select>';
|
||||
@@ -322,9 +326,9 @@ function smarty_function_html_select_date($params)
|
||||
|
||||
$_html_days = '<select name="' . $_name . '"';
|
||||
if ($day_id !== null || $all_id !== null) {
|
||||
$_html_days .= ' id="' . smarty_function_escape_special_chars(
|
||||
$day_id !== null ? ($day_id ? $day_id : $_name) : ($all_id ? ($all_id . $_name) : $_name)
|
||||
) . '"';
|
||||
$_html_days .= ' id="' .
|
||||
smarty_function_escape_special_chars($day_id !== null ? ($day_id ? $day_id : $_name) :
|
||||
($all_id ? ($all_id . $_name) : $_name)) . '"';
|
||||
}
|
||||
if ($day_size) {
|
||||
$_html_days .= ' size="' . $day_size . '"';
|
||||
@@ -332,16 +336,16 @@ function smarty_function_html_select_date($params)
|
||||
$_html_days .= $_extra . $extra_attrs . '>' . $option_separator;
|
||||
|
||||
if (isset($day_empty) || isset($all_empty)) {
|
||||
$_html_days .= '<option value="">' . (isset($day_empty) ? $day_empty : $all_empty) . '</option>' . $option_separator;
|
||||
$_html_days .= '<option value="">' . (isset($day_empty) ? $day_empty : $all_empty) . '</option>' .
|
||||
$option_separator;
|
||||
}
|
||||
|
||||
for ($i = 1; $i <= 31; $i ++) {
|
||||
$_val = sprintf('%02d', $i);
|
||||
$_text = $day_format == '%02d' ? $_val : sprintf($day_format, $i);
|
||||
$_value = $day_value_format == '%02d' ? $_val : sprintf($day_value_format, $i);
|
||||
$_html_days .= '<option value="' . $_value . '"'
|
||||
. ($_val == $_day ? ' selected="selected"' : '')
|
||||
. '>' . $_text . '</option>' . $option_separator;
|
||||
$_html_days .= '<option value="' . $_value . '"' . ($_val == $_day ? ' selected="selected"' : '') . '>' .
|
||||
$_text . '</option>' . $option_separator;
|
||||
}
|
||||
|
||||
$_html_days .= '</select>';
|
||||
@@ -350,7 +354,7 @@ function smarty_function_html_select_date($params)
|
||||
// order the fields for output
|
||||
$_html = '';
|
||||
for ($i = 0; $i <= 2; $i ++) {
|
||||
switch ($field_order[$i]) {
|
||||
switch ($field_order[ $i ]) {
|
||||
case 'Y':
|
||||
case 'y':
|
||||
if (isset($_html_years)) {
|
||||
|
@@ -148,31 +148,29 @@ function smarty_function_html_select_time($params)
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($params['time']) && is_array($params['time'])) {
|
||||
if (isset($params['time'][$prefix . 'Hour'])) {
|
||||
if (isset($params[ 'time' ]) && is_array($params[ 'time' ])) {
|
||||
if (isset($params[ 'time' ][ $prefix . 'Hour' ])) {
|
||||
// $_REQUEST[$field_array] given
|
||||
foreach (array('H' => 'Hour', 'i' => 'Minute', 's' => 'Second') as $_elementKey => $_elementName) {
|
||||
$_variableName = '_' . strtolower($_elementName);
|
||||
$$_variableName = isset($params['time'][$prefix . $_elementName])
|
||||
? $params['time'][$prefix . $_elementName]
|
||||
: date($_elementKey);
|
||||
$$_variableName =
|
||||
isset($params[ 'time' ][ $prefix . $_elementName ]) ? $params[ 'time' ][ $prefix . $_elementName ] :
|
||||
date($_elementKey);
|
||||
}
|
||||
$_meridian = isset($params['time'][$prefix . 'Meridian'])
|
||||
? (' ' . $params['time'][$prefix . 'Meridian'])
|
||||
: '';
|
||||
$_meridian =
|
||||
isset($params[ 'time' ][ $prefix . 'Meridian' ]) ? (' ' . $params[ 'time' ][ $prefix . 'Meridian' ]) :
|
||||
'';
|
||||
$time = strtotime($_hour . ':' . $_minute . ':' . $_second . $_meridian);
|
||||
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
|
||||
foreach (array('H' => 'Hour', 'i' => 'Minute', 's' => 'Second') as $_elementKey => $_elementName) {
|
||||
$_variableName = '_' . strtolower($_elementName);
|
||||
$$_variableName = isset($params['time'][$field_array][$prefix . $_elementName])
|
||||
? $params['time'][$field_array][$prefix . $_elementName]
|
||||
: date($_elementKey);
|
||||
$$_variableName = isset($params[ 'time' ][ $field_array ][ $prefix . $_elementName ]) ?
|
||||
$params[ 'time' ][ $field_array ][ $prefix . $_elementName ] : date($_elementKey);
|
||||
}
|
||||
$_meridian = isset($params['time'][$field_array][$prefix . 'Meridian'])
|
||||
? (' ' . $params['time'][$field_array][$prefix . 'Meridian'])
|
||||
: '';
|
||||
$_meridian = isset($params[ 'time' ][ $field_array ][ $prefix . 'Meridian' ]) ?
|
||||
(' ' . $params[ 'time' ][ $field_array ][ $prefix . 'Meridian' ]) : '';
|
||||
$time = strtotime($_hour . ':' . $_minute . ':' . $_second . $_meridian);
|
||||
list($_hour, $_minute, $_second) = $time = explode('-', date('H-i-s', $time));
|
||||
} else {
|
||||
@@ -203,9 +201,9 @@ function smarty_function_html_select_time($params)
|
||||
|
||||
$_html_hours = '<select name="' . $_name . '"';
|
||||
if ($hour_id !== null || $all_id !== null) {
|
||||
$_html_hours .= ' id="' . smarty_function_escape_special_chars(
|
||||
$hour_id !== null ? ($hour_id ? $hour_id : $_name) : ($all_id ? ($all_id . $_name) : $_name)
|
||||
) . '"';
|
||||
$_html_hours .= ' id="' .
|
||||
smarty_function_escape_special_chars($hour_id !== null ? ($hour_id ? $hour_id : $_name) :
|
||||
($all_id ? ($all_id . $_name) : $_name)) . '"';
|
||||
}
|
||||
if ($hour_size) {
|
||||
$_html_hours .= ' size="' . $hour_size . '"';
|
||||
@@ -213,7 +211,8 @@ function smarty_function_html_select_time($params)
|
||||
$_html_hours .= $_extra . $extra_attrs . '>' . $option_separator;
|
||||
|
||||
if (isset($hour_empty) || isset($all_empty)) {
|
||||
$_html_hours .= '<option value="">' . (isset($hour_empty) ? $hour_empty : $all_empty) . '</option>' . $option_separator;
|
||||
$_html_hours .= '<option value="">' . (isset($hour_empty) ? $hour_empty : $all_empty) . '</option>' .
|
||||
$option_separator;
|
||||
}
|
||||
|
||||
$start = $use_24_hours ? 0 : 1;
|
||||
@@ -224,15 +223,12 @@ function smarty_function_html_select_time($params)
|
||||
$_value = $hour_value_format == '%02d' ? $_val : sprintf($hour_value_format, $i);
|
||||
|
||||
if (!$use_24_hours) {
|
||||
$_hour12 = $_hour == 0
|
||||
? 12
|
||||
: ($_hour <= 12 ? $_hour : $_hour - 12);
|
||||
$_hour12 = $_hour == 0 ? 12 : ($_hour <= 12 ? $_hour : $_hour - 12);
|
||||
}
|
||||
|
||||
$selected = $_hour !== null ? ($use_24_hours ? $_hour == $_val : $_hour12 == $_val) : null;
|
||||
$_html_hours .= '<option value="' . $_value . '"'
|
||||
. ($selected ? ' selected="selected"' : '')
|
||||
. '>' . $_text . '</option>' . $option_separator;
|
||||
$_html_hours .= '<option value="' . $_value . '"' . ($selected ? ' selected="selected"' : '') . '>' .
|
||||
$_text . '</option>' . $option_separator;
|
||||
}
|
||||
|
||||
$_html_hours .= '</select>';
|
||||
@@ -252,9 +248,10 @@ function smarty_function_html_select_time($params)
|
||||
|
||||
$_html_minutes = '<select name="' . $_name . '"';
|
||||
if ($minute_id !== null || $all_id !== null) {
|
||||
$_html_minutes .= ' id="' . smarty_function_escape_special_chars(
|
||||
$minute_id !== null ? ($minute_id ? $minute_id : $_name) : ($all_id ? ($all_id . $_name) : $_name)
|
||||
) . '"';
|
||||
$_html_minutes .= ' id="' . smarty_function_escape_special_chars($minute_id !== null ?
|
||||
($minute_id ? $minute_id : $_name) :
|
||||
($all_id ? ($all_id . $_name) :
|
||||
$_name)) . '"';
|
||||
}
|
||||
if ($minute_size) {
|
||||
$_html_minutes .= ' size="' . $minute_size . '"';
|
||||
@@ -262,7 +259,8 @@ function smarty_function_html_select_time($params)
|
||||
$_html_minutes .= $_extra . $extra_attrs . '>' . $option_separator;
|
||||
|
||||
if (isset($minute_empty) || isset($all_empty)) {
|
||||
$_html_minutes .= '<option value="">' . (isset($minute_empty) ? $minute_empty : $all_empty) . '</option>' . $option_separator;
|
||||
$_html_minutes .= '<option value="">' . (isset($minute_empty) ? $minute_empty : $all_empty) . '</option>' .
|
||||
$option_separator;
|
||||
}
|
||||
|
||||
$selected = $_minute !== null ? ($_minute - $_minute % $minute_interval) : null;
|
||||
@@ -270,9 +268,8 @@ function smarty_function_html_select_time($params)
|
||||
$_val = sprintf('%02d', $i);
|
||||
$_text = $minute_format == '%02d' ? $_val : sprintf($minute_format, $i);
|
||||
$_value = $minute_value_format == '%02d' ? $_val : sprintf($minute_value_format, $i);
|
||||
$_html_minutes .= '<option value="' . $_value . '"'
|
||||
. ($selected === $i ? ' selected="selected"' : '')
|
||||
. '>' . $_text . '</option>' . $option_separator;
|
||||
$_html_minutes .= '<option value="' . $_value . '"' . ($selected === $i ? ' selected="selected"' : '') .
|
||||
'>' . $_text . '</option>' . $option_separator;
|
||||
}
|
||||
|
||||
$_html_minutes .= '</select>';
|
||||
@@ -292,9 +289,10 @@ function smarty_function_html_select_time($params)
|
||||
|
||||
$_html_seconds = '<select name="' . $_name . '"';
|
||||
if ($second_id !== null || $all_id !== null) {
|
||||
$_html_seconds .= ' id="' . smarty_function_escape_special_chars(
|
||||
$second_id !== null ? ($second_id ? $second_id : $_name) : ($all_id ? ($all_id . $_name) : $_name)
|
||||
) . '"';
|
||||
$_html_seconds .= ' id="' . smarty_function_escape_special_chars($second_id !== null ?
|
||||
($second_id ? $second_id : $_name) :
|
||||
($all_id ? ($all_id . $_name) :
|
||||
$_name)) . '"';
|
||||
}
|
||||
if ($second_size) {
|
||||
$_html_seconds .= ' size="' . $second_size . '"';
|
||||
@@ -302,7 +300,8 @@ function smarty_function_html_select_time($params)
|
||||
$_html_seconds .= $_extra . $extra_attrs . '>' . $option_separator;
|
||||
|
||||
if (isset($second_empty) || isset($all_empty)) {
|
||||
$_html_seconds .= '<option value="">' . (isset($second_empty) ? $second_empty : $all_empty) . '</option>' . $option_separator;
|
||||
$_html_seconds .= '<option value="">' . (isset($second_empty) ? $second_empty : $all_empty) . '</option>' .
|
||||
$option_separator;
|
||||
}
|
||||
|
||||
$selected = $_second !== null ? ($_second - $_second % $second_interval) : null;
|
||||
@@ -310,9 +309,8 @@ function smarty_function_html_select_time($params)
|
||||
$_val = sprintf('%02d', $i);
|
||||
$_text = $second_format == '%02d' ? $_val : sprintf($second_format, $i);
|
||||
$_value = $second_value_format == '%02d' ? $_val : sprintf($second_value_format, $i);
|
||||
$_html_seconds .= '<option value="' . $_value . '"'
|
||||
. ($selected === $i ? ' selected="selected"' : '')
|
||||
. '>' . $_text . '</option>' . $option_separator;
|
||||
$_html_seconds .= '<option value="' . $_value . '"' . ($selected === $i ? ' selected="selected"' : '') .
|
||||
'>' . $_text . '</option>' . $option_separator;
|
||||
}
|
||||
|
||||
$_html_seconds .= '</select>';
|
||||
@@ -332,9 +330,11 @@ function smarty_function_html_select_time($params)
|
||||
|
||||
$_html_meridian = '<select name="' . $_name . '"';
|
||||
if ($meridian_id !== null || $all_id !== null) {
|
||||
$_html_meridian .= ' id="' . smarty_function_escape_special_chars(
|
||||
$meridian_id !== null ? ($meridian_id ? $meridian_id : $_name) : ($all_id ? ($all_id . $_name) : $_name)
|
||||
) . '"';
|
||||
$_html_meridian .= ' id="' . smarty_function_escape_special_chars($meridian_id !== null ?
|
||||
($meridian_id ? $meridian_id :
|
||||
$_name) :
|
||||
($all_id ? ($all_id . $_name) :
|
||||
$_name)) . '"';
|
||||
}
|
||||
if ($meridian_size) {
|
||||
$_html_meridian .= ' size="' . $meridian_size . '"';
|
||||
@@ -342,12 +342,14 @@ function smarty_function_html_select_time($params)
|
||||
$_html_meridian .= $_extra . $extra_attrs . '>' . $option_separator;
|
||||
|
||||
if (isset($meridian_empty) || isset($all_empty)) {
|
||||
$_html_meridian .= '<option value="">' . (isset($meridian_empty) ? $meridian_empty : $all_empty) . '</option>' . $option_separator;
|
||||
$_html_meridian .= '<option value="">' . (isset($meridian_empty) ? $meridian_empty : $all_empty) .
|
||||
'</option>' . $option_separator;
|
||||
}
|
||||
|
||||
$_html_meridian .= '<option value="am"' . ($_hour > 0 && $_hour < 12 ? ' selected="selected"' : '') . '>AM</option>' . $option_separator
|
||||
. '<option value="pm"' . ($_hour < 12 ? '' : ' selected="selected"') . '>PM</option>' . $option_separator
|
||||
. '</select>';
|
||||
$_html_meridian .= '<option value="am"' . ($_hour > 0 && $_hour < 12 ? ' selected="selected"' : '') .
|
||||
'>AM</option>' . $option_separator . '<option value="pm"' .
|
||||
($_hour < 12 ? '' : ' selected="selected"') . '>PM</option>' . $option_separator .
|
||||
'</select>';
|
||||
}
|
||||
|
||||
$_html = '';
|
||||
|
@@ -62,7 +62,7 @@ function smarty_function_html_table($params)
|
||||
$caption = '';
|
||||
$loop = null;
|
||||
|
||||
if (!isset($params['loop'])) {
|
||||
if (!isset($params[ 'loop' ])) {
|
||||
trigger_error("html_table: missing 'loop' parameter", E_USER_WARNING);
|
||||
|
||||
return;
|
||||
@@ -110,11 +110,11 @@ function smarty_function_html_table($params)
|
||||
}
|
||||
|
||||
$loop_count = count($loop);
|
||||
if (empty($params['rows'])) {
|
||||
if (empty($params[ 'rows' ])) {
|
||||
/* no rows specified */
|
||||
$rows = ceil($loop_count / $cols_count);
|
||||
} elseif (empty($params['cols'])) {
|
||||
if (!empty($params['rows'])) {
|
||||
} elseif (empty($params[ 'cols' ])) {
|
||||
if (!empty($params[ 'rows' ])) {
|
||||
/* no cols specified, but rows */
|
||||
$cols_count = ceil($loop_count / $rows);
|
||||
}
|
||||
@@ -132,7 +132,7 @@ function smarty_function_html_table($params)
|
||||
|
||||
for ($r = 0; $r < $cols_count; $r ++) {
|
||||
$output .= '<th' . smarty_function_html_table_cycle('th', $th_attr, $r) . '>';
|
||||
$output .= $cols[$r];
|
||||
$output .= $cols[ $r ];
|
||||
$output .= "</th>\n";
|
||||
}
|
||||
$output .= "</tr></thead>\n";
|
||||
@@ -151,7 +151,7 @@ function smarty_function_html_table($params)
|
||||
}
|
||||
|
||||
if ($x < $loop_count) {
|
||||
$output .= "<td" . smarty_function_html_table_cycle('td', $td_attr, $c) . ">" . $loop[$x] . "</td>\n";
|
||||
$output .= "<td" . smarty_function_html_table_cycle('td', $td_attr, $c) . ">" . $loop[ $x ] . "</td>\n";
|
||||
} else {
|
||||
$output .= "<td" . smarty_function_html_table_cycle('td', $td_attr, $c) . ">$trailpad</td>\n";
|
||||
}
|
||||
@@ -169,7 +169,7 @@ function smarty_function_html_table_cycle($name, $var, $no)
|
||||
if (!is_array($var)) {
|
||||
$ret = $var;
|
||||
} else {
|
||||
$ret = $var[$no % count($var)];
|
||||
$ret = $var[ $no % count($var) ];
|
||||
}
|
||||
|
||||
return ($ret) ? ' ' . $ret : '';
|
||||
|
@@ -50,15 +50,16 @@
|
||||
*/
|
||||
function smarty_function_mailto($params)
|
||||
{
|
||||
static $_allowed_encoding = array('javascript' => true, 'javascript_charcode' => true, 'hex' => true, 'none' => true);
|
||||
static $_allowed_encoding =
|
||||
array('javascript' => true, 'javascript_charcode' => true, 'hex' => true, 'none' => true);
|
||||
$extra = '';
|
||||
|
||||
if (empty($params['address'])) {
|
||||
if (empty($params[ 'address' ])) {
|
||||
trigger_error("mailto: missing 'address' parameter", E_USER_WARNING);
|
||||
|
||||
return;
|
||||
} else {
|
||||
$address = $params['address'];
|
||||
$address = $params[ 'address' ];
|
||||
}
|
||||
|
||||
$text = $address;
|
||||
@@ -94,9 +95,10 @@ function smarty_function_mailto($params)
|
||||
$address .= '?' . join('&', $mail_parms);
|
||||
}
|
||||
|
||||
$encode = (empty($params['encode'])) ? 'none' : $params['encode'];
|
||||
if (!isset($_allowed_encoding[$encode])) {
|
||||
trigger_error("mailto: 'encode' parameter must be none, javascript, javascript_charcode or hex", E_USER_WARNING);
|
||||
$encode = (empty($params[ 'encode' ])) ? 'none' : $params[ 'encode' ];
|
||||
if (!isset($_allowed_encoding[ $encode ])) {
|
||||
trigger_error("mailto: 'encode' parameter must be none, javascript, javascript_charcode or hex",
|
||||
E_USER_WARNING);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -106,7 +108,7 @@ function smarty_function_mailto($params)
|
||||
|
||||
$js_encode = '';
|
||||
for ($x = 0, $_length = strlen($string); $x < $_length; $x ++) {
|
||||
$js_encode .= '%' . bin2hex($string[$x]);
|
||||
$js_encode .= '%' . bin2hex($string[ $x ]);
|
||||
}
|
||||
|
||||
return '<script type="text/javascript">eval(unescape(\'' . $js_encode . '\'))</script>';
|
||||
@@ -114,35 +116,31 @@ function smarty_function_mailto($params)
|
||||
$string = '<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>';
|
||||
|
||||
for ($x = 0, $y = strlen($string); $x < $y; $x ++) {
|
||||
$ord[] = ord($string[$x]);
|
||||
$ord[] = ord($string[ $x ]);
|
||||
}
|
||||
|
||||
$_ret = "<script type=\"text/javascript\" language=\"javascript\">\n"
|
||||
. "{document.write(String.fromCharCode("
|
||||
. implode(',', $ord)
|
||||
. "))"
|
||||
. "}\n"
|
||||
. "</script>\n";
|
||||
$_ret = "<script type=\"text/javascript\" language=\"javascript\">\n" . "{document.write(String.fromCharCode(" .
|
||||
implode(',', $ord) . "))" . "}\n" . "</script>\n";
|
||||
|
||||
return $_ret;
|
||||
} elseif ($encode == 'hex') {
|
||||
preg_match('!^(.*)(\?.*)$!', $address, $match);
|
||||
if (!empty($match[2])) {
|
||||
if (!empty($match[ 2 ])) {
|
||||
trigger_error("mailto: hex encoding does not work with extra attributes. Try javascript.", E_USER_WARNING);
|
||||
|
||||
return;
|
||||
}
|
||||
$address_encode = '';
|
||||
for ($x = 0, $_length = strlen($address); $x < $_length; $x ++) {
|
||||
if (preg_match('!\w!' . Smarty::$_UTF8_MODIFIER, $address[$x])) {
|
||||
$address_encode .= '%' . bin2hex($address[$x]);
|
||||
if (preg_match('!\w!' . Smarty::$_UTF8_MODIFIER, $address[ $x ])) {
|
||||
$address_encode .= '%' . bin2hex($address[ $x ]);
|
||||
} else {
|
||||
$address_encode .= $address[$x];
|
||||
$address_encode .= $address[ $x ];
|
||||
}
|
||||
}
|
||||
$text_encode = '';
|
||||
for ($x = 0, $_length = strlen($text); $x < $_length; $x ++) {
|
||||
$text_encode .= '&#x' . bin2hex($text[$x]) . ';';
|
||||
$text_encode .= '&#x' . bin2hex($text[ $x ]) . ';';
|
||||
}
|
||||
|
||||
$mailto = "mailto:";
|
||||
|
@@ -24,19 +24,18 @@
|
||||
*/
|
||||
function smarty_function_math($params, $template)
|
||||
{
|
||||
static $_allowed_funcs = array(
|
||||
'int' => 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
|
||||
);
|
||||
static $_allowed_funcs =
|
||||
array('int' => 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
|
||||
if (empty($params['equation'])) {
|
||||
if (empty($params[ 'equation' ])) {
|
||||
trigger_error("math: missing equation parameter", E_USER_WARNING);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$equation = $params['equation'];
|
||||
$equation = $params[ 'equation' ];
|
||||
|
||||
// make sure parenthesis are balanced
|
||||
if (substr_count($equation, "(") != substr_count($equation, ")")) {
|
||||
@@ -48,8 +47,8 @@ function smarty_function_math($params, $template)
|
||||
// match all vars in equation, make sure all are passed
|
||||
preg_match_all("!(?:0x[a-fA-F0-9]+)|([a-zA-Z][a-zA-Z0-9_]*)!", $equation, $match);
|
||||
|
||||
foreach ($match[1] as $curr_var) {
|
||||
if ($curr_var && !isset($params[$curr_var]) && !isset($_allowed_funcs[$curr_var])) {
|
||||
foreach ($match[ 1 ] as $curr_var) {
|
||||
if ($curr_var && !isset($params[ $curr_var ]) && !isset($_allowed_funcs[ $curr_var ])) {
|
||||
trigger_error("math: function call $curr_var not allowed", E_USER_WARNING);
|
||||
|
||||
return;
|
||||
@@ -75,17 +74,17 @@ function smarty_function_math($params, $template)
|
||||
$smarty_math_result = null;
|
||||
eval("\$smarty_math_result = " . $equation . ";");
|
||||
|
||||
if (empty($params['format'])) {
|
||||
if (empty($params['assign'])) {
|
||||
if (empty($params[ 'format' ])) {
|
||||
if (empty($params[ 'assign' ])) {
|
||||
return $smarty_math_result;
|
||||
} else {
|
||||
$template->assign($params['assign'], $smarty_math_result);
|
||||
$template->assign($params[ 'assign' ], $smarty_math_result);
|
||||
}
|
||||
} else {
|
||||
if (empty($params['assign'])) {
|
||||
printf($params['format'], $smarty_math_result);
|
||||
if (empty($params[ 'assign' ])) {
|
||||
printf($params[ 'format' ], $smarty_math_result);
|
||||
} else {
|
||||
$template->assign($params['assign'], sprintf($params['format'], $smarty_math_result));
|
||||
$template->assign($params[ 'assign' ], sprintf($params[ 'format' ], $smarty_math_result));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -29,17 +29,23 @@ function smarty_modifier_capitalize($string, $uc_digits = false, $lc_rest = fals
|
||||
$upper_string = mb_convert_case($string, MB_CASE_TITLE, Smarty::$_CHARSET);
|
||||
} else {
|
||||
// uppercase word breaks
|
||||
$upper_string = preg_replace_callback("!(^|[^\p{L}'])([\p{Ll}])!S" . Smarty::$_UTF8_MODIFIER, 'smarty_mod_cap_mbconvert_cb', $string);
|
||||
$upper_string = preg_replace_callback("!(^|[^\p{L}'])([\p{Ll}])!S" . Smarty::$_UTF8_MODIFIER,
|
||||
'smarty_mod_cap_mbconvert_cb', $string);
|
||||
}
|
||||
// check uc_digits case
|
||||
if (!$uc_digits) {
|
||||
if (preg_match_all("!\b([\p{L}]*[\p{N}]+[\p{L}]*)\b!" . Smarty::$_UTF8_MODIFIER, $string, $matches, PREG_OFFSET_CAPTURE)) {
|
||||
foreach ($matches[1] as $match) {
|
||||
$upper_string = substr_replace($upper_string, mb_strtolower($match[0], Smarty::$_CHARSET), $match[1], strlen($match[0]));
|
||||
if (preg_match_all("!\b([\p{L}]*[\p{N}]+[\p{L}]*)\b!" . Smarty::$_UTF8_MODIFIER, $string, $matches,
|
||||
PREG_OFFSET_CAPTURE)) {
|
||||
foreach ($matches[ 1 ] as $match) {
|
||||
$upper_string =
|
||||
substr_replace($upper_string, mb_strtolower($match[ 0 ], Smarty::$_CHARSET), $match[ 1 ],
|
||||
strlen($match[ 0 ]));
|
||||
}
|
||||
}
|
||||
}
|
||||
$upper_string = preg_replace_callback("!((^|\s)['\"])(\w)!" . Smarty::$_UTF8_MODIFIER, 'smarty_mod_cap_mbconvert2_cb', $upper_string);
|
||||
$upper_string =
|
||||
preg_replace_callback("!((^|\s)['\"])(\w)!" . Smarty::$_UTF8_MODIFIER, 'smarty_mod_cap_mbconvert2_cb',
|
||||
$upper_string);
|
||||
return $upper_string;
|
||||
}
|
||||
|
||||
@@ -48,16 +54,21 @@ function smarty_modifier_capitalize($string, $uc_digits = false, $lc_rest = fals
|
||||
$string = strtolower($string);
|
||||
}
|
||||
// uppercase (including hyphenated words)
|
||||
$upper_string = preg_replace_callback("!(^|[^\p{L}'])([\p{Ll}])!S" . Smarty::$_UTF8_MODIFIER, 'smarty_mod_cap_ucfirst_cb', $string);
|
||||
$upper_string =
|
||||
preg_replace_callback("!(^|[^\p{L}'])([\p{Ll}])!S" . Smarty::$_UTF8_MODIFIER, 'smarty_mod_cap_ucfirst_cb',
|
||||
$string);
|
||||
// check uc_digits case
|
||||
if (!$uc_digits) {
|
||||
if (preg_match_all("!\b([\p{L}]*[\p{N}]+[\p{L}]*)\b!" . Smarty::$_UTF8_MODIFIER, $string, $matches, PREG_OFFSET_CAPTURE)) {
|
||||
foreach ($matches[1] as $match) {
|
||||
$upper_string = substr_replace($upper_string, strtolower($match[0]), $match[1], strlen($match[0]));
|
||||
if (preg_match_all("!\b([\p{L}]*[\p{N}]+[\p{L}]*)\b!" . Smarty::$_UTF8_MODIFIER, $string, $matches,
|
||||
PREG_OFFSET_CAPTURE)) {
|
||||
foreach ($matches[ 1 ] as $match) {
|
||||
$upper_string =
|
||||
substr_replace($upper_string, strtolower($match[ 0 ]), $match[ 1 ], strlen($match[ 0 ]));
|
||||
}
|
||||
}
|
||||
}
|
||||
$upper_string = preg_replace_callback("!((^|\s)['\"])(\w)!" . Smarty::$_UTF8_MODIFIER, 'smarty_mod_cap_ucfirst2_cb', $upper_string);
|
||||
$upper_string = preg_replace_callback("!((^|\s)['\"])(\w)!" . Smarty::$_UTF8_MODIFIER, 'smarty_mod_cap_ucfirst2_cb',
|
||||
$upper_string);
|
||||
return $upper_string;
|
||||
}
|
||||
|
||||
@@ -71,20 +82,20 @@ function smarty_modifier_capitalize($string, $uc_digits = false, $lc_rest = fals
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
function smarty_mod_cap_ucfirst_cb($matches)
|
||||
{
|
||||
return stripslashes($matches[1]) . ucfirst(stripslashes($matches[2]));
|
||||
return stripslashes($matches[ 1 ]) . ucfirst(stripslashes($matches[ 2 ]));
|
||||
}
|
||||
|
||||
function smarty_mod_cap_ucfirst2_cb($matches)
|
||||
{
|
||||
return stripslashes($matches[1]) . ucfirst(stripslashes($matches[3]));
|
||||
return stripslashes($matches[ 1 ]) . ucfirst(stripslashes($matches[ 3 ]));
|
||||
}
|
||||
|
@@ -33,7 +33,8 @@ function smarty_modifier_debug_print_var($var, $max = 10, $length = 40, $depth =
|
||||
}
|
||||
foreach ($var as $curr_key => $curr_val) {
|
||||
$results .= '<br>' . str_repeat(' ', $depth * 2) . '<b>' . strtr($curr_key, $_replace) .
|
||||
'</b> => ' . smarty_modifier_debug_print_var($curr_val, $max, $length, ++ $depth, $objects);
|
||||
'</b> => ' .
|
||||
smarty_modifier_debug_print_var($curr_val, $max, $length, ++ $depth, $objects);
|
||||
$depth --;
|
||||
}
|
||||
break;
|
||||
|
@@ -66,7 +66,8 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
|
||||
// php <5.2.3 - prevent double encoding
|
||||
$string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string);
|
||||
$string = htmlspecialchars($string, ENT_QUOTES, $char_set);
|
||||
$string = str_replace(array('%%%SMARTY_START%%%', '%%%SMARTY_END%%%'), array('&', ';'), $string);
|
||||
$string =
|
||||
str_replace(array('%%%SMARTY_START%%%', '%%%SMARTY_END%%%'), array('&', ';'), $string);
|
||||
|
||||
return $string;
|
||||
}
|
||||
@@ -107,7 +108,7 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
|
||||
$return = '';
|
||||
$_length = strlen($string);
|
||||
for ($x = 0; $x < $_length; $x ++) {
|
||||
$return .= '%' . bin2hex($string[$x]);
|
||||
$return .= '%' . bin2hex($string[ $x ]);
|
||||
}
|
||||
|
||||
return $return;
|
||||
@@ -126,7 +127,7 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
|
||||
// no MBString fallback
|
||||
$_length = strlen($string);
|
||||
for ($x = 0; $x < $_length; $x ++) {
|
||||
$return .= '&#x' . bin2hex($string[$x]) . ';';
|
||||
$return .= '&#x' . bin2hex($string[ $x ]) . ';';
|
||||
}
|
||||
|
||||
return $return;
|
||||
@@ -145,14 +146,15 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
|
||||
// no MBString fallback
|
||||
$_length = strlen($string);
|
||||
for ($x = 0; $x < $_length; $x ++) {
|
||||
$return .= '&#' . ord($string[$x]) . ';';
|
||||
$return .= '&#' . ord($string[ $x ]) . ';';
|
||||
}
|
||||
|
||||
return $return;
|
||||
|
||||
case 'javascript':
|
||||
// escape quotes and backslashes, newlines, etc.
|
||||
return strtr($string, array('\\' => '\\\\', "'" => "\\'", '"' => '\\"', "\r" => '\\r', "\n" => '\\n', '</' => '<\/'));
|
||||
return strtr($string, array('\\' => '\\\\', "'" => "\\'", '"' => '\\"', "\r" => '\\r', "\n" => '\\n',
|
||||
'</' => '<\/'));
|
||||
|
||||
case 'mail':
|
||||
if (Smarty::$_MBSTRING) {
|
||||
|
@@ -23,11 +23,11 @@
|
||||
*
|
||||
* @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)) {
|
||||
foreach ($search as $idx => $s) {
|
||||
$search[$idx] = _smarty_regex_replace_check($s);
|
||||
$search[ $idx ] = _smarty_regex_replace_check($s);
|
||||
}
|
||||
} else {
|
||||
$search = _smarty_regex_replace_check($search);
|
||||
@@ -50,8 +50,8 @@ function _smarty_regex_replace_check($search)
|
||||
$search = substr($search, 0, $pos);
|
||||
}
|
||||
// remove eval-modifier from $search
|
||||
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]);
|
||||
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 ]);
|
||||
}
|
||||
|
||||
return $search;
|
||||
|
@@ -35,20 +35,22 @@ function smarty_modifier_truncate($string, $length = 80, $etc = '...', $break_wo
|
||||
if (mb_strlen($string, Smarty::$_CHARSET) > $length) {
|
||||
$length -= min($length, mb_strlen($etc, Smarty::$_CHARSET));
|
||||
if (!$break_words && !$middle) {
|
||||
$string = preg_replace('/\s+?(\S+)?$/' . Smarty::$_UTF8_MODIFIER, '', mb_substr($string, 0, $length + 1, Smarty::$_CHARSET));
|
||||
$string = preg_replace('/\s+?(\S+)?$/' . Smarty::$_UTF8_MODIFIER, '',
|
||||
mb_substr($string, 0, $length + 1, Smarty::$_CHARSET));
|
||||
}
|
||||
if (!$middle) {
|
||||
return mb_substr($string, 0, $length, Smarty::$_CHARSET) . $etc;
|
||||
}
|
||||
|
||||
return mb_substr($string, 0, $length / 2, Smarty::$_CHARSET) . $etc . mb_substr($string, - $length / 2, $length, Smarty::$_CHARSET);
|
||||
return mb_substr($string, 0, $length / 2, Smarty::$_CHARSET) . $etc .
|
||||
mb_substr($string, - $length / 2, $length, Smarty::$_CHARSET);
|
||||
}
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
// no MBString fallback
|
||||
if (isset($string[$length])) {
|
||||
if (isset($string[ $length ])) {
|
||||
$length -= min($length, strlen($etc));
|
||||
if (!$break_words && !$middle) {
|
||||
$string = preg_replace('/\s+?(\S+)?$/', '', substr($string, 0, $length + 1));
|
||||
|
@@ -21,12 +21,12 @@
|
||||
*/
|
||||
function smarty_modifiercompiler_count_characters($params)
|
||||
{
|
||||
if (!isset($params[1]) || $params[1] != 'true') {
|
||||
return 'preg_match_all(\'/[^\s]/' . Smarty::$_UTF8_MODIFIER . '\',' . $params[0] . ', $tmp)';
|
||||
if (!isset($params[ 1 ]) || $params[ 1 ] != 'true') {
|
||||
return 'preg_match_all(\'/[^\s]/' . Smarty::$_UTF8_MODIFIER . '\',' . $params[ 0 ] . ', $tmp)';
|
||||
}
|
||||
if (Smarty::$_MBSTRING) {
|
||||
return 'mb_strlen(' . $params[0] . ', \'' . addslashes(Smarty::$_CHARSET) . '\')';
|
||||
return 'mb_strlen(' . $params[ 0 ] . ', \'' . addslashes(Smarty::$_CHARSET) . '\')';
|
||||
}
|
||||
// no MBString fallback
|
||||
return 'strlen(' . $params[0] . ')';
|
||||
return 'strlen(' . $params[ 0 ] . ')';
|
||||
}
|
||||
|
@@ -23,5 +23,5 @@
|
||||
function smarty_modifiercompiler_count_paragraphs($params)
|
||||
{
|
||||
// count \r or \n characters
|
||||
return '(preg_match_all(\'#[\r\n]+#\', ' . $params[0] . ', $tmp)+1)';
|
||||
return '(preg_match_all(\'#[\r\n]+#\', ' . $params[ 0 ] . ', $tmp)+1)';
|
||||
}
|
||||
|
@@ -23,5 +23,5 @@
|
||||
function smarty_modifiercompiler_count_sentences($params)
|
||||
{
|
||||
// find periods, question marks, exclamation marks with a word before but not after.
|
||||
return 'preg_match_all("#\w[\.\?\!](\W|$)#S' . Smarty::$_UTF8_MODIFIER . '", ' . $params[0] . ', $tmp)';
|
||||
return 'preg_match_all("#\w[\.\?\!](\W|$)#S' . Smarty::$_UTF8_MODIFIER . '", ' . $params[ 0 ] . ', $tmp)';
|
||||
}
|
||||
|
@@ -24,8 +24,9 @@ function smarty_modifiercompiler_count_words($params)
|
||||
if (Smarty::$_MBSTRING) {
|
||||
// return 'preg_match_all(\'#[\w\pL]+#' . Smarty::$_UTF8_MODIFIER . '\', ' . $params[0] . ', $tmp)';
|
||||
// expression taken from http://de.php.net/manual/en/function.str-word-count.php#85592
|
||||
return 'preg_match_all(\'/\p{L}[\p{L}\p{Mn}\p{Pd}\\\'\x{2019}]*/' . Smarty::$_UTF8_MODIFIER . '\', ' . $params[0] . ', $tmp)';
|
||||
return 'preg_match_all(\'/\p{L}[\p{L}\p{Mn}\p{Pd}\\\'\x{2019}]*/' . Smarty::$_UTF8_MODIFIER . '\', ' .
|
||||
$params[ 0 ] . ', $tmp)';
|
||||
}
|
||||
// no MBString fallback
|
||||
return 'str_word_count(' . $params[0] . ')';
|
||||
return 'str_word_count(' . $params[ 0 ] . ')';
|
||||
}
|
||||
|
@@ -21,9 +21,9 @@
|
||||
*/
|
||||
function smarty_modifiercompiler_default($params)
|
||||
{
|
||||
$output = $params[0];
|
||||
if (!isset($params[1])) {
|
||||
$params[1] = "''";
|
||||
$output = $params[ 0 ];
|
||||
if (!isset($params[ 1 ])) {
|
||||
$params[ 1 ] = "''";
|
||||
}
|
||||
|
||||
array_shift($params);
|
||||
|
@@ -44,14 +44,10 @@ function smarty_modifiercompiler_escape($params, $compiler)
|
||||
switch ($esc_type) {
|
||||
case 'html':
|
||||
if ($_double_encode) {
|
||||
return 'htmlspecialchars('
|
||||
. $params[0] . ', ENT_QUOTES, '
|
||||
. var_export($char_set, true) . ', '
|
||||
. var_export($double_encode, true) . ')';
|
||||
return 'htmlspecialchars(' . $params[ 0 ] . ', ENT_QUOTES, ' . var_export($char_set, true) . ', ' .
|
||||
var_export($double_encode, true) . ')';
|
||||
} elseif ($double_encode) {
|
||||
return 'htmlspecialchars('
|
||||
. $params[0] . ', ENT_QUOTES, '
|
||||
. var_export($char_set, true) . ')';
|
||||
return 'htmlspecialchars(' . $params[ 0 ] . ', ENT_QUOTES, ' . var_export($char_set, true) . ')';
|
||||
} else {
|
||||
// fall back to modifier.escape.php
|
||||
}
|
||||
@@ -60,19 +56,13 @@ function smarty_modifiercompiler_escape($params, $compiler)
|
||||
if (Smarty::$_MBSTRING) {
|
||||
if ($_double_encode) {
|
||||
// php >=5.2.3 - go native
|
||||
return 'mb_convert_encoding(htmlspecialchars('
|
||||
. $params[0] . ', ENT_QUOTES, '
|
||||
. var_export($char_set, true) . ', '
|
||||
. var_export($double_encode, true)
|
||||
. '), "HTML-ENTITIES", '
|
||||
. var_export($char_set, true) . ')';
|
||||
return 'mb_convert_encoding(htmlspecialchars(' . $params[ 0 ] . ', ENT_QUOTES, ' .
|
||||
var_export($char_set, true) . ', ' . var_export($double_encode, true) .
|
||||
'), "HTML-ENTITIES", ' . var_export($char_set, true) . ')';
|
||||
} elseif ($double_encode) {
|
||||
// php <5.2.3 - only handle double encoding
|
||||
return 'mb_convert_encoding(htmlspecialchars('
|
||||
. $params[0] . ', ENT_QUOTES, '
|
||||
. var_export($char_set, true)
|
||||
. '), "HTML-ENTITIES", '
|
||||
. var_export($char_set, true) . ')';
|
||||
return 'mb_convert_encoding(htmlspecialchars(' . $params[ 0 ] . ', ENT_QUOTES, ' .
|
||||
var_export($char_set, true) . '), "HTML-ENTITIES", ' . var_export($char_set, true) . ')';
|
||||
} else {
|
||||
// fall back to modifier.escape.php
|
||||
}
|
||||
@@ -81,32 +71,29 @@ function smarty_modifiercompiler_escape($params, $compiler)
|
||||
// no MBString fallback
|
||||
if ($_double_encode) {
|
||||
// php >=5.2.3 - go native
|
||||
return 'htmlentities('
|
||||
. $params[0] . ', ENT_QUOTES, '
|
||||
. var_export($char_set, true) . ', '
|
||||
. var_export($double_encode, true) . ')';
|
||||
return 'htmlentities(' . $params[ 0 ] . ', ENT_QUOTES, ' . var_export($char_set, true) . ', ' .
|
||||
var_export($double_encode, true) . ')';
|
||||
} elseif ($double_encode) {
|
||||
// php <5.2.3 - only handle double encoding
|
||||
return 'htmlentities('
|
||||
. $params[0] . ', ENT_QUOTES, '
|
||||
. var_export($char_set, true) . ')';
|
||||
return 'htmlentities(' . $params[ 0 ] . ', ENT_QUOTES, ' . var_export($char_set, true) . ')';
|
||||
} else {
|
||||
// fall back to modifier.escape.php
|
||||
}
|
||||
|
||||
case 'url':
|
||||
return 'rawurlencode(' . $params[0] . ')';
|
||||
return 'rawurlencode(' . $params[ 0 ] . ')';
|
||||
|
||||
case 'urlpathinfo':
|
||||
return 'str_replace("%2F", "/", rawurlencode(' . $params[0] . '))';
|
||||
return 'str_replace("%2F", "/", rawurlencode(' . $params[ 0 ] . '))';
|
||||
|
||||
case 'quotes':
|
||||
// escape unescaped single quotes
|
||||
return 'preg_replace("%(?<!\\\\\\\\)\'%", "\\\'",' . $params[0] . ')';
|
||||
return 'preg_replace("%(?<!\\\\\\\\)\'%", "\\\'",' . $params[ 0 ] . ')';
|
||||
|
||||
case 'javascript':
|
||||
// escape quotes and backslashes, newlines, etc.
|
||||
return 'strtr(' . $params[0] . ', array("\\\\" => "\\\\\\\\", "\'" => "\\\\\'", "\"" => "\\\\\"", "\\r" => "\\\\r", "\\n" => "\\\n", "</" => "<\/" ))';
|
||||
return 'strtr(' . $params[ 0 ] .
|
||||
', array("\\\\" => "\\\\\\\\", "\'" => "\\\\\'", "\"" => "\\\\\"", "\\r" => "\\\\r", "\\n" => "\\\n", "</" => "<\/" ))';
|
||||
}
|
||||
}
|
||||
catch (SmartyException $e) {
|
||||
@@ -115,11 +102,15 @@ function smarty_modifiercompiler_escape($params, $compiler)
|
||||
|
||||
// could not optimize |escape call, so fallback to regular plugin
|
||||
if ($compiler->template->caching && ($compiler->tag_nocache | $compiler->nocache)) {
|
||||
$compiler->parent_compiler->template->compiled->required_plugins['nocache']['escape']['modifier']['file'] = SMARTY_PLUGINS_DIR . 'modifier.escape.php';
|
||||
$compiler->parent_compiler->template->compiled->required_plugins['nocache']['escape']['modifier']['function'] = 'smarty_modifier_escape';
|
||||
$compiler->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ 'escape' ][ 'modifier' ][ 'file' ] =
|
||||
SMARTY_PLUGINS_DIR . 'modifier.escape.php';
|
||||
$compiler->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ 'escape' ][ 'modifier' ][ 'function' ] =
|
||||
'smarty_modifier_escape';
|
||||
} else {
|
||||
$compiler->parent_compiler->template->compiled->required_plugins['compiled']['escape']['modifier']['file'] = SMARTY_PLUGINS_DIR . 'modifier.escape.php';
|
||||
$compiler->parent_compiler->template->compiled->required_plugins['compiled']['escape']['modifier']['function'] = 'smarty_modifier_escape';
|
||||
$compiler->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ 'escape' ][ 'modifier' ][ 'file' ] =
|
||||
SMARTY_PLUGINS_DIR . 'modifier.escape.php';
|
||||
$compiler->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ 'escape' ][ 'modifier' ][ 'function' ] =
|
||||
'smarty_modifier_escape';
|
||||
}
|
||||
|
||||
return 'smarty_modifier_escape(' . join(', ', $params) . ')';
|
||||
|
@@ -22,12 +22,12 @@ function smarty_modifiercompiler_from_charset($params)
|
||||
{
|
||||
if (!Smarty::$_MBSTRING) {
|
||||
// FIXME: (rodneyrehm) shouldn't this throw an error?
|
||||
return $params[0];
|
||||
return $params[ 0 ];
|
||||
}
|
||||
|
||||
if (!isset($params[1])) {
|
||||
$params[1] = '"ISO-8859-1"';
|
||||
if (!isset($params[ 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 ] . ')';
|
||||
}
|
||||
|
@@ -22,12 +22,12 @@
|
||||
|
||||
function smarty_modifiercompiler_indent($params)
|
||||
{
|
||||
if (!isset($params[1])) {
|
||||
$params[1] = 4;
|
||||
if (!isset($params[ 1 ])) {
|
||||
$params[ 1 ] = 4;
|
||||
}
|
||||
if (!isset($params[2])) {
|
||||
$params[2] = "' '";
|
||||
if (!isset($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 ] . ')';
|
||||
}
|
||||
|
@@ -24,8 +24,8 @@
|
||||
function smarty_modifiercompiler_lower($params)
|
||||
{
|
||||
if (Smarty::$_MBSTRING) {
|
||||
return 'mb_strtolower(' . $params[0] . ', \'' . addslashes(Smarty::$_CHARSET) . '\')';
|
||||
return 'mb_strtolower(' . $params[ 0 ] . ', \'' . addslashes(Smarty::$_CHARSET) . '\')';
|
||||
}
|
||||
// no MBString fallback
|
||||
return 'strtolower(' . $params[0] . ')';
|
||||
return 'strtolower(' . $params[ 0 ] . ')';
|
||||
}
|
||||
|
@@ -21,5 +21,5 @@
|
||||
*/
|
||||
function smarty_modifiercompiler_string_format($params)
|
||||
{
|
||||
return 'sprintf(' . $params[1] . ',' . $params[0] . ')';
|
||||
return 'sprintf(' . $params[ 1 ] . ',' . $params[ 0 ] . ')';
|
||||
}
|
||||
|
@@ -25,8 +25,8 @@
|
||||
|
||||
function smarty_modifiercompiler_strip($params)
|
||||
{
|
||||
if (!isset($params[1])) {
|
||||
$params[1] = "' '";
|
||||
if (!isset($params[ 1 ])) {
|
||||
$params[ 1 ] = "' '";
|
||||
}
|
||||
|
||||
return "preg_replace('!\s+!" . Smarty::$_UTF8_MODIFIER . "', {$params[1]},{$params[0]})";
|
||||
|
@@ -21,9 +21,9 @@
|
||||
*/
|
||||
function smarty_modifiercompiler_strip_tags($params)
|
||||
{
|
||||
if (!isset($params[1]) || $params[1] === true || trim($params[1], '"') == 'true') {
|
||||
if (!isset($params[ 1 ]) || $params[ 1 ] === true || trim($params[ 1 ], '"') == 'true') {
|
||||
return "preg_replace('!<[^>]*?>!', ' ', {$params[0]})";
|
||||
} else {
|
||||
return 'strip_tags(' . $params[0] . ')';
|
||||
return 'strip_tags(' . $params[ 0 ] . ')';
|
||||
}
|
||||
}
|
||||
|
@@ -22,12 +22,12 @@ function smarty_modifiercompiler_to_charset($params)
|
||||
{
|
||||
if (!Smarty::$_MBSTRING) {
|
||||
// FIXME: (rodneyrehm) shouldn't this throw an error?
|
||||
return $params[0];
|
||||
return $params[ 0 ];
|
||||
}
|
||||
|
||||
if (!isset($params[1])) {
|
||||
$params[1] = '"ISO-8859-1"';
|
||||
if (!isset($params[ 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) . '")';
|
||||
}
|
||||
|
@@ -20,31 +20,31 @@
|
||||
*/
|
||||
function smarty_modifiercompiler_unescape($params)
|
||||
{
|
||||
if (!isset($params[1])) {
|
||||
$params[1] = 'html';
|
||||
if (!isset($params[ 1 ])) {
|
||||
$params[ 1 ] = 'html';
|
||||
}
|
||||
if (!isset($params[2])) {
|
||||
$params[2] = '\'' . addslashes(Smarty::$_CHARSET) . '\'';
|
||||
if (!isset($params[ 2 ])) {
|
||||
$params[ 2 ] = '\'' . addslashes(Smarty::$_CHARSET) . '\'';
|
||||
} else {
|
||||
$params[2] = "'" . $params[2] . "'";
|
||||
$params[ 2 ] = "'" . $params[ 2 ] . "'";
|
||||
}
|
||||
|
||||
switch (trim($params[1], '"\'')) {
|
||||
switch (trim($params[ 1 ], '"\'')) {
|
||||
case 'entity':
|
||||
case 'htmlall':
|
||||
if (Smarty::$_MBSTRING) {
|
||||
return 'mb_convert_encoding(' . $params[0] . ', ' . $params[2] . ', \'HTML-ENTITIES\')';
|
||||
return 'mb_convert_encoding(' . $params[ 0 ] . ', ' . $params[ 2 ] . ', \'HTML-ENTITIES\')';
|
||||
}
|
||||
|
||||
return 'html_entity_decode(' . $params[0] . ', ENT_NOQUOTES, ' . $params[2] . ')';
|
||||
return 'html_entity_decode(' . $params[ 0 ] . ', ENT_NOQUOTES, ' . $params[ 2 ] . ')';
|
||||
|
||||
case 'html':
|
||||
return 'htmlspecialchars_decode(' . $params[0] . ', ENT_QUOTES)';
|
||||
return 'htmlspecialchars_decode(' . $params[ 0 ] . ', ENT_QUOTES)';
|
||||
|
||||
case 'url':
|
||||
return 'rawurldecode(' . $params[0] . ')';
|
||||
return 'rawurldecode(' . $params[ 0 ] . ')';
|
||||
|
||||
default:
|
||||
return $params[0];
|
||||
return $params[ 0 ];
|
||||
}
|
||||
}
|
||||
|
@@ -22,8 +22,8 @@
|
||||
function smarty_modifiercompiler_upper($params)
|
||||
{
|
||||
if (Smarty::$_MBSTRING) {
|
||||
return 'mb_strtoupper(' . $params[0] . ', \'' . addslashes(Smarty::$_CHARSET) . '\')';
|
||||
return 'mb_strtoupper(' . $params[ 0 ] . ', \'' . addslashes(Smarty::$_CHARSET) . '\')';
|
||||
}
|
||||
// no MBString fallback
|
||||
return 'strtoupper(' . $params[0] . ')';
|
||||
return 'strtoupper(' . $params[ 0 ] . ')';
|
||||
}
|
||||
|
@@ -22,26 +22,30 @@
|
||||
*/
|
||||
function smarty_modifiercompiler_wordwrap($params, $compiler)
|
||||
{
|
||||
if (!isset($params[1])) {
|
||||
$params[1] = 80;
|
||||
if (!isset($params[ 1 ])) {
|
||||
$params[ 1 ] = 80;
|
||||
}
|
||||
if (!isset($params[2])) {
|
||||
$params[2] = '"\n"';
|
||||
if (!isset($params[ 2 ])) {
|
||||
$params[ 2 ] = '"\n"';
|
||||
}
|
||||
if (!isset($params[3])) {
|
||||
$params[3] = 'false';
|
||||
if (!isset($params[ 3 ])) {
|
||||
$params[ 3 ] = 'false';
|
||||
}
|
||||
$function = 'wordwrap';
|
||||
if (Smarty::$_MBSTRING) {
|
||||
if ($compiler->template->caching && ($compiler->tag_nocache | $compiler->nocache)) {
|
||||
$compiler->parent_compiler->template->compiled->required_plugins['nocache']['wordwrap']['modifier']['file'] = SMARTY_PLUGINS_DIR . 'shared.mb_wordwrap.php';
|
||||
$compiler->template->required_plugins['nocache']['wordwrap']['modifier']['function'] = 'smarty_mb_wordwrap';
|
||||
$compiler->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ 'wordwrap' ][ 'modifier' ][ 'file' ] =
|
||||
SMARTY_PLUGINS_DIR . 'shared.mb_wordwrap.php';
|
||||
$compiler->template->required_plugins[ 'nocache' ][ 'wordwrap' ][ 'modifier' ][ 'function' ] =
|
||||
'smarty_mb_wordwrap';
|
||||
} else {
|
||||
$compiler->parent_compiler->template->compiled->required_plugins['compiled']['wordwrap']['modifier']['file'] = SMARTY_PLUGINS_DIR . 'shared.mb_wordwrap.php';
|
||||
$compiler->parent_compiler->template->compiled->required_plugins['compiled']['wordwrap']['modifier']['function'] = 'smarty_mb_wordwrap';
|
||||
$compiler->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ 'wordwrap' ][ 'modifier' ][ 'file' ] =
|
||||
SMARTY_PLUGINS_DIR . 'shared.mb_wordwrap.php';
|
||||
$compiler->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ 'wordwrap' ][ 'modifier' ][ 'function' ] =
|
||||
'smarty_mb_wordwrap';
|
||||
}
|
||||
$function = 'smarty_mb_wordwrap';
|
||||
}
|
||||
|
||||
return $function . '(' . $params[0] . ',' . $params[1] . ',' . $params[2] . ',' . $params[3] . ')';
|
||||
return $function . '(' . $params[ 0 ] . ',' . $params[ 1 ] . ',' . $params[ 2 ] . ',' . $params[ 3 ] . ')';
|
||||
}
|
||||
|
@@ -27,12 +27,13 @@ function smarty_outputfilter_trimwhitespace($source)
|
||||
$source = preg_replace("/\015\012|\015|\012/", "\n", $source);
|
||||
|
||||
// capture Internet Explorer Conditional Comments
|
||||
if (preg_match_all('#<!--\[[^\]]+\]>.*?<!\[[^\]]+\]-->#is', $source, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) {
|
||||
if (preg_match_all('#<!--\[[^\]]+\]>.*?<!\[[^\]]+\]-->#is', $source, $matches,
|
||||
PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) {
|
||||
foreach ($matches as $match) {
|
||||
$store[] = $match[0][0];
|
||||
$_length = strlen($match[0][0]);
|
||||
$store[] = $match[ 0 ][ 0 ];
|
||||
$_length = strlen($match[ 0 ][ 0 ]);
|
||||
$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);
|
||||
$_store ++;
|
||||
@@ -45,29 +46,27 @@ function smarty_outputfilter_trimwhitespace($source)
|
||||
|
||||
// capture html elements not to be messed with
|
||||
$_offset = 0;
|
||||
if (preg_match_all('#(<script[^>]*>.*?</script[^>]*>)|(<textarea[^>]*>.*?</textarea[^>]*>)|(<pre[^>]*>.*?</pre[^>]*>)#is', $source, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) {
|
||||
if (preg_match_all('#(<script[^>]*>.*?</script[^>]*>)|(<textarea[^>]*>.*?</textarea[^>]*>)|(<pre[^>]*>.*?</pre[^>]*>)#is',
|
||||
$source, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) {
|
||||
foreach ($matches as $match) {
|
||||
$store[] = $match[0][0];
|
||||
$_length = strlen($match[0][0]);
|
||||
$store[] = $match[ 0 ][ 0 ];
|
||||
$_length = strlen($match[ 0 ][ 0 ]);
|
||||
$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);
|
||||
$_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
|
||||
'#(:SMARTY@!@|>)\s+(?=@!@SMARTY:|<)#s' => '\1 \2',
|
||||
// remove spaces between attributes (but not in attribute values!)
|
||||
'#(([a-z0-9]\s*=\s*("[^"]*?")|(\'[^\']*?\'))|<[a-z0-9_]+)\s+([a-z/>])#is' => '\1 \5',
|
||||
// note: for some very weird reason trim() seems to remove spaces inside attributes.
|
||||
// maybe a \0 byte or something is interfering?
|
||||
'#^\s+<#Ss' => '<',
|
||||
'#>\s+$#Ss' => '>',
|
||||
);
|
||||
'#^\s+<#Ss' => '<', '#>\s+$#Ss' => '>',);
|
||||
|
||||
$source = preg_replace(array_keys($expressions), array_values($expressions), $source);
|
||||
// note: for some very weird reason trim() seems to remove spaces inside attributes.
|
||||
@@ -77,9 +76,9 @@ function smarty_outputfilter_trimwhitespace($source)
|
||||
$_offset = 0;
|
||||
if (preg_match_all('#@!@SMARTY:([0-9]+):SMARTY@!@#is', $source, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) {
|
||||
foreach ($matches as $match) {
|
||||
$_length = strlen($match[0][0]);
|
||||
$replace = $store[$match[1][0]];
|
||||
$source = substr_replace($source, $replace, $match[0][1] + $_offset, $_length);
|
||||
$_length = strlen($match[ 0 ][ 0 ]);
|
||||
$replace = $store[ $match[ 1 ][ 0 ] ];
|
||||
$source = substr_replace($source, $replace, $match[ 0 ][ 1 ] + $_offset, $_length);
|
||||
|
||||
$_offset += strlen($replace) - $_length;
|
||||
$_store ++;
|
||||
|
@@ -20,16 +20,17 @@
|
||||
function smarty_literal_compiler_param($params, $index, $default = null)
|
||||
{
|
||||
// not set, go default
|
||||
if (!isset($params[$index])) {
|
||||
if (!isset($params[ $index ])) {
|
||||
return $default;
|
||||
}
|
||||
// test if param is a literal
|
||||
if (!preg_match('/^([\'"]?)[a-zA-Z0-9-]+(\\1)$/', $params[$index])) {
|
||||
throw new SmartyException('$param[' . $index . '] is not a literal and is thus not evaluatable at compile time');
|
||||
if (!preg_match('/^([\'"]?)[a-zA-Z0-9-]+(\\1)$/', $params[ $index ])) {
|
||||
throw new SmartyException('$param[' . $index .
|
||||
'] is not a literal and is thus not evaluatable at compile time');
|
||||
}
|
||||
|
||||
$t = null;
|
||||
eval("\$t = " . $params[$index] . ";");
|
||||
eval("\$t = " . $params[ $index ] . ";");
|
||||
|
||||
return $t;
|
||||
}
|
||||
|
@@ -21,12 +21,14 @@ function smarty_make_timestamp($string)
|
||||
if (empty($string)) {
|
||||
// use "now":
|
||||
return time();
|
||||
} elseif ($string instanceof DateTime || (interface_exists('DateTimeInterface', false) && $string instanceof DateTimeInterface)) {
|
||||
} elseif ($string instanceof DateTime ||
|
||||
(interface_exists('DateTimeInterface', false) && $string instanceof DateTimeInterface)
|
||||
) {
|
||||
return (int) $string->format('U'); // PHP 5.2 BC
|
||||
} elseif (strlen($string) == 14 && ctype_digit($string)) {
|
||||
// it is mysql timestamp format of YYYYMMDDHHMMSS?
|
||||
return mktime(substr($string, 8, 2), substr($string, 10, 2), substr($string, 12, 2),
|
||||
substr($string, 4, 2), substr($string, 6, 2), substr($string, 0, 4));
|
||||
return mktime(substr($string, 8, 2), substr($string, 10, 2), substr($string, 12, 2), substr($string, 4, 2),
|
||||
substr($string, 6, 2), substr($string, 0, 4));
|
||||
} elseif (is_numeric($string)) {
|
||||
// it is a numeric string, we handle it as timestamp
|
||||
return (int) $string;
|
||||
|
@@ -26,7 +26,7 @@ if (!function_exists('smarty_mb_str_replace')) {
|
||||
if (is_array($subject)) {
|
||||
// call mb_replace for each single string in $subject
|
||||
foreach ($subject as &$string) {
|
||||
$string = & smarty_mb_str_replace($search, $replace, $string, $c);
|
||||
$string = &smarty_mb_str_replace($search, $replace, $string, $c);
|
||||
$count += $c;
|
||||
}
|
||||
} elseif (is_array($search)) {
|
||||
|
@@ -24,7 +24,8 @@ if (!function_exists('smarty_mb_wordwrap')) {
|
||||
function smarty_mb_wordwrap($str, $width = 75, $break = "\n", $cut = false)
|
||||
{
|
||||
// break words into tokens using white space as a delimiter
|
||||
$tokens = preg_split('!(\s)!S' . Smarty::$_UTF8_MODIFIER, $str, - 1, PREG_SPLIT_NO_EMPTY + PREG_SPLIT_DELIM_CAPTURE);
|
||||
$tokens =
|
||||
preg_split('!(\s)!S' . Smarty::$_UTF8_MODIFIER, $str, - 1, PREG_SPLIT_NO_EMPTY + PREG_SPLIT_DELIM_CAPTURE);
|
||||
$length = 0;
|
||||
$t = '';
|
||||
$_previous = false;
|
||||
@@ -35,7 +36,8 @@ if (!function_exists('smarty_mb_wordwrap')) {
|
||||
$_tokens = array($_token);
|
||||
if ($token_length > $width) {
|
||||
if ($cut) {
|
||||
$_tokens = preg_split('!(.{' . $width . '})!S' . Smarty::$_UTF8_MODIFIER, $_token, - 1, PREG_SPLIT_NO_EMPTY + PREG_SPLIT_DELIM_CAPTURE);
|
||||
$_tokens = preg_split('!(.{' . $width . '})!S' . Smarty::$_UTF8_MODIFIER, $_token, - 1,
|
||||
PREG_SPLIT_NO_EMPTY + PREG_SPLIT_DELIM_CAPTURE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -50,7 +50,8 @@ abstract class Smarty_CacheResource
|
||||
*
|
||||
* @return bool true or false if the cached content does not exist
|
||||
*/
|
||||
abstract public function process(Smarty_Internal_Template $_template, Smarty_Template_Cached $cached = null, $update = false);
|
||||
abstract public function process(Smarty_Internal_Template $_template, Smarty_Template_Cached $cached = null,
|
||||
$update = false);
|
||||
|
||||
/**
|
||||
* Write the rendered template output to cache
|
||||
@@ -185,24 +186,24 @@ abstract class Smarty_CacheResource
|
||||
}
|
||||
|
||||
// try smarty's cache
|
||||
if (isset($smarty->_cache['cacheresource_handlers'][$type])) {
|
||||
return $smarty->_cache['cacheresource_handlers'][$type];
|
||||
if (isset($smarty->_cache[ 'cacheresource_handlers' ][ $type ])) {
|
||||
return $smarty->_cache[ 'cacheresource_handlers' ][ $type ];
|
||||
}
|
||||
|
||||
// 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
|
||||
return $smarty->_cache['cacheresource_handlers'][$type] = $smarty->registered_cache_resources[$type];
|
||||
return $smarty->_cache[ 'cacheresource_handlers' ][ $type ] = $smarty->registered_cache_resources[ $type ];
|
||||
}
|
||||
// try sysplugins dir
|
||||
if (isset(self::$sysplugins[$type])) {
|
||||
if (isset(self::$sysplugins[ $type ])) {
|
||||
$cache_resource_class = 'Smarty_Internal_CacheResource_' . ucfirst($type);
|
||||
return $smarty->_cache['cacheresource_handlers'][$type] = new $cache_resource_class();
|
||||
return $smarty->_cache[ 'cacheresource_handlers' ][ $type ] = new $cache_resource_class();
|
||||
}
|
||||
// try plugins dir
|
||||
$cache_resource_class = 'Smarty_CacheResource_' . ucfirst($type);
|
||||
if ($smarty->loadPlugin($cache_resource_class)) {
|
||||
return $smarty->_cache['cacheresource_handlers'][$type] = new $cache_resource_class();
|
||||
return $smarty->_cache[ 'cacheresource_handlers' ][ $type ] = new $cache_resource_class();
|
||||
}
|
||||
// give up
|
||||
throw new SmartyException("Unable to load cache resource '{$type}'");
|
||||
|
@@ -101,7 +101,8 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource
|
||||
*/
|
||||
public function populateTimestamp(Smarty_Template_Cached $cached)
|
||||
{
|
||||
$mtime = $this->fetchTimestamp($cached->filepath, $cached->source->name, $cached->cache_id, $cached->compile_id);
|
||||
$mtime =
|
||||
$this->fetchTimestamp($cached->filepath, $cached->source->name, $cached->cache_id, $cached->compile_id);
|
||||
if ($mtime !== null) {
|
||||
$cached->timestamp = $mtime;
|
||||
$cached->exists = !!$cached->timestamp;
|
||||
@@ -109,7 +110,8 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource
|
||||
return;
|
||||
}
|
||||
$timestamp = null;
|
||||
$this->fetch($cached->filepath, $cached->source->name, $cached->cache_id, $cached->compile_id, $cached->content, $timestamp);
|
||||
$this->fetch($cached->filepath, $cached->source->name, $cached->cache_id, $cached->compile_id, $cached->content,
|
||||
$timestamp);
|
||||
$cached->timestamp = isset($timestamp) ? $timestamp : false;
|
||||
$cached->exists = !!$cached->timestamp;
|
||||
}
|
||||
@@ -131,7 +133,8 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource
|
||||
$content = $cached->content ? $cached->content : null;
|
||||
$timestamp = $cached->timestamp ? $cached->timestamp : null;
|
||||
if ($content === null || !$timestamp) {
|
||||
$this->fetch($_template->cached->filepath, $_template->source->name, $_template->cache_id, $_template->compile_id, $content, $timestamp);
|
||||
$this->fetch($_template->cached->filepath, $_template->source->name, $_template->cache_id,
|
||||
$_template->compile_id, $content, $timestamp);
|
||||
}
|
||||
if (isset($content)) {
|
||||
/** @var Smarty_Internal_Template $_smarty_tpl
|
||||
@@ -156,7 +159,8 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource
|
||||
*/
|
||||
public function writeCachedContent(Smarty_Internal_Template $_template, $content)
|
||||
{
|
||||
return $this->save($_template->cached->filepath, $_template->source->name, $_template->cache_id, $_template->compile_id, $_template->cache_lifetime, $content);
|
||||
return $this->save($_template->cached->filepath, $_template->source->name, $_template->cache_id,
|
||||
$_template->compile_id, $_template->cache_lifetime, $content);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -172,7 +176,8 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource
|
||||
$timestamp = null;
|
||||
if ($content === null) {
|
||||
$timestamp = null;
|
||||
$this->fetch($_template->cached->filepath, $_template->source->name, $_template->cache_id, $_template->compile_id, $content, $timestamp);
|
||||
$this->fetch($_template->cached->filepath, $_template->source->name, $_template->cache_id,
|
||||
$_template->compile_id, $content, $timestamp);
|
||||
}
|
||||
if (isset($content)) {
|
||||
return $content;
|
||||
|
@@ -69,7 +69,9 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
|
||||
*/
|
||||
public function populateTimestamp(Smarty_Template_Cached $cached)
|
||||
{
|
||||
if (!$this->fetch($cached->filepath, $cached->source->name, $cached->cache_id, $cached->compile_id, $content, $timestamp, $cached->source->uid)) {
|
||||
if (!$this->fetch($cached->filepath, $cached->source->name, $cached->cache_id, $cached->compile_id, $content,
|
||||
$timestamp, $cached->source->uid)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
$cached->content = $content;
|
||||
@@ -94,7 +96,9 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
|
||||
$content = $cached->content ? $cached->content : null;
|
||||
$timestamp = $cached->timestamp ? $cached->timestamp : null;
|
||||
if ($content === null || !$timestamp) {
|
||||
if (!$this->fetch($_template->cached->filepath, $_template->source->name, $_template->cache_id, $_template->compile_id, $content, $timestamp, $_template->source->uid)) {
|
||||
if (!$this->fetch($_template->cached->filepath, $_template->source->name, $_template->cache_id,
|
||||
$_template->compile_id, $content, $timestamp, $_template->source->uid)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -138,7 +142,9 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
|
||||
$content = $_template->cached->content ? $_template->cached->content : null;
|
||||
$timestamp = null;
|
||||
if ($content === null) {
|
||||
if (!$this->fetch($_template->cached->filepath, $_template->source->name, $_template->cache_id, $_template->compile_id, $content, $timestamp, $_template->source->uid)) {
|
||||
if (!$this->fetch($_template->cached->filepath, $_template->source->name, $_template->cache_id,
|
||||
$_template->compile_id, $content, $timestamp, $_template->source->uid)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -242,14 +248,16 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
|
||||
*
|
||||
* @return boolean success
|
||||
*/
|
||||
protected function fetch($cid, $resource_name = null, $cache_id = null, $compile_id = null, &$content = null, &$timestamp = null, $resource_uid = null)
|
||||
protected function fetch($cid, $resource_name = null, $cache_id = null, $compile_id = null, &$content = null,
|
||||
&$timestamp = null, $resource_uid = null)
|
||||
{
|
||||
$t = $this->read(array($cid));
|
||||
$content = !empty($t[$cid]) ? $t[$cid] : null;
|
||||
$content = !empty($t[ $cid ]) ? $t[ $cid ] : null;
|
||||
$timestamp = null;
|
||||
|
||||
if ($content && ($timestamp = $this->getMetaTimestamp($content))) {
|
||||
$invalidated = $this->getLatestInvalidationTimestamp($cid, $resource_name, $cache_id, $compile_id, $resource_uid);
|
||||
$invalidated =
|
||||
$this->getLatestInvalidationTimestamp($cid, $resource_name, $cache_id, $compile_id, $resource_uid);
|
||||
if ($invalidated > $timestamp) {
|
||||
$timestamp = null;
|
||||
$content = null;
|
||||
@@ -268,7 +276,7 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
|
||||
protected function addMetaTimestamp(&$content)
|
||||
{
|
||||
$mt = explode(" ", microtime());
|
||||
$ts = pack("NN", $mt[1], (int) ($mt[0] * 100000000));
|
||||
$ts = pack("NN", $mt[ 1 ], (int) ($mt[ 0 ] * 100000000));
|
||||
$content = $ts . $content;
|
||||
}
|
||||
|
||||
@@ -296,7 +304,8 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function invalidate($cid = null, $resource_name = null, $cache_id = null, $compile_id = null, $resource_uid = null)
|
||||
protected function invalidate($cid = null, $resource_name = null, $cache_id = null, $compile_id = null,
|
||||
$resource_uid = null)
|
||||
{
|
||||
$now = microtime(true);
|
||||
$key = null;
|
||||
@@ -336,7 +345,8 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
|
||||
*
|
||||
* @return float the microtime the CacheID was invalidated
|
||||
*/
|
||||
protected function getLatestInvalidationTimestamp($cid, $resource_name = null, $cache_id = null, $compile_id = null, $resource_uid = null)
|
||||
protected function getLatestInvalidationTimestamp($cid, $resource_name = null, $cache_id = null, $compile_id = null,
|
||||
$resource_uid = null)
|
||||
{
|
||||
// abort if there is no CacheID
|
||||
if (false && !$cid) {
|
||||
@@ -370,7 +380,8 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
|
||||
* @return array list of InvalidationKeys
|
||||
* @uses $invalidationKeyPrefix to prepend to each InvalidationKey
|
||||
*/
|
||||
protected function listInvalidationKeys($cid, $resource_name = null, $cache_id = null, $compile_id = null, $resource_uid = null)
|
||||
protected function listInvalidationKeys($cid, $resource_name = null, $cache_id = null, $compile_id = null,
|
||||
$resource_uid = null)
|
||||
{
|
||||
$t = array('IVK#ALL');
|
||||
$_name = $_compile = '#';
|
||||
@@ -422,7 +433,7 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
|
||||
$key = 'LOCK#' . $cached->filepath;
|
||||
$data = $this->read(array($key));
|
||||
|
||||
return $data && time() - $data[$key] < $smarty->locking_timeout;
|
||||
return $data && time() - $data[ $key ] < $smarty->locking_timeout;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -59,7 +59,7 @@ class Smarty_Data extends Smarty_Internal_Data
|
||||
} elseif (is_array($_parent)) {
|
||||
// set up variable values
|
||||
foreach ($_parent as $_key => $_val) {
|
||||
$this->tpl_vars[$_key] = new Smarty_Variable($_val);
|
||||
$this->tpl_vars[ $_key ] = new Smarty_Variable($_val);
|
||||
}
|
||||
} elseif ($_parent != null) {
|
||||
throw new SmartyException("Wrong type for template variables");
|
||||
|
@@ -58,8 +58,8 @@ class Smarty_Internal_CacheResource_File extends Smarty_CacheResource
|
||||
}
|
||||
$cached->lock_id = $_lock_dir . sha1($_cache_id . $_compile_id . $_template->source->uid) . '.lock';
|
||||
}
|
||||
$cached->filepath = $_cache_dir . $_cache_id . $_compile_id . $_filepath . '.' . basename($_source_file_path) .
|
||||
'.php';
|
||||
$cached->filepath =
|
||||
$_cache_dir . $_cache_id . $_compile_id . $_filepath . '.' . basename($_source_file_path) . '.php';
|
||||
$cached->timestamp = $cached->exists = is_file($cached->filepath);
|
||||
if ($cached->exists) {
|
||||
$cached->timestamp = filemtime($cached->filepath);
|
||||
@@ -115,7 +115,9 @@ class Smarty_Internal_CacheResource_File extends Smarty_CacheResource
|
||||
*/
|
||||
public function writeCachedContent(Smarty_Internal_Template $_template, $content)
|
||||
{
|
||||
if ($_template->smarty->ext->_writeFile->writeFile($_template->cached->filepath, $content, $_template->smarty) === true) {
|
||||
if ($_template->smarty->ext->_writeFile->writeFile($_template->cached->filepath, $content,
|
||||
$_template->smarty) === true
|
||||
) {
|
||||
if (function_exists('opcache_invalidate')) {
|
||||
opcache_invalidate($_template->cached->filepath, true);
|
||||
} elseif (function_exists('apc_compile_file')) {
|
||||
|
@@ -34,11 +34,11 @@ class Smarty_Internal_Compile_Append extends Smarty_Internal_Compile_Assign
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
// map to compile assign attributes
|
||||
if (isset($_attr['index'])) {
|
||||
$_params['smarty_internal_index'] = '[' . $_attr['index'] . ']';
|
||||
unset($_attr['index']);
|
||||
if (isset($_attr[ 'index' ])) {
|
||||
$_params[ 'smarty_internal_index' ] = '[' . $_attr[ 'index' ] . ']';
|
||||
unset($_attr[ 'index' ]);
|
||||
} else {
|
||||
$_params['smarty_internal_index'] = '[]';
|
||||
$_params[ 'smarty_internal_index' ] = '[]';
|
||||
}
|
||||
$_new_attr = array();
|
||||
foreach ($_attr as $key => $value) {
|
||||
|
@@ -185,7 +185,8 @@ class Smarty_Internal_Compile_Blockclose extends Smarty_Internal_Compile_Shared_
|
||||
$sourceInfo = $compiler->template->source->filepath;
|
||||
} else {
|
||||
$basename = $compiler->template->source->handler->getBasename($compiler->template->source);
|
||||
$sourceInfo = $compiler->template->source->type .':' . ($basename ? $basename : $compiler->template->source->name);
|
||||
$sourceInfo =
|
||||
$compiler->template->source->type . ':' . ($basename ? $basename : $compiler->template->source->name);
|
||||
}
|
||||
|
||||
$output = "<?php\n";
|
||||
|
@@ -48,22 +48,22 @@ class Smarty_Internal_Compile_Break extends Smarty_Internal_CompileBase
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
|
||||
if ($_attr['nocache'] === true) {
|
||||
if ($_attr[ 'nocache' ] === true) {
|
||||
$compiler->trigger_template_error('nocache option not allowed', null, true);
|
||||
}
|
||||
|
||||
if (isset($_attr['levels'])) {
|
||||
if (!is_numeric($_attr['levels'])) {
|
||||
if (isset($_attr[ 'levels' ])) {
|
||||
if (!is_numeric($_attr[ 'levels' ])) {
|
||||
$compiler->trigger_template_error('level attribute must be a numeric constant', null, true);
|
||||
}
|
||||
$_levels = $_attr['levels'];
|
||||
$_levels = $_attr[ 'levels' ];
|
||||
} else {
|
||||
$_levels = 1;
|
||||
}
|
||||
$level_count = $_levels;
|
||||
$stack_count = count($compiler->_tag_stack) - 1;
|
||||
while ($level_count > 0 && $stack_count >= 0) {
|
||||
if (isset($_is_loopy[$compiler->_tag_stack[$stack_count][0]])) {
|
||||
if (isset($_is_loopy[ $compiler->_tag_stack[ $stack_count ][ 0 ] ])) {
|
||||
$level_count --;
|
||||
}
|
||||
$stack_count --;
|
||||
|
@@ -53,13 +53,13 @@ class Smarty_Internal_Compile_Call extends Smarty_Internal_CompileBase
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
// save possible attributes
|
||||
if (isset($_attr['assign'])) {
|
||||
if (isset($_attr[ 'assign' ])) {
|
||||
// output will be stored in a smarty variable instead of being displayed
|
||||
$_assign = $_attr['assign'];
|
||||
$_assign = $_attr[ 'assign' ];
|
||||
}
|
||||
//$_name = trim($_attr['name'], "'\"");
|
||||
$_name = $_attr['name'];
|
||||
unset($_attr['name'], $_attr['assign'], $_attr['nocache']);
|
||||
$_name = $_attr[ 'name' ];
|
||||
unset($_attr[ 'name' ], $_attr[ 'assign' ], $_attr[ 'nocache' ]);
|
||||
// set flag (compiled code of {function} must be included in cache file
|
||||
if (!$compiler->template->caching || $compiler->nocache || $compiler->tag_nocache) {
|
||||
$_nocache = 'true';
|
||||
|
@@ -45,14 +45,15 @@ class Smarty_Internal_Compile_Capture extends Smarty_Internal_CompileBase
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
|
||||
$buffer = isset($_attr['name']) ? $_attr['name'] : "'default'";
|
||||
$assign = isset($_attr['assign']) ? $_attr['assign'] : 'null';
|
||||
$append = isset($_attr['append']) ? $_attr['append'] : 'null';
|
||||
$buffer = isset($_attr[ 'name' ]) ? $_attr[ 'name' ] : "'default'";
|
||||
$assign = isset($_attr[ 'assign' ]) ? $_attr[ 'assign' ] : 'null';
|
||||
$append = isset($_attr[ 'append' ]) ? $_attr[ 'append' ] : 'null';
|
||||
|
||||
$compiler->_capture_stack[0][] = array($buffer, $assign, $append, $compiler->nocache);
|
||||
$compiler->_capture_stack[ 0 ][] = array($buffer, $assign, $append, $compiler->nocache);
|
||||
// maybe nocache because of nocache variables
|
||||
$compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
|
||||
$_output = "<?php \$_smarty_tpl->smarty->_cache['capture_stack'][] = array($buffer, $assign, $append); ob_start(); ?>";
|
||||
$_output =
|
||||
"<?php \$_smarty_tpl->smarty->_cache['capture_stack'][] = array($buffer, $assign, $append); ob_start(); ?>";
|
||||
|
||||
return $_output;
|
||||
}
|
||||
@@ -103,9 +104,10 @@ class Smarty_Internal_Compile_CaptureClose extends Smarty_Internal_CompileBase
|
||||
$compiler->tag_nocache = true;
|
||||
}
|
||||
|
||||
list($buffer, $assign, $append, $compiler->nocache) = array_pop($compiler->_capture_stack[0]);
|
||||
list($buffer, $assign, $append, $compiler->nocache) = array_pop($compiler->_capture_stack[ 0 ]);
|
||||
|
||||
$_output = "<?php list(\$_capture_buffer, \$_capture_assign, \$_capture_append) = array_pop(\$_smarty_tpl->smarty->_cache['capture_stack']);\n";
|
||||
$_output =
|
||||
"<?php list(\$_capture_buffer, \$_capture_assign, \$_capture_append) = array_pop(\$_smarty_tpl->smarty->_cache['capture_stack']);\n";
|
||||
$_output .= "if (!empty(\$_capture_buffer)) {\n";
|
||||
$_output .= " if (isset(\$_capture_assign)) \$_smarty_tpl->assign(\$_capture_assign, ob_get_contents());\n";
|
||||
$_output .= " if (isset( \$_capture_append)) \$_smarty_tpl->append( \$_capture_append, ob_get_contents());\n";
|
||||
|
@@ -45,8 +45,7 @@ class Smarty_Internal_Compile_Config_Load extends Smarty_Internal_CompileBase
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $valid_scopes = array('local' => true, 'parent' => true, 'root' => true,
|
||||
'tpl_root' => true);
|
||||
public $valid_scopes = array('local' => true, 'parent' => true, 'root' => true, 'tpl_root' => true);
|
||||
|
||||
/**
|
||||
* Compiles code for the {config_load} tag
|
||||
@@ -62,32 +61,34 @@ class Smarty_Internal_Compile_Config_Load extends Smarty_Internal_CompileBase
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
|
||||
if ($_attr['nocache'] === true) {
|
||||
if ($_attr[ 'nocache' ] === true) {
|
||||
$compiler->trigger_template_error('nocache option not allowed', null, true);
|
||||
}
|
||||
|
||||
// save possible attributes
|
||||
$conf_file = $_attr['file'];
|
||||
if (isset($_attr['section'])) {
|
||||
$section = $_attr['section'];
|
||||
$conf_file = $_attr[ 'file' ];
|
||||
if (isset($_attr[ 'section' ])) {
|
||||
$section = $_attr[ 'section' ];
|
||||
} else {
|
||||
$section = 'null';
|
||||
}
|
||||
$_scope = Smarty::SCOPE_LOCAL;
|
||||
if (isset($_attr['scope'])) {
|
||||
$_attr['scope'] = trim($_attr['scope'], "'\"");
|
||||
if (!isset($this->valid_scopes[$_attr['scope']])) {
|
||||
$compiler->trigger_template_error("illegal value '{$_attr['scope']}' for \"scope\" attribute", null, true);
|
||||
if (isset($_attr[ 'scope' ])) {
|
||||
$_attr[ 'scope' ] = trim($_attr[ 'scope' ], "'\"");
|
||||
if (!isset($this->valid_scopes[ $_attr[ 'scope' ] ])) {
|
||||
$compiler->trigger_template_error("illegal value '{$_attr['scope']}' for \"scope\" attribute", null,
|
||||
true);
|
||||
}
|
||||
if ($_attr['scope'] != 'local') {
|
||||
if ($_attr['scope'] == 'parent') {
|
||||
if ($_attr[ 'scope' ] != 'local') {
|
||||
if ($_attr[ 'scope' ] == 'parent') {
|
||||
$_scope = Smarty::SCOPE_PARENT;
|
||||
} elseif ($_attr['scope'] == 'root') {
|
||||
} elseif ($_attr[ 'scope' ] == 'root') {
|
||||
$_scope = Smarty::SCOPE_ROOT;
|
||||
} elseif ($_attr['scope'] == 'tpl_root') {
|
||||
} elseif ($_attr[ 'scope' ] == 'tpl_root') {
|
||||
$_scope = Smarty::SCOPE_TPL_ROOT;
|
||||
}
|
||||
$_scope += (isset($_attr['bubble_up']) && $_attr['bubble_up'] == 'false') ? 0 : Smarty::SCOPE_BUBBLE_UP;
|
||||
$_scope += (isset($_attr[ 'bubble_up' ]) && $_attr[ 'bubble_up' ] == 'false') ? 0 :
|
||||
Smarty::SCOPE_BUBBLE_UP;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -48,22 +48,22 @@ class Smarty_Internal_Compile_Continue extends Smarty_Internal_CompileBase
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
|
||||
if ($_attr['nocache'] === true) {
|
||||
if ($_attr[ 'nocache' ] === true) {
|
||||
$compiler->trigger_template_error('nocache option not allowed', null, true);
|
||||
}
|
||||
|
||||
if (isset($_attr['levels'])) {
|
||||
if (!is_numeric($_attr['levels'])) {
|
||||
if (isset($_attr[ 'levels' ])) {
|
||||
if (!is_numeric($_attr[ 'levels' ])) {
|
||||
$compiler->trigger_template_error('level attribute must be a numeric constant', null, true);
|
||||
}
|
||||
$_levels = $_attr['levels'];
|
||||
$_levels = $_attr[ 'levels' ];
|
||||
} else {
|
||||
$_levels = 1;
|
||||
}
|
||||
$level_count = $_levels;
|
||||
$stack_count = count($compiler->_tag_stack) - 1;
|
||||
while ($level_count > 0 && $stack_count >= 0) {
|
||||
if (isset($_is_loopy[$compiler->_tag_stack[$stack_count][0]])) {
|
||||
if (isset($_is_loopy[ $compiler->_tag_stack[ $stack_count ][ 0 ] ])) {
|
||||
$level_count --;
|
||||
}
|
||||
$stack_count --;
|
||||
|
@@ -34,7 +34,8 @@ class Smarty_Internal_Compile_Debug extends Smarty_Internal_CompileBase
|
||||
$compiler->tag_nocache = true;
|
||||
|
||||
// display debug template
|
||||
$_output = "<?php \$_smarty_debug = new Smarty_Internal_Debug;\n \$_smarty_debug->display_debug(\$_smarty_tpl);\n";
|
||||
$_output =
|
||||
"<?php \$_smarty_debug = new Smarty_Internal_Debug;\n \$_smarty_debug->display_debug(\$_smarty_tpl);\n";
|
||||
$_output .= "unset(\$_smarty_debug);\n?>";
|
||||
return $_output;
|
||||
}
|
||||
|
@@ -23,6 +23,7 @@ class Smarty_Internal_Compile_Eval extends Smarty_Internal_CompileBase
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $required_attributes = array('var');
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
@@ -30,6 +31,7 @@ class Smarty_Internal_Compile_Eval extends Smarty_Internal_CompileBase
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $optional_attributes = array('assign');
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
@@ -52,13 +54,14 @@ class Smarty_Internal_Compile_Eval extends Smarty_Internal_CompileBase
|
||||
$this->optional_attributes = array('assign');
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
if (isset($_attr['assign'])) {
|
||||
if (isset($_attr[ 'assign' ])) {
|
||||
// output will be stored in a smarty variable instead of being displayed
|
||||
$_assign = $_attr['assign'];
|
||||
$_assign = $_attr[ 'assign' ];
|
||||
}
|
||||
|
||||
// create template object
|
||||
$_output = "\$_template = new {$compiler->smarty->template_class}('eval:'." . $_attr['var'] . ", \$_smarty_tpl->smarty, \$_smarty_tpl);";
|
||||
$_output = "\$_template = new {$compiler->smarty->template_class}('eval:'." . $_attr[ 'var' ] .
|
||||
", \$_smarty_tpl->smarty, \$_smarty_tpl);";
|
||||
//was there an assign attribute?
|
||||
if (isset($_assign)) {
|
||||
$_output .= "\$_smarty_tpl->assign($_assign,\$_template->fetch());";
|
||||
|
@@ -55,37 +55,37 @@ class Smarty_Internal_Compile_Extends extends Smarty_Internal_Compile_Shared_Inh
|
||||
{
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
if ($_attr['nocache'] === true) {
|
||||
if ($_attr[ 'nocache' ] === true) {
|
||||
$compiler->trigger_template_error('nocache option not allowed', $compiler->parser->lex->line - 1);
|
||||
}
|
||||
if (strpos($_attr['file'], '$_tmp') !== false) {
|
||||
if (strpos($_attr[ 'file' ], '$_tmp') !== false) {
|
||||
$compiler->trigger_template_error('illegal value for file attribute', $compiler->parser->lex->line - 1);
|
||||
}
|
||||
// add code to initialize inheritance
|
||||
$this->registerInit($compiler, true);
|
||||
$file = trim($_attr['file'], '\'"');
|
||||
$file = trim($_attr[ 'file' ], '\'"');
|
||||
if (strlen($file) > 8 && substr($file, 0, 8) == 'extends:') {
|
||||
// generate code for each template
|
||||
$files = array_reverse(explode('|', substr($file, 8)));
|
||||
$i = 0;
|
||||
foreach ($files as $file) {
|
||||
if ($file[0] == '"') {
|
||||
if ($file[ 0 ] == '"') {
|
||||
$file = trim($file, '".');
|
||||
} else {
|
||||
$file = "'{$file}'";
|
||||
}
|
||||
$i ++;
|
||||
if ($i == count($files) && isset($_attr['extends_resource'])) {
|
||||
if ($i == count($files) && isset($_attr[ 'extends_resource' ])) {
|
||||
$this->compileEndChild($compiler);
|
||||
}
|
||||
$this->compileInclude($compiler, $file);
|
||||
}
|
||||
if (!isset($_attr['extends_resource'])) {
|
||||
if (!isset($_attr[ 'extends_resource' ])) {
|
||||
$this->compileEndChild($compiler);
|
||||
}
|
||||
} else {
|
||||
$this->compileEndChild($compiler);
|
||||
$this->compileInclude($compiler, $_attr['file']);
|
||||
$this->compileInclude($compiler, $_attr[ 'file' ]);
|
||||
}
|
||||
$compiler->has_code = false;
|
||||
return '';
|
||||
|
@@ -34,7 +34,7 @@ class Smarty_Internal_Compile_For extends Smarty_Internal_CompileBase
|
||||
*/
|
||||
public function compile($args, $compiler, $parameter)
|
||||
{
|
||||
$compiler->loopNesting++;
|
||||
$compiler->loopNesting ++;
|
||||
if ($parameter == 0) {
|
||||
$this->required_attributes = array('start', 'to');
|
||||
$this->optional_attributes = array('max', 'step');
|
||||
@@ -47,41 +47,41 @@ class Smarty_Internal_Compile_For extends Smarty_Internal_CompileBase
|
||||
|
||||
$output = "<?php\n";
|
||||
if ($parameter == 1) {
|
||||
foreach ($_attr['start'] as $_statement) {
|
||||
if (is_array($_statement['var'])) {
|
||||
$var = $_statement['var']['var'];
|
||||
$index = $_statement['var']['smarty_internal_index'];
|
||||
foreach ($_attr[ 'start' ] as $_statement) {
|
||||
if (is_array($_statement[ 'var' ])) {
|
||||
$var = $_statement[ 'var' ][ 'var' ];
|
||||
$index = $_statement[ 'var' ][ 'smarty_internal_index' ];
|
||||
} else {
|
||||
$var = $_statement['var'];
|
||||
$var = $_statement[ 'var' ];
|
||||
$index = '';
|
||||
}
|
||||
$output .= "\$_smarty_tpl->tpl_vars[$var] = new Smarty_Variable;\n";
|
||||
$output .= "\$_smarty_tpl->tpl_vars[$var]->value{$index} = {$_statement['value']};\n";
|
||||
}
|
||||
if (is_array($_attr['var'])) {
|
||||
$var = $_attr['var']['var'];
|
||||
$index = $_attr['var']['smarty_internal_index'];
|
||||
if (is_array($_attr[ 'var' ])) {
|
||||
$var = $_attr[ 'var' ][ 'var' ];
|
||||
$index = $_attr[ 'var' ][ 'smarty_internal_index' ];
|
||||
} else {
|
||||
$var = $_attr['var'];
|
||||
$var = $_attr[ 'var' ];
|
||||
$index = '';
|
||||
}
|
||||
$output .= "if ($_attr[ifexp]) {\nfor (\$_foo=true;$_attr[ifexp]; \$_smarty_tpl->tpl_vars[$var]->value{$index}$_attr[step]) {\n";
|
||||
} else {
|
||||
$_statement = $_attr['start'];
|
||||
if (is_array($_statement['var'])) {
|
||||
$var = $_statement['var']['var'];
|
||||
$index = $_statement['var']['smarty_internal_index'];
|
||||
$_statement = $_attr[ 'start' ];
|
||||
if (is_array($_statement[ 'var' ])) {
|
||||
$var = $_statement[ 'var' ][ 'var' ];
|
||||
$index = $_statement[ 'var' ][ 'smarty_internal_index' ];
|
||||
} else {
|
||||
$var = $_statement['var'];
|
||||
$var = $_statement[ 'var' ];
|
||||
$index = '';
|
||||
}
|
||||
$output .= "\$_smarty_tpl->tpl_vars[$var] = new Smarty_Variable;";
|
||||
if (isset($_attr['step'])) {
|
||||
if (isset($_attr[ 'step' ])) {
|
||||
$output .= "\$_smarty_tpl->tpl_vars[$var]->step = $_attr[step];";
|
||||
} else {
|
||||
$output .= "\$_smarty_tpl->tpl_vars[$var]->step = 1;";
|
||||
}
|
||||
if (isset($_attr['max'])) {
|
||||
if (isset($_attr[ 'max' ])) {
|
||||
$output .= "\$_smarty_tpl->tpl_vars[$var]->total = (int) min(ceil((\$_smarty_tpl->tpl_vars[$var]->step > 0 ? $_attr[to]+1 - ($_statement[value]) : $_statement[value]-($_attr[to])+1)/abs(\$_smarty_tpl->tpl_vars[$var]->step)),$_attr[max]);\n";
|
||||
} else {
|
||||
$output .= "\$_smarty_tpl->tpl_vars[$var]->total = (int) ceil((\$_smarty_tpl->tpl_vars[$var]->step > 0 ? $_attr[to]+1 - ($_statement[value]) : $_statement[value]-($_attr[to])+1)/abs(\$_smarty_tpl->tpl_vars[$var]->step));\n";
|
||||
@@ -149,7 +149,7 @@ class Smarty_Internal_Compile_Forclose extends Smarty_Internal_CompileBase
|
||||
*/
|
||||
public function compile($args, $compiler, $parameter)
|
||||
{
|
||||
$compiler->loopNesting--;
|
||||
$compiler->loopNesting --;
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
// must endblock be nocache?
|
||||
|
@@ -53,16 +53,17 @@ class Smarty_Internal_Compile_Function extends Smarty_Internal_CompileBase
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
|
||||
{
|
||||
$compiler->loopNesting++;
|
||||
$compiler->loopNesting ++;
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
|
||||
if ($_attr['nocache'] === true) {
|
||||
if ($_attr[ 'nocache' ] === true) {
|
||||
$compiler->trigger_template_error('nocache option not allowed', null, true);
|
||||
}
|
||||
unset($_attr['nocache']);
|
||||
$_name = trim($_attr['name'], "'\"");
|
||||
$compiler->parent_compiler->tpl_function[$_name] = $compiler->parent_compiler->template->tpl_function[$_name] = array();
|
||||
unset($_attr[ 'nocache' ]);
|
||||
$_name = trim($_attr[ 'name' ], "'\"");
|
||||
$compiler->parent_compiler->tpl_function[ $_name ] =
|
||||
$compiler->parent_compiler->template->tpl_function[ $_name ] = array();
|
||||
$save = array($_attr, $compiler->parser->current_buffer, $compiler->template->compiled->has_nocache_code,
|
||||
$compiler->template->caching);
|
||||
$this->openTag($compiler, 'function', $save);
|
||||
@@ -100,17 +101,22 @@ class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
|
||||
{
|
||||
$compiler->loopNesting--;
|
||||
$compiler->loopNesting --;
|
||||
$this->compiler = $compiler;
|
||||
$saved_data = $this->closeTag($compiler, array('function'));
|
||||
$_attr = $saved_data[0];
|
||||
$_name = trim($_attr['name'], "'\"");
|
||||
$compiler->parent_compiler->tpl_function[$_name]['called_functions'] = $compiler->parent_compiler->template->tpl_function[$_name]['called_functions'] = $compiler->called_functions;
|
||||
$compiler->parent_compiler->tpl_function[$_name]['compiled_filepath'] = $compiler->parent_compiler->template->tpl_function[$_name]['compiled_filepath'] = $compiler->parent_compiler->template->compiled->filepath;
|
||||
$compiler->parent_compiler->tpl_function[$_name]['uid'] = $compiler->parent_compiler->template->tpl_function[$_name]['uid'] = $compiler->template->source->uid;
|
||||
$_attr = $saved_data[ 0 ];
|
||||
$_name = trim($_attr[ 'name' ], "'\"");
|
||||
$compiler->parent_compiler->tpl_function[ $_name ][ 'called_functions' ] =
|
||||
$compiler->parent_compiler->template->tpl_function[ $_name ][ 'called_functions' ] =
|
||||
$compiler->called_functions;
|
||||
$compiler->parent_compiler->tpl_function[ $_name ][ 'compiled_filepath' ] =
|
||||
$compiler->parent_compiler->template->tpl_function[ $_name ][ 'compiled_filepath' ] =
|
||||
$compiler->parent_compiler->template->compiled->filepath;
|
||||
$compiler->parent_compiler->tpl_function[ $_name ][ 'uid' ] =
|
||||
$compiler->parent_compiler->template->tpl_function[ $_name ][ 'uid' ] = $compiler->template->source->uid;
|
||||
$compiler->called_functions = array();
|
||||
$_parameter = $_attr;
|
||||
unset($_parameter['name']);
|
||||
unset($_parameter[ 'name' ]);
|
||||
// default parameter
|
||||
$_paramsArray = array();
|
||||
foreach ($_parameter as $_key => $_value) {
|
||||
@@ -133,7 +139,8 @@ class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase
|
||||
$_funcName = "smarty_template_function_{$_name}_{$compiler->template->compiled->nocache_hash}";
|
||||
$_funcNameCaching = $_funcName . '_nocache';
|
||||
if ($compiler->template->compiled->has_nocache_code) {
|
||||
$compiler->parent_compiler->tpl_function[$_name]['call_name_caching'] = $compiler->parent_compiler->template->tpl_function[$_name]['call_name_caching'] = $_funcNameCaching;
|
||||
$compiler->parent_compiler->tpl_function[ $_name ][ 'call_name_caching' ] =
|
||||
$compiler->parent_compiler->template->tpl_function[ $_name ][ 'call_name_caching' ] = $_funcNameCaching;
|
||||
$output = "<?php\n";
|
||||
$output .= "/* {$_funcNameCaching} */\n";
|
||||
$output .= "if (!function_exists('{$_funcNameCaching}')) {\n";
|
||||
@@ -147,7 +154,9 @@ class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase
|
||||
$output .= "echo \"/*%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%*/<?php ";
|
||||
$output .= "\\\$saved_tpl_vars = \\\$_smarty_tpl->tpl_vars;\nforeach (\$params as \\\$key => \\\$value) {\n\\\$_smarty_tpl->tpl_vars[\\\$key] = new Smarty_Variable(\\\$value);\n}\n?>";
|
||||
$output .= "/*/%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%*/\n\";?>";
|
||||
$compiler->parser->current_buffer->append_subtree($compiler->parser, new Smarty_Internal_ParseTree_Tag($compiler->parser, $output));
|
||||
$compiler->parser->current_buffer->append_subtree($compiler->parser,
|
||||
new Smarty_Internal_ParseTree_Tag($compiler->parser,
|
||||
$output));
|
||||
$compiler->parser->current_buffer->append_subtree($compiler->parser, $_functionCode);
|
||||
$output = "<?php echo \"/*%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%*/<?php ";
|
||||
$output .= "foreach (Smarty::\\\$global_tpl_vars as \\\$key => \\\$value){\n";
|
||||
@@ -158,11 +167,16 @@ class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase
|
||||
$output .= "\$_smarty_tpl->tpl_vars = array_pop(\$_smarty_tpl->_cache['saved_tpl_vars']);\n}\n}\n";
|
||||
$output .= "/*/ {$_funcName}_nocache */\n\n";
|
||||
$output .= "?>\n";
|
||||
$compiler->parser->current_buffer->append_subtree($compiler->parser, new Smarty_Internal_ParseTree_Tag($compiler->parser, $output));
|
||||
$_functionCode = new Smarty_Internal_ParseTree_Tag($compiler->parser, preg_replace_callback("/((<\?php )?echo '\/\*%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%\*\/([\S\s]*?)\/\*\/%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%\*\/';(\?>\n)?)/", array($this,
|
||||
'removeNocache'), $_functionCode->to_smarty_php($compiler->parser)));
|
||||
$compiler->parser->current_buffer->append_subtree($compiler->parser,
|
||||
new Smarty_Internal_ParseTree_Tag($compiler->parser,
|
||||
$output));
|
||||
$_functionCode = new Smarty_Internal_ParseTree_Tag($compiler->parser,
|
||||
preg_replace_callback("/((<\?php )?echo '\/\*%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%\*\/([\S\s]*?)\/\*\/%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%\*\/';(\?>\n)?)/",
|
||||
array($this, 'removeNocache'),
|
||||
$_functionCode->to_smarty_php($compiler->parser)));
|
||||
}
|
||||
$compiler->parent_compiler->tpl_function[$_name]['call_name'] = $compiler->parent_compiler->template->tpl_function[$_name]['call_name'] = $_funcName;
|
||||
$compiler->parent_compiler->tpl_function[ $_name ][ 'call_name' ] =
|
||||
$compiler->parent_compiler->template->tpl_function[ $_name ][ 'call_name' ] = $_funcName;
|
||||
$output = "<?php\n";
|
||||
$output .= "/* {$_funcName} */\n";
|
||||
$output .= "if (!function_exists('{$_funcName}')) {\n";
|
||||
@@ -170,29 +184,34 @@ class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase
|
||||
$output .= "\$saved_tpl_vars = \$_smarty_tpl->tpl_vars;\n";
|
||||
$output .= $_paramsCode;
|
||||
$output .= "foreach (\$params as \$key => \$value) {\n\$_smarty_tpl->tpl_vars[\$key] = new Smarty_Variable(\$value);\n}?>";
|
||||
$compiler->parser->current_buffer->append_subtree($compiler->parser, new Smarty_Internal_ParseTree_Tag($compiler->parser, $output));
|
||||
$compiler->parser->current_buffer->append_subtree($compiler->parser,
|
||||
new Smarty_Internal_ParseTree_Tag($compiler->parser,
|
||||
$output));
|
||||
$compiler->parser->current_buffer->append_subtree($compiler->parser, $_functionCode);
|
||||
$output = "<?php foreach (Smarty::\$global_tpl_vars as \$key => \$value){\n";
|
||||
$output .= "if (!isset(\$_smarty_tpl->tpl_vars[\$key]) || \$_smarty_tpl->tpl_vars[\$key] === \$value) \$saved_tpl_vars[\$key] = \$value;\n}\n";
|
||||
$output .= "\$_smarty_tpl->tpl_vars = \$saved_tpl_vars;\n}\n}\n";
|
||||
$output .= "/*/ {$_funcName} */\n\n";
|
||||
$output .= "?>\n";
|
||||
$compiler->parser->current_buffer->append_subtree($compiler->parser, new Smarty_Internal_ParseTree_Tag($compiler->parser, $output));
|
||||
$compiler->parser->current_buffer->append_subtree($compiler->parser,
|
||||
new Smarty_Internal_ParseTree_Tag($compiler->parser,
|
||||
$output));
|
||||
$compiler->parent_compiler->blockOrFunctionCode .= $compiler->parser->current_buffer->to_smarty_php($compiler->parser);
|
||||
// nocache plugins must be copied
|
||||
if (!empty($compiler->template->compiled->required_plugins['nocache'])) {
|
||||
foreach ($compiler->template->compiled->required_plugins['nocache'] as $plugin => $tmp) {
|
||||
if (!empty($compiler->template->compiled->required_plugins[ 'nocache' ])) {
|
||||
foreach ($compiler->template->compiled->required_plugins[ 'nocache' ] as $plugin => $tmp) {
|
||||
foreach ($tmp as $type => $data) {
|
||||
$compiler->parent_compiler->template->compiled->required_plugins['compiled'][$plugin][$type] = $data;
|
||||
$compiler->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin ][ $type ] =
|
||||
$data;
|
||||
}
|
||||
}
|
||||
}
|
||||
// restore old buffer
|
||||
|
||||
$compiler->parser->current_buffer = $saved_data[1];
|
||||
$compiler->parser->current_buffer = $saved_data[ 1 ];
|
||||
// restore old status
|
||||
$compiler->template->compiled->has_nocache_code = $saved_data[2];
|
||||
$compiler->template->caching = $saved_data[3];
|
||||
$compiler->template->compiled->has_nocache_code = $saved_data[ 2 ];
|
||||
$compiler->template->caching = $saved_data[ 3 ];
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -203,7 +222,9 @@ class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase
|
||||
*/
|
||||
function removeNocache($match)
|
||||
{
|
||||
$code = preg_replace("/((<\?php )?echo '\/\*%%SmartyNocache:{$this->compiler->template->compiled->nocache_hash}%%\*\/)|(\/\*\/%%SmartyNocache:{$this->compiler->template->compiled->nocache_hash}%%\*\/';(\?>\n)?)/", '', $match[0]);
|
||||
$code =
|
||||
preg_replace("/((<\?php )?echo '\/\*%%SmartyNocache:{$this->compiler->template->compiled->nocache_hash}%%\*\/)|(\/\*\/%%SmartyNocache:{$this->compiler->template->compiled->nocache_hash}%%\*\/';(\?>\n)?)/",
|
||||
'', $match[ 0 ]);
|
||||
$code = str_replace(array('\\\'', '\\\\\''), array('\'', '\\\''), $code);
|
||||
return $code;
|
||||
}
|
||||
|
@@ -38,37 +38,38 @@ class Smarty_Internal_Compile_If extends Smarty_Internal_CompileBase
|
||||
$compiler->trigger_template_error("missing if condition", null, true);
|
||||
}
|
||||
|
||||
if (is_array($parameter['if condition'])) {
|
||||
if (is_array($parameter[ 'if condition' ])) {
|
||||
if ($compiler->nocache) {
|
||||
$_nocache = ',true';
|
||||
// create nocache var to make it know for further compiling
|
||||
if (is_array($parameter['if condition']['var'])) {
|
||||
$var = trim($parameter['if condition']['var']['var'], "'");
|
||||
if (is_array($parameter[ 'if condition' ][ 'var' ])) {
|
||||
$var = trim($parameter[ 'if condition' ][ 'var' ][ 'var' ], "'");
|
||||
} else {
|
||||
$var = trim($parameter['if condition']['var'], "'");
|
||||
$var = trim($parameter[ 'if condition' ][ 'var' ], "'");
|
||||
}
|
||||
if (isset($compiler->template->tpl_vars[$var])) {
|
||||
$compiler->template->tpl_vars[$var]->nocache = true;
|
||||
if (isset($compiler->template->tpl_vars[ $var ])) {
|
||||
$compiler->template->tpl_vars[ $var ]->nocache = true;
|
||||
} else {
|
||||
$compiler->template->tpl_vars[$var] = new Smarty_Variable(null, true);
|
||||
$compiler->template->tpl_vars[ $var ] = new Smarty_Variable(null, true);
|
||||
}
|
||||
} else {
|
||||
$_nocache = '';
|
||||
}
|
||||
if (is_array($parameter['if condition']['var'])) {
|
||||
$_output = "<?php if (!isset(\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] .
|
||||
"]) || !is_array(\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] .
|
||||
"]->value)) \$_smarty_tpl->_createLocalArrayVariable(" . $parameter['if condition']['var']['var'] .
|
||||
"$_nocache);\n";
|
||||
$_output .= "if (\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] . "]->value" .
|
||||
$parameter['if condition']['var']['smarty_internal_index'] . " = " .
|
||||
$parameter['if condition']['value'] . ") {?>";
|
||||
if (is_array($parameter[ 'if condition' ][ 'var' ])) {
|
||||
$_output =
|
||||
"<?php if (!isset(\$_smarty_tpl->tpl_vars[" . $parameter[ 'if condition' ][ 'var' ][ 'var' ] .
|
||||
"]) || !is_array(\$_smarty_tpl->tpl_vars[" . $parameter[ 'if condition' ][ 'var' ][ 'var' ] .
|
||||
"]->value)) \$_smarty_tpl->_createLocalArrayVariable(" .
|
||||
$parameter[ 'if condition' ][ 'var' ][ 'var' ] . "$_nocache);\n";
|
||||
$_output .= "if (\$_smarty_tpl->tpl_vars[" . $parameter[ 'if condition' ][ 'var' ][ 'var' ] .
|
||||
"]->value" . $parameter[ 'if condition' ][ 'var' ][ 'smarty_internal_index' ] . " = " .
|
||||
$parameter[ 'if condition' ][ 'value' ] . ") {?>";
|
||||
} else {
|
||||
$_output = "<?php if (!isset(\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] .
|
||||
"])) \$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] .
|
||||
$_output = "<?php if (!isset(\$_smarty_tpl->tpl_vars[" . $parameter[ 'if condition' ][ 'var' ] .
|
||||
"])) \$_smarty_tpl->tpl_vars[" . $parameter[ 'if condition' ][ 'var' ] .
|
||||
"] = new Smarty_Variable(null{$_nocache});";
|
||||
$_output .= "if (\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "]->value = " .
|
||||
$parameter['if condition']['value'] . ") {?>";
|
||||
$_output .= "if (\$_smarty_tpl->tpl_vars[" . $parameter[ 'if condition' ][ 'var' ] . "]->value = " .
|
||||
$parameter[ 'if condition' ][ 'value' ] . ") {?>";
|
||||
}
|
||||
|
||||
return $_output;
|
||||
@@ -133,20 +134,20 @@ class Smarty_Internal_Compile_Elseif extends Smarty_Internal_CompileBase
|
||||
$compiler->trigger_template_error("missing elseif condition", null, true);
|
||||
}
|
||||
|
||||
if (is_array($parameter['if condition'])) {
|
||||
if (is_array($parameter[ 'if condition' ])) {
|
||||
$condition_by_assign = true;
|
||||
if ($compiler->nocache) {
|
||||
$_nocache = ',true';
|
||||
// create nocache var to make it know for further compiling
|
||||
if (is_array($parameter['if condition']['var'])) {
|
||||
$var = trim($parameter['if condition']['var']['var'], "'");
|
||||
if (is_array($parameter[ 'if condition' ][ 'var' ])) {
|
||||
$var = trim($parameter[ 'if condition' ][ 'var' ][ 'var' ], "'");
|
||||
} else {
|
||||
$var = trim($parameter['if condition']['var'], "'");
|
||||
$var = trim($parameter[ 'if condition' ][ 'var' ], "'");
|
||||
}
|
||||
if (isset($compiler->template->tpl_vars[$var])) {
|
||||
$compiler->template->tpl_vars[$var]->nocache = true;
|
||||
if (isset($compiler->template->tpl_vars[ $var ])) {
|
||||
$compiler->template->tpl_vars[ $var ]->nocache = true;
|
||||
} else {
|
||||
$compiler->template->tpl_vars[$var] = new Smarty_Variable(null, true);
|
||||
$compiler->template->tpl_vars[ $var ] = new Smarty_Variable(null, true);
|
||||
}
|
||||
} else {
|
||||
$_nocache = '';
|
||||
@@ -158,21 +159,23 @@ class Smarty_Internal_Compile_Elseif extends Smarty_Internal_CompileBase
|
||||
if (empty($compiler->prefix_code)) {
|
||||
if ($condition_by_assign) {
|
||||
$this->openTag($compiler, 'elseif', array($nesting + 1, $compiler->tag_nocache));
|
||||
if (is_array($parameter['if condition']['var'])) {
|
||||
if (is_array($parameter[ 'if condition' ][ 'var' ])) {
|
||||
$_output = "<?php } else { if (!isset(\$_smarty_tpl->tpl_vars[" .
|
||||
$parameter['if condition']['var']['var'] . "]) || !is_array(\$_smarty_tpl->tpl_vars[" .
|
||||
$parameter['if condition']['var']['var'] .
|
||||
$parameter[ 'if condition' ][ 'var' ][ 'var' ] .
|
||||
"]) || !is_array(\$_smarty_tpl->tpl_vars[" .
|
||||
$parameter[ 'if condition' ][ 'var' ][ 'var' ] .
|
||||
"]->value)) \$_smarty_tpl->_createLocalArrayVariable(" .
|
||||
$parameter['if condition']['var']['var'] . "$_nocache);\n";
|
||||
$_output .= "if (\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] . "]->value" .
|
||||
$parameter['if condition']['var']['smarty_internal_index'] . " = " .
|
||||
$parameter['if condition']['value'] . ") {?>";
|
||||
$parameter[ 'if condition' ][ 'var' ][ 'var' ] . "$_nocache);\n";
|
||||
$_output .= "if (\$_smarty_tpl->tpl_vars[" . $parameter[ 'if condition' ][ 'var' ][ 'var' ] .
|
||||
"]->value" . $parameter[ 'if condition' ][ 'var' ][ 'smarty_internal_index' ] . " = " .
|
||||
$parameter[ 'if condition' ][ 'value' ] . ") {?>";
|
||||
} else {
|
||||
$_output = "<?php } else { if (!isset(\$_smarty_tpl->tpl_vars[" .
|
||||
$parameter['if condition']['var'] . "])) \$_smarty_tpl->tpl_vars[" .
|
||||
$parameter['if condition']['var'] . "] = new Smarty_Variable(null{$_nocache});";
|
||||
$_output .= "if (\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "]->value = " .
|
||||
$parameter['if condition']['value'] . ") {?>";
|
||||
$_output =
|
||||
"<?php } else { if (!isset(\$_smarty_tpl->tpl_vars[" . $parameter[ 'if condition' ][ 'var' ] .
|
||||
"])) \$_smarty_tpl->tpl_vars[" . $parameter[ 'if condition' ][ 'var' ] .
|
||||
"] = new Smarty_Variable(null{$_nocache});";
|
||||
$_output .= "if (\$_smarty_tpl->tpl_vars[" . $parameter[ 'if condition' ][ 'var' ] . "]->value = " .
|
||||
$parameter[ 'if condition' ][ 'value' ] . ") {?>";
|
||||
}
|
||||
|
||||
return $_output;
|
||||
@@ -190,24 +193,25 @@ class Smarty_Internal_Compile_Elseif extends Smarty_Internal_CompileBase
|
||||
$tmp = $compiler->appendCode("<?php } else {?>", $tmp);
|
||||
$this->openTag($compiler, 'elseif', array($nesting + 1, $compiler->tag_nocache));
|
||||
if ($condition_by_assign) {
|
||||
if (is_array($parameter['if condition']['var'])) {
|
||||
if (is_array($parameter[ 'if condition' ][ 'var' ])) {
|
||||
$_output = $compiler->appendCode($tmp, "<?php if (!isset(\$_smarty_tpl->tpl_vars[" .
|
||||
$parameter['if condition']['var']['var'] .
|
||||
$parameter[ 'if condition' ][ 'var' ][ 'var' ] .
|
||||
"]) || !is_array(\$_smarty_tpl->tpl_vars[" .
|
||||
$parameter['if condition']['var']['var'] .
|
||||
$parameter[ 'if condition' ][ 'var' ][ 'var' ] .
|
||||
"]->value)) \$_smarty_tpl->_createLocalArrayVariable(" .
|
||||
$parameter['if condition']['var']['var'] . "$_nocache);\n");
|
||||
$_output .= "if (\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] . "]->value" .
|
||||
$parameter['if condition']['var']['smarty_internal_index'] . " = " .
|
||||
$parameter['if condition']['value'] . ") {?>";
|
||||
$parameter[ 'if condition' ][ 'var' ][ 'var' ] .
|
||||
"$_nocache);\n");
|
||||
$_output .= "if (\$_smarty_tpl->tpl_vars[" . $parameter[ 'if condition' ][ 'var' ][ 'var' ] .
|
||||
"]->value" . $parameter[ 'if condition' ][ 'var' ][ 'smarty_internal_index' ] . " = " .
|
||||
$parameter[ 'if condition' ][ 'value' ] . ") {?>";
|
||||
} else {
|
||||
$_output = $compiler->appendCode($tmp, "<?php if (!isset(\$_smarty_tpl->tpl_vars[" .
|
||||
$parameter['if condition']['var'] .
|
||||
$parameter[ 'if condition' ][ 'var' ] .
|
||||
"])) \$_smarty_tpl->tpl_vars[" .
|
||||
$parameter['if condition']['var'] .
|
||||
$parameter[ 'if condition' ][ 'var' ] .
|
||||
"] = new Smarty_Variable(null{$_nocache});");
|
||||
$_output .= "if (\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "]->value = " .
|
||||
$parameter['if condition']['value'] . ") {?>";
|
||||
$_output .= "if (\$_smarty_tpl->tpl_vars[" . $parameter[ 'if condition' ][ 'var' ] . "]->value = " .
|
||||
$parameter[ 'if condition' ][ 'value' ] . ") {?>";
|
||||
}
|
||||
|
||||
return $_output;
|
||||
|
@@ -58,8 +58,7 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $valid_scopes = array('local' => true, 'parent' => true, 'root' => true,
|
||||
'tpl_root' => true);
|
||||
public $valid_scopes = array('local' => true, 'parent' => true, 'root' => true, 'tpl_root' => true);
|
||||
|
||||
/**
|
||||
* Compiles code for the {include} tag
|
||||
@@ -76,13 +75,13 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
|
||||
$hashResourceName = $fullResourceName = $source_resource = $_attr['file'];
|
||||
$hashResourceName = $fullResourceName = $source_resource = $_attr[ 'file' ];
|
||||
$variable_template = false;
|
||||
$cache_tpl = false;
|
||||
// parse resource_name
|
||||
if (preg_match('/^([\'"])(([A-Za-z0-9_\-]{2,})[:])?(([^$()]+)|(.+))\1$/', $source_resource, $match)) {
|
||||
$type = !empty($match[3]) ? $match[3] : $compiler->template->smarty->default_resource_type;
|
||||
$name = !empty($match[5]) ? $match[5] : $match[6];
|
||||
$type = !empty($match[ 3 ]) ? $match[ 3 ] : $compiler->template->smarty->default_resource_type;
|
||||
$name = !empty($match[ 5 ]) ? $match[ 5 ] : $match[ 6 ];
|
||||
$handler = Smarty_Resource::load($compiler->smarty, $type);
|
||||
if ($handler->recompiled || $handler->uncompiled) {
|
||||
$variable_template = true;
|
||||
@@ -91,40 +90,41 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase
|
||||
if ($type != 'string') {
|
||||
$fullResourceName = "{$type}:{$name}";
|
||||
$compiled = $compiler->parent_compiler->template->compiled;
|
||||
if (isset($compiled->includes[$fullResourceName])) {
|
||||
$compiled->includes[$fullResourceName] ++;
|
||||
if (isset($compiled->includes[ $fullResourceName ])) {
|
||||
$compiled->includes[ $fullResourceName ] ++;
|
||||
$cache_tpl = true;
|
||||
} else {
|
||||
$compiled->includes[$fullResourceName] = 1;
|
||||
$compiled->includes[ $fullResourceName ] = 1;
|
||||
}
|
||||
$fullResourceName = '"' . $fullResourceName . '"';
|
||||
}
|
||||
}
|
||||
if (empty($match[5])) {
|
||||
if (empty($match[ 5 ])) {
|
||||
$variable_template = true;
|
||||
}
|
||||
} else {
|
||||
$variable_template = true;
|
||||
}
|
||||
|
||||
if (isset($_attr['assign'])) {
|
||||
if (isset($_attr[ 'assign' ])) {
|
||||
// output will be stored in a smarty variable instead of being displayed
|
||||
$_assign = $_attr['assign'];
|
||||
$_assign = $_attr[ 'assign' ];
|
||||
}
|
||||
|
||||
// scope setup
|
||||
$_scope = Smarty::SCOPE_LOCAL;
|
||||
if (isset($_attr['scope'])) {
|
||||
$_attr['scope'] = trim($_attr['scope'], "'\"");
|
||||
if (!isset($this->valid_scopes[$_attr['scope']])) {
|
||||
$compiler->trigger_template_error("illegal value '{$_attr['scope']}' for \"scope\" attribute", null, true);
|
||||
if (isset($_attr[ 'scope' ])) {
|
||||
$_attr[ 'scope' ] = trim($_attr[ 'scope' ], "'\"");
|
||||
if (!isset($this->valid_scopes[ $_attr[ 'scope' ] ])) {
|
||||
$compiler->trigger_template_error("illegal value '{$_attr['scope']}' for \"scope\" attribute", null,
|
||||
true);
|
||||
}
|
||||
if ($_attr['scope'] != 'local') {
|
||||
if ($_attr['scope'] == 'parent') {
|
||||
if ($_attr[ 'scope' ] != 'local') {
|
||||
if ($_attr[ 'scope' ] == 'parent') {
|
||||
$_scope = Smarty::SCOPE_PARENT;
|
||||
} elseif ($_attr['scope'] == 'root') {
|
||||
} elseif ($_attr[ 'scope' ] == 'root') {
|
||||
$_scope = Smarty::SCOPE_ROOT;
|
||||
} elseif ($_attr['scope'] == 'tpl_root') {
|
||||
} elseif ($_attr[ 'scope' ] == 'tpl_root') {
|
||||
$_scope = Smarty::SCOPE_TPL_ROOT;
|
||||
}
|
||||
$_scope += (isset($_attr[ 'bubble_up' ]) && $_attr[ 'bubble_up' ] == 'false') ? 0 :
|
||||
@@ -141,7 +141,7 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase
|
||||
// assume caching is off
|
||||
$_caching = Smarty::CACHING_OFF;
|
||||
|
||||
if ($_attr['nocache'] === true) {
|
||||
if ($_attr[ 'nocache' ] === true) {
|
||||
$compiler->tag_nocache = true;
|
||||
}
|
||||
|
||||
@@ -153,10 +153,10 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase
|
||||
}
|
||||
|
||||
// flag if included template code should be merged into caller
|
||||
$merge_compiled_includes = ($compiler->smarty->merge_compiled_includes || $_attr['inline'] === true) &&
|
||||
$merge_compiled_includes = ($compiler->smarty->merge_compiled_includes || $_attr[ 'inline' ] === true) &&
|
||||
!$compiler->template->source->handler->recompiled;
|
||||
|
||||
if ($merge_compiled_includes && $_attr['inline'] !== true) {
|
||||
if ($merge_compiled_includes && $_attr[ 'inline' ] !== true) {
|
||||
// variable template name ?
|
||||
if ($variable_template) {
|
||||
$merge_compiled_includes = false;
|
||||
@@ -166,10 +166,11 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase
|
||||
}
|
||||
}
|
||||
// variable compile_id?
|
||||
if (isset($_attr['compile_id'])) {
|
||||
if (!((substr_count($_attr['compile_id'], '"') == 2 || substr_count($_attr['compile_id'], "'") == 2 ||
|
||||
is_numeric($_attr['compile_id']))) || substr_count($_attr['compile_id'], '(') != 0 ||
|
||||
substr_count($_attr['compile_id'], '$_smarty_tpl->') != 0
|
||||
if (isset($_attr[ 'compile_id' ])) {
|
||||
if (!((substr_count($_attr[ 'compile_id' ], '"') == 2 ||
|
||||
substr_count($_attr[ 'compile_id' ], "'") == 2 || is_numeric($_attr[ 'compile_id' ]))) ||
|
||||
substr_count($_attr[ 'compile_id' ], '(') != 0 ||
|
||||
substr_count($_attr[ 'compile_id' ], '$_smarty_tpl->') != 0
|
||||
) {
|
||||
$merge_compiled_includes = false;
|
||||
if ($compiler->template->caching) {
|
||||
@@ -186,28 +187,28 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase
|
||||
* a call in nocache mode.
|
||||
*
|
||||
*/
|
||||
if ($_attr['nocache'] !== true && $_attr['caching']) {
|
||||
$_caching = $_new_caching = (int) $_attr['caching'];
|
||||
if ($_attr[ 'nocache' ] !== true && $_attr[ 'caching' ]) {
|
||||
$_caching = $_new_caching = (int) $_attr[ 'caching' ];
|
||||
$call_nocache = true;
|
||||
} else {
|
||||
$_new_caching = Smarty::CACHING_LIFETIME_CURRENT;
|
||||
}
|
||||
if (isset($_attr['cache_lifetime'])) {
|
||||
$_cache_lifetime = $_attr['cache_lifetime'];
|
||||
if (isset($_attr[ 'cache_lifetime' ])) {
|
||||
$_cache_lifetime = $_attr[ 'cache_lifetime' ];
|
||||
$call_nocache = true;
|
||||
$_caching = $_new_caching;
|
||||
} else {
|
||||
$_cache_lifetime = '$_smarty_tpl->cache_lifetime';
|
||||
}
|
||||
if (isset($_attr['cache_id'])) {
|
||||
$_cache_id = $_attr['cache_id'];
|
||||
if (isset($_attr[ 'cache_id' ])) {
|
||||
$_cache_id = $_attr[ 'cache_id' ];
|
||||
$call_nocache = true;
|
||||
$_caching = $_new_caching;
|
||||
} else {
|
||||
$_cache_id = '$_smarty_tpl->cache_id';
|
||||
}
|
||||
if (isset($_attr['compile_id'])) {
|
||||
$_compile_id = $_attr['compile_id'];
|
||||
if (isset($_attr[ 'compile_id' ])) {
|
||||
$_compile_id = $_attr[ 'compile_id' ];
|
||||
} else {
|
||||
$_compile_id = '$_smarty_tpl->compile_id';
|
||||
}
|
||||
@@ -219,10 +220,10 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase
|
||||
|
||||
$has_compiled_template = false;
|
||||
if ($merge_compiled_includes) {
|
||||
$c_id = isset($_attr['compile_id']) ? $_attr['compile_id'] : $compiler->template->compile_id;
|
||||
$c_id = isset($_attr[ 'compile_id' ]) ? $_attr[ 'compile_id' ] : $compiler->template->compile_id;
|
||||
// we must observe different compile_id and caching
|
||||
$t_hash = sha1($c_id . ($_caching ? '--caching' : '--nocaching'));
|
||||
if (!isset($compiler->parent_compiler->mergedSubTemplatesData[$hashResourceName][$t_hash])) {
|
||||
if (!isset($compiler->parent_compiler->mergedSubTemplatesData[ $hashResourceName ][ $t_hash ])) {
|
||||
$has_compiled_template =
|
||||
$this->compileInlineTemplate($compiler, $fullResourceName, $_caching, $hashResourceName, $t_hash,
|
||||
$c_id);
|
||||
@@ -231,7 +232,7 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase
|
||||
}
|
||||
}
|
||||
// delete {include} standard attributes
|
||||
unset($_attr['file'], $_attr['assign'], $_attr['cache_id'], $_attr['compile_id'], $_attr['cache_lifetime'], $_attr['nocache'], $_attr['caching'], $_attr['scope'], $_attr['inline'], $_attr['bubble_up']);
|
||||
unset($_attr[ 'file' ], $_attr[ 'assign' ], $_attr[ 'cache_id' ], $_attr[ 'compile_id' ], $_attr[ 'cache_lifetime' ], $_attr[ 'nocache' ], $_attr[ 'caching' ], $_attr[ 'scope' ], $_attr[ 'inline' ], $_attr[ 'bubble_up' ]);
|
||||
// remaining attributes must be assigned as smarty variable
|
||||
$_vars_nc = '';
|
||||
if (!empty($_attr)) {
|
||||
@@ -315,11 +316,12 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase
|
||||
{
|
||||
$compiler->smarty->allow_ambiguous_resources = true;
|
||||
/* @var Smarty_Internal_Template $tpl */
|
||||
$tpl =
|
||||
new $compiler->smarty->template_class (trim($fullResourceName, '"\''), $compiler->smarty, $compiler->template,
|
||||
$compiler->template->cache_id, $c_id, $_caching);
|
||||
$tpl = new $compiler->smarty->template_class (trim($fullResourceName, '"\''), $compiler->smarty,
|
||||
$compiler->template, $compiler->template->cache_id, $c_id,
|
||||
$_caching);
|
||||
if (!($tpl->source->handler->uncompiled) && $tpl->source->exists) {
|
||||
$compiler->parent_compiler->mergedSubTemplatesData[$hashResourceName][$t_hash]['uid'] = $tpl->source->uid;
|
||||
$compiler->parent_compiler->mergedSubTemplatesData[ $hashResourceName ][ $t_hash ][ 'uid' ] =
|
||||
$tpl->source->uid;
|
||||
if (isset($compiler->template->ext->_inheritance)) {
|
||||
$tpl->ext->_inheritance = clone $compiler->template->ext->_inheritance;
|
||||
}
|
||||
@@ -327,17 +329,18 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase
|
||||
$tpl->compiled->nocache_hash = $compiler->parent_compiler->template->compiled->nocache_hash;
|
||||
$tpl->loadCompiler();
|
||||
// save unique function name
|
||||
$compiler->parent_compiler->mergedSubTemplatesData[$hashResourceName][$t_hash]['func'] =
|
||||
$compiler->parent_compiler->mergedSubTemplatesData[ $hashResourceName ][ $t_hash ][ 'func' ] =
|
||||
$tpl->compiled->unifunc = 'content_' . str_replace(array('.', ','), '_', uniqid('', true));
|
||||
// make sure whole chain gets compiled
|
||||
$tpl->mustCompile = true;
|
||||
$compiler->parent_compiler->mergedSubTemplatesData[$hashResourceName][$t_hash]['nocache_hash'] =
|
||||
$compiler->parent_compiler->mergedSubTemplatesData[ $hashResourceName ][ $t_hash ][ 'nocache_hash' ] =
|
||||
$tpl->compiled->nocache_hash;
|
||||
if ($compiler->template->source->type == 'file') {
|
||||
$sourceInfo = $compiler->template->source->filepath;
|
||||
} else {
|
||||
$basename = $compiler->template->source->handler->getBasename($compiler->template->source);
|
||||
$sourceInfo = $compiler->template->source->type .':' . ($basename ? $basename : $compiler->template->source->name);
|
||||
$sourceInfo = $compiler->template->source->type . ':' .
|
||||
($basename ? $basename : $compiler->template->source->name);
|
||||
}
|
||||
// get compiled code
|
||||
$compiled_code = "<?php\n\n";
|
||||
@@ -358,7 +361,7 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase
|
||||
$compiled_code);
|
||||
$compiler->template->compiled->has_nocache_code = true;
|
||||
}
|
||||
$compiler->parent_compiler->mergedSubTemplatesCode[$tpl->compiled->unifunc] = $compiled_code;
|
||||
$compiler->parent_compiler->mergedSubTemplatesCode[ $tpl->compiled->unifunc ] = $compiled_code;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
@@ -64,7 +64,7 @@ class Smarty_Internal_Compile_Include_Php extends Smarty_Internal_CompileBase
|
||||
$_smarty_tpl = $compiler->template;
|
||||
$_filepath = false;
|
||||
$_file = null;
|
||||
eval('$_file = @' . $_attr['file'] . ';');
|
||||
eval('$_file = @' . $_attr[ 'file' ] . ';');
|
||||
if (!isset($compiler->smarty->security_policy) && file_exists($_file)) {
|
||||
$_filepath = $compiler->smarty->_realpath($_file, true);
|
||||
} else {
|
||||
@@ -91,13 +91,13 @@ class Smarty_Internal_Compile_Include_Php extends Smarty_Internal_CompileBase
|
||||
$compiler->smarty->security_policy->isTrustedPHPDir($_filepath);
|
||||
}
|
||||
|
||||
if (isset($_attr['assign'])) {
|
||||
if (isset($_attr[ 'assign' ])) {
|
||||
// output will be stored in a smarty variable instead of being displayed
|
||||
$_assign = $_attr['assign'];
|
||||
$_assign = $_attr[ 'assign' ];
|
||||
}
|
||||
$_once = '_once';
|
||||
if (isset($_attr['once'])) {
|
||||
if ($_attr['once'] == 'false') {
|
||||
if (isset($_attr[ 'once' ])) {
|
||||
if ($_attr[ 'once' ] == 'false') {
|
||||
$_once = '';
|
||||
}
|
||||
}
|
||||
|
@@ -66,24 +66,24 @@ class Smarty_Internal_Compile_Insert extends Smarty_Internal_CompileBase
|
||||
|
||||
$_output = '<?php ';
|
||||
// save possible attributes
|
||||
eval('$_name = @' . $_attr['name'] . ';');
|
||||
if (isset($_attr['assign'])) {
|
||||
eval('$_name = @' . $_attr[ 'name' ] . ';');
|
||||
if (isset($_attr[ 'assign' ])) {
|
||||
// output will be stored in a smarty variable instead of being displayed
|
||||
$_assign = $_attr['assign'];
|
||||
$_assign = $_attr[ 'assign' ];
|
||||
// create variable to make sure that the compiler knows about its nocache status
|
||||
$var = trim($_attr['assign'], "'");
|
||||
if (isset($compiler->template->tpl_vars[$var])) {
|
||||
$compiler->template->tpl_vars[$var]->nocache = true;
|
||||
$var = trim($_attr[ 'assign' ], "'");
|
||||
if (isset($compiler->template->tpl_vars[ $var ])) {
|
||||
$compiler->template->tpl_vars[ $var ]->nocache = true;
|
||||
} else {
|
||||
$compiler->template->tpl_vars[$var] = new Smarty_Variable(null, true);
|
||||
$compiler->template->tpl_vars[ $var ] = new Smarty_Variable(null, true);
|
||||
}
|
||||
}
|
||||
if (isset($_attr['script'])) {
|
||||
if (isset($_attr[ 'script' ])) {
|
||||
// script which must be included
|
||||
$_function = "smarty_insert_{$_name}";
|
||||
$_smarty_tpl = $compiler->template;
|
||||
$_filepath = false;
|
||||
eval('$_script = @' . $_attr['script'] . ';');
|
||||
eval('$_script = @' . $_attr[ 'script' ] . ';');
|
||||
if (!isset($compiler->smarty->security_policy) && file_exists($_script)) {
|
||||
$_filepath = $_script;
|
||||
} else {
|
||||
@@ -109,7 +109,8 @@ class Smarty_Internal_Compile_Insert extends Smarty_Internal_CompileBase
|
||||
$_output .= "require_once '{$_filepath}' ;";
|
||||
require_once $_filepath;
|
||||
if (!is_callable($_function)) {
|
||||
$compiler->trigger_template_error(" {insert} function '{$_function}' is not callable in script file '{$_script}'", null, true);
|
||||
$compiler->trigger_template_error(" {insert} function '{$_function}' is not callable in script file '{$_script}'",
|
||||
null, true);
|
||||
}
|
||||
} else {
|
||||
$_filepath = 'null';
|
||||
@@ -118,12 +119,13 @@ class Smarty_Internal_Compile_Insert extends Smarty_Internal_CompileBase
|
||||
if (!is_callable($_function)) {
|
||||
// try plugin
|
||||
if (!$_function = $compiler->getPlugin($_name, 'insert')) {
|
||||
$compiler->trigger_template_error("{insert} no function or plugin found for '{$_name}'", null, true);
|
||||
$compiler->trigger_template_error("{insert} no function or plugin found for '{$_name}'", null,
|
||||
true);
|
||||
}
|
||||
}
|
||||
}
|
||||
// delete {insert} standard attributes
|
||||
unset($_attr['name'], $_attr['assign'], $_attr['script'], $_attr['nocache']);
|
||||
unset($_attr[ 'name' ], $_attr[ 'assign' ], $_attr[ 'script' ], $_attr[ 'nocache' ]);
|
||||
// convert attributes into parameter array string
|
||||
$_paramsArray = array();
|
||||
foreach ($_attr as $_key => $_value) {
|
||||
|
@@ -29,7 +29,7 @@ class Smarty_Internal_Compile_Ldelim extends Smarty_Internal_CompileBase
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
|
||||
{
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
if ($_attr['nocache'] === true) {
|
||||
if ($_attr[ 'nocache' ] === true) {
|
||||
$compiler->trigger_template_error('nocache option not allowed', null, true);
|
||||
}
|
||||
// this tag does not return compiled code
|
||||
|
@@ -66,8 +66,7 @@ class Smarty_Internal_Compile_Private_Block_Plugin extends Smarty_Internal_Compi
|
||||
$output .= "if (!is_callable({$callable})) {\nthrow new SmartyException('block tag \'{$tag}\' not callable or registered');\n}\n";
|
||||
}
|
||||
$output .= "\$_smarty_tpl->smarty->_cache['_tag_stack'][] = array('{$tag}', {$_params});\n";
|
||||
$output .=
|
||||
"\$_block_repeat{$this->nesting}=true;\necho {$callback}({$_params}, null, \$_smarty_tpl, \$_block_repeat{$this->nesting});\nwhile (\$_block_repeat{$this->nesting}) {\nob_start();\n?>";
|
||||
$output .= "\$_block_repeat{$this->nesting}=true;\necho {$callback}({$_params}, null, \$_smarty_tpl, \$_block_repeat{$this->nesting});\nwhile (\$_block_repeat{$this->nesting}) {\nob_start();\n?>";
|
||||
$this->openTag($compiler, $tag, array($_params, $compiler->nocache, $callback));
|
||||
// maybe nocache because of nocache variables or nocache plugin
|
||||
$compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
|
||||
|
@@ -110,11 +110,11 @@ class Smarty_Internal_Compile_Private_ForeachSection extends Smarty_Internal_Com
|
||||
public function buildPropertyPreg($named, $attributes)
|
||||
{
|
||||
if ($named) {
|
||||
$this->resultOffsets['named'] = $this->startOffset + 3;
|
||||
$this->resultOffsets[ 'named' ] = $this->startOffset + 3;
|
||||
$this->propertyPreg .= "([\$]smarty[.]{$this->tagName}[.]{$attributes['name']}[.](";
|
||||
$properties = $this->nameProperties;
|
||||
} else {
|
||||
$this->resultOffsets['item'] = $this->startOffset + 3;
|
||||
$this->resultOffsets[ 'item' ] = $this->startOffset + 3;
|
||||
$this->propertyPreg .= "([\$]{$attributes['item']}[@](";
|
||||
$properties = $this->itemProperties;
|
||||
}
|
||||
@@ -140,8 +140,8 @@ class Smarty_Internal_Compile_Private_ForeachSection extends Smarty_Internal_Com
|
||||
preg_match_all($this->propertyPreg, $source, $match, PREG_SET_ORDER);
|
||||
foreach ($this->resultOffsets as $key => $offset) {
|
||||
foreach ($match as $m) {
|
||||
if (isset($m[$offset]) && !empty($m[$offset])) {
|
||||
$this->matchResults[$key][strtolower($m[$offset])] = true;
|
||||
if (isset($m[ $offset ]) && !empty($m[ $offset ])) {
|
||||
$this->matchResults[ $key ][ strtolower($m[ $offset ]) ] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -173,9 +173,11 @@ class Smarty_Internal_Compile_Private_ForeachSection extends Smarty_Internal_Com
|
||||
$_content = $nextCompiler->template->source->getContent();
|
||||
if ($_content != '') {
|
||||
// run pre filter if required
|
||||
if ((isset($nextCompiler->smarty->autoload_filters['pre']) ||
|
||||
isset($nextCompiler->smarty->registered_filters['pre']))) {
|
||||
$_content = $nextCompiler->smarty->ext->_filterHandler->runFilter('pre', $_content, $nextCompiler->template);
|
||||
if ((isset($nextCompiler->smarty->autoload_filters[ 'pre' ]) ||
|
||||
isset($nextCompiler->smarty->registered_filters[ 'pre' ]))
|
||||
) {
|
||||
$_content = $nextCompiler->smarty->ext->_filterHandler->runFilter('pre', $_content,
|
||||
$nextCompiler->template);
|
||||
}
|
||||
$this->matchProperty($_content);
|
||||
}
|
||||
@@ -190,7 +192,6 @@ class Smarty_Internal_Compile_Private_ForeachSection extends Smarty_Internal_Com
|
||||
*/
|
||||
public function matchBlockSource(Smarty_Internal_TemplateCompilerBase $compiler)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -50,10 +50,10 @@ class Smarty_Internal_Compile_Private_Function_Plugin extends Smarty_Internal_Co
|
||||
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
if ($_attr['nocache'] === true) {
|
||||
if ($_attr[ 'nocache' ] === true) {
|
||||
$compiler->tag_nocache = true;
|
||||
}
|
||||
unset($_attr['nocache']);
|
||||
unset($_attr[ 'nocache' ]);
|
||||
// convert attributes into parameter array string
|
||||
$_paramsArray = array();
|
||||
foreach ($_attr as $_key => $_value) {
|
||||
|
@@ -31,15 +31,15 @@ class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBa
|
||||
{
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
$output = $parameter['value'];
|
||||
$output = $parameter[ 'value' ];
|
||||
// loop over list of modifiers
|
||||
foreach ($parameter['modifierlist'] as $single_modifier) {
|
||||
$modifier = $single_modifier[0];
|
||||
$single_modifier[0] = $output;
|
||||
foreach ($parameter[ 'modifierlist' ] as $single_modifier) {
|
||||
$modifier = $single_modifier[ 0 ];
|
||||
$single_modifier[ 0 ] = $output;
|
||||
$params = implode(',', $single_modifier);
|
||||
// check if we know already the type of modifier
|
||||
if (isset($compiler->known_modifier_type[$modifier])) {
|
||||
$modifier_types = array($compiler->known_modifier_type[$modifier]);
|
||||
if (isset($compiler->known_modifier_type[ $modifier ])) {
|
||||
$modifier_types = array($compiler->known_modifier_type[ $modifier ]);
|
||||
} else {
|
||||
$modifier_types = array(1, 2, 3, 4, 5, 6);
|
||||
}
|
||||
@@ -47,27 +47,30 @@ class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBa
|
||||
switch ($type) {
|
||||
case 1:
|
||||
// registered modifier
|
||||
if (isset($compiler->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER][$modifier])) {
|
||||
$function = $compiler->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER][$modifier][0];
|
||||
if (isset($compiler->smarty->registered_plugins[ Smarty::PLUGIN_MODIFIER ][ $modifier ])) {
|
||||
$function =
|
||||
$compiler->smarty->registered_plugins[ Smarty::PLUGIN_MODIFIER ][ $modifier ][ 0 ];
|
||||
if (!is_array($function)) {
|
||||
$output = "{$function}({$params})";
|
||||
} else {
|
||||
if (is_object($function[0])) {
|
||||
if (is_object($function[ 0 ])) {
|
||||
$output = '$_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER][\'' .
|
||||
$modifier . '\'][0][0]->' . $function[1] . '(' . $params . ')';
|
||||
$modifier . '\'][0][0]->' . $function[ 1 ] . '(' . $params . ')';
|
||||
} else {
|
||||
$output = $function[0] . '::' . $function[1] . '(' . $params . ')';
|
||||
$output = $function[ 0 ] . '::' . $function[ 1 ] . '(' . $params . ')';
|
||||
}
|
||||
}
|
||||
$compiler->known_modifier_type[$modifier] = $type;
|
||||
$compiler->known_modifier_type[ $modifier ] = $type;
|
||||
break 2;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
// registered modifier compiler
|
||||
if (isset($compiler->smarty->registered_plugins[Smarty::PLUGIN_MODIFIERCOMPILER][$modifier][0])) {
|
||||
$output = call_user_func($compiler->smarty->registered_plugins[Smarty::PLUGIN_MODIFIERCOMPILER][$modifier][0], $single_modifier, $compiler->smarty);
|
||||
$compiler->known_modifier_type[$modifier] = $type;
|
||||
if (isset($compiler->smarty->registered_plugins[ Smarty::PLUGIN_MODIFIERCOMPILER ][ $modifier ][ 0 ])) {
|
||||
$output =
|
||||
call_user_func($compiler->smarty->registered_plugins[ Smarty::PLUGIN_MODIFIERCOMPILER ][ $modifier ][ 0 ],
|
||||
$single_modifier, $compiler->smarty);
|
||||
$compiler->known_modifier_type[ $modifier ] = $type;
|
||||
break 2;
|
||||
}
|
||||
break;
|
||||
@@ -81,7 +84,7 @@ class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBa
|
||||
$plugin = 'smarty_modifiercompiler_' . $modifier;
|
||||
$output = $plugin($single_modifier, $compiler);
|
||||
}
|
||||
$compiler->known_modifier_type[$modifier] = $type;
|
||||
$compiler->known_modifier_type[ $modifier ] = $type;
|
||||
break 2;
|
||||
}
|
||||
break;
|
||||
@@ -94,7 +97,7 @@ class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBa
|
||||
) {
|
||||
$output = "{$function}({$params})";
|
||||
}
|
||||
$compiler->known_modifier_type[$modifier] = $type;
|
||||
$compiler->known_modifier_type[ $modifier ] = $type;
|
||||
break 2;
|
||||
}
|
||||
break;
|
||||
@@ -107,17 +110,17 @@ class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBa
|
||||
) {
|
||||
$output = "{$modifier}({$params})";
|
||||
}
|
||||
$compiler->known_modifier_type[$modifier] = $type;
|
||||
$compiler->known_modifier_type[ $modifier ] = $type;
|
||||
break 2;
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
// default plugin handler
|
||||
if (isset($compiler->default_handler_plugins[Smarty::PLUGIN_MODIFIER][$modifier]) ||
|
||||
if (isset($compiler->default_handler_plugins[ Smarty::PLUGIN_MODIFIER ][ $modifier ]) ||
|
||||
(is_callable($compiler->smarty->default_plugin_handler_func) &&
|
||||
$compiler->getPluginFromDefaultHandler($modifier, Smarty::PLUGIN_MODIFIER))
|
||||
) {
|
||||
$function = $compiler->default_handler_plugins[Smarty::PLUGIN_MODIFIER][$modifier][0];
|
||||
$function = $compiler->default_handler_plugins[ Smarty::PLUGIN_MODIFIER ][ $modifier ][ 0 ];
|
||||
// check if modifier allowed
|
||||
if (!is_object($compiler->smarty->security_policy) ||
|
||||
$compiler->smarty->security_policy->isTrustedModifier($modifier, $compiler)
|
||||
@@ -125,27 +128,28 @@ class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBa
|
||||
if (!is_array($function)) {
|
||||
$output = "{$function}({$params})";
|
||||
} else {
|
||||
if (is_object($function[0])) {
|
||||
$output = '$_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER][\'' .
|
||||
$modifier . '\'][0][0]->' . $function[1] . '(' . $params . ')';
|
||||
if (is_object($function[ 0 ])) {
|
||||
$output =
|
||||
'$_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER][\'' .
|
||||
$modifier . '\'][0][0]->' . $function[ 1 ] . '(' . $params . ')';
|
||||
} else {
|
||||
$output = $function[0] . '::' . $function[1] . '(' . $params . ')';
|
||||
$output = $function[ 0 ] . '::' . $function[ 1 ] . '(' . $params . ')';
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($compiler->parent_compiler->template->compiled->required_plugins['nocache'][$modifier][Smarty::PLUGIN_MODIFIER]['file']) ||
|
||||
isset($compiler->parent_compiler->template->compiled->required_plugins['compiled'][$modifier][Smarty::PLUGIN_MODIFIER]['file'])
|
||||
if (isset($compiler->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $modifier ][ Smarty::PLUGIN_MODIFIER ][ 'file' ]) ||
|
||||
isset($compiler->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $modifier ][ Smarty::PLUGIN_MODIFIER ][ 'file' ])
|
||||
) {
|
||||
// was a plugin
|
||||
$compiler->known_modifier_type[$modifier] = 4;
|
||||
$compiler->known_modifier_type[ $modifier ] = 4;
|
||||
} else {
|
||||
$compiler->known_modifier_type[$modifier] = $type;
|
||||
$compiler->known_modifier_type[ $modifier ] = $type;
|
||||
}
|
||||
break 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isset($compiler->known_modifier_type[$modifier])) {
|
||||
if (!isset($compiler->known_modifier_type[ $modifier ])) {
|
||||
$compiler->trigger_template_error("unknown modifier \"" . $modifier . "\"", null, true);
|
||||
}
|
||||
}
|
||||
|
@@ -39,19 +39,19 @@ class Smarty_Internal_Compile_Private_Object_Function extends Smarty_Internal_Co
|
||||
{
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
if ($_attr['nocache'] === true) {
|
||||
if ($_attr[ 'nocache' ] === true) {
|
||||
$compiler->tag_nocache = true;
|
||||
}
|
||||
unset($_attr['nocache']);
|
||||
unset($_attr[ 'nocache' ]);
|
||||
$_assign = null;
|
||||
if (isset($_attr['assign'])) {
|
||||
$_assign = $_attr['assign'];
|
||||
unset($_attr['assign']);
|
||||
if (isset($_attr[ 'assign' ])) {
|
||||
$_assign = $_attr[ 'assign' ];
|
||||
unset($_attr[ 'assign' ]);
|
||||
}
|
||||
// method or property ?
|
||||
if (method_exists($compiler->smarty->registered_objects[$tag][0], $method)) {
|
||||
if (method_exists($compiler->smarty->registered_objects[ $tag ][ 0 ], $method)) {
|
||||
// convert attributes into parameter array string
|
||||
if ($compiler->smarty->registered_objects[$tag][2]) {
|
||||
if ($compiler->smarty->registered_objects[ $tag ][ 2 ]) {
|
||||
$_paramsArray = array();
|
||||
foreach ($_attr as $_key => $_value) {
|
||||
if (is_int($_key)) {
|
||||
|
@@ -40,59 +40,69 @@ class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
$compiler->has_code = false;
|
||||
if ($_attr['type'] == 'xml') {
|
||||
if ($_attr[ 'type' ] == 'xml') {
|
||||
$compiler->tag_nocache = true;
|
||||
$save = $compiler->template->compiled->has_nocache_code;
|
||||
$output = addcslashes($_attr['code'], "'\\");
|
||||
$compiler->parser->current_buffer->append_subtree($compiler->parser, new Smarty_Internal_ParseTree_Tag($compiler->parser, $compiler->processNocacheCode("<?php echo '" .
|
||||
$output = addcslashes($_attr[ 'code' ], "'\\");
|
||||
$compiler->parser->current_buffer->append_subtree($compiler->parser,
|
||||
new Smarty_Internal_ParseTree_Tag($compiler->parser,
|
||||
$compiler->processNocacheCode("<?php echo '" .
|
||||
$output .
|
||||
"';?>", true)));
|
||||
"';?>",
|
||||
true)));
|
||||
$compiler->template->compiled->has_nocache_code = $save;
|
||||
return '';
|
||||
}
|
||||
if ($_attr['type'] != 'tag') {
|
||||
if ($_attr[ 'type' ] != 'tag') {
|
||||
if ($compiler->php_handling == Smarty::PHP_REMOVE) {
|
||||
return '';
|
||||
} elseif ($compiler->php_handling == Smarty::PHP_QUOTE) {
|
||||
$output = preg_replace_callback('#(<\?(?:php|=)?)|(<%)|(<script\s+language\s*=\s*["\']?\s*php\s*["\']?\s*>)|(\?>)|(%>)|(<\/script>)#i', array($this,
|
||||
'quote'), $_attr['code']);
|
||||
$compiler->parser->current_buffer->append_subtree($compiler->parser, new Smarty_Internal_ParseTree_Text($output));
|
||||
$output =
|
||||
preg_replace_callback('#(<\?(?:php|=)?)|(<%)|(<script\s+language\s*=\s*["\']?\s*php\s*["\']?\s*>)|(\?>)|(%>)|(<\/script>)#i',
|
||||
array($this, 'quote'), $_attr[ 'code' ]);
|
||||
$compiler->parser->current_buffer->append_subtree($compiler->parser,
|
||||
new Smarty_Internal_ParseTree_Text($output));
|
||||
return '';
|
||||
} elseif ($compiler->php_handling == Smarty::PHP_PASSTHRU || $_attr['type'] == 'unmatched') {
|
||||
} elseif ($compiler->php_handling == Smarty::PHP_PASSTHRU || $_attr[ 'type' ] == 'unmatched') {
|
||||
$compiler->tag_nocache = true;
|
||||
$save = $compiler->template->compiled->has_nocache_code;
|
||||
$output = addcslashes($_attr['code'], "'\\");
|
||||
$compiler->parser->current_buffer->append_subtree($compiler->parser, new Smarty_Internal_ParseTree_Tag($compiler->parser, $compiler->processNocacheCode("<?php echo '" .
|
||||
$output = addcslashes($_attr[ 'code' ], "'\\");
|
||||
$compiler->parser->current_buffer->append_subtree($compiler->parser,
|
||||
new Smarty_Internal_ParseTree_Tag($compiler->parser,
|
||||
$compiler->processNocacheCode("<?php echo '" .
|
||||
$output .
|
||||
"';?>", true)));
|
||||
"';?>",
|
||||
true)));
|
||||
$compiler->template->compiled->has_nocache_code = $save;
|
||||
return '';
|
||||
} elseif ($compiler->php_handling == Smarty::PHP_ALLOW) {
|
||||
if (!($compiler->smarty instanceof SmartyBC)) {
|
||||
$compiler->trigger_template_error('$smarty->php_handling PHP_ALLOW not allowed. Use SmartyBC to enable it', null, true);
|
||||
$compiler->trigger_template_error('$smarty->php_handling PHP_ALLOW not allowed. Use SmartyBC to enable it',
|
||||
null, true);
|
||||
}
|
||||
$compiler->has_code = true;
|
||||
return $_attr['code'];
|
||||
return $_attr[ 'code' ];
|
||||
} else {
|
||||
$compiler->trigger_template_error('Illegal $smarty->php_handling value', null, true);
|
||||
}
|
||||
} else {
|
||||
$compiler->has_code = true;
|
||||
if (!($compiler->smarty instanceof SmartyBC)) {
|
||||
$compiler->trigger_template_error('{php}{/php} tags not allowed. Use SmartyBC to enable them', null, true);
|
||||
$compiler->trigger_template_error('{php}{/php} tags not allowed. Use SmartyBC to enable them', null,
|
||||
true);
|
||||
}
|
||||
$ldel = preg_quote($compiler->smarty->left_delimiter, '#');
|
||||
$rdel = preg_quote($compiler->smarty->right_delimiter, '#');
|
||||
preg_match("#^({$ldel}php\\s*)((.)*?)({$rdel})#", $_attr['code'], $match);
|
||||
if (!empty($match[2])) {
|
||||
if ('nocache' == trim($match[2])) {
|
||||
preg_match("#^({$ldel}php\\s*)((.)*?)({$rdel})#", $_attr[ 'code' ], $match);
|
||||
if (!empty($match[ 2 ])) {
|
||||
if ('nocache' == trim($match[ 2 ])) {
|
||||
$compiler->tag_nocache = true;
|
||||
} else {
|
||||
$compiler->trigger_template_error("illegal value of option flag \"{$match[2]}\"", null, true);
|
||||
}
|
||||
}
|
||||
return preg_replace(array("#^{$ldel}\\s*php\\s*(.)*?{$rdel}#",
|
||||
"#{$ldel}\\s*/\\s*php\\s*{$rdel}$#"), array('<?php ', '?>'), $_attr['code']);
|
||||
return preg_replace(array("#^{$ldel}\\s*php\\s*(.)*?{$rdel}#", "#{$ldel}\\s*/\\s*php\\s*{$rdel}$#"),
|
||||
array('<?php ', '?>'), $_attr[ 'code' ]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,14 +162,15 @@ class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase
|
||||
$start = $lex->counter + strlen($lex->value);
|
||||
$body = true;
|
||||
if (preg_match('~' . preg_quote($closeTag, '~') . '~i', $lex->data, $match, PREG_OFFSET_CAPTURE, $start)) {
|
||||
$close = $match[0][1];
|
||||
$close = $match[ 0 ][ 1 ];
|
||||
} else {
|
||||
$lex->compiler->trigger_template_error("missing closing tag '{$closeTag}'");
|
||||
}
|
||||
while ($body) {
|
||||
if (preg_match('~([/][*])|([/][/][^\n]*)|(\'[^\'\\\\]*(?:\\.[^\'\\\\]*)*\')|("[^"\\\\]*(?:\\.[^"\\\\]*)*")~', $lex->data, $match, PREG_OFFSET_CAPTURE, $start)) {
|
||||
$value = $match[0][0];
|
||||
$from = $pos = $match[0][1];
|
||||
if (preg_match('~([/][*])|([/][/][^\n]*)|(\'[^\'\\\\]*(?:\\.[^\'\\\\]*)*\')|("[^"\\\\]*(?:\\.[^"\\\\]*)*")~',
|
||||
$lex->data, $match, PREG_OFFSET_CAPTURE, $start)) {
|
||||
$value = $match[ 0 ][ 0 ];
|
||||
$from = $pos = $match[ 0 ][ 1 ];
|
||||
if ($pos > $close) {
|
||||
$body = false;
|
||||
} else {
|
||||
@@ -168,15 +179,15 @@ class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase
|
||||
if ($phpCommentStart) {
|
||||
$phpCommentEnd = preg_match('~([*][/])~', $lex->data, $match, PREG_OFFSET_CAPTURE, $start);
|
||||
if ($phpCommentEnd) {
|
||||
$pos2 = $match[0][1];
|
||||
$start = $pos2 + strlen($match[0][0]);
|
||||
$pos2 = $match[ 0 ][ 1 ];
|
||||
$start = $pos2 + strlen($match[ 0 ][ 0 ]);
|
||||
}
|
||||
}
|
||||
while ($close > $pos && $close < $start) {
|
||||
if (preg_match('~' . preg_quote($closeTag, '~') .
|
||||
'~i', $lex->data, $match, PREG_OFFSET_CAPTURE, $from)) {
|
||||
$close = $match[0][1];
|
||||
$from = $close + strlen($match[0][0]);
|
||||
if (preg_match('~' . preg_quote($closeTag, '~') . '~i', $lex->data, $match, PREG_OFFSET_CAPTURE,
|
||||
$from)) {
|
||||
$close = $match[ 0 ][ 1 ];
|
||||
$from = $close + strlen($match[ 0 ][ 0 ]);
|
||||
} else {
|
||||
$lex->compiler->trigger_template_error("missing closing tag '{$closeTag}'");
|
||||
}
|
||||
@@ -204,6 +215,6 @@ class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase
|
||||
*/
|
||||
private function quote($match)
|
||||
{
|
||||
return htmlspecialchars($match[0], ENT_QUOTES);
|
||||
return htmlspecialchars($match[ 0 ], ENT_QUOTES);
|
||||
}
|
||||
}
|
||||
|
@@ -47,36 +47,39 @@ class Smarty_Internal_Compile_Private_Print_Expression extends Smarty_Internal_C
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
// nocache option
|
||||
if ($_attr['nocache'] === true) {
|
||||
if ($_attr[ 'nocache' ] === true) {
|
||||
$compiler->tag_nocache = true;
|
||||
}
|
||||
if (isset($_attr['assign'])) {
|
||||
if (isset($_attr[ 'assign' ])) {
|
||||
// assign output to variable
|
||||
$output = "<?php \$_smarty_tpl->assign({$_attr['assign']},{$parameter['value']});?>";
|
||||
} else {
|
||||
// display value
|
||||
$output = $parameter['value'];
|
||||
$output = $parameter[ 'value' ];
|
||||
// tag modifier
|
||||
if (!empty($parameter['modifierlist'])) {
|
||||
$output = $compiler->compileTag('private_modifier', array(), array('modifierlist' => $parameter['modifierlist'],
|
||||
if (!empty($parameter[ 'modifierlist' ])) {
|
||||
$output = $compiler->compileTag('private_modifier', array(),
|
||||
array('modifierlist' => $parameter[ 'modifierlist' ],
|
||||
'value' => $output));
|
||||
}
|
||||
if (!$_attr['nofilter']) {
|
||||
if (!$_attr[ 'nofilter' ]) {
|
||||
// default modifier
|
||||
if (!empty($compiler->smarty->default_modifiers)) {
|
||||
if (empty($compiler->default_modifier_list)) {
|
||||
$modifierlist = array();
|
||||
foreach ($compiler->smarty->default_modifiers as $key => $single_default_modifier) {
|
||||
preg_match_all('/(\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\'|"[^"\\\\]*(?:\\\\.[^"\\\\]*)*"|:|[^:]+)/', $single_default_modifier, $mod_array);
|
||||
for ($i = 0, $count = count($mod_array[0]); $i < $count; $i ++) {
|
||||
if ($mod_array[0][$i] != ':') {
|
||||
$modifierlist[$key][] = $mod_array[0][$i];
|
||||
preg_match_all('/(\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\'|"[^"\\\\]*(?:\\\\.[^"\\\\]*)*"|:|[^:]+)/',
|
||||
$single_default_modifier, $mod_array);
|
||||
for ($i = 0, $count = count($mod_array[ 0 ]); $i < $count; $i ++) {
|
||||
if ($mod_array[ 0 ][ $i ] != ':') {
|
||||
$modifierlist[ $key ][] = $mod_array[ 0 ][ $i ];
|
||||
}
|
||||
}
|
||||
}
|
||||
$compiler->default_modifier_list = $modifierlist;
|
||||
}
|
||||
$output = $compiler->compileTag('private_modifier', array(), array('modifierlist' => $compiler->default_modifier_list,
|
||||
$output = $compiler->compileTag('private_modifier', array(),
|
||||
array('modifierlist' => $compiler->default_modifier_list,
|
||||
'value' => $output));
|
||||
}
|
||||
// autoescape html
|
||||
@@ -84,21 +87,23 @@ class Smarty_Internal_Compile_Private_Print_Expression extends Smarty_Internal_C
|
||||
$output = "htmlspecialchars({$output}, ENT_QUOTES, '" . addslashes(Smarty::$_CHARSET) . "')";
|
||||
}
|
||||
// loop over registered filters
|
||||
if (!empty($compiler->template->smarty->registered_filters[Smarty::FILTER_VARIABLE])) {
|
||||
foreach ($compiler->template->smarty->registered_filters[Smarty::FILTER_VARIABLE] as $key =>
|
||||
if (!empty($compiler->template->smarty->registered_filters[ Smarty::FILTER_VARIABLE ])) {
|
||||
foreach ($compiler->template->smarty->registered_filters[ Smarty::FILTER_VARIABLE ] as $key =>
|
||||
$function) {
|
||||
if (!is_array($function)) {
|
||||
$output = "{$function}({$output},\$_smarty_tpl)";
|
||||
} elseif (is_object($function[0])) {
|
||||
$output = "\$_smarty_tpl->smarty->registered_filters[Smarty::FILTER_VARIABLE]['{$key}'][0]->{$function[1]}({$output},\$_smarty_tpl)";
|
||||
} elseif (is_object($function[ 0 ])) {
|
||||
$output =
|
||||
"\$_smarty_tpl->smarty->registered_filters[Smarty::FILTER_VARIABLE]['{$key}'][0]->{$function[1]}({$output},\$_smarty_tpl)";
|
||||
} else {
|
||||
$output = "{$function[0]}::{$function[1]}({$output},\$_smarty_tpl)";
|
||||
}
|
||||
}
|
||||
}
|
||||
// auto loaded filters
|
||||
if (isset($compiler->smarty->autoload_filters[Smarty::FILTER_VARIABLE])) {
|
||||
foreach ((array) $compiler->template->smarty->autoload_filters[Smarty::FILTER_VARIABLE] as $name) {
|
||||
if (isset($compiler->smarty->autoload_filters[ Smarty::FILTER_VARIABLE ])) {
|
||||
foreach ((array) $compiler->template->smarty->autoload_filters[ Smarty::FILTER_VARIABLE ] as $name)
|
||||
{
|
||||
$result = $this->compile_output_filter($compiler, $name, $output);
|
||||
if ($result !== false) {
|
||||
$output = $result;
|
||||
@@ -110,12 +115,12 @@ class Smarty_Internal_Compile_Private_Print_Expression extends Smarty_Internal_C
|
||||
}
|
||||
foreach ($compiler->variable_filters as $filter) {
|
||||
if (count($filter) == 1 &&
|
||||
($result = $this->compile_output_filter($compiler, $filter[0], $output)) !== false
|
||||
($result = $this->compile_output_filter($compiler, $filter[ 0 ], $output)) !== false
|
||||
) {
|
||||
$output = $result;
|
||||
} else {
|
||||
$output = $compiler->compileTag('private_modifier', array(), array('modifierlist' => array($filter),
|
||||
'value' => $output));
|
||||
$output = $compiler->compileTag('private_modifier', array(),
|
||||
array('modifierlist' => array($filter), 'value' => $output));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -140,11 +145,15 @@ class Smarty_Internal_Compile_Private_Print_Expression extends Smarty_Internal_C
|
||||
$path = $compiler->smarty->loadPlugin($plugin_name, false);
|
||||
if ($path) {
|
||||
if ($compiler->template->caching) {
|
||||
$compiler->parent_compiler->template->compiled->required_plugins['nocache'][$name][Smarty::FILTER_VARIABLE]['file'] = $path;
|
||||
$compiler->parent_compiler->template->compiled->required_plugins['nocache'][$name][Smarty::FILTER_VARIABLE]['function'] = $plugin_name;
|
||||
$compiler->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $name ][ Smarty::FILTER_VARIABLE ][ 'file' ] =
|
||||
$path;
|
||||
$compiler->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $name ][ Smarty::FILTER_VARIABLE ][ 'function' ] =
|
||||
$plugin_name;
|
||||
} else {
|
||||
$compiler->parent_compiler->template->compiled->required_plugins['compiled'][$name][Smarty::FILTER_VARIABLE]['file'] = $path;
|
||||
$compiler->parent_compiler->template->compiled->required_plugins['compiled'][$name][Smarty::FILTER_VARIABLE]['function'] = $plugin_name;
|
||||
$compiler->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $name ][ Smarty::FILTER_VARIABLE ][ 'file' ] =
|
||||
$path;
|
||||
$compiler->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $name ][ Smarty::FILTER_VARIABLE ][ 'function' ] =
|
||||
$plugin_name;
|
||||
}
|
||||
} else {
|
||||
// not found
|
||||
|
@@ -28,23 +28,25 @@ class Smarty_Internal_Compile_Private_Registered_Block extends Smarty_Internal_C
|
||||
*/
|
||||
public function setup(Smarty_Internal_TemplateCompilerBase $compiler, $_attr, $tag, $function)
|
||||
{
|
||||
if (isset($compiler->smarty->registered_plugins[Smarty::PLUGIN_BLOCK][$tag])) {
|
||||
$tag_info = $compiler->smarty->registered_plugins[Smarty::PLUGIN_BLOCK][$tag];
|
||||
if (isset($compiler->smarty->registered_plugins[ Smarty::PLUGIN_BLOCK ][ $tag ])) {
|
||||
$tag_info = $compiler->smarty->registered_plugins[ Smarty::PLUGIN_BLOCK ][ $tag ];
|
||||
$callback = $tag_info[ 0 ];
|
||||
if (is_array($callback)) {
|
||||
if (is_object($callback[ 0 ])) {
|
||||
$callable = "array(\$_block_plugin{$this->nesting}, '{$callback[1]}')";
|
||||
$callback = array("\$_smarty_tpl->smarty->registered_plugins['block']['{$tag}'][0][0]", "->{$callback[1]}");
|
||||
$callback =
|
||||
array("\$_smarty_tpl->smarty->registered_plugins['block']['{$tag}'][0][0]", "->{$callback[1]}");
|
||||
} else {
|
||||
$callable = "array(\$_block_plugin{$this->nesting}, '{$callback[1]}')";
|
||||
$callback = array("\$_smarty_tpl->smarty->registered_plugins['block']['{$tag}'][0][0]", "::{$callback[1]}");
|
||||
$callback =
|
||||
array("\$_smarty_tpl->smarty->registered_plugins['block']['{$tag}'][0][0]", "::{$callback[1]}");
|
||||
}
|
||||
} else {
|
||||
$callable = "\$_block_plugin{$this->nesting}";
|
||||
$callback = array("\$_smarty_tpl->smarty->registered_plugins['block']['{$tag}'][0]", '');
|
||||
}
|
||||
} else {
|
||||
$tag_info = $compiler->default_handler_plugins[Smarty::PLUGIN_BLOCK][$tag];
|
||||
$tag_info = $compiler->default_handler_plugins[ Smarty::PLUGIN_BLOCK ][ $tag ];
|
||||
$callback = $tag_info[ 0 ];
|
||||
if (is_array($callback)) {
|
||||
$callable = "array('{$callback[0]}', '{$callback[1]}')";
|
||||
|
@@ -40,23 +40,23 @@ class Smarty_Internal_Compile_Private_Registered_Function extends Smarty_Interna
|
||||
$compiler->has_output = true;
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
if ($_attr['nocache']) {
|
||||
if ($_attr[ 'nocache' ]) {
|
||||
$compiler->tag_nocache = true;
|
||||
}
|
||||
unset($_attr['nocache']);
|
||||
if (isset($compiler->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION][$tag])) {
|
||||
$tag_info = $compiler->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION][$tag];
|
||||
unset($_attr[ 'nocache' ]);
|
||||
if (isset($compiler->smarty->registered_plugins[ Smarty::PLUGIN_FUNCTION ][ $tag ])) {
|
||||
$tag_info = $compiler->smarty->registered_plugins[ Smarty::PLUGIN_FUNCTION ][ $tag ];
|
||||
} else {
|
||||
$tag_info = $compiler->default_handler_plugins[Smarty::PLUGIN_FUNCTION][$tag];
|
||||
$tag_info = $compiler->default_handler_plugins[ Smarty::PLUGIN_FUNCTION ][ $tag ];
|
||||
}
|
||||
// not cachable?
|
||||
$compiler->tag_nocache = $compiler->tag_nocache || !$tag_info[1];
|
||||
$compiler->tag_nocache = $compiler->tag_nocache || !$tag_info[ 1 ];
|
||||
// convert attributes into parameter array string
|
||||
$_paramsArray = array();
|
||||
foreach ($_attr as $_key => $_value) {
|
||||
if (is_int($_key)) {
|
||||
$_paramsArray[] = "$_key=>$_value";
|
||||
} elseif ($compiler->template->caching && in_array($_key, $tag_info[2])) {
|
||||
} elseif ($compiler->template->caching && in_array($_key, $tag_info[ 2 ])) {
|
||||
$_value = str_replace("'", "^#^", $_value);
|
||||
$_paramsArray[] = "'$_key'=>^#^.var_export($_value,true).^#^";
|
||||
} else {
|
||||
@@ -64,12 +64,13 @@ class Smarty_Internal_Compile_Private_Registered_Function extends Smarty_Interna
|
||||
}
|
||||
}
|
||||
$_params = 'array(' . implode(",", $_paramsArray) . ')';
|
||||
$function = $tag_info[0];
|
||||
$function = $tag_info[ 0 ];
|
||||
// compile code
|
||||
if (!is_array($function)) {
|
||||
$output = "<?php echo {$function}({$_params},\$_smarty_tpl);?>\n";
|
||||
} elseif (is_object($function[0])) {
|
||||
$output = "<?php echo \$_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['{$tag}'][0][0]->{$function[1]}({$_params},\$_smarty_tpl);?>\n";
|
||||
} elseif (is_object($function[ 0 ])) {
|
||||
$output =
|
||||
"<?php echo \$_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['{$tag}'][0][0]->{$function[1]}({$_params},\$_smarty_tpl);?>\n";
|
||||
} else {
|
||||
$output = "<?php echo {$function[0]}::{$function[1]}({$_params},\$_smarty_tpl);?>\n";
|
||||
}
|
||||
|
@@ -29,7 +29,7 @@ class Smarty_Internal_Compile_Rdelim extends Smarty_Internal_CompileBase
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
|
||||
{
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
if ($_attr['nocache'] === true) {
|
||||
if ($_attr[ 'nocache' ] === true) {
|
||||
$compiler->trigger_template_error('nocache option not allowed', null, true);
|
||||
}
|
||||
// this tag does not return compiled code
|
||||
|
@@ -59,8 +59,8 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_Compile_Private_Fo
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $nameProperties = array('first', 'last', 'index', 'iteration', 'show', 'total', 'rownum',
|
||||
'index_prev', 'index_next', 'loop');
|
||||
public $nameProperties = array('first', 'last', 'index', 'iteration', 'show', 'total', 'rownum', 'index_prev',
|
||||
'index_next', 'loop');
|
||||
|
||||
/**
|
||||
* {section} tag has no item properties
|
||||
@@ -87,11 +87,11 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_Compile_Private_Fo
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
|
||||
{
|
||||
$compiler->loopNesting++;
|
||||
$compiler->loopNesting ++;
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
$attributes = array('name' => $compiler->getId($_attr['name']));
|
||||
unset($_attr['name']);
|
||||
$attributes = array('name' => $compiler->getId($_attr[ 'name' ]));
|
||||
unset($_attr[ 'name' ]);
|
||||
foreach ($attributes as $a => $v) {
|
||||
if ($v === false) {
|
||||
$compiler->trigger_template_error("'{$a}' attribute/variable has illegal value", null, true);
|
||||
@@ -103,7 +103,8 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_Compile_Private_Fo
|
||||
// maybe nocache because of nocache variables
|
||||
$compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
|
||||
|
||||
$initLocal = array('saved' => "isset(\$_smarty_tpl->tpl_vars['__smarty_section_{$attributes['name']}']) ? \$_smarty_tpl->tpl_vars['__smarty_section_{$attributes['name']}'] : false",);
|
||||
$initLocal =
|
||||
array('saved' => "isset(\$_smarty_tpl->tpl_vars['__smarty_section_{$attributes['name']}']) ? \$_smarty_tpl->tpl_vars['__smarty_section_{$attributes['name']}'] : false",);
|
||||
$initNamedProperty = array();
|
||||
$initFor = array();
|
||||
$incFor = array();
|
||||
@@ -115,10 +116,10 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_Compile_Private_Fo
|
||||
$propType = array('index' => 2, 'iteration' => 2, 'show' => 0, 'step' => 0,);
|
||||
// search for used tag attributes
|
||||
$this->scanForProperties($attributes, $compiler);
|
||||
if (!empty($this->matchResults['named'])) {
|
||||
$namedAttr = $this->matchResults['named'];
|
||||
if (!empty($this->matchResults[ 'named' ])) {
|
||||
$namedAttr = $this->matchResults[ 'named' ];
|
||||
}
|
||||
$namedAttr['index'] = true;
|
||||
$namedAttr[ 'index' ] = true;
|
||||
$output = "<?php\n";
|
||||
foreach ($_attr as $attr_name => $attr_value) {
|
||||
switch ($attr_name) {
|
||||
@@ -130,13 +131,13 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_Compile_Private_Fo
|
||||
$v = "(is_array(@\$_loop=$attr_value) ? count(\$_loop) : max(0, (int) \$_loop))";
|
||||
$t = 1;
|
||||
}
|
||||
if (isset($namedAttr['loop'])) {
|
||||
$initNamedProperty['loop'] = "'loop' => {$v}";
|
||||
if (isset($namedAttr[ 'loop' ])) {
|
||||
$initNamedProperty[ 'loop' ] = "'loop' => {$v}";
|
||||
if ($t == 1) {
|
||||
$v = "{$sectionVar}->value['loop']";
|
||||
}
|
||||
} elseif ($t == 1) {
|
||||
$initLocal['loop'] = $v;
|
||||
$initLocal[ 'loop' ] = $v;
|
||||
$v = "{$local}loop";
|
||||
}
|
||||
break;
|
||||
@@ -156,7 +157,7 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_Compile_Private_Fo
|
||||
$t = 0;
|
||||
break;
|
||||
}
|
||||
$initLocal['step'] = "((int)@$attr_value) == 0 ? 1 : (int)@$attr_value";
|
||||
$initLocal[ 'step' ] = "((int)@$attr_value) == 0 ? 1 : (int)@$attr_value";
|
||||
$v = "{$local}step";
|
||||
$t = 2;
|
||||
break;
|
||||
@@ -175,169 +176,171 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_Compile_Private_Fo
|
||||
if ($t == 3 && $compiler->getId($attr_value)) {
|
||||
$t = 1;
|
||||
}
|
||||
$propValue[$attr_name] = $v;
|
||||
$propType[$attr_name] = $t;
|
||||
$propValue[ $attr_name ] = $v;
|
||||
$propType[ $attr_name ] = $t;
|
||||
}
|
||||
|
||||
if (isset($namedAttr['step'])) {
|
||||
$initNamedProperty['step'] = $propValue['step'];
|
||||
if (isset($namedAttr[ 'step' ])) {
|
||||
$initNamedProperty[ 'step' ] = $propValue[ 'step' ];
|
||||
}
|
||||
if (isset($namedAttr['iteration'])) {
|
||||
$propValue['iteration'] = "{$sectionVar}->value['iteration']";
|
||||
if (isset($namedAttr[ 'iteration' ])) {
|
||||
$propValue[ 'iteration' ] = "{$sectionVar}->value['iteration']";
|
||||
}
|
||||
$incFor['iteration'] = "{$propValue['iteration']}++";
|
||||
$initFor['iteration'] = "{$propValue['iteration']} = 1";
|
||||
$incFor[ 'iteration' ] = "{$propValue['iteration']}++";
|
||||
$initFor[ 'iteration' ] = "{$propValue['iteration']} = 1";
|
||||
|
||||
if ($propType['step'] == 0) {
|
||||
if ($propValue['step'] == 1) {
|
||||
$incFor['index'] = "{$sectionVar}->value['index']++";
|
||||
} elseif ($propValue['step'] > 1) {
|
||||
$incFor['index'] = "{$sectionVar}->value['index'] += {$propValue['step']}";
|
||||
if ($propType[ 'step' ] == 0) {
|
||||
if ($propValue[ 'step' ] == 1) {
|
||||
$incFor[ 'index' ] = "{$sectionVar}->value['index']++";
|
||||
} elseif ($propValue[ 'step' ] > 1) {
|
||||
$incFor[ 'index' ] = "{$sectionVar}->value['index'] += {$propValue['step']}";
|
||||
} else {
|
||||
$incFor['index'] = "{$sectionVar}->value['index'] -= " . - $propValue['step'];
|
||||
$incFor[ 'index' ] = "{$sectionVar}->value['index'] -= " . - $propValue[ 'step' ];
|
||||
}
|
||||
} else {
|
||||
$incFor['index'] = "{$sectionVar}->value['index'] += {$propValue['step']}";
|
||||
$incFor[ 'index' ] = "{$sectionVar}->value['index'] += {$propValue['step']}";
|
||||
}
|
||||
|
||||
if (!isset($propValue['max'])) {
|
||||
$propValue['max'] = $propValue['loop'];
|
||||
$propType['max'] = $propType['loop'];
|
||||
} elseif ($propType['max'] != 0) {
|
||||
$propValue['max'] = "{$propValue['max']} < 0 ? {$propValue['loop']} : {$propValue['max']}";
|
||||
$propType['max'] = 1;
|
||||
if (!isset($propValue[ 'max' ])) {
|
||||
$propValue[ 'max' ] = $propValue[ 'loop' ];
|
||||
$propType[ 'max' ] = $propType[ 'loop' ];
|
||||
} elseif ($propType[ 'max' ] != 0) {
|
||||
$propValue[ 'max' ] = "{$propValue['max']} < 0 ? {$propValue['loop']} : {$propValue['max']}";
|
||||
$propType[ 'max' ] = 1;
|
||||
} else {
|
||||
if ($propValue['max'] < 0) {
|
||||
$propValue['max'] = $propValue['loop'];
|
||||
$propType['max'] = $propType['loop'];
|
||||
if ($propValue[ 'max' ] < 0) {
|
||||
$propValue[ 'max' ] = $propValue[ 'loop' ];
|
||||
$propType[ 'max' ] = $propType[ 'loop' ];
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($propValue['start'])) {
|
||||
$start_code = array(1 => "{$propValue['step']} > 0 ? ", 2 => '0', 3 => ' : ', 4 => $propValue['loop'],
|
||||
5 => ' - 1');
|
||||
if ($propType['loop'] == 0) {
|
||||
$start_code[5] = '';
|
||||
$start_code[4] = $propValue['loop'] - 1;
|
||||
if (!isset($propValue[ 'start' ])) {
|
||||
$start_code =
|
||||
array(1 => "{$propValue['step']} > 0 ? ", 2 => '0', 3 => ' : ', 4 => $propValue[ 'loop' ], 5 => ' - 1');
|
||||
if ($propType[ 'loop' ] == 0) {
|
||||
$start_code[ 5 ] = '';
|
||||
$start_code[ 4 ] = $propValue[ 'loop' ] - 1;
|
||||
}
|
||||
if ($propType['step'] == 0) {
|
||||
if ($propValue['step'] > 0) {
|
||||
if ($propType[ 'step' ] == 0) {
|
||||
if ($propValue[ 'step' ] > 0) {
|
||||
$start_code = array(1 => '0');
|
||||
$propType['start'] = 0;
|
||||
$propType[ 'start' ] = 0;
|
||||
} else {
|
||||
$start_code[1] = $start_code[2] = $start_code[3] = '';
|
||||
$propType['start'] = $propType['loop'];
|
||||
$start_code[ 1 ] = $start_code[ 2 ] = $start_code[ 3 ] = '';
|
||||
$propType[ 'start' ] = $propType[ 'loop' ];
|
||||
}
|
||||
} else {
|
||||
$propType['start'] = 1;
|
||||
$propType[ 'start' ] = 1;
|
||||
}
|
||||
$propValue['start'] = join('', $start_code);
|
||||
$propValue[ 'start' ] = join('', $start_code);
|
||||
} else {
|
||||
$start_code = array(1 => "{$propValue['start']} < 0 ? ", 2 => 'max(', 3 => "{$propValue['step']} > 0 ? ",
|
||||
4 => '0', 5 => ' : ', 6 => '-1', 7 => ', ',
|
||||
8 => "{$propValue['start']} + {$propValue['loop']}", 10 => ')', 11 => ' : ',
|
||||
12 => 'min(', 13 => $propValue['start'], 14 => ', ',
|
||||
15 => "{$propValue['step']} > 0 ? ", 16 => $propValue['loop'], 17 => ' : ',
|
||||
18 => $propType['loop'] == 0 ? $propValue['loop'] - 1 : "{$propValue['loop']} - 1",
|
||||
$start_code =
|
||||
array(1 => "{$propValue['start']} < 0 ? ", 2 => 'max(', 3 => "{$propValue['step']} > 0 ? ", 4 => '0',
|
||||
5 => ' : ', 6 => '-1', 7 => ', ', 8 => "{$propValue['start']} + {$propValue['loop']}", 10 => ')',
|
||||
11 => ' : ', 12 => 'min(', 13 => $propValue[ 'start' ], 14 => ', ',
|
||||
15 => "{$propValue['step']} > 0 ? ", 16 => $propValue[ 'loop' ], 17 => ' : ',
|
||||
18 => $propType[ 'loop' ] == 0 ? $propValue[ 'loop' ] - 1 : "{$propValue['loop']} - 1",
|
||||
19 => ')');
|
||||
if ($propType['step'] == 0) {
|
||||
$start_code[3] = $start_code[5] = $start_code[15] = $start_code[17] = '';
|
||||
if ($propValue['step'] > 0) {
|
||||
$start_code[6] = $start_code[18] = '';
|
||||
if ($propType[ 'step' ] == 0) {
|
||||
$start_code[ 3 ] = $start_code[ 5 ] = $start_code[ 15 ] = $start_code[ 17 ] = '';
|
||||
if ($propValue[ 'step' ] > 0) {
|
||||
$start_code[ 6 ] = $start_code[ 18 ] = '';
|
||||
} else {
|
||||
$start_code[4] = $start_code[16] = '';
|
||||
$start_code[ 4 ] = $start_code[ 16 ] = '';
|
||||
}
|
||||
}
|
||||
if ($propType['start'] == 0) {
|
||||
if ($propType['loop'] == 0) {
|
||||
$start_code[8] = $propValue['start'] + $propValue['loop'];
|
||||
if ($propType[ 'start' ] == 0) {
|
||||
if ($propType[ 'loop' ] == 0) {
|
||||
$start_code[ 8 ] = $propValue[ 'start' ] + $propValue[ 'loop' ];
|
||||
}
|
||||
$propType['start'] = $propType['step'] + $propType['loop'];
|
||||
$start_code[1] = '';
|
||||
if ($propValue['start'] < 0) {
|
||||
$propType[ 'start' ] = $propType[ 'step' ] + $propType[ 'loop' ];
|
||||
$start_code[ 1 ] = '';
|
||||
if ($propValue[ 'start' ] < 0) {
|
||||
for ($i = 11; $i <= 19; $i ++) {
|
||||
$start_code[$i] = '';
|
||||
$start_code[ $i ] = '';
|
||||
}
|
||||
if ($propType['start'] == 0) {
|
||||
$start_code = array(max($propValue['step'] > 0 ? 0 : - 1, $propValue['start'] +
|
||||
$propValue['loop']));
|
||||
if ($propType[ 'start' ] == 0) {
|
||||
$start_code = array(max($propValue[ 'step' ] > 0 ? 0 : - 1,
|
||||
$propValue[ 'start' ] + $propValue[ 'loop' ]));
|
||||
}
|
||||
} else {
|
||||
for ($i = 1; $i <= 11; $i ++) {
|
||||
$start_code[$i] = '';
|
||||
$start_code[ $i ] = '';
|
||||
}
|
||||
if ($propType['start'] == 0) {
|
||||
$start_code = array(min($propValue['step'] > 0 ? $propValue['loop'] : $propValue['loop'] -
|
||||
1, $propValue['start']));
|
||||
if ($propType[ 'start' ] == 0) {
|
||||
$start_code =
|
||||
array(min($propValue[ 'step' ] > 0 ? $propValue[ 'loop' ] : $propValue[ 'loop' ] - 1,
|
||||
$propValue[ 'start' ]));
|
||||
}
|
||||
}
|
||||
}
|
||||
$propValue['start'] = join('', $start_code);
|
||||
$propValue[ 'start' ] = join('', $start_code);
|
||||
}
|
||||
if ($propType['start'] != 0) {
|
||||
$initLocal['start'] = $propValue['start'];
|
||||
$propValue['start'] = "{$local}start";
|
||||
if ($propType[ 'start' ] != 0) {
|
||||
$initLocal[ 'start' ] = $propValue[ 'start' ];
|
||||
$propValue[ 'start' ] = "{$local}start";
|
||||
}
|
||||
|
||||
$initFor['index'] = "{$sectionVar}->value['index'] = {$propValue['start']}";
|
||||
$initFor[ 'index' ] = "{$sectionVar}->value['index'] = {$propValue['start']}";
|
||||
|
||||
if (!isset($_attr['start']) && !isset($_attr['step']) && !isset($_attr['max'])) {
|
||||
$propValue['total'] = $propValue['loop'];
|
||||
$propType['total'] = $propType['loop'];
|
||||
if (!isset($_attr[ 'start' ]) && !isset($_attr[ 'step' ]) && !isset($_attr[ 'max' ])) {
|
||||
$propValue[ 'total' ] = $propValue[ 'loop' ];
|
||||
$propType[ 'total' ] = $propType[ 'loop' ];
|
||||
} else {
|
||||
$propType['total'] = $propType['start'] + $propType['loop'] + $propType['step'] + $propType['max'];
|
||||
if ($propType['total'] == 0) {
|
||||
$propValue['total'] = min(ceil(($propValue['step'] > 0 ? $propValue['loop'] -
|
||||
$propValue['start'] : (int) $propValue['start'] + 1) /
|
||||
abs($propValue['step'])), $propValue['max']);
|
||||
$propType[ 'total' ] =
|
||||
$propType[ 'start' ] + $propType[ 'loop' ] + $propType[ 'step' ] + $propType[ 'max' ];
|
||||
if ($propType[ 'total' ] == 0) {
|
||||
$propValue[ 'total' ] =
|
||||
min(ceil(($propValue[ 'step' ] > 0 ? $propValue[ 'loop' ] - $propValue[ 'start' ] :
|
||||
(int) $propValue[ 'start' ] + 1) / abs($propValue[ 'step' ])), $propValue[ 'max' ]);
|
||||
} else {
|
||||
$total_code = array(1 => 'min(', 2 => 'ceil(', 3 => '(', 4 => "{$propValue['step']} > 0 ? ",
|
||||
5 => $propValue['loop'], 6 => ' - ', 7 => $propValue['start'], 8 => ' : ',
|
||||
9 => $propValue['start'], 10 => '+ 1', 11 => ')', 12 => '/ ', 13 => 'abs(',
|
||||
14 => $propValue['step'], 15 => ')', 16 => ')', 17 => ", {$propValue['max']})",);
|
||||
if (!isset($propValue['max'])) {
|
||||
$total_code[1] = $total_code[17] = '';
|
||||
5 => $propValue[ 'loop' ], 6 => ' - ', 7 => $propValue[ 'start' ], 8 => ' : ',
|
||||
9 => $propValue[ 'start' ], 10 => '+ 1', 11 => ')', 12 => '/ ', 13 => 'abs(',
|
||||
14 => $propValue[ 'step' ], 15 => ')', 16 => ')', 17 => ", {$propValue['max']})",);
|
||||
if (!isset($propValue[ 'max' ])) {
|
||||
$total_code[ 1 ] = $total_code[ 17 ] = '';
|
||||
}
|
||||
if ($propType['loop'] + $propType['start'] == 0) {
|
||||
$total_code[5] = $propValue['loop'] - $propValue['start'];
|
||||
$total_code[6] = $total_code[7] = '';
|
||||
if ($propType[ 'loop' ] + $propType[ 'start' ] == 0) {
|
||||
$total_code[ 5 ] = $propValue[ 'loop' ] - $propValue[ 'start' ];
|
||||
$total_code[ 6 ] = $total_code[ 7 ] = '';
|
||||
}
|
||||
if ($propType['start'] == 0) {
|
||||
$total_code[9] = (int) $propValue['start'] + 1;
|
||||
$total_code[10] = '';
|
||||
if ($propType[ 'start' ] == 0) {
|
||||
$total_code[ 9 ] = (int) $propValue[ 'start' ] + 1;
|
||||
$total_code[ 10 ] = '';
|
||||
}
|
||||
if ($propType['step'] == 0) {
|
||||
$total_code[13] = $total_code[15] = '';
|
||||
if ($propValue['step'] == 1 || $propValue['step'] == - 1) {
|
||||
$total_code[2] = $total_code[12] = $total_code[14] = $total_code[16] = '';
|
||||
} elseif ($propValue['step'] < 0) {
|
||||
$total_code[14] = - $propValue['step'];
|
||||
if ($propType[ 'step' ] == 0) {
|
||||
$total_code[ 13 ] = $total_code[ 15 ] = '';
|
||||
if ($propValue[ 'step' ] == 1 || $propValue[ 'step' ] == - 1) {
|
||||
$total_code[ 2 ] = $total_code[ 12 ] = $total_code[ 14 ] = $total_code[ 16 ] = '';
|
||||
} elseif ($propValue[ 'step' ] < 0) {
|
||||
$total_code[ 14 ] = - $propValue[ 'step' ];
|
||||
}
|
||||
$total_code[4] = '';
|
||||
if ($propValue['step'] > 0) {
|
||||
$total_code[8] = $total_code[9] = $total_code[10] = '';
|
||||
$total_code[ 4 ] = '';
|
||||
if ($propValue[ 'step' ] > 0) {
|
||||
$total_code[ 8 ] = $total_code[ 9 ] = $total_code[ 10 ] = '';
|
||||
} else {
|
||||
$total_code[5] = $total_code[6] = $total_code[7] = $total_code[8] = '';
|
||||
$total_code[ 5 ] = $total_code[ 6 ] = $total_code[ 7 ] = $total_code[ 8 ] = '';
|
||||
}
|
||||
}
|
||||
$propValue['total'] = join('', $total_code);
|
||||
$propValue[ 'total' ] = join('', $total_code);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($namedAttr[ 'loop' ])) {
|
||||
$initNamedProperty[ 'loop' ] = "'loop' => {$propValue['total']}";
|
||||
}
|
||||
if (isset($namedAttr['total'])) {
|
||||
$initNamedProperty['total'] = "'total' => {$propValue['total']}";
|
||||
if ($propType['total'] > 0) {
|
||||
$propValue['total'] = "{$sectionVar}->value['total']";
|
||||
if (isset($namedAttr[ 'total' ])) {
|
||||
$initNamedProperty[ 'total' ] = "'total' => {$propValue['total']}";
|
||||
if ($propType[ 'total' ] > 0) {
|
||||
$propValue[ 'total' ] = "{$sectionVar}->value['total']";
|
||||
}
|
||||
} elseif ($propType['total'] > 0) {
|
||||
$initLocal['total'] = $propValue['total'];
|
||||
$propValue['total'] = "{$local}total";
|
||||
} elseif ($propType[ 'total' ] > 0) {
|
||||
$initLocal[ 'total' ] = $propValue[ 'total' ];
|
||||
$propValue[ 'total' ] = "{$local}total";
|
||||
}
|
||||
|
||||
$cmpFor['iteration'] = "{$propValue['iteration']} <= {$propValue['total']}";
|
||||
$cmpFor[ 'iteration' ] = "{$propValue['iteration']} <= {$propValue['total']}";
|
||||
|
||||
foreach ($initLocal as $key => $code) {
|
||||
$output .= "{$local}{$key} = {$code};\n";
|
||||
@@ -346,17 +349,17 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_Compile_Private_Fo
|
||||
$_vars = 'array(' . join(', ', $initNamedProperty) . ')';
|
||||
$output .= "{$sectionVar} = new Smarty_Variable({$_vars});\n";
|
||||
$cond_code = "{$propValue['total']} != 0";
|
||||
if ($propType['total'] == 0) {
|
||||
if ($propValue['total'] == 0) {
|
||||
if ($propType[ 'total' ] == 0) {
|
||||
if ($propValue[ 'total' ] == 0) {
|
||||
$cond_code = 'false';
|
||||
} else {
|
||||
$cond_code = 'true';
|
||||
}
|
||||
}
|
||||
if ($propType['show'] > 0) {
|
||||
if ($propType[ 'show' ] > 0) {
|
||||
$output .= "{$local}show = {$propValue['show']} ? {$cond_code} : false;\n";
|
||||
$output .= "if ({$local}show) {\n";
|
||||
} elseif ($propValue['show'] == 'true') {
|
||||
} elseif ($propValue[ 'show' ] == 'true') {
|
||||
$output .= "if ({$cond_code}) {\n";
|
||||
} else {
|
||||
$output .= "if (false) {\n";
|
||||
@@ -365,19 +368,19 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_Compile_Private_Fo
|
||||
$jcmp = join(', ', $cmpFor);
|
||||
$jinc = join(', ', $incFor);
|
||||
$output .= "for ({$jinit}; {$jcmp}; {$jinc}){\n";
|
||||
if (isset($namedAttr['rownum'])) {
|
||||
if (isset($namedAttr[ 'rownum' ])) {
|
||||
$output .= "{$sectionVar}->value['rownum'] = {$propValue['iteration']};\n";
|
||||
}
|
||||
if (isset($namedAttr['index_prev'])) {
|
||||
if (isset($namedAttr[ 'index_prev' ])) {
|
||||
$output .= "{$sectionVar}->value['index_prev'] = {$propValue['index']} - {$propValue['step']};\n";
|
||||
}
|
||||
if (isset($namedAttr['index_next'])) {
|
||||
if (isset($namedAttr[ 'index_next' ])) {
|
||||
$output .= "{$sectionVar}->value['index_next'] = {$propValue['index']} + {$propValue['step']};\n";
|
||||
}
|
||||
if (isset($namedAttr['first'])) {
|
||||
if (isset($namedAttr[ 'first' ])) {
|
||||
$output .= "{$sectionVar}->value['first'] = ({$propValue['iteration']} == 1);\n";
|
||||
}
|
||||
if (isset($namedAttr['last'])) {
|
||||
if (isset($namedAttr[ 'last' ])) {
|
||||
$output .= "{$sectionVar}->value['last'] = ({$propValue['iteration']} == {$propValue['total']});\n";
|
||||
}
|
||||
$output .= "?>";
|
||||
@@ -432,14 +435,14 @@ class Smarty_Internal_Compile_Sectionclose extends Smarty_Internal_CompileBase
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
|
||||
{
|
||||
$compiler->loopNesting--;
|
||||
$compiler->loopNesting --;
|
||||
// must endblock be nocache?
|
||||
if ($compiler->nocache) {
|
||||
$compiler->tag_nocache = true;
|
||||
}
|
||||
|
||||
list($openTag, $compiler->nocache, $local, $sectionVar) = $this->closeTag($compiler, array('section',
|
||||
'sectionelse'));
|
||||
list($openTag, $compiler->nocache, $local, $sectionVar) =
|
||||
$this->closeTag($compiler, array('section', 'sectionelse'));
|
||||
|
||||
$output = "<?php\n";
|
||||
if ($openTag == 'sectionelse') {
|
||||
|
@@ -28,7 +28,7 @@ class Smarty_Internal_Compile_Setfilter extends Smarty_Internal_CompileBase
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
|
||||
{
|
||||
$compiler->variable_filter_stack[] = $compiler->variable_filters;
|
||||
$compiler->variable_filters = $parameter['modifier_list'];
|
||||
$compiler->variable_filters = $parameter[ 'modifier_list' ];
|
||||
// this tag does not return compiled code
|
||||
$compiler->has_code = false;
|
||||
|
||||
|
@@ -24,11 +24,11 @@ class Smarty_Internal_Compile_Shared_Inheritance extends Smarty_Internal_Compile
|
||||
*/
|
||||
public function registerInit(Smarty_Internal_TemplateCompilerBase $compiler, $initChildSequence = false)
|
||||
{
|
||||
if ($initChildSequence || !isset($compiler->_cache['inheritanceInit'])) {
|
||||
if ($initChildSequence || !isset($compiler->_cache[ 'inheritanceInit' ])) {
|
||||
$compiler->registerPostCompileCallback(array('Smarty_Internal_Compile_Shared_Inheritance', 'postCompile'),
|
||||
array($initChildSequence), 'inheritanceInit', $initChildSequence);
|
||||
|
||||
$compiler->_cache['inheritanceInit'] = true;
|
||||
$compiler->_cache[ 'inheritanceInit' ] = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -28,7 +28,7 @@ class Smarty_Internal_Compile_While extends Smarty_Internal_CompileBase
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
|
||||
{
|
||||
$compiler->loopNesting++;
|
||||
$compiler->loopNesting ++;
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
$this->openTag($compiler, 'while', $compiler->nocache);
|
||||
@@ -40,37 +40,38 @@ class Smarty_Internal_Compile_While extends Smarty_Internal_CompileBase
|
||||
// maybe nocache because of nocache variables
|
||||
$compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
|
||||
$_output = "<?php\n";
|
||||
if (is_array($parameter['if condition'])) {
|
||||
if (is_array($parameter[ 'if condition' ])) {
|
||||
if ($compiler->nocache) {
|
||||
$_nocache = ',true';
|
||||
// create nocache var to make it know for further compiling
|
||||
if (is_array($parameter['if condition']['var'])) {
|
||||
$var = trim($parameter['if condition']['var']['var'], "'");
|
||||
if (is_array($parameter[ 'if condition' ][ 'var' ])) {
|
||||
$var = trim($parameter[ 'if condition' ][ 'var' ][ 'var' ], "'");
|
||||
} else {
|
||||
$var = trim($parameter['if condition']['var'], "'");
|
||||
$var = trim($parameter[ 'if condition' ][ 'var' ], "'");
|
||||
}
|
||||
if (isset($compiler->template->tpl_vars[$var])) {
|
||||
$compiler->template->tpl_vars[$var]->nocache = true;
|
||||
if (isset($compiler->template->tpl_vars[ $var ])) {
|
||||
$compiler->template->tpl_vars[ $var ]->nocache = true;
|
||||
} else {
|
||||
$compiler->template->tpl_vars[$var] = new Smarty_Variable(null, true);
|
||||
$compiler->template->tpl_vars[ $var ] = new Smarty_Variable(null, true);
|
||||
}
|
||||
} else {
|
||||
$_nocache = '';
|
||||
}
|
||||
if (is_array($parameter['if condition']['var'])) {
|
||||
$_output .= "if (!isset(\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] .
|
||||
"]) || !is_array(\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] .
|
||||
"]->value)) \$_smarty_tpl->_createLocalArrayVariable(" . $parameter['if condition']['var']['var'] .
|
||||
"$_nocache);\n";
|
||||
$_output .= "while (\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] . "]->value" .
|
||||
$parameter['if condition']['var']['smarty_internal_index'] . " = " .
|
||||
$parameter['if condition']['value'] . ") {?>";
|
||||
if (is_array($parameter[ 'if condition' ][ 'var' ])) {
|
||||
$_output .= "if (!isset(\$_smarty_tpl->tpl_vars[" . $parameter[ 'if condition' ][ 'var' ][ 'var' ] .
|
||||
"]) || !is_array(\$_smarty_tpl->tpl_vars[" .
|
||||
$parameter[ 'if condition' ][ 'var' ][ 'var' ] .
|
||||
"]->value)) \$_smarty_tpl->_createLocalArrayVariable(" .
|
||||
$parameter[ 'if condition' ][ 'var' ][ 'var' ] . "$_nocache);\n";
|
||||
$_output .= "while (\$_smarty_tpl->tpl_vars[" . $parameter[ 'if condition' ][ 'var' ][ 'var' ] .
|
||||
"]->value" . $parameter[ 'if condition' ][ 'var' ][ 'smarty_internal_index' ] . " = " .
|
||||
$parameter[ 'if condition' ][ 'value' ] . ") {?>";
|
||||
} else {
|
||||
$_output .= "if (!isset(\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] .
|
||||
"])) \$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] .
|
||||
$_output .= "if (!isset(\$_smarty_tpl->tpl_vars[" . $parameter[ 'if condition' ][ 'var' ] .
|
||||
"])) \$_smarty_tpl->tpl_vars[" . $parameter[ 'if condition' ][ 'var' ] .
|
||||
"] = new Smarty_Variable(null{$_nocache});";
|
||||
$_output .= "while (\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "]->value = " .
|
||||
$parameter['if condition']['value'] . ") {?>";
|
||||
$_output .= "while (\$_smarty_tpl->tpl_vars[" . $parameter[ 'if condition' ][ 'var' ] . "]->value = " .
|
||||
$parameter[ 'if condition' ][ 'value' ] . ") {?>";
|
||||
}
|
||||
} else {
|
||||
$_output .= "while ({$parameter['if condition']}) {?>";
|
||||
@@ -97,7 +98,7 @@ class Smarty_Internal_Compile_Whileclose extends Smarty_Internal_CompileBase
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
|
||||
{
|
||||
$compiler->loopNesting--;
|
||||
$compiler->loopNesting --;
|
||||
// must endblock be nocache?
|
||||
if ($compiler->nocache) {
|
||||
$compiler->tag_nocache = true;
|
||||
|
@@ -65,10 +65,10 @@ abstract class Smarty_Internal_CompileBase
|
||||
if (!is_array($mixed)) {
|
||||
// option flag ?
|
||||
if (in_array(trim($mixed, '\'"'), $this->option_flags)) {
|
||||
$_indexed_attr[trim($mixed, '\'"')] = true;
|
||||
$_indexed_attr[ trim($mixed, '\'"') ] = true;
|
||||
// shorthand attribute ?
|
||||
} elseif (isset($this->shorttag_order[$key])) {
|
||||
$_indexed_attr[$this->shorttag_order[$key]] = $mixed;
|
||||
} elseif (isset($this->shorttag_order[ $key ])) {
|
||||
$_indexed_attr[ $this->shorttag_order[ $key ] ] = $mixed;
|
||||
} else {
|
||||
// too many shorthands
|
||||
$compiler->trigger_template_error('too many shorthand attributes', null, true);
|
||||
@@ -77,20 +77,22 @@ abstract class Smarty_Internal_CompileBase
|
||||
} else {
|
||||
$kv = each($mixed);
|
||||
// option flag?
|
||||
if (in_array($kv['key'], $this->option_flags)) {
|
||||
if (is_bool($kv['value'])) {
|
||||
$_indexed_attr[$kv['key']] = $kv['value'];
|
||||
} elseif (is_string($kv['value']) && in_array(trim($kv['value'], '\'"'), array('true', 'false'))) {
|
||||
if (trim($kv['value']) == 'true') {
|
||||
$_indexed_attr[$kv['key']] = true;
|
||||
if (in_array($kv[ 'key' ], $this->option_flags)) {
|
||||
if (is_bool($kv[ 'value' ])) {
|
||||
$_indexed_attr[ $kv[ 'key' ] ] = $kv[ 'value' ];
|
||||
} elseif (is_string($kv[ 'value' ]) &&
|
||||
in_array(trim($kv[ 'value' ], '\'"'), array('true', 'false'))
|
||||
) {
|
||||
if (trim($kv[ 'value' ]) == 'true') {
|
||||
$_indexed_attr[ $kv[ 'key' ] ] = true;
|
||||
} else {
|
||||
$_indexed_attr[$kv['key']] = false;
|
||||
$_indexed_attr[ $kv[ 'key' ] ] = false;
|
||||
}
|
||||
} elseif (is_numeric($kv['value']) && in_array($kv['value'], array(0, 1))) {
|
||||
if ($kv['value'] == 1) {
|
||||
$_indexed_attr[$kv['key']] = true;
|
||||
} elseif (is_numeric($kv[ 'value' ]) && in_array($kv[ 'value' ], array(0, 1))) {
|
||||
if ($kv[ 'value' ] == 1) {
|
||||
$_indexed_attr[ $kv[ 'key' ] ] = true;
|
||||
} else {
|
||||
$_indexed_attr[$kv['key']] = false;
|
||||
$_indexed_attr[ $kv[ 'key' ] ] = false;
|
||||
}
|
||||
} else {
|
||||
$compiler->trigger_template_error("illegal value of option flag \"{$kv['key']}\"", null, true);
|
||||
@@ -98,7 +100,7 @@ abstract class Smarty_Internal_CompileBase
|
||||
// must be named attribute
|
||||
} else {
|
||||
reset($mixed);
|
||||
$_indexed_attr[key($mixed)] = $mixed[key($mixed)];
|
||||
$_indexed_attr[ key($mixed) ] = $mixed[ key($mixed) ];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -119,8 +121,8 @@ abstract class Smarty_Internal_CompileBase
|
||||
}
|
||||
// default 'false' for all option flags not set
|
||||
foreach ($this->option_flags as $flag) {
|
||||
if (!isset($_indexed_attr[$flag])) {
|
||||
$_indexed_attr[$flag] = false;
|
||||
if (!isset($_indexed_attr[ $flag ])) {
|
||||
$_indexed_attr[ $flag ] = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -87,8 +87,8 @@ class Smarty_Internal_Config_File_Compiler
|
||||
$this->lexer_class = $lexer_class;
|
||||
$this->parser_class = $parser_class;
|
||||
$this->smarty = $smarty;
|
||||
$this->config_data['sections'] = array();
|
||||
$this->config_data['vars'] = array();
|
||||
$this->config_data[ 'sections' ] = array();
|
||||
$this->config_data[ 'vars' ] = array();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -101,16 +101,16 @@ class Smarty_Internal_Config_File_Compiler
|
||||
public function compileTemplate(Smarty_Internal_Template $template)
|
||||
{
|
||||
$this->template = $template;
|
||||
$this->template->compiled->file_dependency[$this->template->source->uid] = array($this->template->source->filepath,
|
||||
$this->template->source->getTimeStamp(),
|
||||
$this->template->compiled->file_dependency[ $this->template->source->uid ] =
|
||||
array($this->template->source->filepath, $this->template->source->getTimeStamp(),
|
||||
$this->template->source->type);
|
||||
if ($this->smarty->debugging) {
|
||||
$this->smarty->_debug->start_compile($this->template);
|
||||
}
|
||||
// init the lexer/parser to compile the config file
|
||||
/* @var Smarty_Internal_ConfigFileLexer $lex */
|
||||
$lex = new $this->lexer_class(str_replace(array("\r\n", "\r"), "\n", $template->source->getContent()) .
|
||||
"\n", $this);
|
||||
$lex = new $this->lexer_class(str_replace(array("\r\n", "\r"), "\n", $template->source->getContent()) . "\n",
|
||||
$this);
|
||||
/* @var Smarty_Internal_ConfigFileParser $parser */
|
||||
$parser = new $this->parser_class($lex, $this);
|
||||
|
||||
@@ -141,8 +141,9 @@ class Smarty_Internal_Config_File_Compiler
|
||||
$this->smarty->_debug->end_compile($this->template);
|
||||
}
|
||||
// template header code
|
||||
$template_header = "<?php /* Smarty version " . Smarty::SMARTY_VERSION . ", created on " .
|
||||
strftime("%Y-%m-%d %H:%M:%S") . "\n";
|
||||
$template_header =
|
||||
"<?php /* Smarty version " . Smarty::SMARTY_VERSION . ", created on " . strftime("%Y-%m-%d %H:%M:%S") .
|
||||
"\n";
|
||||
$template_header .= " compiled from \"" . $this->template->source->filepath . "\" */ ?>\n";
|
||||
|
||||
$code = '<?php $_smarty_tpl->smarty->ext->configLoad->_loadConfigVars($_smarty_tpl, ' .
|
||||
@@ -170,20 +171,21 @@ class Smarty_Internal_Config_File_Compiler
|
||||
// $line--;
|
||||
}
|
||||
$match = preg_split("/\n/", $this->lex->data);
|
||||
$error_text = "Syntax error in config file '{$this->template->source->filepath}' on line {$line} '{$match[$line - 1]}' ";
|
||||
$error_text =
|
||||
"Syntax error in config file '{$this->template->source->filepath}' on line {$line} '{$match[$line - 1]}' ";
|
||||
if (isset($args)) {
|
||||
// individual error message
|
||||
$error_text .= $args;
|
||||
} else {
|
||||
// expected token from parser
|
||||
foreach ($this->parser->yy_get_expected_tokens($this->parser->yymajor) as $token) {
|
||||
$exp_token = $this->parser->yyTokenName[$token];
|
||||
if (isset($this->lex->smarty_token_names[$exp_token])) {
|
||||
$exp_token = $this->parser->yyTokenName[ $token ];
|
||||
if (isset($this->lex->smarty_token_names[ $exp_token ])) {
|
||||
// token type from lexer
|
||||
$expect[] = '"' . $this->lex->smarty_token_names[$exp_token] . '"';
|
||||
$expect[] = '"' . $this->lex->smarty_token_names[ $exp_token ] . '"';
|
||||
} else {
|
||||
// otherwise internal token name
|
||||
$expect[] = $this->parser->yyTokenName[$token];
|
||||
$expect[] = $this->parser->yyTokenName[ $token ];
|
||||
}
|
||||
}
|
||||
// output parser error message
|
||||
|
@@ -144,7 +144,7 @@ class Smarty_Internal_Configfilelexer
|
||||
$this->data = $data . "\n"; //now all lines are \n-terminated
|
||||
$this->counter = 0;
|
||||
if (preg_match('/^\xEF\xBB\xBF/', $this->data, $match)) {
|
||||
$this->counter += strlen($match[0]);
|
||||
$this->counter += strlen($match[ 0 ]);
|
||||
}
|
||||
$this->line = 1;
|
||||
$this->compiler = $compiler;
|
||||
@@ -179,23 +179,31 @@ class Smarty_Internal_Configfilelexer
|
||||
public function yypushstate($state)
|
||||
{
|
||||
if ($this->yyTraceFILE) {
|
||||
fprintf($this->yyTraceFILE, "%sState push %s\n", $this->yyTracePrompt, isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] : $this->_yy_state);
|
||||
fprintf($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);
|
||||
$this->_yy_state = $state;
|
||||
if ($this->yyTraceFILE) {
|
||||
fprintf($this->yyTraceFILE, "%snew State %s\n", $this->yyTracePrompt, isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] : $this->_yy_state);
|
||||
fprintf($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()
|
||||
{
|
||||
if ($this->yyTraceFILE) {
|
||||
fprintf($this->yyTraceFILE, "%sState pop %s\n", $this->yyTracePrompt, isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] : $this->_yy_state);
|
||||
fprintf($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);
|
||||
if ($this->yyTraceFILE) {
|
||||
fprintf($this->yyTraceFILE, "%snew State %s\n", $this->yyTracePrompt, isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] : $this->_yy_state);
|
||||
fprintf($this->yyTraceFILE, "%snew State %s\n", $this->yyTracePrompt,
|
||||
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] :
|
||||
$this->_yy_state);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -203,14 +211,17 @@ class Smarty_Internal_Configfilelexer
|
||||
{
|
||||
$this->_yy_state = $state;
|
||||
if ($this->yyTraceFILE) {
|
||||
fprintf($this->yyTraceFILE, "%sState set %s\n", $this->yyTracePrompt, isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] : $this->_yy_state);
|
||||
fprintf($this->yyTraceFILE, "%sState set %s\n", $this->yyTracePrompt,
|
||||
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] :
|
||||
$this->_yy_state);
|
||||
}
|
||||
}
|
||||
|
||||
public function yylex1()
|
||||
{
|
||||
if (!isset($this->yy_global_pattern1)) {
|
||||
$this->yy_global_pattern1 = "/\G(#|;)|\G(\\[)|\G(\\])|\G(=)|\G([ \t\r]+)|\G(\n)|\G([0-9]*[a-zA-Z_]\\w*)|\G([\S\s])/isS";
|
||||
$this->yy_global_pattern1 =
|
||||
"/\G(#|;)|\G(\\[)|\G(\\])|\G(=)|\G([ \t\r]+)|\G(\n)|\G([0-9]*[a-zA-Z_]\\w*)|\G([\S\s])/isS";
|
||||
}
|
||||
if ($this->counter >= strlen($this->data)) {
|
||||
return false; // end of input
|
||||
@@ -219,13 +230,14 @@ class Smarty_Internal_Configfilelexer
|
||||
do {
|
||||
if (preg_match($this->yy_global_pattern1, $this->data, $yymatches, null, $this->counter)) {
|
||||
$yysubmatches = $yymatches;
|
||||
if (strlen($yysubmatches[0]) < 200) {
|
||||
if (strlen($yysubmatches[ 0 ]) < 200) {
|
||||
$yymatches = preg_grep("/(.|\s)+/", $yysubmatches);
|
||||
} else {
|
||||
$yymatches = array_filter($yymatches, 'strlen');
|
||||
}
|
||||
if (empty($yymatches)) {
|
||||
throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . substr($this->data, $this->counter, 5) . '... state START');
|
||||
throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' .
|
||||
substr($this->data, $this->counter, 5) . '... state START');
|
||||
}
|
||||
next($yymatches); // skip global match
|
||||
$this->token = key($yymatches); // token number
|
||||
@@ -250,10 +262,11 @@ class Smarty_Internal_Configfilelexer
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[$this->counter]);
|
||||
throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[ $this->counter ]);
|
||||
}
|
||||
break;
|
||||
} while (true);
|
||||
}
|
||||
while (true);
|
||||
} // end function
|
||||
|
||||
const START = 1;
|
||||
@@ -312,7 +325,8 @@ class Smarty_Internal_Configfilelexer
|
||||
public function yylex2()
|
||||
{
|
||||
if (!isset($this->yy_global_pattern2)) {
|
||||
$this->yy_global_pattern2 = "/\G([ \t\r]+)|\G(\\d+\\.\\d+(?=[ \t\r]*[\n#;]))|\G(\\d+(?=[ \t\r]*[\n#;]))|\G(\"\"\")|\G('[^'\\\\]*(?:\\\\.[^'\\\\]*)*'(?=[ \t\r]*[\n#;]))|\G(\"[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*\"(?=[ \t\r]*[\n#;]))|\G([a-zA-Z]+(?=[ \t\r]*[\n#;]))|\G([^\n]+?(?=[ \t\r]*\n))|\G(\n)/isS";
|
||||
$this->yy_global_pattern2 =
|
||||
"/\G([ \t\r]+)|\G(\\d+\\.\\d+(?=[ \t\r]*[\n#;]))|\G(\\d+(?=[ \t\r]*[\n#;]))|\G(\"\"\")|\G('[^'\\\\]*(?:\\\\.[^'\\\\]*)*'(?=[ \t\r]*[\n#;]))|\G(\"[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*\"(?=[ \t\r]*[\n#;]))|\G([a-zA-Z]+(?=[ \t\r]*[\n#;]))|\G([^\n]+?(?=[ \t\r]*\n))|\G(\n)/isS";
|
||||
}
|
||||
if ($this->counter >= strlen($this->data)) {
|
||||
return false; // end of input
|
||||
@@ -321,13 +335,14 @@ class Smarty_Internal_Configfilelexer
|
||||
do {
|
||||
if (preg_match($this->yy_global_pattern2, $this->data, $yymatches, null, $this->counter)) {
|
||||
$yysubmatches = $yymatches;
|
||||
if (strlen($yysubmatches[0]) < 200) {
|
||||
if (strlen($yysubmatches[ 0 ]) < 200) {
|
||||
$yymatches = preg_grep("/(.|\s)+/", $yysubmatches);
|
||||
} else {
|
||||
$yymatches = array_filter($yymatches, 'strlen');
|
||||
}
|
||||
if (empty($yymatches)) {
|
||||
throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . substr($this->data, $this->counter, 5) . '... state VALUE');
|
||||
throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' .
|
||||
substr($this->data, $this->counter, 5) . '... state VALUE');
|
||||
}
|
||||
next($yymatches); // skip global match
|
||||
$this->token = key($yymatches); // token number
|
||||
@@ -352,10 +367,11 @@ class Smarty_Internal_Configfilelexer
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[$this->counter]);
|
||||
throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[ $this->counter ]);
|
||||
}
|
||||
break;
|
||||
} while (true);
|
||||
}
|
||||
while (true);
|
||||
} // end function
|
||||
|
||||
const VALUE = 2;
|
||||
@@ -404,8 +420,8 @@ class Smarty_Internal_Configfilelexer
|
||||
function yy_r2_7()
|
||||
{
|
||||
|
||||
if (!$this->configBooleanize || !in_array(strtolower($this->value), Array("true", "false", "on", "off", "yes",
|
||||
"no"))
|
||||
if (!$this->configBooleanize ||
|
||||
!in_array(strtolower($this->value), Array("true", "false", "on", "off", "yes", "no"))
|
||||
) {
|
||||
$this->yypopstate();
|
||||
$this->yypushstate(self::NAKED_STRING_VALUE);
|
||||
@@ -443,13 +459,14 @@ class Smarty_Internal_Configfilelexer
|
||||
do {
|
||||
if (preg_match($this->yy_global_pattern3, $this->data, $yymatches, null, $this->counter)) {
|
||||
$yysubmatches = $yymatches;
|
||||
if (strlen($yysubmatches[0]) < 200) {
|
||||
if (strlen($yysubmatches[ 0 ]) < 200) {
|
||||
$yymatches = preg_grep("/(.|\s)+/", $yysubmatches);
|
||||
} else {
|
||||
$yymatches = array_filter($yymatches, 'strlen');
|
||||
}
|
||||
if (empty($yymatches)) {
|
||||
throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . substr($this->data, $this->counter, 5) . '... state NAKED_STRING_VALUE');
|
||||
throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' .
|
||||
substr($this->data, $this->counter, 5) . '... state NAKED_STRING_VALUE');
|
||||
}
|
||||
next($yymatches); // skip global match
|
||||
$this->token = key($yymatches); // token number
|
||||
@@ -474,10 +491,11 @@ class Smarty_Internal_Configfilelexer
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[$this->counter]);
|
||||
throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[ $this->counter ]);
|
||||
}
|
||||
break;
|
||||
} while (true);
|
||||
}
|
||||
while (true);
|
||||
} // end function
|
||||
|
||||
const NAKED_STRING_VALUE = 3;
|
||||
@@ -501,13 +519,14 @@ class Smarty_Internal_Configfilelexer
|
||||
do {
|
||||
if (preg_match($this->yy_global_pattern4, $this->data, $yymatches, null, $this->counter)) {
|
||||
$yysubmatches = $yymatches;
|
||||
if (strlen($yysubmatches[0]) < 200) {
|
||||
if (strlen($yysubmatches[ 0 ]) < 200) {
|
||||
$yymatches = preg_grep("/(.|\s)+/", $yysubmatches);
|
||||
} else {
|
||||
$yymatches = array_filter($yymatches, 'strlen');
|
||||
}
|
||||
if (empty($yymatches)) {
|
||||
throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . substr($this->data, $this->counter, 5) . '... state COMMENT');
|
||||
throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' .
|
||||
substr($this->data, $this->counter, 5) . '... state COMMENT');
|
||||
}
|
||||
next($yymatches); // skip global match
|
||||
$this->token = key($yymatches); // token number
|
||||
@@ -532,10 +551,11 @@ class Smarty_Internal_Configfilelexer
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[$this->counter]);
|
||||
throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[ $this->counter ]);
|
||||
}
|
||||
break;
|
||||
} while (true);
|
||||
}
|
||||
while (true);
|
||||
} // end function
|
||||
|
||||
const COMMENT = 4;
|
||||
@@ -571,13 +591,14 @@ class Smarty_Internal_Configfilelexer
|
||||
do {
|
||||
if (preg_match($this->yy_global_pattern5, $this->data, $yymatches, null, $this->counter)) {
|
||||
$yysubmatches = $yymatches;
|
||||
if (strlen($yysubmatches[0]) < 200) {
|
||||
if (strlen($yysubmatches[ 0 ]) < 200) {
|
||||
$yymatches = preg_grep("/(.|\s)+/", $yysubmatches);
|
||||
} else {
|
||||
$yymatches = array_filter($yymatches, 'strlen');
|
||||
}
|
||||
if (empty($yymatches)) {
|
||||
throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . substr($this->data, $this->counter, 5) . '... state SECTION');
|
||||
throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' .
|
||||
substr($this->data, $this->counter, 5) . '... state SECTION');
|
||||
}
|
||||
next($yymatches); // skip global match
|
||||
$this->token = key($yymatches); // token number
|
||||
@@ -602,10 +623,11 @@ class Smarty_Internal_Configfilelexer
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[$this->counter]);
|
||||
throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[ $this->counter ]);
|
||||
}
|
||||
break;
|
||||
} while (true);
|
||||
}
|
||||
while (true);
|
||||
} // end function
|
||||
|
||||
const SECTION = 5;
|
||||
@@ -635,13 +657,14 @@ class Smarty_Internal_Configfilelexer
|
||||
do {
|
||||
if (preg_match($this->yy_global_pattern6, $this->data, $yymatches, null, $this->counter)) {
|
||||
$yysubmatches = $yymatches;
|
||||
if (strlen($yysubmatches[0]) < 200) {
|
||||
if (strlen($yysubmatches[ 0 ]) < 200) {
|
||||
$yymatches = preg_grep("/(.|\s)+/", $yysubmatches);
|
||||
} else {
|
||||
$yymatches = array_filter($yymatches, 'strlen');
|
||||
}
|
||||
if (empty($yymatches)) {
|
||||
throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . substr($this->data, $this->counter, 5) . '... state TRIPPLE');
|
||||
throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' .
|
||||
substr($this->data, $this->counter, 5) . '... state TRIPPLE');
|
||||
}
|
||||
next($yymatches); // skip global match
|
||||
$this->token = key($yymatches); // token number
|
||||
@@ -666,10 +689,11 @@ class Smarty_Internal_Configfilelexer
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[$this->counter]);
|
||||
throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[ $this->counter ]);
|
||||
}
|
||||
break;
|
||||
} while (true);
|
||||
}
|
||||
while (true);
|
||||
} // end function
|
||||
|
||||
const TRIPPLE = 6;
|
||||
@@ -687,8 +711,8 @@ class Smarty_Internal_Configfilelexer
|
||||
|
||||
$to = strlen($this->data);
|
||||
preg_match("/\"\"\"[ \t\r]*[\n#;]/", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter);
|
||||
if (isset($match[0][1])) {
|
||||
$to = $match[0][1];
|
||||
if (isset($match[ 0 ][ 1 ])) {
|
||||
$to = $match[ 0 ][ 1 ];
|
||||
} else {
|
||||
$this->compiler->trigger_template_error("missing or misspelled literal closing tag");
|
||||
}
|
||||
|
@@ -28,18 +28,18 @@ class TPC_yyToken implements ArrayAccess
|
||||
|
||||
public function offsetExists($offset)
|
||||
{
|
||||
return isset($this->metadata[$offset]);
|
||||
return isset($this->metadata[ $offset ]);
|
||||
}
|
||||
|
||||
public function offsetGet($offset)
|
||||
{
|
||||
return $this->metadata[$offset];
|
||||
return $this->metadata[ $offset ];
|
||||
}
|
||||
|
||||
public function offsetSet($offset, $value)
|
||||
{
|
||||
if ($offset === null) {
|
||||
if (isset($value[0])) {
|
||||
if (isset($value[ 0 ])) {
|
||||
$x = ($value instanceof TPC_yyToken) ? $value->metadata : $value;
|
||||
$this->metadata = array_merge($this->metadata, $x);
|
||||
|
||||
@@ -52,16 +52,16 @@ class TPC_yyToken implements ArrayAccess
|
||||
}
|
||||
if ($value instanceof TPC_yyToken) {
|
||||
if ($value->metadata) {
|
||||
$this->metadata[$offset] = $value->metadata;
|
||||
$this->metadata[ $offset ] = $value->metadata;
|
||||
}
|
||||
} elseif ($value) {
|
||||
$this->metadata[$offset] = $value;
|
||||
$this->metadata[ $offset ] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
public function offsetUnset($offset)
|
||||
{
|
||||
unset($this->metadata[$offset]);
|
||||
unset($this->metadata[ $offset ]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -226,9 +226,9 @@ class Smarty_Internal_Configfileparser
|
||||
|
||||
$str = "";
|
||||
foreach ($ss as $s) {
|
||||
if (strlen($s) === 2 && $s[0] === '\\') {
|
||||
if (isset(self::$escapes_single[$s[1]])) {
|
||||
$s = self::$escapes_single[$s[1]];
|
||||
if (strlen($s) === 2 && $s[ 0 ] === '\\') {
|
||||
if (isset(self::$escapes_single[ $s[ 1 ] ])) {
|
||||
$s = self::$escapes_single[ $s[ 1 ] ];
|
||||
}
|
||||
}
|
||||
$str .= $s;
|
||||
@@ -269,14 +269,14 @@ class Smarty_Internal_Configfileparser
|
||||
*/
|
||||
private function set_var(Array $var, Array &$target_array)
|
||||
{
|
||||
$key = $var["key"];
|
||||
$value = $var["value"];
|
||||
$key = $var[ "key" ];
|
||||
$value = $var[ "value" ];
|
||||
|
||||
if ($this->configOverwrite || !isset($target_array['vars'][$key])) {
|
||||
$target_array['vars'][$key] = $value;
|
||||
if ($this->configOverwrite || !isset($target_array[ 'vars' ][ $key ])) {
|
||||
$target_array[ 'vars' ][ $key ] = $value;
|
||||
} else {
|
||||
settype($target_array['vars'][$key], 'array');
|
||||
$target_array['vars'][$key][] = $value;
|
||||
settype($target_array[ 'vars' ][ $key ], 'array');
|
||||
$target_array[ 'vars' ][ $key ][] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -287,8 +287,8 @@ class Smarty_Internal_Configfileparser
|
||||
*/
|
||||
private function add_global_vars(Array $vars)
|
||||
{
|
||||
if (!isset($this->compiler->config_data['vars'])) {
|
||||
$this->compiler->config_data['vars'] = Array();
|
||||
if (!isset($this->compiler->config_data[ 'vars' ])) {
|
||||
$this->compiler->config_data[ 'vars' ] = Array();
|
||||
}
|
||||
foreach ($vars as $var) {
|
||||
$this->set_var($var, $this->compiler->config_data);
|
||||
@@ -303,11 +303,11 @@ class Smarty_Internal_Configfileparser
|
||||
*/
|
||||
private function add_section_vars($section_name, Array $vars)
|
||||
{
|
||||
if (!isset($this->compiler->config_data['sections'][$section_name]['vars'])) {
|
||||
$this->compiler->config_data['sections'][$section_name]['vars'] = Array();
|
||||
if (!isset($this->compiler->config_data[ 'sections' ][ $section_name ][ 'vars' ])) {
|
||||
$this->compiler->config_data[ 'sections' ][ $section_name ][ 'vars' ] = Array();
|
||||
}
|
||||
foreach ($vars as $var) {
|
||||
$this->set_var($var, $this->compiler->config_data['sections'][$section_name]);
|
||||
$this->set_var($var, $this->compiler->config_data[ 'sections' ][ $section_name ]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -375,10 +375,12 @@ class Smarty_Internal_Configfileparser
|
||||
static public $yy_reduce_ofst = array(- 10, - 1, - 1, - 1, - 20, 10, 12, 8, 14, 7, - 11,);
|
||||
|
||||
static public $yyExpectedTokens = array(array(), array(5, 17, 18,), array(5, 17, 18,), array(5, 17, 18,),
|
||||
array(7, 8, 9, 10, 11, 12, 15, 16,), array(17, 18,), array(17, 18,), array(1,), array(), array(), array(),
|
||||
array(2, 4,), array(15, 17,), array(13, 14,), array(14,), array(17,), array(3,), array(3,), array(2,),
|
||||
array(6,), array(), array(), array(), array(), array(), array(), array(), array(), array(), array(), array(),
|
||||
array(), array(), array(), array(), array(),);
|
||||
array(7, 8, 9, 10, 11, 12, 15, 16,), array(17, 18,), array(17, 18,),
|
||||
array(1,), array(), array(), array(), array(2, 4,), array(15, 17,),
|
||||
array(13, 14,), array(14,), array(17,), array(3,), array(3,), array(2,),
|
||||
array(6,), array(), array(), array(), array(), array(), array(), array(),
|
||||
array(), array(), array(), array(), array(), array(), array(), array(),
|
||||
array(),);
|
||||
|
||||
static public $yy_default = array(44, 37, 41, 40, 58, 58, 58, 36, 39, 44, 44, 58, 58, 58, 58, 58, 58, 58, 58, 58,
|
||||
55, 54, 57, 56, 50, 45, 43, 42, 38, 46, 47, 52, 51, 49, 48, 53,);
|
||||
@@ -425,17 +427,20 @@ class Smarty_Internal_Configfileparser
|
||||
public $yystack = array(); /* The parser's stack */
|
||||
|
||||
public $yyTokenName = array('$', 'OPENB', 'SECTION', 'CLOSEB', 'DOT', 'ID', 'EQUAL', 'FLOAT', 'INT', 'BOOL',
|
||||
'SINGLE_QUOTED_STRING', 'DOUBLE_QUOTED_STRING', 'TRIPPLE_QUOTES', 'TRIPPLE_TEXT', 'TRIPPLE_QUOTES_END',
|
||||
'NAKED_STRING', 'OTHER', 'NEWLINE', 'COMMENTSTART', 'error', 'start', 'global_vars', 'sections', 'var_list',
|
||||
'section', 'newline', 'var', 'value',);
|
||||
'SINGLE_QUOTED_STRING', 'DOUBLE_QUOTED_STRING', 'TRIPPLE_QUOTES', 'TRIPPLE_TEXT',
|
||||
'TRIPPLE_QUOTES_END', 'NAKED_STRING', 'OTHER', 'NEWLINE', 'COMMENTSTART', 'error',
|
||||
'start', 'global_vars', 'sections', 'var_list', 'section', 'newline', 'var', 'value',);
|
||||
|
||||
public static $yyRuleName = array('start ::= global_vars sections', 'global_vars ::= var_list',
|
||||
'sections ::= sections section', 'sections ::=', 'section ::= OPENB SECTION CLOSEB newline var_list',
|
||||
'section ::= OPENB DOT SECTION CLOSEB newline var_list', 'var_list ::= var_list newline',
|
||||
'var_list ::= var_list var', 'var_list ::=', 'var ::= ID EQUAL value', 'value ::= FLOAT', 'value ::= INT',
|
||||
'value ::= BOOL', 'value ::= SINGLE_QUOTED_STRING', 'value ::= DOUBLE_QUOTED_STRING',
|
||||
'value ::= TRIPPLE_QUOTES TRIPPLE_TEXT TRIPPLE_QUOTES_END', 'value ::= TRIPPLE_QUOTES TRIPPLE_QUOTES_END',
|
||||
'value ::= NAKED_STRING', 'value ::= OTHER', 'newline ::= NEWLINE', 'newline ::= COMMENTSTART NEWLINE',
|
||||
'sections ::= sections section', 'sections ::=',
|
||||
'section ::= OPENB SECTION CLOSEB newline var_list',
|
||||
'section ::= OPENB DOT SECTION CLOSEB newline var_list',
|
||||
'var_list ::= var_list newline', 'var_list ::= var_list var', 'var_list ::=',
|
||||
'var ::= ID EQUAL value', 'value ::= FLOAT', 'value ::= INT', 'value ::= BOOL',
|
||||
'value ::= SINGLE_QUOTED_STRING', 'value ::= DOUBLE_QUOTED_STRING',
|
||||
'value ::= TRIPPLE_QUOTES TRIPPLE_TEXT TRIPPLE_QUOTES_END',
|
||||
'value ::= TRIPPLE_QUOTES TRIPPLE_QUOTES_END', 'value ::= NAKED_STRING',
|
||||
'value ::= OTHER', 'newline ::= NEWLINE', 'newline ::= COMMENTSTART NEWLINE',
|
||||
'newline ::= COMMENTSTART NAKED_STRING NEWLINE',);
|
||||
|
||||
public function tokenName($tokenType)
|
||||
@@ -444,7 +449,7 @@ class Smarty_Internal_Configfileparser
|
||||
return 'End of Input';
|
||||
}
|
||||
if ($tokenType > 0 && $tokenType < count($this->yyTokenName)) {
|
||||
return $this->yyTokenName[$tokenType];
|
||||
return $this->yyTokenName[ $tokenType ];
|
||||
} else {
|
||||
return "Unknown";
|
||||
}
|
||||
@@ -465,7 +470,7 @@ class Smarty_Internal_Configfileparser
|
||||
}
|
||||
$yytos = array_pop($this->yystack);
|
||||
if ($this->yyTraceFILE && $this->yyidx >= 0) {
|
||||
fwrite($this->yyTraceFILE, $this->yyTracePrompt . 'Popping ' . $this->yyTokenName[$yytos->major] . "\n");
|
||||
fwrite($this->yyTraceFILE, $this->yyTracePrompt . 'Popping ' . $this->yyTokenName[ $yytos->major ] . "\n");
|
||||
}
|
||||
$yymajor = $yytos->major;
|
||||
self::yy_destructor($yymajor, $yytos->minor);
|
||||
@@ -488,14 +493,14 @@ class Smarty_Internal_Configfileparser
|
||||
{
|
||||
static $res3 = array();
|
||||
static $res4 = array();
|
||||
$state = $this->yystack[$this->yyidx]->stateno;
|
||||
$expected = self::$yyExpectedTokens[$state];
|
||||
if (isset($res3[$state][$token])) {
|
||||
if ($res3[$state][$token]) {
|
||||
$state = $this->yystack[ $this->yyidx ]->stateno;
|
||||
$expected = self::$yyExpectedTokens[ $state ];
|
||||
if (isset($res3[ $state ][ $token ])) {
|
||||
if ($res3[ $state ][ $token ]) {
|
||||
return $expected;
|
||||
}
|
||||
} else {
|
||||
if ($res3[$state][$token] = in_array($token, self::$yyExpectedTokens[$state], true)) {
|
||||
if ($res3[ $state ][ $token ] = in_array($token, self::$yyExpectedTokens[ $state ], true)) {
|
||||
return $expected;
|
||||
}
|
||||
}
|
||||
@@ -515,18 +520,21 @@ class Smarty_Internal_Configfileparser
|
||||
return array_unique($expected);
|
||||
}
|
||||
$yyruleno = $yyact - self::YYNSTATE;
|
||||
$this->yyidx -= self::$yyRuleInfo[$yyruleno][1];
|
||||
$nextstate = $this->yy_find_reduce_action($this->yystack[$this->yyidx]->stateno, self::$yyRuleInfo[$yyruleno][0]);
|
||||
if (isset(self::$yyExpectedTokens[$nextstate])) {
|
||||
$expected = array_merge($expected, self::$yyExpectedTokens[$nextstate]);
|
||||
if (isset($res4[$nextstate][$token])) {
|
||||
if ($res4[$nextstate][$token]) {
|
||||
$this->yyidx -= self::$yyRuleInfo[ $yyruleno ][ 1 ];
|
||||
$nextstate = $this->yy_find_reduce_action($this->yystack[ $this->yyidx ]->stateno,
|
||||
self::$yyRuleInfo[ $yyruleno ][ 0 ]);
|
||||
if (isset(self::$yyExpectedTokens[ $nextstate ])) {
|
||||
$expected = array_merge($expected, self::$yyExpectedTokens[ $nextstate ]);
|
||||
if (isset($res4[ $nextstate ][ $token ])) {
|
||||
if ($res4[ $nextstate ][ $token ]) {
|
||||
$this->yyidx = $yyidx;
|
||||
$this->yystack = $stack;
|
||||
return array_unique($expected);
|
||||
}
|
||||
} else {
|
||||
if ($res4[$nextstate][$token] = in_array($token, self::$yyExpectedTokens[$nextstate], true)) {
|
||||
if ($res4[ $nextstate ][ $token ] =
|
||||
in_array($token, self::$yyExpectedTokens[ $nextstate ], true)
|
||||
) {
|
||||
$this->yyidx = $yyidx;
|
||||
$this->yystack = $stack;
|
||||
return array_unique($expected);
|
||||
@@ -538,8 +546,8 @@ class Smarty_Internal_Configfileparser
|
||||
$this->yyidx ++;
|
||||
$x = new TPC_yyStackEntry;
|
||||
$x->stateno = $nextstate;
|
||||
$x->major = self::$yyRuleInfo[$yyruleno][0];
|
||||
$this->yystack[$this->yyidx] = $x;
|
||||
$x->major = self::$yyRuleInfo[ $yyruleno ][ 0 ];
|
||||
$this->yystack[ $this->yyidx ] = $x;
|
||||
continue 2;
|
||||
} elseif ($nextstate == self::YYNSTATE + self::YYNRULE + 1) {
|
||||
$this->yyidx = $yyidx;
|
||||
@@ -556,10 +564,12 @@ class Smarty_Internal_Configfileparser
|
||||
} else {
|
||||
$yyact = $nextstate;
|
||||
}
|
||||
} while (true);
|
||||
}
|
||||
while (true);
|
||||
}
|
||||
break;
|
||||
} while (true);
|
||||
}
|
||||
while (true);
|
||||
$this->yyidx = $yyidx;
|
||||
$this->yystack = $stack;
|
||||
|
||||
@@ -573,13 +583,13 @@ class Smarty_Internal_Configfileparser
|
||||
if ($token === 0) {
|
||||
return true; // 0 is not part of this
|
||||
}
|
||||
$state = $this->yystack[$this->yyidx]->stateno;
|
||||
if (isset($res[$state][$token])) {
|
||||
if ($res[$state][$token]) {
|
||||
$state = $this->yystack[ $this->yyidx ]->stateno;
|
||||
if (isset($res[ $state ][ $token ])) {
|
||||
if ($res[ $state ][ $token ]) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if ($res[$state][$token] = in_array($token, self::$yyExpectedTokens[$state], true)) {
|
||||
if ($res[ $state ][ $token ] = in_array($token, self::$yyExpectedTokens[ $state ], true)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -599,16 +609,20 @@ class Smarty_Internal_Configfileparser
|
||||
return true;
|
||||
}
|
||||
$yyruleno = $yyact - self::YYNSTATE;
|
||||
$this->yyidx -= self::$yyRuleInfo[$yyruleno][1];
|
||||
$nextstate = $this->yy_find_reduce_action($this->yystack[$this->yyidx]->stateno, self::$yyRuleInfo[$yyruleno][0]);
|
||||
if (isset($res2[$nextstate][$token])) {
|
||||
if ($res2[$nextstate][$token]) {
|
||||
$this->yyidx -= self::$yyRuleInfo[ $yyruleno ][ 1 ];
|
||||
$nextstate = $this->yy_find_reduce_action($this->yystack[ $this->yyidx ]->stateno,
|
||||
self::$yyRuleInfo[ $yyruleno ][ 0 ]);
|
||||
if (isset($res2[ $nextstate ][ $token ])) {
|
||||
if ($res2[ $nextstate ][ $token ]) {
|
||||
$this->yyidx = $yyidx;
|
||||
$this->yystack = $stack;
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if ($res2[$nextstate][$token] = (isset(self::$yyExpectedTokens[$nextstate]) && in_array($token, self::$yyExpectedTokens[$nextstate], true))) {
|
||||
if ($res2[ $nextstate ][ $token ] = (isset(self::$yyExpectedTokens[ $nextstate ]) &&
|
||||
in_array($token, self::$yyExpectedTokens[ $nextstate ],
|
||||
true))
|
||||
) {
|
||||
$this->yyidx = $yyidx;
|
||||
$this->yystack = $stack;
|
||||
return true;
|
||||
@@ -619,8 +633,8 @@ class Smarty_Internal_Configfileparser
|
||||
$this->yyidx ++;
|
||||
$x = new TPC_yyStackEntry;
|
||||
$x->stateno = $nextstate;
|
||||
$x->major = self::$yyRuleInfo[$yyruleno][0];
|
||||
$this->yystack[$this->yyidx] = $x;
|
||||
$x->major = self::$yyRuleInfo[ $yyruleno ][ 0 ];
|
||||
$this->yystack[ $this->yyidx ] = $x;
|
||||
continue 2;
|
||||
} elseif ($nextstate == self::YYNSTATE + self::YYNRULE + 1) {
|
||||
$this->yyidx = $yyidx;
|
||||
@@ -641,10 +655,12 @@ class Smarty_Internal_Configfileparser
|
||||
} else {
|
||||
$yyact = $nextstate;
|
||||
}
|
||||
} while (true);
|
||||
}
|
||||
while (true);
|
||||
}
|
||||
break;
|
||||
} while (true);
|
||||
}
|
||||
while (true);
|
||||
$this->yyidx = $yyidx;
|
||||
$this->yystack = $stack;
|
||||
|
||||
@@ -653,33 +669,37 @@ class Smarty_Internal_Configfileparser
|
||||
|
||||
public function yy_find_shift_action($iLookAhead)
|
||||
{
|
||||
$stateno = $this->yystack[$this->yyidx]->stateno;
|
||||
$stateno = $this->yystack[ $this->yyidx ]->stateno;
|
||||
|
||||
/* if ($this->yyidx < 0) return self::YY_NO_ACTION; */
|
||||
if (!isset(self::$yy_shift_ofst[$stateno])) {
|
||||
if (!isset(self::$yy_shift_ofst[ $stateno ])) {
|
||||
// no shift actions
|
||||
return self::$yy_default[$stateno];
|
||||
return self::$yy_default[ $stateno ];
|
||||
}
|
||||
$i = self::$yy_shift_ofst[$stateno];
|
||||
$i = self::$yy_shift_ofst[ $stateno ];
|
||||
if ($i === self::YY_SHIFT_USE_DFLT) {
|
||||
return self::$yy_default[$stateno];
|
||||
return self::$yy_default[ $stateno ];
|
||||
}
|
||||
if ($iLookAhead == self::YYNOCODE) {
|
||||
return self::YY_NO_ACTION;
|
||||
}
|
||||
$i += $iLookAhead;
|
||||
if ($i < 0 || $i >= self::YY_SZ_ACTTAB || self::$yy_lookahead[$i] != $iLookAhead) {
|
||||
if (count(self::$yyFallback) && $iLookAhead < count(self::$yyFallback) && ($iFallback = self::$yyFallback[$iLookAhead]) != 0) {
|
||||
if ($i < 0 || $i >= self::YY_SZ_ACTTAB || self::$yy_lookahead[ $i ] != $iLookAhead) {
|
||||
if (count(self::$yyFallback) && $iLookAhead < count(self::$yyFallback) &&
|
||||
($iFallback = self::$yyFallback[ $iLookAhead ]) != 0
|
||||
) {
|
||||
if ($this->yyTraceFILE) {
|
||||
fwrite($this->yyTraceFILE, $this->yyTracePrompt . "FALLBACK " . $this->yyTokenName[$iLookAhead] . " => " . $this->yyTokenName[$iFallback] . "\n");
|
||||
fwrite($this->yyTraceFILE,
|
||||
$this->yyTracePrompt . "FALLBACK " . $this->yyTokenName[ $iLookAhead ] . " => " .
|
||||
$this->yyTokenName[ $iFallback ] . "\n");
|
||||
}
|
||||
|
||||
return $this->yy_find_shift_action($iFallback);
|
||||
}
|
||||
|
||||
return self::$yy_default[$stateno];
|
||||
return self::$yy_default[ $stateno ];
|
||||
} else {
|
||||
return self::$yy_action[$i];
|
||||
return self::$yy_action[ $i ];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -687,21 +707,21 @@ class Smarty_Internal_Configfileparser
|
||||
{
|
||||
/* $stateno = $this->yystack[$this->yyidx]->stateno; */
|
||||
|
||||
if (!isset(self::$yy_reduce_ofst[$stateno])) {
|
||||
return self::$yy_default[$stateno];
|
||||
if (!isset(self::$yy_reduce_ofst[ $stateno ])) {
|
||||
return self::$yy_default[ $stateno ];
|
||||
}
|
||||
$i = self::$yy_reduce_ofst[$stateno];
|
||||
$i = self::$yy_reduce_ofst[ $stateno ];
|
||||
if ($i == self::YY_REDUCE_USE_DFLT) {
|
||||
return self::$yy_default[$stateno];
|
||||
return self::$yy_default[ $stateno ];
|
||||
}
|
||||
if ($iLookAhead == self::YYNOCODE) {
|
||||
return self::YY_NO_ACTION;
|
||||
}
|
||||
$i += $iLookAhead;
|
||||
if ($i < 0 || $i >= self::YY_SZ_ACTTAB || self::$yy_lookahead[$i] != $iLookAhead) {
|
||||
return self::$yy_default[$stateno];
|
||||
if ($i < 0 || $i >= self::YY_SZ_ACTTAB || self::$yy_lookahead[ $i ] != $iLookAhead) {
|
||||
return self::$yy_default[ $stateno ];
|
||||
} else {
|
||||
return self::$yy_action[$i];
|
||||
return self::$yy_action[ $i ];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -732,22 +752,24 @@ class Smarty_Internal_Configfileparser
|
||||
fprintf($this->yyTraceFILE, "%sShift %d\n", $this->yyTracePrompt, $yyNewState);
|
||||
fprintf($this->yyTraceFILE, "%sStack:", $this->yyTracePrompt);
|
||||
for ($i = 1; $i <= $this->yyidx; $i ++) {
|
||||
fprintf($this->yyTraceFILE, " %s", $this->yyTokenName[$this->yystack[$i]->major]);
|
||||
fprintf($this->yyTraceFILE, " %s", $this->yyTokenName[ $this->yystack[ $i ]->major ]);
|
||||
}
|
||||
fwrite($this->yyTraceFILE, "\n");
|
||||
}
|
||||
}
|
||||
|
||||
public static $yyRuleInfo = array(array(0 => 20, 1 => 2), array(0 => 21, 1 => 1), array(0 => 22, 1 => 2),
|
||||
array(0 => 22, 1 => 0), array(0 => 24, 1 => 5), array(0 => 24, 1 => 6), array(0 => 23, 1 => 2),
|
||||
array(0 => 23, 1 => 2), array(0 => 23, 1 => 0), array(0 => 26, 1 => 3), array(0 => 27, 1 => 1),
|
||||
array(0 => 27, 1 => 1), array(0 => 27, 1 => 1), array(0 => 27, 1 => 1), array(0 => 27, 1 => 1),
|
||||
array(0 => 27, 1 => 3), array(0 => 27, 1 => 2), array(0 => 27, 1 => 1), array(0 => 27, 1 => 1),
|
||||
array(0 => 25, 1 => 1), array(0 => 25, 1 => 2), array(0 => 25, 1 => 3),);
|
||||
array(0 => 22, 1 => 0), array(0 => 24, 1 => 5), array(0 => 24, 1 => 6),
|
||||
array(0 => 23, 1 => 2), array(0 => 23, 1 => 2), array(0 => 23, 1 => 0),
|
||||
array(0 => 26, 1 => 3), array(0 => 27, 1 => 1), array(0 => 27, 1 => 1),
|
||||
array(0 => 27, 1 => 1), array(0 => 27, 1 => 1), array(0 => 27, 1 => 1),
|
||||
array(0 => 27, 1 => 3), array(0 => 27, 1 => 2), array(0 => 27, 1 => 1),
|
||||
array(0 => 27, 1 => 1), array(0 => 25, 1 => 1), array(0 => 25, 1 => 2),
|
||||
array(0 => 25, 1 => 3),);
|
||||
|
||||
public static $yyReduceMap = array(0 => 0, 2 => 0, 3 => 0, 19 => 0, 20 => 0, 21 => 0, 1 => 1, 4 => 4, 5 => 5,
|
||||
6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10, 11 => 11, 12 => 12, 13 => 13,
|
||||
14 => 14, 15 => 15, 16 => 16, 17 => 17, 18 => 17,);
|
||||
6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10, 11 => 11, 12 => 12, 13 => 13, 14 => 14,
|
||||
15 => 15, 16 => 16, 17 => 17, 18 => 17,);
|
||||
|
||||
#line 261 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
function yy_r0()
|
||||
@@ -758,14 +780,14 @@ class Smarty_Internal_Configfileparser
|
||||
#line 266 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
function yy_r1()
|
||||
{
|
||||
$this->add_global_vars($this->yystack[$this->yyidx + 0]->minor);
|
||||
$this->add_global_vars($this->yystack[ $this->yyidx + 0 ]->minor);
|
||||
$this->_retvalue = null;
|
||||
}
|
||||
|
||||
#line 280 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
function yy_r4()
|
||||
{
|
||||
$this->add_section_vars($this->yystack[$this->yyidx + - 3]->minor, $this->yystack[$this->yyidx + 0]->minor);
|
||||
$this->add_section_vars($this->yystack[ $this->yyidx + - 3 ]->minor, $this->yystack[ $this->yyidx + 0 ]->minor);
|
||||
$this->_retvalue = null;
|
||||
}
|
||||
|
||||
@@ -773,7 +795,8 @@ class Smarty_Internal_Configfileparser
|
||||
function yy_r5()
|
||||
{
|
||||
if ($this->configReadHidden) {
|
||||
$this->add_section_vars($this->yystack[$this->yyidx + - 3]->minor, $this->yystack[$this->yyidx + 0]->minor);
|
||||
$this->add_section_vars($this->yystack[ $this->yyidx + - 3 ]->minor,
|
||||
$this->yystack[ $this->yyidx + 0 ]->minor);
|
||||
}
|
||||
$this->_retvalue = null;
|
||||
}
|
||||
@@ -781,13 +804,14 @@ class Smarty_Internal_Configfileparser
|
||||
#line 293 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
function yy_r6()
|
||||
{
|
||||
$this->_retvalue = $this->yystack[$this->yyidx + - 1]->minor;
|
||||
$this->_retvalue = $this->yystack[ $this->yyidx + - 1 ]->minor;
|
||||
}
|
||||
|
||||
#line 297 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
function yy_r7()
|
||||
{
|
||||
$this->_retvalue = array_merge($this->yystack[$this->yyidx + - 1]->minor, Array($this->yystack[$this->yyidx + 0]->minor));
|
||||
$this->_retvalue =
|
||||
array_merge($this->yystack[ $this->yyidx + - 1 ]->minor, Array($this->yystack[ $this->yyidx + 0 ]->minor));
|
||||
}
|
||||
|
||||
#line 301 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
@@ -799,44 +823,44 @@ class Smarty_Internal_Configfileparser
|
||||
#line 307 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
function yy_r9()
|
||||
{
|
||||
$this->_retvalue = Array("key" => $this->yystack[$this->yyidx + - 2]->minor,
|
||||
"value" => $this->yystack[$this->yyidx + 0]->minor);
|
||||
$this->_retvalue = Array("key" => $this->yystack[ $this->yyidx + - 2 ]->minor,
|
||||
"value" => $this->yystack[ $this->yyidx + 0 ]->minor);
|
||||
}
|
||||
|
||||
#line 312 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
function yy_r10()
|
||||
{
|
||||
$this->_retvalue = (float) $this->yystack[$this->yyidx + 0]->minor;
|
||||
$this->_retvalue = (float) $this->yystack[ $this->yyidx + 0 ]->minor;
|
||||
}
|
||||
|
||||
#line 316 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
function yy_r11()
|
||||
{
|
||||
$this->_retvalue = (int) $this->yystack[$this->yyidx + 0]->minor;
|
||||
$this->_retvalue = (int) $this->yystack[ $this->yyidx + 0 ]->minor;
|
||||
}
|
||||
|
||||
#line 320 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
function yy_r12()
|
||||
{
|
||||
$this->_retvalue = $this->parse_bool($this->yystack[$this->yyidx + 0]->minor);
|
||||
$this->_retvalue = $this->parse_bool($this->yystack[ $this->yyidx + 0 ]->minor);
|
||||
}
|
||||
|
||||
#line 324 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
function yy_r13()
|
||||
{
|
||||
$this->_retvalue = self::parse_single_quoted_string($this->yystack[$this->yyidx + 0]->minor);
|
||||
$this->_retvalue = self::parse_single_quoted_string($this->yystack[ $this->yyidx + 0 ]->minor);
|
||||
}
|
||||
|
||||
#line 328 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
function yy_r14()
|
||||
{
|
||||
$this->_retvalue = self::parse_double_quoted_string($this->yystack[$this->yyidx + 0]->minor);
|
||||
$this->_retvalue = self::parse_double_quoted_string($this->yystack[ $this->yyidx + 0 ]->minor);
|
||||
}
|
||||
|
||||
#line 332 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
function yy_r15()
|
||||
{
|
||||
$this->_retvalue = self::parse_tripple_double_quoted_string($this->yystack[$this->yyidx + - 1]->minor);
|
||||
$this->_retvalue = self::parse_tripple_double_quoted_string($this->yystack[ $this->yyidx + - 1 ]->minor);
|
||||
}
|
||||
|
||||
#line 336 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
@@ -848,7 +872,7 @@ class Smarty_Internal_Configfileparser
|
||||
#line 340 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
function yy_r17()
|
||||
{
|
||||
$this->_retvalue = $this->yystack[$this->yyidx + 0]->minor;
|
||||
$this->_retvalue = $this->yystack[ $this->yyidx + 0 ]->minor;
|
||||
}
|
||||
|
||||
private $_retvalue;
|
||||
@@ -856,24 +880,25 @@ class Smarty_Internal_Configfileparser
|
||||
public function yy_reduce($yyruleno)
|
||||
{
|
||||
if ($this->yyTraceFILE && $yyruleno >= 0 && $yyruleno < count(self::$yyRuleName)) {
|
||||
fprintf($this->yyTraceFILE, "%sReduce (%d) [%s].\n", $this->yyTracePrompt, $yyruleno, self::$yyRuleName[$yyruleno]);
|
||||
fprintf($this->yyTraceFILE, "%sReduce (%d) [%s].\n", $this->yyTracePrompt, $yyruleno,
|
||||
self::$yyRuleName[ $yyruleno ]);
|
||||
}
|
||||
|
||||
$this->_retvalue = $yy_lefthand_side = null;
|
||||
if (isset(self::$yyReduceMap[$yyruleno])) {
|
||||
if (isset(self::$yyReduceMap[ $yyruleno ])) {
|
||||
// call the action
|
||||
$this->_retvalue = null;
|
||||
$this->{'yy_r' . self::$yyReduceMap[$yyruleno]}();
|
||||
$this->{'yy_r' . self::$yyReduceMap[ $yyruleno ]}();
|
||||
$yy_lefthand_side = $this->_retvalue;
|
||||
}
|
||||
$yygoto = self::$yyRuleInfo[$yyruleno][0];
|
||||
$yysize = self::$yyRuleInfo[$yyruleno][1];
|
||||
$yygoto = self::$yyRuleInfo[ $yyruleno ][ 0 ];
|
||||
$yysize = self::$yyRuleInfo[ $yyruleno ][ 1 ];
|
||||
$this->yyidx -= $yysize;
|
||||
for ($i = $yysize; $i; $i --) {
|
||||
// pop all of the right-hand side parameters
|
||||
array_pop($this->yystack);
|
||||
}
|
||||
$yyact = $this->yy_find_reduce_action($this->yystack[$this->yyidx]->stateno, $yygoto);
|
||||
$yyact = $this->yy_find_reduce_action($this->yystack[ $this->yyidx ]->stateno, $yygoto);
|
||||
if ($yyact < self::YYNSTATE) {
|
||||
if (!$this->yyTraceFILE && $yysize) {
|
||||
$this->yyidx ++;
|
||||
@@ -881,7 +906,7 @@ class Smarty_Internal_Configfileparser
|
||||
$x->stateno = $yyact;
|
||||
$x->major = $yygoto;
|
||||
$x->minor = $yy_lefthand_side;
|
||||
$this->yystack[$this->yyidx] = $x;
|
||||
$this->yystack[ $this->yyidx ] = $x;
|
||||
} else {
|
||||
$this->yy_shift($yyact, $yygoto, $yy_lefthand_side);
|
||||
}
|
||||
@@ -940,7 +965,7 @@ class Smarty_Internal_Configfileparser
|
||||
$yyendofinput = ($yymajor == 0);
|
||||
|
||||
if ($this->yyTraceFILE) {
|
||||
fprintf($this->yyTraceFILE, "%sInput %s\n", $this->yyTracePrompt, $this->yyTokenName[$yymajor]);
|
||||
fprintf($this->yyTraceFILE, "%sInput %s\n", $this->yyTracePrompt, $this->yyTokenName[ $yymajor ]);
|
||||
}
|
||||
|
||||
do {
|
||||
@@ -967,15 +992,17 @@ class Smarty_Internal_Configfileparser
|
||||
if ($this->yyerrcnt < 0) {
|
||||
$this->yy_syntax_error($yymajor, $yytokenvalue);
|
||||
}
|
||||
$yymx = $this->yystack[$this->yyidx]->major;
|
||||
$yymx = $this->yystack[ $this->yyidx ]->major;
|
||||
if ($yymx == self::YYERRORSYMBOL || $yyerrorhit) {
|
||||
if ($this->yyTraceFILE) {
|
||||
fprintf($this->yyTraceFILE, "%sDiscard input token %s\n", $this->yyTracePrompt, $this->yyTokenName[$yymajor]);
|
||||
fprintf($this->yyTraceFILE, "%sDiscard input token %s\n", $this->yyTracePrompt,
|
||||
$this->yyTokenName[ $yymajor ]);
|
||||
}
|
||||
$this->yy_destructor($yymajor, $yytokenvalue);
|
||||
$yymajor = self::YYNOCODE;
|
||||
} else {
|
||||
while ($this->yyidx >= 0 && $yymx != self::YYERRORSYMBOL && ($yyact = $this->yy_find_shift_action(self::YYERRORSYMBOL)) >= self::YYNSTATE) {
|
||||
while ($this->yyidx >= 0 && $yymx != self::YYERRORSYMBOL &&
|
||||
($yyact = $this->yy_find_shift_action(self::YYERRORSYMBOL)) >= self::YYNSTATE) {
|
||||
$this->yy_pop_parser_stack();
|
||||
}
|
||||
if ($this->yyidx < 0 || $yymajor == 0) {
|
||||
@@ -1004,7 +1031,8 @@ class Smarty_Internal_Configfileparser
|
||||
$this->yy_accept();
|
||||
$yymajor = self::YYNOCODE;
|
||||
}
|
||||
} while ($yymajor != self::YYNOCODE && $this->yyidx >= 0);
|
||||
}
|
||||
while ($yymajor != self::YYNOCODE && $this->yyidx >= 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -15,7 +15,6 @@
|
||||
* @subpackage Template
|
||||
*
|
||||
* @property int $scope
|
||||
|
||||
* The following methods will be dynamically loaded by the extension handler when they are called.
|
||||
* They are located in a corresponding Smarty_Internal_Method_xxxx class
|
||||
*
|
||||
@@ -97,7 +96,7 @@ class Smarty_Internal_Data
|
||||
if (is_array($tpl_var)) {
|
||||
foreach ($tpl_var as $_key => $_val) {
|
||||
if ($_key != '') {
|
||||
$this->tpl_vars[$_key] = new Smarty_Variable($_val, $nocache);
|
||||
$this->tpl_vars[ $_key ] = new Smarty_Variable($_val, $nocache);
|
||||
if ($this->_objType == 2 && $this->scope) {
|
||||
$this->ext->_updateScope->updateScope($this, $_key);
|
||||
}
|
||||
@@ -105,7 +104,7 @@ class Smarty_Internal_Data
|
||||
}
|
||||
} else {
|
||||
if ($tpl_var != '') {
|
||||
$this->tpl_vars[$tpl_var] = new Smarty_Variable($value, $nocache);
|
||||
$this->tpl_vars[ $tpl_var ] = new Smarty_Variable($value, $nocache);
|
||||
if ($this->_objType == 2 && $this->scope) {
|
||||
$this->ext->_updateScope->updateScope($this, $tpl_var);
|
||||
}
|
||||
@@ -203,7 +202,9 @@ class Smarty_Internal_Data
|
||||
* @return Smarty_Variable|Smarty_Undefined_Variable the object of the variable
|
||||
* @deprecated since 3.1.28 please use Smarty_Internal_Data::getTemplateVars() instead.
|
||||
*/
|
||||
public function getVariable($variable = null, Smarty_Internal_Data $_ptr = null, $searchParents = true, $error_enable = true){
|
||||
public function getVariable($variable = null, Smarty_Internal_Data $_ptr = null, $searchParents = true,
|
||||
$error_enable = true)
|
||||
{
|
||||
return $this->ext->getTemplateVars->_getVariable($this, $variable, $_ptr, $searchParents, $error_enable);
|
||||
}
|
||||
|
||||
|
@@ -55,10 +55,10 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
|
||||
if (isset($mode)) {
|
||||
$this->index ++;
|
||||
$this->offset ++;
|
||||
$this->template_data[$this->index] = null;
|
||||
$this->template_data[ $this->index ] = null;
|
||||
}
|
||||
$key = $this->get_key($template);
|
||||
$this->template_data[$this->index][$key]['start_template_time'] = microtime(true);
|
||||
$this->template_data[ $this->index ][ $key ][ 'start_template_time' ] = microtime(true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -69,8 +69,8 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
|
||||
public function end_template(Smarty_Internal_Template $template)
|
||||
{
|
||||
$key = $this->get_key($template);
|
||||
$this->template_data[$this->index][$key]['total_time'] +=
|
||||
microtime(true) - $this->template_data[$this->index][$key]['start_template_time'];
|
||||
$this->template_data[ $this->index ][ $key ][ 'total_time' ] +=
|
||||
microtime(true) - $this->template_data[ $this->index ][ $key ][ 'start_template_time' ];
|
||||
//$this->template_data[$this->index][$key]['properties'] = $template->properties;
|
||||
}
|
||||
|
||||
@@ -84,24 +84,24 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
|
||||
static $_is_stringy = array('string' => true, 'eval' => true);
|
||||
if (!empty($template->compiler->trace_uid)) {
|
||||
$key = $template->compiler->trace_uid;
|
||||
if (!isset($this->template_data[$this->index][$key])) {
|
||||
if (isset($_is_stringy[$template->source->type])) {
|
||||
$this->template_data[$this->index][$key]['name'] =
|
||||
if (!isset($this->template_data[ $this->index ][ $key ])) {
|
||||
if (isset($_is_stringy[ $template->source->type ])) {
|
||||
$this->template_data[ $this->index ][ $key ][ 'name' ] =
|
||||
'\'' . substr($template->source->name, 0, 25) . '...\'';
|
||||
} else {
|
||||
$this->template_data[$this->index][$key]['name'] = $template->source->filepath;
|
||||
$this->template_data[ $this->index ][ $key ][ 'name' ] = $template->source->filepath;
|
||||
}
|
||||
$this->template_data[$this->index][$key]['compile_time'] = 0;
|
||||
$this->template_data[$this->index][$key]['render_time'] = 0;
|
||||
$this->template_data[$this->index][$key]['cache_time'] = 0;
|
||||
$this->template_data[ $this->index ][ $key ][ 'compile_time' ] = 0;
|
||||
$this->template_data[ $this->index ][ $key ][ 'render_time' ] = 0;
|
||||
$this->template_data[ $this->index ][ $key ][ 'cache_time' ] = 0;
|
||||
}
|
||||
} else {
|
||||
if (isset($this->ignore_uid[$template->source->uid])) {
|
||||
if (isset($this->ignore_uid[ $template->source->uid ])) {
|
||||
return;
|
||||
}
|
||||
$key = $this->get_key($template);
|
||||
}
|
||||
$this->template_data[$this->index][$key]['start_time'] = microtime(true);
|
||||
$this->template_data[ $this->index ][ $key ][ 'start_time' ] = microtime(true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -114,14 +114,14 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
|
||||
if (!empty($template->compiler->trace_uid)) {
|
||||
$key = $template->compiler->trace_uid;
|
||||
} else {
|
||||
if (isset($this->ignore_uid[$template->source->uid])) {
|
||||
if (isset($this->ignore_uid[ $template->source->uid ])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$key = $this->get_key($template);
|
||||
}
|
||||
$this->template_data[$this->index][$key]['compile_time'] +=
|
||||
microtime(true) - $this->template_data[$this->index][$key]['start_time'];
|
||||
$this->template_data[ $this->index ][ $key ][ 'compile_time' ] +=
|
||||
microtime(true) - $this->template_data[ $this->index ][ $key ][ 'start_time' ];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -132,7 +132,7 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
|
||||
public function start_render(Smarty_Internal_Template $template)
|
||||
{
|
||||
$key = $this->get_key($template);
|
||||
$this->template_data[$this->index][$key]['start_time'] = microtime(true);
|
||||
$this->template_data[ $this->index ][ $key ][ 'start_time' ] = microtime(true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -143,8 +143,8 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
|
||||
public function end_render(Smarty_Internal_Template $template)
|
||||
{
|
||||
$key = $this->get_key($template);
|
||||
$this->template_data[$this->index][$key]['render_time'] +=
|
||||
microtime(true) - $this->template_data[$this->index][$key]['start_time'];
|
||||
$this->template_data[ $this->index ][ $key ][ 'render_time' ] +=
|
||||
microtime(true) - $this->template_data[ $this->index ][ $key ][ 'start_time' ];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -155,7 +155,7 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
|
||||
public function start_cache(Smarty_Internal_Template $template)
|
||||
{
|
||||
$key = $this->get_key($template);
|
||||
$this->template_data[$this->index][$key]['start_time'] = microtime(true);
|
||||
$this->template_data[ $this->index ][ $key ][ 'start_time' ] = microtime(true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -166,8 +166,8 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
|
||||
public function end_cache(Smarty_Internal_Template $template)
|
||||
{
|
||||
$key = $this->get_key($template);
|
||||
$this->template_data[$this->index][$key]['cache_time'] +=
|
||||
microtime(true) - $this->template_data[$this->index][$key]['start_time'];
|
||||
$this->template_data[ $this->index ][ $key ][ 'cache_time' ] +=
|
||||
microtime(true) - $this->template_data[ $this->index ][ $key ][ 'start_time' ];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -244,7 +244,7 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
|
||||
$_template->assign('template_name', $obj->source->type . ':' . $obj->source->name);
|
||||
}
|
||||
if ($obj->_objType == 1 || $full) {
|
||||
$_template->assign('template_data', $this->template_data[$this->index]);
|
||||
$_template->assign('template_data', $this->template_data[ $this->index ]);
|
||||
} else {
|
||||
$_template->assign('template_data', null);
|
||||
}
|
||||
@@ -273,53 +273,53 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
|
||||
{
|
||||
$config_vars = array();
|
||||
foreach ($obj->config_vars as $key => $var) {
|
||||
$config_vars[$key]['value'] = $var;
|
||||
$config_vars[ $key ][ 'value' ] = $var;
|
||||
if ($obj->_objType == 2) {
|
||||
$config_vars[$key]['scope'] = $obj->source->type . ':' . $obj->source->name;
|
||||
$config_vars[ $key ][ 'scope' ] = $obj->source->type . ':' . $obj->source->name;
|
||||
} elseif ($obj->_objType == 4) {
|
||||
$tpl_vars[$key]['scope'] = $obj->dataObjectName;
|
||||
$tpl_vars[ $key ][ 'scope' ] = $obj->dataObjectName;
|
||||
} else {
|
||||
$config_vars[$key]['scope'] = 'Smarty object';
|
||||
$config_vars[ $key ][ 'scope' ] = 'Smarty object';
|
||||
}
|
||||
}
|
||||
$tpl_vars = array();
|
||||
foreach ($obj->tpl_vars as $key => $var) {
|
||||
foreach ($var as $varkey => $varvalue) {
|
||||
if ($varkey == 'value') {
|
||||
$tpl_vars[$key][$varkey] = $varvalue;
|
||||
$tpl_vars[ $key ][ $varkey ] = $varvalue;
|
||||
} else {
|
||||
if ($varkey == 'nocache') {
|
||||
if ($varvalue == true) {
|
||||
$tpl_vars[$key][$varkey] = $varvalue;
|
||||
$tpl_vars[ $key ][ $varkey ] = $varvalue;
|
||||
}
|
||||
} else {
|
||||
if ($varkey != 'scope' || $varvalue !== 0) {
|
||||
$tpl_vars[$key]['attributes'][$varkey] = $varvalue;
|
||||
$tpl_vars[ $key ][ 'attributes' ][ $varkey ] = $varvalue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($obj->_objType == 2) {
|
||||
$tpl_vars[$key]['scope'] = $obj->source->type . ':' . $obj->source->name;
|
||||
$tpl_vars[ $key ][ 'scope' ] = $obj->source->type . ':' . $obj->source->name;
|
||||
} elseif ($obj->_objType == 4) {
|
||||
$tpl_vars[$key]['scope'] = $obj->dataObjectName;
|
||||
$tpl_vars[ $key ][ 'scope' ] = $obj->dataObjectName;
|
||||
} else {
|
||||
$tpl_vars[$key]['scope'] = 'Smarty object';
|
||||
$tpl_vars[ $key ][ 'scope' ] = 'Smarty object';
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($obj->parent)) {
|
||||
$parent = $this->get_debug_vars($obj->parent);
|
||||
foreach ($parent->tpl_vars as $name => $pvar) {
|
||||
if (isset($tpl_vars[$name]) && $tpl_vars[$name]['value'] === $pvar['value']) {
|
||||
$tpl_vars[$name]['scope'] = $pvar['scope'];
|
||||
if (isset($tpl_vars[ $name ]) && $tpl_vars[ $name ][ 'value' ] === $pvar[ 'value' ]) {
|
||||
$tpl_vars[ $name ][ 'scope' ] = $pvar[ 'scope' ];
|
||||
}
|
||||
}
|
||||
$tpl_vars = array_merge($parent->tpl_vars, $tpl_vars);
|
||||
|
||||
foreach ($parent->config_vars as $name => $pvar) {
|
||||
if (isset($config_vars[$name]) && $config_vars[$name]['value'] === $pvar['value']) {
|
||||
$config_vars[$name]['scope'] = $pvar['scope'];
|
||||
if (isset($config_vars[ $name ]) && $config_vars[ $name ][ 'value' ] === $pvar[ 'value' ]) {
|
||||
$config_vars[ $name ][ 'scope' ] = $pvar[ 'scope' ];
|
||||
}
|
||||
}
|
||||
$config_vars = array_merge($parent->config_vars, $config_vars);
|
||||
@@ -328,20 +328,20 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
|
||||
if (!array_key_exists($key, $tpl_vars)) {
|
||||
foreach ($var as $varkey => $varvalue) {
|
||||
if ($varkey == 'value') {
|
||||
$tpl_vars[$key][$varkey] = $varvalue;
|
||||
$tpl_vars[ $key ][ $varkey ] = $varvalue;
|
||||
} else {
|
||||
if ($varkey == 'nocache') {
|
||||
if ($varvalue == true) {
|
||||
$tpl_vars[$key][$varkey] = $varvalue;
|
||||
$tpl_vars[ $key ][ $varkey ] = $varvalue;
|
||||
}
|
||||
} else {
|
||||
if ($varkey != 'scope' || $varvalue !== 0) {
|
||||
$tpl_vars[$key]['attributes'][$varkey] = $varvalue;
|
||||
$tpl_vars[ $key ][ 'attributes' ][ $varkey ] = $varvalue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$tpl_vars[$key]['scope'] = 'Global';
|
||||
$tpl_vars[ $key ][ 'scope' ] = 'Global';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -364,19 +364,19 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
|
||||
$template->source->filepath;
|
||||
}
|
||||
$key = $template->source->uid;
|
||||
if (isset($this->template_data[$this->index][$key])) {
|
||||
if (isset($this->template_data[ $this->index ][ $key ])) {
|
||||
return $key;
|
||||
} else {
|
||||
if (isset($_is_stringy[$template->source->type])) {
|
||||
$this->template_data[$this->index][$key]['name'] =
|
||||
if (isset($_is_stringy[ $template->source->type ])) {
|
||||
$this->template_data[ $this->index ][ $key ][ 'name' ] =
|
||||
'\'' . substr($template->source->name, 0, 25) . '...\'';
|
||||
} else {
|
||||
$this->template_data[$this->index][$key]['name'] = $template->source->filepath;
|
||||
$this->template_data[ $this->index ][ $key ][ 'name' ] = $template->source->filepath;
|
||||
}
|
||||
$this->template_data[$this->index][$key]['compile_time'] = 0;
|
||||
$this->template_data[$this->index][$key]['render_time'] = 0;
|
||||
$this->template_data[$this->index][$key]['cache_time'] = 0;
|
||||
$this->template_data[$this->index][$key]['total_time'] = 0;
|
||||
$this->template_data[ $this->index ][ $key ][ 'compile_time' ] = 0;
|
||||
$this->template_data[ $this->index ][ $key ][ 'render_time' ] = 0;
|
||||
$this->template_data[ $this->index ][ $key ][ 'cache_time' ] = 0;
|
||||
$this->template_data[ $this->index ][ $key ][ 'total_time' ] = 0;
|
||||
|
||||
return $key;
|
||||
}
|
||||
@@ -393,7 +393,7 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
|
||||
if ($template->source->uid == '') {
|
||||
$template->source->filepath;
|
||||
}
|
||||
$this->ignore_uid[$template->source->uid] = true;
|
||||
$this->ignore_uid[ $template->source->uid ] = true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -403,8 +403,8 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
|
||||
*/
|
||||
public function debugUrl(Smarty $smarty)
|
||||
{
|
||||
if (isset($_SERVER['QUERY_STRING'])) {
|
||||
$_query_string = $_SERVER['QUERY_STRING'];
|
||||
if (isset($_SERVER[ 'QUERY_STRING' ])) {
|
||||
$_query_string = $_SERVER[ 'QUERY_STRING' ];
|
||||
} else {
|
||||
$_query_string = '';
|
||||
}
|
||||
@@ -422,7 +422,7 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
|
||||
$smarty->debugging = true;
|
||||
}
|
||||
} else {
|
||||
if (isset($_COOKIE['SMARTY_DEBUG'])) {
|
||||
if (isset($_COOKIE[ 'SMARTY_DEBUG' ])) {
|
||||
$smarty->debugging = true;
|
||||
}
|
||||
}
|
||||
|
@@ -77,13 +77,13 @@ class Smarty_Internal_Extension_Clear
|
||||
$_parts_count = count($_parts);
|
||||
// check name
|
||||
if (isset($resource_name)) {
|
||||
if ($_parts[$_parts_count - 1] != $_resourcename_parts) {
|
||||
if ($_parts[ $_parts_count - 1 ] != $_resourcename_parts) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
// check compile id
|
||||
if (isset($_compile_id) && (!isset($_parts[$_parts_count - 2 - $_compile_id_offset]) ||
|
||||
$_parts[$_parts_count - 2 - $_compile_id_offset] != $_compile_id)
|
||||
if (isset($_compile_id) && (!isset($_parts[ $_parts_count - 2 - $_compile_id_offset ]) ||
|
||||
$_parts[ $_parts_count - 2 - $_compile_id_offset ] != $_compile_id)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
@@ -96,7 +96,7 @@ class Smarty_Internal_Extension_Clear
|
||||
continue;
|
||||
}
|
||||
for ($i = 0; $i < $_cache_id_parts_count; $i ++) {
|
||||
if ($_parts[$i] != $_cache_id_parts[$i]) {
|
||||
if ($_parts[ $i ] != $_cache_id_parts[ $i ]) {
|
||||
continue 2;
|
||||
}
|
||||
}
|
||||
@@ -105,7 +105,7 @@ class Smarty_Internal_Extension_Clear
|
||||
if (isset($exp_time)) {
|
||||
if ($exp_time < 0) {
|
||||
preg_match('#\'cache_lifetime\' =>\s*(\d*)#', file_get_contents($_file), $match);
|
||||
if ($_time < (@filemtime($_file) + $match[1])) {
|
||||
if ($_time < (@filemtime($_file) + $match[ 1 ])) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
|
@@ -65,22 +65,22 @@ class Smarty_Internal_Extension_Handler
|
||||
if (!isset($smarty->ext->$name)) {
|
||||
$class = 'Smarty_Internal_Method_' . ucfirst($name);
|
||||
if (preg_match('/^(set|get)([A-Z].*)$/', $name, $match)) {
|
||||
if (!isset($this->_property_info[$prop = $match[2]])) {
|
||||
if (!isset($this->_property_info[ $prop = $match[ 2 ] ])) {
|
||||
// convert camel case to underscored name
|
||||
$this->resolvedProperties[$prop] = $pn = strtolower(join('_',
|
||||
preg_split('/([A-Z][^A-Z]*)/', $prop, - 1,
|
||||
PREG_SPLIT_NO_EMPTY |
|
||||
$this->resolvedProperties[ $prop ] = $pn = strtolower(join('_',
|
||||
preg_split('/([A-Z][^A-Z]*)/', $prop,
|
||||
- 1, PREG_SPLIT_NO_EMPTY |
|
||||
PREG_SPLIT_DELIM_CAPTURE)));
|
||||
$this->_property_info[$prop] = property_exists($data, $pn) ? 1 :
|
||||
$this->_property_info[ $prop ] = property_exists($data, $pn) ? 1 :
|
||||
($data->_objType == 2 && property_exists($smarty, $pn) ? 2 : 0);
|
||||
}
|
||||
if ($this->_property_info[$prop]) {
|
||||
$pn = $this->resolvedProperties[$prop];
|
||||
if ($match[1] == 'get') {
|
||||
return $this->_property_info[$prop] == 1 ? $data->$pn : $data->smarty->$pn;
|
||||
if ($this->_property_info[ $prop ]) {
|
||||
$pn = $this->resolvedProperties[ $prop ];
|
||||
if ($match[ 1 ] == 'get') {
|
||||
return $this->_property_info[ $prop ] == 1 ? $data->$pn : $data->smarty->$pn;
|
||||
} else {
|
||||
return $this->_property_info[$prop] == 1 ? $data->$pn = $args[0] :
|
||||
$data->smarty->$pn = $args[0];
|
||||
return $this->_property_info[ $prop ] == 1 ? $data->$pn = $args[ 0 ] :
|
||||
$data->smarty->$pn = $args[ 0 ];
|
||||
}
|
||||
} elseif (!class_exists($class)) {
|
||||
throw new SmartyException("property '$pn' does not exist.");
|
||||
@@ -93,7 +93,7 @@ class Smarty_Internal_Extension_Handler
|
||||
$callback = array($smarty->ext->$name, $name);
|
||||
}
|
||||
array_unshift($args, $data);
|
||||
if (isset($callback) && $callback[0]->objMap | $data->_objType) {
|
||||
if (isset($callback) && $callback[ 0 ]->objMap | $data->_objType) {
|
||||
return call_user_func_array($callback, $args);
|
||||
}
|
||||
return call_user_func_array(array(new Smarty_Internal_Undefined(), $name), $args);
|
||||
|
@@ -31,18 +31,19 @@ class Smarty_Internal_Method_AddAutoloadFilters extends Smarty_Internal_Method_S
|
||||
$smarty = isset($obj->smarty) ? $obj->smarty : $obj;
|
||||
if ($type !== null) {
|
||||
$this->_checkFilterType($type);
|
||||
if (!empty($smarty->autoload_filters[$type])) {
|
||||
$smarty->autoload_filters[$type] = array_merge($smarty->autoload_filters[$type], (array) $filters);
|
||||
if (!empty($smarty->autoload_filters[ $type ])) {
|
||||
$smarty->autoload_filters[ $type ] = array_merge($smarty->autoload_filters[ $type ], (array) $filters);
|
||||
} else {
|
||||
$smarty->autoload_filters[$type] = (array) $filters;
|
||||
$smarty->autoload_filters[ $type ] = (array) $filters;
|
||||
}
|
||||
} else {
|
||||
foreach ((array) $filters as $type => $value) {
|
||||
$this->_checkFilterType($type);
|
||||
if (!empty($smarty->autoload_filters[$type])) {
|
||||
$smarty->autoload_filters[$type] = array_merge($smarty->autoload_filters[$type], (array) $value);
|
||||
if (!empty($smarty->autoload_filters[ $type ])) {
|
||||
$smarty->autoload_filters[ $type ] =
|
||||
array_merge($smarty->autoload_filters[ $type ], (array) $value);
|
||||
} else {
|
||||
$smarty->autoload_filters[$type] = (array) $value;
|
||||
$smarty->autoload_filters[ $type ] = (array) $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -44,25 +44,25 @@ class Smarty_Internal_Method_Append
|
||||
}
|
||||
} else {
|
||||
if ($tpl_var != '' && isset($value)) {
|
||||
if (!isset($data->tpl_vars[$tpl_var])) {
|
||||
if (!isset($data->tpl_vars[ $tpl_var ])) {
|
||||
$tpl_var_inst = $data->ext->getTemplateVars->_getVariable($data, $tpl_var, null, true, false);
|
||||
if ($tpl_var_inst instanceof Smarty_Undefined_Variable) {
|
||||
$data->tpl_vars[$tpl_var] = new Smarty_Variable(null, $nocache);
|
||||
$data->tpl_vars[ $tpl_var ] = new Smarty_Variable(null, $nocache);
|
||||
} else {
|
||||
$data->tpl_vars[$tpl_var] = clone $tpl_var_inst;
|
||||
$data->tpl_vars[ $tpl_var ] = clone $tpl_var_inst;
|
||||
}
|
||||
}
|
||||
if (!(is_array($data->tpl_vars[$tpl_var]->value) ||
|
||||
$data->tpl_vars[$tpl_var]->value instanceof ArrayAccess)
|
||||
if (!(is_array($data->tpl_vars[ $tpl_var ]->value) ||
|
||||
$data->tpl_vars[ $tpl_var ]->value instanceof ArrayAccess)
|
||||
) {
|
||||
settype($data->tpl_vars[$tpl_var]->value, 'array');
|
||||
settype($data->tpl_vars[ $tpl_var ]->value, 'array');
|
||||
}
|
||||
if ($merge && is_array($value)) {
|
||||
foreach ($value as $_mkey => $_mval) {
|
||||
$data->tpl_vars[$tpl_var]->value[$_mkey] = $_mval;
|
||||
$data->tpl_vars[ $tpl_var ]->value[ $_mkey ] = $_mval;
|
||||
}
|
||||
} else {
|
||||
$data->tpl_vars[$tpl_var]->value[] = $value;
|
||||
$data->tpl_vars[ $tpl_var ]->value[] = $value;
|
||||
}
|
||||
}
|
||||
if ($data->_objType == 2 && $data->scope) {
|
||||
|
@@ -28,18 +28,18 @@ class Smarty_Internal_Method_AppendByRef
|
||||
public static function appendByRef(Smarty_Internal_Data $data, $tpl_var, &$value, $merge = false)
|
||||
{
|
||||
if ($tpl_var != '' && isset($value)) {
|
||||
if (!isset($data->tpl_vars[$tpl_var])) {
|
||||
$data->tpl_vars[$tpl_var] = new Smarty_Variable();
|
||||
if (!isset($data->tpl_vars[ $tpl_var ])) {
|
||||
$data->tpl_vars[ $tpl_var ] = new Smarty_Variable();
|
||||
}
|
||||
if (!is_array($data->tpl_vars[$tpl_var]->value)) {
|
||||
settype($data->tpl_vars[$tpl_var]->value, 'array');
|
||||
if (!is_array($data->tpl_vars[ $tpl_var ]->value)) {
|
||||
settype($data->tpl_vars[ $tpl_var ]->value, 'array');
|
||||
}
|
||||
if ($merge && is_array($value)) {
|
||||
foreach ($value as $_key => $_val) {
|
||||
$data->tpl_vars[$tpl_var]->value[$_key] = &$value[$_key];
|
||||
$data->tpl_vars[ $tpl_var ]->value[ $_key ] = &$value[ $_key ];
|
||||
}
|
||||
} else {
|
||||
$data->tpl_vars[$tpl_var]->value[] = &$value;
|
||||
$data->tpl_vars[ $tpl_var ]->value[] = &$value;
|
||||
}
|
||||
if ($data->_objType == 2 && $data->scope) {
|
||||
$data->ext->_updateScope->updateScope($data, $tpl_var);
|
||||
|
@@ -25,8 +25,8 @@ class Smarty_Internal_Method_AssignByRef
|
||||
public function assignByRef(Smarty_Internal_Data $data, $tpl_var, &$value, $nocache)
|
||||
{
|
||||
if ($tpl_var != '') {
|
||||
$data->tpl_vars[$tpl_var] = new Smarty_Variable(null, $nocache);
|
||||
$data->tpl_vars[$tpl_var]->value = &$value;
|
||||
$data->tpl_vars[ $tpl_var ] = new Smarty_Variable(null, $nocache);
|
||||
$data->tpl_vars[ $tpl_var ]->value = &$value;
|
||||
if ($data->_objType == 2 && $data->scope) {
|
||||
$data->ext->_updateScope->updateScope($data, $tpl_var);
|
||||
}
|
||||
|
@@ -31,10 +31,10 @@ class Smarty_Internal_Method_AssignGlobal
|
||||
public function assignGlobal(Smarty_Internal_Data $data, $varName, $value = null, $nocache = false)
|
||||
{
|
||||
if ($varName != '') {
|
||||
Smarty::$global_tpl_vars[$varName] = new Smarty_Variable($value, $nocache);
|
||||
Smarty::$global_tpl_vars[ $varName ] = new Smarty_Variable($value, $nocache);
|
||||
$ptr = $data;
|
||||
while ($ptr->_objType == 2) {
|
||||
$ptr->tpl_vars[$varName] = clone Smarty::$global_tpl_vars[$varName];
|
||||
$ptr->tpl_vars[ $varName ] = clone Smarty::$global_tpl_vars[ $varName ];
|
||||
$ptr = $ptr->parent;
|
||||
}
|
||||
}
|
||||
|
@@ -33,10 +33,10 @@ class Smarty_Internal_Method_ClearAssign
|
||||
{
|
||||
if (is_array($tpl_var)) {
|
||||
foreach ($tpl_var as $curr_var) {
|
||||
unset($data->tpl_vars[$curr_var]);
|
||||
unset($data->tpl_vars[ $curr_var ]);
|
||||
}
|
||||
} else {
|
||||
unset($data->tpl_vars[$tpl_var]);
|
||||
unset($data->tpl_vars[ $tpl_var ]);
|
||||
}
|
||||
|
||||
return $data;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user