| 
									
										
										
										
											2015-10-21 02:02:42 +02:00
										 |  |  | <?php | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * Runtime Methods createLocalArrayVariable | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * @package    Smarty | 
					
						
							|  |  |  |  * @subpackage PluginsInternal | 
					
						
							|  |  |  |  * @author     Uwe Tews | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  **/ | 
					
						
							|  |  |  | class Smarty_Internal_Runtime_Var | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Template code runtime function to create a local Smarty variable for array assignments | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @param \Smarty_Internal_Template $tpl     template object | 
					
						
							| 
									
										
										
										
											2015-10-24 05:02:24 +02:00
										 |  |  |      * @param string                    $varName template variable name | 
					
						
							| 
									
										
										
										
											2015-10-21 02:02:42 +02:00
										 |  |  |      * @param bool                      $nocache cache mode of variable | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2015-12-19 20:10:45 +01:00
										 |  |  |     public function createLocalArrayVariable(Smarty_Internal_Template $tpl, $varName, $nocache = false) | 
					
						
							| 
									
										
										
										
											2015-10-21 02:02:42 +02:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2015-10-24 05:02:24 +02:00
										 |  |  |         if (!isset($tpl->tpl_vars[$varName])) { | 
					
						
							| 
									
										
										
										
											2015-10-29 22:17:35 +01:00
										 |  |  |             $tpl->tpl_vars[$varName] = new Smarty_Variable(array(), $nocache); | 
					
						
							| 
									
										
										
										
											2015-10-21 02:02:42 +02:00
										 |  |  |         } else { | 
					
						
							| 
									
										
										
										
											2015-10-24 05:02:24 +02:00
										 |  |  |             $tpl->tpl_vars[$varName] = clone $tpl->tpl_vars[$varName]; | 
					
						
							|  |  |  |             if (!(is_array($tpl->tpl_vars[$varName]->value) || | 
					
						
							|  |  |  |                 $tpl->tpl_vars[$varName]->value instanceof ArrayAccess) | 
					
						
							| 
									
										
										
										
											2015-10-21 02:02:42 +02:00
										 |  |  |             ) { | 
					
						
							| 
									
										
										
										
											2015-10-24 05:02:24 +02:00
										 |  |  |                 settype($tpl->tpl_vars[$varName]->value, 'array'); | 
					
						
							| 
									
										
										
										
											2015-10-21 02:02:42 +02:00
										 |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } |