Update PSR-2

This commit is contained in:
Sławomir Kaleta
2018-06-12 09:58:15 +02:00
parent cc4d8fa1a0
commit 2404095783
190 changed files with 3833 additions and 3119 deletions

View File

@@ -2,7 +2,9 @@
"name": "smarty/smarty",
"type": "library",
"description": "Smarty - the compiling PHP template engine",
"keywords": ["templating"],
"keywords": [
"templating"
],
"homepage": "http://www.smarty.net",
"license": "LGPL-3.0",
"authors": [
@@ -28,12 +30,13 @@
"php": ">=5.2"
},
"autoload": {
"files": ["libs/bootstrap.php"]
"files": [
"libs/bootstrap.php"
]
},
"extra": {
"branch-alias": {
"dev-master": "3.1.x-dev"
}
}
}

View File

@@ -17,11 +17,15 @@ $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")));
$smarty->assign(
"contacts", array(array("phone" => "1", "fax" => "2", "cell" => "3"),
array("phone" => "555-4444", "fax" => "555-3333", "cell" => "760-1234"))
);
$smarty->assign("option_values", array("NY", "NE", "KS", "IA", "OK", "TX"));
$smarty->assign("option_output", array("New York", "Nebraska", "Kansas", "Iowa", "Oklahoma", "Texas"));

View File

@@ -43,8 +43,10 @@ class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom
}
$this->fetch = $this->db->prepare('SELECT modified, content FROM output_cache WHERE id = :id');
$this->fetchTimestamp = $this->db->prepare('SELECT modified FROM output_cache WHERE id = :id');
$this->save = $this->db->prepare('REPLACE INTO output_cache (id, name, cache_id, compile_id, content)
VALUES (:id, :name, :cache_id, :compile_id, :content)');
$this->save = $this->db->prepare(
'REPLACE INTO output_cache (id, name, cache_id, compile_id, content)
VALUES (:id, :name, :cache_id, :compile_id, :content)'
);
}
/**
@@ -108,8 +110,10 @@ 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();
}

View File

@@ -54,8 +54,8 @@ class Smarty_Autoloader
if (!defined('SMARTY_SPL_AUTOLOAD')) {
define('SMARTY_SPL_AUTOLOAD', 0);
}
if (SMARTY_SPL_AUTOLOAD &&
set_include_path(get_include_path() . PATH_SEPARATOR . SMARTY_SYSPLUGINS_DIR) !== false
if (SMARTY_SPL_AUTOLOAD
&& set_include_path(get_include_path() . PATH_SEPARATOR . SMARTY_SYSPLUGINS_DIR) !== false
) {
$registeredAutoLoadFunctions = spl_autoload_functions();
if (!isset($registeredAutoLoadFunctions[ 'spl_autoload' ])) {

View File

@@ -1008,8 +1008,8 @@ class Smarty extends Smarty_Internal_TemplateBase
$cache_id = null,
$compile_id = null,
$caching = null,
Smarty_Internal_Template $template = null)
{
Smarty_Internal_Template $template = null
) {
$template_name = (strpos($template_name, ':') === false) ? "{$this->default_resource_type}:{$template_name}" :
$template_name;
$cache_id = $cache_id === null ? $this->cache_id : $cache_id;
@@ -1036,7 +1036,8 @@ class Smarty extends Smarty_Internal_TemplateBase
* @param string $path file path
* @param bool $realpath if true - convert to absolute
* false - convert to relative
* null - keep as it is but remove /./ /../
* null - keep as it is but
* remove /./ /../
*
* @return string
*/
@@ -1045,9 +1046,11 @@ class Smarty extends Smarty_Internal_TemplateBase
$nds = array('/' => '\\', '\\' => '/');
// normalize DIRECTORY_SEPARATOR
//$path = str_replace(array($nds[DIRECTORY_SEPARATOR], DIRECTORY_SEPARATOR . '.' . DIRECTORY_SEPARATOR), DIRECTORY_SEPARATOR, $path);
preg_match('%^(?<root>(?:[[:alpha:]]:[\\\\]|/|[\\\\]{2}[[:alpha:]]+|[[:print:]]{2,}:[/]{2}|[\\\\])?)(?<path>(.*))$%u',
preg_match(
'%^(?<root>(?:[[:alpha:]]:[\\\\]|/|[\\\\]{2}[[:alpha:]]+|[[:print:]]{2,}:[/]{2}|[\\\\])?)(?<path>(.*))$%u',
$path,
$parts);
$parts
);
$path = $parts[ 'path' ];
if ($parts[ 'root' ] === '\\') {
$parts[ 'root' ] = substr(getcwd(), 0, 2) . $parts[ 'root' ];
@@ -1059,7 +1062,8 @@ class Smarty extends Smarty_Internal_TemplateBase
do {
$path = preg_replace(
array('#[\\\\/]{2}#', '#[\\\\/][.][\\\\/]#', '#[\\\\/]([^\\\\/.]+)[\\\\/][.][.][\\\\/]#'),
DIRECTORY_SEPARATOR, $path, -1, $count);
DIRECTORY_SEPARATOR, $path, -1, $count
);
} while($count > 0);
return $realpath !== false ? $parts[ 'root' ] . $path : str_ireplace(getcwd(), '.', $parts[ 'root' ] . $path);
}
@@ -1270,7 +1274,9 @@ class Smarty extends Smarty_Internal_TemplateBase
return null;
} else {
trigger_error('Undefined property: ' . get_class($this) . '::$' . $name, E_USER_NOTICE);
}}}
}
}
}
return null;
}
@@ -1297,7 +1303,8 @@ class Smarty extends Smarty_Internal_TemplateBase
} else {
trigger_error('Undefined property: ' . get_class($this) . '::$' . $name, E_USER_NOTICE);
}
}}
}
}
}
/**
@@ -1320,7 +1327,6 @@ class Smarty extends Smarty_Internal_TemplateBase
* Normalize template_dir or config_dir
*
* @param bool $isConfig true for config_dir
*
*/
private function _normalizeTemplateConfig($isConfig)
{

View File

@@ -28,7 +28,7 @@
/**
* @ignore
*/
require_once(dirname(__FILE__) . '/Smarty.class.php');
require_once dirname(__FILE__) . '/Smarty.class.php';
/**
* Smarty Backward Compatibility Wrapper Class
@@ -53,7 +53,6 @@ class SmartyBC extends Smarty
/**
* Initialize new SmartyBC object
*
*/
public function __construct()
{
@@ -131,8 +130,8 @@ class SmartyBC extends Smarty
* @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())
{
$block_methods = array()
) {
settype($allowed, 'array');
settype($smarty_args, 'boolean');
$this->registerObject($object, $object_impl, $allowed, $smarty_args, $block_methods);

View File

@@ -12,6 +12,6 @@
* Load and register Smarty Autoloader
*/
if (!class_exists('Smarty_Autoloader')) {
require dirname(__FILE__) . '/Autoloader.php';
include dirname(__FILE__) . '/Autoloader.php';
}
Smarty_Autoloader::register(true);

View File

@@ -20,7 +20,6 @@
* - indent_char - string (" ")
* - wrap_boundary - boolean (true)
*
*
* @link http://www.smarty.net/manual/en/language.function.textformat.php {textformat}
* (Smarty online manual)
*
@@ -39,8 +38,10 @@ function smarty_block_textformat($params, $content, Smarty_Internal_Template $te
return;
}
if (Smarty::$_MBSTRING) {
$template->_checkPlugins(array(array('function' => 'smarty_modifier_mb_wordwrap',
'file' => SMARTY_PLUGINS_DIR . 'modifier.mb_wordwrap.php')));
$template->_checkPlugins(
array(array('function' => 'smarty_modifier_mb_wordwrap',
'file' => SMARTY_PLUGINS_DIR . 'modifier.mb_wordwrap.php'))
);
}
$style = null;
@@ -88,10 +89,12 @@ function smarty_block_textformat($params, $content, Smarty_Internal_Template $te
}
// convert mult. spaces & special chars to single space
$_paragraph =
preg_replace(array('!\s+!' . Smarty::$_UTF8_MODIFIER,
preg_replace(
array('!\s+!' . Smarty::$_UTF8_MODIFIER,
'!(^\s+)|(\s+$)!' . Smarty::$_UTF8_MODIFIER),
array(' ',
''), $_paragraph);
''), $_paragraph
);
// indent first line
if ($indent_first > 0) {
$_paragraph = str_repeat($indent_char, $indent_first) . $_paragraph;

View File

@@ -29,7 +29,6 @@
* {cycle name=row values="one,two,three" reset=true}
* {cycle name=row}
*
*
* @link http://www.smarty.net/manual/en/language.function.cycle.php {cycle}
* (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com>

View File

@@ -29,7 +29,6 @@
* - assign (optional) - assign the output as an array to this variable
* - escape (optional) - escape the content (not value), defaults to true
*
*
* @link http://www.smarty.net/manual/en/language.function.html.checkboxes.php {html_checkboxes}
* (Smarty online manual)
* @author Christopher Kvarme <christopher.kvarme@flashjab.com>
@@ -45,8 +44,10 @@
*/
function smarty_function_html_checkboxes($params, Smarty_Internal_Template $template)
{
$template->_checkPlugins(array(array('function' => 'smarty_function_escape_special_chars',
'file' => SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php')));
$template->_checkPlugins(
array(array('function' => 'smarty_function_escape_special_chars',
'file' => SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'))
);
$name = 'checkbox';
$values = null;
@@ -91,8 +92,10 @@ function smarty_function_html_checkboxes($params, Smarty_Internal_Template $temp
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 {
@@ -104,8 +107,10 @@ function smarty_function_html_checkboxes($params, Smarty_Internal_Template $temp
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);
@@ -113,8 +118,10 @@ function smarty_function_html_checkboxes($params, Smarty_Internal_Template $temp
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;
@@ -128,8 +135,10 @@ function smarty_function_html_checkboxes($params, Smarty_Internal_Template $temp
case 'readonly':
if (!empty($params[ 'strict' ])) {
if (!is_scalar($_val)) {
trigger_error("html_options: {$_key} attribute must be a scalar, only boolean true or string '{$_key}' will actually add the attribute",
E_USER_NOTICE);
trigger_error(
"html_options: {$_key} attribute must be a scalar, only boolean true or string '{$_key}' will actually add the attribute",
E_USER_NOTICE
);
}
if ($_val === true || $_val === $_key) {
@@ -159,15 +168,19 @@ function smarty_function_html_checkboxes($params, Smarty_Internal_Template $temp
if (isset($options)) {
foreach ($options as $_key => $_val) {
$_html_result[] =
smarty_function_html_checkboxes_output($name, $_key, $_val, $selected, $extra, $separator, $labels,
$label_ids, $escape);
smarty_function_html_checkboxes_output(
$name, $_key, $_val, $selected, $extra, $separator, $labels,
$label_ids, $escape
);
}
} else {
foreach ($values as $_i => $_key) {
$_val = isset($output[ $_i ]) ? $output[ $_i ] : '';
$_html_result[] =
smarty_function_html_checkboxes_output($name, $_key, $_val, $selected, $extra, $separator, $labels,
$label_ids, $escape);
smarty_function_html_checkboxes_output(
$name, $_key, $_val, $selected, $extra, $separator, $labels,
$label_ids, $escape
);
}
}
@@ -191,16 +204,18 @@ function smarty_function_html_checkboxes($params, Smarty_Internal_Template $temp
* @return string
*/
function smarty_function_html_checkboxes_output($name, $value, $output, $selected, $extra, $separator, $labels,
$label_ids, $escape = true)
{
$label_ids, $escape = true
) {
$_output = '';
if (is_object($value)) {
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 '';
}
@@ -212,8 +227,10 @@ 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 '';
}
@@ -223,8 +240,12 @@ 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>';

View File

@@ -22,7 +22,6 @@
* - basedir - (optional) - base directory for absolute paths, default is environment variable DOCUMENT_ROOT
* - path_prefix - prefix for path output (optional, default empty)
*
*
* @link http://www.smarty.net/manual/en/language.function.html.image.php {html_image}
* (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com>
@@ -38,8 +37,10 @@
*/
function smarty_function_html_image($params, Smarty_Internal_Template $template)
{
$template->_checkPlugins(array(array('function' => 'smarty_function_escape_special_chars',
'file' => SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php')));
$template->_checkPlugins(
array(array('function' => 'smarty_function_escape_special_chars',
'file' => SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'))
);
$alt = '';
$file = '';
@@ -65,7 +66,7 @@ function smarty_function_html_image($params, Smarty_Internal_Template $template)
if (!is_array($_val)) {
$$_key = smarty_function_escape_special_chars($_val);
} else {
throw new SmartyException ("html_image: extra attribute '{$_key}' cannot be an array", E_USER_NOTICE);
throw new SmartyException("html_image: extra attribute '{$_key}' cannot be an array", E_USER_NOTICE);
}
break;
@@ -79,7 +80,7 @@ function smarty_function_html_image($params, Smarty_Internal_Template $template)
if (!is_array($_val)) {
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
} else {
throw new SmartyException ("html_image: extra attribute '{$_key}' cannot be an array", E_USER_NOTICE);
throw new SmartyException("html_image: extra attribute '{$_key}' cannot be an array", E_USER_NOTICE);
}
break;
}

View File

@@ -21,7 +21,6 @@
* - id (optional) - string default not set
* - class (optional) - string default not set
*
*
* @link http://www.smarty.net/manual/en/language.function.html.options.php {html_image}
* (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com>
@@ -37,8 +36,10 @@
*/
function smarty_function_html_options($params, Smarty_Internal_Template $template)
{
$template->_checkPlugins(array(array('function' => 'smarty_function_escape_special_chars',
'file' => SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php')));
$template->_checkPlugins(
array(array('function' => 'smarty_function_escape_special_chars',
'file' => SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'))
);
$name = null;
$values = null;
@@ -75,8 +76,10 @@ function smarty_function_html_options($params, Smarty_Internal_Template $templat
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 {
@@ -88,8 +91,10 @@ function smarty_function_html_options($params, Smarty_Internal_Template $templat
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);
@@ -103,8 +108,10 @@ function smarty_function_html_options($params, Smarty_Internal_Template $templat
case 'readonly':
if (!empty($params[ 'strict' ])) {
if (!is_scalar($_val)) {
trigger_error("html_options: {$_key} attribute must be a scalar, only boolean true or string '{$_key}' will actually add the attribute",
E_USER_NOTICE);
trigger_error(
"html_options: {$_key} attribute must be a scalar, only boolean true or string '{$_key}' will actually add the attribute",
E_USER_NOTICE
);
}
if ($_val === true || $_val === $_key) {
@@ -183,8 +190,10 @@ 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 '';
}
@@ -196,8 +205,10 @@ function smarty_function_html_options_optoutput($key, $value, $selected, $id, $c
} else {
$_idx = 0;
$_html_result =
smarty_function_html_options_optgroup($key, $value, $selected, !empty($id) ? ($id . '-' . $idx) : null,
$class, $_idx);
smarty_function_html_options_optgroup(
$key, $value, $selected, !empty($id) ? ($id . '-' . $idx) : null,
$class, $_idx
);
$idx ++;
}

View File

@@ -29,7 +29,6 @@
* {html_radios values=$ids name='box' separator='<br>' output=$names}
* {html_radios values=$ids checked=$checked separator='<br>' output=$names}
*
*
* @link http://smarty.php.net/manual/en/language.function.html.radios.php {html_radios}
* (Smarty online manual)
* @author Christopher Kvarme <christopher.kvarme@flashjab.com>
@@ -45,8 +44,10 @@
*/
function smarty_function_html_radios($params, Smarty_Internal_Template $template)
{
$template->_checkPlugins(array(array('function' => 'smarty_function_escape_special_chars',
'file' => SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php')));
$template->_checkPlugins(
array(array('function' => 'smarty_function_escape_special_chars',
'file' => SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'))
);
$name = 'radio';
$values = null;
@@ -74,8 +75,10 @@ function smarty_function_html_radios($params, Smarty_Internal_Template $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;
@@ -98,8 +101,10 @@ function smarty_function_html_radios($params, Smarty_Internal_Template $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;
@@ -113,8 +118,10 @@ function smarty_function_html_radios($params, Smarty_Internal_Template $template
case 'readonly':
if (!empty($params[ 'strict' ])) {
if (!is_scalar($_val)) {
trigger_error("html_options: {$_key} attribute must be a scalar, only boolean true or string '$_key' will actually add the attribute",
E_USER_NOTICE);
trigger_error(
"html_options: {$_key} attribute must be a scalar, only boolean true or string '$_key' will actually add the attribute",
E_USER_NOTICE
);
}
if ($_val === true || $_val === $_key) {
@@ -146,15 +153,19 @@ function smarty_function_html_radios($params, Smarty_Internal_Template $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);
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);
smarty_function_html_radios_output(
$name, $_key, $_val, $selected, $extra, $separator, $labels,
$label_ids, $escape
);
}
}
@@ -178,16 +189,18 @@ function smarty_function_html_radios($params, Smarty_Internal_Template $template
* @return string
*/
function smarty_function_html_radios_output($name, $value, $output, $selected, $extra, $separator, $labels, $label_ids,
$escape)
{
$escape
) {
$_output = '';
if (is_object($value)) {
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 '';
}
@@ -199,8 +212,10 @@ 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 '';
}
@@ -210,8 +225,12 @@ 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>';

View File

@@ -28,7 +28,6 @@
* - 2.0 complete rewrite for performance,
* added attributes month_names, *_id
*
*
* @link http://www.smarty.net/manual/en/language.function.html.select.date.php {html_select_date}
* (Smarty online manual)
* @version 2.0
@@ -45,8 +44,10 @@
*/
function smarty_function_html_select_date($params, Smarty_Internal_Template $template)
{
$template->_checkPlugins(array(array('function' => 'smarty_function_escape_special_chars',
'file' => SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php')));
$template->_checkPlugins(
array(array('function' => 'smarty_function_escape_special_chars',
'file' => SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'))
);
// generate timestamps used for month names only
static $_month_timestamps = null;
static $_current_year = null;
@@ -111,8 +112,10 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
switch ($_key) {
case 'time':
if (!is_array($_value) && $_value !== null) {
$template->_checkPlugins(array(array('function' => 'smarty_make_timestamp',
'file' => SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php')));
$template->_checkPlugins(
array(array('function' => 'smarty_make_timestamp',
'file' => SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php'))
);
$time = smarty_make_timestamp($_value);
}
break;
@@ -250,10 +253,12 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
} else {
$_html_years = '<select name="' . $_name . '"';
if ($year_id !== null || $all_id !== null) {
$_html_years .= ' id="' . smarty_function_escape_special_chars($year_id !== null ?
$_html_years .= ' id="' . smarty_function_escape_special_chars(
$year_id !== null ?
($year_id ? $year_id : $_name) :
($all_id ? ($all_id . $_name) :
$_name)) . '"';
$_name)
) . '"';
}
if ($year_size) {
$_html_years .= ' size="' . $year_size . '"';
@@ -288,10 +293,12 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
$_html_months = '<select name="' . $_name . '"';
if ($month_id !== null || $all_id !== null) {
$_html_months .= ' id="' . smarty_function_escape_special_chars($month_id !== null ?
$_html_months .= ' id="' . smarty_function_escape_special_chars(
$month_id !== null ?
($month_id ? $month_id : $_name) :
($all_id ? ($all_id . $_name) :
$_name)) . '"';
$_name)
) . '"';
}
if ($month_size) {
$_html_months .= ' size="' . $month_size . '"';
@@ -329,8 +336,10 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
$_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)) . '"';
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 . '"';

View File

@@ -26,8 +26,10 @@
*/
function smarty_function_html_select_time($params, Smarty_Internal_Template $template)
{
$template->_checkPlugins(array(array('function' => 'smarty_function_escape_special_chars',
'file' => SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php')));
$template->_checkPlugins(
array(array('function' => 'smarty_function_escape_special_chars',
'file' => SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'))
);
$prefix = 'Time_';
$field_array = null;
$field_separator = "\n";
@@ -78,8 +80,10 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
switch ($_key) {
case 'time':
if (!is_array($_value) && $_value !== null) {
$template->_checkPlugins(array(array('function' => 'smarty_make_timestamp',
'file' => SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php')));
$template->_checkPlugins(
array(array('function' => 'smarty_make_timestamp',
'file' => SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php'))
);
$time = smarty_make_timestamp($_value);
}
break;
@@ -203,8 +207,10 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
$_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)) . '"';
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 . '"';
@@ -249,10 +255,12 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
$_html_minutes = '<select name="' . $_name . '"';
if ($minute_id !== null || $all_id !== null) {
$_html_minutes .= ' id="' . smarty_function_escape_special_chars($minute_id !== null ?
$_html_minutes .= ' id="' . smarty_function_escape_special_chars(
$minute_id !== null ?
($minute_id ? $minute_id : $_name) :
($all_id ? ($all_id . $_name) :
$_name)) . '"';
$_name)
) . '"';
}
if ($minute_size) {
$_html_minutes .= ' size="' . $minute_size . '"';
@@ -290,10 +298,12 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
$_html_seconds = '<select name="' . $_name . '"';
if ($second_id !== null || $all_id !== null) {
$_html_seconds .= ' id="' . smarty_function_escape_special_chars($second_id !== null ?
$_html_seconds .= ' id="' . smarty_function_escape_special_chars(
$second_id !== null ?
($second_id ? $second_id : $_name) :
($all_id ? ($all_id . $_name) :
$_name)) . '"';
$_name)
) . '"';
}
if ($second_size) {
$_html_seconds .= ' size="' . $second_size . '"';
@@ -331,11 +341,13 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
$_html_meridian = '<select name="' . $_name . '"';
if ($meridian_id !== null || $all_id !== null) {
$_html_meridian .= ' id="' . smarty_function_escape_special_chars($meridian_id !== null ?
$_html_meridian .= ' id="' . smarty_function_escape_special_chars(
$meridian_id !== null ?
($meridian_id ? $meridian_id :
$_name) :
($all_id ? ($all_id . $_name) :
$_name)) . '"';
$_name)
) . '"';
}
if ($meridian_size) {
$_html_meridian .= ' size="' . $meridian_size . '"';

View File

@@ -35,7 +35,6 @@
* {table loop=$data cols=4 tr_attr='"bgcolor=red"'}
* {table loop=$data cols="first,second,third" tr_attr=$colors}
*
*
* @author Monte Ohrt <monte at ohrt dot com>
* @author credit to Messju Mohr <messju at lammfellpuschen dot de>
* @author credit to boots <boots dot smarty at yahoo dot com>

View File

@@ -37,7 +37,6 @@
* {mailto address="me@domain.com" cc="you@domain.com,they@domain.com"}
* {mailto address="me@domain.com" extra='class="mailto"'}
*
*
* @link http://www.smarty.net/manual/en/language.function.mailto.php {mailto}
* (Smarty online manual)
* @version 1.2
@@ -97,8 +96,10 @@ function smarty_function_mailto($params)
$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);
trigger_error(
"mailto: 'encode' parameter must be none, javascript, javascript_charcode or hex",
E_USER_WARNING
);
return;
}

View File

@@ -29,23 +29,32 @@ 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)) {
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 ]));
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);
preg_replace_callback(
"!((^|\s)['\"])(\w)!" . Smarty::$_UTF8_MODIFIER, 'smarty_mod_cap_mbconvert2_cb',
$upper_string
);
return $upper_string;
}
@@ -55,20 +64,27 @@ function smarty_modifier_capitalize($string, $uc_digits = false, $lc_rest = fals
}
// uppercase (including hyphenated words)
$upper_string =
preg_replace_callback("!(^|[^\p{L}'])([\p{Ll}])!S" . Smarty::$_UTF8_MODIFIER, 'smarty_mod_cap_ucfirst_cb',
$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)) {
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;
}

View File

@@ -38,7 +38,7 @@ function smarty_modifier_date_format($string, $format = null, $default_date = ''
static $is_loaded = false;
if (!$is_loaded) {
if (!is_callable('smarty_make_timestamp')) {
require_once(SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php');
include_once SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php';
}
$is_loaded = true;
}

View File

@@ -48,9 +48,11 @@ 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%%%',
$string = str_replace(
array('%%%SMARTY_START%%%',
'%%%SMARTY_END%%%'), array('&',
';'), $string);
';'), $string
);
return $string;
}
@@ -71,9 +73,11 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
$string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string);
$string = htmlspecialchars($string, ENT_QUOTES, $char_set);
$string =
str_replace(array('%%%SMARTY_START%%%',
str_replace(
array('%%%SMARTY_START%%%',
'%%%SMARTY_END%%%'), array('&',
';'), $string);
';'), $string
);
return $string;
}
@@ -92,9 +96,11 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
} else {
$string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string);
$string = htmlentities($string, ENT_QUOTES, $char_set);
$string = str_replace(array('%%%SMARTY_START%%%',
$string = str_replace(
array('%%%SMARTY_START%%%',
'%%%SMARTY_END%%%'), array('&',
';'), $string);
';'), $string
);
return $string;
}
@@ -126,7 +132,7 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
if (Smarty::$_MBSTRING) {
if (!$is_loaded_1) {
if (!is_callable('smarty_mb_to_unicode')) {
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php');
include_once SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php';
}
$is_loaded_1 = true;
}
@@ -150,7 +156,7 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
if (Smarty::$_MBSTRING) {
if (!$is_loaded_1) {
if (!is_callable('smarty_mb_to_unicode')) {
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php');
include_once SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php';
}
$is_loaded_1 = true;
}
@@ -171,29 +177,35 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
case 'javascript':
// escape quotes and backslashes, newlines, etc.
return strtr($string, array('\\' => '\\\\',
return strtr(
$string, array('\\' => '\\\\',
"'" => "\\'",
'"' => '\\"',
"\r" => '\\r',
"\n" => '\\n',
'</' => '<\/'));
'</' => '<\/')
);
case 'mail':
if (Smarty::$_MBSTRING) {
if (!$is_loaded_2) {
if (!is_callable('smarty_mb_str_replace')) {
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php');
include_once SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php';
}
$is_loaded_2 = true;
}
return smarty_mb_str_replace(array('@',
return smarty_mb_str_replace(
array('@',
'.'), array(' [AT] ',
' [DOT] '), $string);
' [DOT] '), $string
);
}
// no MBString fallback
return str_replace(array('@',
return str_replace(
array('@',
'.'), array(' [AT] ',
' [DOT] '), $string);
' [DOT] '), $string
);
case 'nonstd':
// escape non-standard chars, such as ms document quotes
@@ -201,7 +213,7 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
if (Smarty::$_MBSTRING) {
if (!$is_loaded_1) {
if (!is_callable('smarty_mb_to_unicode')) {
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php');
include_once SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php';
}
$is_loaded_1 = true;
}

View File

@@ -11,7 +11,6 @@
* Name: mb_wordwrap
* Purpose: Wrap a string to a given number of characters
*
* @link http://php.net/manual/en/function.wordwrap.php for similarity
*
* @param string $str the string to wrap
@@ -36,10 +35,12 @@ function smarty_modifier_mb_wordwrap($str, $width = 75, $break = "\n", $cut = fa
$_tokens = array($_token);
if ($token_length > $width) {
if ($cut) {
$_tokens = preg_split('!(.{' . $width . '})!S' . Smarty::$_UTF8_MODIFIER,
$_tokens = preg_split(
'!(.{' . $width . '})!S' . Smarty::$_UTF8_MODIFIER,
$_token,
-1,
PREG_SPLIT_NO_EMPTY + PREG_SPLIT_DELIM_CAPTURE);
PREG_SPLIT_NO_EMPTY + PREG_SPLIT_DELIM_CAPTURE
);
}
}

View File

@@ -28,7 +28,7 @@ function smarty_modifier_replace($string, $search, $replace)
if (Smarty::$_MBSTRING) {
if (!$is_loaded) {
if (!is_callable('smarty_mb_str_replace')) {
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php');
include_once SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php';
}
$is_loaded = true;
}

View File

@@ -35,8 +35,10 @@ 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;

View File

@@ -24,8 +24,10 @@ function smarty_modifiercompiler_escape($params, Smarty_Internal_TemplateCompile
{
static $_double_encode = null;
static $is_loaded = false;
$compiler->template->_checkPlugins(array(array('function' => 'smarty_literal_compiler_param',
'file' => SMARTY_PLUGINS_DIR . 'shared.literal_compiler_param.php')));
$compiler->template->_checkPlugins(
array(array('function' => 'smarty_literal_compiler_param',
'file' => SMARTY_PLUGINS_DIR . 'shared.literal_compiler_param.php'))
);
if ($_double_encode === null) {
$_double_encode = version_compare(PHP_VERSION, '5.2.3', '>=');
}

View File

@@ -33,7 +33,7 @@ function smarty_modifiercompiler_wordwrap($params, Smarty_Internal_TemplateCompi
}
$function = 'wordwrap';
if (Smarty::$_MBSTRING) {
$function = $compiler->getPlugin('mb_wordwrap','modifier');
$function = $compiler->getPlugin('mb_wordwrap', 'modifier');
}
return $function . '(' . $params[ 0 ] . ',' . $params[ 1 ] . ',' . $params[ 2 ] . ',' . $params[ 3 ] . ')';
}

View File

@@ -27,8 +27,11 @@ function smarty_outputfilter_trimwhitespace($source)
$source = preg_replace('/\015\012|\015|\012/', "\n", $source);
// capture Internet Explorer and KnockoutJS Conditional Comments
if (preg_match_all('#<!--((\[[^\]]+\]>.*?<!\[[^\]]+\])|(\s*/?ko\s+.+))-->#is', $source, $matches,
PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) {
if (preg_match_all(
'#<!--((\[[^\]]+\]>.*?<!\[[^\]]+\])|(\s*/?ko\s+.+))-->#is', $source, $matches,
PREG_OFFSET_CAPTURE | PREG_SET_ORDER
)
) {
foreach ($matches as $match) {
$store[] = $match[ 0 ][ 0 ];
$_length = strlen($match[ 0 ][ 0 ]);
@@ -46,8 +49,11 @@ 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 ]);

View File

@@ -25,8 +25,10 @@ function smarty_literal_compiler_param($params, $index, $default = null)
}
// 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');
throw new SmartyException(
'$param[' . $index .
'] is not a literal and is thus not evaluatable at compile time'
);
}
$t = null;

View File

@@ -21,14 +21,16 @@ 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;

View File

@@ -51,7 +51,8 @@ abstract class Smarty_CacheResource
* @return boolean true or false if the cached content does not exist
*/
abstract public function process(Smarty_Internal_Template $_template, Smarty_Template_Cached $cached = null,
$update = false);
$update = false
);
/**
* Write the rendered template output to cache

View File

@@ -110,8 +110,10 @@ 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;
}
@@ -126,16 +128,18 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource
* @return boolean true or false if the cached content does not exist
*/
public function process(Smarty_Internal_Template $_smarty_tpl, Smarty_Template_Cached $cached = null,
$update = false)
{
$update = false
) {
if (!$cached) {
$cached = $_smarty_tpl->cached;
}
$content = $cached->content ? $cached->content : null;
$timestamp = $cached->timestamp ? $cached->timestamp : null;
if ($content === null || !$timestamp) {
$this->fetch($_smarty_tpl->cached->filepath, $_smarty_tpl->source->name, $_smarty_tpl->cache_id,
$_smarty_tpl->compile_id, $content, $timestamp);
$this->fetch(
$_smarty_tpl->cached->filepath, $_smarty_tpl->source->name, $_smarty_tpl->cache_id,
$_smarty_tpl->compile_id, $content, $timestamp
);
}
if (isset($content)) {
eval('?>' . $content);
@@ -156,8 +160,10 @@ 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
);
}
/**
@@ -173,8 +179,10 @@ 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;

View File

@@ -69,8 +69,10 @@ 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;
}
@@ -89,16 +91,18 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
* @return boolean true or false if the cached content does not exist
*/
public function process(Smarty_Internal_Template $_smarty_tpl, Smarty_Template_Cached $cached = null,
$update = false)
{
$update = false
) {
if (!$cached) {
$cached = $_smarty_tpl->cached;
}
$content = $cached->content ? $cached->content : null;
$timestamp = $cached->timestamp ? $cached->timestamp : null;
if ($content === null || !$timestamp) {
if (!$this->fetch($_smarty_tpl->cached->filepath, $_smarty_tpl->source->name, $_smarty_tpl->cache_id,
$_smarty_tpl->compile_id, $content, $timestamp, $_smarty_tpl->source->uid)
if (!$this->fetch(
$_smarty_tpl->cached->filepath, $_smarty_tpl->source->name, $_smarty_tpl->cache_id,
$_smarty_tpl->compile_id, $content, $timestamp, $_smarty_tpl->source->uid
)
) {
return false;
}
@@ -139,8 +143,10 @@ 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;
}
@@ -204,7 +210,6 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
*
* @return string filepath of cache file
* @throws \SmartyException
*
*/
protected function getTemplateUid(Smarty $smarty, $resource_name)
{
@@ -247,8 +252,8 @@ 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)
{
&$timestamp = null, $resource_uid = null
) {
$t = $this->read(array($cid));
$content = !empty($t[ $cid ]) ? $t[ $cid ] : null;
$timestamp = null;
@@ -307,8 +312,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)
{
$resource_uid = null
) {
$now = microtime(true);
$key = null;
// invalidate everything
@@ -348,8 +353,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)
{
$resource_uid = null
) {
// abort if there is no CacheID
if (false && !$cid) {
return 0;
@@ -383,8 +388,8 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
* @uses $invalidationKeyPrefix to prepend to each InvalidationKey
*/
protected function listInvalidationKeys($cid, $resource_name = null, $cache_id = null, $compile_id = null,
$resource_uid = null)
{
$resource_uid = null
) {
$t = array('IVK#ALL');
$_name = $_compile = '#';
if ($resource_name) {

View File

@@ -32,11 +32,13 @@ class Smarty_Internal_CacheResource_File extends Smarty_CacheResource
$_filepath = sha1($source->uid . $smarty->_joined_template_dir);
$cached->filepath = $smarty->getCacheDir();
if (isset($_template->cache_id)) {
$cached->filepath .= preg_replace(array('![^\w|]+!',
$cached->filepath .= preg_replace(
array('![^\w|]+!',
'![|]+!'),
array('_',
$_compile_dir_sep),
$_template->cache_id) . $_compile_dir_sep;
$_template->cache_id
) . $_compile_dir_sep;
}
if (isset($_template->compile_id)) {
$cached->filepath .= preg_replace('![^\w]+!', '_', $_template->compile_id) . $_compile_dir_sep;
@@ -89,8 +91,8 @@ class Smarty_Internal_CacheResource_File extends Smarty_CacheResource
*/
public function process(Smarty_Internal_Template $_smarty_tpl,
Smarty_Template_Cached $cached = null,
$update = false)
{
$update = false
) {
$_smarty_tpl->cached->valid = false;
if ($update && defined('HHVM_VERSION')) {
eval('?>' . file_get_contents($_smarty_tpl->cached->filepath));
@@ -111,12 +113,14 @@ 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,
if ($_template->smarty->ext->_writeFile->writeFile(
$_template->cached->filepath,
$content,
$_template->smarty) === true
$_template->smarty
) === true
) {
if (function_exists('opcache_invalidate') &&
(!function_exists('ini_get') || strlen(ini_get('opcache.restrict_api'))) < 1
if (function_exists('opcache_invalidate')
&& (!function_exists('ini_get') || strlen(ini_get('opcache.restrict_api'))) < 1
) {
opcache_invalidate($_template->cached->filepath, true);
} else if (function_exists('apc_compile_file')) {

View File

@@ -50,7 +50,6 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_Compile_Shared_Inher
* @param array $args array with attributes from parser
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
* @param array $parameter array with compilation parameter
*
*/
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
{
@@ -72,11 +71,13 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_Compile_Shared_Inher
$compiler->_cache[ 'blockClass' ][ $compiler->_cache[ 'blockNesting' ] ] = $_className;
$compiler->_cache[ 'blockParams' ][ $compiler->_cache[ 'blockNesting' ] ] = array();
$compiler->_cache[ 'blockParams' ][ 1 ][ 'subBlocks' ][ trim($_attr[ 'name' ], '"\'') ][] = $_className;
$this->openTag($compiler,
$this->openTag(
$compiler,
'block',
array($_attr, $compiler->nocache, $compiler->parser->current_buffer,
$compiler->template->compiled->has_nocache_code,
$compiler->template->caching));
$compiler->template->caching)
);
$compiler->saveRequiredPlugins(true);
$compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
$compiler->parser->current_buffer = new Smarty_Internal_ParseTree_Template();
@@ -86,7 +87,6 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_Compile_Shared_Inher
}
/**
* Smarty Internal Plugin Compile BlockClose Class
*
*/
class Smarty_Internal_Compile_Blockclose extends Smarty_Internal_Compile_Shared_Inheritance
{
@@ -124,7 +124,7 @@ class Smarty_Internal_Compile_Blockclose extends Smarty_Internal_Compile_Shared_
$output .= "class {$_className} extends Smarty_Internal_Block\n";
$output .= "{\n";
foreach ($_block as $property => $value) {
$output .= "public \${$property} = " . var_export($value,true) .";\n";
$output .= "public \${$property} = " . var_export($value, true) .";\n";
}
$output .= "public function callBlock(Smarty_Internal_Template \$_smarty_tpl) {\n";
$output .= $compiler->compileRequiredPlugins();
@@ -136,9 +136,13 @@ class Smarty_Internal_Compile_Blockclose extends Smarty_Internal_Compile_Shared_
$output .= "ob_start();\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->parser->current_buffer->append_subtree($compiler->parser, $_functionCode);
$output = "<?php\n";
if (isset($_assign)) {
@@ -148,9 +152,13 @@ class Smarty_Internal_Compile_Blockclose extends Smarty_Internal_Compile_Shared_
$output .= "}\n";
$output .= "/* {/block {$_name}} */\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->blockOrFunctionCode .= $compiler->parser->current_buffer->to_smarty_php($compiler->parser);
$compiler->parser->current_buffer = new Smarty_Internal_ParseTree_Template();
// restore old status

View File

@@ -36,7 +36,7 @@ class Smarty_Internal_Compile_Capture extends Smarty_Internal_CompileBase
* Compiles code for the {$smarty.capture.xxx}
*
* @param array $args array with attributes from parser
* @param \Smarty_Internal_TemplateCompilerBase$compiler compiler object
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
* @param array $parameter array with compilation parameter
*
* @return string compiled code

View File

@@ -53,8 +53,10 @@ class Smarty_Internal_Compile_Child extends Smarty_Internal_CompileBase
$_attr = $this->getAttributes($compiler, $args);
$tag = isset($parameter[0]) ? "'{$parameter[0]}'" : "'{{$this->tag}}'";
if (!isset($compiler->_cache[ 'blockNesting' ])) {
$compiler->trigger_template_error("{$tag} used outside {block} tags ",
$compiler->parser->lex->taglineno);
$compiler->trigger_template_error(
"{$tag} used outside {block} tags ",
$compiler->parser->lex->taglineno
);
}
$compiler->has_code = true;
$compiler->suppressNocacheProcessing = true;

View File

@@ -108,11 +108,13 @@ class Smarty_Internal_Compile_Extends extends Smarty_Internal_Compile_Shared_Inh
$inlineUids = $match[ 1 ];
}
}
$compiler->parser->template_postfix[] = new Smarty_Internal_ParseTree_Tag($compiler->parser,
$compiler->parser->template_postfix[] = new Smarty_Internal_ParseTree_Tag(
$compiler->parser,
'<?php $_smarty_tpl->inheritance->endChild($_smarty_tpl' .
(isset($template) ?
", {$template}{$inlineUids}" :
'') . ");\n?>");
'') . ");\n?>"
);
}
/**
@@ -126,10 +128,14 @@ class Smarty_Internal_Compile_Extends extends Smarty_Internal_Compile_Shared_Inh
*/
private function compileInclude(Smarty_Internal_TemplateCompilerBase $compiler, $template)
{
$compiler->parser->template_postfix[] = new Smarty_Internal_ParseTree_Tag($compiler->parser,
$compiler->compileTag('include',
$compiler->parser->template_postfix[] = new Smarty_Internal_ParseTree_Tag(
$compiler->parser,
$compiler->compileTag(
'include',
array($template,
array('scope' => 'parent'))));
array('scope' => 'parent'))
)
);
}
/**

View File

@@ -119,8 +119,10 @@ class Smarty_Internal_Compile_Foreach extends Smarty_Internal_Compile_Private_Fo
if ($fromName) {
foreach (array('item', 'key') as $a) {
if (isset($attributes[ $a ]) && $attributes[ $a ] === $fromName) {
$compiler->trigger_template_error("'{$a}' and 'from' may not have same variable name '{$fromName}'",
null, true);
$compiler->trigger_template_error(
"'{$a}' and 'from' may not have same variable name '{$fromName}'",
null, true
);
}
}
}
@@ -187,8 +189,10 @@ class Smarty_Internal_Compile_Foreach extends Smarty_Internal_Compile_Private_Fo
}
$needTotal = isset($itemAttr[ 'total' ]);
// Register tag
$this->openTag($compiler, 'foreach',
array('foreach', $compiler->nocache, $local, $itemVar, empty($itemAttr) ? 1 : 2));
$this->openTag(
$compiler, 'foreach',
array('foreach', $compiler->nocache, $local, $itemVar, empty($itemAttr) ? 1 : 2)
);
// maybe nocache because of nocache variables
$compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
// generate output code

View File

@@ -143,9 +143,13 @@ class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase
$output .= "echo \"/*%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%*/<?php ";
$output .= "\\\$_smarty_tpl->smarty->ext->_tplFunction->saveTemplateVariables(\\\$_smarty_tpl, '{$_name}');\nforeach (\$params as \\\$key => \\\$value) {\n\\\$_smarty_tpl->tpl_vars[\\\$key] = new Smarty_Variable(\\\$value, \\\$_smarty_tpl->isRenderingCache);\n}\n?>";
$output .= "/*/%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%*/\";?>";
$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 .= "\\\$_smarty_tpl->smarty->ext->_tplFunction->restoreTemplateVariables(\\\$_smarty_tpl, '{$_name}');?>\n";
@@ -154,13 +158,21 @@ class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase
$output .= "}\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)?)/",
$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)));
$_functionCode->to_smarty_php($compiler->parser)
)
);
}
$compiler->parent_compiler->tpl_function[ $_name ][ 'call_name' ] = $_funcName;
$output = "<?php\n";
@@ -171,16 +183,24 @@ class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase
$output .= "foreach (\$params as \$key => \$value) {\n\$_smarty_tpl->tpl_vars[\$key] = new Smarty_Variable(\$value, \$_smarty_tpl->isRenderingCache);\n}\n";
$output .= $compiler->compileCheckPlugins(array_merge($compiler->required_plugins[ 'compiled' ], $compiler->required_plugins[ 'nocache' ]));
$output .= "?>\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\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);
// restore old buffer
$compiler->parser->current_buffer = $saved_data[ 1 ];
@@ -201,8 +221,10 @@ 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 ]);
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;
}

View File

@@ -55,8 +55,10 @@ class Smarty_Internal_Compile_If extends Smarty_Internal_CompileBase
$assignCompiler = new Smarty_Internal_Compile_Assign();
if (is_array($parameter[ 'if condition' ][ 'var' ])) {
$assignAttr[][ 'var' ] = $parameter[ 'if condition' ][ 'var' ][ 'var' ];
$_output .= $assignCompiler->compile($assignAttr, $compiler,
array('smarty_internal_index' => $parameter[ 'if condition' ][ 'var' ][ 'smarty_internal_index' ]));
$_output .= $assignCompiler->compile(
$assignAttr, $compiler,
array('smarty_internal_index' => $parameter[ 'if condition' ][ 'var' ][ 'smarty_internal_index' ])
);
} else {
$assignAttr[][ 'var' ] = $parameter[ 'if condition' ][ 'var' ];
$_output .= $assignCompiler->compile($assignAttr, $compiler, array());
@@ -143,8 +145,10 @@ class Smarty_Internal_Compile_Elseif extends Smarty_Internal_CompileBase
$assignAttr[][ 'value' ] = $prefixVar;
if (is_array($parameter[ 'if condition' ][ 'var' ])) {
$assignAttr[][ 'var' ] = $parameter[ 'if condition' ][ 'var' ][ 'var' ];
$assignCode .= $assignCompiler->compile($assignAttr, $compiler,
array('smarty_internal_index' => $parameter[ 'if condition' ][ 'var' ][ 'smarty_internal_index' ]));
$assignCode .= $assignCompiler->compile(
$assignAttr, $compiler,
array('smarty_internal_index' => $parameter[ 'if condition' ][ 'var' ][ 'smarty_internal_index' ])
);
} else {
$assignAttr[][ 'var' ] = $parameter[ 'if condition' ][ 'var' ];
$assignCode .= $assignCompiler->compile($assignAttr, $compiler, array());

View File

@@ -91,8 +91,7 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase
$compiled->includes[ $fullResourceName ]++;
$cache_tpl = true;
} else {
if ("{$compiler->template->source->type}:{$compiler->template->source->name}" ==
$fullResourceName
if ("{$compiler->template->source->type}:{$compiler->template->source->name}" == $fullResourceName
) {
// recursive call of current template
$compiled->includes[ $fullResourceName ] = 2;
@@ -193,9 +192,11 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase
$t_hash = sha1($c_id . ($_caching ? '--caching' : '--nocaching'));
$compiler->smarty->allow_ambiguous_resources = true;
/* @var Smarty_Internal_Template $tpl */
$tpl = new $compiler->smarty->template_class (trim($fullResourceName, '"\''), $compiler->smarty,
$tpl = new $compiler->smarty->template_class(
trim($fullResourceName, '"\''), $compiler->smarty,
$compiler->template, $compiler->template->cache_id, $c_id,
$_caching);
$_caching
);
$uid = $tpl->source->type . $tpl->source->uid;
if (!isset($compiler->parent_compiler->mergedSubTemplatesData[ $uid ][ $t_hash ])) {
$has_compiled_template = $this->compileInlineTemplate($compiler, $tpl, $t_hash);
@@ -277,8 +278,8 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase
*/
public function compileInlineTemplate(Smarty_Internal_SmartyTemplateCompiler $compiler,
Smarty_Internal_Template $tpl,
$t_hash)
{
$t_hash
) {
$uid = $tpl->source->type . $tpl->source->uid;
if (!($tpl->source->handler->uncompiled) && $tpl->source->exists) {
$compiler->parent_compiler->mergedSubTemplatesData[ $uid ][ $t_hash ][ 'uid' ] = $tpl->source->uid;
@@ -317,9 +318,11 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase
if ($tpl->compiled->has_nocache_code) {
// replace nocache_hash
$compiled_code =
str_replace("{$tpl->compiled->nocache_hash}",
str_replace(
"{$tpl->compiled->nocache_hash}",
$compiler->template->compiled->nocache_hash,
$compiled_code);
$compiled_code
);
$compiler->template->compiled->has_nocache_code = true;
}
$compiler->parent_compiler->mergedSubTemplatesCode[ $tpl->compiled->unifunc ] = $compiled_code;

View File

@@ -56,7 +56,10 @@ class Smarty_Internal_Compile_Include_Php extends Smarty_Internal_CompileBase
}
// check and get attributes
$_attr = $this->getAttributes($compiler, $args);
/** @var Smarty_Internal_Template $_smarty_tpl
/**
*
*
* @var Smarty_Internal_Template $_smarty_tpl
* used in evaluated code
*/
$_smarty_tpl = $compiler->template;

View File

@@ -104,11 +104,13 @@ class Smarty_Internal_Compile_Insert extends Smarty_Internal_CompileBase
}
// code for script file loading
$_output .= "require_once '{$_filepath}' ;";
require_once $_filepath;
include_once $_filepath;
if (!is_callable($_function)) {
$compiler->trigger_template_error(" {insert} function '{$_function}' is not callable in script file '{$_script}'",
$compiler->trigger_template_error(
" {insert} function '{$_function}' is not callable in script file '{$_script}'",
null,
true);
true
);
}
} else {
$_filepath = 'null';
@@ -117,9 +119,11 @@ 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}'",
$compiler->trigger_template_error(
"{insert} no function or plugin found for '{$_name}'",
null,
true);
true
);
}
}
}

View File

@@ -84,9 +84,11 @@ class Smarty_Internal_Compile_Private_Block_Plugin extends Smarty_Internal_Compi
$mod_content2 = "\$_block_content{$this->nesting}";
$mod_content = "\$_block_content{$this->nesting} = ob_get_clean();\n";
$mod_pre = "ob_start();\n";
$mod_post = 'echo ' . $compiler->compileTag('private_modifier', array(),
$mod_post = 'echo ' . $compiler->compileTag(
'private_modifier', array(),
array('modifierlist' => $parameter[ 'modifier_list' ],
'value' => 'ob_get_clean()')) . ";\n";
'value' => 'ob_get_clean()')
) . ";\n";
}
$output = "<?php {$mod_content}\$_block_repeat=false;\n{$mod_pre}echo {$callback}({$_params}, {$mod_content2}, \$_smarty_tpl, \$_block_repeat);\n{$mod_post}}\n";
$output .= 'array_pop($_smarty_tpl->smarty->_cache[\'_tag_stack\']);?>';

View File

@@ -178,11 +178,13 @@ class Smarty_Internal_Compile_Private_ForeachSection extends Smarty_Internal_Com
$_content = $nextCompiler->template->source->getContent();
if ($_content !== '') {
// run pre filter if required
if ((isset($nextCompiler->smarty->autoload_filters[ 'pre' ]) ||
isset($nextCompiler->smarty->registered_filters[ 'pre' ]))
if ((isset($nextCompiler->smarty->autoload_filters[ 'pre' ])
|| isset($nextCompiler->smarty->registered_filters[ 'pre' ]))
) {
$_content = $nextCompiler->smarty->ext->_filterHandler->runFilter('pre', $_content,
$nextCompiler->template);
$_content = $nextCompiler->smarty->ext->_filterHandler->runFilter(
'pre', $_content,
$nextCompiler->template
);
}
$this->matchProperty($_content);
}

View File

@@ -64,9 +64,11 @@ class Smarty_Internal_Compile_Private_Function_Plugin extends Smarty_Internal_Co
// compile code
$output = "{$function}({$_params},\$_smarty_tpl)";
if (!empty($parameter[ 'modifierlist' ])) {
$output = $compiler->compileTag('private_modifier', array(),
$output = $compiler->compileTag(
'private_modifier', array(),
array('modifierlist' => $parameter[ 'modifierlist' ],
'value' => $output));
'value' => $output)
);
}
$output = "<?php echo {$output};?>\n";
return $output;

View File

@@ -52,8 +52,10 @@ class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBa
if (isset($compiler->smarty->registered_plugins[ Smarty::PLUGIN_MODIFIER ][ $modifier ])) {
if (is_callable($compiler->smarty->registered_plugins[ Smarty::PLUGIN_MODIFIER ][ $modifier ][ 0 ])) {
$output =
sprintf('call_user_func_array($_smarty_tpl->registered_plugins[ \'%s\' ][ %s ][ 0 ], array( %s ))',
Smarty::PLUGIN_MODIFIER, var_export($modifier, true), $params);
sprintf(
'call_user_func_array($_smarty_tpl->registered_plugins[ \'%s\' ][ %s ][ 0 ], array( %s ))',
Smarty::PLUGIN_MODIFIER, var_export($modifier, true), $params
);
$compiler->known_modifier_type[ $modifier ] = $type;
break 2;
}
@@ -63,8 +65,10 @@ class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBa
// 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);
call_user_func(
$compiler->smarty->registered_plugins[ Smarty::PLUGIN_MODIFIERCOMPILER ][ $modifier ][ 0 ],
$single_modifier, $compiler->smarty
);
$compiler->known_modifier_type[ $modifier ] = $type;
break 2;
}
@@ -73,8 +77,8 @@ class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBa
// modifiercompiler plugin
if ($compiler->smarty->loadPlugin('smarty_modifiercompiler_' . $modifier)) {
// check if modifier allowed
if (!is_object($compiler->smarty->security_policy) ||
$compiler->smarty->security_policy->isTrustedModifier($modifier, $compiler)
if (!is_object($compiler->smarty->security_policy)
|| $compiler->smarty->security_policy->isTrustedModifier($modifier, $compiler)
) {
$plugin = 'smarty_modifiercompiler_' . $modifier;
$output = $plugin($single_modifier, $compiler);
@@ -87,8 +91,8 @@ class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBa
// modifier plugin
if ($function = $compiler->getPlugin($modifier, Smarty::PLUGIN_MODIFIER)) {
// check if modifier allowed
if (!is_object($compiler->smarty->security_policy) ||
$compiler->smarty->security_policy->isTrustedModifier($modifier, $compiler)
if (!is_object($compiler->smarty->security_policy)
|| $compiler->smarty->security_policy->isTrustedModifier($modifier, $compiler)
) {
$output = "{$function}({$params})";
}
@@ -100,8 +104,8 @@ class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBa
// PHP function
if (is_callable($modifier)) {
// check if modifier allowed
if (!is_object($compiler->smarty->security_policy) ||
$compiler->smarty->security_policy->isTrustedPhpModifier($modifier, $compiler)
if (!is_object($compiler->smarty->security_policy)
|| $compiler->smarty->security_policy->isTrustedPhpModifier($modifier, $compiler)
) {
$output = "{$modifier}({$params})";
}
@@ -111,14 +115,14 @@ class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBa
break;
case 6:
// default plugin handler
if (isset($compiler->default_handler_plugins[ Smarty::PLUGIN_MODIFIER ][ $modifier ]) ||
(is_callable($compiler->smarty->default_plugin_handler_func) &&
$compiler->getPluginFromDefaultHandler($modifier, Smarty::PLUGIN_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 ];
// check if modifier allowed
if (!is_object($compiler->smarty->security_policy) ||
$compiler->smarty->security_policy->isTrustedModifier($modifier, $compiler)
if (!is_object($compiler->smarty->security_policy)
|| $compiler->smarty->security_policy->isTrustedModifier($modifier, $compiler)
) {
if (!is_array($function)) {
$output = "{$function}({$params})";
@@ -130,8 +134,8 @@ class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBa
}
}
}
if (isset($compiler->required_plugins[ 'nocache' ][ $modifier ][ Smarty::PLUGIN_MODIFIER ][ 'file' ]) ||
isset($compiler->required_plugins[ 'compiled' ][ $modifier ][ Smarty::PLUGIN_MODIFIER ][ 'file' ])
if (isset($compiler->required_plugins[ 'nocache' ][ $modifier ][ Smarty::PLUGIN_MODIFIER ][ 'file' ])
|| isset($compiler->required_plugins[ 'compiled' ][ $modifier ][ Smarty::PLUGIN_MODIFIER ][ 'file' ])
) {
// was a plugin
$compiler->known_modifier_type[ $modifier ] = 4;

View File

@@ -70,8 +70,10 @@ class Smarty_Internal_Compile_Private_Object_Function extends Smarty_Internal_Co
$output = "\$_smarty_tpl->smarty->registered_objects['{$tag}'][0]->{$method}";
}
if (!empty($parameter[ 'modifierlist' ])) {
$output = $compiler->compileTag('private_modifier', array(),
array('modifierlist' => $parameter[ 'modifierlist' ], 'value' => $output));
$output = $compiler->compileTag(
'private_modifier', array(),
array('modifierlist' => $parameter[ 'modifierlist' ], 'value' => $output)
);
}
if (empty($_assign)) {
return "<?php echo {$output};?>\n";

View File

@@ -43,10 +43,16 @@ class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase
if ($_attr[ 'type' ] === 'xml') {
$compiler->tag_nocache = true;
$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)));
$compiler->parser->current_buffer->append_subtree(
$compiler->parser,
new Smarty_Internal_ParseTree_Tag(
$compiler->parser,
$compiler->processNocacheCode(
"<?php echo '{$output}';?>",
true
)
)
);
return '';
}
if ($_attr[ 'type' ] !== 'tag') {
@@ -54,23 +60,35 @@ class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase
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));
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') {
$compiler->tag_nocache = true;
$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)));
$compiler->parser->current_buffer->append_subtree(
$compiler->parser,
new Smarty_Internal_ParseTree_Tag(
$compiler->parser,
$compiler->processNocacheCode(
"<?php echo '{$output}';?>",
true
)
)
);
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' ];
@@ -80,8 +98,10 @@ class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase
} 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, '#');
@@ -93,8 +113,10 @@ class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase
$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' ]
);
}
}
@@ -148,8 +170,8 @@ class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase
if ($lex->phpType === 'unmatched') {
return;
}
if (($lex->phpType === 'php' || $lex->phpType === 'asp') &&
($lex->compiler->php_handling === Smarty::PHP_PASSTHRU || $lex->compiler->php_handling === Smarty::PHP_QUOTE)
if (($lex->phpType === 'php' || $lex->phpType === 'asp')
&& ($lex->compiler->php_handling === Smarty::PHP_PASSTHRU || $lex->compiler->php_handling === Smarty::PHP_QUOTE)
) {
return;
}
@@ -161,8 +183,11 @@ class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase
$lex->compiler->trigger_template_error("missing closing tag '{$closeTag}'");
}
while ($body) {
if (preg_match('~([/][*])|([/][/][^\n]*)|(\'[^\'\\\\]*(?:\\.[^\'\\\\]*)*\')|("[^"\\\\]*(?:\\.[^"\\\\]*)*")~',
$lex->data, $match, PREG_OFFSET_CAPTURE, $start)) {
if (preg_match(
'~([/][*])|([/][/][^\n]*)|(\'[^\'\\\\]*(?:\\.[^\'\\\\]*)*\')|("[^"\\\\]*(?:\\.[^"\\\\]*)*")~',
$lex->data, $match, PREG_OFFSET_CAPTURE, $start
)
) {
$value = $match[ 0 ][ 0 ];
$from = $pos = $match[ 0 ][ 1 ];
if ($pos > $close) {
@@ -178,8 +203,11 @@ class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase
}
}
while ($close > $pos && $close < $start) {
if (preg_match('~' . preg_quote($closeTag, '~') . '~i', $lex->data, $match, PREG_OFFSET_CAPTURE,
$from)) {
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 {

View File

@@ -49,9 +49,11 @@ class Smarty_Internal_Compile_Private_Print_Expression extends Smarty_Internal_C
$output = $parameter[ 'value' ];
// tag modifier
if (!empty($parameter[ 'modifierlist' ])) {
$output = $compiler->compileTag('private_modifier', array(),
$output = $compiler->compileTag(
'private_modifier', array(),
array('modifierlist' => $parameter[ 'modifierlist' ],
'value' => $output));
'value' => $output)
);
}
if (isset($_attr[ 'assign' ])) {
// assign output to variable
@@ -64,8 +66,10 @@ class Smarty_Internal_Compile_Private_Print_Expression extends Smarty_Internal_C
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);
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 ];
@@ -74,9 +78,11 @@ class Smarty_Internal_Compile_Private_Print_Expression extends Smarty_Internal_C
}
$compiler->default_modifier_list = $modifierlist;
}
$output = $compiler->compileTag('private_modifier', array(),
$output = $compiler->compileTag(
'private_modifier', array(),
array('modifierlist' => $compiler->default_modifier_list,
'value' => $output));
'value' => $output)
);
}
// autoescape html
if ($compiler->template->smarty->escape_html) {
@@ -110,13 +116,15 @@ class Smarty_Internal_Compile_Private_Print_Expression extends Smarty_Internal_C
}
}
foreach ($compiler->variable_filters as $filter) {
if (count($filter) === 1 &&
($result = $this->compile_variable_filter($compiler, $filter[ 0 ], $output)) !== false
if (count($filter) === 1
&& ($result = $this->compile_variable_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)
);
}
}
}

View File

@@ -76,9 +76,11 @@ class Smarty_Internal_Compile_Private_Registered_Function extends Smarty_Interna
}
}
if (!empty($parameter[ 'modifierlist' ])) {
$output = $compiler->compileTag('private_modifier', array(),
$output = $compiler->compileTag(
'private_modifier', array(),
array('modifierlist' => $parameter[ 'modifierlist' ],
'value' => $output));
'value' => $output)
);
}
$output = "<?php echo {$output};?>\n";
return $output;

View File

@@ -33,8 +33,8 @@ class Smarty_Internal_Compile_Private_Special_Variable extends Smarty_Internal_C
if ($variable === false) {
$compiler->trigger_template_error("special \$Smarty variable name index can not be variable", null, true);
}
if (!isset($compiler->smarty->security_policy) ||
$compiler->smarty->security_policy->isTrustedSpecialSmartyVar($variable, $compiler)
if (!isset($compiler->smarty->security_policy)
|| $compiler->smarty->security_policy->isTrustedSpecialSmartyVar($variable, $compiler)
) {
switch ($variable) {
case 'foreach':
@@ -52,8 +52,8 @@ class Smarty_Internal_Compile_Private_Special_Variable extends Smarty_Internal_C
case 'now':
return 'time()';
case 'cookies':
if (isset($compiler->smarty->security_policy) &&
!$compiler->smarty->security_policy->allow_super_globals
if (isset($compiler->smarty->security_policy)
&& !$compiler->smarty->security_policy->allow_super_globals
) {
$compiler->trigger_template_error("(secure mode) super globals not permitted");
break;
@@ -66,8 +66,8 @@ class Smarty_Internal_Compile_Private_Special_Variable extends Smarty_Internal_C
case 'server':
case 'session':
case 'request':
if (isset($compiler->smarty->security_policy) &&
!$compiler->smarty->security_policy->allow_super_globals
if (isset($compiler->smarty->security_policy)
&& !$compiler->smarty->security_policy->allow_super_globals
) {
$compiler->trigger_template_error("(secure mode) super globals not permitted");
break;
@@ -88,8 +88,8 @@ class Smarty_Internal_Compile_Private_Special_Variable extends Smarty_Internal_C
return "Smarty::SMARTY_VERSION";
case 'const':
if (isset($compiler->smarty->security_policy) &&
!$compiler->smarty->security_policy->allow_constants
if (isset($compiler->smarty->security_policy)
&& !$compiler->smarty->security_policy->allow_constants
) {
$compiler->trigger_template_error("(secure mode) constants not permitted");
break;

View File

@@ -28,7 +28,7 @@ class Smarty_Internal_Compile_Rdelim extends Smarty_Internal_Compile_Ldelim
*/
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
{
parent::compile($args,$compiler);
parent::compile($args, $compiler);
return $compiler->smarty->right_delimiter;
}
}

View File

@@ -264,8 +264,10 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_Compile_Private_Fo
$start_code[ $i ] = '';
}
if ($propType[ 'start' ] === 0) {
$start_code = array(max($propValue[ 'step' ] > 0 ? 0 : - 1,
$propValue[ 'start' ] + $propValue[ 'loop' ]));
$start_code = array(max(
$propValue[ 'step' ] > 0 ? 0 : - 1,
$propValue[ 'start' ] + $propValue[ 'loop' ]
));
}
} else {
for ($i = 1; $i <= 11; $i ++) {
@@ -273,8 +275,10 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_Compile_Private_Fo
}
if ($propType[ 'start' ] === 0) {
$start_code =
array(min($propValue[ 'step' ] > 0 ? $propValue[ 'loop' ] : $propValue[ 'loop' ] - 1,
$propValue[ 'start' ]));
array(min(
$propValue[ 'step' ] > 0 ? $propValue[ 'loop' ] : $propValue[ 'loop' ] - 1,
$propValue[ 'start' ]
));
}
}
}
@@ -295,8 +299,12 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_Compile_Private_Fo
$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' ]);
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 => ' : ',

View File

@@ -37,10 +37,12 @@ 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'])) {
$compiler->registerPostCompileCallback(array('Smarty_Internal_Compile_Shared_Inheritance', 'postCompile'),
$compiler->registerPostCompileCallback(
array('Smarty_Internal_Compile_Shared_Inheritance', 'postCompile'),
array($initChildSequence),
'inheritanceInit',
$initChildSequence);
$initChildSequence
);
$compiler->_cache['inheritanceInit'] = true;
}

View File

@@ -56,8 +56,10 @@ class Smarty_Internal_Compile_While extends Smarty_Internal_CompileBase
if (is_array($parameter[ 'if condition' ][ 'var' ])) {
$assignAttr[][ 'var' ] = $parameter[ 'if condition' ][ 'var' ][ 'var' ];
$_output = "<?php while ({$prefixVar} = {$parameter[ 'if condition' ][ 'value' ]}) {?>";
$_output .= $assignCompiler->compile($assignAttr, $compiler,
array('smarty_internal_index' => $parameter[ 'if condition' ][ 'var' ][ 'smarty_internal_index' ]));
$_output .= $assignCompiler->compile(
$assignAttr, $compiler,
array('smarty_internal_index' => $parameter[ 'if condition' ][ 'var' ][ 'smarty_internal_index' ])
);
} else {
$assignAttr[][ 'var' ] = $parameter[ 'if condition' ][ 'var' ];
$_output = "<?php while ({$prefixVar} = {$parameter[ 'if condition' ][ 'value' ]}) {?>";

View File

@@ -103,8 +103,10 @@ abstract class Smarty_Internal_CompileBase
if (isset($this->optionMap[ $v ])) {
$_indexed_attr[ $k ] = $this->optionMap[ $v ];
} else {
$compiler->trigger_template_error("illegal value '" . var_export($v, true) .
"' for option flag '{$k}'", null, true);
$compiler->trigger_template_error(
"illegal value '" . var_export($v, true) .
"' for option flag '{$k}'", null, true
);
}
}
// must be named attribute
@@ -124,8 +126,12 @@ abstract class Smarty_Internal_CompileBase
if ($this->optional_attributes !== array('_any')) {
if (!isset($this->mapCache[ 'all' ])) {
$this->mapCache[ 'all' ] =
array_fill_keys(array_merge($this->required_attributes, $this->optional_attributes,
$this->option_flags), true);
array_fill_keys(
array_merge(
$this->required_attributes, $this->optional_attributes,
$this->option_flags
), true
);
}
foreach ($_indexed_attr as $key => $dummy) {
if (!isset($this->mapCache[ 'all' ][ $key ]) && $key !== 0) {

View File

@@ -114,9 +114,13 @@ class Smarty_Internal_Config_File_Compiler
}
// init the lexer/parser to compile the config file
/* @var Smarty_Internal_ConfigFileLexer $this ->lex */
$this->lex = new $this->lexer_class(str_replace(array("\r\n",
"\r"), "\n", $template->source->getContent()) . "\n",
$this);
$this->lex = new $this->lexer_class(
str_replace(
array("\r\n",
"\r"), "\n", $template->source->getContent()
) . "\n",
$this
);
/* @var Smarty_Internal_ConfigFileParser $this ->parser */
$this->parser = new $this->parser_class($this->lex, $this);

View File

@@ -166,39 +166,47 @@ class Smarty_Internal_Configfilelexer
public function yypushstate($state)
{
if ($this->yyTraceFILE) {
fprintf($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);
$this->_yy_state
);
}
array_push($this->_yy_stack, $this->_yy_state);
$this->_yy_state = $state;
if ($this->yyTraceFILE) {
fprintf($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);
$this->_yy_state
);
}
}
public function yypopstate()
{
if ($this->yyTraceFILE) {
fprintf($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);
$this->_yy_state
);
}
$this->_yy_state = array_pop($this->_yy_stack);
if ($this->yyTraceFILE) {
fprintf($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);
$this->_yy_state
);
}
}
@@ -206,11 +214,13 @@ class Smarty_Internal_Configfilelexer
{
$this->_yy_state = $state;
if ($this->yyTraceFILE) {
fprintf($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);
$this->_yy_state
);
}
}
@@ -234,10 +244,14 @@ class Smarty_Internal_Configfilelexer
$yymatches = array_filter($yymatches);
}
if (empty($yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' .
' an empty string. Input "' . substr($this->data,
throw new Exception(
'Error: lexing failed because a rule matched' .
' an empty string. Input "' . substr(
$this->data,
$this->counter,
5) . '... state START');
5
) . '... state START'
);
}
next($yymatches); // skip global match
$this->token = key($yymatches); // token number
@@ -262,8 +276,10 @@ 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);
@@ -332,10 +348,14 @@ class Smarty_Internal_Configfilelexer
$yymatches = array_filter($yymatches);
}
if (empty($yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' .
' an empty string. Input "' . substr($this->data,
throw new Exception(
'Error: lexing failed because a rule matched' .
' an empty string. Input "' . substr(
$this->data,
$this->counter,
5) . '... state VALUE');
5
) . '... state VALUE'
);
}
next($yymatches); // skip global match
$this->token = key($yymatches); // token number
@@ -360,8 +380,10 @@ 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);
@@ -404,8 +426,9 @@ 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);
return true; //reprocess in new state
@@ -447,10 +470,14 @@ class Smarty_Internal_Configfilelexer
$yymatches = array_filter($yymatches);
}
if (empty($yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' .
' an empty string. Input "' . substr($this->data,
throw new Exception(
'Error: lexing failed because a rule matched' .
' an empty string. Input "' . substr(
$this->data,
$this->counter,
5) . '... state NAKED_STRING_VALUE');
5
) . '... state NAKED_STRING_VALUE'
);
}
next($yymatches); // skip global match
$this->token = key($yymatches); // token number
@@ -475,8 +502,10 @@ 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);
@@ -507,10 +536,14 @@ class Smarty_Internal_Configfilelexer
$yymatches = array_filter($yymatches);
}
if (empty($yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' .
' an empty string. Input "' . substr($this->data,
throw new Exception(
'Error: lexing failed because a rule matched' .
' an empty string. Input "' . substr(
$this->data,
$this->counter,
5) . '... state COMMENT');
5
) . '... state COMMENT'
);
}
next($yymatches); // skip global match
$this->token = key($yymatches); // token number
@@ -535,8 +568,10 @@ 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);
@@ -577,10 +612,14 @@ class Smarty_Internal_Configfilelexer
$yymatches = array_filter($yymatches);
}
if (empty($yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' .
' an empty string. Input "' . substr($this->data,
throw new Exception(
'Error: lexing failed because a rule matched' .
' an empty string. Input "' . substr(
$this->data,
$this->counter,
5) . '... state SECTION');
5
) . '... state SECTION'
);
}
next($yymatches); // skip global match
$this->token = key($yymatches); // token number
@@ -605,8 +644,10 @@ 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);
@@ -642,10 +683,14 @@ class Smarty_Internal_Configfilelexer
$yymatches = array_filter($yymatches);
}
if (empty($yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' .
' an empty string. Input "' . substr($this->data,
throw new Exception(
'Error: lexing failed because a rule matched' .
' an empty string. Input "' . substr(
$this->data,
$this->counter,
5) . '... state TRIPPLE');
5
) . '... state TRIPPLE'
);
}
next($yymatches); // skip global match
$this->token = key($yymatches); // token number
@@ -670,8 +715,10 @@ 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);

View File

@@ -9,7 +9,7 @@ class TPC_yyStackEntry
** is the value of the token */
}
#line 12 "../smarty/lexer/smarty_internal_configfileparser.y"
// line 12 "../smarty/lexer/smarty_internal_configfileparser.y"
/**
* Smarty Internal Plugin Configfileparse
@@ -23,7 +23,7 @@ class TPC_yyStackEntry
*/
class Smarty_Internal_Configfileparser
{
#line 25 "../smarty/lexer/smarty_internal_configfileparser.y"
// line 25 "../smarty/lexer/smarty_internal_configfileparser.y"
const TPC_OPENB = 1;
const TPC_SECTION = 2;
const TPC_CLOSEB = 3;
@@ -375,9 +375,11 @@ class Smarty_Internal_Configfileparser
}
$yytos = array_pop($this->yystack);
if ($this->yyTraceFILE && $this->yyidx >= 0) {
fwrite($this->yyTraceFILE,
fwrite(
$this->yyTraceFILE,
$this->yyTracePrompt . 'Popping ' . $this->yyTokenName[ $yytos->major ] .
"\n");
"\n"
);
}
$yymajor = $yytos->major;
self::yy_destructor($yymajor, $yytos->minor);
@@ -429,7 +431,8 @@ class Smarty_Internal_Configfileparser
$this->yyidx -= self::$yyRuleInfo[ $yyruleno ][ 1 ];
$nextstate = $this->yy_find_reduce_action(
$this->yystack[ $this->yyidx ]->stateno,
self::$yyRuleInfo[ $yyruleno ][ 0 ]);
self::$yyRuleInfo[ $yyruleno ][ 0 ]
);
if (isset(self::$yyExpectedTokens[ $nextstate ])) {
$expected = array_merge($expected, self::$yyExpectedTokens[ $nextstate ]);
if (isset($res4[ $nextstate ][ $token ])) {
@@ -439,8 +442,8 @@ class Smarty_Internal_Configfileparser
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);
@@ -515,7 +518,8 @@ class Smarty_Internal_Configfileparser
$this->yyidx -= self::$yyRuleInfo[ $yyruleno ][ 1 ];
$nextstate = $this->yy_find_reduce_action(
$this->yystack[ $this->yyidx ]->stateno,
self::$yyRuleInfo[ $yyruleno ][ 0 ]);
self::$yyRuleInfo[ $yyruleno ][ 0 ]
);
if (isset($res2[ $nextstate ][ $token ])) {
if ($res2[ $nextstate ][ $token ]) {
$this->yyidx = $yyidx;
@@ -523,10 +527,13 @@ class Smarty_Internal_Configfileparser
return true;
}
} else {
if ($res2[ $nextstate ][ $token ] = (isset(self::$yyExpectedTokens[ $nextstate ]) &&
in_array($token,
if ($res2[ $nextstate ][ $token ] = (isset(self::$yyExpectedTokens[ $nextstate ])
&& in_array(
$token,
self::$yyExpectedTokens[ $nextstate ],
true))) {
true
))
) {
$this->yyidx = $yyidx;
$this->yystack = $stack;
return true;
@@ -584,15 +591,19 @@ class Smarty_Internal_Configfileparser
return self::YY_NO_ACTION;
}
$i += $iLookAhead;
if ($i < 0 || $i >= self::YY_SZ_ACTTAB ||
self::$yy_lookahead[ $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) {
&& ($iFallback = self::$yyFallback[ $iLookAhead ]) != 0
) {
if ($this->yyTraceFILE) {
fwrite($this->yyTraceFILE,
fwrite(
$this->yyTraceFILE,
$this->yyTracePrompt . 'FALLBACK ' .
$this->yyTokenName[ $iLookAhead ] . ' => ' .
$this->yyTokenName[ $iFallback ] . "\n");
$this->yyTokenName[ $iFallback ] . "\n"
);
}
return $this->yy_find_shift_action($iFallback);
}
@@ -616,8 +627,9 @@ class Smarty_Internal_Configfileparser
return self::YY_NO_ACTION;
}
$i += $iLookAhead;
if ($i < 0 || $i >= self::YY_SZ_ACTTAB ||
self::$yy_lookahead[ $i ] != $iLookAhead) {
if ($i < 0 || $i >= self::YY_SZ_ACTTAB
|| self::$yy_lookahead[ $i ] != $iLookAhead
) {
return self::$yy_default[ $stateno ];
} else {
return self::$yy_action[ $i ];
@@ -635,7 +647,7 @@ class Smarty_Internal_Configfileparser
while ($this->yyidx >= 0) {
$this->yy_pop_parser_stack();
}
#line 239 "../smarty/lexer/smarty_internal_configfileparser.y"
// line 239 "../smarty/lexer/smarty_internal_configfileparser.y"
$this->internalError = true;
$this->compiler->trigger_config_file_error('Stack overflow in configfile parser');
return;
@@ -646,15 +658,19 @@ class Smarty_Internal_Configfileparser
$yytos->minor = $yypMinor;
$this->yystack[] = $yytos;
if ($this->yyTraceFILE && $this->yyidx > 0) {
fprintf($this->yyTraceFILE,
fprintf(
$this->yyTraceFILE,
"%sShift %d\n",
$this->yyTracePrompt,
$yyNewState);
$yyNewState
);
fprintf($this->yyTraceFILE, "%sStack:", $this->yyTracePrompt);
for ($i = 1; $i <= $this->yyidx; $i++) {
fprintf($this->yyTraceFILE,
fprintf(
$this->yyTraceFILE,
" %s",
$this->yyTokenName[ $this->yystack[ $i ]->major ]);
$this->yyTokenName[ $this->yystack[ $i ]->major ]
);
}
fwrite($this->yyTraceFILE, "\n");
}
@@ -677,100 +693,105 @@ class Smarty_Internal_Configfileparser
$this->_retvalue = null;
}
#line 245 "../smarty/lexer/smarty_internal_configfileparser.y"
// line 245 "../smarty/lexer/smarty_internal_configfileparser.y"
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;
}
#line 250 "../smarty/lexer/smarty_internal_configfileparser.y"
// line 250 "../smarty/lexer/smarty_internal_configfileparser.y"
function yy_r6()
{
$this->_retvalue = $this->yystack[ $this->yyidx + -1 ]->minor;
}
#line 264 "../smarty/lexer/smarty_internal_configfileparser.y"
// line 264 "../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));
}
#line 269 "../smarty/lexer/smarty_internal_configfileparser.y"
// line 269 "../smarty/lexer/smarty_internal_configfileparser.y"
function yy_r8()
{
$this->_retvalue = array();
}
#line 277 "../smarty/lexer/smarty_internal_configfileparser.y"
// line 277 "../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);
}
#line 281 "../smarty/lexer/smarty_internal_configfileparser.y"
// line 281 "../smarty/lexer/smarty_internal_configfileparser.y"
function yy_r10()
{
$this->_retvalue = (float)$this->yystack[ $this->yyidx + 0 ]->minor;
}
#line 285 "../smarty/lexer/smarty_internal_configfileparser.y"
// line 285 "../smarty/lexer/smarty_internal_configfileparser.y"
function yy_r11()
{
$this->_retvalue = (int)$this->yystack[ $this->yyidx + 0 ]->minor;
}
#line 291 "../smarty/lexer/smarty_internal_configfileparser.y"
// line 291 "../smarty/lexer/smarty_internal_configfileparser.y"
function yy_r12()
{
$this->_retvalue = $this->parse_bool($this->yystack[ $this->yyidx + 0 ]->minor);
}
#line 296 "../smarty/lexer/smarty_internal_configfileparser.y"
// line 296 "../smarty/lexer/smarty_internal_configfileparser.y"
function yy_r13()
{
$this->_retvalue = self::parse_single_quoted_string($this->yystack[ $this->yyidx + 0 ]->minor);
}
#line 300 "../smarty/lexer/smarty_internal_configfileparser.y"
// line 300 "../smarty/lexer/smarty_internal_configfileparser.y"
function yy_r14()
{
$this->_retvalue = self::parse_double_quoted_string($this->yystack[ $this->yyidx + 0 ]->minor);
}
#line 304 "../smarty/lexer/smarty_internal_configfileparser.y"
// line 304 "../smarty/lexer/smarty_internal_configfileparser.y"
function yy_r15()
{
$this->_retvalue = self::parse_tripple_double_quoted_string($this->yystack[ $this->yyidx + -1 ]->minor);
}
#line 308 "../smarty/lexer/smarty_internal_configfileparser.y"
// line 308 "../smarty/lexer/smarty_internal_configfileparser.y"
function yy_r16()
{
$this->_retvalue = '';
}
#line 312 "../smarty/lexer/smarty_internal_configfileparser.y"
// line 312 "../smarty/lexer/smarty_internal_configfileparser.y"
function yy_r17()
{
$this->_retvalue = $this->yystack[ $this->yyidx + 0 ]->minor;
}
#line 316 "../smarty/lexer/smarty_internal_configfileparser.y"
// line 316 "../smarty/lexer/smarty_internal_configfileparser.y"
public function yy_reduce($yyruleno)
{
if ($this->yyTraceFILE && $yyruleno >= 0
&& $yyruleno < count(self::$yyRuleName)) {
fprintf($this->yyTraceFILE,
&& $yyruleno < count(self::$yyRuleName)
) {
fprintf(
$this->yyTraceFILE,
"%sReduce (%d) [%s].\n",
$this->yyTracePrompt,
$yyruleno,
self::$yyRuleName[ $yyruleno ]);
self::$yyRuleName[ $yyruleno ]
);
}
$this->_retvalue = $yy_lefthand_side = null;
if (isset(self::$yyReduceMap[ $yyruleno ])) {
@@ -803,7 +824,7 @@ class Smarty_Internal_Configfileparser
}
}
#line 320 "../smarty/lexer/smarty_internal_configfileparser.y"
// line 320 "../smarty/lexer/smarty_internal_configfileparser.y"
public function yy_parse_failed()
{
if ($this->yyTraceFILE) {
@@ -814,10 +835,10 @@ class Smarty_Internal_Configfileparser
}
}
#line 324 "../smarty/lexer/smarty_internal_configfileparser.y"
// line 324 "../smarty/lexer/smarty_internal_configfileparser.y"
public function yy_syntax_error($yymajor, $TOKEN)
{
#line 232 "../smarty/lexer/smarty_internal_configfileparser.y"
// line 232 "../smarty/lexer/smarty_internal_configfileparser.y"
$this->internalError = true;
$this->yymajor = $yymajor;
$this->compiler->trigger_config_file_error();
@@ -831,7 +852,7 @@ class Smarty_Internal_Configfileparser
while ($this->yyidx >= 0) {
$this->yy_pop_parser_stack();
}
#line 225 "../smarty/lexer/smarty_internal_configfileparser.y"
// line 225 "../smarty/lexer/smarty_internal_configfileparser.y"
$this->successful = !$this->internalError;
$this->internalError = false;
$this->retvalue = $this->_retvalue;
@@ -851,15 +872,18 @@ class Smarty_Internal_Configfileparser
}
$yyendofinput = ($yymajor == 0);
if ($this->yyTraceFILE) {
fprintf($this->yyTraceFILE,
fprintf(
$this->yyTraceFILE,
"%sInput %s\n",
$this->yyTracePrompt,
$this->yyTokenName[ $yymajor ]);
$this->yyTokenName[ $yymajor ]
);
}
do {
$yyact = $this->yy_find_shift_action($yymajor);
if ($yymajor < self::YYERRORSYMBOL &&
!$this->yy_is_expected_token($yymajor)) {
if ($yymajor < self::YYERRORSYMBOL
&& !$this->yy_is_expected_token($yymajor)
) {
// force a syntax error
$yyact = self::YY_ERROR_ACTION;
}
@@ -875,9 +899,11 @@ class Smarty_Internal_Configfileparser
$this->yy_reduce($yyact - self::YYNSTATE);
} else if ($yyact === self::YY_ERROR_ACTION) {
if ($this->yyTraceFILE) {
fprintf($this->yyTraceFILE,
fprintf(
$this->yyTraceFILE,
"%sSyntax Error!\n",
$this->yyTracePrompt);
$this->yyTracePrompt
);
}
if (self::YYERRORSYMBOL) {
if ($this->yyerrcnt < 0) {
@@ -886,10 +912,12 @@ class Smarty_Internal_Configfileparser
$yymx = $this->yystack[ $this->yyidx ]->major;
if ($yymx === self::YYERRORSYMBOL || $yyerrorhit) {
if ($this->yyTraceFILE) {
fprintf($this->yyTraceFILE,
fprintf(
$this->yyTraceFILE,
"%sDiscard input token %s\n",
$this->yyTracePrompt,
$this->yyTokenName[ $yymajor ]);
$this->yyTokenName[ $yymajor ]
);
}
$this->yy_destructor($yymajor, $yytokenvalue);
$yymajor = self::YYNOCODE;

View File

@@ -103,7 +103,11 @@ abstract class Smarty_Internal_Data
} else {
if ($tpl_var !== '') {
if ($this->_objType === 2) {
/** @var Smarty_Internal_Template $this */
/**
*
*
* @var Smarty_Internal_Template $this
*/
$this->_assignInScope($tpl_var, $value, $nocache);
} else {
$this->tpl_vars[ $tpl_var ] = new Smarty_Variable($value, $nocache);
@@ -203,8 +207,8 @@ abstract class Smarty_Internal_Data
* @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)
{
$error_enable = true
) {
return $this->ext->getTemplateVars->_getVariable($this, $variable, $_ptr, $searchParents, $error_enable);
}

View File

@@ -3,7 +3,6 @@
/**
* Smarty error handler
*
*
* @package Smarty
* @subpackage PluginsInternal
* @author Uwe Tews
@@ -98,12 +97,14 @@ class Smarty_Internal_ErrorHandler
// or the error was within smarty but masked to be ignored
if (!$_is_muted_directory || ($errno && $errno & error_reporting())) {
if (self::$previousErrorHandler) {
return call_user_func(self::$previousErrorHandler,
return call_user_func(
self::$previousErrorHandler,
$errno,
$errstr,
$errfile,
$errline,
$errcontext);
$errcontext
);
} else {
return false;
}

View File

@@ -5,7 +5,6 @@
*
* Load extensions dynamically
*
*
* @package Smarty
* @subpackage PluginsInternal
* @author Uwe Tews
@@ -50,7 +49,7 @@ class Smarty_Internal_Extension_Handler
*/
private $_property_info = array('AutoloadFilters' => 0, 'DefaultModifiers' => 0, 'ConfigVars' => 0,
'DebugTemplate' => 0, 'RegisteredObject' => 0, 'StreamVariable' => 0,
'TemplateVars' => 0, 'Literals' => 'Literals',);#
'TemplateVars' => 0, 'Literals' => 'Literals',);//
private $resolvedProperties = array();
@@ -71,8 +70,9 @@ class Smarty_Internal_Extension_Handler
if (!isset($smarty->ext->$name)) {
if (preg_match('/^((set|get)|(.*?))([A-Z].*)$/', $name, $match)) {
$basename = $this->upperCase($match[4]);
if (!isset($smarty->ext->$basename) && isset($this->_property_info[ $basename ]) &&
is_string($this->_property_info[ $basename ])) {
if (!isset($smarty->ext->$basename) && isset($this->_property_info[ $basename ])
&& is_string($this->_property_info[ $basename ])
) {
$class = 'Smarty_Internal_Method_' . $this->_property_info[ $basename ];
if (class_exists($class)) {
$classObj = new $class();
@@ -90,12 +90,18 @@ class Smarty_Internal_Extension_Handler
if (!isset($this->resolvedProperties[ $match[0] ][ $objType ])) {
$property = isset($this->resolvedProperties['property'][ $basename ]) ?
$this->resolvedProperties['property'][ $basename ] :
$property = $this->resolvedProperties['property'][ $basename ] = strtolower(join('_',
preg_split('/([A-Z][^A-Z]*)/',
$property = $this->resolvedProperties['property'][ $basename ] = strtolower(
join(
'_',
preg_split(
'/([A-Z][^A-Z]*)/',
$basename,
-1,
PREG_SPLIT_NO_EMPTY |
PREG_SPLIT_DELIM_CAPTURE)));
PREG_SPLIT_DELIM_CAPTURE
)
)
);
if ($property !== false) {
if (property_exists($data, $property)) {

View File

@@ -18,10 +18,11 @@ class Smarty_Internal_Method_AddAutoloadFilters extends Smarty_Internal_Method_S
*
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
* @param array $filters filters to load automatically
* @param string $type "pre", "output", … specify the
* filter type to set. Defaults to
* none treating $filters' keys as
* the appropriate types
* @param string $type "pre", "output", … specify
* the filter type to set.
* Defaults to none treating
* $filters' keys as the
* appropriate types
*
* @return \Smarty|\Smarty_Internal_Template
* @throws \SmartyException

View File

@@ -52,8 +52,8 @@ class Smarty_Internal_Method_Append
$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');
}

View File

@@ -35,8 +35,8 @@ class Smarty_Internal_Method_ClearCache
* @throws \SmartyException
*/
public function clearCache(Smarty $smarty, $template_name, $cache_id = null, $compile_id = null, $exp_time = null,
$type = null)
{
$type = null
) {
$smarty->_clearTemplateCache();
// load cache resource and call clear
$_cache_resource = Smarty_CacheResource::load($smarty, $type);

View File

@@ -90,18 +90,20 @@ class Smarty_Internal_Method_ClearCompiledTemplate
continue;
}
$unlink = false;
if ((!isset($_compile_id) || (isset($_filepath[ $_compile_id_part_length ]) && $a =
!strncmp($_filepath, $_compile_id_part, $_compile_id_part_length))) &&
(!isset($resource_name) || (isset($_filepath[ $_resource_part_1_length ]) &&
substr_compare($_filepath,
if ((!isset($_compile_id) || (isset($_filepath[ $_compile_id_part_length ]) && $a =!strncmp($_filepath, $_compile_id_part, $_compile_id_part_length)))
&& (!isset($resource_name) || (isset($_filepath[ $_resource_part_1_length ])
&& substr_compare(
$_filepath,
$_resource_part_1,
-$_resource_part_1_length,
$_resource_part_1_length) ===
0) || (isset($_filepath[ $_resource_part_2_length ]) &&
substr_compare($_filepath,
$_resource_part_1_length
) ===0) || (isset($_filepath[ $_resource_part_2_length ])
&& substr_compare(
$_filepath,
$_resource_part_2,
-$_resource_part_2_length,
$_resource_part_2_length) === 0))
$_resource_part_2_length
) === 0))
) {
if (isset($exp_time)) {
if (is_file($_filepath) && time() - filemtime($_filepath) >= $exp_time) {

View File

@@ -26,8 +26,8 @@ class Smarty_Internal_Method_CompileAllConfig extends Smarty_Internal_Method_Com
* @return int number of template files recompiled
*/
public function compileAllConfig(Smarty $smarty, $extension = '.conf', $force_compile = false, $time_limit = 0,
$max_errors = null)
{
$max_errors = null
) {
return $this->compileAll($smarty, $extension, $force_compile, $time_limit, $max_errors, true);
}
}

View File

@@ -34,8 +34,8 @@ class Smarty_Internal_Method_CompileAllTemplates
$extension = '.tpl',
$force_compile = false,
$time_limit = 0,
$max_errors = null)
{
$max_errors = null
) {
return $this->compileAll($smarty, $extension, $force_compile, $time_limit, $max_errors);
}
@@ -56,8 +56,8 @@ class Smarty_Internal_Method_CompileAllTemplates
$force_compile,
$time_limit,
$max_errors,
$isConfig = false)
{
$isConfig = false
) {
// switch off time limit
if (function_exists('set_time_limit')) {
@set_time_limit($time_limit);
@@ -67,8 +67,10 @@ class Smarty_Internal_Method_CompileAllTemplates
$sourceDir = $isConfig ? $smarty->getConfigDir() : $smarty->getTemplateDir();
// loop over array of source directories
foreach ($sourceDir as $_dir) {
$_dir_1 = new RecursiveDirectoryIterator($_dir, defined('FilesystemIterator::FOLLOW_SYMLINKS') ?
FilesystemIterator::FOLLOW_SYMLINKS : 0);
$_dir_1 = new RecursiveDirectoryIterator(
$_dir, defined('FilesystemIterator::FOLLOW_SYMLINKS') ?
FilesystemIterator::FOLLOW_SYMLINKS : 0
);
$_dir_2 = new RecursiveIteratorIterator($_dir_1);
foreach ($_dir_2 as $_fileinfo) {
$_file = $_fileinfo->getFilename();

View File

@@ -48,6 +48,7 @@ class Smarty_Internal_Method_ConfigLoad
* @param string $config_file filename
* @param mixed $sections array of section names, single
* section or null
* @param int $scope scope into which config variables
* shall be loaded
*
@@ -76,7 +77,6 @@ class Smarty_Internal_Method_ConfigLoad
*
* @param \Smarty_Internal_Template $tpl
* @param array $new_config_vars
*
*/
public function _loadConfigVars(Smarty_Internal_Template $tpl, $new_config_vars)
{

View File

@@ -32,8 +32,8 @@ class Smarty_Internal_Method_GetTemplateVars
* @return mixed variable value or or array of variables
*/
public function getTemplateVars(Smarty_Internal_Data $data, $varName = null, Smarty_Internal_Data $_ptr = null,
$searchParents = true)
{
$searchParents = true
) {
if (isset($varName)) {
$_var = $this->_getVariable($data, $varName, $_ptr, $searchParents, false);
if (is_object($_var)) {
@@ -82,8 +82,8 @@ class Smarty_Internal_Method_GetTemplateVars
* @return \Smarty_Variable
*/
public function _getVariable(Smarty_Internal_Data $data, $varName, Smarty_Internal_Data $_ptr = null,
$searchParents = true, $errorEnable = true)
{
$searchParents = true, $errorEnable = true
) {
if ($_ptr === null) {
$_ptr = $data;
}

View File

@@ -40,7 +40,7 @@ class Smarty_Internal_Method_Literals
*
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
* @param array|string $literals literal or list of literals
* to add
* to addto add
*
* @return \Smarty|\Smarty_Internal_Template
* @throws \SmartyException
@@ -60,7 +60,7 @@ class Smarty_Internal_Method_Literals
*
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
* @param array|string $literals literal or list of literals
* to set
* to setto set
*
* @return \Smarty|\Smarty_Internal_Template
* @throws \SmartyException
@@ -90,8 +90,10 @@ class Smarty_Internal_Method_Literals
$error = isset($literals[ $smarty->left_delimiter ]) ? array($smarty->left_delimiter) : array();
$error = isset($literals[ $smarty->right_delimiter ]) ? $error[] = $smarty->right_delimiter : $error;
if (!empty($error)) {
throw new SmartyException('User defined literal(s) "' . $error .
'" may not be identical with left or right delimiter');
throw new SmartyException(
'User defined literal(s) "' . $error .
'" may not be identical with left or right delimiter'
);
}
$smarty->literals = array_merge((array)$smarty->literals, (array)$literals);
}

View File

@@ -50,7 +50,7 @@ class Smarty_Internal_Method_LoadPlugin
} else {
if (is_file($file)) {
$this->plugin_files[ $file ] = $file;
require_once($file);
include_once $file;
return $file;
} else {
$this->plugin_files[ $file ] = false;
@@ -87,7 +87,7 @@ class Smarty_Internal_Method_LoadPlugin
$file = $_plugin_dir . $name;
if (is_file($file)) {
$this->plugin_files[ 'plugins_dir' ][ $_lower_filename ] = $file;
require_once($file);
include_once $file;
return $file;
}
$this->plugin_files[ 'plugins_dir' ][ $_lower_filename ] = false;
@@ -100,7 +100,7 @@ class Smarty_Internal_Method_LoadPlugin
$file = $smarty->ext->_getIncludePath->getIncludePath($_p_dirs, $_file_name, $smarty);
$this->plugin_files[ 'include_path' ][ $_lower_filename ] = $file;
if ($file !== false) {
require_once($file);
include_once $file;
return $file;
}
}

View File

@@ -31,8 +31,8 @@ class Smarty_Internal_Method_RegisterCacheResource
* @return \Smarty|\Smarty_Internal_Template
*/
public function registerCacheResource(Smarty_Internal_TemplateBase $obj, $name,
Smarty_CacheResource $resource_handler)
{
Smarty_CacheResource $resource_handler
) {
$smarty = $obj->_getSmartyObj();
$smarty->registered_cache_resources[ $name ] = $resource_handler;
return $obj;

View File

@@ -55,16 +55,20 @@ class Smarty_Internal_Method_RegisterDefaultTemplateHandler
$default_handler = $source->smarty->default_template_handler_func;
}
$_content = $_timestamp = null;
$_return = call_user_func_array($default_handler,
array($source->type, $source->name, &$_content, &$_timestamp, $source->smarty));
$_return = call_user_func_array(
$default_handler,
array($source->type, $source->name, &$_content, &$_timestamp, $source->smarty)
);
if (is_string($_return)) {
$source->exists = is_file($_return);
if ($source->exists) {
$source->timestamp = filemtime($_return);
} else {
throw new SmartyException('Default handler: Unable to load ' .
throw new SmartyException(
'Default handler: Unable to load ' .
($source->isConfig ? 'config' : 'template') .
" default file '{$_return}' for '{$source->type}:{$source->name}'");
" default file '{$_return}' for '{$source->type}:{$source->name}'"
);
}
$source->name = $source->filepath = $_return;
$source->uid = sha1($source->filepath);
@@ -75,8 +79,10 @@ class Smarty_Internal_Method_RegisterDefaultTemplateHandler
$source->handler = Smarty_Resource::load($source->smarty, 'eval');
} else {
$source->exists = false;
throw new SmartyException('Default handler: No ' . ($source->isConfig ? 'config' : 'template') .
" default content for '{$source->type}:{$source->name}'");
throw new SmartyException(
'Default handler: No ' . ($source->isConfig ? 'config' : 'template') .
" default content for '{$source->type}:{$source->name}'"
);
}
}
}

View File

@@ -28,16 +28,23 @@ class Smarty_Internal_Method_RegisterObject
* @param string $object_name
* @param object $object the
* referenced
* PHP object to
* PHP
* object
* to
* register
*
* @param array $allowed_methods_properties list of
* allowed
* methods
* (empty = all)
* (empty
* = all)
*
* @param bool $format smarty
* argument
* format, else
* format,
* else
* traditional
*
* @param array $block_methods list of
* block-methods
*
@@ -45,8 +52,8 @@ class Smarty_Internal_Method_RegisterObject
* @throws \SmartyException
*/
public function registerObject(Smarty_Internal_TemplateBase $obj, $object_name, $object,
$allowed_methods_properties = array(), $format = true, $block_methods = array())
{
$allowed_methods_properties = array(), $format = true, $block_methods = array()
) {
$smarty = $obj->_getSmartyObj();
// test if allowed methods callable
if (!empty($allowed_methods_properties)) {

View File

@@ -30,14 +30,15 @@ class Smarty_Internal_Method_RegisterPlugin
* @param callback $callback PHP callback to register
* @param bool $cacheable if true (default) this
* function is cache able
* @param mixed $cache_attr caching attributes if any
*
* @return \Smarty|\Smarty_Internal_Template
* @throws SmartyException when the plugin tag is invalid
*/
public function registerPlugin(Smarty_Internal_TemplateBase $obj, $type, $name, $callback, $cacheable = true,
$cache_attr = null)
{
$cache_attr = null
) {
$smarty = $obj->_getSmartyObj();
if (isset($smarty->registered_plugins[ $type ][ $name ])) {
throw new SmartyException("Plugin tag '{$name}' already registered");

View File

@@ -27,9 +27,11 @@ class Smarty_Internal_Method_RegisterResource
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
* @param string $name name of resource type
* @param Smarty_Resource|array $resource_handler or instance of
* Smarty_Resource, or
* array of callbacks to
* handle resource
* Smarty_Resource,
* or array of
* callbacks to
* handle
* resource
* (deprecated)
*
* @return \Smarty|\Smarty_Internal_Template

View File

@@ -32,10 +32,11 @@ class Smarty_Internal_Method_SetAutoloadFilters
*
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
* @param array $filters filters to load automatically
* @param string $type "pre", "output", … specify the
* filter type to set. Defaults to
* none treating $filters' keys as
* the appropriate types
* @param string $type "pre", "output", … specify
* the filter type to set.
* Defaults to none treating
* $filters' keys as the
* appropriate types
*
* @return \Smarty|\Smarty_Internal_Template
* @throws \SmartyException

View File

@@ -32,7 +32,7 @@ class Smarty_Internal_Method_UnloadFilter extends Smarty_Internal_Method_LoadFil
if (isset($smarty->registered_filters[ $type ])) {
$_filter_name = "smarty_{$type}filter_{$name}";
if (isset($smarty->registered_filters[ $type ][ $_filter_name ])) {
unset ($smarty->registered_filters[ $type ][ $_filter_name ]);
unset($smarty->registered_filters[ $type ][ $_filter_name ]);
if (empty($smarty->registered_filters[ $type ])) {
unset($smarty->registered_filters[ $type ]);
}

View File

@@ -40,17 +40,21 @@ class Smarty_Internal_ParseTree_Dq extends Smarty_Internal_ParseTree
public function append_subtree(Smarty_Internal_Templateparser $parser, Smarty_Internal_ParseTree $subtree)
{
$last_subtree = count($this->subtrees) - 1;
if ($last_subtree >= 0 && $this->subtrees[ $last_subtree ] instanceof Smarty_Internal_ParseTree_Tag &&
$this->subtrees[ $last_subtree ]->saved_block_nesting < $parser->block_nesting_level
if ($last_subtree >= 0 && $this->subtrees[ $last_subtree ] instanceof Smarty_Internal_ParseTree_Tag
&& $this->subtrees[ $last_subtree ]->saved_block_nesting < $parser->block_nesting_level
) {
if ($subtree instanceof Smarty_Internal_ParseTree_Code) {
$this->subtrees[ $last_subtree ]->data =
$parser->compiler->appendCode($this->subtrees[ $last_subtree ]->data,
'<?php echo ' . $subtree->data . ';?>');
$parser->compiler->appendCode(
$this->subtrees[ $last_subtree ]->data,
'<?php echo ' . $subtree->data . ';?>'
);
} elseif ($subtree instanceof Smarty_Internal_ParseTree_DqContent) {
$this->subtrees[ $last_subtree ]->data =
$parser->compiler->appendCode($this->subtrees[ $last_subtree ]->data,
'<?php echo "' . $subtree->data . '";?>');
$parser->compiler->appendCode(
$this->subtrees[ $last_subtree ]->data,
'<?php echo "' . $subtree->data . '";?>'
);
} else {
$this->subtrees[ $last_subtree ]->data =
$parser->compiler->appendCode($this->subtrees[ $last_subtree ]->data, $subtree->data);

View File

@@ -28,7 +28,6 @@ class Smarty_Internal_ParseTree_Template extends Smarty_Internal_ParseTree
/**
* Create root of parse tree for template elements
*
*/
public function __construct()
{
@@ -101,8 +100,10 @@ class Smarty_Internal_ParseTree_Template extends Smarty_Internal_ParseTree
if ($subtree === '') {
continue;
}
$code .= preg_replace('/((<%)|(%>)|(<\?php)|(<\?)|(\?>)|(<\/?script))/', "<?php echo '\$1'; ?>\n",
$subtree);
$code .= preg_replace(
'/((<%)|(%>)|(<\?php)|(<\?)|(\?>)|(<\/?script))/', "<?php echo '\$1'; ?>\n",
$subtree
);
continue;
}
if ($this->subtrees[ $key ] instanceof Smarty_Internal_ParseTree_Tag) {

View File

@@ -35,11 +35,11 @@ class Smarty_Internal_Resource_File extends Smarty_Resource
return is_file($file) ? $file : false;
}
// go relative to a given template?
if ($file[ 0 ] === '.' && $_template && $_template->_isSubTpl() &&
preg_match('#^[.]{1,2}[\\\/]#', $file)
if ($file[ 0 ] === '.' && $_template && $_template->_isSubTpl()
&& preg_match('#^[.]{1,2}[\\\/]#', $file)
) {
if ($_template->parent->source->type !== 'file' && $_template->parent->source->type !== 'extends' &&
!isset($_template->parent->_cache[ 'allow_relative_path' ])
if ($_template->parent->source->type !== 'file' && $_template->parent->source->type !== 'extends'
&& !isset($_template->parent->_cache[ 'allow_relative_path' ])
) {
throw new SmartyException("Template '{$file}' cannot be relative to template of resource type '{$_template->parent->source->type}'");
}
@@ -124,8 +124,10 @@ class Smarty_Internal_Resource_File extends Smarty_Resource
$source->smarty->security_policy->isTrustedResourceDir($source->filepath, $source->isConfig);
}
$source->exists = true;
$source->uid = sha1($source->filepath . ($source->isConfig ? $source->smarty->_joined_config_dir :
$source->smarty->_joined_template_dir));
$source->uid = sha1(
$source->filepath . ($source->isConfig ? $source->smarty->_joined_config_dir :
$source->smarty->_joined_template_dir)
);
$source->timestamp = filemtime($source->filepath);
} else {
$source->timestamp = $source->exists = false;
@@ -160,8 +162,10 @@ class Smarty_Internal_Resource_File extends Smarty_Resource
if ($source->exists) {
return file_get_contents($source->filepath);
}
throw new SmartyException('Unable to read ' . ($source->isConfig ? 'config' : 'template') .
" {$source->type} '{$source->name}'");
throw new SmartyException(
'Unable to read ' . ($source->isConfig ? 'config' : 'template') .
" {$source->type} '{$source->name}'"
);
}
/**

View File

@@ -88,8 +88,10 @@ class Smarty_Internal_Resource_Php extends Smarty_Internal_Resource_File
throw new SmartyException('PHP templates are disabled');
}
if (!$source->exists) {
throw new SmartyException("Unable to load template '{$source->type}:{$source->name}'" .
($_template->_isSubTpl() ? " in '{$_template->parent->template_resource}'" : ''));
throw new SmartyException(
"Unable to load template '{$source->type}:{$source->name}'" .
($_template->_isSubTpl() ? " in '{$_template->parent->template_resource}'" : '')
);
}
// prepare variables
@@ -99,11 +101,14 @@ class Smarty_Internal_Resource_Php extends Smarty_Internal_Resource_File
if (function_exists('ini_set')) {
ini_set('short_open_tag', '1');
}
/** @var Smarty_Internal_Template $_smarty_template
/**
*
*
* @var Smarty_Internal_Template $_smarty_template
* used in included file
*/
$_smarty_template = $_template;
include($source->filepath);
include $source->filepath;
if (function_exists('ini_set')) {
ini_set('short_open_tag', $this->short_open_tag);
}

View File

@@ -58,8 +58,10 @@ class Smarty_Internal_Resource_Registered extends Smarty_Resource
{
// return timestamp
$time_stamp = false;
call_user_func_array($source->smarty->registered_resources[ $source->type ][ 0 ][ 1 ],
array($source->name, &$time_stamp, $source->smarty));
call_user_func_array(
$source->smarty->registered_resources[ $source->type ][ 0 ][ 1 ],
array($source->name, &$time_stamp, $source->smarty)
);
return is_numeric($time_stamp) ? (int) $time_stamp : $time_stamp;
}
@@ -76,8 +78,10 @@ class Smarty_Internal_Resource_Registered extends Smarty_Resource
{
// return template string
$content = null;
$t = call_user_func_array($source->smarty->registered_resources[ $source->type ][ 0 ][ 0 ],
array($source->name, &$content, $source->smarty));
$t = call_user_func_array(
$source->smarty->registered_resources[ $source->type ][ 0 ][ 0 ],
array($source->name, &$content, $source->smarty)
);
if (is_bool($t) && !$t) {
throw new SmartyException("Unable to read template {$source->type} '{$source->name}'");
}

View File

@@ -6,7 +6,6 @@
* @package Smarty
* @subpackage PluginsInternal
* @author Uwe Tews
*
**/
class Smarty_Internal_Runtime_CacheModify
{
@@ -34,7 +33,7 @@ class Smarty_Internal_Runtime_CacheModify
break;
case 'cli':
if ( /* ^phpunit */
if (/* ^phpunit */
!empty($_SERVER[ 'SMARTY_PHPUNIT_DISABLE_HEADERS' ]) /* phpunit$ */
) {
$_SERVER[ 'SMARTY_PHPUNIT_HEADERS' ][] = '304 Not Modified';
@@ -42,7 +41,7 @@ class Smarty_Internal_Runtime_CacheModify
break;
default:
if ( /* ^phpunit */
if (/* ^phpunit */
!empty($_SERVER[ 'SMARTY_PHPUNIT_DISABLE_HEADERS' ]) /* phpunit$ */
) {
$_SERVER[ 'SMARTY_PHPUNIT_HEADERS' ][] = '304 Not Modified';
@@ -54,7 +53,7 @@ class Smarty_Internal_Runtime_CacheModify
} else {
switch (PHP_SAPI) {
case 'cli':
if ( /* ^phpunit */
if (/* ^phpunit */
!empty($_SERVER[ 'SMARTY_PHPUNIT_DISABLE_HEADERS' ]) /* phpunit$ */
) {
$_SERVER[ 'SMARTY_PHPUNIT_HEADERS' ][] =

View File

@@ -88,8 +88,8 @@ class Smarty_Internal_Runtime_CacheResourceFile
}
}
// 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;
}

View File

@@ -26,8 +26,8 @@ class Smarty_Internal_Runtime_CodeFrame
* @return string
*/
public function create(Smarty_Internal_Template $_template, $content = '', $functions = '', $cache = false,
Smarty_Internal_TemplateCompilerBase $compiler = null)
{
Smarty_Internal_TemplateCompilerBase $compiler = null
) {
// build property code
$properties[ 'version' ] = Smarty::SMARTY_VERSION;
$properties[ 'unifunc' ] = 'content_' . str_replace(array('.', ','), '_', uniqid('', true));
@@ -42,7 +42,7 @@ class Smarty_Internal_Runtime_CodeFrame
}
$output = "<?php\n";
$output .= "/* Smarty version {$properties[ 'version' ]}, created on " . strftime("%Y-%m-%d %H:%M:%S") .
"\n from '" . str_replace('*/','* /',$_template->source->filepath) . "' */\n\n";
"\n from '" . str_replace('*/', '* /', $_template->source->filepath) . "' */\n\n";
$output .= "/* @var Smarty_Internal_Template \$_smarty_tpl */\n";
$dec = "\$_smarty_tpl->_decodeProperties(\$_smarty_tpl, " . var_export($properties, true) . ',' .
($cache ? 'true' : 'false') . ')';
@@ -65,11 +65,15 @@ class Smarty_Internal_Runtime_CodeFrame
$output .= "<?php }\n";
// remove unneeded PHP tags
if (preg_match('/\s*\?>[\n]?<\?php\s*/', $output)) {
$curr_split = preg_split('/\s*\?>[\n]?<\?php\s*/',
$output);
preg_match_all('/\s*\?>[\n]?<\?php\s*/',
$curr_split = preg_split(
'/\s*\?>[\n]?<\?php\s*/',
$output
);
preg_match_all(
'/\s*\?>[\n]?<\?php\s*/',
$output,
$curr_parts);
$curr_parts
);
$output = '';
foreach ($curr_split as $idx => $curr_output) {
$output .= $curr_output;
@@ -79,8 +83,10 @@ class Smarty_Internal_Runtime_CodeFrame
}
}
if (preg_match('/\?>\s*$/', $output)) {
$curr_split = preg_split('/\?>\s*$/',
$output);
$curr_split = preg_split(
'/\?>\s*$/',
$output
);
$output = '';
foreach ($curr_split as $idx => $curr_output) {
$output .= $curr_output;

View File

@@ -6,7 +6,6 @@
* @package Smarty
* @subpackage PluginsInternal
* @author Uwe Tews
*
*/
class Smarty_Internal_Runtime_Foreach
{
@@ -35,8 +34,8 @@ class Smarty_Internal_Runtime_Foreach
* @return mixed $from
*/
public function init(Smarty_Internal_Template $tpl, $from, $item, $needTotal = false, $key = null, $name = null,
$properties = array())
{
$properties = array()
) {
$needTotal = $needTotal || isset($properties[ 'total' ]);
$saveVars = array();
$total = null;
@@ -97,7 +96,6 @@ class Smarty_Internal_Runtime_Foreach
}
/**
*
* [util function] counts an array, arrayAccess/traversable or PDOStatement object
*
* @param mixed $value

View File

@@ -109,13 +109,11 @@ class Smarty_Internal_Runtime_GetIncludePath
* @param \Smarty $smarty
*
* @return bool|string full filepath or false
*
*/
public function getIncludePath($dirs, $file, Smarty $smarty)
{
//if (!(isset($this->_has_stream_include) ? $this->_has_stream_include : $this->_has_stream_include = false)) {
if (!(isset($this->_has_stream_include) ? $this->_has_stream_include :
$this->_has_stream_include = function_exists('stream_resolve_include_path'))
if (!(isset($this->_has_stream_include) ? $this->_has_stream_include : $this->_has_stream_include = function_exists('stream_resolve_include_path'))
) {
$this->isNewIncludePath($smarty);
}

View File

@@ -6,7 +6,6 @@
* @package Smarty
* @subpackage PluginsInternal
* @author Uwe Tews
*
**/
class Smarty_Internal_Runtime_Inheritance
{
@@ -64,7 +63,6 @@ class Smarty_Internal_Runtime_Inheritance
* @param \Smarty_Internal_Template $tpl template object of caller
* @param bool $initChild if true init for child template
* @param array $blockNames outer level block name
*
*/
public function init(Smarty_Internal_Template $tpl, $initChild, $blockNames = array())
{
@@ -113,9 +111,11 @@ class Smarty_Internal_Runtime_Inheritance
ob_end_clean();
$this->state = 2;
}
if (isset($template) && (($tpl->parent->_isTplObj() && $tpl->parent->source->type !== 'extends') ||
$tpl->smarty->extends_recursion)) {
$tpl->_subTemplateRender($template,
if (isset($template) && (($tpl->parent->_isTplObj() && $tpl->parent->source->type !== 'extends')
|| $tpl->smarty->extends_recursion)
) {
$tpl->_subTemplateRender(
$template,
$tpl->cache_id,
$tpl->compile_id,
$tpl->caching ? 9999 : 0,
@@ -124,7 +124,8 @@ class Smarty_Internal_Runtime_Inheritance
2,
false,
$uid,
$func);
$func
);
}
}
@@ -167,8 +168,8 @@ class Smarty_Internal_Runtime_Inheritance
* @throws \SmartyException
*/
public function process(Smarty_Internal_Template $tpl, Smarty_Internal_Block $block,
Smarty_Internal_Block $parent = null)
{
Smarty_Internal_Block $parent = null
) {
if ($block->hide && !isset($block->child)) {
return;
}
@@ -187,8 +188,8 @@ class Smarty_Internal_Runtime_Inheritance
if ($block->prepend && isset($parent)) {
$this->callParent($tpl, $block, '{block prepend}');
if ($block->append) {
if ($block->callsChild || !isset($block->child) ||
($block->child->hide && !isset($block->child->child))
if ($block->callsChild || !isset($block->child)
|| ($block->child->hide && !isset($block->child->child))
) {
$this->callBlock($block, $tpl);
} else {

View File

@@ -6,7 +6,6 @@
* @package Smarty
* @subpackage PluginsInternal
* @author Uwe Tews
*
*/
class Smarty_Internal_Runtime_Make_Nocache
{

View File

@@ -6,7 +6,6 @@
* @package Smarty
* @subpackage PluginsInternal
* @author Uwe Tews
*
**/
class Smarty_Internal_Runtime_TplFunction
{
@@ -36,14 +35,14 @@ class Smarty_Internal_Runtime_TplFunction
}
if (function_exists($function)) {
$this->saveTemplateVariables($tpl, $name);
$function ($tpl, $params);
$function($tpl, $params);
$this->restoreTemplateVariables($tpl, $name);
return;
}
// try to load template function dynamically
if ($this->addTplFuncToCache($tpl, $name, $function)) {
$this->saveTemplateVariables($tpl, $name);
$function ($tpl, $params);
$function($tpl, $params);
$this->restoreTemplateVariables($tpl, $name);
return;
}
@@ -90,7 +89,6 @@ class Smarty_Internal_Runtime_TplFunction
}
/**
*
* Add template function to cache file for nocache calls
*
* @param Smarty_Internal_Template $tpl
@@ -126,11 +124,15 @@ class Smarty_Internal_Runtime_TplFunction
if (!preg_match("/'{$funcParam['uid']}'(.*?)'nocache_hash'/", $content, $match2)) {
$content = preg_replace("/('file_dependency'(.*?)\()/", "\\1{$match1[0]}", $content);
}
$tplPtr->smarty->ext->_updateCache->write($tplPtr,
$tplPtr->smarty->ext->_updateCache->write(
$tplPtr,
preg_replace('/\s*\?>\s*$/', "\n", $content) .
"\n" . preg_replace(array('/^\s*<\?php\s+/',
"\n" . preg_replace(
array('/^\s*<\?php\s+/',
'/\s*\?>\s*$/',), "\n",
$match[ 0 ]));
$match[ 0 ]
)
);
}
}
return true;

View File

@@ -6,7 +6,6 @@
* @package Smarty
* @subpackage PluginsInternal
* @author Uwe Tews
*
**/
class Smarty_Internal_Runtime_UpdateCache
{
@@ -67,8 +66,8 @@ class Smarty_Internal_Runtime_UpdateCache
*/
public function removeNoCacheHash(Smarty_Template_Cached $cached,
Smarty_Internal_Template $_template,
$no_output_filter)
{
$no_output_filter
) {
$php_pattern = '/(<%|%>|<\?php|<\?|\?>|<script\s+language\s*=\s*[\"\']?\s*php\s*[\"\']?\s*>)/';
$content = ob_get_clean();
$hash_array = $cached->hashes;
@@ -78,22 +77,30 @@ class Smarty_Internal_Runtime_UpdateCache
$_template->cached->has_nocache_code = false;
// get text between non-cached items
$cache_split =
preg_split("!/\*%%SmartyNocache:{$nocache_hash}%%\*\/(.+?)/\*/%%SmartyNocache:{$nocache_hash}%%\*/!s",
$content);
preg_split(
"!/\*%%SmartyNocache:{$nocache_hash}%%\*\/(.+?)/\*/%%SmartyNocache:{$nocache_hash}%%\*/!s",
$content
);
// get non-cached items
preg_match_all("!/\*%%SmartyNocache:{$nocache_hash}%%\*\/(.+?)/\*/%%SmartyNocache:{$nocache_hash}%%\*/!s",
preg_match_all(
"!/\*%%SmartyNocache:{$nocache_hash}%%\*\/(.+?)/\*/%%SmartyNocache:{$nocache_hash}%%\*/!s",
$content,
$cache_parts);
$cache_parts
);
$content = '';
// loop over items, stitch back together
foreach ($cache_split as $curr_idx => $curr_split) {
if (preg_match($php_pattern, $curr_split)) {
// escape PHP tags in template content
$php_split = preg_split($php_pattern,
$curr_split);
preg_match_all($php_pattern,
$php_split = preg_split(
$php_pattern,
$curr_split
);
preg_match_all(
$php_pattern,
$curr_split,
$php_parts);
$php_parts
);
foreach ($php_split as $idx_php => $curr_php) {
$content .= $curr_php;
if (isset($php_parts[ 0 ][ $idx_php ])) {
@@ -108,9 +115,9 @@ class Smarty_Internal_Runtime_UpdateCache
$content .= $cache_parts[ 2 ][ $curr_idx ];
}
}
if (!$no_output_filter && !$_template->cached->has_nocache_code &&
(isset($_template->smarty->autoload_filters[ 'output' ]) ||
isset($_template->smarty->registered_filters[ 'output' ]))
if (!$no_output_filter && !$_template->cached->has_nocache_code
&& (isset($_template->smarty->autoload_filters[ 'output' ])
|| isset($_template->smarty->registered_filters[ 'output' ]))
) {
$content = $_template->smarty->ext->_filterHandler->runFilter('output', $content, $_template);
}

View File

@@ -6,7 +6,6 @@
* @package Smarty
* @subpackage PluginsInternal
* @author Uwe Tews
*
**/
class Smarty_Internal_Runtime_UpdateScope
{
@@ -17,14 +16,14 @@ class Smarty_Internal_Runtime_UpdateScope
* @param Smarty_Internal_Template $tpl data object
* @param string|null $varName variable name
* @param int $tagScope tag scope to which bubble up variable value
*
*/
public function _updateScope(Smarty_Internal_Template $tpl, $varName, $tagScope = 0)
{
if ($tagScope) {
$this->_updateVarStack($tpl, $varName);
$tagScope = $tagScope & ~Smarty::SCOPE_LOCAL;
if (!$tpl->scope && !$tagScope) return;
if (!$tpl->scope && !$tagScope) { return;
}
}
$mergedScope = $tagScope | $tpl->scope;
if ($mergedScope) {
@@ -35,7 +34,8 @@ class Smarty_Internal_Runtime_UpdateScope
foreach ($this->_getAffectedScopes($tpl, $mergedScope) as $ptr) {
$this->_updateVariableInOtherScope($ptr->tpl_vars, $tpl, $varName);
if($tagScope && $ptr->_isTplObj() && isset($tpl->_cache[ 'varStack' ])) {
$this->_updateVarStack($ptr, $varName); }
$this->_updateVarStack($ptr, $varName);
}
}
}
}

View File

@@ -89,9 +89,15 @@ class Smarty_Internal_SmartyTemplateCompiler extends Smarty_Internal_TemplateCom
then written to compiled files. */
// init the lexer/parser to compile the template
$this->parser =
new $this->parser_class(new $this->lexer_class(str_replace(array("\r\n",
"\r"), "\n", $_content), $this),
$this);
new $this->parser_class(
new $this->lexer_class(
str_replace(
array("\r\n",
"\r"), "\n", $_content
), $this
),
$this
);
if ($isTemplateSource && $this->template->caching) {
$this->parser->insertPhpCode("<?php\n\$_smarty_tpl->compiled->nocache_hash = '{$this->nocache_hash}';\n?>\n");
}
@@ -127,8 +133,10 @@ class Smarty_Internal_SmartyTemplateCompiler extends Smarty_Internal_TemplateCom
if (count($this->_tag_stack) > 0) {
// get stacked info
list($openTag, $_data) = array_pop($this->_tag_stack);
$this->trigger_template_error("unclosed {$this->smarty->left_delimiter}" . $openTag .
"{$this->smarty->right_delimiter} tag");
$this->trigger_template_error(
"unclosed {$this->smarty->left_delimiter}" . $openTag .
"{$this->smarty->right_delimiter} tag"
);
}
// call post compile callbacks
foreach ($this->postCompileCallbacks as $cb) {
@@ -148,7 +156,6 @@ class Smarty_Internal_SmartyTemplateCompiler extends Smarty_Internal_TemplateCom
* @param array $parameter optional parameter array
* @param string $key optional key for callback
* @param bool $replace if true replace existing keyed callback
*
*/
public function registerPostCompileCallback($callback, $parameter = array(), $key = null, $replace = false)
{

View File

@@ -145,8 +145,8 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
*/
public function __construct($template_resource, Smarty $smarty, Smarty_Internal_Data $_parent = null,
$_cache_id = null, $_compile_id = null, $_caching = null, $_cache_lifetime = null,
$_isConfig = false)
{
$_isConfig = false
) {
$this->smarty = $smarty;
// Smarty parameter
$this->cache_id = $_cache_id === null ? $this->smarty->cache_id : $_cache_id;
@@ -184,8 +184,10 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
}
// checks if template exists
if (!$this->source->exists) {
throw new SmartyException("Unable to load template '{$this->source->type}:{$this->source->name}'" .
($this->_isSubTpl() ? " in '{$this->parent->template_resource}'" : ''));
throw new SmartyException(
"Unable to load template '{$this->source->type}:{$this->source->name}'" .
($this->_isSubTpl() ? " in '{$this->parent->template_resource}'" : '')
);
}
// disable caching for evaluated code
if ($this->source->handler->recompiled) {
@@ -193,8 +195,8 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
}
// read from cache or render
if ($this->caching === Smarty::CACHING_LIFETIME_CURRENT || $this->caching === Smarty::CACHING_LIFETIME_SAVED) {
if (!isset($this->cached) || $this->cached->cache_id !== $this->cache_id ||
$this->cached->compile_id !== $this->compile_id
if (!isset($this->cached) || $this->cached->cache_id !== $this->cache_id
|| $this->cached->compile_id !== $this->compile_id
) {
$this->loadCached(true);
}
@@ -209,12 +211,14 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
// display or fetch
if ($display) {
if ($this->caching && $this->smarty->cache_modified_check) {
$this->smarty->ext->_cacheModify->cacheModifiedCheck($this->cached, $this,
isset($content) ? $content : ob_get_clean());
$this->smarty->ext->_cacheModify->cacheModifiedCheck(
$this->cached, $this,
isset($content) ? $content : ob_get_clean()
);
} else {
if ((!$this->caching || $this->cached->has_nocache_code || $this->source->handler->recompiled) &&
!$no_output_filter && (isset($this->smarty->autoload_filters[ 'output' ]) ||
isset($this->smarty->registered_filters[ 'output' ]))
if ((!$this->caching || $this->cached->has_nocache_code || $this->source->handler->recompiled)
&& !$no_output_filter && (isset($this->smarty->autoload_filters[ 'output' ])
|| isset($this->smarty->registered_filters[ 'output' ]))
) {
echo $this->smarty->ext->_filterHandler->runFilter('output', ob_get_clean(), $this);
} else {
@@ -234,10 +238,10 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
$this->smarty->_debug->display_debug($this, true);
}
}
if (!$no_output_filter &&
(!$this->caching || $this->cached->has_nocache_code || $this->source->handler->recompiled) &&
(isset($this->smarty->autoload_filters[ 'output' ]) ||
isset($this->smarty->registered_filters[ 'output' ]))
if (!$no_output_filter
&& (!$this->caching || $this->cached->has_nocache_code || $this->source->handler->recompiled)
&& (isset($this->smarty->autoload_filters[ 'output' ])
|| isset($this->smarty->registered_filters[ 'output' ]))
) {
return $this->smarty->ext->_filterHandler->runFilter('output', ob_get_clean(), $this);
}
@@ -264,8 +268,8 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
* @throws \SmartyException
*/
public function _subTemplateRender($template, $cache_id, $compile_id, $caching, $cache_lifetime, $data, $scope,
$forceTplCache, $uid = null, $content_func = null)
{
$forceTplCache, $uid = null, $content_func = null
) {
$tpl = clone $this;
$tpl->parent = $this;
$smarty = &$this->smarty;
@@ -322,9 +326,9 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
$tpl->scope = $scope;
if (!isset(self::$tplObjCache[ $tpl->templateId ]) && !$tpl->source->handler->recompiled) {
// check if template object should be cached
if ($forceTplCache || (isset(self::$subTplInfo[ $tpl->template_resource ]) &&
self::$subTplInfo[ $tpl->template_resource ] > 1) ||
($tpl->_isSubTpl() && isset(self::$tplObjCache[ $tpl->parent->templateId ]))
if ($forceTplCache || (isset(self::$subTplInfo[ $tpl->template_resource ])
&& self::$subTplInfo[ $tpl->template_resource ] > 1)
|| ($tpl->_isSubTpl() && isset(self::$tplObjCache[ $tpl->parent->templateId ]))
) {
self::$tplObjCache[ $tpl->templateId ] = $tpl;
}
@@ -369,7 +373,6 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
/**
* Get called sub-templates and save call count
*
*/
public function _subTemplateRegister()
{
@@ -399,7 +402,6 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
* @param mixed $value value
* @param bool $nocache nocache flag
* @param int $scope scope into which variable shall be assigned
*
*/
public function _assignInScope($varName, $value, $nocache = false, $scope = 0)
{
@@ -426,14 +428,15 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
*
* @throws \SmartyException
*/
public function _checkPlugins($plugins) {
public function _checkPlugins($plugins)
{
static $checked = array();
foreach($plugins as $plugin) {
$name = join('::', (array)$plugin[ 'function' ]);
if (!isset($checked[$name])) {
if (!is_callable($plugin['function'])) {
if (is_file($plugin['file'])) {
require_once $plugin['file'];
include_once $plugin['file'];
if (is_callable($plugin['function'])) {
$checked[ $name ] = true;
}
@@ -476,8 +479,8 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
return false;
}
$is_valid = true;
if (!empty($properties[ 'file_dependency' ]) &&
((!$cache && $tpl->compile_check) || $tpl->compile_check === Smarty::COMPILECHECK_ON)
if (!empty($properties[ 'file_dependency' ])
&& ((!$cache && $tpl->compile_check) || $tpl->compile_check === Smarty::COMPILECHECK_ON)
) {
// check file dependencies at compiled code
foreach ($properties[ 'file_dependency' ] as $_file_to_check) {
@@ -507,8 +510,8 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
}
if ($cache) {
// CACHING_LIFETIME_SAVED cache expiry has to be validated here since otherwise we'd define the unifunc
if ($tpl->caching === Smarty::CACHING_LIFETIME_SAVED && $properties[ 'cache_lifetime' ] >= 0 &&
(time() > ($tpl->cached->timestamp + $properties[ 'cache_lifetime' ]))
if ($tpl->caching === Smarty::CACHING_LIFETIME_SAVED && $properties[ 'cache_lifetime' ] >= 0
&& (time() > ($tpl->cached->timestamp + $properties[ 'cache_lifetime' ]))
) {
$is_valid = false;
}
@@ -596,7 +599,6 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
/**
* Load inheritance object
*
*/
public function _loadInheritance()
{
@@ -607,7 +609,6 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
/**
* Unload inheritance object
*
*/
public function _cleanUp()
{
@@ -627,8 +628,10 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
$this->smarty->loadPlugin($this->source->compiler_class);
}
$this->compiler =
new $this->source->compiler_class($this->source->template_lexer_class, $this->source->template_parser_class,
$this->smarty);
new $this->source->compiler_class(
$this->source->template_lexer_class, $this->source->template_parser_class,
$this->smarty
);
}
/**

View File

@@ -329,10 +329,12 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data
* @throws \SmartyException
*/
public function registerObject($object_name, $object, $allowed_methods_properties = array(), $format = true,
$block_methods = array())
{
return $this->ext->registerObject->registerObject($this, $object_name, $object, $allowed_methods_properties,
$format, $block_methods);
$block_methods = array()
) {
return $this->ext->registerObject->registerObject(
$this, $object_name, $object, $allowed_methods_properties,
$format, $block_methods
);
}
/**

View File

@@ -324,10 +324,12 @@ abstract class Smarty_Internal_TemplateCompilerBase
public function __construct(Smarty $smarty)
{
$this->smarty = $smarty;
$this->nocache_hash = str_replace(array('.',
$this->nocache_hash = str_replace(
array('.',
','),
'_',
uniqid(rand(), true));
uniqid(rand(), true)
);
}
/**
@@ -342,17 +344,21 @@ abstract class Smarty_Internal_TemplateCompilerBase
*/
public function compileTemplate(Smarty_Internal_Template $template,
$nocache = null,
Smarty_Internal_TemplateCompilerBase $parent_compiler = null)
{
Smarty_Internal_TemplateCompilerBase $parent_compiler = null
) {
// get code frame of compiled template
$_compiled_code = $template->smarty->ext->_codeFrame->create($template,
$this->compileTemplateSource($template,
$_compiled_code = $template->smarty->ext->_codeFrame->create(
$template,
$this->compileTemplateSource(
$template,
$nocache,
$parent_compiler),
$parent_compiler
),
$this->postFilter($this->blockOrFunctionCode) .
join('', $this->mergedSubTemplatesCode),
false,
$this);
$this
);
return $_compiled_code;
}
@@ -368,8 +374,8 @@ abstract class Smarty_Internal_TemplateCompilerBase
*/
public function compileTemplateSource(Smarty_Internal_Template $template,
$nocache = null,
Smarty_Internal_TemplateCompilerBase $parent_compiler = null)
{
Smarty_Internal_TemplateCompilerBase $parent_compiler = null
) {
try {
// save template object in compiler class
$this->template = $template;
@@ -455,8 +461,8 @@ abstract class Smarty_Internal_TemplateCompilerBase
public function postFilter($code)
{
// run post filter if on code
if (!empty($code) &&
(isset($this->smarty->autoload_filters[ 'post' ]) || isset($this->smarty->registered_filters[ 'post' ]))
if (!empty($code)
&& (isset($this->smarty->autoload_filters[ 'post' ]) || isset($this->smarty->registered_filters[ 'post' ]))
) {
return $this->smarty->ext->_filterHandler->runFilter('post', $code, $this->template);
} else {
@@ -475,8 +481,8 @@ abstract class Smarty_Internal_TemplateCompilerBase
public function preFilter($_content)
{
// run pre filter if required
if ($_content !== '' &&
((isset($this->smarty->autoload_filters[ 'pre' ]) || isset($this->smarty->registered_filters[ 'pre' ])))
if ($_content !== ''
&& ((isset($this->smarty->autoload_filters[ 'pre' ]) || isset($this->smarty->registered_filters[ 'pre' ])))
) {
return $this->smarty->ext->_filterHandler->runFilter('pre', $_content, $this->template);
} else {
@@ -523,11 +529,13 @@ abstract class Smarty_Internal_TemplateCompilerBase
// not a variable variable
$var = trim($variable, '\'');
$this->tag_nocache = $this->tag_nocache |
$this->template->ext->getTemplateVars->_getVariable($this->template,
$this->template->ext->getTemplateVars->_getVariable(
$this->template,
$var,
null,
true,
false)->nocache;
false
)->nocache;
// todo $this->template->compiled->properties['variables'][$var] = $this->tag_nocache | $this->nocache;
}
return '$_smarty_tpl->tpl_vars[' . $variable . ']->value';
@@ -558,8 +566,8 @@ abstract class Smarty_Internal_TemplateCompilerBase
public function compilePHPFunctionCall($name, $parameter)
{
if (!$this->smarty->security_policy || $this->smarty->security_policy->isTrustedPhpFunction($name, $this)) {
if (strcasecmp($name, 'isset') === 0 || strcasecmp($name, 'empty') === 0 ||
strcasecmp($name, 'array') === 0 || is_callable($name)
if (strcasecmp($name, 'isset') === 0 || strcasecmp($name, 'empty') === 0
|| strcasecmp($name, 'array') === 0 || is_callable($name)
) {
$func_name = strtolower($name);
$par = implode(',', $parameter);
@@ -578,13 +586,16 @@ abstract class Smarty_Internal_TemplateCompilerBase
$isset_par = str_replace("')->value", "',null,true,false)->value", $par);
}
return $name . '(' . $isset_par . ')';
} else if (in_array($func_name,
} else if (in_array(
$func_name,
array('empty',
'reset',
'current',
'end',
'prev',
'next'))) {
'next')
)
) {
if (count($parameter) !== 1) {
$this->trigger_template_error("Illegal number of parameter in '{$func_name()}'");
}
@@ -625,8 +636,11 @@ abstract class Smarty_Internal_TemplateCompilerBase
if (strpos($text, '<') !== false) {
// capture html elements not to be messed with
$_offset = 0;
if (preg_match_all('#(<script[^>]*>.*?</script[^>]*>)|(<textarea[^>]*>.*?</textarea[^>]*>)|(<pre[^>]*>.*?</pre[^>]*>)#is',
$text, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) {
if (preg_match_all(
'#(<script[^>]*>.*?</script[^>]*>)|(<textarea[^>]*>.*?</textarea[^>]*>)|(<pre[^>]*>.*?</pre[^>]*>)#is',
$text, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER
)
) {
foreach ($matches as $match) {
$store[] = $match[ 0 ][ 0 ];
$_length = strlen($match[ 0 ][ 0 ]);
@@ -648,8 +662,11 @@ abstract class Smarty_Internal_TemplateCompilerBase
$text = preg_replace(array_keys($expressions), array_values($expressions), $text);
$_offset = 0;
if (preg_match_all('#@!@SMARTY:([0-9]+):SMARTY@!@#is', $text, $matches,
PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) {
if (preg_match_all(
'#@!@SMARTY:([0-9]+):SMARTY@!@#is', $text, $matches,
PREG_OFFSET_CAPTURE | PREG_SET_ORDER
)
) {
foreach ($matches as $match) {
$_length = strlen($match[ 0 ][ 0 ]);
$replace = $store[ $match[ 1 ][ 0 ] ];
@@ -710,8 +727,8 @@ abstract class Smarty_Internal_TemplateCompilerBase
$_tag = explode('_', $tag);
$_tag = array_map('ucfirst', $_tag);
$class_name = 'Smarty_Internal_Compile_' . implode('_', $_tag);
if (class_exists($class_name) &&
(!isset($this->smarty->security_policy) || $this->smarty->security_policy->isTrustedTag($tag, $this))
if (class_exists($class_name)
&& (!isset($this->smarty->security_policy) || $this->smarty->security_policy->isTrustedTag($tag, $this))
) {
self::$_tag_objects[ $tag ] = new $class_name;
} else {
@@ -801,13 +818,15 @@ abstract class Smarty_Internal_TemplateCompilerBase
$callback = null;
$script = null;
$cacheable = true;
$result = call_user_func_array($this->smarty->default_plugin_handler_func,
$result = call_user_func_array(
$this->smarty->default_plugin_handler_func,
array($tag,
$plugin_type,
$this->template,
&$callback,
&$script,
&$cacheable,));
&$cacheable,)
);
if ($result) {
$this->tag_nocache = $this->tag_nocache || !$cacheable;
if ($script !== null) {
@@ -823,7 +842,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
$this->required_plugins[ 'compiled' ][ $tag ][ $plugin_type ][ 'function' ] =
$callback;
}
require_once $script;
include_once $script;
} else {
$this->trigger_template_error("Default plugin handler: Returned script file '{$script}' for '{$tag}' not found");
}
@@ -875,8 +894,8 @@ abstract class Smarty_Internal_TemplateCompilerBase
// If the template is not evaluated and we have a nocache section and or a nocache tag
if ($is_code && !empty($content)) {
// generate replacement code
if ((!($this->template->source->handler->recompiled) || $this->forceNocache) && $this->caching &&
!$this->suppressNocacheProcessing && ($this->nocache || $this->tag_nocache)
if ((!($this->template->source->handler->recompiled) || $this->forceNocache) && $this->caching
&& !$this->suppressNocacheProcessing && ($this->nocache || $this->tag_nocache)
) {
$this->template->compiled->has_nocache_code = true;
$_output = addcslashes($content, '\'\\');
@@ -1015,14 +1034,21 @@ abstract class Smarty_Internal_TemplateCompilerBase
} else {
$line = (int)$line;
}
if (in_array($this->template->source->type,
if (in_array(
$this->template->source->type,
array('eval',
'string'))) {
$templateName = $this->template->source->type . ':' . trim(preg_replace('![\t\r\n]+!',
'string')
)
) {
$templateName = $this->template->source->type . ':' . trim(
preg_replace(
'![\t\r\n]+!',
' ',
strlen($lex->data) > 40 ?
substr($lex->data, 0, 40) .
'...' : $lex->data));
'...' : $lex->data
)
);
} else {
$templateName = $this->template->source->type . ':' . $this->template->source->filepath;
}
@@ -1104,11 +1130,13 @@ abstract class Smarty_Internal_TemplateCompilerBase
*/
public function replaceDelimiter($lexerPreg)
{
return str_replace(array('SMARTYldel', 'SMARTYliteral', 'SMARTYrdel', 'SMARTYautoliteral', 'SMARTYal'),
return str_replace(
array('SMARTYldel', 'SMARTYliteral', 'SMARTYrdel', 'SMARTYautoliteral', 'SMARTYal'),
array($this->ldelPreg, $this->literalPreg, $this->rdelPreg,
$this->smarty->getAutoLiteral() ? '{1,}' : '{9}',
$this->smarty->getAutoLiteral() ? '' : '\\s*'),
$lexerPreg);
$lexerPreg
);
}
/**
@@ -1153,9 +1181,11 @@ abstract class Smarty_Internal_TemplateCompilerBase
{
if (array_pop($this->_tag_stack_count) !== $this->getTagStackCount()) {
$tag = $this->getOpenBlockTag();
$this->trigger_template_error("unclosed '{{$tag}}' in doubled quoted string",
$this->trigger_template_error(
"unclosed '{{$tag}}' in doubled quoted string",
null,
true);
true
);
}
}
@@ -1395,9 +1425,9 @@ abstract class Smarty_Internal_TemplateCompilerBase
}
// compile the smarty tag (required compile classes to compile the tag are auto loaded)
if (($_output = $this->callTagCompiler($tag, $args, $parameter)) === false) {
if (isset($this->parent_compiler->tpl_function[ $tag ]) ||
(isset ($this->template->smarty->ext->_tplFunction) &&
$this->template->smarty->ext->_tplFunction->getTplFunction($this->template, $tag) !== false)
if (isset($this->parent_compiler->tpl_function[ $tag ])
|| (isset($this->template->smarty->ext->_tplFunction)
&& $this->template->smarty->ext->_tplFunction->getTplFunction($this->template, $tag) !== false)
) {
// template defined by {template} tag
$args[ '_attr' ][ 'name' ] = "'{$tag}'";
@@ -1428,23 +1458,27 @@ abstract class Smarty_Internal_TemplateCompilerBase
// check if tag is a registered object
if (isset($this->smarty->registered_objects[ $tag ]) && isset($parameter[ 'object_method' ])) {
$method = $parameter[ 'object_method' ];
if (!in_array($method, $this->smarty->registered_objects[ $tag ][ 3 ]) &&
(empty($this->smarty->registered_objects[ $tag ][ 1 ]) ||
in_array($method, $this->smarty->registered_objects[ $tag ][ 1 ]))
if (!in_array($method, $this->smarty->registered_objects[ $tag ][ 3 ])
&& (empty($this->smarty->registered_objects[ $tag ][ 1 ])
|| in_array($method, $this->smarty->registered_objects[ $tag ][ 1 ]))
) {
return $this->callTagCompiler('private_object_function', $args, $parameter, $tag, $method);
} else if (in_array($method, $this->smarty->registered_objects[ $tag ][ 3 ])) {
return $this->callTagCompiler('private_object_block_function',
return $this->callTagCompiler(
'private_object_block_function',
$args,
$parameter,
$tag,
$method);
$method
);
} else {
// throw exception
$this->trigger_template_error('not allowed method "' . $method . '" in registered object "' .
$this->trigger_template_error(
'not allowed method "' . $method . '" in registered object "' .
$tag . '"',
null,
true);
true
);
}
}
// check if tag is registered
@@ -1465,25 +1499,29 @@ abstract class Smarty_Internal_TemplateCompilerBase
if (!$this->smarty->registered_plugins[ $plugin_type ][ $tag ][ 1 ]) {
$this->tag_nocache = true;
}
return call_user_func_array($this->smarty->registered_plugins[ $plugin_type ][ $tag ][ 0 ],
return call_user_func_array(
$this->smarty->registered_plugins[ $plugin_type ][ $tag ][ 0 ],
array($new_args,
$this));
$this)
);
}
// compile registered function or block function
if ($plugin_type === Smarty::PLUGIN_FUNCTION || $plugin_type === Smarty::PLUGIN_BLOCK) {
return $this->callTagCompiler('private_registered_' . $plugin_type,
return $this->callTagCompiler(
'private_registered_' . $plugin_type,
$args,
$parameter,
$tag);
$tag
);
}
}
}
// check plugins from plugins folder
foreach ($this->plugin_search_order as $plugin_type) {
if ($plugin_type === Smarty::PLUGIN_COMPILER &&
$this->smarty->loadPlugin('smarty_compiler_' . $tag) &&
(!isset($this->smarty->security_policy) ||
$this->smarty->security_policy->isTrustedTag($tag, $this))
if ($plugin_type === Smarty::PLUGIN_COMPILER
&& $this->smarty->loadPlugin('smarty_compiler_' . $tag)
&& (!isset($this->smarty->security_policy)
|| $this->smarty->security_policy->isTrustedTag($tag, $this))
) {
$plugin = 'smarty_compiler_' . $tag;
if (is_callable($plugin)) {
@@ -1507,14 +1545,16 @@ abstract class Smarty_Internal_TemplateCompilerBase
throw new SmartyException("Plugin '{$tag}' not callable");
} else {
if ($function = $this->getPlugin($tag, $plugin_type)) {
if (!isset($this->smarty->security_policy) ||
$this->smarty->security_policy->isTrustedTag($tag, $this)
if (!isset($this->smarty->security_policy)
|| $this->smarty->security_policy->isTrustedTag($tag, $this)
) {
return $this->callTagCompiler('private_' . $plugin_type . '_plugin',
return $this->callTagCompiler(
'private_' . $plugin_type . '_plugin',
$args,
$parameter,
$tag,
$function);
$function
);
}
}
}
@@ -1548,14 +1588,18 @@ abstract class Smarty_Internal_TemplateCompilerBase
$new_args[ $key ] = $mixed;
}
}
return call_user_func_array($this->default_handler_plugins[ $plugin_type ][ $tag ][ 0 ],
return call_user_func_array(
$this->default_handler_plugins[ $plugin_type ][ $tag ][ 0 ],
array($new_args,
$this));
$this)
);
} else {
return $this->callTagCompiler('private_registered_' . $plugin_type,
return $this->callTagCompiler(
'private_registered_' . $plugin_type,
$args,
$parameter,
$tag);
$tag
);
}
}
}
@@ -1566,22 +1610,26 @@ abstract class Smarty_Internal_TemplateCompilerBase
if (isset($this->smarty->registered_objects[ $base_tag ]) && isset($parameter[ 'object_method' ])) {
$method = $parameter[ 'object_method' ];
if (in_array($method, $this->smarty->registered_objects[ $base_tag ][ 3 ])) {
return $this->callTagCompiler('private_object_block_function',
return $this->callTagCompiler(
'private_object_block_function',
$args,
$parameter,
$tag,
$method);
$method
);
} else {
// throw exception
$this->trigger_template_error('not allowed closing tag method "' . $method .
$this->trigger_template_error(
'not allowed closing tag method "' . $method .
'" in registered object "' . $base_tag . '"',
null,
true);
true
);
}
}
// registered block tag ?
if (isset($this->smarty->registered_plugins[ Smarty::PLUGIN_BLOCK ][ $base_tag ]) ||
isset($this->default_handler_plugins[ Smarty::PLUGIN_BLOCK ][ $base_tag ])
if (isset($this->smarty->registered_plugins[ Smarty::PLUGIN_BLOCK ][ $base_tag ])
|| isset($this->default_handler_plugins[ Smarty::PLUGIN_BLOCK ][ $base_tag ])
) {
return $this->callTagCompiler('private_registered_block', $args, $parameter, $tag);
}
@@ -1595,8 +1643,8 @@ abstract class Smarty_Internal_TemplateCompilerBase
}
// function plugin?
if ($function = $this->getPlugin($tag, Smarty::PLUGIN_FUNCTION)) {
if (!isset($this->smarty->security_policy) ||
$this->smarty->security_policy->isTrustedTag($tag, $this)
if (!isset($this->smarty->security_policy)
|| $this->smarty->security_policy->isTrustedTag($tag, $this)
) {
return $this->callTagCompiler('private_function_plugin', $args, $parameter, $tag, $function);
}
@@ -1608,9 +1656,11 @@ abstract class Smarty_Internal_TemplateCompilerBase
if (!$this->smarty->registered_plugins[ Smarty::PLUGIN_COMPILER ][ $tag ][ 1 ]) {
$this->tag_nocache = true;
}
return call_user_func_array($this->smarty->registered_plugins[ Smarty::PLUGIN_COMPILER ][ $tag ][ 0 ],
return call_user_func_array(
$this->smarty->registered_plugins[ Smarty::PLUGIN_COMPILER ][ $tag ][ 0 ],
array($args,
$this));
$this)
);
}
if ($this->smarty->loadPlugin('smarty_compiler_' . $tag)) {
$plugin = 'smarty_compiler_' . $tag;

View File

@@ -13,7 +13,6 @@
* This is the template file lexer.
* It is generated from the smarty_internal_templatelexer.plex file
*
*
* @author Uwe Tews <uwe.tews@googlemail.com>
*/
class Smarty_Internal_Templatelexer
@@ -219,7 +218,6 @@ class Smarty_Internal_Templatelexer
/**
* open lexer/parser trace file
*
*/
public function PrintTrace()
{
@@ -258,39 +256,47 @@ class Smarty_Internal_Templatelexer
public function yypushstate($state)
{
if ($this->yyTraceFILE) {
fprintf($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);
$this->_yy_state
);
}
array_push($this->_yy_stack, $this->_yy_state);
$this->_yy_state = $state;
if ($this->yyTraceFILE) {
fprintf($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);
$this->_yy_state
);
}
}
public function yypopstate()
{
if ($this->yyTraceFILE) {
fprintf($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);
$this->_yy_state
);
}
$this->_yy_state = array_pop($this->_yy_stack);
if ($this->yyTraceFILE) {
fprintf($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);
$this->_yy_state
);
}
}
@@ -298,15 +304,17 @@ class Smarty_Internal_Templatelexer
{
$this->_yy_state = $state;
if ($this->yyTraceFILE) {
fprintf($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);
$this->_yy_state
);
}
}
public function yylex1()
public function yylex1()
{
if (!isset($this->yy_global_pattern1)) {
$this->yy_global_pattern1 =
@@ -326,10 +334,14 @@ public function yylex1()
$yymatches = array_filter($yymatches);
}
if (empty($yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' .
' an empty string. Input "' . substr($this->data,
throw new Exception(
'Error: lexing failed because a rule matched' .
' an empty string. Input "' . substr(
$this->data,
$this->counter,
5) . '... state TEXT');
5
) . '... state TEXT'
);
}
next($yymatches); // skip global match
$this->token = key($yymatches); // token number
@@ -354,8 +366,10 @@ public function yylex1()
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);
@@ -368,11 +382,13 @@ public function yylex1()
function yy_r1_2()
{
preg_match("/[*]{$this->compiler->getRdelPreg()}[\n]?/",
preg_match(
"/[*]{$this->compiler->getRdelPreg()}[\n]?/",
$this->data,
$match,
PREG_OFFSET_CAPTURE,
$this->counter);
$this->counter
);
if (isset($match[ 0 ][ 1 ])) {
$to = $match[ 0 ][ 1 ] + strlen($match[ 0 ][ 0 ]);
} else {
@@ -420,7 +436,7 @@ public function yylex1()
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
}
public function yylex2()
public function yylex2()
{
if (!isset($this->yy_global_pattern2)) {
$this->yy_global_pattern2 =
@@ -440,10 +456,14 @@ public function yylex2()
$yymatches = array_filter($yymatches);
}
if (empty($yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' .
' an empty string. Input "' . substr($this->data,
throw new Exception(
'Error: lexing failed because a rule matched' .
' an empty string. Input "' . substr(
$this->data,
$this->counter,
5) . '... state TAG');
5
) . '... state TAG'
);
}
next($yymatches); // skip global match
$this->token = key($yymatches); // token number
@@ -468,8 +488,10 @@ public function yylex2()
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);
@@ -559,7 +581,7 @@ public function yylex2()
$this->taglineno = $this->line;
}
public function yylex3()
public function yylex3()
{
if (!isset($this->yy_global_pattern3)) {
$this->yy_global_pattern3 =
@@ -579,10 +601,14 @@ public function yylex3()
$yymatches = array_filter($yymatches);
}
if (empty($yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' .
' an empty string. Input "' . substr($this->data,
throw new Exception(
'Error: lexing failed because a rule matched' .
' an empty string. Input "' . substr(
$this->data,
$this->counter,
5) . '... state TAGBODY');
5
) . '... state TAGBODY'
);
}
next($yymatches); // skip global match
$this->token = key($yymatches); // token number
@@ -607,8 +633,10 @@ public function yylex3()
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);
@@ -766,8 +794,8 @@ public function yylex3()
function yy_r3_43()
{
// resolve conflicts with shorttag and right_delimiter starting with '='
if (substr($this->data, $this->counter + strlen($this->value) - 1, $this->compiler->getRdelLength()) ===
$this->smarty->getRightDelimiter()) {
if (substr($this->data, $this->counter + strlen($this->value) - 1, $this->compiler->getRdelLength()) === $this->smarty->getRightDelimiter()
) {
preg_match('/\s+/', $this->value, $match);
$this->value = $match[ 0 ];
$this->token = Smarty_Internal_Templateparser::TP_SPACE;
@@ -847,7 +875,7 @@ public function yylex3()
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
}
public function yylex4()
public function yylex4()
{
if (!isset($this->yy_global_pattern4)) {
$this->yy_global_pattern4 =
@@ -867,10 +895,14 @@ public function yylex4()
$yymatches = array_filter($yymatches);
}
if (empty($yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' .
' an empty string. Input "' . substr($this->data,
throw new Exception(
'Error: lexing failed because a rule matched' .
' an empty string. Input "' . substr(
$this->data,
$this->counter,
5) . '... state LITERAL');
5
) . '... state LITERAL'
);
}
next($yymatches); // skip global match
$this->token = key($yymatches); // token number
@@ -895,8 +927,10 @@ public function yylex4()
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);
@@ -924,7 +958,7 @@ public function yylex4()
$this->token = Smarty_Internal_Templateparser::TP_LITERAL;
} // end function
public function yylex5()
public function yylex5()
{
if (!isset($this->yy_global_pattern5)) {
$this->yy_global_pattern5 =
@@ -944,10 +978,14 @@ public function yylex5()
$yymatches = array_filter($yymatches);
}
if (empty($yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' .
' an empty string. Input "' . substr($this->data,
throw new Exception(
'Error: lexing failed because a rule matched' .
' an empty string. Input "' . substr(
$this->data,
$this->counter,
5) . '... state DOUBLEQUOTEDSTRING');
5
) . '... state DOUBLEQUOTEDSTRING'
);
}
next($yymatches); // skip global match
$this->token = key($yymatches); // token number
@@ -972,8 +1010,10 @@ public function yylex5()
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);

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More