/framework/vendor/smarty3/lib/libs/sysplugins/smarty_internal_compile_append.php
PHP | 61 lines | 34 code | 4 blank | 23 comment | 10 complexity | 3618e8ccf0029d5a3994767d744fc9f8 MD5 | raw file
1<?php 2 3/** 4* Smarty Internal Plugin Compile Append 5* 6* Compiles the {append} tag 7* 8* @package Smarty 9* @subpackage Compiler 10* @author Uwe Tews 11*/ 12/** 13* Smarty Internal Plugin Compile Append Class 14*/ 15class Smarty_Internal_Compile_Append extends Smarty_Internal_CompileBase { 16 /** 17 * Compiles code for the {append} tag 18 * 19 * @param array $args array with attributes from parser 20 * @param object $compiler compiler object 21 * @return string compiled code 22 */ 23 public function compile($args, $compiler) 24 { 25 $this->compiler = $compiler; 26 $this->required_attributes = array('var', 'value'); 27 $this->optional_attributes = array('scope', 'nocache', 'index'); 28 29 $_nocache = 'null'; 30 $_scope = 'null'; 31 // check for nocache attribute before _get_attributes because 32 // it shall not controll caching of the compiled code, but is a parameter 33 if (isset($args['nocache'])) { 34 if ($args['nocache'] == 'true') { 35 $_nocache = 'true'; 36 $_nocache_boolean = true; 37 } 38 unset($args['nocache']); 39 } 40 // check and get attributes 41 $_attr = $this->_get_attributes($args); 42 43 if (isset($_attr['scope'])) { 44 if ($_attr['scope'] == '\'parent\'') { 45 $_scope = SMARTY_PARENT_SCOPE; 46 } elseif ($_attr['scope'] == '\'root\'') { 47 $_scope = SMARTY_ROOT_SCOPE; 48 } elseif ($_attr['scope'] == '\'global\'') { 49 $_scope = SMARTY_GLOBAL_SCOPE; 50 } 51 } 52 // compiled output 53 if (isset($_attr['index'])) { 54 return "<?php \$_smarty_tpl->append($_attr[var],array($_attr[index] => $_attr[value]),true,$_nocache,$_scope);?>"; 55 } else { 56 return "<?php \$_smarty_tpl->append($_attr[var],$_attr[value],false,$_nocache,$_scope);?>"; 57 } 58 } 59} 60 61?>