| 
									
										
										
										
											2015-10-24 05:02:24 +02:00
										 |  |  | <?php | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * Smarty Extension handler | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Load extensions dynamically | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * @package    Smarty | 
					
						
							|  |  |  |  * @subpackage PluginsInternal | 
					
						
							|  |  |  |  * @author     Uwe Tews | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2016-08-14 02:38:55 +02:00
										 |  |  |  * Runtime extensions | 
					
						
							| 
									
										
										
										
											2018-06-12 09:58:15 +02:00
										 |  |  |  * @property   Smarty_Internal_Runtime_CacheModify       $_cacheModify | 
					
						
							|  |  |  |  * @property   Smarty_Internal_Runtime_CacheResourceFile $_cacheResourceFile | 
					
						
							|  |  |  |  * @property   Smarty_Internal_Runtime_Capture           $_capture | 
					
						
							|  |  |  |  * @property   Smarty_Internal_Runtime_CodeFrame         $_codeFrame | 
					
						
							|  |  |  |  * @property   Smarty_Internal_Runtime_FilterHandler     $_filterHandler | 
					
						
							|  |  |  |  * @property   Smarty_Internal_Runtime_Foreach           $_foreach | 
					
						
							|  |  |  |  * @property   Smarty_Internal_Runtime_GetIncludePath    $_getIncludePath | 
					
						
							|  |  |  |  * @property   Smarty_Internal_Runtime_Make_Nocache      $_make_nocache | 
					
						
							|  |  |  |  * @property   Smarty_Internal_Runtime_UpdateCache       $_updateCache | 
					
						
							|  |  |  |  * @property   Smarty_Internal_Runtime_UpdateScope       $_updateScope | 
					
						
							|  |  |  |  * @property   Smarty_Internal_Runtime_TplFunction       $_tplFunction | 
					
						
							|  |  |  |  * @property   Smarty_Internal_Runtime_WriteFile         $_writeFile | 
					
						
							| 
									
										
										
										
											2016-08-14 02:38:55 +02:00
										 |  |  |  * | 
					
						
							|  |  |  |  * Method extensions | 
					
						
							| 
									
										
										
										
											2018-06-12 09:58:15 +02:00
										 |  |  |  * @property   Smarty_Internal_Method_GetTemplateVars    $getTemplateVars | 
					
						
							|  |  |  |  * @property   Smarty_Internal_Method_Append             $append | 
					
						
							| 
									
										
										
										
											2018-08-31 16:45:09 +02:00
										 |  |  |  * @property   Smarty_Internal_Method_AppendByRef        $appendByRef | 
					
						
							|  |  |  |  * @property   Smarty_Internal_Method_AssignGlobal       $assignGlobal | 
					
						
							|  |  |  |  * @property   Smarty_Internal_Method_AssignByRef        $assignByRef | 
					
						
							|  |  |  |  * @property   Smarty_Internal_Method_LoadFilter         $loadFilter | 
					
						
							|  |  |  |  * @property   Smarty_Internal_Method_LoadPlugin         $loadPlugin | 
					
						
							|  |  |  |  * @property   Smarty_Internal_Method_RegisterFilter     $registerFilter | 
					
						
							|  |  |  |  * @property   Smarty_Internal_Method_RegisterObject     $registerObject | 
					
						
							|  |  |  |  * @property   Smarty_Internal_Method_RegisterPlugin     $registerPlugin | 
					
						
							|  |  |  |  * @property   mixed|\Smarty_Template_Cached             configLoad | 
					
						
							| 
									
										
										
										
											2015-10-24 05:02:24 +02:00
										 |  |  |  */ | 
					
						
							|  |  |  | class Smarty_Internal_Extension_Handler | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2015-10-29 22:17:35 +01:00
										 |  |  |     public $objType = null; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-10-24 05:02:24 +02:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * Cache for property information from generic getter/setter | 
					
						
							|  |  |  |      * Preloaded with names which should not use with generic getter/setter | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @var array | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2018-08-31 16:45:09 +02:00
										 |  |  |     private $_property_info     = array( | 
					
						
							|  |  |  |         'AutoloadFilters' => 0, 'DefaultModifiers' => 0, 'ConfigVars' => 0, | 
					
						
							|  |  |  |         'DebugTemplate'   => 0, 'RegisteredObject' => 0, 'StreamVariable' => 0, | 
					
						
							|  |  |  |         'TemplateVars'    => 0, 'Literals' => 'Literals', | 
					
						
							|  |  |  |     );//
 | 
					
						
							| 
									
										
										
										
											2015-10-24 05:02:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-10-29 22:17:35 +01:00
										 |  |  |     private $resolvedProperties = array(); | 
					
						
							| 
									
										
										
										
											2015-10-24 05:02:24 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Call external Method | 
					
						
							| 
									
										
										
										
											2015-10-29 22:17:35 +01:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2015-10-24 05:02:24 +02:00
										 |  |  |      * @param \Smarty_Internal_Data $data | 
					
						
							| 
									
										
										
										
											2015-10-29 22:17:35 +01:00
										 |  |  |      * @param string                $name external method names | 
					
						
							|  |  |  |      * @param array                 $args argument array | 
					
						
							| 
									
										
										
										
											2015-10-24 05:02:24 +02:00
										 |  |  |      * | 
					
						
							|  |  |  |      * @return mixed | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2015-10-29 22:17:35 +01:00
										 |  |  |     public function _callExternalMethod(Smarty_Internal_Data $data, $name, $args) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         /* @var Smarty $data ->smarty */ | 
					
						
							| 
									
										
										
										
											2015-10-24 05:02:24 +02:00
										 |  |  |         $smarty = isset($data->smarty) ? $data->smarty : $data; | 
					
						
							|  |  |  |         if (!isset($smarty->ext->$name)) { | 
					
						
							| 
									
										
										
										
											2017-10-07 08:20:18 +02:00
										 |  |  |             if (preg_match('/^((set|get)|(.*?))([A-Z].*)$/', $name, $match)) { | 
					
						
							| 
									
										
										
										
											2018-08-31 16:45:09 +02:00
										 |  |  |                 $basename = $this->upperCase($match[ 4 ]); | 
					
						
							|  |  |  |                 if (!isset($smarty->ext->$basename) && isset($this->_property_info[ $basename ]) | 
					
						
							| 
									
										
										
										
											2018-06-12 09:58:15 +02:00
										 |  |  |                     && is_string($this->_property_info[ $basename ]) | 
					
						
							|  |  |  |                 ) { | 
					
						
							| 
									
										
										
										
											2017-10-07 08:20:18 +02:00
										 |  |  |                     $class = 'Smarty_Internal_Method_' . $this->_property_info[ $basename ]; | 
					
						
							|  |  |  |                     if (class_exists($class)) { | 
					
						
							|  |  |  |                         $classObj = new $class(); | 
					
						
							|  |  |  |                         $methodes = get_class_methods($classObj); | 
					
						
							|  |  |  |                         foreach ($methodes as $method) { | 
					
						
							|  |  |  |                             $smarty->ext->$method = $classObj; | 
					
						
							|  |  |  |                         } | 
					
						
							|  |  |  |                     } | 
					
						
							| 
									
										
										
										
											2015-10-29 22:17:35 +01:00
										 |  |  |                 } | 
					
						
							| 
									
										
										
										
											2018-08-31 16:45:09 +02:00
										 |  |  |                 if (!empty($match[ 2 ]) && !isset($smarty->ext->$name)) { | 
					
						
							| 
									
										
										
										
											2017-10-07 08:20:18 +02:00
										 |  |  |                     $class = 'Smarty_Internal_Method_' . $this->upperCase($name); | 
					
						
							|  |  |  |                     if (!class_exists($class)) { | 
					
						
							|  |  |  |                         $objType = $data->_objType; | 
					
						
							|  |  |  |                         $propertyType = false; | 
					
						
							| 
									
										
										
										
											2018-08-31 16:45:09 +02:00
										 |  |  |                         if (!isset($this->resolvedProperties[ $match[ 0 ] ][ $objType ])) { | 
					
						
							|  |  |  |                             $property = isset($this->resolvedProperties[ 'property' ][ $basename ]) ? | 
					
						
							|  |  |  |                                 $this->resolvedProperties[ 'property' ][ $basename ] : | 
					
						
							|  |  |  |                                 $property = $this->resolvedProperties[ 'property' ][ $basename ] = strtolower( | 
					
						
							| 
									
										
										
										
											2018-06-12 09:58:15 +02:00
										 |  |  |                                     join( | 
					
						
							|  |  |  |                                         '_', | 
					
						
							|  |  |  |                                         preg_split( | 
					
						
							|  |  |  |                                             '/([A-Z][^A-Z]*)/', | 
					
						
							|  |  |  |                                             $basename, | 
					
						
							|  |  |  |                                             -1, | 
					
						
							|  |  |  |                                             PREG_SPLIT_NO_EMPTY | | 
					
						
							|  |  |  |                                             PREG_SPLIT_DELIM_CAPTURE | 
					
						
							|  |  |  |                                         ) | 
					
						
							|  |  |  |                                     ) | 
					
						
							|  |  |  |                                 ); | 
					
						
							| 
									
										
										
										
											2017-10-07 08:20:18 +02:00
										 |  |  |                             if ($property !== false) { | 
					
						
							|  |  |  |                                 if (property_exists($data, $property)) { | 
					
						
							| 
									
										
										
										
											2018-08-31 16:45:09 +02:00
										 |  |  |                                     $propertyType = $this->resolvedProperties[ $match[ 0 ] ][ $objType ] = 1; | 
					
						
							| 
									
										
										
										
											2018-08-19 02:35:46 +02:00
										 |  |  |                                 } elseif (property_exists($smarty, $property)) { | 
					
						
							| 
									
										
										
										
											2018-08-31 16:45:09 +02:00
										 |  |  |                                     $propertyType = $this->resolvedProperties[ $match[ 0 ] ][ $objType ] = 2; | 
					
						
							| 
									
										
										
										
											2017-10-07 08:20:18 +02:00
										 |  |  |                                 } else { | 
					
						
							| 
									
										
										
										
											2018-08-31 16:45:09 +02:00
										 |  |  |                                     $this->resolvedProperties[ 'property' ][ $basename ] = $property = false; | 
					
						
							| 
									
										
										
										
											2017-10-07 08:20:18 +02:00
										 |  |  |                                 } | 
					
						
							|  |  |  |                             } | 
					
						
							|  |  |  |                         } else { | 
					
						
							| 
									
										
										
										
											2018-08-31 16:45:09 +02:00
										 |  |  |                             $propertyType = $this->resolvedProperties[ $match[ 0 ] ][ $objType ]; | 
					
						
							|  |  |  |                             $property = $this->resolvedProperties[ 'property' ][ $basename ]; | 
					
						
							| 
									
										
										
										
											2017-10-07 08:20:18 +02:00
										 |  |  |                         } | 
					
						
							|  |  |  |                         if ($propertyType) { | 
					
						
							|  |  |  |                             $obj = $propertyType === 1 ? $data : $smarty; | 
					
						
							| 
									
										
										
										
											2018-08-31 16:45:09 +02:00
										 |  |  |                             if ($match[ 2 ] === 'get') { | 
					
						
							| 
									
										
										
										
											2017-10-07 08:20:18 +02:00
										 |  |  |                                 return $obj->$property; | 
					
						
							| 
									
										
										
										
											2018-08-31 16:45:09 +02:00
										 |  |  |                             } elseif ($match[ 2 ] === 'set') { | 
					
						
							|  |  |  |                                 return $obj->$property = $args[ 0 ]; | 
					
						
							| 
									
										
										
										
											2017-10-07 08:20:18 +02:00
										 |  |  |                             } | 
					
						
							|  |  |  |                         } | 
					
						
							| 
									
										
										
										
											2015-10-29 22:17:35 +01:00
										 |  |  |                     } | 
					
						
							| 
									
										
										
										
											2015-10-24 05:02:24 +02:00
										 |  |  |                 } | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-10-07 08:20:18 +02:00
										 |  |  |         $callback = array($smarty->ext->$name, $name); | 
					
						
							| 
									
										
										
										
											2015-10-24 05:02:24 +02:00
										 |  |  |         array_unshift($args, $data); | 
					
						
							| 
									
										
										
										
											2018-08-31 16:45:09 +02:00
										 |  |  |         if (isset($callback) && $callback[ 0 ]->objMap | $data->_objType) { | 
					
						
							| 
									
										
										
										
											2015-10-24 05:02:24 +02:00
										 |  |  |             return call_user_func_array($callback, $args); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         return call_user_func_array(array(new Smarty_Internal_Undefined(), $name), $args); | 
					
						
							| 
									
										
										
										
											2015-10-29 22:17:35 +01:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2015-10-24 05:02:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-20 15:58:12 +02:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * Make first character of name parts upper case | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @param string $name | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @return string | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2016-09-19 16:39:19 +02:00
										 |  |  |     public function upperCase($name) | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2016-08-20 15:58:12 +02:00
										 |  |  |         $_name = explode('_', $name); | 
					
						
							|  |  |  |         $_name = array_map('ucfirst', $_name); | 
					
						
							|  |  |  |         return implode('_', $_name); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-10-24 05:02:24 +02:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * get extension object | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @param string $property_name property name | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @return mixed|Smarty_Template_Cached | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public function __get($property_name) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         // object properties of runtime template extensions will start with '_'
 | 
					
						
							| 
									
										
										
										
											2018-08-31 16:45:09 +02:00
										 |  |  |         if ($property_name[ 0 ] === '_') { | 
					
						
							| 
									
										
										
										
											2016-08-20 15:58:12 +02:00
										 |  |  |             $class = 'Smarty_Internal_Runtime' . $this->upperCase($property_name); | 
					
						
							| 
									
										
										
										
											2015-10-24 05:02:24 +02:00
										 |  |  |         } else { | 
					
						
							| 
									
										
										
										
											2016-08-20 15:58:12 +02:00
										 |  |  |             $class = 'Smarty_Internal_Method_' . $this->upperCase($property_name); | 
					
						
							| 
									
										
										
										
											2015-10-24 05:02:24 +02:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2016-08-14 02:38:55 +02:00
										 |  |  |         if (!class_exists($class)) { | 
					
						
							|  |  |  |             return $this->$property_name = new Smarty_Internal_Undefined($class); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2016-02-01 00:46:15 +01:00
										 |  |  |         return $this->$property_name = new $class(); | 
					
						
							| 
									
										
										
										
											2015-10-24 05:02:24 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-07 08:20:18 +02:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * set extension property | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @param string $property_name property name | 
					
						
							|  |  |  |      * @param mixed  $value         value | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public function __set($property_name, $value) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         $this->$property_name = $value; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-10-24 05:02:24 +02:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * Call error handler for undefined method | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @param string $name unknown method-name | 
					
						
							|  |  |  |      * @param array  $args argument array | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @return mixed | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public function __call($name, $args) | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2016-02-01 00:46:15 +01:00
										 |  |  |         return call_user_func_array(array(new Smarty_Internal_Undefined(), $name), array($this)); | 
					
						
							| 
									
										
										
										
											2015-10-24 05:02:24 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-06-12 09:58:15 +02:00
										 |  |  | } |