104 return get_class($this) .
'#' . $smarty->joined_template_dir .
'#' . $resource_name;
115 $_compile_id = isset($_template->compile_id) ? preg_replace(
'![^\w\|]+!',
'_', $_template->compile_id) : null;
116 $_filepath = $compiled->source->uid;
118 if ($_template->smarty->use_sub_dirs) {
119 $_filepath = substr($_filepath, 0, 2) . DS
120 . substr($_filepath, 2, 2) . DS
121 . substr($_filepath, 4, 2) . DS
124 $_compile_dir_sep = $_template->smarty->use_sub_dirs ? DS :
'^';
125 if (isset($_compile_id)) {
126 $_filepath = $_compile_id . $_compile_dir_sep . $_filepath;
129 if ($_template->caching) {
134 $_compile_dir = $_template->smarty->getCompileDir();
136 $_basename = $this->
getBasename($compiled->source);
137 if ($_basename === null) {
138 $_basename = basename( preg_replace(
'![^\w\/]+!',
'_', $compiled->source->name) );
142 $_basename =
'.' . $_basename;
145 $compiled->filepath = $_compile_dir . $_filepath .
'.' . $compiled->source->type . $_basename . $_cache .
'.php';
159 $_path = str_replace(
'\\',
'/', $_path);
165 $_path = preg_replace(
'#(/\./(\./)*)|/{2,}#',
'/', $_path);
168 $_parent = strpos($_path,
'/../', $offset);
171 }
else if ($_path[$_parent - 1] ===
'.') {
172 $offset = $_parent + 3;
176 $_pos = strrpos($_path,
'/', $_parent - strlen($_path) - 1);
177 if ($_pos ===
false) {
182 $_path = substr_replace($_path,
'', $_pos, $_parent + 3 - $_pos);
185 if ($ds && DS !=
'/') {
187 $_path = str_replace(
'/',
'\\', $_path);
203 $file = $source->name;
205 $_directories = $source->smarty->getConfigDir();
206 $_default_handler = $source->smarty->default_config_handler_func;
208 $_directories = $source->smarty->getTemplateDir();
209 $_default_handler = $source->smarty->default_template_handler_func;
213 $_file_is_dotted = $file[0] ==
'.' && ($file[1] ==
'.' || $file[1] ==
'/' || $file[1] ==
"\\");
215 if ($_template->parent->source->type !=
'file' && $_template->parent->source->type !=
'extends' && !$_template->parent->allow_relative_path) {
216 throw new SmartyException(
"Template '{$file}' cannot be relative to template of resource type '{$_template->parent->source->type}'");
218 $file = dirname($_template->parent->source->filepath) . DS . $file;
219 $_file_exact_match =
true;
220 if (!preg_match(
'/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $file)) {
223 $file = getcwd() . DS . $file;
228 if (!preg_match(
'/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $file)) {
230 $_path = str_replace(
'\\',
'/', $file);
231 $_path = DS . trim($file,
'/');
232 $_was_relative =
true;
235 $_path = str_replace(
'\\',
'/', $file);
240 $_path = str_replace(
'/',
'\\', $_path);
243 if (isset($_was_relative)) {
244 $_path = substr($_path, 1);
248 $file = rtrim($_path,
'/\\');
251 if (isset($_file_exact_match)) {
252 return $this->
fileExists($source, $file) ? $file :
false;
256 if (preg_match(
'#^\[(?P<key>[^\]]+)\](?P<file>.+)$#', $file,
$match)) {
259 if (isset($_directories[
$match[
'key']])) {
260 $_directory = $_directories[$match[
'key']];
261 }
else if (is_numeric($match[
'key'])) {
263 $match[
'key'] = (int) $match[
'key'];
264 if (isset($_directories[$match[
'key']])) {
265 $_directory = $_directories[$match[
'key']];
268 $keys = array_keys($_directories);
269 $_directory = $_directories[$keys[$match[
'key']]];
274 $_file = substr($file, strpos($file,
']') + 1);
275 $_filepath = $_directory . $_file;
282 $_stream_resolve_include_path = function_exists(
'stream_resolve_include_path');
285 if (!preg_match(
'/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $file)) {
286 foreach ($_directories as $_directory) {
287 $_filepath = $_directory . $file;
291 if ($source->smarty->use_include_path && !preg_match(
'/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $_directory)) {
293 if ($_stream_resolve_include_path) {
294 $_filepath = stream_resolve_include_path($_filepath);
299 if ($_filepath !==
false) {
314 if ($_default_handler) {
315 if (!is_callable($_default_handler)) {
316 if ($source instanceof Smarty_Config_Source) {
322 $_return = call_user_func_array($_default_handler,
323 array($source->type, $source->name, &$_content, &$_timestamp, $source->smarty));
324 if (is_string($_return)) {
325 $source->timestamp = @filemtime($_return);
326 $source->exists = !!$source->timestamp;
328 }
elseif ($_return ===
true) {
329 $source->content = $_content;
330 $source->timestamp = $_timestamp;
331 $source->exists =
true;
349 $source->timestamp = @filemtime($file);
350 return $source->exists = !!$source->timestamp;
375 if (isset($smarty->_resource_handlers[$type])) {
376 return $smarty->_resource_handlers[$type];
380 if (isset($smarty->registered_resources[$type])) {
382 $smarty->_resource_handlers[$type] = $smarty->registered_resources[$type];
384 return $smarty->_resource_handlers[$type];
387 if (!isset(self::$resources[
'registered'])) {
390 if (!isset($smarty->_resource_handlers[$type])) {
391 $smarty->_resource_handlers[$type] = self::$resources[
'registered'];
394 return $smarty->_resource_handlers[$type];
398 if (isset(self::$sysplugins[$type])) {
399 if (!isset(self::$resources[$type])) {
400 $_resource_class =
'Smarty_Internal_Resource_' . ucfirst($type);
401 self::$resources[$type] =
new $_resource_class();
403 return $smarty->_resource_handlers[$type] = self::$resources[$type];
407 $_resource_class =
'Smarty_Resource_' . ucfirst($type);
409 if (isset(self::$resources[$type])) {
410 return $smarty->_resource_handlers[$type] = self::$resources[$type];
413 if (class_exists($_resource_class,
false)) {
414 self::$resources[$type] =
new $_resource_class();
415 return $smarty->_resource_handlers[$type] = self::$resources[$type];
418 "smarty_resource_{$type}_source",
419 "smarty_resource_{$type}_timestamp",
420 "smarty_resource_{$type}_secure",
421 "smarty_resource_{$type}_trusted"
425 return self::load($smarty, $type);
430 $_known_stream = stream_get_wrappers();
431 if (in_array($type, $_known_stream)) {
433 if (is_object($smarty->security_policy)) {
434 $smarty->security_policy->isTrustedStream($type);
436 if (!isset(self::$resources[
'stream'])) {
439 return $smarty->_resource_handlers[$type] = self::$resources[
'stream'];
460 $parts = explode(
':', $resource_name, 2);
461 if (!isset($parts[1]) || !isset($parts[0][1])) {
464 $type = $default_resource;
465 $name = $resource_name;
490 self::parseResourceName($template_resource, $smarty->default_resource_type, $name, $type);
493 return $resource->buildUniqueResourceName($smarty, $name);
509 $smarty = $_template->smarty;
510 $template_resource = $_template->template_resource;
514 self::parseResourceName($template_resource, $smarty->default_resource_type, $name, $type);
516 $unique_resource_name = $resource->buildUniqueResourceName($smarty, $name);
519 $_cache_key =
'template|' . $unique_resource_name;
520 if ($smarty->compile_id) {
521 $_cache_key .=
'|'.$smarty->compile_id;
523 if (isset(self::$sources[$_cache_key])) {
524 return self::$sources[$_cache_key];
528 $source =
new Smarty_Template_Source($resource, $smarty, $template_resource, $type, $name, $unique_resource_name);
529 $resource->populate($source, $_template);
532 self::$sources[$_cache_key] = $source;
544 static $_incompatible_resources = array(
'eval' =>
true,
'string' =>
true,
'extends' =>
true,
'php' =>
true);
545 $config_resource = $_config->config_resource;
546 $smarty = $_config->smarty;
549 self::parseResourceName($config_resource, $smarty->default_config_type, $name, $type);
552 if (isset($_incompatible_resources[$type])) {
553 throw new SmartyException (
"Unable to use resource '{$type}' for config");
558 $unique_resource_name = $resource->buildUniqueResourceName($smarty, $name);
561 $_cache_key =
'config|' . $unique_resource_name;
562 if (isset(self::$sources[$_cache_key])) {
563 return self::$sources[$_cache_key];
567 $source =
new Smarty_Config_Source($resource, $smarty, $config_resource, $type, $name, $unique_resource_name);
568 $resource->populate($source, null);
571 self::$sources[$_cache_key] = $source;
691 $this->compiler_class = $handler->compiler_class;
692 $this->template_lexer_class = $handler->template_lexer_class;
693 $this->template_parser_class = $handler->template_parser_class;
713 $_cache_key = $this->unique_resource .
'#' . $_template->compile_id;
719 $this->handler->populateCompiledFilepath($compiled, $_template);
720 $compiled->timestamp = @filemtime($compiled->filepath);
721 $compiled->exists = !!$compiled->timestamp;
736 return $this->handler->renderUncompiled($this, $_template);
746 public function __set($property_name, $value)
748 switch ($property_name) {
755 $this->$property_name = $value;
759 throw new SmartyException(
"invalid source property '$property_name'.");
770 public function __get($property_name)
772 switch ($property_name) {
775 $this->handler->populateTimestamp($this);
776 return $this->$property_name;
779 return $this->content = $this->handler->getContent($this);
782 throw new SmartyException(
"source property '$property_name' does not exist.");
buildUniqueResourceName(Smarty $smarty, $resource_name)
modify resource_name according to resource handlers specifications
getContent(Smarty_Template_Source $source)
Load template's source into current template object.
__construct(Smarty_Template_Source $source)
create Compiled Object container
loadPlugin($plugin_name, $check=true)
Takes unknown classes and loads plugin files for them class name format: Smarty_PluginType_PluginName...
getCompiled(Smarty_Internal_Template $_template)
get a Compiled Object of this source
__get($property_name)
<> Generic getter.
renderUncompiled(Smarty_Internal_Template $_template)
render the uncompiled source
static getIncludePath($filepath)
Return full file path from PHP include_path.
fileExists(Smarty_Template_Source $source, $file)
test is file exists and save timestamp
__construct(Smarty_Resource $handler, Smarty $smarty, $resource, $type, $name, $unique_resource)
create Source Object container
static load(Smarty $smarty, $type)
Load Resource Handler.
populateCompiledFilepath(Smarty_Template_Compiled $compiled, Smarty_Internal_Template $_template)
populate Compiled Object with compiled filepath
static config(Smarty_Internal_Config $_config)
initialize Config Source Object for given resource
getBasename(Smarty_Template_Source $source)
Determine basename for compiled filename.
Smarty plugin to format text blocks.
static source(Smarty_Internal_Template $_template=null, Smarty $smarty=null, $template_resource=null)
initialize Source Object for given resource
static getUniqueTemplateName($smarty, $template_resource)
modify resource_name according to resource handlers specifications
populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template=null)
populate Source Object with meta data from Resource
__set($property_name, $value)
<> Generic Setter.
if(strlen($date2)== '10') if($type== 'users-by-age'&&a_priv('admin_users', true)) elseif($type== 'forums-count'&&a_priv('admin_content', true)) elseif($type== 'forums-categories'&&a_priv('admin_content', true)) elseif($type== 'users-count'&&a_priv('admin_users', true)) elseif($type== 'product-categories'&&a_priv('admin_products', true)) elseif($type== 'users-by-sex'&&a_priv('admin_users', true)) elseif($type== 'users-by-country'&&a_priv('admin_users', true)) elseif($type== 'sales'&&a_priv('admin_sales', true))
normalizePath($_path, $ds=true)
Normalize Paths "foo/../bar" to "bar".
static parseResourceName($resource_name, $default_resource, &$name, &$type)
extract resource_type and resource_name from template_resource and config_resource ...
registerResource($type, $callback)
Registers a resource to fetch a template.
buildFilepath(Smarty_Template_Source $source, Smarty_Internal_Template $_template=null)
build template filepath by traversing the template_dir array
populateTimestamp(Smarty_Template_Source $source)
populate Source Object with timestamp and exists from Resource