mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-10 13:24:27 +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
|
04/21/2009
|
||||||
- change of new style syntax for forach. Now: {foreach $array as $var} like in PHP
|
- 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
|
// no resource given, use default
|
||||||
$this->resource_type = $this->smarty->default_resource_type;
|
$this->resource_type = $this->smarty->default_resource_type;
|
||||||
$this->resource_name = $template_resource;
|
$this->resource_name = $template_resource;
|
||||||
} elseif (strpos($template_resource, '://') != strpos($template_resource, ':')) {
|
} else {
|
||||||
// get type and name from path
|
// get type and name from path
|
||||||
list($this->resource_type, $this->resource_name) = explode(':', $template_resource, 2);
|
list($this->resource_type, $this->resource_name) = explode(':', $template_resource, 2);
|
||||||
if (strlen($this->resource_type) == 1) {
|
if (strlen($this->resource_type) == 1) {
|
||||||
@@ -483,28 +483,38 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase {
|
|||||||
} else {
|
} else {
|
||||||
$this->resource_type = strtolower($this->resource_type);
|
$this->resource_type = strtolower($this->resource_type);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
// stream resource
|
|
||||||
$this->resource_type = 'stream';
|
|
||||||
$this->resource_name = $template_resource;
|
|
||||||
}
|
}
|
||||||
// load resource handler if required
|
// load resource handler if required
|
||||||
if (!isset($this->resource_objects[$this->resource_type])) {
|
if (!isset($this->resource_objects[$this->resource_type])) {
|
||||||
// is this an internal or custom resource?
|
// try sysplugins dir first
|
||||||
if (in_array($this->resource_type, array('file', 'php', 'string', 'extend', 'stream'))) {
|
|
||||||
// internal, get from sysplugins dir
|
|
||||||
$_resource_class = "Smarty_Internal_Resource_{$this->resource_type}";
|
$_resource_class = "Smarty_Internal_Resource_{$this->resource_type}";
|
||||||
} else {
|
if ($this->smarty->loadPlugin($_resource_class)) {
|
||||||
// custom, get from plugins dir
|
|
||||||
$_resource_class = "Smarty_Resource_{$this->resource_type}";
|
|
||||||
}
|
|
||||||
// load resource plugin, instantiate
|
|
||||||
$this->smarty->loadPlugin($_resource_class);
|
|
||||||
$this->resource_objects[$this->resource_type] = new $_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
|
// cache template object under a unique ID
|
||||||
// do not cache string resources
|
// 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;
|
Smarty::$template_objects[$this->buildTemplateId ($this->template_resource, $this->cache_id, $this->compile_id)] = $this;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
Reference in New Issue
Block a user