| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  | <?php | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  | * Smarty Internal Plugin Data | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  | *  | 
					
						
							|  |  |  | * This file contains the basic classes and methodes for template and variable creation | 
					
						
							|  |  |  | *  | 
					
						
							|  |  |  | * @package Smarty | 
					
						
							|  |  |  | * @subpackage Templates | 
					
						
							|  |  |  | * @author Uwe Tews  | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  | * Base class with template and variable methodes | 
					
						
							|  |  |  | */ | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  | class Smarty_Internal_Data { | 
					
						
							| 
									
										
										
										
											2009-08-18 16:53:33 +00:00
										 |  |  |     // class used for templates
 | 
					
						
							| 
									
										
										
										
											2009-09-29 22:58:54 +00:00
										 |  |  |     public $template_class = 'Smarty_Internal_Template'; | 
					
						
							| 
									
										
										
										
											2009-08-18 16:53:33 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     /** | 
					
						
							|  |  |  |     * assigns a Smarty variable | 
					
						
							|  |  |  |     *  | 
					
						
							|  |  |  |     * @param array $ |string $tpl_var the template variable name(s) | 
					
						
							|  |  |  |     * @param mixed $value the value to assign | 
					
						
							|  |  |  |     * @param boolean $nocache if true any output of this variable will be not cached | 
					
						
							| 
									
										
										
										
											2009-04-12 22:26:02 +00:00
										 |  |  |     * @param boolean $scope the scope the variable will have  (local,parent or root) | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     */ | 
					
						
							| 
									
										
										
										
											2009-04-07 16:22:31 +00:00
										 |  |  |     public function assign($tpl_var, $value = null, $nocache = false, $scope = SMARTY_LOCAL_SCOPE) | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     { | 
					
						
							|  |  |  |         if (is_array($tpl_var)) { | 
					
						
							|  |  |  |             foreach ($tpl_var as $_key => $_val) { | 
					
						
							|  |  |  |                 if ($_key != '') { | 
					
						
							| 
									
										
										
										
											2009-04-07 16:22:31 +00:00
										 |  |  |                     $this->tpl_vars[$_key] = new Smarty_variable($_val, $nocache, $scope); | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |                 }  | 
					
						
							|  |  |  |             }  | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             if ($tpl_var != '') { | 
					
						
							| 
									
										
										
										
											2009-04-07 16:22:31 +00:00
										 |  |  |                 $this->tpl_vars[$tpl_var] = new Smarty_variable($value, $nocache, $scope); | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |             }  | 
					
						
							|  |  |  |         }  | 
					
						
							|  |  |  |     }  | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |     * assigns a global Smarty variable | 
					
						
							|  |  |  |     *  | 
					
						
							|  |  |  |     * @param string $varname the global variable name | 
					
						
							|  |  |  |     * @param mixed $value the value to assign | 
					
						
							|  |  |  |     * @param boolean $nocache if true any output of this variable will be not cached | 
					
						
							|  |  |  |     */ | 
					
						
							| 
									
										
										
										
											2010-02-06 22:11:10 +00:00
										 |  |  |     public function assignGlobal($varname, $value = null, $nocache = false) | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     { | 
					
						
							|  |  |  |         if ($varname != '') { | 
					
						
							| 
									
										
										
										
											2009-09-19 13:22:32 +00:00
										 |  |  |             $this->smarty->global_tpl_vars[$varname] = new Smarty_variable($value, $nocache); | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |         }  | 
					
						
							|  |  |  |     }  | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |     * assigns values to template variables by reference | 
					
						
							| 
									
										
										
										
											2009-10-11 20:23:00 +00:00
										 |  |  |     *  | 
					
						
							|  |  |  |     * @param string $tpl_var the template variable name | 
					
						
							|  |  |  |     * @param mixed $ &$value the referenced value to assign | 
					
						
							|  |  |  |     * @param boolean $nocache if true any output of this variable will be not cached | 
					
						
							|  |  |  |     * @param boolean $scope the scope the variable will have  (local,parent or root) | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     */ | 
					
						
							| 
									
										
										
										
											2010-02-06 22:11:10 +00:00
										 |  |  |     public function assignByRef($tpl_var, &$value, $nocache = false, $scope = SMARTY_LOCAL_SCOPE) | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2009-10-11 20:23:00 +00:00
										 |  |  |         if ($tpl_var != '') { | 
					
						
							|  |  |  |             $this->tpl_vars[$tpl_var] = new Smarty_variable(null, $nocache, $scope); | 
					
						
							|  |  |  |             $this->tpl_vars[$tpl_var]->value = &$value; | 
					
						
							|  |  |  |         }  | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     }  | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |     * appends values to template variables | 
					
						
							|  |  |  |     *  | 
					
						
							|  |  |  |     * @param array $ |string $tpl_var the template variable name(s) | 
					
						
							|  |  |  |     * @param mixed $value the value to append | 
					
						
							|  |  |  |     * @param boolean $merge flag if array elements shall be merged | 
					
						
							| 
									
										
										
										
											2009-04-07 16:22:31 +00:00
										 |  |  |     * @param boolean $nocache if true any output of this variable will be not cached | 
					
						
							| 
									
										
										
										
											2009-04-12 22:26:02 +00:00
										 |  |  |     * @param boolean $scope the scope the variable will have  (local,parent or root) | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     */ | 
					
						
							| 
									
										
										
										
											2009-04-07 16:22:31 +00:00
										 |  |  |     public function append($tpl_var, $value = null, $merge = false, $nocache = false, $scope = SMARTY_LOCAL_SCOPE) | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     { | 
					
						
							|  |  |  |         if (is_array($tpl_var)) { | 
					
						
							|  |  |  |             // $tpl_var is an array, ignore $value
 | 
					
						
							|  |  |  |             foreach ($tpl_var as $_key => $_val) { | 
					
						
							|  |  |  |                 if ($_key != '') { | 
					
						
							|  |  |  |                     if (!isset($this->tpl_vars[$_key])) { | 
					
						
							| 
									
										
										
										
											2009-04-12 22:26:02 +00:00
										 |  |  |                         $tpl_var_inst = $this->getVariable($_key, null, true, false); | 
					
						
							|  |  |  |                         if ($tpl_var_inst instanceof Undefined_Smarty_Variable) { | 
					
						
							|  |  |  |                             $this->tpl_vars[$_key] = new Smarty_variable(null, $nocache, $scope); | 
					
						
							|  |  |  |                         } else { | 
					
						
							|  |  |  |                             $this->tpl_vars[$_key] = clone $tpl_var_inst; | 
					
						
							|  |  |  |                             if ($scope != SMARTY_LOCAL_SCOPE) { | 
					
						
							|  |  |  |                                 $this->tpl_vars[$_key]->scope = $scope; | 
					
						
							|  |  |  |                             }  | 
					
						
							|  |  |  |                         }  | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |                     }  | 
					
						
							| 
									
										
										
										
											2009-04-12 22:26:02 +00:00
										 |  |  |                     if (!(is_array($this->tpl_vars[$_key]->value) || $this->tpl_vars[$_key]->value instanceof ArrayAccess)) { | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |                         settype($this->tpl_vars[$_key]->value, 'array'); | 
					
						
							|  |  |  |                     }  | 
					
						
							|  |  |  |                     if ($merge && is_array($_val)) { | 
					
						
							|  |  |  |                         foreach($_val as $_mkey => $_mval) { | 
					
						
							|  |  |  |                             $this->tpl_vars[$_key]->value[$_mkey] = $_mval; | 
					
						
							|  |  |  |                         }  | 
					
						
							|  |  |  |                     } else { | 
					
						
							|  |  |  |                         $this->tpl_vars[$_key]->value[] = $_val; | 
					
						
							|  |  |  |                     }  | 
					
						
							|  |  |  |                 }  | 
					
						
							|  |  |  |             }  | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             if ($tpl_var != '' && isset($value)) { | 
					
						
							|  |  |  |                 if (!isset($this->tpl_vars[$tpl_var])) { | 
					
						
							| 
									
										
										
										
											2009-04-12 22:26:02 +00:00
										 |  |  |                     $tpl_var_inst = $this->getVariable($tpl_var, null, true, false); | 
					
						
							|  |  |  |                     if ($tpl_var_inst instanceof Undefined_Smarty_Variable) { | 
					
						
							|  |  |  |                         $this->tpl_vars[$tpl_var] = new Smarty_variable(null, $nocache, $scope); | 
					
						
							|  |  |  |                     } else { | 
					
						
							|  |  |  |                         $this->tpl_vars[$tpl_var] = clone $tpl_var_inst; | 
					
						
							|  |  |  |                         if ($scope != SMARTY_LOCAL_SCOPE) { | 
					
						
							|  |  |  |                             $this->tpl_vars[$tpl_var]->scope = $scope; | 
					
						
							|  |  |  |                         }  | 
					
						
							|  |  |  |                     }  | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |                 }  | 
					
						
							| 
									
										
										
										
											2009-04-12 22:26:02 +00:00
										 |  |  |                 if (!(is_array($this->tpl_vars[$tpl_var]->value) || $this->tpl_vars[$tpl_var]->value instanceof ArrayAccess)) { | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |                     settype($this->tpl_vars[$tpl_var]->value, 'array'); | 
					
						
							|  |  |  |                 }  | 
					
						
							|  |  |  |                 if ($merge && is_array($value)) { | 
					
						
							|  |  |  |                     foreach($value as $_mkey => $_mval) { | 
					
						
							|  |  |  |                         $this->tpl_vars[$tpl_var]->value[$_mkey] = $_mval; | 
					
						
							|  |  |  |                     }  | 
					
						
							|  |  |  |                 } else { | 
					
						
							|  |  |  |                     $this->tpl_vars[$tpl_var]->value[] = $value; | 
					
						
							|  |  |  |                 }  | 
					
						
							|  |  |  |             }  | 
					
						
							|  |  |  |         }  | 
					
						
							|  |  |  |     }  | 
					
						
							| 
									
										
										
										
											2009-04-12 22:26:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     /** | 
					
						
							|  |  |  |     * appends values to template variables by reference | 
					
						
							|  |  |  |     *  | 
					
						
							| 
									
										
										
										
											2009-10-11 20:23:00 +00:00
										 |  |  |     * @param string $tpl_var the template variable name | 
					
						
							|  |  |  |     * @param mixed $ &$value the referenced value to append | 
					
						
							|  |  |  |     * @param boolean $merge flag if array elements shall be merged | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     */ | 
					
						
							| 
									
										
										
										
											2010-02-06 22:11:10 +00:00
										 |  |  |     public function appendByRef($tpl_var, &$value, $merge = false) | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2009-10-11 20:23:00 +00:00
										 |  |  |         if ($tpl_var != '' && isset($value)) { | 
					
						
							|  |  |  |             if (!isset($this->tpl_vars[$tpl_var])) { | 
					
						
							|  |  |  |                 $this->tpl_vars[$tpl_var] = new Smarty_variable(); | 
					
						
							|  |  |  |             }  | 
					
						
							|  |  |  |             if (!@is_array($this->tpl_vars[$tpl_var]->value)) { | 
					
						
							|  |  |  |                 settype($this->tpl_vars[$tpl_var]->value, 'array'); | 
					
						
							|  |  |  |             }  | 
					
						
							|  |  |  |             if ($merge && is_array($value)) { | 
					
						
							|  |  |  |                 foreach($value as $_key => $_val) { | 
					
						
							|  |  |  |                     $this->tpl_vars[$tpl_var]->value[$_key] = &$value[$_key]; | 
					
						
							|  |  |  |                 }  | 
					
						
							|  |  |  |             } else { | 
					
						
							|  |  |  |                 $this->tpl_vars[$tpl_var]->value[] = &$value; | 
					
						
							|  |  |  |             }  | 
					
						
							|  |  |  |         }  | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     }  | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-02-08 17:31:15 +00:00
										 |  |  |     /** | 
					
						
							|  |  |  |     * Returns a single or all template variables | 
					
						
							|  |  |  |     *  | 
					
						
							|  |  |  |     * @param string $varname variable name or null | 
					
						
							|  |  |  |     * @return string variable value or or array of variables | 
					
						
							|  |  |  |     */ | 
					
						
							|  |  |  |     function getTemplateVars($varname = null, $_ptr = null, $search_parents = true) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (isset($varname)) { | 
					
						
							|  |  |  |             $_var = $this->getVariable($varname, $_ptr, $search_parents); | 
					
						
							|  |  |  |             if (is_object($_var)) { | 
					
						
							|  |  |  |                 return $_var->value; | 
					
						
							|  |  |  |             } else { | 
					
						
							|  |  |  |                 return null; | 
					
						
							|  |  |  |             }  | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             $_result = array(); | 
					
						
							|  |  |  |             if ($_ptr === null) { | 
					
						
							|  |  |  |                 $_ptr = $this; | 
					
						
							|  |  |  |             } while ($_ptr !== null) { | 
					
						
							|  |  |  |                 foreach ($_ptr->tpl_vars AS $key => $var) { | 
					
						
							|  |  |  |                     $_result[$key] = $var->value; | 
					
						
							|  |  |  |                 }  | 
					
						
							|  |  |  |                 // not found, try at parent
 | 
					
						
							|  |  |  |                 if ($search_parents) { | 
					
						
							|  |  |  |                     $_ptr = $_ptr->parent; | 
					
						
							|  |  |  |                 } else { | 
					
						
							|  |  |  |                     $_ptr = null; | 
					
						
							|  |  |  |                 }  | 
					
						
							|  |  |  |             }  | 
					
						
							| 
									
										
										
										
											2010-05-06 00:32:10 +00:00
										 |  |  |             if ($search_parents && isset($this->global_tpl_vars)) { | 
					
						
							| 
									
										
										
										
											2010-02-08 17:31:15 +00:00
										 |  |  |                 foreach ($this->global_tpl_vars AS $key => $var) { | 
					
						
							|  |  |  |                     $_result[$key] = $var->value; | 
					
						
							|  |  |  |                 }  | 
					
						
							|  |  |  |             }  | 
					
						
							|  |  |  |             return $_result; | 
					
						
							|  |  |  |         }  | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |      | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     /** | 
					
						
							|  |  |  |     * clear the given assigned template variable. | 
					
						
							|  |  |  |     *  | 
					
						
							|  |  |  |     * @param string $ |array $tpl_var the template variable(s) to clear | 
					
						
							|  |  |  |     */ | 
					
						
							| 
									
										
										
										
											2010-02-06 22:11:10 +00:00
										 |  |  |     public function clearAssign($tpl_var) | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     { | 
					
						
							|  |  |  |         if (is_array($tpl_var)) { | 
					
						
							|  |  |  |             foreach ($tpl_var as $curr_var) { | 
					
						
							|  |  |  |                 unset($this->tpl_vars[$curr_var]); | 
					
						
							|  |  |  |             }  | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             unset($this->tpl_vars[$tpl_var]); | 
					
						
							|  |  |  |         }  | 
					
						
							|  |  |  |     }  | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |     * clear all the assigned template variables. | 
					
						
							|  |  |  |     */ | 
					
						
							| 
									
										
										
										
											2010-02-06 22:11:10 +00:00
										 |  |  |     public function clearAllAssign() | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     { | 
					
						
							|  |  |  |         $this->tpl_vars = array(); | 
					
						
							|  |  |  |     }  | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-05 18:22:40 +00:00
										 |  |  |     /** | 
					
						
							|  |  |  |     * load a config file, optionally load just selected sections | 
					
						
							|  |  |  |     *  | 
					
						
							|  |  |  |     * @param string $config_file filename | 
					
						
							|  |  |  |     * @param mixed $sections array of section names, single section or null | 
					
						
							|  |  |  |     */ | 
					
						
							| 
									
										
										
										
											2010-02-06 22:11:10 +00:00
										 |  |  |     public function configLoad($config_file, $sections = null) | 
					
						
							| 
									
										
										
										
											2009-11-05 18:22:40 +00:00
										 |  |  |     {  | 
					
						
							|  |  |  |         // load Config class
 | 
					
						
							|  |  |  |         $config = new Smarty_Internal_Config($config_file, $this->smarty); | 
					
						
							|  |  |  |         $config->loadConfigVars($sections, $this); | 
					
						
							|  |  |  |     }  | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     /** | 
					
						
							|  |  |  |     * gets the object of a Smarty variable | 
					
						
							|  |  |  |     *  | 
					
						
							|  |  |  |     * @param string $variable the name of the Smarty variable | 
					
						
							|  |  |  |     * @param object $_ptr optional pointer to data object | 
					
						
							|  |  |  |     * @param boolean $search_parents search also in parent data | 
					
						
							|  |  |  |     * @return object the object of the variable | 
					
						
							|  |  |  |     */ | 
					
						
							| 
									
										
										
										
											2009-04-12 22:26:02 +00:00
										 |  |  |     public function getVariable($variable, $_ptr = null, $search_parents = true, $error_enable = true) | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     { | 
					
						
							|  |  |  |         if ($_ptr === null) { | 
					
						
							|  |  |  |             $_ptr = $this; | 
					
						
							| 
									
										
										
										
											2009-04-12 22:26:02 +00:00
										 |  |  |         } while ($_ptr !== null) { | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |             if (isset($_ptr->tpl_vars[$variable])) { | 
					
						
							|  |  |  |                 // found it, return it
 | 
					
						
							|  |  |  |                 return $_ptr->tpl_vars[$variable]; | 
					
						
							|  |  |  |             }  | 
					
						
							|  |  |  |             // not found, try at parent
 | 
					
						
							|  |  |  |             if ($search_parents) { | 
					
						
							|  |  |  |                 $_ptr = $_ptr->parent; | 
					
						
							|  |  |  |             } else { | 
					
						
							|  |  |  |                 $_ptr = null; | 
					
						
							|  |  |  |             }  | 
					
						
							|  |  |  |         }  | 
					
						
							| 
									
										
										
										
											2009-09-19 13:22:32 +00:00
										 |  |  |         if (isset($this->smarty->global_tpl_vars[$variable])) { | 
					
						
							| 
									
										
										
										
											2009-04-10 12:33:51 +00:00
										 |  |  |             // found it, return it
 | 
					
						
							| 
									
										
										
										
											2009-09-19 13:22:32 +00:00
										 |  |  |             return $this->smarty->global_tpl_vars[$variable]; | 
					
						
							| 
									
										
										
										
											2009-04-10 12:33:51 +00:00
										 |  |  |         }  | 
					
						
							| 
									
										
										
										
											2009-10-31 00:44:58 +00:00
										 |  |  |         if ($this->smarty->error_unassigned && $error_enable) { | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |             throw new Exception('Undefined Smarty variable "' . $variable . '"'); | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             return new Undefined_Smarty_Variable; | 
					
						
							|  |  |  |         }  | 
					
						
							|  |  |  |     }  | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |     * gets  a config variable | 
					
						
							|  |  |  |     *  | 
					
						
							|  |  |  |     * @param string $variable the name of the config variable | 
					
						
							|  |  |  |     * @return mixed the value of the config variable | 
					
						
							|  |  |  |     */ | 
					
						
							|  |  |  |     public function getConfigVariable($variable) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         $_ptr = $this; | 
					
						
							|  |  |  |         while ($_ptr !== null) { | 
					
						
							|  |  |  |             if (isset($_ptr->config_vars[$variable])) { | 
					
						
							|  |  |  |                 // found it, return it
 | 
					
						
							|  |  |  |                 return $_ptr->config_vars[$variable]; | 
					
						
							|  |  |  |             }  | 
					
						
							|  |  |  |             // not found, try at parent
 | 
					
						
							|  |  |  |             $_ptr = $_ptr->parent; | 
					
						
							|  |  |  |         }  | 
					
						
							| 
									
										
										
										
											2009-10-31 00:44:58 +00:00
										 |  |  |         if ($this->smarty->error_unassigned) { | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |             throw new Exception('Undefined config variable "' . $variable . '"'); | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             return ''; | 
					
						
							|  |  |  |         }  | 
					
						
							|  |  |  |     }  | 
					
						
							|  |  |  |     /** | 
					
						
							| 
									
										
										
										
											2009-04-18 14:46:29 +00:00
										 |  |  |     * gets  a stream variable | 
					
						
							|  |  |  |     *  | 
					
						
							|  |  |  |     * @param string $variable the stream of the variable | 
					
						
							| 
									
										
										
										
											2009-09-19 13:22:32 +00:00
										 |  |  |     * @return mixed the value of the stream variable | 
					
						
							| 
									
										
										
										
											2009-04-18 14:46:29 +00:00
										 |  |  |     */ | 
					
						
							|  |  |  |     public function getStreamVariable($variable) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         $_result = ''; | 
					
						
							|  |  |  |         if ($fp = fopen($variable, 'r+')) { | 
					
						
							|  |  |  |             while (!feof($fp)) { | 
					
						
							|  |  |  |                 $_result .= fgets($fp); | 
					
						
							|  |  |  |             }  | 
					
						
							|  |  |  |             fclose($fp); | 
					
						
							|  |  |  |             return $_result; | 
					
						
							|  |  |  |         }  | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-10-31 00:44:58 +00:00
										 |  |  |         if ($this->smarty->$error_unassigned) { | 
					
						
							| 
									
										
										
										
											2009-09-19 13:22:32 +00:00
										 |  |  |             throw new Exception('Undefined stream variable "' . $variable . '"'); | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |         } else { | 
					
						
							|  |  |  |             return ''; | 
					
						
							|  |  |  |         }  | 
					
						
							|  |  |  |     }  | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							| 
									
										
										
										
											2010-01-22 16:39:30 +00:00
										 |  |  |     * Returns a single or all config variables | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     *  | 
					
						
							| 
									
										
										
										
											2010-01-22 16:39:30 +00:00
										 |  |  |     * @param string $varname variable name or null | 
					
						
							|  |  |  |     * @return string variable value or or array of variables | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     */ | 
					
						
							| 
									
										
										
										
											2010-02-06 22:11:10 +00:00
										 |  |  |     function getConfigVars($varname = null) | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2010-01-22 16:39:30 +00:00
										 |  |  |         if (isset($varname)) { | 
					
						
							|  |  |  |             if (isset($this->config_vars[$varname])) { | 
					
						
							|  |  |  |                 return $this->config_vars[$varname]; | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |             } else { | 
					
						
							| 
									
										
										
										
											2010-01-22 16:39:30 +00:00
										 |  |  |                 return ''; | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |             }  | 
					
						
							|  |  |  |         } else { | 
					
						
							| 
									
										
										
										
											2010-01-22 16:39:30 +00:00
										 |  |  |             return $this->config_vars; | 
					
						
							| 
									
										
										
										
											2009-09-29 22:58:54 +00:00
										 |  |  |         }  | 
					
						
							| 
									
										
										
										
											2010-01-22 16:39:30 +00:00
										 |  |  |     }  | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |     * Deassigns a single or all config variables | 
					
						
							|  |  |  |     *  | 
					
						
							|  |  |  |     * @param string $varname variable name or null | 
					
						
							|  |  |  |     */ | 
					
						
							| 
									
										
										
										
											2010-02-06 22:11:10 +00:00
										 |  |  |     function clearConfig($varname = null) | 
					
						
							| 
									
										
										
										
											2010-01-22 16:39:30 +00:00
										 |  |  |     { | 
					
						
							|  |  |  |         if (isset($varname)) { | 
					
						
							|  |  |  |             unset($this->config_vars[$varname]); | 
					
						
							|  |  |  |             return; | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             $this->config_vars = array(); | 
					
						
							|  |  |  |             return; | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |         }  | 
					
						
							|  |  |  |     }  | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |     * return current time | 
					
						
							|  |  |  |     *  | 
					
						
							|  |  |  |     * @returns double current time | 
					
						
							|  |  |  |     */ | 
					
						
							|  |  |  |     function _get_time() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         $_mtime = microtime(); | 
					
						
							|  |  |  |         $_mtime = explode(" ", $_mtime); | 
					
						
							|  |  |  |         return (double)($_mtime[1]) + (double)($_mtime[0]); | 
					
						
							|  |  |  |     }  | 
					
						
							|  |  |  | }  | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  | * class for the Smarty data object | 
					
						
							|  |  |  | *  | 
					
						
							|  |  |  | * The Smarty data object will hold Smarty variables in the current scope | 
					
						
							|  |  |  | *  | 
					
						
							|  |  |  | * @param object $parent tpl_vars next higher level of Smarty variables | 
					
						
							|  |  |  | */ | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  | class Smarty_Data extends Smarty_Internal_Data { | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     // array of variable objects
 | 
					
						
							|  |  |  |     public $tpl_vars = array();  | 
					
						
							|  |  |  |     // back pointer to parent object
 | 
					
						
							|  |  |  |     public $parent = null;  | 
					
						
							|  |  |  |     // config vars
 | 
					
						
							| 
									
										
										
										
											2010-01-22 16:39:30 +00:00
										 |  |  |     public $config_vars = array();  | 
					
						
							|  |  |  |     // Smarty object
 | 
					
						
							|  |  |  |     public $smarty = null; | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     /** | 
					
						
							|  |  |  |     * create Smarty data object | 
					
						
							|  |  |  |     */ | 
					
						
							| 
									
										
										
										
											2010-01-22 16:39:30 +00:00
										 |  |  |     public function __construct ($_parent = null, $smarty = null) | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2010-01-22 16:39:30 +00:00
										 |  |  |         $this->smarty = $smarty; | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |         if (is_object($_parent)) { | 
					
						
							|  |  |  |             // when object set up back pointer
 | 
					
						
							|  |  |  |             $this->parent = $_parent; | 
					
						
							|  |  |  |         } elseif (is_array($_parent)) { | 
					
						
							|  |  |  |             // set up variable values
 | 
					
						
							|  |  |  |             foreach ($_parent as $_key => $_val) { | 
					
						
							|  |  |  |                 $this->tpl_vars[$_key] = new Smarty_variable($_val); | 
					
						
							|  |  |  |             }  | 
					
						
							| 
									
										
										
										
											2010-01-22 16:39:30 +00:00
										 |  |  |         } elseif ($_parent != null) { | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |             throw new Exception("Wrong type for template variables"); | 
					
						
							|  |  |  |         }  | 
					
						
							|  |  |  |     }  | 
					
						
							|  |  |  | }  | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  | * class for the Smarty variable object | 
					
						
							|  |  |  | *  | 
					
						
							|  |  |  | * This class defines the Smarty variable object | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | class Smarty_Variable { | 
					
						
							|  |  |  |     // template variable
 | 
					
						
							|  |  |  |     public $value; | 
					
						
							|  |  |  |     public $nocache; | 
					
						
							| 
									
										
										
										
											2009-04-07 16:22:31 +00:00
										 |  |  |     public $scope; | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     /** | 
					
						
							|  |  |  |     * create Smarty variable object | 
					
						
							|  |  |  |     *  | 
					
						
							|  |  |  |     * @param mixed $value the value to assign | 
					
						
							|  |  |  |     * @param boolean $nocache if true any output of this variable will be not cached | 
					
						
							| 
									
										
										
										
											2009-04-12 22:26:02 +00:00
										 |  |  |     * @param boolean $scope the scope the variable will have  (local,parent or root) | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     */ | 
					
						
							| 
									
										
										
										
											2009-04-07 16:22:31 +00:00
										 |  |  |     public function __construct ($value = null, $nocache = false, $scope = SMARTY_LOCAL_SCOPE) | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     { | 
					
						
							|  |  |  |         $this->value = $value; | 
					
						
							|  |  |  |         $this->nocache = $nocache; | 
					
						
							| 
									
										
										
										
											2009-04-07 16:22:31 +00:00
										 |  |  |         $this->scope = $scope; | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     }  | 
					
						
							|  |  |  | }  | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  | * class for undefined variable object | 
					
						
							|  |  |  | *  | 
					
						
							|  |  |  | * This class defines an object for undefined variable handling | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | class Undefined_Smarty_Variable { | 
					
						
							|  |  |  |     // return always false
 | 
					
						
							|  |  |  |     public function __get ($name) | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2009-03-26 14:08:43 +00:00
										 |  |  |         if ($name == 'nocache') { | 
					
						
							|  |  |  |             return false; | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             return null; | 
					
						
							|  |  |  |         }  | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     }  | 
					
						
							|  |  |  | }  | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-05-06 00:32:10 +00:00
										 |  |  | ?>
 |