| 
									
										
										
										
											2009-11-06 14:35:00 +00:00
										 |  |  | <?php | 
					
						
							| 
									
										
										
										
											2012-06-30 15:53:22 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-07-27 07:05:26 +00:00
										 |  |  | /** | 
					
						
							|  |  |  |  * Smarty Internal Plugin Compile Block | 
					
						
							|  |  |  |  * Compiles the {block}{/block} tags | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |  * @package    Smarty | 
					
						
							| 
									
										
										
										
											2013-07-27 07:05:26 +00:00
										 |  |  |  * @subpackage Compiler | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |  * @author     Uwe Tews | 
					
						
							| 
									
										
										
										
											2013-07-27 07:05:26 +00:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * Smarty Internal Plugin Compile Block Class | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |  * @package    Smarty | 
					
						
							| 
									
										
										
										
											2013-07-27 07:05:26 +00:00
										 |  |  |  * @subpackage Compiler | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | class Smarty_Internal_Compile_Block extends Smarty_Internal_CompileBase | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2013-08-24 18:46:31 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     const parent = '____SMARTY_BLOCK_PARENT____'; | 
					
						
							| 
									
										
										
										
											2011-12-20 17:50:15 +00:00
										 |  |  |     /** | 
					
						
							| 
									
										
										
										
											2013-07-27 07:05:26 +00:00
										 |  |  |      * Attribute definition: Overwrites base class. | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @var array | 
					
						
							|  |  |  |      * @see Smarty_Internal_CompileBase | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public $required_attributes = array('name'); | 
					
						
							| 
									
										
										
										
											2012-06-30 15:53:22 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-12-20 17:50:15 +00:00
										 |  |  |     /** | 
					
						
							| 
									
										
										
										
											2013-07-27 07:05:26 +00:00
										 |  |  |      * Attribute definition: Overwrites base class. | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @var array | 
					
						
							|  |  |  |      * @see Smarty_Internal_CompileBase | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2013-08-24 18:46:31 +00:00
										 |  |  |     public $shorttag_order = array('name'); | 
					
						
							| 
									
										
										
										
											2012-06-30 15:53:22 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-07-27 07:05:26 +00:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * Attribute definition: Overwrites base class. | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @var array | 
					
						
							|  |  |  |      * @see Smarty_Internal_CompileBase | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2013-08-24 18:46:31 +00:00
										 |  |  |     public $option_flags = array('hide', 'append', 'prepend', 'nocache'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Attribute definition: Overwrites base class. | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @var array | 
					
						
							|  |  |  |      * @see Smarty_Internal_CompileBase | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public $optional_attributes = array('internal_file', 'internal_uid', 'internal_line'); | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * nested child block names | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @var array | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public static $nested_block_names = array(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * child block source buffer | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @var array | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public static $block_data = array(); | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-07-27 07:05:26 +00:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * Compiles code for the {block} tag | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |      * @param array  $args     array with attributes from parser | 
					
						
							| 
									
										
										
										
											2013-07-27 07:05:26 +00:00
										 |  |  |      * @param object $compiler compiler object | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2013-07-27 07:05:26 +00:00
										 |  |  |      * @return boolean true | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public function compile($args, $compiler) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         // check and get attributes
 | 
					
						
							|  |  |  |         $_attr = $this->getAttributes($compiler, $args); | 
					
						
							| 
									
										
										
										
											2013-08-24 18:46:31 +00:00
										 |  |  |         $_name = trim($_attr['name'], "\"'"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         // check if we process an inheritance child template
 | 
					
						
							|  |  |  |         if ($compiler->inheritance_child) { | 
					
						
							|  |  |  |             array_unshift(self::$nested_block_names, $_name); | 
					
						
							|  |  |  |             // build {block} for child block
 | 
					
						
							|  |  |  |             self::$block_data[$_name]['source'] = | 
					
						
							| 
									
										
										
										
											2014-04-06 18:50:39 +00:00
										 |  |  |                 "{$compiler->smarty->left_delimiter}private_child_block name={$_attr['name']} file='{$compiler->template->source->filepath}' type='{$compiler->template->source->type}' resource='{$compiler->template->template_resource}'" . | 
					
						
							| 
									
										
										
										
											2013-08-24 18:46:31 +00:00
										 |  |  |                 " uid='{$compiler->template->source->uid}' line={$compiler->lex->line}"; | 
					
						
							|  |  |  |             if ($_attr['nocache']) { | 
					
						
							|  |  |  |                 self::$block_data[$_name]['source'] .= ' nocache'; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             self::$block_data[$_name]['source'] .= $compiler->smarty->right_delimiter; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             $save = array($_attr, $compiler->inheritance); | 
					
						
							|  |  |  |             $this->openTag($compiler, 'block', $save); | 
					
						
							|  |  |  |             // set flag for {block} tag
 | 
					
						
							|  |  |  |             $compiler->inheritance = true; | 
					
						
							|  |  |  |             $compiler->lex->yypushstate(Smarty_Internal_Templatelexer::CHILDBLOCK); | 
					
						
							|  |  |  |             $compiler->has_code = false; | 
					
						
							|  |  |  |             return; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         // must merge includes
 | 
					
						
							| 
									
										
										
										
											2013-07-27 07:05:26 +00:00
										 |  |  |         if ($_attr['nocache'] == true) { | 
					
						
							| 
									
										
										
										
											2013-08-24 18:46:31 +00:00
										 |  |  |             $compiler->tag_nocache = true; | 
					
						
							| 
									
										
										
										
											2013-07-27 07:05:26 +00:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2013-08-24 18:46:31 +00:00
										 |  |  |         $save = array($_attr, $compiler->inheritance, $compiler->parser->current_buffer, $compiler->nocache); | 
					
						
							|  |  |  |         $this->openTag($compiler, 'block', $save); | 
					
						
							| 
									
										
										
										
											2013-07-27 07:05:26 +00:00
										 |  |  |         $compiler->inheritance = true; | 
					
						
							| 
									
										
										
										
											2013-08-24 18:46:31 +00:00
										 |  |  |         $compiler->nocache = $compiler->nocache | $compiler->tag_nocache; | 
					
						
							| 
									
										
										
										
											2010-01-11 20:44:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-07-27 07:05:26 +00:00
										 |  |  |         $compiler->parser->current_buffer = new _smarty_template_buffer($compiler->parser); | 
					
						
							|  |  |  |         $compiler->has_code = false; | 
					
						
							| 
									
										
										
										
											2013-07-14 22:15:45 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-07-27 07:05:26 +00:00
										 |  |  |         return true; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2010-11-11 21:34:36 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-07-27 07:05:26 +00:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * Compile saved child block source | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |      * @param object $compiler compiler object | 
					
						
							|  |  |  |      * @param string $_name    optional name of child block | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2013-08-24 18:46:31 +00:00
										 |  |  |      * @return string   compiled code of child block | 
					
						
							| 
									
										
										
										
											2013-07-27 07:05:26 +00:00
										 |  |  |      */ | 
					
						
							|  |  |  |     static function compileChildBlock($compiler, $_name = null) | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2013-08-24 18:46:31 +00:00
										 |  |  |         if ($compiler->inheritance_child) { | 
					
						
							|  |  |  |             $name1 = Smarty_Internal_Compile_Block::$nested_block_names[0]; | 
					
						
							|  |  |  |             if (isset($compiler->template->block_data[$name1])) { | 
					
						
							|  |  |  |                 //  replace inner block name with generic
 | 
					
						
							|  |  |  |                 Smarty_Internal_Compile_Block::$block_data[$name1]['source'] .= $compiler->template->block_data[$name1]['source']; | 
					
						
							|  |  |  |                 Smarty_Internal_Compile_Block::$block_data[$name1]['child'] = true; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             $compiler->lex->yypushstate(Smarty_Internal_Templatelexer::CHILDBLOCK); | 
					
						
							|  |  |  |             $compiler->has_code = false; | 
					
						
							|  |  |  |             return; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2013-07-27 07:05:26 +00:00
										 |  |  |         // if called by {$smarty.block.child} we must search the name of enclosing {block}
 | 
					
						
							|  |  |  |         if ($_name == null) { | 
					
						
							|  |  |  |             $stack_count = count($compiler->_tag_stack); | 
					
						
							|  |  |  |             while (--$stack_count >= 0) { | 
					
						
							|  |  |  |                 if ($compiler->_tag_stack[$stack_count][0] == 'block') { | 
					
						
							| 
									
										
										
										
											2013-08-24 18:46:31 +00:00
										 |  |  |                     $_name = trim($compiler->_tag_stack[$stack_count][1][0]['name'], "\"'"); | 
					
						
							| 
									
										
										
										
											2013-07-27 07:05:26 +00:00
										 |  |  |                     break; | 
					
						
							|  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2013-07-26 13:50:44 +00:00
										 |  |  |             } | 
					
						
							| 
									
										
										
										
											2013-07-27 07:05:26 +00:00
										 |  |  |         } | 
					
						
							|  |  |  |         if ($_name == null) { | 
					
						
							| 
									
										
										
										
											2013-08-24 18:46:31 +00:00
										 |  |  |             $compiler->trigger_template_error(' tag {$smarty.block.child} used outside {block} tags ', $compiler->lex->taglineno); | 
					
						
							| 
									
										
										
										
											2013-07-27 07:05:26 +00:00
										 |  |  |         } | 
					
						
							|  |  |  |         // undefined child?
 | 
					
						
							|  |  |  |         if (!isset($compiler->template->block_data[$_name]['source'])) { | 
					
						
							| 
									
										
										
										
											2013-08-24 18:46:31 +00:00
										 |  |  |             $compiler->popTrace(); | 
					
						
							| 
									
										
										
										
											2013-07-27 07:05:26 +00:00
										 |  |  |             return ''; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2013-08-24 18:46:31 +00:00
										 |  |  |         // flag that child is already compile by {$smarty.block.child} inclusion
 | 
					
						
							|  |  |  |         $compiler->template->block_data[$_name]['compiled'] = true; | 
					
						
							| 
									
										
										
										
											2013-07-27 07:05:26 +00:00
										 |  |  |         $_tpl = new Smarty_Internal_template('string:' . $compiler->template->block_data[$_name]['source'], $compiler->smarty, $compiler->template, $compiler->template->cache_id, | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |                                              $compiler->template->compile_id, $compiler->template->caching, $compiler->template->cache_lifetime); | 
					
						
							| 
									
										
										
										
											2013-08-24 18:46:31 +00:00
										 |  |  |         if ($compiler->smarty->debugging) { | 
					
						
							|  |  |  |             Smarty_Internal_Debug::ignore($_tpl); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2013-12-15 15:19:01 +00:00
										 |  |  |         $_tpl->tpl_vars = $compiler->template->tpl_vars; | 
					
						
							| 
									
										
										
										
											2013-07-27 07:05:26 +00:00
										 |  |  |         $_tpl->variable_filters = $compiler->template->variable_filters; | 
					
						
							|  |  |  |         $_tpl->properties['nocache_hash'] = $compiler->template->properties['nocache_hash']; | 
					
						
							|  |  |  |         $_tpl->allow_relative_path = true; | 
					
						
							| 
									
										
										
										
											2013-08-24 18:46:31 +00:00
										 |  |  |         $_tpl->compiler->inheritance = true; | 
					
						
							| 
									
										
										
										
											2013-07-27 07:05:26 +00:00
										 |  |  |         $_tpl->compiler->suppressHeader = true; | 
					
						
							|  |  |  |         $_tpl->compiler->suppressFilter = true; | 
					
						
							|  |  |  |         $_tpl->compiler->suppressTemplatePropertyHeader = true; | 
					
						
							|  |  |  |         $_tpl->compiler->suppressMergedTemplates = true; | 
					
						
							| 
									
										
										
										
											2013-08-24 18:46:31 +00:00
										 |  |  |         $nocache = $compiler->nocache || $compiler->tag_nocache; | 
					
						
							|  |  |  |         if (strpos($compiler->template->block_data[$_name]['source'], self::parent) !== false) { | 
					
						
							|  |  |  |             $_output = str_replace(self::parent, $compiler->parser->current_buffer->to_smarty_php(), $_tpl->compiler->compileTemplate($_tpl, $nocache)); | 
					
						
							| 
									
										
										
										
											2013-07-27 07:05:26 +00:00
										 |  |  |         } elseif ($compiler->template->block_data[$_name]['mode'] == 'prepend') { | 
					
						
							| 
									
										
										
										
											2013-08-24 18:46:31 +00:00
										 |  |  |             $_output = $_tpl->compiler->compileTemplate($_tpl, $nocache) . $compiler->parser->current_buffer->to_smarty_php(); | 
					
						
							| 
									
										
										
										
											2013-07-27 07:05:26 +00:00
										 |  |  |         } elseif ($compiler->template->block_data[$_name]['mode'] == 'append') { | 
					
						
							| 
									
										
										
										
											2013-08-24 18:46:31 +00:00
										 |  |  |             $_output = $compiler->parser->current_buffer->to_smarty_php() . $_tpl->compiler->compileTemplate($_tpl, $nocache); | 
					
						
							| 
									
										
										
										
											2013-07-27 07:05:26 +00:00
										 |  |  |         } elseif (!empty($compiler->template->block_data[$_name])) { | 
					
						
							| 
									
										
										
										
											2013-08-24 18:46:31 +00:00
										 |  |  |             $_output = $_tpl->compiler->compileTemplate($_tpl, $nocache); | 
					
						
							| 
									
										
										
										
											2013-07-27 07:05:26 +00:00
										 |  |  |         } | 
					
						
							|  |  |  |         $compiler->template->properties['file_dependency'] = array_merge($compiler->template->properties['file_dependency'], $_tpl->properties['file_dependency']); | 
					
						
							|  |  |  |         $compiler->template->properties['function'] = array_merge($compiler->template->properties['function'], $_tpl->properties['function']); | 
					
						
							|  |  |  |         $compiler->merged_templates = array_merge($compiler->merged_templates, $_tpl->compiler->merged_templates); | 
					
						
							|  |  |  |         $compiler->template->variable_filters = $_tpl->variable_filters; | 
					
						
							|  |  |  |         if ($_tpl->has_nocache_code) { | 
					
						
							|  |  |  |             $compiler->template->has_nocache_code = true; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         foreach ($_tpl->required_plugins as $key => $tmp1) { | 
					
						
							|  |  |  |             if ($compiler->nocache && $compiler->template->caching) { | 
					
						
							|  |  |  |                 $code = 'nocache'; | 
					
						
							|  |  |  |             } else { | 
					
						
							|  |  |  |                 $code = $key; | 
					
						
							| 
									
										
										
										
											2013-07-26 13:50:44 +00:00
										 |  |  |             } | 
					
						
							| 
									
										
										
										
											2013-07-27 07:05:26 +00:00
										 |  |  |             foreach ($tmp1 as $name => $tmp) { | 
					
						
							|  |  |  |                 foreach ($tmp as $type => $data) { | 
					
						
							|  |  |  |                     $compiler->template->required_plugins[$code][$name][$type] = $data; | 
					
						
							| 
									
										
										
										
											2011-12-20 17:50:15 +00:00
										 |  |  |                 } | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2013-07-27 07:05:26 +00:00
										 |  |  |         unset($_tpl); | 
					
						
							| 
									
										
										
										
											2013-08-24 18:46:31 +00:00
										 |  |  |         $compiler->has_code = true; | 
					
						
							| 
									
										
										
										
											2013-07-27 07:05:26 +00:00
										 |  |  |         return $_output; | 
					
						
							| 
									
										
										
										
											2011-12-20 17:50:15 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2010-11-11 21:34:36 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-24 18:46:31 +00:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * Compile $smarty.block.parent | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |      * @param object $compiler compiler object | 
					
						
							|  |  |  |      * @param string $_name    optional name of child block | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @return string   compiled code of child block | 
					
						
							| 
									
										
										
										
											2013-08-24 18:46:31 +00:00
										 |  |  |      */ | 
					
						
							|  |  |  |     static function compileParentBlock($compiler, $_name = null) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         // if called by {$smarty.block.parent} we must search the name of enclosing {block}
 | 
					
						
							|  |  |  |         if ($_name == null) { | 
					
						
							|  |  |  |             $stack_count = count($compiler->_tag_stack); | 
					
						
							|  |  |  |             while (--$stack_count >= 0) { | 
					
						
							|  |  |  |                 if ($compiler->_tag_stack[$stack_count][0] == 'block') { | 
					
						
							|  |  |  |                     $_name = trim($compiler->_tag_stack[$stack_count][1][0]['name'], "\"'"); | 
					
						
							|  |  |  |                     break; | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         if ($_name == null) { | 
					
						
							|  |  |  |             $compiler->trigger_template_error(' tag {$smarty.block.parent} used outside {block} tags ', $compiler->lex->taglineno); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         if (empty(Smarty_Internal_Compile_Block::$nested_block_names)) { | 
					
						
							|  |  |  |             $compiler->trigger_template_error(' illegal {$smarty.block.parent} in parent template ', $compiler->lex->taglineno); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         Smarty_Internal_Compile_Block::$block_data[Smarty_Internal_Compile_Block::$nested_block_names[0]]['source'] .= Smarty_Internal_Compile_Block::parent; | 
					
						
							|  |  |  |         $compiler->lex->yypushstate(Smarty_Internal_Templatelexer::CHILDBLOCK); | 
					
						
							|  |  |  |         $compiler->has_code = false; | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Process block source | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |      * @param        $compiler | 
					
						
							|  |  |  |      * @param string $source source text | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2013-08-24 18:46:31 +00:00
										 |  |  |      */ | 
					
						
							|  |  |  |     static function blockSource($compiler, $source) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         Smarty_Internal_Compile_Block::$block_data[Smarty_Internal_Compile_Block::$nested_block_names[0]]['source'] .= $source; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2013-07-27 07:05:26 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * Smarty Internal Plugin Compile BlockClose Class | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |  * @package    Smarty | 
					
						
							| 
									
										
										
										
											2013-07-27 07:05:26 +00:00
										 |  |  |  * @subpackage Compiler | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | class Smarty_Internal_Compile_Blockclose extends Smarty_Internal_CompileBase | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2011-12-20 17:50:15 +00:00
										 |  |  |     /** | 
					
						
							| 
									
										
										
										
											2013-07-27 07:05:26 +00:00
										 |  |  |      * Compiles code for the {/block} tag | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |      * @param array  $args     array with attributes from parser | 
					
						
							| 
									
										
										
										
											2013-07-27 07:05:26 +00:00
										 |  |  |      * @param object $compiler compiler object | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2013-07-27 07:05:26 +00:00
										 |  |  |      * @return string compiled code | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public function compile($args, $compiler) | 
					
						
							| 
									
										
										
										
											2013-07-14 22:15:45 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2013-07-27 07:05:26 +00:00
										 |  |  |         $compiler->has_code = true; | 
					
						
							|  |  |  |         // check and get attributes
 | 
					
						
							|  |  |  |         $_attr = $this->getAttributes($compiler, $args); | 
					
						
							|  |  |  |         $saved_data = $this->closeTag($compiler, array('block')); | 
					
						
							|  |  |  |         $_name = trim($saved_data[0]['name'], "\"'"); | 
					
						
							| 
									
										
										
										
											2013-08-24 18:46:31 +00:00
										 |  |  |         // reset flag for {block} tag
 | 
					
						
							|  |  |  |         $compiler->inheritance = $saved_data[1]; | 
					
						
							|  |  |  |         // check if we process an inheritance child template
 | 
					
						
							|  |  |  |         if ($compiler->inheritance_child) { | 
					
						
							|  |  |  |             $name1 = Smarty_Internal_Compile_Block::$nested_block_names[0]; | 
					
						
							|  |  |  |             Smarty_Internal_Compile_Block::$block_data[$name1]['source'] .= "{$compiler->smarty->left_delimiter}/private_child_block{$compiler->smarty->right_delimiter}"; | 
					
						
							|  |  |  |             array_shift(Smarty_Internal_Compile_Block::$nested_block_names); | 
					
						
							|  |  |  |             if (!empty(Smarty_Internal_Compile_Block::$nested_block_names)) { | 
					
						
							|  |  |  |                 $name2 = Smarty_Internal_Compile_Block::$nested_block_names[0]; | 
					
						
							|  |  |  |                 if (isset($compiler->template->block_data[$name1]) || !$saved_data[0]['hide']) { | 
					
						
							|  |  |  |                     if (isset(Smarty_Internal_Compile_Block::$block_data[$name1]['child']) || !isset($compiler->template->block_data[$name1])) { | 
					
						
							|  |  |  |                         Smarty_Internal_Compile_Block::$block_data[$name2]['source'] .= Smarty_Internal_Compile_Block::$block_data[$name1]['source']; | 
					
						
							|  |  |  |                     } else { | 
					
						
							|  |  |  |                         if ($compiler->template->block_data[$name1]['mode'] == 'append') { | 
					
						
							|  |  |  |                             Smarty_Internal_Compile_Block::$block_data[$name2]['source'] .= Smarty_Internal_Compile_Block::$block_data[$name1]['source'] . $compiler->template->block_data[$name1]['source']; | 
					
						
							|  |  |  |                         } elseif ($compiler->template->block_data[$name1]['mode'] == 'prepend') { | 
					
						
							|  |  |  |                             Smarty_Internal_Compile_Block::$block_data[$name2]['source'] .= $compiler->template->block_data[$name1]['source'] . Smarty_Internal_Compile_Block::$block_data[$name1]['source']; | 
					
						
							|  |  |  |                         } else { | 
					
						
							|  |  |  |                             Smarty_Internal_Compile_Block::$block_data[$name2]['source'] .= $compiler->template->block_data[$name1]['source']; | 
					
						
							|  |  |  |                         } | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 unset(Smarty_Internal_Compile_Block::$block_data[$name1]); | 
					
						
							|  |  |  |                 $compiler->lex->yypushstate(Smarty_Internal_Templatelexer::CHILDBLOCK); | 
					
						
							|  |  |  |             } else { | 
					
						
							|  |  |  |                 if (isset($compiler->template->block_data[$name1]) || !$saved_data[0]['hide']) { | 
					
						
							|  |  |  |                     if (isset($compiler->template->block_data[$name1]) && !isset(Smarty_Internal_Compile_Block::$block_data[$name1]['child'])) { | 
					
						
							|  |  |  |                         if (strpos($compiler->template->block_data[$name1]['source'], Smarty_Internal_Compile_Block::parent) !== false) { | 
					
						
							|  |  |  |                             $compiler->template->block_data[$name1]['source'] = | 
					
						
							|  |  |  |                                 str_replace(Smarty_Internal_Compile_Block::parent, Smarty_Internal_Compile_Block::$block_data[$name1]['source'], $compiler->template->block_data[$name1]['source']); | 
					
						
							|  |  |  |                         } elseif ($compiler->template->block_data[$name1]['mode'] == 'prepend') { | 
					
						
							|  |  |  |                             $compiler->template->block_data[$name1]['source'] .= Smarty_Internal_Compile_Block::$block_data[$name1]['source']; | 
					
						
							|  |  |  |                         } elseif ($compiler->template->block_data[$name1]['mode'] == 'append') { | 
					
						
							|  |  |  |                             $compiler->template->block_data[$name1]['source'] = Smarty_Internal_Compile_Block::$block_data[$name1]['source'] . $compiler->template->block_data[$name1]['source']; | 
					
						
							|  |  |  |                         } | 
					
						
							|  |  |  |                     } else { | 
					
						
							|  |  |  |                         $compiler->template->block_data[$name1]['source'] = Smarty_Internal_Compile_Block::$block_data[$name1]['source']; | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  |                     $compiler->template->block_data[$name1]['mode'] = 'replace'; | 
					
						
							|  |  |  |                     if ($saved_data[0]['append']) { | 
					
						
							|  |  |  |                         $compiler->template->block_data[$name1]['mode'] = 'append'; | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  |                     if ($saved_data[0]['prepend']) { | 
					
						
							|  |  |  |                         $compiler->template->block_data[$name1]['mode'] = 'prepend'; | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 unset(Smarty_Internal_Compile_Block::$block_data[$name1]); | 
					
						
							|  |  |  |                 $compiler->lex->yypushstate(Smarty_Internal_Templatelexer::CHILDBODY); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             $compiler->has_code = false; | 
					
						
							|  |  |  |             return; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2013-07-27 07:05:26 +00:00
										 |  |  |         if (isset($compiler->template->block_data[$_name]) && !isset($compiler->template->block_data[$_name]['compiled'])) { | 
					
						
							|  |  |  |             $_output = Smarty_Internal_Compile_Block::compileChildBlock($compiler, $_name); | 
					
						
							|  |  |  |         } else { | 
					
						
							| 
									
										
										
										
											2013-08-24 18:46:31 +00:00
										 |  |  |             if ($saved_data[0]['hide'] && !isset($compiler->template->block_data[$_name]['source'])) { | 
					
						
							| 
									
										
										
										
											2013-07-27 07:05:26 +00:00
										 |  |  |                 $_output = ''; | 
					
						
							| 
									
										
										
										
											2011-12-20 17:50:15 +00:00
										 |  |  |             } else { | 
					
						
							| 
									
										
										
										
											2013-07-27 07:05:26 +00:00
										 |  |  |                 $_output = $compiler->parser->current_buffer->to_smarty_php(); | 
					
						
							| 
									
										
										
										
											2011-12-20 17:50:15 +00:00
										 |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2013-10-29 00:40:14 +00:00
										 |  |  |         unset($compiler->template->block_data[$_name]['compiled']); | 
					
						
							| 
									
										
										
										
											2013-07-27 07:05:26 +00:00
										 |  |  |         // reset flags
 | 
					
						
							| 
									
										
										
										
											2013-08-24 18:46:31 +00:00
										 |  |  |         $compiler->parser->current_buffer = $saved_data[2]; | 
					
						
							|  |  |  |         if ($compiler->nocache) { | 
					
						
							|  |  |  |             $compiler->tag_nocache = true; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         $compiler->nocache = $saved_data[3]; | 
					
						
							| 
									
										
										
										
											2013-07-27 07:05:26 +00:00
										 |  |  |         // $_output content has already nocache code processed
 | 
					
						
							|  |  |  |         $compiler->suppressNocacheProcessing = true; | 
					
						
							| 
									
										
										
										
											2013-07-14 22:15:45 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-07-27 07:05:26 +00:00
										 |  |  |         return $_output; | 
					
						
							| 
									
										
										
										
											2011-12-20 17:50:15 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2013-08-24 18:46:31 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * Smarty Internal Plugin Compile Child Block Class | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |  * @package    Smarty | 
					
						
							| 
									
										
										
										
											2013-08-24 18:46:31 +00:00
										 |  |  |  * @subpackage Compiler | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | class Smarty_Internal_Compile_Private_Child_Block extends Smarty_Internal_CompileBase | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Attribute definition: Overwrites base class. | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @var array | 
					
						
							|  |  |  |      * @see Smarty_Internal_CompileBase | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2014-04-06 18:50:39 +00:00
										 |  |  |     public $required_attributes = array('name', 'file', 'uid', 'line', 'type', 'resource'); | 
					
						
							| 
									
										
										
										
											2013-08-24 18:46:31 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Compiles code for the {private_child_block} tag | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |      * @param array  $args     array with attributes from parser | 
					
						
							| 
									
										
										
										
											2013-08-24 18:46:31 +00:00
										 |  |  |      * @param object $compiler compiler object | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2013-08-24 18:46:31 +00:00
										 |  |  |      * @return boolean true | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public function compile($args, $compiler) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         // check and get attributes
 | 
					
						
							|  |  |  |         $_attr = $this->getAttributes($compiler, $args); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-03-08 23:03:08 +00:00
										 |  |  |         // update template with original template resource of {block}
 | 
					
						
							| 
									
										
										
										
											2014-04-06 18:50:39 +00:00
										 |  |  |         if (trim($_attr['type'], "'") == 'file') { | 
					
						
							|  |  |  |             $compiler->template->template_resource = realpath(trim($_attr['file'], "'")); | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             $compiler->template->template_resource = trim($_attr['resource'], "'"); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2014-03-08 23:03:08 +00:00
										 |  |  |         // source object
 | 
					
						
							|  |  |  |         unset ($compiler->template->source); | 
					
						
							|  |  |  |         $exists = $compiler->template->source->exists; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-24 18:46:31 +00:00
										 |  |  |         // must merge includes
 | 
					
						
							|  |  |  |         if ($_attr['nocache'] == true) { | 
					
						
							|  |  |  |             $compiler->tag_nocache = true; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         $save = array($_attr, $compiler->nocache); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         // set trace back to child block
 | 
					
						
							|  |  |  |         $compiler->pushTrace(trim($_attr['file'], "\"'"), trim($_attr['uid'], "\"'"), $_attr['line'] - $compiler->lex->line); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         $this->openTag($compiler, 'private_child_block', $save); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         $compiler->nocache = $compiler->nocache | $compiler->tag_nocache; | 
					
						
							|  |  |  |         $compiler->has_code = false; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return true; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2013-07-27 07:05:26 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-24 18:46:31 +00:00
										 |  |  | /** | 
					
						
							|  |  |  |  * Smarty Internal Plugin Compile Child Block Close Class | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |  * @package    Smarty | 
					
						
							| 
									
										
										
										
											2013-08-24 18:46:31 +00:00
										 |  |  |  * @subpackage Compiler | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | class Smarty_Internal_Compile_Private_Child_Blockclose extends Smarty_Internal_CompileBase | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Compiles code for the {/private_child_block} tag | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |      * @param array  $args     array with attributes from parser | 
					
						
							| 
									
										
										
										
											2013-08-24 18:46:31 +00:00
										 |  |  |      * @param object $compiler compiler object | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2013-08-24 18:46:31 +00:00
										 |  |  |      * @return boolean true | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public function compile($args, $compiler) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         // check and get attributes
 | 
					
						
							|  |  |  |         $_attr = $this->getAttributes($compiler, $args); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         $saved_data = $this->closeTag($compiler, array('private_child_block')); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         // end of child block
 | 
					
						
							|  |  |  |         $compiler->popTrace(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         $compiler->nocache = $saved_data[1]; | 
					
						
							|  |  |  |         $compiler->has_code = false; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return true; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2013-07-27 07:05:26 +00:00
										 |  |  | } |