| 
									
										
										
										
											2009-04-04 15:46:09 +00:00
										 |  |  | <?php | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  | * Smarty Internal Plugin Compile Append | 
					
						
							|  |  |  | *  | 
					
						
							|  |  |  | * Compiles the {append} tag | 
					
						
							|  |  |  | *  | 
					
						
							|  |  |  | * @package Smarty | 
					
						
							|  |  |  | * @subpackage Compiler | 
					
						
							|  |  |  | * @author Uwe Tews  | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  | * Smarty Internal Plugin Compile Append Class | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | class Smarty_Internal_Compile_Append extends Smarty_Internal_CompileBase { | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |     * Compiles code for the {append} tag | 
					
						
							|  |  |  |     *  | 
					
						
							|  |  |  |     * @param array $args array with attributes from parser | 
					
						
							|  |  |  |     * @param object $compiler compiler object | 
					
						
							|  |  |  |     * @return string compiled code | 
					
						
							|  |  |  |     */ | 
					
						
							|  |  |  |     public function compile($args, $compiler) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         $this->compiler = $compiler; | 
					
						
							|  |  |  |         $this->required_attributes = array('var', 'value'); | 
					
						
							| 
									
										
										
										
											2009-04-07 16:22:31 +00:00
										 |  |  |         $this->optional_attributes = array('scope', 'nocache', 'index'); | 
					
						
							| 
									
										
										
										
											2009-04-04 15:46:09 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |         $_nocache = 'null'; | 
					
						
							| 
									
										
										
										
											2009-04-07 16:22:31 +00:00
										 |  |  |         $_scope = 'null';  | 
					
						
							| 
									
										
										
										
											2009-04-04 15:46:09 +00:00
										 |  |  |         // check for nocache attribute before _get_attributes because
 | 
					
						
							|  |  |  |         // it shall not controll caching of the compiled code, but is a parameter
 | 
					
						
							|  |  |  |         if (isset($args['nocache'])) { | 
					
						
							|  |  |  |             if ($args['nocache'] == 'true') { | 
					
						
							| 
									
										
										
										
											2010-07-31 13:29:59 +00:00
										 |  |  |                 $this->compiler->tag_nocache = true; | 
					
						
							| 
									
										
										
										
											2009-04-04 15:46:09 +00:00
										 |  |  |             }  | 
					
						
							|  |  |  |             unset($args['nocache']); | 
					
						
							|  |  |  |         }  | 
					
						
							| 
									
										
										
										
											2010-07-31 13:29:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-04 15:46:09 +00:00
										 |  |  |         // check and get attributes
 | 
					
						
							|  |  |  |         $_attr = $this->_get_attributes($args); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-07-31 13:29:59 +00:00
										 |  |  |         if ($this->compiler->tag_nocache) { | 
					
						
							|  |  |  |             $_nocache = 'true';  | 
					
						
							|  |  |  |             // create nocache var to make it know for further compiling
 | 
					
						
							|  |  |  |             $compiler->template->tpl_vars[trim($_attr['var'],"'")] = new Smarty_variable(null, true); | 
					
						
							|  |  |  |         }  | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-07 16:22:31 +00:00
										 |  |  |         if (isset($_attr['scope'])) { | 
					
						
							| 
									
										
										
										
											2010-07-30 13:09:52 +00:00
										 |  |  |             $_attr['scope'] = trim($_attr['scope'], "'\""); | 
					
						
							|  |  |  |             if ($_attr['scope'] == 'parent') { | 
					
						
							| 
									
										
										
										
											2009-08-09 22:03:33 +00:00
										 |  |  |                 $_scope = SMARTY_PARENT_SCOPE; | 
					
						
							| 
									
										
										
										
											2010-07-30 13:09:52 +00:00
										 |  |  |             } elseif ($_attr['scope'] == 'root') { | 
					
						
							| 
									
										
										
										
											2009-08-09 22:03:33 +00:00
										 |  |  |                 $_scope = SMARTY_ROOT_SCOPE; | 
					
						
							| 
									
										
										
										
											2010-07-30 13:09:52 +00:00
										 |  |  |            } elseif ($_attr['scope'] == 'global') { | 
					
						
							| 
									
										
										
										
											2009-08-09 22:03:33 +00:00
										 |  |  |                 $_scope = SMARTY_GLOBAL_SCOPE; | 
					
						
							|  |  |  |             }  | 
					
						
							| 
									
										
										
										
											2009-04-04 15:46:09 +00:00
										 |  |  |         }  | 
					
						
							|  |  |  |         // compiled output
 | 
					
						
							|  |  |  |         if (isset($_attr['index'])) { | 
					
						
							| 
									
										
										
										
											2009-04-07 16:22:31 +00:00
										 |  |  |             return "<?php \$_smarty_tpl->append($_attr[var],array($_attr[index] => $_attr[value]),true,$_nocache,$_scope);?>"; | 
					
						
							| 
									
										
										
										
											2009-04-04 15:46:09 +00:00
										 |  |  |         } else { | 
					
						
							| 
									
										
										
										
											2009-04-07 16:22:31 +00:00
										 |  |  |             return "<?php \$_smarty_tpl->append($_attr[var],$_attr[value],false,$_nocache,$_scope);?>"; | 
					
						
							| 
									
										
										
										
											2009-04-04 15:46:09 +00:00
										 |  |  |         }  | 
					
						
							|  |  |  |     }  | 
					
						
							|  |  |  | }  | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-07-30 13:09:52 +00:00
										 |  |  | ?>
 |