Removed redundant code

This commit is contained in:
Uwe Tews
2015-05-18 04:26:46 +02:00
parent ac99173cea
commit ed740b967a

View File

@@ -111,21 +111,28 @@ class Smarty extends Smarty_Internal_TemplateBase
/** /**
* smarty version * smarty version
*/ */
const SMARTY_VERSION = '3.1.24-dev/6'; const SMARTY_VERSION = '3.1.24-dev/7';
/** /**
* define variable scopes * define variable scopes
*/ */
const SCOPE_LOCAL = 0; const SCOPE_LOCAL = 0;
const SCOPE_PARENT = 1; const SCOPE_PARENT = 1;
const SCOPE_ROOT = 2; const SCOPE_ROOT = 2;
const SCOPE_GLOBAL = 3; const SCOPE_GLOBAL = 3;
/** /**
* define caching modes * define caching modes
*/ */
const CACHING_OFF = 0; const CACHING_OFF = 0;
const CACHING_LIFETIME_CURRENT = 1; const CACHING_LIFETIME_CURRENT = 1;
const CACHING_LIFETIME_SAVED = 2; const CACHING_LIFETIME_SAVED = 2;
/** /**
* define constant for clearing cache files be saved expiration datees * define constant for clearing cache files be saved expiration datees
*/ */
@@ -135,36 +142,53 @@ class Smarty extends Smarty_Internal_TemplateBase
* define compile check modes * define compile check modes
*/ */
const COMPILECHECK_OFF = 0; const COMPILECHECK_OFF = 0;
const COMPILECHECK_ON = 1; const COMPILECHECK_ON = 1;
const COMPILECHECK_CACHEMISS = 2; const COMPILECHECK_CACHEMISS = 2;
/** /**
* define debug modes * define debug modes
*/ */
const DEBUG_OFF = 0; const DEBUG_OFF = 0;
const DEBUG_ON = 1; const DEBUG_ON = 1;
const DEBUG_INDIVIDUAL = 2; const DEBUG_INDIVIDUAL = 2;
/** /**
* modes for handling of "<?php ... ?>" tags in templates. * modes for handling of "<?php ... ?>" tags in templates.
*/ */
const PHP_PASSTHRU = 0; //-> print tags as plain text const PHP_PASSTHRU = 0; //-> print tags as plain text
const PHP_QUOTE = 1; //-> escape tags as entities const PHP_QUOTE = 1; //-> escape tags as entities
const PHP_REMOVE = 2; //-> escape tags as entities const PHP_REMOVE = 2; //-> escape tags as entities
const PHP_ALLOW = 3; //-> escape tags as entities const PHP_ALLOW = 3; //-> escape tags as entities
/** /**
* filter types * filter types
*/ */
const FILTER_POST = 'post'; const FILTER_POST = 'post';
const FILTER_PRE = 'pre'; const FILTER_PRE = 'pre';
const FILTER_OUTPUT = 'output'; const FILTER_OUTPUT = 'output';
const FILTER_VARIABLE = 'variable'; const FILTER_VARIABLE = 'variable';
/** /**
* plugin types * plugin types
*/ */
const PLUGIN_FUNCTION = 'function'; const PLUGIN_FUNCTION = 'function';
const PLUGIN_BLOCK = 'block'; const PLUGIN_BLOCK = 'block';
const PLUGIN_COMPILER = 'compiler'; const PLUGIN_COMPILER = 'compiler';
const PLUGIN_MODIFIER = 'modifier'; const PLUGIN_MODIFIER = 'modifier';
const PLUGIN_MODIFIERCOMPILER = 'modifiercompiler'; const PLUGIN_MODIFIERCOMPILER = 'modifiercompiler';
/**#@-*/ /**#@-*/
@@ -178,23 +202,29 @@ class Smarty extends Smarty_Internal_TemplateBase
* error handler returned by set_error_hanlder() in Smarty::muteExpectedErrors() * error handler returned by set_error_hanlder() in Smarty::muteExpectedErrors()
*/ */
public static $_previous_error_handler = null; public static $_previous_error_handler = null;
/** /**
* contains directories outside of SMARTY_DIR that are to be muted by muteExpectedErrors() * contains directories outside of SMARTY_DIR that are to be muted by muteExpectedErrors()
*/ */
public static $_muted_directories = array('./templates_c/' => null, './cache/' => null); public static $_muted_directories = array('./templates_c/' => null,
'./cache/' => null);
/** /**
* Flag denoting if Multibyte String functions are available * Flag denoting if Multibyte String functions are available
*/ */
public static $_MBSTRING = SMARTY_MBSTRING; public static $_MBSTRING = SMARTY_MBSTRING;
/** /**
* The character set to adhere to (e.g. "UTF-8") * The character set to adhere to (e.g. "UTF-8")
*/ */
public static $_CHARSET = SMARTY_RESOURCE_CHAR_SET; public static $_CHARSET = SMARTY_RESOURCE_CHAR_SET;
/** /**
* The date format to be used internally * The date format to be used internally
* (accepts date() and strftime()) * (accepts date() and strftime())
*/ */
public static $_DATE_FORMAT = SMARTY_RESOURCE_DATE_FORMAT; public static $_DATE_FORMAT = SMARTY_RESOURCE_DATE_FORMAT;
/** /**
* Flag denoting if PCRE should run in UTF-8 mode * Flag denoting if PCRE should run in UTF-8 mode
*/ */
@@ -215,132 +245,154 @@ class Smarty extends Smarty_Internal_TemplateBase
* @var boolean * @var boolean
*/ */
public $auto_literal = true; public $auto_literal = true;
/** /**
* display error on not assigned variables * display error on not assigned variables
* *
* @var boolean * @var boolean
*/ */
public $error_unassigned = false; public $error_unassigned = false;
/** /**
* look up relative filepaths in include_path * look up relative filepaths in include_path
* *
* @var boolean * @var boolean
*/ */
public $use_include_path = false; public $use_include_path = false;
/** /**
* template directory * template directory
* *
* @var array * @var array
*/ */
private $template_dir = array('./templates/'); private $template_dir = array('./templates/');
/** /**
* joined template directory string used in cache keys * joined template directory string used in cache keys
* *
* @var string * @var string
*/ */
public $joined_template_dir = './templates/'; public $joined_template_dir = './templates/';
/** /**
* joined config directory string used in cache keys * joined config directory string used in cache keys
* *
* @var string * @var string
*/ */
public $joined_config_dir = './configs/'; public $joined_config_dir = './configs/';
/** /**
* default template handler * default template handler
* *
* @var callable * @var callable
*/ */
public $default_template_handler_func = null; public $default_template_handler_func = null;
/** /**
* default config handler * default config handler
* *
* @var callable * @var callable
*/ */
public $default_config_handler_func = null; public $default_config_handler_func = null;
/** /**
* default plugin handler * default plugin handler
* *
* @var callable * @var callable
*/ */
public $default_plugin_handler_func = null; public $default_plugin_handler_func = null;
/** /**
* compile directory * compile directory
* *
* @var string * @var string
*/ */
private $compile_dir = './templates_c/'; private $compile_dir = './templates_c/';
/** /**
* plugins directory * plugins directory
* *
* @var array * @var array
*/ */
private $plugins_dir = null; private $plugins_dir = null;
/** /**
* cache directory * cache directory
* *
* @var string * @var string
*/ */
private $cache_dir = './cache/'; private $cache_dir = './cache/';
/** /**
* config directory * config directory
* *
* @var array * @var array
*/ */
private $config_dir = array('./configs/'); private $config_dir = array('./configs/');
/** /**
* force template compiling? * force template compiling?
* *
* @var boolean * @var boolean
*/ */
public $force_compile = false; public $force_compile = false;
/** /**
* check template for modifications? * check template for modifications?
* *
* @var boolean * @var boolean
*/ */
public $compile_check = true; public $compile_check = true;
/** /**
* use sub dirs for compiled/cached files? * use sub dirs for compiled/cached files?
* *
* @var boolean * @var boolean
*/ */
public $use_sub_dirs = false; public $use_sub_dirs = false;
/** /**
* allow ambiguous resources (that are made unique by the resource handler) * allow ambiguous resources (that are made unique by the resource handler)
* *
* @var boolean * @var boolean
*/ */
public $allow_ambiguous_resources = false; public $allow_ambiguous_resources = false;
/** /**
* merge compiled includes * merge compiled includes
* *
* @var boolean * @var boolean
*/ */
public $merge_compiled_includes = false; public $merge_compiled_includes = false;
/** /**
* template inheritance merge compiled includes * template inheritance merge compiled includes
* *
* @var boolean * @var boolean
*/ */
public $inheritance_merge_compiled_includes = true; public $inheritance_merge_compiled_includes = true;
/** /**
* force cache file creation * force cache file creation
* *
* @var boolean * @var boolean
*/ */
public $force_cache = false; public $force_cache = false;
/** /**
* template left-delimiter * template left-delimiter
* *
* @var string * @var string
*/ */
public $left_delimiter = "{"; public $left_delimiter = "{";
/** /**
* template right-delimiter * template right-delimiter
* *
* @var string * @var string
*/ */
public $right_delimiter = "}"; public $right_delimiter = "}";
/**#@+ /**#@+
* security * security
*/ */
@@ -352,24 +404,28 @@ class Smarty extends Smarty_Internal_TemplateBase
* @see Smarty_Security * @see Smarty_Security
*/ */
public $security_class = 'Smarty_Security'; public $security_class = 'Smarty_Security';
/** /**
* implementation of security class * implementation of security class
* *
* @var Smarty_Security * @var Smarty_Security
*/ */
public $security_policy = null; public $security_policy = null;
/** /**
* controls handling of PHP-blocks * controls handling of PHP-blocks
* *
* @var integer * @var integer
*/ */
public $php_handling = self::PHP_PASSTHRU; public $php_handling = self::PHP_PASSTHRU;
/** /**
* controls if the php template file resource is allowed * controls if the php template file resource is allowed
* *
* @var bool * @var bool
*/ */
public $allow_php_templates = false; public $allow_php_templates = false;
/** /**
* Should compiled-templates be prevented from being called directly? * Should compiled-templates be prevented from being called directly?
* {@internal * {@internal
@@ -379,6 +435,7 @@ class Smarty extends Smarty_Internal_TemplateBase
* @var boolean * @var boolean
*/ */
public $direct_access_security = true; public $direct_access_security = true;
/**#@-*/ /**#@-*/
/** /**
* debug mode * debug mode
@@ -387,6 +444,7 @@ class Smarty extends Smarty_Internal_TemplateBase
* @var boolean * @var boolean
*/ */
public $debugging = false; public $debugging = false;
/** /**
* This determines if debugging is enable-able from the browser. * This determines if debugging is enable-able from the browser.
* <ul> * <ul>
@@ -397,6 +455,7 @@ class Smarty extends Smarty_Internal_TemplateBase
* @var string * @var string
*/ */
public $debugging_ctrl = 'NONE'; public $debugging_ctrl = 'NONE';
/** /**
* Name of debugging URL-param. * Name of debugging URL-param.
* Only used when $debugging_ctrl is set to 'URL'. * Only used when $debugging_ctrl is set to 'URL'.
@@ -405,12 +464,14 @@ class Smarty extends Smarty_Internal_TemplateBase
* @var string * @var string
*/ */
public $smarty_debug_id = 'SMARTY_DEBUG'; public $smarty_debug_id = 'SMARTY_DEBUG';
/** /**
* Path of debug template. * Path of debug template.
* *
* @var string * @var string
*/ */
public $debug_tpl = null; public $debug_tpl = null;
/** /**
* When set, smarty uses this value as error_reporting-level. * When set, smarty uses this value as error_reporting-level.
* *
@@ -435,12 +496,14 @@ class Smarty extends Smarty_Internal_TemplateBase
* @var boolean * @var boolean
*/ */
public $config_overwrite = true; public $config_overwrite = true;
/** /**
* Controls whether config values of on/true/yes and off/false/no get converted to boolean. * Controls whether config values of on/true/yes and off/false/no get converted to boolean.
* *
* @var boolean * @var boolean
*/ */
public $config_booleanize = true; public $config_booleanize = true;
/** /**
* Controls whether hidden config sections/vars are read from the file. * Controls whether hidden config sections/vars are read from the file.
* *
@@ -460,12 +523,14 @@ class Smarty extends Smarty_Internal_TemplateBase
* @var boolean * @var boolean
*/ */
public $compile_locking = true; public $compile_locking = true;
/** /**
* Controls whether cache resources should emply locking mechanism * Controls whether cache resources should emply locking mechanism
* *
* @var boolean * @var boolean
*/ */
public $cache_locking = false; public $cache_locking = false;
/** /**
* seconds to wait for acquiring a lock before ignoring the write lock * seconds to wait for acquiring a lock before ignoring the write lock
* *
@@ -482,6 +547,7 @@ class Smarty extends Smarty_Internal_TemplateBase
* @var string * @var string
*/ */
public $default_resource_type = 'file'; public $default_resource_type = 'file';
/** /**
* caching type * caching type
* Must be an element of $cache_resource_types. * Must be an element of $cache_resource_types.
@@ -489,24 +555,28 @@ class Smarty extends Smarty_Internal_TemplateBase
* @var string * @var string
*/ */
public $caching_type = 'file'; public $caching_type = 'file';
/** /**
* internal config properties * internal config properties
* *
* @var array * @var array
*/ */
public $properties = array(); public $properties = array();
/** /**
* config type * config type
* *
* @var string * @var string
*/ */
public $default_config_type = 'file'; public $default_config_type = 'file';
/** /**
* cached template objects * cached template objects
* *
* @var array * @var array
*/ */
public $source_objects = array(); public $source_objects = array();
/** /**
* cached template objects * cached template objects
* *
@@ -520,126 +590,150 @@ class Smarty extends Smarty_Internal_TemplateBase
* @var bool * @var bool
*/ */
public $resource_caching = false; public $resource_caching = false;
/** /**
* enable template resource caching * enable template resource caching
* *
* @var bool * @var bool
*/ */
public $template_resource_caching = true; public $template_resource_caching = true;
/** /**
* check If-Modified-Since headers * check If-Modified-Since headers
* *
* @var boolean * @var boolean
*/ */
public $cache_modified_check = false; public $cache_modified_check = false;
/** /**
* registered plugins * registered plugins
* *
* @var array * @var array
*/ */
public $registered_plugins = array(); public $registered_plugins = array();
/** /**
* plugin search order * plugin search order
* *
* @var array * @var array
*/ */
public $plugin_search_order = array('function', 'block', 'compiler', 'class'); public $plugin_search_order = array('function',
'block',
'compiler',
'class');
/** /**
* registered objects * registered objects
* *
* @var array * @var array
*/ */
public $registered_objects = array(); public $registered_objects = array();
/** /**
* registered classes * registered classes
* *
* @var array * @var array
*/ */
public $registered_classes = array(); public $registered_classes = array();
/** /**
* registered filters * registered filters
* *
* @var array * @var array
*/ */
public $registered_filters = array(); public $registered_filters = array();
/** /**
* registered resources * registered resources
* *
* @var array * @var array
*/ */
public $registered_resources = array(); public $registered_resources = array();
/** /**
* resource handler cache * resource handler cache
* *
* @var array * @var array
*/ */
public $_resource_handlers = array(); public $_resource_handlers = array();
/** /**
* registered cache resources * registered cache resources
* *
* @var array * @var array
*/ */
public $registered_cache_resources = array(); public $registered_cache_resources = array();
/** /**
* cache resource handler cache * cache resource handler cache
* *
* @var array * @var array
*/ */
public $_cacheresource_handlers = array(); public $_cacheresource_handlers = array();
/** /**
* autoload filter * autoload filter
* *
* @var array * @var array
*/ */
public $autoload_filters = array(); public $autoload_filters = array();
/** /**
* default modifier * default modifier
* *
* @var array * @var array
*/ */
public $default_modifiers = array(); public $default_modifiers = array();
/** /**
* autoescape variable output * autoescape variable output
* *
* @var boolean * @var boolean
*/ */
public $escape_html = false; public $escape_html = false;
/** /**
* global internal smarty vars * global internal smarty vars
* *
* @var array * @var array
*/ */
public static $_smarty_vars = array(); public static $_smarty_vars = array();
/** /**
* start time for execution time calculation * start time for execution time calculation
* *
* @var int * @var int
*/ */
public $start_time = 0; public $start_time = 0;
/** /**
* default file permissions * default file permissions
* *
* @var int * @var int
*/ */
public $_file_perms = 0644; public $_file_perms = 0644;
/** /**
* default dir permissions * default dir permissions
* *
* @var int * @var int
*/ */
public $_dir_perms = 0771; public $_dir_perms = 0771;
/** /**
* block tag hierarchy * block tag hierarchy
* *
* @var array * @var array
*/ */
public $_tag_stack = array(); public $_tag_stack = array();
/** /**
* required by the compiler for BC * required by the compiler for BC
* *
* @var string * @var string
*/ */
public $_current_file = null; public $_current_file = null;
/** /**
* internal flag to enable parser debugging * internal flag to enable parser debugging
* *
@@ -658,7 +752,6 @@ class Smarty extends Smarty_Internal_TemplateBase
/** /**
* Initialize new Smarty object * Initialize new Smarty object
*/ */
public function __construct() public function __construct()
{ {
@@ -1281,9 +1374,7 @@ class Smarty extends Smarty_Internal_TemplateBase
} }
} }
if ($this->debugging) { if ($this->debugging) {
if ($this->debugging) { Smarty_Internal_Debug::register_template($tpl);
Smarty_Internal_Debug::register_template($tpl);
}
} }
return $tpl; return $tpl;
} }
@@ -1329,10 +1420,8 @@ class Smarty extends Smarty_Internal_TemplateBase
// loop through plugin dirs and find the plugin // loop through plugin dirs and find the plugin
foreach ($this->getPluginsDir() as $_plugin_dir) { foreach ($this->getPluginsDir() as $_plugin_dir) {
$names = array( $names = array($_plugin_dir . $_plugin_filename,
$_plugin_dir . $_plugin_filename, $_plugin_dir . strtolower($_plugin_filename),);
$_plugin_dir . strtolower($_plugin_filename),
);
foreach ($names as $file) { foreach ($names as $file) {
if (isset($this->_is_file_cache[$file]) ? $this->_is_file_cache[$file] : $this->_is_file_cache[$file] = is_file($file)) { if (isset($this->_is_file_cache[$file]) ? $this->_is_file_cache[$file] : $this->_is_file_cache[$file] = is_file($file)) {
require_once($file); require_once($file);
@@ -1589,13 +1678,11 @@ class Smarty extends Smarty_Internal_TemplateBase
*/ */
public function __get($name) public function __get($name)
{ {
$allowed = array( $allowed = array('template_dir' => 'getTemplateDir',
'template_dir' => 'getTemplateDir', 'config_dir' => 'getConfigDir',
'config_dir' => 'getConfigDir', 'plugins_dir' => 'getPluginsDir',
'plugins_dir' => 'getPluginsDir', 'compile_dir' => 'getCompileDir',
'compile_dir' => 'getCompileDir', 'cache_dir' => 'getCacheDir',);
'cache_dir' => 'getCacheDir',
);
if (isset($allowed[$name])) { if (isset($allowed[$name])) {
return $this->{$allowed[$name]}(); return $this->{$allowed[$name]}();
@@ -1614,13 +1701,11 @@ class Smarty extends Smarty_Internal_TemplateBase
*/ */
public function __set($name, $value) public function __set($name, $value)
{ {
$allowed = array( $allowed = array('template_dir' => 'setTemplateDir',
'template_dir' => 'setTemplateDir', 'config_dir' => 'setConfigDir',
'config_dir' => 'setConfigDir', 'plugins_dir' => 'setPluginsDir',
'plugins_dir' => 'setPluginsDir', 'compile_dir' => 'setCompileDir',
'compile_dir' => 'setCompileDir', 'cache_dir' => 'setCacheDir',);
'cache_dir' => 'setCacheDir',
);
if (isset($allowed[$name])) { if (isset($allowed[$name])) {
$this->{$allowed[$name]}($value); $this->{$allowed[$name]}($value);
@@ -1650,10 +1735,8 @@ class Smarty extends Smarty_Internal_TemplateBase
if (!isset(Smarty::$_muted_directories[SMARTY_DIR])) { if (!isset(Smarty::$_muted_directories[SMARTY_DIR])) {
$smarty_dir = realpath(SMARTY_DIR); $smarty_dir = realpath(SMARTY_DIR);
if ($smarty_dir !== false) { if ($smarty_dir !== false) {
Smarty::$_muted_directories[SMARTY_DIR] = array( Smarty::$_muted_directories[SMARTY_DIR] = array('file' => $smarty_dir,
'file' => $smarty_dir, 'length' => strlen($smarty_dir),);
'length' => strlen($smarty_dir),
);
} }
} }
@@ -1667,10 +1750,8 @@ class Smarty extends Smarty_Internal_TemplateBase
unset(Smarty::$_muted_directories[$key]); unset(Smarty::$_muted_directories[$key]);
continue; continue;
} }
$dir = array( $dir = array('file' => $file,
'file' => $file, 'length' => strlen($file),);
'length' => strlen($file),
);
} }
if (!strncmp($errfile, $dir['file'], $dir['length'])) { if (!strncmp($errfile, $dir['file'], $dir['length'])) {
$_is_muted_directory = true; $_is_muted_directory = true;
@@ -1712,7 +1793,8 @@ class Smarty extends Smarty_Internal_TemplateBase
- between file_exists() and filemtime() a possible race condition is opened, - between file_exists() and filemtime() a possible race condition is opened,
which does not exist using the simple @filemtime() approach. which does not exist using the simple @filemtime() approach.
*/ */
$error_handler = array('Smarty', 'mutingErrorHandler'); $error_handler = array('Smarty',
'mutingErrorHandler');
$previous = set_error_handler($error_handler); $previous = set_error_handler($error_handler);
// avoid dead loops // avoid dead loops