Update Smarty to 3.1.3

This commit is contained in:
Rob Lensen
2018-01-18 00:23:24 +01:00
parent 6a3f8f3e76
commit db684f6151
190 changed files with 7430 additions and 5215 deletions
@@ -13,6 +13,10 @@
*
* @package Smarty
* @subpackage TemplateResources
*
* @method renderUncompiled(Smarty_Template_Source $source, Smarty_Internal_Template $_template)
* @method populateCompiledFilepath(Smarty_Template_Compiled $compiled, Smarty_Internal_Template $_template)
* @method process(Smarty_Internal_Template $_smarty_tpl)
*/
abstract class Smarty_Resource
{
@@ -35,12 +39,12 @@ abstract class Smarty_Resource
*
* @var array
*/
public static $sysplugins = array('file' => 'smarty_internal_resource_file.php',
'string' => 'smarty_internal_resource_string.php',
public static $sysplugins = array('file' => 'smarty_internal_resource_file.php',
'string' => 'smarty_internal_resource_string.php',
'extends' => 'smarty_internal_resource_extends.php',
'stream' => 'smarty_internal_resource_stream.php',
'eval' => 'smarty_internal_resource_eval.php',
'php' => 'smarty_internal_resource_php.php');
'stream' => 'smarty_internal_resource_stream.php',
'eval' => 'smarty_internal_resource_eval.php',
'php' => 'smarty_internal_resource_php.php');
/**
* Flag if resource does implement populateCompiledFilepath() method
@@ -49,27 +53,6 @@ abstract class Smarty_Resource
*/
public $hasCompiledHandler = false;
/**
* Name of the Class to compile this resource's contents with
*
* @var string
*/
public $compiler_class = 'Smarty_Internal_SmartyTemplateCompiler';
/**
* Name of the Class to tokenize this resource's contents with
*
* @var string
*/
public $template_lexer_class = 'Smarty_Internal_Templatelexer';
/**
* Name of the Class to parse this resource's contents with
*
* @var string
*/
public $template_parser_class = 'Smarty_Internal_Templateparser';
/**
* Load template's source into current template object
*
@@ -131,7 +114,7 @@ abstract class Smarty_Resource
*/
public function getBasename(Smarty_Template_Source $source)
{
return null;
return basename(preg_replace('![^\w]+!', '_', $source->name));
}
/**
@@ -146,28 +129,28 @@ abstract class Smarty_Resource
public static function load(Smarty $smarty, $type)
{
// try smarty's cache
if (isset($smarty->_cache['resource_handlers'][$type])) {
return $smarty->_cache['resource_handlers'][$type];
if (isset($smarty->_cache[ 'resource_handlers' ][ $type ])) {
return $smarty->_cache[ 'resource_handlers' ][ $type ];
}
// try registered resource
if (isset($smarty->registered_resources[$type])) {
return $smarty->_cache['resource_handlers'][$type] =
$smarty->registered_resources[$type] instanceof Smarty_Resource ? $smarty->registered_resources[$type] :
new Smarty_Internal_Resource_Registered();
if (isset($smarty->registered_resources[ $type ])) {
return $smarty->_cache[ 'resource_handlers' ][ $type ] =
$smarty->registered_resources[ $type ] instanceof Smarty_Resource ?
$smarty->registered_resources[ $type ] : new Smarty_Internal_Resource_Registered();
}
// try sysplugins dir
if (isset(self::$sysplugins[$type])) {
if (isset(self::$sysplugins[ $type ])) {
$_resource_class = 'Smarty_Internal_Resource_' . ucfirst($type);
return $smarty->_cache['resource_handlers'][$type] = new $_resource_class();
return $smarty->_cache[ 'resource_handlers' ][ $type ] = new $_resource_class();
}
// try plugins dir
$_resource_class = 'Smarty_Resource_' . ucfirst($type);
if ($smarty->loadPlugin($_resource_class)) {
if (class_exists($_resource_class, false)) {
return $smarty->_cache['resource_handlers'][$type] = new $_resource_class();
return $smarty->_cache[ 'resource_handlers' ][ $type ] = new $_resource_class();
} else {
$smarty->registerResource($type,
array("smarty_resource_{$type}_source", "smarty_resource_{$type}_timestamp",
@@ -184,7 +167,7 @@ abstract class Smarty_Resource
if (is_object($smarty->security_policy)) {
$smarty->security_policy->isTrustedStream($type);
}
return $smarty->_cache['resource_handlers'][$type] = new Smarty_Internal_Resource_Stream();
return $smarty->_cache[ 'resource_handlers' ][ $type ] = new Smarty_Internal_Resource_Stream();
}
// TODO: try default_(template|config)_handler
@@ -205,8 +188,8 @@ abstract class Smarty_Resource
public static function parseResourceName($resource_name, $default_resource)
{
if (preg_match('/^([A-Za-z0-9_\-]{2,})[:]/', $resource_name, $match)) {
$type = $match[1];
$name = substr($resource_name, strlen($match[0]));
$type = $match[ 1 ];
$name = substr($resource_name, strlen($match[ 0 ]));
} else {
// no resource given, use default
// or single character before the colon is not a resource type, but part of the filepath
@@ -226,16 +209,16 @@ abstract class Smarty_Resource
*/
public static function getUniqueTemplateName($obj, $template_resource)
{
$smarty = $obj->_objType == 2 ? $obj->smarty : $obj;
$smarty = $obj->_getSmartyObj();
list($name, $type) = self::parseResourceName($template_resource, $smarty->default_resource_type);
// TODO: optimize for Smarty's internal resource types
$resource = Smarty_Resource::load($smarty, $type);
// go relative to a given template?
$_file_is_dotted = $name[0] == '.' && ($name[1] == '.' || $name[1] == '/');
if ($obj->_objType == 2 && $_file_is_dotted &&
$_file_is_dotted = $name[ 0 ] == '.' && ($name[ 1 ] == '.' || $name[ 1 ] == '/');
if ($obj->_isTplObj() && $_file_is_dotted &&
($obj->source->type == 'file' || $obj->parent->source->type == 'extends')
) {
$name = dirname($obj->source->filepath) . DS . $name;
$name = $smarty->_realpath(dirname($obj->parent->source->filepath) . $smarty->ds . $name);
}
return $resource->buildUniqueResourceName($smarty, $name);
}
@@ -246,7 +229,8 @@ abstract class Smarty_Resource
*
* @return bool
*/
public function checkTimestamps() {
public function checkTimestamps()
{
return true;
}