aboutsummaryrefslogtreecommitdiffstats
path: root/library/Smarty/libs/sysplugins/smarty_resource.php
diff options
context:
space:
mode:
authorMario Vavti <mario@mariovavti.com>2015-12-06 21:09:58 +0100
committerMario Vavti <mario@mariovavti.com>2015-12-06 21:09:58 +0100
commit26c465ad0c1d5b6801507ed190430f44ac92c672 (patch)
tree9e80c34da1235e6dd55942c23bf9511fac31344d /library/Smarty/libs/sysplugins/smarty_resource.php
parentf2d70831838b0738e6895296f3e8ce02f86fec2f (diff)
downloadvolse-hubzilla-26c465ad0c1d5b6801507ed190430f44ac92c672.tar.gz
volse-hubzilla-26c465ad0c1d5b6801507ed190430f44ac92c672.tar.bz2
volse-hubzilla-26c465ad0c1d5b6801507ed190430f44ac92c672.zip
update smarty to 3.1.28-dev which fixes a bug where changes in a template are only visible on the second pageload which is annoying for developing
Diffstat (limited to 'library/Smarty/libs/sysplugins/smarty_resource.php')
-rw-r--r--library/Smarty/libs/sysplugins/smarty_resource.php108
1 files changed, 42 insertions, 66 deletions
diff --git a/library/Smarty/libs/sysplugins/smarty_resource.php b/library/Smarty/libs/sysplugins/smarty_resource.php
index 5d5e368d9..72611255e 100644
--- a/library/Smarty/libs/sysplugins/smarty_resource.php
+++ b/library/Smarty/libs/sysplugins/smarty_resource.php
@@ -29,37 +29,25 @@ abstract class Smarty_Resource
* @var boolean
*/
public $recompiled = false;
+
/**
- * resource handler object
- *
- * @var Smarty_Resource
- */
- public $handler = null;
- /**
- * cache for Smarty_Template_Source instances
- *
- * @var array
- */
- public static $sources = array();
- /**
- * cache for Smarty_Template_Compiled instances
+ * resource types provided by the core
*
* @var array
*/
- public static $compileds = array();
+ 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');
+
/**
- * resource types provided by the core
+ * Flag if resource does implement populateCompiledFilepath() method
*
- * @var array
+ * @var bool
*/
- protected 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'
- );
+ public $hasCompiledHandler = false;
/**
* Name of the Class to compile this resource's contents with
@@ -84,7 +72,6 @@ abstract class Smarty_Resource
/**
* Load template's source into current template object
- * {@internal The loaded source is assigned to $_template->source->content directly.}}
*
* @param Smarty_Template_Source $source source object
*
@@ -123,9 +110,15 @@ abstract class Smarty_Resource
public function buildUniqueResourceName(Smarty $smarty, $resource_name, $isConfig = false)
{
if ($isConfig) {
- return get_class($this) . '#' . $smarty->joined_config_dir . '#' . $resource_name;
+ if (!isset($smarty->_joined_config_dir)) {
+ $smarty->getTemplateDir(null, true);
+ }
+ return get_class($this) . '#' . $smarty->_joined_config_dir . '#' . $resource_name;
} else {
- return get_class($this) . '#' . $smarty->joined_template_dir . '#' . $resource_name;
+ if (!isset($smarty->_joined_template_dir)) {
+ $smarty->getTemplateDir();
+ }
+ return get_class($this) . '#' . $smarty->_joined_template_dir . '#' . $resource_name;
}
}
@@ -153,42 +146,32 @@ abstract class Smarty_Resource
public static function load(Smarty $smarty, $type)
{
// try smarty's cache
- if (isset($smarty->_resource_handlers[$type])) {
- return $smarty->_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])) {
- if ($smarty->registered_resources[$type] instanceof Smarty_Resource) {
- $smarty->_resource_handlers[$type] = $smarty->registered_resources[$type];
- } else {
- $smarty->_resource_handlers[$type] = new Smarty_Internal_Resource_Registered();
- }
-
- return $smarty->_resource_handlers[$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])) {
$_resource_class = 'Smarty_Internal_Resource_' . ucfirst($type);
- if (!class_exists($_resource_class, false)) {
- require SMARTY_SYSPLUGINS_DIR . self::$sysplugins[$type];
- }
- return $smarty->_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->_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",
- "smarty_resource_{$type}_secure",
- "smarty_resource_{$type}_trusted"
- ));
+ $smarty->registerResource($type,
+ array("smarty_resource_{$type}_source", "smarty_resource_{$type}_timestamp",
+ "smarty_resource_{$type}_secure", "smarty_resource_{$type}_trusted"));
// give it another try, now that the resource is registered properly
return self::load($smarty, $type);
}
@@ -201,7 +184,7 @@ abstract class Smarty_Resource
if (is_object($smarty->security_policy)) {
$smarty->security_policy->isTrustedStream($type);
}
- return $smarty->_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
@@ -221,7 +204,7 @@ abstract class Smarty_Resource
*/
public static function parseResourceName($resource_name, $default_resource)
{
- if (preg_match('/^([A-Za-z0-9_\-]{2,})[:]/', $resource_name, $match)) {
+ if (preg_match('/^([A-Za-z0-9_\-]{2,})[:]/', $resource_name, $match)) {
$type = $match[1];
$name = substr($resource_name, strlen($match[0]));
} else {
@@ -229,38 +212,30 @@ abstract class Smarty_Resource
// or single character before the colon is not a resource type, but part of the filepath
$type = $default_resource;
$name = $resource_name;
-
}
return array($name, $type);
}
/**
- * modify resource_name according to resource handlers specifications
- *
- * @param Smarty $smarty Smarty instance
- * @param string $resource_name resource_name to make unique
- *
- * @return string unique resource name
- */
-
- /**
* modify template_resource according to resource handlers specifications
*
- * @param Smarty_Internal_template $template Smarty instance
- * @param string $template_resource template_resource to extract resource handler and name of
+ * @param \Smarty_Internal_Template|\Smarty $obj Smarty instance
+ * @param string $template_resource template_resource to extract resource handler and name of
*
* @return string unique resource name
*/
- public static function getUniqueTemplateName($template, $template_resource)
+ public static function getUniqueTemplateName($obj, $template_resource)
{
- $smarty = isset($template->smarty) ? $template->smarty : $template;
+ $smarty = $obj->_objType == 2 ? $obj->smarty : $obj;
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 ($template instanceof Smarty_Internal_Template && $_file_is_dotted && ($template->source->type == 'file' || $template->parent->source->type == 'extends')) {
- $name = dirname($template->source->filepath) . DS . $name;
+ if ($obj->_objType == 2 && $_file_is_dotted &&
+ ($obj->source->type == 'file' || $obj->parent->source->type == 'extends')
+ ) {
+ $name = dirname($obj->source->filepath) . DS . $name;
}
return $resource->buildUniqueResourceName($smarty, $name);
}
@@ -276,7 +251,8 @@ abstract class Smarty_Resource
*
* @return Smarty_Template_Source Source Object
*/
- public static function source(Smarty_Internal_Template $_template = null, Smarty $smarty = null, $template_resource = null)
+ public static function source(Smarty_Internal_Template $_template = null, Smarty $smarty = null,
+ $template_resource = null)
{
return Smarty_Template_Source::load($_template, $smarty, $template_resource);
}