123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- <?php
-
-
- class Smarty_Internal_Extension_Handler
- {
-
- public $objType = null;
-
-
-
- private $_property_info = array('AutoloadFilters' => 0, 'DefaultModifiers' => 0, 'ConfigVars' => 0,
- 'DebugTemplate' => 0, 'RegisteredObject' => 0, 'StreamVariable' => 0,
- 'TemplateVars' => 0,);
-
- private $resolvedProperties = array();
-
-
-
- public function _callExternalMethod(Smarty_Internal_Data $data, $name, $args)
- {
-
- $smarty = isset($data->smarty) ? $data->smarty : $data;
- if (!isset($smarty->ext->$name)) {
- $class = 'Smarty_Internal_Method_' . ucfirst($name);
- if (preg_match('/^(set|get)([A-Z].*)$/', $name, $match)) {
- if (!isset($this->_property_info[$prop = $match[2]])) {
-
- $this->resolvedProperties[$prop] = $pn = strtolower(join('_',
- preg_split('/([A-Z][^A-Z]*)/', $prop, - 1,
- PREG_SPLIT_NO_EMPTY |
- PREG_SPLIT_DELIM_CAPTURE)));
- $this->_property_info[$prop] = property_exists($data, $pn) ? 1 :
- ($data->_objType == 2 && property_exists($smarty, $pn) ? 2 : 0);
- }
- if ($this->_property_info[$prop]) {
- $pn = $this->resolvedProperties[$prop];
- if ($match[1] == 'get') {
- return $this->_property_info[$prop] == 1 ? $data->$pn : $data->smarty->$pn;
- } else {
- return $this->_property_info[$prop] == 1 ? $data->$pn = $args[0] :
- $data->smarty->$pn = $args[0];
- }
- } elseif (!class_exists($class)) {
- throw new SmartyException("property '$pn' does not exist.");
- }
- }
- if (class_exists($class)) {
- $callback = array($smarty->ext->$name = new $class(), $name);
- }
- } else {
- $callback = array($smarty->ext->$name, $name);
- }
- array_unshift($args, $data);
- if (isset($callback) && $callback[0]->objMap | $data->_objType) {
- return call_user_func_array($callback, $args);
- }
- return call_user_func_array(array(new Smarty_Internal_Undefined(), $name), $args);
- }
-
-
-
- public function __set($property_name, $value)
- {
- $this->$property_name = $value;
- }
-
-
-
- public function __get($property_name)
- {
-
- if ($property_name[0] == '_') {
- $class = 'Smarty_Internal_Runtime_' . ucfirst(substr($property_name, 1));
- } else {
- $class = 'Smarty_Internal_Method_' . ucfirst($property_name);
- }
- if (class_exists($class)) {
- return $this->$property_name = new $class();
- }
- return $this;
- }
-
-
-
- public function __call($name, $args)
- {
- return call_user_func_array(array(new Smarty_Internal_Undefined(), $name), $args);
- }
-
- }
|