uwetews
2018-08-19 02:35:46 +02:00
parent b5e5085391
commit 799b5cb342
51 changed files with 2869 additions and 3418 deletions

View File

@@ -1,4 +1,11 @@
===== 3.1.33-dev-4 =====
===== 3.1.33-dev-6 =====
19.08.2018
- fix PSR-2 coding standards and PHPDoc blocks https://github.com/smarty-php/smarty/pull/452
https://github.com/smarty-php/smarty/pull/475
https://github.com/smarty-php/smarty/pull/473
- bugfix PHP5.2 compatibility https://github.com/smarty-php/smarty/pull/472
===== 3.1.33-dev-4 =====
17.05.2018
- bugfix strip-block produces different output in Smarty v3.1.32 https://github.com/smarty-php/smarty/issues/436
- bugfix Smarty::compileAllTemplates ignores `$extension` parameter https://github.com/smarty-php/smarty/issues/437

View File

@@ -124,7 +124,7 @@ class Smarty_Internal_Configfilelexer
* @param string $data template source
* @param Smarty_Internal_Config_File_Compiler $compiler
*/
function __construct($data, Smarty_Internal_Config_File_Compiler $compiler)
public function __construct($data, Smarty_Internal_Config_File_Compiler $compiler)
{
$this->data = $data . "\n"; //now all lines are \n-terminated
$this->dataLength = strlen($data);

View File

@@ -89,7 +89,7 @@ class Smarty_Internal_Configfileparser
* @param Smarty_Internal_Configfilelexer $lex
* @param Smarty_Internal_Config_File_Compiler $compiler
*/
function __construct(Smarty_Internal_Configfilelexer $lex, Smarty_Internal_Config_File_Compiler $compiler)
public function __construct(Smarty_Internal_Configfilelexer $lex, Smarty_Internal_Config_File_Compiler $compiler)
{
$this->lex = $lex;
$this->smarty = $compiler->smarty;

View File

@@ -215,7 +215,7 @@ class Smarty_Internal_Templatelexer
* @param string $source template source
* @param Smarty_Internal_TemplateCompilerBase $compiler
*/
function __construct($source, Smarty_Internal_TemplateCompilerBase $compiler)
public function __construct($source, Smarty_Internal_TemplateCompilerBase $compiler)
{
$this->data = $source;
$this->dataLength = strlen($this->data);

View File

@@ -147,7 +147,7 @@ class Smarty_Internal_Templateparser
* @param Smarty_Internal_Templatelexer $lex
* @param Smarty_Internal_TemplateCompilerBase $compiler
*/
function __construct(Smarty_Internal_Templatelexer $lex, Smarty_Internal_TemplateCompilerBase $compiler)
public function __construct(Smarty_Internal_Templatelexer $lex, Smarty_Internal_TemplateCompilerBase $compiler)
{
$this->lex = $lex;
$this->compiler = $compiler;

View File

@@ -112,7 +112,7 @@ class Smarty extends Smarty_Internal_TemplateBase
/**
* smarty version
*/
const SMARTY_VERSION = '3.1.33-dev-5';
const SMARTY_VERSION = '3.1.33-dev-6';
/**
* define variable scopes
*/
@@ -166,133 +166,157 @@ class Smarty extends Smarty_Internal_TemplateBase
const PLUGIN_COMPILER = 'compiler';
const PLUGIN_MODIFIER = 'modifier';
const PLUGIN_MODIFIERCOMPILER = 'modifiercompiler';
/**
* assigned global tpl vars
*/
public static $global_tpl_vars = array();
/**
* Flag denoting if Multibyte String functions are available
*/
public static $_MBSTRING = SMARTY_MBSTRING;
/**
* The character set to adhere to (e.g. "UTF-8")
*/
public static $_CHARSET = SMARTY_RESOURCE_CHAR_SET;
/**
* The date format to be used internally
* (accepts date() and strftime())
*/
public static $_DATE_FORMAT = SMARTY_RESOURCE_DATE_FORMAT;
/**
* Flag denoting if PCRE should run in UTF-8 mode
*/
public static $_UTF8_MODIFIER = 'u';
/**
* Flag denoting if operating system is windows
*/
public static $_IS_WINDOWS = false;
/**
* auto literal on delimiters with whitespace
*
* @var boolean
*/
public $auto_literal = true;
/**
* display error on not assigned variables
*
* @var boolean
*/
public $error_unassigned = false;
/**
* look up relative file path in include_path
*
* @var boolean
*/
public $use_include_path = false;
/**
* flag if template_dir is normalized
*
* @var bool
*/
public $_templateDirNormalized = false;
/**
* joined template directory string used in cache keys
*
* @var string
*/
public $_joined_template_dir = null;
/**
* flag if config_dir is normalized
*
* @var bool
*/
public $_configDirNormalized = false;
/**
* joined config directory string used in cache keys
*
* @var string
*/
public $_joined_config_dir = null;
/**
* default template handler
*
* @var callable
*/
public $default_template_handler_func = null;
/**
* default config handler
*
* @var callable
*/
public $default_config_handler_func = null;
/**
* default plugin handler
*
* @var callable
*/
public $default_plugin_handler_func = null;
/**
* flag if template_dir is normalized
*
* @var bool
*/
public $_compileDirNormalized = false;
/**
* flag if plugins_dir is normalized
*
* @var bool
*/
public $_pluginsDirNormalized = false;
/**
* flag if template_dir is normalized
*
* @var bool
*/
public $_cacheDirNormalized = false;
/**
* force template compiling?
*
* @var boolean
*/
public $force_compile = false;
/**
* use sub dirs for compiled/cached files?
*
* @var boolean
*/
public $use_sub_dirs = false;
/**
* allow ambiguous resources (that are made unique by the resource handler)
*
* @var boolean
*/
public $allow_ambiguous_resources = false;
/**
* merge compiled includes
*
* @var boolean
*/
public $merge_compiled_includes = false;
/*
* flag for behaviour when extends: resource and {extends} tag are used simultaneous
* if false disable execution of {extends} in templates called by extends resource.
@@ -301,30 +325,35 @@ class Smarty extends Smarty_Internal_TemplateBase
* @var boolean
*/
public $extends_recursion = true;
/**
* force cache file creation
*
* @var boolean
*/
public $force_cache = false;
/**
* template left-delimiter
*
* @var string
*/
public $left_delimiter = "{";
/**
* template right-delimiter
*
* @var string
*/
public $right_delimiter = "}";
/**
* array of strings which shall be treated as literal by compiler
*
* @var array string
*/
public $literals = array();
/**
* class name
* This should be instance of Smarty_Security.
@@ -333,24 +362,28 @@ class Smarty extends Smarty_Internal_TemplateBase
* @see Smarty_Security
*/
public $security_class = 'Smarty_Security';
/**
* implementation of security class
*
* @var Smarty_Security
*/
public $security_policy = null;
/**
* controls handling of PHP-blocks
*
* @var integer
*/
public $php_handling = self::PHP_PASSTHRU;
/**
* controls if the php template file resource is allowed
*
* @var bool
*/
public $allow_php_templates = false;
/**
* debug mode
* Setting this to true enables the debug-console.
@@ -358,6 +391,7 @@ class Smarty extends Smarty_Internal_TemplateBase
* @var boolean
*/
public $debugging = false;
/**
* This determines if debugging is enable-able from the browser.
* <ul>
@@ -368,6 +402,7 @@ class Smarty extends Smarty_Internal_TemplateBase
* @var string
*/
public $debugging_ctrl = 'NONE';
/**
* Name of debugging URL-param.
* Only used when $debugging_ctrl is set to 'URL'.
@@ -376,54 +411,63 @@ class Smarty extends Smarty_Internal_TemplateBase
* @var string
*/
public $smarty_debug_id = 'SMARTY_DEBUG';
/**
* Path of debug template.
*
* @var string
*/
public $debug_tpl = null;
/**
* When set, smarty uses this value as error_reporting-level.
*
* @var int
*/
public $error_reporting = null;
/**
* Controls whether variables with the same name overwrite each other.
*
* @var boolean
*/
public $config_overwrite = true;
/**
* Controls whether config values of on/true/yes and off/false/no get converted to boolean.
*
* @var boolean
*/
public $config_booleanize = true;
/**
* Controls whether hidden config sections/vars are read from the file.
*
* @var boolean
*/
public $config_read_hidden = false;
/**
* locking concurrent compiles
*
* @var boolean
*/
public $compile_locking = true;
/**
* Controls whether cache resources should use locking mechanism
*
* @var boolean
*/
public $cache_locking = false;
/**
* seconds to wait for acquiring a lock before ignoring the write lock
*
* @var float
*/
public $locking_timeout = 10;
/**
* resource type used if none given
* Must be an valid key of $registered_resources.
@@ -431,6 +475,7 @@ class Smarty extends Smarty_Internal_TemplateBase
* @var string
*/
public $default_resource_type = 'file';
/**
* caching type
* Must be an element of $cache_resource_types.
@@ -438,144 +483,168 @@ class Smarty extends Smarty_Internal_TemplateBase
* @var string
*/
public $caching_type = 'file';
/**
* config type
*
* @var string
*/
public $default_config_type = 'file';
/**
* check If-Modified-Since headers
*
* @var boolean
*/
public $cache_modified_check = false;
/**
* registered plugins
*
* @var array
*/
public $registered_plugins = array();
/**
* registered objects
*
* @var array
*/
public $registered_objects = array();
/**
* registered classes
*
* @var array
*/
public $registered_classes = array();
/**
* registered filters
*
* @var array
*/
public $registered_filters = array();
/**
* registered resources
*
* @var array
*/
public $registered_resources = array();
/**
* registered cache resources
*
* @var array
*/
public $registered_cache_resources = array();
/**
* autoload filter
*
* @var array
*/
public $autoload_filters = array();
/**
* default modifier
*
* @var array
*/
public $default_modifiers = array();
/**
* autoescape variable output
*
* @var boolean
*/
public $escape_html = false;
/**
* start time for execution time calculation
*
* @var int
*/
public $start_time = 0;
/**
* required by the compiler for BC
*
* @var string
*/
public $_current_file = null;
/**
* internal flag to enable parser debugging
*
* @var bool
*/
public $_parserdebug = false;
/**
* This object type (Smarty = 1, template = 2, data = 4)
*
* @var int
*/
public $_objType = 1;
/**
* Debug object
*
* @var Smarty_Internal_Debug
*/
public $_debug = null;
/**
* template directory
*
* @var array
*/
protected $template_dir = array('./templates/');
/**
* flags for normalized template directory entries
*
* @var array
*/
protected $_processedTemplateDir = array();
/**
* config directory
*
* @var array
*/
protected $config_dir = array('./configs/');
/**
* flags for normalized template directory entries
*
* @var array
*/
protected $_processedConfigDir = array();
/**
* compile directory
*
* @var string
*/
protected $compile_dir = './templates_c/';
/**
* plugins directory
*
* @var array
*/
protected $plugins_dir = array();
/**
* cache directory
*
* @var string
*/
protected $cache_dir = './cache/';
/**
* removed properties
*
@@ -584,6 +653,7 @@ class Smarty extends Smarty_Internal_TemplateBase
protected $obsoleteProperties = array('resource_caching', 'template_resource_caching', 'direct_access_security',
'_dir_perms', '_file_perms', 'plugin_search_order',
'inheritance_merge_compiled_includes', 'resource_cache_mode',);
/**
* List of private properties which will call getter/setter on a direct access
*
@@ -657,7 +727,7 @@ class Smarty extends Smarty_Internal_TemplateBase
* @param string|Smarty_Security $security_class if a string is used, it must be class-name
*
* @return Smarty current Smarty instance for chaining
* @throws SmartyException when an invalid class name is provided
* @throws \SmartyException
*/
public function enableSecurity($security_class = null)
{
@@ -984,8 +1054,8 @@ class Smarty extends Smarty_Internal_TemplateBase
* @param string $plugin_name class plugin name to load
* @param bool $check check if already loaded
*
* @throws SmartyException
* @return string |boolean filepath of loaded file or false
* @throws \SmartyException
*/
public function loadPlugin($plugin_name, $check = true)
{
@@ -1009,7 +1079,8 @@ class Smarty extends Smarty_Internal_TemplateBase
$compile_id = null,
$caching = null,
Smarty_Internal_Template $template = null
) {
)
{
$template_name = (strpos($template_name, ':') === false) ? "{$this->default_resource_type}:{$template_name}" :
$template_name;
$cache_id = $cache_id === null ? $this->cache_id : $cache_id;
@@ -1044,8 +1115,6 @@ class Smarty extends Smarty_Internal_TemplateBase
public function _realpath($path, $realpath = null)
{
$nds = array('/' => '\\', '\\' => '/');
// normalize DIRECTORY_SEPARATOR
//$path = str_replace(array($nds[DIRECTORY_SEPARATOR], DIRECTORY_SEPARATOR . '.' . DIRECTORY_SEPARATOR), DIRECTORY_SEPARATOR, $path);
preg_match(
'%^(?<root>(?:[[:alpha:]]:[\\\\]|/|[\\\\]{2}[[:alpha:]]+|[[:print:]]{2,}:[/]{2}|[\\\\])?)(?<path>(.*))$%u',
$path,
@@ -1059,10 +1128,15 @@ class Smarty extends Smarty_Internal_TemplateBase
$path = getcwd() . DIRECTORY_SEPARATOR . $path;
}
}
// normalize DIRECTORY_SEPARATOR
$path = str_replace($nds[DIRECTORY_SEPARATOR], DIRECTORY_SEPARATOR, $path);
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);
@@ -1261,22 +1335,19 @@ class Smarty extends Smarty_Internal_TemplateBase
* @param string $name property name
*
* @return mixed
* @throws \SmartyException
*/
public function __get($name)
{
if (isset($this->accessMap[ $name ])) {
$method = 'get' . $this->accessMap[ $name ];
return $this->{$method}();
} else {if (isset($this->_cache[ $name ])) {
} elseif (isset($this->_cache[ $name ])) {
return $this->_cache[ $name ];
} else {if (in_array($name, $this->obsoleteProperties)) {
} elseif (in_array($name, $this->obsoleteProperties)) {
return null;
} else {
trigger_error('Undefined property: ' . get_class($this) . '::$' . $name, E_USER_NOTICE);
}
}
}
return null;
}
@@ -1288,24 +1359,20 @@ class Smarty extends Smarty_Internal_TemplateBase
* @param string $name property name
* @param mixed $value parameter passed to setter
*
* @throws \SmartyException
*/
public function __set($name, $value)
{
if (isset($this->accessMap[ $name ])) {
$method = 'set' . $this->accessMap[ $name ];
$this->{$method}($value);
} else {if (in_array($name, $this->obsoleteProperties)) {
} elseif (in_array($name, $this->obsoleteProperties)) {
return;
} else {
if (is_object($value) && method_exists($value, $name)) {
} elseif (is_object($value) && method_exists($value, $name)) {
$this->$name = $value;
} else {
trigger_error('Undefined property: ' . get_class($this) . '::$' . $name, E_USER_NOTICE);
}
}
}
}
/**
* Normalize and set directory string

View File

@@ -127,7 +127,7 @@
{foreach $assigned_vars as $vars}
<tr class="{if $vars@iteration % 2 eq 0}odd{else}even{/if}">
<td><h3><font color=blue>${$vars@key}</font></h3>
{if isset($vars['nocache'])}<b>Nocache</b></br>{/if}
{if isset($vars['nocache'])}<b>Nocache</b><br>{/if}
{if isset($vars['scope'])}<b>Origin:</b> {$vars['scope']|debug_print_var nofilter}{/if}
</td>
<td><h3>Value</h3>{$vars['value']|debug_print_var:10:80 nofilter}</td>

View File

@@ -43,7 +43,6 @@ function smarty_block_textformat($params, $content, Smarty_Internal_Template $te
'file' => SMARTY_PLUGINS_DIR . 'modifier.mb_wordwrap.php'))
);
}
$style = null;
$indent = 0;
$indent_first = 0;
@@ -52,7 +51,6 @@ function smarty_block_textformat($params, $content, Smarty_Internal_Template $te
$wrap_char = "\n";
$wrap_cut = false;
$assign = null;
foreach ($params as $_key => $_val) {
switch ($_key) {
case 'style':
@@ -61,28 +59,23 @@ function smarty_block_textformat($params, $content, Smarty_Internal_Template $te
case 'assign':
$$_key = (string)$_val;
break;
case 'indent':
case 'indent_first':
case 'wrap':
$$_key = (int)$_val;
break;
case 'wrap_cut':
$$_key = (bool)$_val;
break;
default:
trigger_error("textformat: unknown attribute '{$_key}'");
}
}
if ($style === 'email') {
$wrap = 72;
}
// split into paragraphs
$_paragraphs = preg_split('![\r\n]{2}!', $content);
foreach ($_paragraphs as &$_paragraph) {
if (!$_paragraph) {
continue;
@@ -93,7 +86,8 @@ function smarty_block_textformat($params, $content, Smarty_Internal_Template $te
array('!\s+!' . Smarty::$_UTF8_MODIFIER,
'!(^\s+)|(\s+$)!' . Smarty::$_UTF8_MODIFIER),
array(' ',
''), $_paragraph
''),
$_paragraph
);
// indent first line
if ($indent_first > 0) {
@@ -111,7 +105,6 @@ function smarty_block_textformat($params, $content, Smarty_Internal_Template $te
}
}
$_output = implode($wrap_char . $wrap_char, $_paragraphs);
if ($assign) {
$template->assign($assign, $_output);
} else {

View File

@@ -5,7 +5,6 @@
* @package Smarty
* @subpackage PluginsFunction
*/
/**
* Smarty {fetch} plugin
* Type: function
@@ -26,20 +25,16 @@ function smarty_function_fetch($params, $template)
{
if (empty($params[ 'file' ])) {
trigger_error('[plugin] fetch parameter \'file\' cannot be empty', E_USER_NOTICE);
return;
}
// strip file protocol
if (stripos($params[ 'file' ], 'file://') === 0) {
$params[ 'file' ] = substr($params[ 'file' ], 7);
}
$protocol = strpos($params[ 'file' ], '://');
if ($protocol !== false) {
$protocol = strtolower(substr($params[ 'file' ], 0, $protocol));
}
if (isset($template->smarty->security_policy)) {
if ($protocol) {
// remote resource (or php stream, …)
@@ -53,7 +48,6 @@ function smarty_function_fetch($params, $template)
}
}
}
$content = '';
if ($protocol === 'http') {
// http fetch
@@ -104,7 +98,6 @@ function smarty_function_fetch($params, $template)
if (!empty($param_value)) {
if (!preg_match('![\w\d-]+: .+!', $param_value)) {
trigger_error("[plugin] invalid header format '{$param_value}'", E_USER_NOTICE);
return;
} else {
$extra_headers[] = $param_value;
@@ -121,7 +114,6 @@ function smarty_function_fetch($params, $template)
$proxy_port = (int)$param_value;
} else {
trigger_error("[plugin] invalid value for attribute '{$param_key }'", E_USER_NOTICE);
return;
}
break;
@@ -140,13 +132,11 @@ function smarty_function_fetch($params, $template)
$timeout = (int)$param_value;
} else {
trigger_error("[plugin] invalid value for attribute '{$param_key}'", E_USER_NOTICE);
return;
}
break;
default:
trigger_error("[plugin] unrecognized attribute '{$param_key}'", E_USER_NOTICE);
return;
}
}
@@ -156,10 +146,8 @@ function smarty_function_fetch($params, $template)
} else {
$fp = fsockopen($server_name, $port, $errno, $errstr, $timeout);
}
if (!$fp) {
trigger_error("[plugin] unable to fetch: $errstr ($errno)", E_USER_NOTICE);
return;
} else {
if ($_is_proxy) {
@@ -187,23 +175,19 @@ function smarty_function_fetch($params, $template)
if (!empty($user) && !empty($pass)) {
fputs($fp, 'Authorization: BASIC ' . base64_encode("$user:$pass") . "\r\n");
}
fputs($fp, "\r\n");
while (!feof($fp)) {
$content .= fgets($fp, 4096);
}
fclose($fp);
$csplit = preg_split("!\r\n\r\n!", $content, 2);
$content = $csplit[ 1 ];
if (!empty($params[ 'assign_headers' ])) {
$template->assign($params[ 'assign_headers' ], preg_split("!\r\n!", $csplit[ 0 ]));
}
}
} else {
trigger_error("[plugin fetch] unable to parse URL, check syntax", E_USER_NOTICE);
return;
}
} else {
@@ -212,7 +196,6 @@ function smarty_function_fetch($params, $template)
throw new SmartyException("{fetch} cannot read resource '" . $params[ 'file' ] . "'");
}
}
if (!empty($params[ 'assign' ])) {
$template->assign($params[ 'assign' ], $content);
} else {

View File

@@ -48,7 +48,6 @@ function smarty_function_html_checkboxes($params, Smarty_Internal_Template $temp
array(array('function' => 'smarty_function_escape_special_chars',
'file' => SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'))
);
$name = 'checkbox';
$values = null;
$options = null;
@@ -58,31 +57,25 @@ function smarty_function_html_checkboxes($params, Smarty_Internal_Template $temp
$labels = true;
$label_ids = false;
$output = null;
$extra = '';
foreach ($params as $_key => $_val) {
switch ($_key) {
case 'name':
case 'separator':
$$_key = (string)$_val;
break;
case 'escape':
case 'labels':
case 'label_ids':
$$_key = (bool)$_val;
break;
case 'options':
$$_key = (array)$_val;
break;
case 'values':
case 'output':
$$_key = array_values((array)$_val);
break;
case 'checked':
case 'selected':
if (is_array($_val)) {
@@ -94,7 +87,8 @@ function smarty_function_html_checkboxes($params, Smarty_Internal_Template $temp
} else {
trigger_error(
'html_checkboxes: selected attribute contains an object of class \'' .
get_class($_sel) . '\' without __toString() method', E_USER_NOTICE
get_class($_sel) . '\' without __toString() method',
E_USER_NOTICE
);
continue;
}
@@ -109,14 +103,14 @@ function smarty_function_html_checkboxes($params, Smarty_Internal_Template $temp
} else {
trigger_error(
'html_checkboxes: selected attribute is an object of class \'' . get_class($_val) .
'\' without __toString() method', E_USER_NOTICE
'\' without __toString() method',
E_USER_NOTICE
);
}
} else {
$selected = smarty_function_escape_special_chars((string)$_val);
}
break;
case 'checkboxes':
trigger_error(
'html_checkboxes: the use of the "checkboxes" attribute is deprecated, use "options" instead',
@@ -124,13 +118,10 @@ function smarty_function_html_checkboxes($params, Smarty_Internal_Template $temp
);
$options = (array)$_val;
break;
case 'assign':
break;
case 'strict':
break;
case 'disabled':
case 'readonly':
if (!empty($params[ 'strict' ])) {
@@ -140,15 +131,12 @@ function smarty_function_html_checkboxes($params, Smarty_Internal_Template $temp
E_USER_NOTICE
);
}
if ($_val === true || $_val === $_key) {
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_key) . '"';
}
break;
}
// omit break; to fall through!
default:
if (!is_array($_val)) {
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
@@ -158,19 +146,23 @@ function smarty_function_html_checkboxes($params, Smarty_Internal_Template $temp
break;
}
}
if (!isset($options) && !isset($values)) {
return '';
} /* raise error here? */
$_html_result = array();
if (isset($options)) {
foreach ($options as $_key => $_val) {
$_html_result[] =
smarty_function_html_checkboxes_output(
$name, $_key, $_val, $selected, $extra, $separator, $labels,
$label_ids, $escape
$name,
$_key,
$_val,
$selected,
$extra,
$separator,
$labels,
$label_ids,
$escape
);
}
} else {
@@ -178,18 +170,25 @@ function smarty_function_html_checkboxes($params, Smarty_Internal_Template $temp
$_val = isset($output[ $_i ]) ? $output[ $_i ] : '';
$_html_result[] =
smarty_function_html_checkboxes_output(
$name, $_key, $_val, $selected, $extra, $separator, $labels,
$label_ids, $escape
$name,
$_key,
$_val,
$selected,
$extra,
$separator,
$labels,
$label_ids,
$escape
);
}
}
if (!empty($params[ 'assign' ])) {
$template->assign($params[ 'assign' ], $_html_result);
} else {
return implode("\n", $_html_result);
}
}
/**
* @param $name
* @param $value
@@ -203,46 +202,52 @@ function smarty_function_html_checkboxes($params, Smarty_Internal_Template $temp
*
* @return string
*/
function smarty_function_html_checkboxes_output($name, $value, $output, $selected, $extra, $separator, $labels,
$label_ids, $escape = true
) {
function smarty_function_html_checkboxes_output($name,
$value,
$output,
$selected,
$extra,
$separator,
$labels,
$label_ids,
$escape = true
)
{
$_output = '';
if (is_object($value)) {
if (method_exists($value, '__toString')) {
$value = (string)$value->__toString();
} else {
trigger_error(
'html_options: value is an object of class \'' . get_class($value) .
'\' without __toString() method', E_USER_NOTICE
'\' without __toString() method',
E_USER_NOTICE
);
return '';
}
} else {
$value = (string)$value;
}
if (is_object($output)) {
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
'\' without __toString() method',
E_USER_NOTICE
);
return '';
}
} else {
$output = (string)$output;
}
if ($labels) {
if ($label_ids) {
$_id = smarty_function_escape_special_chars(
preg_replace(
'![^\w\-\.]!' . Smarty::$_UTF8_MODIFIER, '_',
'![^\w\-\.]!' . Smarty::$_UTF8_MODIFIER,
'_',
$name . '_' . $value
)
);
@@ -251,19 +256,15 @@ function smarty_function_html_checkboxes_output($name, $value, $output, $selecte
$_output .= '<label>';
}
}
$name = smarty_function_escape_special_chars($name);
$value = smarty_function_escape_special_chars($value);
if ($escape) {
$output = smarty_function_escape_special_chars($output);
}
$_output .= '<input type="checkbox" name="' . $name . '[]" value="' . $value . '"';
if ($labels && $label_ids) {
$_output .= ' id="' . $_id . '"';
}
if (is_array($selected)) {
if (isset($selected[ $value ])) {
$_output .= ' checked="checked"';
@@ -271,13 +272,10 @@ function smarty_function_html_checkboxes_output($name, $value, $output, $selecte
} elseif ($value === $selected) {
$_output .= ' checked="checked"';
}
$_output .= $extra . ' />' . $output;
if ($labels) {
$_output .= '</label>';
}
$_output .= $separator;
return $_output;
}

View File

@@ -5,7 +5,6 @@
* @package Smarty
* @subpackage PluginsFunction
*/
/**
* Smarty {html_image} function plugin
* Type: function
@@ -41,7 +40,6 @@ function smarty_function_html_image($params, Smarty_Internal_Template $template)
array(array('function' => 'smarty_function_escape_special_chars',
'file' => SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'))
);
$alt = '';
$file = '';
$height = '';
@@ -61,53 +59,46 @@ function smarty_function_html_image($params, Smarty_Internal_Template $template)
case 'basedir':
$$_key = $_val;
break;
case 'alt':
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;
case 'link':
case 'href':
$prefix = '<a href="' . $_val . '">';
$suffix = '</a>';
break;
default:
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;
}
}
if (empty($file)) {
trigger_error('html_image: missing \'file\' parameter', E_USER_NOTICE);
return;
}
if ($file[ 0 ] === '/') {
$_image_path = $basedir . $file;
} else {
$_image_path = $file;
}
// strip file protocol
if (stripos($params[ 'file' ], 'file://') === 0) {
$params[ 'file' ] = substr($params[ 'file' ], 7);
}
$protocol = strpos($params[ 'file' ], '://');
if ($protocol !== false) {
$protocol = strtolower(substr($params[ 'file' ], 0, $protocol));
}
if (isset($template->smarty->security_policy)) {
if ($protocol) {
// remote resource (or php stream, …)
@@ -121,25 +112,20 @@ function smarty_function_html_image($params, Smarty_Internal_Template $template)
}
}
}
if (!isset($params[ 'width' ]) || !isset($params[ 'height' ])) {
// FIXME: (rodneyrehm) getimagesize() loads the complete file off a remote resource, use custom [jpg,png,gif]header reader!
if (!$_image_data = @getimagesize($_image_path)) {
if (!file_exists($_image_path)) {
trigger_error("html_image: unable to find '{$_image_path}'", E_USER_NOTICE);
return;
} elseif (!is_readable($_image_path)) {
trigger_error("html_image: unable to read '{$_image_path}'", E_USER_NOTICE);
return;
} else {
trigger_error("html_image: '{$_image_path}' is not a valid image file", E_USER_NOTICE);
return;
}
}
if (!isset($params[ 'width' ])) {
$width = $_image_data[ 0 ];
}
@@ -147,7 +133,6 @@ function smarty_function_html_image($params, Smarty_Internal_Template $template)
$height = $_image_data[ 1 ];
}
}
if (isset($params[ 'dpi' ])) {
if (strstr($_SERVER[ 'HTTP_USER_AGENT' ], 'Mac')) {
// FIXME: (rodneyrehm) wrong dpi assumption
@@ -160,7 +145,6 @@ function smarty_function_html_image($params, Smarty_Internal_Template $template)
$width = round($width * $_resize);
$height = round($height * $_resize);
}
return $prefix . '<img src="' . $path_prefix . $file . '" alt="' . $alt . '" width="' . $width . '" height="' .
$height . '"' . $extra . ' />' . $suffix;
}

View File

@@ -40,7 +40,6 @@ function smarty_function_html_options($params, Smarty_Internal_Template $templat
array(array('function' => 'smarty_function_escape_special_chars',
'file' => SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'))
);
$name = null;
$values = null;
$options = null;
@@ -48,9 +47,7 @@ function smarty_function_html_options($params, Smarty_Internal_Template $templat
$output = null;
$id = null;
$class = null;
$extra = '';
foreach ($params as $_key => $_val) {
switch ($_key) {
case 'name':
@@ -58,16 +55,13 @@ function smarty_function_html_options($params, Smarty_Internal_Template $templat
case 'id':
$$_key = (string)$_val;
break;
case 'options':
$options = (array)$_val;
break;
case 'values':
case 'output':
$$_key = array_values((array)$_val);
break;
case 'selected':
if (is_array($_val)) {
$selected = array();
@@ -78,7 +72,8 @@ function smarty_function_html_options($params, Smarty_Internal_Template $templat
} else {
trigger_error(
'html_options: selected attribute contains an object of class \'' .
get_class($_sel) . '\' without __toString() method', E_USER_NOTICE
get_class($_sel) . '\' without __toString() method',
E_USER_NOTICE
);
continue;
}
@@ -93,17 +88,16 @@ function smarty_function_html_options($params, Smarty_Internal_Template $templat
} else {
trigger_error(
'html_options: selected attribute is an object of class \'' . get_class($_val) .
'\' without __toString() method', E_USER_NOTICE
'\' without __toString() method',
E_USER_NOTICE
);
}
} else {
$selected = smarty_function_escape_special_chars((string)$_val);
}
break;
case 'strict':
break;
case 'disabled':
case 'readonly':
if (!empty($params[ 'strict' ])) {
@@ -113,15 +107,12 @@ function smarty_function_html_options($params, Smarty_Internal_Template $templat
E_USER_NOTICE
);
}
if ($_val === true || $_val === $_key) {
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_key) . '"';
}
break;
}
// omit break; to fall through!
default:
if (!is_array($_val)) {
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
@@ -131,16 +122,12 @@ function smarty_function_html_options($params, Smarty_Internal_Template $templat
break;
}
}
if (!isset($options) && !isset($values)) {
/* raise error here? */
return '';
}
$_html_result = '';
$_idx = 0;
if (isset($options)) {
foreach ($options as $_key => $_val) {
$_html_result .= smarty_function_html_options_optoutput($_key, $_val, $selected, $id, $class, $_idx);
@@ -151,7 +138,6 @@ function smarty_function_html_options($params, Smarty_Internal_Template $templat
$_html_result .= smarty_function_html_options_optoutput($_key, $_val, $selected, $id, $class, $_idx);
}
}
if (!empty($name)) {
$_html_class = !empty($class) ? ' class="' . $class . '"' : '';
$_html_id = !empty($id) ? ' id="' . $id . '"' : '';
@@ -159,9 +145,9 @@ function smarty_function_html_options($params, Smarty_Internal_Template $templat
'<select name="' . $name . '"' . $_html_class . $_html_id . $extra . '>' . "\n" . $_html_result .
'</select>' . "\n";
}
return $_html_result;
}
/**
* @param $key
* @param $value
@@ -192,9 +178,9 @@ function smarty_function_html_options_optoutput($key, $value, $selected, $id, $c
} else {
trigger_error(
'html_options: value is an object of class \'' . get_class($value) .
'\' without __toString() method', E_USER_NOTICE
'\' without __toString() method',
E_USER_NOTICE
);
return '';
}
} else {
@@ -206,14 +192,18 @@ function smarty_function_html_options_optoutput($key, $value, $selected, $id, $c
$_idx = 0;
$_html_result =
smarty_function_html_options_optgroup(
$key, $value, $selected, !empty($id) ? ($id . '-' . $idx) : null,
$class, $_idx
$key,
$value,
$selected,
!empty($id) ? ($id . '-' . $idx) : null,
$class,
$_idx
);
$idx++;
}
return $_html_result;
}
/**
* @param $key
* @param $values
@@ -231,6 +221,5 @@ function smarty_function_html_options_optgroup($key, $values, $selected, $id, $c
$optgroup_html .= smarty_function_html_options_optoutput($key, $value, $selected, $id, $class, $idx);
}
$optgroup_html .= "</optgroup>\n";
return $optgroup_html;
}

View File

@@ -48,7 +48,6 @@ function smarty_function_html_radios($params, Smarty_Internal_Template $template
array(array('function' => 'smarty_function_escape_special_chars',
'file' => SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'))
);
$name = 'radio';
$values = null;
$options = null;
@@ -59,14 +58,12 @@ function smarty_function_html_radios($params, Smarty_Internal_Template $template
$label_ids = false;
$output = null;
$extra = '';
foreach ($params as $_key => $_val) {
switch ($_key) {
case 'name':
case 'separator':
$$_key = (string)$_val;
break;
case 'checked':
case 'selected':
if (is_array($_val)) {
@@ -77,29 +74,26 @@ function smarty_function_html_radios($params, Smarty_Internal_Template $template
} else {
trigger_error(
'html_radios: selected attribute is an object of class \'' . get_class($_val) .
'\' without __toString() method', E_USER_NOTICE
'\' without __toString() method',
E_USER_NOTICE
);
}
} else {
$selected = (string)$_val;
}
break;
case 'escape':
case 'labels':
case 'label_ids':
$$_key = (bool)$_val;
break;
case 'options':
$$_key = (array)$_val;
break;
case 'values':
case 'output':
$$_key = array_values((array)$_val);
break;
case 'radios':
trigger_error(
'html_radios: the use of the "radios" attribute is deprecated, use "options" instead',
@@ -107,13 +101,10 @@ function smarty_function_html_radios($params, Smarty_Internal_Template $template
);
$options = (array)$_val;
break;
case 'assign':
break;
case 'strict':
break;
case 'disabled':
case 'readonly':
if (!empty($params[ 'strict' ])) {
@@ -123,15 +114,12 @@ function smarty_function_html_radios($params, Smarty_Internal_Template $template
E_USER_NOTICE
);
}
if ($_val === true || $_val === $_key) {
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_key) . '"';
}
break;
}
// omit break; to fall through!
default:
if (!is_array($_val)) {
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
@@ -141,21 +129,24 @@ function smarty_function_html_radios($params, Smarty_Internal_Template $template
break;
}
}
if (!isset($options) && !isset($values)) {
/* raise error here? */
return '';
}
$_html_result = array();
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
$name,
$_key,
$_val,
$selected,
$extra,
$separator,
$labels,
$label_ids,
$escape
);
}
} else {
@@ -163,18 +154,25 @@ function smarty_function_html_radios($params, Smarty_Internal_Template $template
$_val = isset($output[ $_i ]) ? $output[ $_i ] : '';
$_html_result[] =
smarty_function_html_radios_output(
$name, $_key, $_val, $selected, $extra, $separator, $labels,
$label_ids, $escape
$name,
$_key,
$_val,
$selected,
$extra,
$separator,
$labels,
$label_ids,
$escape
);
}
}
if (!empty($params[ 'assign' ])) {
$template->assign($params[ 'assign' ], $_html_result);
} else {
return implode("\n", $_html_result);
}
}
/**
* @param $name
* @param $value
@@ -188,46 +186,52 @@ 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,
function smarty_function_html_radios_output($name,
$value,
$output,
$selected,
$extra,
$separator,
$labels,
$label_ids,
$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
'\' without __toString() method',
E_USER_NOTICE
);
return '';
}
} else {
$value = (string)$value;
}
if (is_object($output)) {
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
'\' without __toString() method',
E_USER_NOTICE
);
return '';
}
} else {
$output = (string)$output;
}
if ($labels) {
if ($label_ids) {
$_id = smarty_function_escape_special_chars(
preg_replace(
'![^\w\-\.]!' . Smarty::$_UTF8_MODIFIER, '_',
'![^\w\-\.]!' . Smarty::$_UTF8_MODIFIER,
'_',
$name . '_' . $value
)
);
@@ -236,29 +240,22 @@ function smarty_function_html_radios_output($name, $value, $output, $selected, $
$_output .= '<label>';
}
}
$name = smarty_function_escape_special_chars($name);
$value = smarty_function_escape_special_chars($value);
if ($escape) {
$output = smarty_function_escape_special_chars($output);
}
$_output .= '<input type="radio" name="' . $name . '" value="' . $value . '"';
if ($labels && $label_ids) {
$_output .= ' id="' . $_id . '"';
}
if ($value === $selected) {
$_output .= ' checked="checked"';
}
$_output .= $extra . ' />' . $output;
if ($labels) {
$_output .= '</label>';
}
$_output .= $separator;
return $_output;
}

View File

@@ -58,7 +58,6 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
$_month_timestamps[ $i ] = mktime(0, 0, 0, $i, 1, 2000);
}
}
/* Default values. */
$prefix = 'Date_';
$start_year = null;
@@ -107,7 +106,6 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
$day_id = null;
$month_id = null;
$year_id = null;
foreach ($params as $_key => $_value) {
switch ($_key) {
case 'time':
@@ -119,7 +117,6 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
$time = smarty_make_timestamp($_value);
}
break;
case 'month_names':
if (is_array($_value) && count($_value) === 12) {
$$_key = $_value;
@@ -127,7 +124,6 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
trigger_error('html_select_date: month_names must be an array of 12 strings', E_USER_NOTICE);
}
break;
case 'prefix':
case 'field_array':
case 'start_year':
@@ -156,7 +152,6 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
case 'year_id':
$$_key = (string)$_value;
break;
case 'display_days':
case 'display_months':
case 'display_years':
@@ -164,7 +159,6 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
case 'reverse_years':
$$_key = (bool)$_value;
break;
default:
if (!is_array($_value)) {
$extra_attrs .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_value) . '"';
@@ -174,7 +168,6 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
break;
}
}
// Note: date() is faster than strftime()
// Note: explode(date()) is faster than date() date() date()
if (isset($params[ 'time' ]) && is_array($params[ 'time' ])) {
@@ -210,7 +203,6 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
} else {
list($_year, $_month, $_day) = $time = explode('-', date('Y-m-d', $time));
}
// make syntax "+N" or "-N" work with $start_year and $end_year
// Note preg_match('!^(\+|\-)\s*(\d+)$!', $end_year, $match) is slower than trim+substr
foreach (array('start',
@@ -227,14 +219,12 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
$$key = (int)$$key;
}
}
// flip for ascending or descending
if (($start_year > $end_year && !$reverse_years) || ($start_year < $end_year && $reverse_years)) {
$t = $end_year;
$end_year = $start_year;
$start_year = $t;
}
// generate year <select> or <input>
if ($display_years) {
$_extra = '';
@@ -245,7 +235,6 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
if ($year_extra) {
$_extra .= ' ' . $year_extra;
}
if ($year_as_text) {
$_html_years =
'<input type="text" name="' . $_name . '" value="' . $_year . '" size="4" maxlength="4"' . $_extra .
@@ -264,22 +253,18 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
$_html_years .= ' size="' . $year_size . '"';
}
$_html_years .= $_extra . $extra_attrs . '>' . $option_separator;
if (isset($year_empty) || isset($all_empty)) {
$_html_years .= '<option value="">' . (isset($year_empty) ? $year_empty : $all_empty) . '</option>' .
$option_separator;
}
$op = $start_year > $end_year ? -1 : 1;
for ($i = $start_year; $op > 0 ? $i <= $end_year : $i >= $end_year; $i += $op) {
$_html_years .= '<option value="' . $i . '"' . ($_year == $i ? ' selected="selected"' : '') . '>' . $i .
'</option>' . $option_separator;
}
$_html_years .= '</select>';
}
}
// generate month <select> or <input>
if ($display_months) {
$_extra = '';
@@ -290,7 +275,6 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
if ($month_extra) {
$_extra .= ' ' . $month_extra;
}
$_html_months = '<select name="' . $_name . '"';
if ($month_id !== null || $all_id !== null) {
$_html_months .= ' id="' . smarty_function_escape_special_chars(
@@ -304,12 +288,10 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
$_html_months .= ' size="' . $month_size . '"';
}
$_html_months .= $_extra . $extra_attrs . '>' . $option_separator;
if (isset($month_empty) || isset($all_empty)) {
$_html_months .= '<option value="">' . (isset($month_empty) ? $month_empty : $all_empty) . '</option>' .
$option_separator;
}
for ($i = 1; $i <= 12; $i++) {
$_val = sprintf('%02d', $i);
$_text = isset($month_names) ? smarty_function_escape_special_chars($month_names[ $i ]) :
@@ -318,10 +300,8 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
$_html_months .= '<option value="' . $_value . '"' . ($_val == $_month ? ' selected="selected"' : '') .
'>' . $_text . '</option>' . $option_separator;
}
$_html_months .= '</select>';
}
// generate day <select> or <input>
if ($display_days) {
$_extra = '';
@@ -332,7 +312,6 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
if ($day_extra) {
$_extra .= ' ' . $day_extra;
}
$_html_days = '<select name="' . $_name . '"';
if ($day_id !== null || $all_id !== null) {
$_html_days .= ' id="' .
@@ -345,12 +324,10 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
$_html_days .= ' size="' . $day_size . '"';
}
$_html_days .= $_extra . $extra_attrs . '>' . $option_separator;
if (isset($day_empty) || isset($all_empty)) {
$_html_days .= '<option value="">' . (isset($day_empty) ? $day_empty : $all_empty) . '</option>' .
$option_separator;
}
for ($i = 1; $i <= 31; $i++) {
$_val = sprintf('%02d', $i);
$_text = $day_format === '%02d' ? $_val : sprintf($day_format, $i);
@@ -358,10 +335,8 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
$_html_days .= '<option value="' . $_value . '"' . ($_val == $_day ? ' selected="selected"' : '') . '>' .
$_text . '</option>' . $option_separator;
}
$_html_days .= '</select>';
}
// order the fields for output
$_html = '';
for ($i = 0; $i <= 2; $i++) {
@@ -375,7 +350,6 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
$_html .= $_html_years;
}
break;
case 'm':
case 'M':
if (isset($_html_months)) {
@@ -385,7 +359,6 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
$_html .= $_html_months;
}
break;
case 'd':
case 'D':
if (isset($_html_days)) {
@@ -397,6 +370,5 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
break;
}
}
return $_html;
}

View File

@@ -35,47 +35,39 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
$field_separator = "\n";
$option_separator = "\n";
$time = null;
$display_hours = true;
$display_minutes = true;
$display_seconds = true;
$display_meridian = true;
$hour_format = '%02d';
$hour_value_format = '%02d';
$minute_format = '%02d';
$minute_value_format = '%02d';
$second_format = '%02d';
$second_value_format = '%02d';
$hour_size = null;
$minute_size = null;
$second_size = null;
$meridian_size = null;
$all_empty = null;
$hour_empty = null;
$minute_empty = null;
$second_empty = null;
$meridian_empty = null;
$all_id = null;
$hour_id = null;
$minute_id = null;
$second_id = null;
$meridian_id = null;
$use_24_hours = true;
$minute_interval = 1;
$second_interval = 1;
$extra_attrs = '';
$all_extra = null;
$hour_extra = null;
$minute_extra = null;
$second_extra = null;
$meridian_extra = null;
foreach ($params as $_key => $_value) {
switch ($_key) {
case 'time':
@@ -87,31 +79,25 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
$time = smarty_make_timestamp($_value);
}
break;
case 'prefix':
case 'field_array':
case 'field_separator':
case 'option_separator':
case 'all_extra':
case 'hour_extra':
case 'minute_extra':
case 'second_extra':
case 'meridian_extra':
case 'all_empty':
case 'hour_empty':
case 'minute_empty':
case 'second_empty':
case 'meridian_empty':
case 'all_id':
case 'hour_id':
case 'minute_id':
case 'second_id':
case 'meridian_id':
case 'hour_format':
case 'hour_value_format':
case 'minute_format':
@@ -120,7 +106,6 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
case 'second_value_format':
$$_key = (string)$_value;
break;
case 'display_hours':
case 'display_minutes':
case 'display_seconds':
@@ -128,17 +113,14 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
case 'use_24_hours':
$$_key = (bool)$_value;
break;
case 'minute_interval':
case 'second_interval':
case 'hour_size':
case 'minute_size':
case 'second_size':
case 'meridian_size':
$$_key = (int)$_value;
break;
default:
if (!is_array($_value)) {
$extra_attrs .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_value) . '"';
@@ -148,7 +130,6 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
break;
}
}
if (isset($params[ 'time' ]) && is_array($params[ 'time' ])) {
if (isset($params[ 'time' ][ $prefix . 'Hour' ])) {
// $_REQUEST[$field_array] given
@@ -191,7 +172,6 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
} else {
list($_hour, $_minute, $_second) = $time = explode('-', date('H-i-s', $time));
}
// generate hour <select>
if ($display_hours) {
$_html_hours = '';
@@ -203,7 +183,6 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
if ($hour_extra) {
$_extra .= ' ' . $hour_extra;
}
$_html_hours = '<select name="' . $_name . '"';
if ($hour_id !== null || $all_id !== null) {
$_html_hours .= ' id="' .
@@ -216,31 +195,25 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
$_html_hours .= ' size="' . $hour_size . '"';
}
$_html_hours .= $_extra . $extra_attrs . '>' . $option_separator;
if (isset($hour_empty) || isset($all_empty)) {
$_html_hours .= '<option value="">' . (isset($hour_empty) ? $hour_empty : $all_empty) . '</option>' .
$option_separator;
}
$start = $use_24_hours ? 0 : 1;
$end = $use_24_hours ? 23 : 12;
for ($i = $start; $i <= $end; $i++) {
$_val = sprintf('%02d', $i);
$_text = $hour_format === '%02d' ? $_val : sprintf($hour_format, $i);
$_value = $hour_value_format === '%02d' ? $_val : sprintf($hour_value_format, $i);
if (!$use_24_hours) {
$_hour12 = $_hour == 0 ? 12 : ($_hour <= 12 ? $_hour : $_hour - 12);
}
$selected = $_hour !== null ? ($use_24_hours ? $_hour == $_val : $_hour12 == $_val) : null;
$_html_hours .= '<option value="' . $_value . '"' . ($selected ? ' selected="selected"' : '') . '>' .
$_text . '</option>' . $option_separator;
}
$_html_hours .= '</select>';
}
// generate minute <select>
if ($display_minutes) {
$_html_minutes = '';
@@ -252,7 +225,6 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
if ($minute_extra) {
$_extra .= ' ' . $minute_extra;
}
$_html_minutes = '<select name="' . $_name . '"';
if ($minute_id !== null || $all_id !== null) {
$_html_minutes .= ' id="' . smarty_function_escape_special_chars(
@@ -266,12 +238,10 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
$_html_minutes .= ' size="' . $minute_size . '"';
}
$_html_minutes .= $_extra . $extra_attrs . '>' . $option_separator;
if (isset($minute_empty) || isset($all_empty)) {
$_html_minutes .= '<option value="">' . (isset($minute_empty) ? $minute_empty : $all_empty) . '</option>' .
$option_separator;
}
$selected = $_minute !== null ? ($_minute - $_minute % $minute_interval) : null;
for ($i = 0; $i <= 59; $i += $minute_interval) {
$_val = sprintf('%02d', $i);
@@ -280,10 +250,8 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
$_html_minutes .= '<option value="' . $_value . '"' . ($selected === $i ? ' selected="selected"' : '') .
'>' . $_text . '</option>' . $option_separator;
}
$_html_minutes .= '</select>';
}
// generate second <select>
if ($display_seconds) {
$_html_seconds = '';
@@ -295,7 +263,6 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
if ($second_extra) {
$_extra .= ' ' . $second_extra;
}
$_html_seconds = '<select name="' . $_name . '"';
if ($second_id !== null || $all_id !== null) {
$_html_seconds .= ' id="' . smarty_function_escape_special_chars(
@@ -309,12 +276,10 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
$_html_seconds .= ' size="' . $second_size . '"';
}
$_html_seconds .= $_extra . $extra_attrs . '>' . $option_separator;
if (isset($second_empty) || isset($all_empty)) {
$_html_seconds .= '<option value="">' . (isset($second_empty) ? $second_empty : $all_empty) . '</option>' .
$option_separator;
}
$selected = $_second !== null ? ($_second - $_second % $second_interval) : null;
for ($i = 0; $i <= 59; $i += $second_interval) {
$_val = sprintf('%02d', $i);
@@ -323,10 +288,8 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
$_html_seconds .= '<option value="' . $_value . '"' . ($selected === $i ? ' selected="selected"' : '') .
'>' . $_text . '</option>' . $option_separator;
}
$_html_seconds .= '</select>';
}
// generate meridian <select>
if ($display_meridian && !$use_24_hours) {
$_html_meridian = '';
@@ -338,7 +301,6 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
if ($meridian_extra) {
$_extra .= ' ' . $meridian_extra;
}
$_html_meridian = '<select name="' . $_name . '"';
if ($meridian_id !== null || $all_id !== null) {
$_html_meridian .= ' id="' . smarty_function_escape_special_chars(
@@ -353,18 +315,15 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
$_html_meridian .= ' size="' . $meridian_size . '"';
}
$_html_meridian .= $_extra . $extra_attrs . '>' . $option_separator;
if (isset($meridian_empty) || isset($all_empty)) {
$_html_meridian .= '<option value="">' . (isset($meridian_empty) ? $meridian_empty : $all_empty) .
'</option>' . $option_separator;
}
$_html_meridian .= '<option value="am"' . ($_hour > 0 && $_hour < 12 ? ' selected="selected"' : '') .
'>AM</option>' . $option_separator . '<option value="pm"' .
($_hour < 12 ? '' : ' selected="selected"') . '>PM</option>' . $option_separator .
'</select>';
}
$_html = '';
foreach (array('_html_hours',
'_html_minutes',
@@ -377,6 +336,5 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
$_html .= $$k;
}
}
return $_html;
}

View File

@@ -5,7 +5,6 @@
* @package Smarty
* @subpackage PluginsFunction
*/
/**
* Smarty {html_table} function plugin
* Type: function
@@ -60,19 +59,15 @@ function smarty_function_html_table($params)
$inner = 'cols';
$caption = '';
$loop = null;
if (!isset($params[ 'loop' ])) {
trigger_error("html_table: missing 'loop' parameter", E_USER_WARNING);
return;
}
foreach ($params as $_key => $_value) {
switch ($_key) {
case 'loop':
$$_key = (array)$_value;
break;
case 'cols':
if (is_array($_value) && !empty($_value)) {
$cols = $_value;
@@ -86,11 +81,9 @@ function smarty_function_html_table($params)
$cols_count = $cols;
}
break;
case 'rows':
$$_key = (int)$_value;
break;
case 'table_attr':
case 'trailpad':
case 'hdir':
@@ -99,7 +92,6 @@ function smarty_function_html_table($params)
case 'caption':
$$_key = (string)$_value;
break;
case 'tr_attr':
case 'td_attr':
case 'th_attr':
@@ -107,7 +99,6 @@ function smarty_function_html_table($params)
break;
}
}
$loop_count = count($loop);
if (empty($params[ 'rows' ])) {
/* no rows specified */
@@ -118,17 +109,13 @@ function smarty_function_html_table($params)
$cols_count = ceil($loop_count / $rows);
}
}
$output = "<table $table_attr>\n";
if (!empty($caption)) {
$output .= '<caption>' . $caption . "</caption>\n";
}
if (is_array($cols)) {
$cols = ($hdir === 'right') ? $cols : array_reverse($cols);
$output .= "<thead><tr>\n";
for ($r = 0; $r < $cols_count; $r++) {
$output .= '<th' . smarty_function_html_table_cycle('th', $th_attr, $r) . '>';
$output .= $cols[ $r ];
@@ -136,19 +123,16 @@ function smarty_function_html_table($params)
}
$output .= "</tr></thead>\n";
}
$output .= "<tbody>\n";
for ($r = 0; $r < $rows; $r++) {
$output .= "<tr" . smarty_function_html_table_cycle('tr', $tr_attr, $r) . ">\n";
$rx = ($vdir === 'down') ? $r * $cols_count : ($rows - 1 - $r) * $cols_count;
for ($c = 0; $c < $cols_count; $c++) {
$x = ($hdir === 'right') ? $rx + $c : $rx + $cols_count - 1 - $c;
if ($inner !== 'cols') {
/* shuffle x to loop over rows*/
$x = floor($x / $cols_count) + ($x % $cols_count) * $rows;
}
if ($x < $loop_count) {
$output .= "<td" . smarty_function_html_table_cycle('td', $td_attr, $c) . ">" . $loop[ $x ] . "</td>\n";
} else {
@@ -159,9 +143,9 @@ function smarty_function_html_table($params)
}
$output .= "</tbody>\n";
$output .= "</table>\n";
return $output;
}
/**
* @param $name
* @param $var
@@ -176,6 +160,5 @@ function smarty_function_html_table_cycle($name, $var, $no)
} else {
$ret = $var[ $no % count($var) ];
}
return ($ret) ? ' ' . $ret : '';
}

View File

@@ -5,7 +5,6 @@
* @package Smarty
* @subpackage PluginsFunction
*/
/**
* Smarty {mailto} function plugin
* Type: function
@@ -52,15 +51,12 @@ function smarty_function_mailto($params)
static $_allowed_encoding =
array('javascript' => true, 'javascript_charcode' => true, 'hex' => true, 'none' => true);
$extra = '';
if (empty($params[ 'address' ])) {
trigger_error("mailto: missing 'address' parameter", E_USER_WARNING);
return;
} else {
$address = $params[ 'address' ];
}
$text = $address;
// netscape and mozilla do not decode %40 (@) in BCC field (bug?)
// so, don't encode it.
@@ -76,59 +72,47 @@ function smarty_function_mailto($params)
$mail_parms[] = $var . '=' . str_replace($search, $replace, rawurlencode($value));
}
break;
case 'subject':
case 'newsgroups':
$mail_parms[] = $var . '=' . rawurlencode($value);
break;
case 'extra':
case 'text':
$$var = $value;
default:
}
}
if ($mail_parms) {
$address .= '?' . join('&', $mail_parms);
}
$encode = (empty($params[ 'encode' ])) ? 'none' : $params[ 'encode' ];
if (!isset($_allowed_encoding[ $encode ])) {
trigger_error(
"mailto: 'encode' parameter must be none, javascript, javascript_charcode or hex",
E_USER_WARNING
);
return;
}
// FIXME: (rodneyrehm) document.write() excues me what? 1998 has passed!
if ($encode === 'javascript') {
$string = 'document.write(\'<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>\');';
$js_encode = '';
for ($x = 0, $_length = strlen($string); $x < $_length; $x++) {
$js_encode .= '%' . bin2hex($string[ $x ]);
}
return '<script type="text/javascript">eval(unescape(\'' . $js_encode . '\'))</script>';
} elseif ($encode === 'javascript_charcode') {
$string = '<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>';
for ($x = 0, $y = strlen($string); $x < $y; $x++) {
$ord[] = ord($string[ $x ]);
}
$_ret = "<script type=\"text/javascript\" language=\"javascript\">\n" . "{document.write(String.fromCharCode(" .
implode(',', $ord) . "))" . "}\n" . "</script>\n";
return $_ret;
} elseif ($encode === 'hex') {
preg_match('!^(.*)(\?.*)$!', $address, $match);
if (!empty($match[ 2 ])) {
trigger_error("mailto: hex encoding does not work with extra attributes. Try javascript.", E_USER_WARNING);
return;
}
$address_encode = '';
@@ -143,9 +127,7 @@ function smarty_function_mailto($params)
for ($x = 0, $_length = strlen($text); $x < $_length; $x++) {
$text_encode .= '&#x' . bin2hex($text[ $x ]) . ';';
}
$mailto = "&#109;&#97;&#105;&#108;&#116;&#111;&#58;";
return '<a href="' . $mailto . $address_encode . '" ' . $extra . '>' . $text_encode . '</a>';
} else {
// no encoding

View File

@@ -5,7 +5,6 @@
* @package Smarty
* @subpackage Debug
*/
/**
* Smarty debug_print_var modifier plugin
* Type: modifier
@@ -38,7 +37,6 @@ function smarty_modifier_debug_print_var($var, $max = 10, $length = 40, $depth =
$depth--;
}
break;
case 'object' :
$object_vars = get_object_vars($var);
$results = '<b>' . get_class($var) . ' Object (' . count($object_vars) . ')</b>';
@@ -56,7 +54,6 @@ function smarty_modifier_debug_print_var($var, $max = 10, $length = 40, $depth =
$depth--;
}
break;
case 'boolean' :
case 'NULL' :
case 'resource' :
@@ -71,12 +68,10 @@ function smarty_modifier_debug_print_var($var, $max = 10, $length = 40, $depth =
}
$results = '<i>' . $results . '</i>';
break;
case 'integer' :
case 'float' :
$results = htmlspecialchars((string)$var);
break;
case 'string' :
$results = strtr($var, $_replace);
if (Smarty::$_MBSTRING) {
@@ -88,10 +83,8 @@ function smarty_modifier_debug_print_var($var, $max = 10, $length = 40, $depth =
$results = substr($var, 0, $length - 3) . '...';
}
}
$results = htmlspecialchars('"' . $results . '"', ENT_QUOTES, Smarty::$_CHARSET);
break;
case 'unknown type' :
default :
$results = strtr((string)$var, $_replace);
@@ -104,9 +97,7 @@ function smarty_modifier_debug_print_var($var, $max = 10, $length = 40, $depth =
$results = substr($results, 0, $length - 3) . '...';
}
}
$results = htmlspecialchars($results, ENT_QUOTES, Smarty::$_CHARSET);
}
return $results;
}

View File

@@ -5,7 +5,6 @@
* @package Smarty
* @subpackage PluginsModifier
*/
/**
* Smarty escape modifier plugin
* Type: modifier
@@ -30,11 +29,9 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
if ($_double_encode === null) {
$_double_encode = version_compare(PHP_VERSION, '5.2.3', '>=');
}
if (!$char_set) {
$char_set = Smarty::$_CHARSET;
}
switch ($esc_type) {
case 'html':
if ($_double_encode) {
@@ -50,14 +47,14 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
$string = htmlspecialchars($string, ENT_QUOTES, $char_set);
$string = str_replace(
array('%%%SMARTY_START%%%',
'%%%SMARTY_END%%%'), array('&',
';'), $string
'%%%SMARTY_END%%%'),
array('&',
';'),
$string
);
return $string;
}
}
case 'htmlall':
if (Smarty::$_MBSTRING) {
// mb_convert_encoding ignores htmlspecialchars()
@@ -75,18 +72,17 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
$string =
str_replace(
array('%%%SMARTY_START%%%',
'%%%SMARTY_END%%%'), array('&',
';'), $string
'%%%SMARTY_END%%%'),
array('&',
';'),
$string
);
return $string;
}
}
// htmlentities() won't convert everything, so use mb_convert_encoding
return mb_convert_encoding($string, 'HTML-ENTITIES', $char_set);
}
// no MBString fallback
if ($_double_encode) {
return htmlentities($string, ENT_QUOTES, $char_set, $double_encode);
@@ -98,24 +94,21 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
$string = htmlentities($string, ENT_QUOTES, $char_set);
$string = str_replace(
array('%%%SMARTY_START%%%',
'%%%SMARTY_END%%%'), array('&',
';'), $string
'%%%SMARTY_END%%%'),
array('&',
';'),
$string
);
return $string;
}
}
case 'url':
return rawurlencode($string);
case 'urlpathinfo':
return str_replace('%2F', '/', rawurlencode($string));
case 'quotes':
// escape unescaped single quotes
return preg_replace("%(?<!\\\\)'%", "\\'", $string);
case 'hex':
// escape every byte into hex
// Note that the UTF-8 encoded character ä will be represented as %c3%a4
@@ -124,9 +117,7 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
for ($x = 0; $x < $_length; $x++) {
$return .= '%' . bin2hex($string[ $x ]);
}
return $return;
case 'hexentity':
$return = '';
if (Smarty::$_MBSTRING) {
@@ -140,7 +131,6 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
foreach (smarty_mb_to_unicode($string, Smarty::$_CHARSET) as $unicode) {
$return .= '&#x' . strtoupper(dechex($unicode)) . ';';
}
return $return;
}
// no MBString fallback
@@ -148,9 +138,7 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
for ($x = 0; $x < $_length; $x++) {
$return .= '&#x' . bin2hex($string[ $x ]) . ';';
}
return $return;
case 'decentity':
$return = '';
if (Smarty::$_MBSTRING) {
@@ -164,7 +152,6 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
foreach (smarty_mb_to_unicode($string, Smarty::$_CHARSET) as $unicode) {
$return .= '&#' . $unicode . ';';
}
return $return;
}
// no MBString fallback
@@ -172,20 +159,18 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
for ($x = 0; $x < $_length; $x++) {
$return .= '&#' . ord($string[ $x ]) . ';';
}
return $return;
case 'javascript':
// escape quotes and backslashes, newlines, etc.
return strtr(
$string, array('\\' => '\\\\',
$string,
array('\\' => '\\\\',
"'" => "\\'",
'"' => '\\"',
"\r" => '\\r',
"\n" => '\\n',
'</' => '<\/')
);
case 'mail':
if (Smarty::$_MBSTRING) {
if (!$is_loaded_2) {
@@ -196,17 +181,20 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
}
return smarty_mb_str_replace(
array('@',
'.'), array(' [AT] ',
' [DOT] '), $string
'.'),
array(' [AT] ',
' [DOT] '),
$string
);
}
// no MBString fallback
return str_replace(
array('@',
'.'), array(' [AT] ',
' [DOT] '), $string
'.'),
array(' [AT] ',
' [DOT] '),
$string
);
case 'nonstd':
// escape non-standard chars, such as ms document quotes
$return = '';
@@ -224,10 +212,8 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
$return .= chr($unicode);
}
}
return $return;
}
$_length = strlen($string);
for ($_i = 0; $_i < $_length; $_i++) {
$_ord = ord(substr($string, $_i, 1));
@@ -238,9 +224,7 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
$return .= substr($string, $_i, 1);
}
}
return $return;
default:
return $string;
}

View File

@@ -31,16 +31,13 @@ function smarty_modifiercompiler_escape($params, Smarty_Internal_TemplateCompile
if ($_double_encode === null) {
$_double_encode = version_compare(PHP_VERSION, '5.2.3', '>=');
}
try {
$esc_type = smarty_literal_compiler_param($params, 1, 'html');
$char_set = smarty_literal_compiler_param($params, 2, Smarty::$_CHARSET);
$double_encode = smarty_literal_compiler_param($params, 3, true);
if (!$char_set) {
$char_set = Smarty::$_CHARSET;
}
switch ($esc_type) {
case 'html':
if ($_double_encode) {
@@ -51,7 +48,6 @@ function smarty_modifiercompiler_escape($params, Smarty_Internal_TemplateCompile
} else {
// fall back to modifier.escape.php
}
case 'htmlall':
if (Smarty::$_MBSTRING) {
if ($_double_encode) {
@@ -67,7 +63,6 @@ function smarty_modifiercompiler_escape($params, Smarty_Internal_TemplateCompile
// fall back to modifier.escape.php
}
}
// no MBString fallback
if ($_double_encode) {
// php >=5.2.3 - go native
@@ -79,27 +74,23 @@ function smarty_modifiercompiler_escape($params, Smarty_Internal_TemplateCompile
} else {
// fall back to modifier.escape.php
}
case 'url':
return 'rawurlencode(' . $params[ 0 ] . ')';
case 'urlpathinfo':
return 'str_replace("%2F", "/", rawurlencode(' . $params[ 0 ] . '))';
case 'quotes':
// escape unescaped single quotes
return 'preg_replace("%(?<!\\\\\\\\)\'%", "\\\'",' . $params[ 0 ] . ')';
case 'javascript':
// escape quotes and backslashes, newlines, etc.
return 'strtr(' . $params[ 0 ] .
return 'strtr(' .
$params[ 0 ] .
', array("\\\\" => "\\\\\\\\", "\'" => "\\\\\'", "\"" => "\\\\\"", "\\r" => "\\\\r", "\\n" => "\\\n", "</" => "<\/" ))';
}
}
catch (SmartyException $e) {
// pass through to regular plugin fallback
}
// could not optimize |escape call, so fallback to regular plugin
if ($compiler->template->caching && ($compiler->tag_nocache | $compiler->nocache)) {
$compiler->required_plugins[ 'nocache' ][ 'escape' ][ 'modifier' ][ 'file' ] =
@@ -112,6 +103,5 @@ function smarty_modifiercompiler_escape($params, Smarty_Internal_TemplateCompile
$compiler->required_plugins[ 'compiled' ][ 'escape' ][ 'modifier' ][ 'function' ] =
'smarty_modifier_escape';
}
return 'smarty_modifier_escape(' . join(', ', $params) . ')';
}

View File

@@ -5,7 +5,6 @@
* @package Smarty
* @subpackage PluginsModifierCompiler
*/
/**
* Smarty unescape modifier plugin
* Type: modifier
@@ -28,22 +27,17 @@ function smarty_modifiercompiler_unescape($params)
} else {
$params[ 2 ] = "'{$params[ 2 ]}'";
}
switch (trim($params[ 1 ], '"\'')) {
case 'entity':
case 'htmlall':
if (Smarty::$_MBSTRING) {
return 'mb_convert_encoding(' . $params[ 0 ] . ', ' . $params[ 2 ] . ', \'HTML-ENTITIES\')';
}
return 'html_entity_decode(' . $params[ 0 ] . ', ENT_NOQUOTES, ' . $params[ 2 ] . ')';
case 'html':
return 'htmlspecialchars_decode(' . $params[ 0 ] . ', ENT_QUOTES)';
case 'url':
return 'rawurldecode(' . $params[ 0 ] . ')';
default:
return $params[ 0 ];
}

View File

@@ -25,12 +25,12 @@ abstract class Smarty_CacheResource
/**
* populate Cached Object with meta data from Resource
*
* @param Smarty_Template_Cached $cached cached object
* @param \Smarty_Template_Cached $cached cached object
* @param Smarty_Internal_Template $_template template object
*
* @return void
*/
abstract public function populate(Smarty_Template_Cached $cached, Smarty_Internal_Template $_template);
abstract public function populate(\Smarty_Template_Cached $cached, Smarty_Internal_Template $_template);
/**
* populate Cached Object with timestamp and exists from Resource

View File

@@ -66,7 +66,7 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_Compile_Shared_Inher
// check and get attributes
$_attr = $this->getAttributes($compiler, $args);
++$compiler->_cache[ 'blockNesting' ];
$_className = 'Block_' . preg_replace('![^\w]+!', '_', uniqid(rand(), true));
$_className = 'Block_' . preg_replace('![^\w]+!', '_', uniqid(mt_rand(), true));
$compiler->_cache[ 'blockName' ][ $compiler->_cache[ 'blockNesting' ] ] = $_attr[ 'name' ];
$compiler->_cache[ 'blockClass' ][ $compiler->_cache[ 'blockNesting' ] ] = $_className;
$compiler->_cache[ 'blockParams' ][ $compiler->_cache[ 'blockNesting' ] ] = array();

View File

@@ -40,7 +40,6 @@ class Smarty_Internal_Compile_Capture extends Smarty_Internal_CompileBase
* @param array $parameter array with compilation parameter
*
* @return string compiled code
* @throws \SmartyCompilerException
*/
public static function compileSpecialVariable($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = null)
{

View File

@@ -1,5 +1,4 @@
<?php
/**
* Smarty Internal Plugin Compile Modifier
* Compiles code for modifier execution
@@ -54,7 +53,9 @@ class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBa
$output =
sprintf(
'call_user_func_array($_smarty_tpl->registered_plugins[ \'%s\' ][ %s ][ 0 ], array( %s ))',
Smarty::PLUGIN_MODIFIER, var_export($modifier, true), $params
Smarty::PLUGIN_MODIFIER,
var_export($modifier, true),
$params
);
$compiler->known_modifier_type[ $modifier ] = $type;
break 2;
@@ -67,7 +68,8 @@ class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBa
$output =
call_user_func(
$compiler->smarty->registered_plugins[ Smarty::PLUGIN_MODIFIERCOMPILER ][ $modifier ][ 0 ],
$single_modifier, $compiler->smarty
$single_modifier,
$compiler->smarty
);
$compiler->known_modifier_type[ $modifier ] = $type;
break 2;
@@ -135,7 +137,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' ])
||
isset($compiler->required_plugins[ 'compiled' ][ $modifier ][ Smarty::PLUGIN_MODIFIER ][ 'file' ])
) {
// was a plugin
$compiler->known_modifier_type[ $modifier ] = 4;
@@ -150,7 +153,6 @@ class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBa
$compiler->trigger_template_error("unknown modifier '{$modifier}'", null, true);
}
}
return $output;
}
}

View File

@@ -43,7 +43,9 @@ class Smarty_Internal_Compile_Private_Special_Variable extends Smarty_Internal_C
$class = 'Smarty_Internal_Compile_' . ucfirst($variable);
Smarty_Internal_TemplateCompilerBase::$_tag_objects[ $variable ] = new $class;
}
return Smarty_Internal_TemplateCompilerBase::$_tag_objects[ $variable ]->compileSpecialVariable(array(), $compiler, $_index);
return Smarty_Internal_TemplateCompilerBase::$_tag_objects[ $variable ]->compileSpecialVariable(array(),
$compiler,
$_index);
case 'capture':
if (class_exists('Smarty_Internal_Compile_Capture')) {
return Smarty_Internal_Compile_Capture::compileSpecialVariable(array(), $compiler, $_index);
@@ -74,19 +76,14 @@ class Smarty_Internal_Compile_Private_Special_Variable extends Smarty_Internal_C
}
$compiled_ref = '$_' . strtoupper($variable);
break;
case 'template':
return 'basename($_smarty_tpl->source->filepath)';
case 'template_object':
return '$_smarty_tpl';
case 'current_dir':
return 'dirname($_smarty_tpl->source->filepath)';
case 'version':
return "Smarty::SMARTY_VERSION";
case 'const':
if (isset($compiler->smarty->security_policy)
&& !$compiler->smarty->security_policy->allow_constants
@@ -99,7 +96,6 @@ class Smarty_Internal_Compile_Private_Special_Variable extends Smarty_Internal_C
} else {
return "@constant({$_index[1]})";
}
case 'config':
if (isset($_index[ 2 ])) {
return "(is_array(\$tmp = \$_smarty_tpl->smarty->ext->configload->_getConfigVariable(\$_smarty_tpl, $_index[1])) ? \$tmp[$_index[2]] : null)";

View File

@@ -103,7 +103,6 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_Compile_Private_Fo
$this->openTag($compiler, 'section', array('section', $compiler->nocache, $local, $sectionVar));
// maybe nocache because of nocache variables
$compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
$initLocal = array();
$initNamedProperty = array();
$initFor = array();
@@ -111,7 +110,6 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_Compile_Private_Fo
$cmpFor = array();
$propValue = array('index' => "{$sectionVar}->value['index']", 'show' => 'true', 'step' => 1,
'iteration' => "{$local}iteration",
);
$propType = array('index' => 2, 'iteration' => 2, 'show' => 0, 'step' => 0,);
// search for used tag attributes
@@ -165,7 +163,6 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_Compile_Private_Fo
$v = "{$local}step";
$t = 2;
break;
case 'max':
case 'start':
if (is_numeric($attr_value)) {
@@ -183,7 +180,6 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_Compile_Private_Fo
$propValue[ $attr_name ] = $v;
$propType[ $attr_name ] = $t;
}
if (isset($namedAttr[ 'step' ])) {
$initNamedProperty[ 'step' ] = $propValue[ 'step' ];
}
@@ -192,7 +188,6 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_Compile_Private_Fo
}
$incFor[ 'iteration' ] = "{$propValue['iteration']}++";
$initFor[ 'iteration' ] = "{$propValue['iteration']} = 1";
if ($propType[ 'step' ] === 0) {
if ($propValue[ 'step' ] === 1) {
$incFor[ 'index' ] = "{$sectionVar}->value['index']++";
@@ -204,7 +199,6 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_Compile_Private_Fo
} else {
$incFor[ 'index' ] = "{$sectionVar}->value['index'] += {$propValue['step']}";
}
if (!isset($propValue[ 'max' ])) {
$propValue[ 'max' ] = $propValue[ 'loop' ];
$propType[ 'max' ] = $propType[ 'loop' ];
@@ -217,7 +211,6 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_Compile_Private_Fo
$propType[ 'max' ] = $propType[ 'loop' ];
}
}
if (!isset($propValue[ 'start' ])) {
$start_code =
array(1 => "{$propValue['step']} > 0 ? ", 2 => '0', 3 => ' : ', 4 => $propValue[ 'loop' ], 5 => ' - 1');
@@ -288,9 +281,7 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_Compile_Private_Fo
$initLocal[ 'start' ] = $propValue[ 'start' ];
$propValue[ 'start' ] = "{$local}start";
}
$initFor[ 'index' ] = "{$sectionVar}->value['index'] = {$propValue['start']}";
if (!isset($_attr[ 'start' ]) && !isset($_attr[ 'step' ]) && !isset($_attr[ 'max' ])) {
$propValue[ 'total' ] = $propValue[ 'loop' ];
$propType[ 'total' ] = $propType[ 'loop' ];
@@ -303,7 +294,8 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_Compile_Private_Fo
ceil(
($propValue[ 'step' ] > 0 ? $propValue[ 'loop' ] - $propValue[ 'start' ] :
(int)$propValue[ 'start' ] + 1) / abs($propValue[ 'step' ])
), $propValue[ 'max' ]
),
$propValue[ 'max' ]
);
} else {
$total_code = array(1 => 'min(', 2 => 'ceil(', 3 => '(', 4 => "{$propValue['step']} > 0 ? ",
@@ -338,7 +330,6 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_Compile_Private_Fo
$propValue[ 'total' ] = join('', $total_code);
}
}
if (isset($namedAttr[ 'loop' ])) {
$initNamedProperty[ 'loop' ] = "'loop' => {$propValue['loop']}";
}
@@ -351,13 +342,10 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_Compile_Private_Fo
$initLocal[ 'total' ] = $propValue[ 'total' ];
$propValue[ 'total' ] = "{$local}total";
}
$cmpFor[ 'iteration' ] = "{$propValue['iteration']} <= {$propValue['total']}";
foreach ($initLocal as $key => $code) {
$output .= "{$local}{$key} = {$code};\n";
}
$_vars = 'array(' . join(', ', $initNamedProperty) . ')';
$output .= "{$sectionVar} = new Smarty_Variable({$_vars});\n";
$cond_code = "{$propValue['total']} !== 0";
@@ -396,7 +384,6 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_Compile_Private_Fo
$output .= "{$sectionVar}->value['last'] = ({$propValue['iteration']} === {$propValue['total']});\n";
}
$output .= '?>';
return $output;
}
}
@@ -421,10 +408,8 @@ class Smarty_Internal_Compile_Sectionelse extends Smarty_Internal_CompileBase
{
// check and get attributes
$_attr = $this->getAttributes($compiler, $args);
list($openTag, $nocache, $local, $sectionVar) = $this->closeTag($compiler, array('section'));
$this->openTag($compiler, 'sectionelse', array('sectionelse', $nocache, $local, $sectionVar));
return "<?php }} else {\n ?>";
}
}
@@ -452,10 +437,8 @@ class Smarty_Internal_Compile_Sectionclose extends Smarty_Internal_CompileBase
if ($compiler->nocache) {
$compiler->tag_nocache = true;
}
list($openTag, $compiler->nocache, $local, $sectionVar) =
$this->closeTag($compiler, array('section', 'sectionelse'));
$output = "<?php\n";
if ($openTag === 'sectionelse') {
$output .= "}\n";
@@ -463,7 +446,6 @@ class Smarty_Internal_Compile_Sectionclose extends Smarty_Internal_CompileBase
$output .= "}\n}\n";
}
$output .= '?>';
return $output;
}
}

View File

@@ -133,7 +133,7 @@ class Smarty_Internal_Configfilelexer
* @param string $data template source
* @param Smarty_Internal_Config_File_Compiler $compiler
*/
function __construct($data, Smarty_Internal_Config_File_Compiler $compiler)
public function __construct($data, Smarty_Internal_Config_File_Compiler $compiler)
{
$this->data = $data . "\n"; //now all lines are \n-terminated
$this->dataLength = strlen($data);
@@ -166,47 +166,35 @@ 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
);
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] : $this->_yy_state);
}
array_push($this->_yy_stack, $this->_yy_state);
$this->_yy_state = $state;
if ($this->yyTraceFILE) {
fprintf(
$this->yyTraceFILE,
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
);
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] : $this->_yy_state);
}
}
public function yypopstate()
{
if ($this->yyTraceFILE) {
fprintf(
$this->yyTraceFILE,
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
);
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] : $this->_yy_state);
}
$this->_yy_state = array_pop($this->_yy_stack);
if ($this->yyTraceFILE) {
fprintf(
$this->yyTraceFILE,
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
);
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] : $this->_yy_state);
}
}
@@ -214,13 +202,10 @@ 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
);
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] : $this->_yy_state);
}
}
@@ -244,14 +229,10 @@ 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
@@ -276,10 +257,8 @@ 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);
@@ -348,14 +327,10 @@ 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
@@ -380,10 +355,8 @@ 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);
@@ -426,9 +399,8 @@ class Smarty_Internal_Configfilelexer
function yy_r2_7()
{
if (!$this->configBooleanize
|| !in_array(strtolower($this->value), array('true', 'false', 'on', 'off', 'yes', 'no'))
) {
if (!$this->configBooleanize ||
!in_array(strtolower($this->value), array('true', 'false', 'on', 'off', 'yes', 'no'))) {
$this->yypopstate();
$this->yypushstate(self::NAKED_STRING_VALUE);
return true; //reprocess in new state
@@ -470,14 +442,10 @@ 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
@@ -502,10 +470,8 @@ 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);
@@ -536,14 +502,10 @@ 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
@@ -568,10 +530,8 @@ 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);
@@ -612,14 +572,10 @@ 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
@@ -644,10 +600,8 @@ 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);
@@ -683,14 +637,10 @@ 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
@@ -715,10 +665,8 @@ 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

@@ -48,7 +48,7 @@ class Smarty_Internal_Configfileparser
const YY_SZ_ACTTAB = 38;
const YY_SHIFT_USE_DFLT = -8;
const YY_SHIFT_MAX = 19;
const YY_REDUCE_USE_DFLT = -21;
const YY_REDUCE_USE_DFLT = -17;
const YY_REDUCE_MAX = 10;
const YYNOCODE = 29;
const YYSTACKDEPTH = 100;
@@ -58,24 +58,24 @@ class Smarty_Internal_Configfileparser
const YYERRSYMDT = 'yy0';
const YYFALLBACK = 0;
static public $yy_action = array(
29, 30, 34, 33, 24, 13, 19, 25, 35, 21,
59, 8, 3, 1, 20, 12, 14, 31, 20, 12,
15, 17, 23, 18, 27, 26, 4, 5, 6, 32,
2, 11, 28, 22, 16, 9, 7, 10,
32, 31, 30, 29, 35, 13, 19, 3, 24, 26,
59, 9, 14, 1, 16, 25, 11, 28, 25, 11,
17, 27, 34, 20, 18, 15, 23, 5, 6, 22,
10, 8, 4, 12, 2, 33, 7, 21,
);
static public $yy_lookahead = array(
7, 8, 9, 10, 11, 12, 5, 27, 15, 16,
20, 21, 23, 23, 17, 18, 13, 14, 17, 18,
15, 2, 17, 4, 25, 26, 6, 3, 3, 14,
23, 1, 24, 17, 2, 25, 22, 25,
7, 8, 9, 10, 11, 12, 5, 23, 15, 16,
20, 21, 2, 23, 4, 17, 18, 14, 17, 18,
13, 14, 25, 26, 15, 2, 17, 3, 3, 17,
25, 25, 6, 1, 23, 27, 22, 24,
);
static public $yy_shift_ofst = array(
-8, 1, 1, 1, -7, -3, -3, 30, -8, -8,
-8, 19, 5, 3, 15, 16, 24, 25, 32, 20,
-8, 1, 1, 1, -7, -2, -2, 32, -8, -8,
-8, 9, 10, 7, 25, 24, 23, 3, 12, 26,
);
static public $yy_reduce_ofst = array(
-10, -1, -1, -1, -20, 10, 12, 8, 14, 7,
-11,
-10, -3, -3, -3, 8, 6, 5, 13, 11, 14,
-16,
);
static public $yyExpectedTokens = array(
array(),
@@ -89,14 +89,14 @@ class Smarty_Internal_Configfileparser
array(),
array(),
array(),
array(2, 4,),
array(15, 17,),
array(2, 4,),
array(13, 14,),
array(14,),
array(17,),
array(3,),
array(3,),
array(2,),
array(14,),
array(17,),
array(6,),
array(),
array(),
@@ -116,10 +116,10 @@ class Smarty_Internal_Configfileparser
array(),
);
static public $yy_default = array(
44, 37, 41, 40, 58, 58, 58, 36, 39, 44,
44, 37, 41, 40, 58, 58, 58, 36, 44, 39,
44, 58, 58, 58, 58, 58, 58, 58, 58, 58,
55, 54, 57, 56, 50, 45, 43, 42, 38, 46,
47, 52, 51, 49, 48, 53,
43, 38, 57, 56, 53, 55, 54, 52, 51, 49,
48, 47, 46, 45, 42, 50,
);
public static $yyFallback = array();
public static $yyRuleName = array(
@@ -275,7 +275,7 @@ class Smarty_Internal_Configfileparser
* @param Smarty_Internal_Configfilelexer $lex
* @param Smarty_Internal_Config_File_Compiler $compiler
*/
function __construct(Smarty_Internal_Configfilelexer $lex, Smarty_Internal_Config_File_Compiler $compiler)
public function __construct(Smarty_Internal_Configfilelexer $lex, Smarty_Internal_Config_File_Compiler $compiler)
{
$this->lex = $lex;
$this->smarty = $compiler->smarty;
@@ -375,11 +375,9 @@ 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);
@@ -431,8 +429,7 @@ 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 ])) {
@@ -442,8 +439,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);
@@ -518,8 +515,7 @@ 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;
@@ -527,13 +523,9 @@ class Smarty_Internal_Configfileparser
return true;
}
} else {
if ($res2[ $nextstate ][ $token ] = (isset(self::$yyExpectedTokens[ $nextstate ])
&& in_array(
$token,
self::$yyExpectedTokens[ $nextstate ],
true
))
) {
if ($res2[ $nextstate ][ $token ] =
(isset(self::$yyExpectedTokens[ $nextstate ]) &&
in_array($token, self::$yyExpectedTokens[ $nextstate ], true))) {
$this->yyidx = $yyidx;
$this->yystack = $stack;
return true;
@@ -591,19 +583,15 @@ 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);
}
@@ -627,9 +615,8 @@ 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 ];
@@ -658,19 +645,15 @@ 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");
}
@@ -697,10 +680,8 @@ class Smarty_Internal_Configfileparser
function yy_r5()
{
if ($this->configReadHidden) {
$this->add_section_vars(
$this->yystack[ $this->yyidx + -3 ]->minor,
$this->yystack[ $this->yyidx + 0 ]->minor
);
$this->add_section_vars($this->yystack[ $this->yyidx + -3 ]->minor,
$this->yystack[ $this->yyidx + 0 ]->minor);
}
$this->_retvalue = null;
}
@@ -727,7 +708,8 @@ class Smarty_Internal_Configfileparser
// line 277 "../smarty/lexer/smarty_internal_configfileparser.y"
function yy_r9()
{
$this->_retvalue = array('key' => $this->yystack[ $this->yyidx + -2 ]->minor,
$this->_retvalue =
array('key' => $this->yystack[ $this->yyidx + -2 ]->minor,
'value' => $this->yystack[ $this->yyidx + 0 ]->minor);
}
@@ -783,15 +765,12 @@ class Smarty_Internal_Configfileparser
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 ])) {
@@ -872,18 +851,15 @@ 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;
}
@@ -899,11 +875,9 @@ class Smarty_Internal_Configfileparser
$this->yy_reduce($yyact - self::YYNSTATE);
} elseif ($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) {
@@ -912,12 +886,10 @@ 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

@@ -206,9 +206,12 @@ abstract class Smarty_Internal_Data
* @return Smarty_Variable|Smarty_Undefined_Variable the object of the variable
* @deprecated since 3.1.28 please use Smarty_Internal_Data::getTemplateVars() instead.
*/
public function getVariable($variable = null, Smarty_Internal_Data $_ptr = null, $searchParents = true,
public function getVariable($variable = null,
Smarty_Internal_Data $_ptr = null,
$searchParents = true,
$error_enable = true
) {
)
{
return $this->ext->getTemplateVars->_getVariable($this, $variable, $_ptr, $searchParents, $error_enable);
}
@@ -281,7 +284,6 @@ abstract class Smarty_Internal_Data
* @param array $args argument array
*
* @return mixed
* @throws SmartyException
*/
public function __call($name, $args)
{

View File

@@ -211,7 +211,7 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
// copy the working dirs from application
$debObj->setCompileDir($smarty->getCompileDir());
// init properties by hand as user may have edited the original Smarty class
$debObj->setPluginsDir(is_dir(__DIR__ . '/../plugins') ? __DIR__ . '/../plugins' : $smarty->getPluginsDir());
$debObj->setPluginsDir(is_dir(dirname(__FILE__) . '/../plugins') ? dirname(__FILE__) . '/../plugins' : $smarty->getPluginsDir());
$debObj->force_compile = false;
$debObj->compile_check = Smarty::COMPILECHECK_ON;
$debObj->left_delimiter = '{';
@@ -220,7 +220,7 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
$debObj->debugging = false;
$debObj->debugging_ctrl = 'NONE';
$debObj->error_reporting = E_ALL & ~E_NOTICE;
$debObj->debug_tpl = isset($smarty->debug_tpl) ? $smarty->debug_tpl : 'file:' . __DIR__ . '/../debug.tpl';
$debObj->debug_tpl = isset($smarty->debug_tpl) ? $smarty->debug_tpl : 'file:' . dirname(__FILE__) . '/../debug.tpl';
$debObj->registered_plugins = array();
$debObj->registered_resources = array();
$debObj->registered_filters = array();

View File

@@ -24,7 +24,6 @@ class Smarty_Internal_ErrorHandler
/**
* Enable error handler to mute expected messages
*
* @return boolean
*/
public static function muteExpectedErrors()
{

View File

@@ -61,7 +61,6 @@ class Smarty_Internal_Extension_Handler
* @param array $args argument array
*
* @return mixed
* @throws SmartyException
*/
public function _callExternalMethod(Smarty_Internal_Data $data, $name, $args)
{
@@ -156,7 +155,6 @@ class Smarty_Internal_Extension_Handler
* @param string $property_name property name
*
* @return mixed|Smarty_Template_Cached
* @throws SmartyException
*/
public function __get($property_name)
{
@@ -178,7 +176,6 @@ class Smarty_Internal_Extension_Handler
* @param string $property_name property name
* @param mixed $value value
*
* @throws SmartyException
*/
public function __set($property_name, $value)
{
@@ -192,7 +189,6 @@ class Smarty_Internal_Extension_Handler
* @param array $args argument array
*
* @return mixed
* @throws SmartyException
*/
public function __call($name, $args)
{

View File

@@ -52,7 +52,6 @@ class Smarty_Internal_Method_ConfigLoad
* @param int $scope scope into which config variables
* shall be loaded
*
* @return \Smarty|\Smarty_Internal_Data|\Smarty_Internal_Template
* @throws \Exception
*/
public function _loadConfigFile(Smarty_Internal_Data $data, $config_file, $sections = null, $scope = 0)

View File

@@ -29,7 +29,7 @@ class Smarty_Internal_Method_CreateData
* variables
* @param string $name optional data block name
*
* @returns Smarty_Data data object
* @return \Smarty_Data data object
*/
public function createData(Smarty_Internal_TemplateBase $obj, Smarty_Internal_Data $parent = null, $name = null)
{

View File

@@ -26,7 +26,6 @@ class Smarty_Internal_Resource_Stream extends Smarty_Resource_Recompiled
* @param Smarty_Internal_Template $_template template object
*
* @return void
* @throws \SmartyException
*/
public function populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template = null)
{
@@ -46,7 +45,6 @@ class Smarty_Internal_Resource_Stream extends Smarty_Resource_Recompiled
* @param Smarty_Template_Source $source source object
*
* @return string template source
* @throws SmartyException if source cannot be loaded
*/
public function getContent(Smarty_Template_Source $source)
{

View File

@@ -31,7 +31,6 @@ class Smarty_Internal_Runtime_CacheModify
case 'fpm-fcgi': // php-fpm >= 5.3.3
header('Status: 304 Not Modified');
break;
case 'cli':
if (/* ^phpunit */
!empty($_SERVER[ 'SMARTY_PHPUNIT_DISABLE_HEADERS' ]) /* phpunit$ */
@@ -39,7 +38,6 @@ class Smarty_Internal_Runtime_CacheModify
$_SERVER[ 'SMARTY_PHPUNIT_HEADERS' ][] = '304 Not Modified';
}
break;
default:
if (/* ^phpunit */
!empty($_SERVER[ 'SMARTY_PHPUNIT_DISABLE_HEADERS' ]) /* phpunit$ */

View File

@@ -26,6 +26,29 @@
*/
class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
{
/**
* Template object cache
*
* @var Smarty_Internal_Template[]
*/
public static $tplObjCache = array();
/**
* Template object cache for Smarty::isCached() === true
*
* @var Smarty_Internal_Template[]
*/
public static $isCacheTplObj = array();
/**
* Sub template Info Cache
* - index name
* - value use count
*
* @var int[]
*/
public static $subTplInfo = array();
/**
* This object type (Smarty = 1, template = 2, data = 4)
*
@@ -103,29 +126,6 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
*/
public $endRenderCallbacks = array();
/**
* Template object cache
*
* @var Smarty_Internal_Template[]
*/
public static $tplObjCache = array();
/**
* Template object cache for Smarty::isCached() === true
*
* @var Smarty_Internal_Template[]
*/
public static $isCacheTplObj = array();
/**
* Sub template Info Cache
* - index name
* - value use count
*
* @var int[]
*/
public static $subTplInfo = array();
/**
* Create template data object
* Some of the global Smarty settings copied to template scope
@@ -133,20 +133,28 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
*
* @param string $template_resource template resource string
* @param Smarty $smarty Smarty instance
* @param null|\Smarty_Internal_Template|\Smarty|\Smarty_Internal_Data $_parent back pointer to parent object
* with variables or null
* @param null|\Smarty_Internal_Template|\Smarty|\Smarty_Internal_Data $_parent back pointer to parent
* object with variables or
* null
* @param mixed $_cache_id cache id or null
* @param mixed $_compile_id compile id or null
* @param bool|int|null $_caching use caching?
* @param int|null $_cache_lifetime cache life-time in seconds
* @param int|null $_cache_lifetime cache life-time in
* seconds
* @param bool $_isConfig
*
* @throws \SmartyException
*/
public function __construct($template_resource, Smarty $smarty, Smarty_Internal_Data $_parent = null,
$_cache_id = null, $_compile_id = null, $_caching = null, $_cache_lifetime = null,
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
) {
)
{
$this->smarty = $smarty;
// Smarty parameter
$this->cache_id = $_cache_id === null ? $this->smarty->cache_id : $_cache_id;
@@ -207,12 +215,12 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
}
$this->compiled->render($this);
}
// display or fetch
if ($display) {
if ($this->caching && $this->smarty->cache_modified_check) {
$this->smarty->ext->_cacheModify->cacheModifiedCheck(
$this->cached, $this,
$this->cached,
$this,
isset($content) ? $content : ob_get_clean()
);
} else {
@@ -267,9 +275,18 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
* @throws \Exception
* @throws \SmartyException
*/
public function _subTemplateRender($template, $cache_id, $compile_id, $caching, $cache_lifetime, $data, $scope,
$forceTplCache, $uid = null, $content_func = null
) {
public function _subTemplateRender($template,
$cache_id,
$compile_id,
$caching,
$cache_lifetime,
$data,
$scope,
$forceTplCache,
$uid = null,
$content_func = null
)
{
$tpl = clone $this;
$tpl->parent = $this;
$smarty = &$this->smarty;
@@ -333,7 +350,6 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
self::$tplObjCache[ $tpl->templateId ] = $tpl;
}
}
if (!empty($data)) {
// set up variable values
foreach ($data as $_key => $_val) {
@@ -653,6 +669,35 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
return parent::__call($name, $args);
}
/**
* get Smarty property in template context
*
* @param string $property_name property name
*
* @return mixed|Smarty_Template_Cached
* @throws SmartyException
*/
public function __get($property_name)
{
switch ($property_name) {
case 'compiled':
$this->loadCompiled();
return $this->compiled;
case 'cached':
$this->loadCached();
return $this->cached;
case 'compiler':
$this->loadCompiler();
return $this->compiler;
default:
// Smarty property ?
if (property_exists($this->smarty, $property_name)) {
return $this->smarty->$property_name;
}
}
throw new SmartyException("template property '$property_name' does not exist.");
}
/**
* set Smarty property in template context
*
@@ -679,37 +724,6 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
throw new SmartyException("invalid template property '$property_name'.");
}
/**
* get Smarty property in template context
*
* @param string $property_name property name
*
* @return mixed|Smarty_Template_Cached
* @throws SmartyException
*/
public function __get($property_name)
{
switch ($property_name) {
case 'compiled':
$this->loadCompiled();
return $this->compiled;
case 'cached':
$this->loadCached();
return $this->cached;
case 'compiler':
$this->loadCompiler();
return $this->compiler;
default:
// Smarty property ?
if (property_exists($this->smarty, $property_name)) {
return $this->smarty->$property_name;
}
}
throw new SmartyException("template property '$property_name' does not exist.");
}
/**
* Template data object destructor
*/

View File

@@ -271,7 +271,7 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data
* @param mixed $cache_attr caching attributes if any
*
* @return \Smarty|\Smarty_Internal_Template
* @throws SmartyException when the plugin tag is invalid
* @throws \SmartyException
*/
public function registerPlugin($type, $name, $callback, $cacheable = true, $cache_attr = null)
{
@@ -288,7 +288,7 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data
* @param string $name filter name
*
* @return bool
* @throws SmartyException if filter could not be loaded
* @throws \SmartyException
*/
public function loadFilter($type, $name)
{

View File

@@ -328,7 +328,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
array('.',
','),
'_',
uniqid(rand(), true)
uniqid(mt_rand(), true)
);
}
@@ -717,7 +717,6 @@ abstract class Smarty_Internal_TemplateCompilerBase
* @param string $tag tag name
*
* @return bool|\Smarty_Internal_CompileBase tag compiler object or false if not found
* @throws \SmartyCompilerException
*/
public function getTagCompiler($tag)
{

View File

@@ -13,6 +13,7 @@
* 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
@@ -200,7 +201,7 @@ class Smarty_Internal_Templatelexer
* @param string $source template source
* @param Smarty_Internal_TemplateCompilerBase $compiler
*/
function __construct($source, Smarty_Internal_TemplateCompilerBase $compiler)
public function __construct($source, Smarty_Internal_TemplateCompilerBase $compiler)
{
$this->data = $source;
$this->dataLength = strlen($this->data);
@@ -218,6 +219,7 @@ class Smarty_Internal_Templatelexer
/**
* open lexer/parser trace file
*
*/
public function PrintTrace()
{
@@ -256,47 +258,35 @@ 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
);
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] : $this->_yy_state);
}
array_push($this->_yy_stack, $this->_yy_state);
$this->_yy_state = $state;
if ($this->yyTraceFILE) {
fprintf(
$this->yyTraceFILE,
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
);
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] : $this->_yy_state);
}
}
public function yypopstate()
{
if ($this->yyTraceFILE) {
fprintf(
$this->yyTraceFILE,
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
);
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] : $this->_yy_state);
}
$this->_yy_state = array_pop($this->_yy_stack);
if ($this->yyTraceFILE) {
fprintf(
$this->yyTraceFILE,
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
);
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] : $this->_yy_state);
}
}
@@ -304,13 +294,10 @@ 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
);
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] : $this->_yy_state);
}
}
@@ -334,14 +321,10 @@ class Smarty_Internal_Templatelexer
$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
@@ -366,10 +349,8 @@ class Smarty_Internal_Templatelexer
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);
@@ -382,13 +363,11 @@ class Smarty_Internal_Templatelexer
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 {
@@ -456,14 +435,10 @@ class Smarty_Internal_Templatelexer
$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
@@ -488,10 +463,8 @@ class Smarty_Internal_Templatelexer
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);
@@ -601,14 +574,10 @@ class Smarty_Internal_Templatelexer
$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
@@ -633,10 +602,8 @@ class Smarty_Internal_Templatelexer
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);
@@ -794,8 +761,8 @@ class Smarty_Internal_Templatelexer
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;
@@ -895,14 +862,10 @@ class Smarty_Internal_Templatelexer
$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
@@ -927,10 +890,8 @@ class Smarty_Internal_Templatelexer
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);
@@ -978,14 +939,10 @@ class Smarty_Internal_Templatelexer
$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
@@ -1010,10 +967,8 @@ class Smarty_Internal_Templatelexer
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

View File

@@ -267,7 +267,6 @@ class Smarty_Security
* @param object $compiler compiler object
*
* @return boolean true if function is trusted
* @throws SmartyCompilerException if php function is not trusted
*/
public function isTrustedPhpFunction($function_name, $compiler)
{
@@ -289,7 +288,6 @@ class Smarty_Security
* @param object $compiler compiler object
*
* @return boolean true if class is trusted
* @throws SmartyCompilerException if static class is not trusted
*/
public function isTrustedStaticClass($class_name, $compiler)
{
@@ -312,7 +310,6 @@ class Smarty_Security
* @param object $compiler compiler object
*
* @return boolean true if class method is trusted
* @throws SmartyCompilerException if static class method is not trusted
*/
public function isTrustedStaticClassAccess($class_name, $params, $compiler)
{
@@ -350,7 +347,6 @@ class Smarty_Security
* @param object $compiler compiler object
*
* @return boolean true if modifier is trusted
* @throws SmartyCompilerException if modifier is not trusted
*/
public function isTrustedPhpModifier($modifier_name, $compiler)
{
@@ -372,7 +368,6 @@ class Smarty_Security
* @param object $compiler compiler object
*
* @return boolean true if tag is trusted
* @throws SmartyCompilerException if modifier is not trusted
*/
public function isTrustedTag($tag_name, $compiler)
{
@@ -410,7 +405,6 @@ class Smarty_Security
* @param object $compiler compiler object
*
* @return boolean true if tag is trusted
* @throws SmartyCompilerException if modifier is not trusted
*/
public function isTrustedSpecialSmartyVar($var_name, $compiler)
{
@@ -433,7 +427,6 @@ class Smarty_Security
* @param object $compiler compiler object
*
* @return boolean true if tag is trusted
* @throws SmartyCompilerException if modifier is not trusted
*/
public function isTrustedModifier($modifier_name, $compiler)
{

View File

@@ -6,7 +6,7 @@
* Time: 23:58
*/
$sysplugins = array();
$iterator = new DirectoryIterator(__DIR__ . '/../libs/sysplugins');
$iterator = new DirectoryIterator(dirname(__FILE__) . '/../libs/sysplugins');
foreach ($iterator as $file) {
if (!$file->isDot() && 'php' == $file->getExtension()) {
$filename = $file->getBasename();
@@ -14,17 +14,17 @@ foreach ($iterator as $file) {
}
}
$plugins = array();
$iterator = new DirectoryIterator(__DIR__ . '/../libs/plugins');
$iterator = new DirectoryIterator(dirname(__FILE__) . '/../libs/plugins');
foreach ($iterator as $file) {
if (!$file->isDot() && 'php' == $file->getExtension()) {
$filename = $file->getBasename();
$plugins[ $filename ] = true;
}
}
$code = file_get_contents(__DIR__ . '/../libs/sysplugins/smarty_internal_testinstall.php');
$code = file_get_contents(dirname(__FILE__) . '/../libs/sysplugins/smarty_internal_testinstall.php');
$expectedPlugins = '$expectedPlugins = ' . var_export($plugins, true);
$code = preg_replace('#\$expectedPlugins =[^;]+#', $expectedPlugins, $code);
$expectedSysplugins = '$expectedSysplugins = ' . var_export($sysplugins, true);
$code = preg_replace('#\$expectedSysplugins =[^;]+#', $expectedSysplugins, $code);
file_put_contents(__DIR__ . '/../libs/sysplugins/smarty_internal_testinstall.php', $code);
file_put_contents(dirname(__FILE__) . '/../libs/sysplugins/smarty_internal_testinstall.php', $code);