58 if ($template === null && $this instanceof $this->template_class) {
61 if (!($template instanceof $this->template_class)) {
65 $smarty = isset($this->smarty) ? $this->smarty : $this;
70 if (!isset($template->cached)) {
71 $template->loadCached();
73 return $template->cached->isCached($template);
87 if ($this->debugging) {
106 $smarty = isset($this->smarty) ? $this->smarty : $this;
107 if ($smarty->allow_ambiguous_resources) {
110 $_templateId = $smarty->joined_template_dir .
"#{$template_name}#{$cache_id}#{$compile_id}";
112 if (isset($_templateId[150])) {
113 $_templateId = sha1($_templateId);
131 public function registerPlugin($type, $tag, $callback, $cacheable =
true, $cache_attr = null)
133 $smarty = isset($this->smarty) ? $this->smarty : $this;
134 if (isset($smarty->registered_plugins[$type][$tag])) {
136 } elseif (!is_callable($callback)) {
139 $smarty->registered_plugins[$type][$tag] = array($callback, (
bool) $cacheable, (array) $cache_attr);
156 $smarty = isset($this->smarty) ? $this->smarty : $this;
157 if (isset($smarty->registered_plugins[$type][$tag])) {
158 unset($smarty->registered_plugins[$type][$tag]);
176 $smarty = isset($this->smarty) ? $this->smarty : $this;
177 $smarty->registered_resources[$type] = $callback instanceof
Smarty_Resource ? $callback : array($callback,
false);
192 $smarty = isset($this->smarty) ? $this->smarty : $this;
193 if (isset($smarty->registered_resources[$type])) {
194 unset($smarty->registered_resources[$type]);
211 $smarty = isset($this->smarty) ? $this->smarty : $this;
212 $smarty->registered_cache_resources[$type] = $callback;
227 $smarty = isset($this->smarty) ? $this->smarty : $this;
228 if (isset($smarty->registered_cache_resources[$type])) {
229 unset($smarty->registered_cache_resources[$type]);
248 public function registerObject($object_name, $object_impl, $allowed = array(), $smarty_args =
true, $block_methods = array())
251 if (!empty($allowed)) {
252 foreach ((array) $allowed as $method) {
253 if (!is_callable(array($object_impl, $method)) && !property_exists($object_impl, $method)) {
254 throw new SmartyException(
"Undefined method or property '$method' in registered object");
259 if (!empty($block_methods)) {
260 foreach ((array) $block_methods as $method) {
261 if (!is_callable(array($object_impl, $method))) {
262 throw new SmartyException(
"Undefined method '$method' in registered object");
267 $smarty = isset($this->smarty) ? $this->smarty : $this;
268 $smarty->registered_objects[$object_name] =
269 array($object_impl, (array) $allowed, (
boolean) $smarty_args, (array) $block_methods);
284 $smarty = isset($this->smarty) ? $this->smarty : $this;
285 if (!isset($smarty->registered_objects[$name])) {
288 if (!is_object($smarty->registered_objects[$name][0])) {
292 return $smarty->registered_objects[$name][0];
305 $smarty = isset($this->smarty) ? $this->smarty : $this;
306 if (isset($smarty->registered_objects[$name])) {
307 unset($smarty->registered_objects[$name]);
326 if (!class_exists($class_impl)) {
327 throw new SmartyException(
"Undefined class '$class_impl' in register template class");
330 $smarty = isset($this->smarty) ? $this->smarty : $this;
331 $smarty->registered_classes[$class_name] = $class_impl;
347 $smarty = isset($this->smarty) ? $this->smarty : $this;
348 if (is_callable($callback)) {
349 $smarty->default_plugin_handler_func = $callback;
351 throw new SmartyException(
"Default plugin handler '$callback' not callable");
398 $smarty = isset($this->smarty) ? $this->smarty : $this;
399 $smarty->registered_filters[$type][$this->
_get_filter_name($callback)] = $callback;
416 $smarty = isset($this->smarty) ? $this->smarty : $this;
417 if (isset($smarty->registered_filters[$type][$name])) {
418 unset($smarty->registered_filters[$type][$name]);
433 if (is_array($function_name)) {
434 $_class_name = (is_object($function_name[0]) ?
435 get_class($function_name[0]) : $function_name[0]);
437 return $_class_name .
'_' . $function_name[1];
439 return $function_name;
453 $smarty = isset($this->smarty) ? $this->smarty : $this;
454 $_plugin =
"smarty_{$type}filter_{$name}";
455 $_filter_name = $_plugin;
456 if ($smarty->loadPlugin($_plugin)) {
457 if (class_exists($_plugin,
false)) {
458 $_plugin = array($_plugin,
'execute');
460 if (is_callable($_plugin)) {
461 $smarty->registered_filters[$type][$_filter_name] = $_plugin;
480 $smarty = isset($this->smarty) ? $this->smarty : $this;
481 $_filter_name =
"smarty_{$type}filter_{$name}";
482 if (isset($smarty->registered_filters[$type][$_filter_name])) {
483 unset ($smarty->registered_filters[$type][$_filter_name]);
498 return "_" . strtolower($match[1]);
511 static $_prefixes = array(
'set' =>
true,
'get' =>
true);
512 static $_resolved_property_name = array();
513 static $_resolved_property_source = array();
516 $first3 = strtolower(substr($name, 0, 3));
517 if (isset($_prefixes[$first3]) && isset($name[3]) && $name[3] !==
'_') {
518 if (isset($_resolved_property_name[$name])) {
519 $property_name = $_resolved_property_name[$name];
523 $property_name = strtolower(substr($name, 3, 1)) . substr($name, 4);
525 $property_name = preg_replace_callback(
'/([A-Z])/', array($this,
'replaceCamelcase'), $property_name);
526 $_resolved_property_name[$name] = $property_name;
528 if (isset($_resolved_property_source[$property_name])) {
529 $status = $_resolved_property_source[$property_name];
532 if (property_exists($this, $property_name)) {
534 } elseif (property_exists($this->smarty, $property_name)) {
537 $_resolved_property_source[$property_name] = $status;
540 if ($status ===
true) {
542 } elseif ($status ===
false) {
543 $smarty = $this->smarty;
546 if ($first3 ==
'get') {
547 return $smarty->$property_name;
549 return $smarty->$property_name = $args[0];
552 throw new SmartyException(
"property '$property_name' does not exist.");