mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-09 12:54:26 +02:00
- unified template stream syntax with standard Smarty resource syntax $smarty->display('mystream:mytemplate')
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
04/22/2009
|
||||
- unified template stream syntax with standard Smarty resource syntax $smarty->display('mystream:mytemplate')
|
||||
|
||||
04/21/2009
|
||||
- change of new style syntax for forach. Now: {foreach $array as $var} like in PHP
|
||||
|
||||
|
@@ -473,7 +473,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase {
|
||||
// no resource given, use default
|
||||
$this->resource_type = $this->smarty->default_resource_type;
|
||||
$this->resource_name = $template_resource;
|
||||
} elseif (strpos($template_resource, '://') != strpos($template_resource, ':')) {
|
||||
} else {
|
||||
// get type and name from path
|
||||
list($this->resource_type, $this->resource_name) = explode(':', $template_resource, 2);
|
||||
if (strlen($this->resource_type) == 1) {
|
||||
@@ -483,28 +483,38 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase {
|
||||
} else {
|
||||
$this->resource_type = strtolower($this->resource_type);
|
||||
}
|
||||
} else {
|
||||
// stream resource
|
||||
$this->resource_type = 'stream';
|
||||
$this->resource_name = $template_resource;
|
||||
}
|
||||
// load resource handler if required
|
||||
if (!isset($this->resource_objects[$this->resource_type])) {
|
||||
// is this an internal or custom resource?
|
||||
if (in_array($this->resource_type, array('file', 'php', 'string', 'extend', 'stream'))) {
|
||||
// internal, get from sysplugins dir
|
||||
// try sysplugins dir first
|
||||
$_resource_class = "Smarty_Internal_Resource_{$this->resource_type}";
|
||||
} else {
|
||||
// custom, get from plugins dir
|
||||
$_resource_class = "Smarty_Resource_{$this->resource_type}";
|
||||
}
|
||||
// load resource plugin, instantiate
|
||||
$this->smarty->loadPlugin($_resource_class);
|
||||
if ($this->smarty->loadPlugin($_resource_class)) {
|
||||
$this->resource_objects[$this->resource_type] = new $_resource_class;
|
||||
} else {
|
||||
// try plugins dir
|
||||
$_resource_class = "Smarty_Resource_{$this->resource_type}";
|
||||
if ($this->smarty->loadPlugin($_resource_class)) {
|
||||
$this->resource_objects[$this->resource_type] = new $_resource_class;
|
||||
} else {
|
||||
// try streams
|
||||
$_known_stream = stream_get_wrappers();
|
||||
if (in_array($this->resource_type, $_known_stream)) {
|
||||
// is known stream
|
||||
if (!isset($this->resource_objects['stream'])) {
|
||||
$this->smarty->loadPlugin('Smarty_Internal_Resource_Stream');
|
||||
$this->resource_objects['stream'] = new Smarty_Internal_Resource_Stream;
|
||||
}
|
||||
$this->resource_type = 'stream';
|
||||
$this->resource_name = str_replace(':', '://', $template_resource);
|
||||
} else {
|
||||
throw new Exception('Unkown resource type \'' . $this->resource_type . '\'');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// cache template object under a unique ID
|
||||
// do not cache string resources
|
||||
if (!in_array($this->resource_type, array('string', 'stream'))) {
|
||||
if ($this->resource_type != 'string') {
|
||||
Smarty::$template_objects[$this->buildTemplateId ($this->template_resource, $this->cache_id, $this->compile_id)] = $this;
|
||||
}
|
||||
return true;
|
||||
@@ -588,12 +598,12 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* wrapper for template class
|
||||
*/
|
||||
class Smarty_Template extends Smarty_Internal_Template {
|
||||
}
|
||||
/**
|
||||
* wrapper for template class
|
||||
*/
|
||||
class Smarty_Template extends Smarty_Internal_Template {
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
Reference in New Issue
Block a user