| 
									
										
										
										
											2009-11-06 14:35:00 +00:00
										 |  |  | <?php | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  | * Smarty Internal Plugin Compile Block | 
					
						
							|  |  |  | *  | 
					
						
							|  |  |  | * Compiles the {block}{/block} tags | 
					
						
							|  |  |  | *  | 
					
						
							|  |  |  | * @package Smarty | 
					
						
							|  |  |  | * @subpackage Compiler | 
					
						
							|  |  |  | * @author Uwe Tews  | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  | * Smarty Internal Plugin Compile Block Class | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | class Smarty_Internal_Compile_Block extends Smarty_Internal_CompileBase { | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |     * Compiles code for the {block} tag | 
					
						
							|  |  |  |     *  | 
					
						
							|  |  |  |     * @param array $args array with attributes from parser | 
					
						
							|  |  |  |     * @param object $compiler compiler object | 
					
						
							|  |  |  |     * @return boolean true | 
					
						
							|  |  |  |     */ | 
					
						
							|  |  |  |     public function compile($args, $compiler) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         $this->compiler = $compiler; | 
					
						
							|  |  |  |         $this->required_attributes = array('name'); | 
					
						
							| 
									
										
										
										
											2010-01-11 20:44:01 +00:00
										 |  |  |         $this->optional_attributes = array('assign','nocache');  | 
					
						
							| 
									
										
										
										
											2009-11-06 14:35:00 +00:00
										 |  |  |         // check and get attributes
 | 
					
						
							|  |  |  |         $_attr = $this->_get_attributes($args); | 
					
						
							| 
									
										
										
										
											2010-01-11 20:44:01 +00:00
										 |  |  |         $save = array($_attr, $compiler->template->extracted_compiled_code, $compiler->template->extract_code, $this->compiler->nocache); | 
					
						
							| 
									
										
										
										
											2009-11-06 14:35:00 +00:00
										 |  |  |         $this->_open_tag('block', $save); | 
					
						
							| 
									
										
										
										
											2010-01-11 20:44:01 +00:00
										 |  |  |         if (isset($_attr['nocache'])) { | 
					
						
							|  |  |  |             if ($_attr['nocache'] == 'true') { | 
					
						
							|  |  |  |                 $compiler->nocache = true; | 
					
						
							|  |  |  |             }  | 
					
						
							|  |  |  |         }  | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-06 14:35:00 +00:00
										 |  |  |         $compiler->template->extract_code = true; | 
					
						
							|  |  |  |         $compiler->template->extracted_compiled_code = ''; | 
					
						
							| 
									
										
										
										
											2010-01-09 19:23:35 +00:00
										 |  |  |         $compiler->has_code = false; | 
					
						
							| 
									
										
										
										
											2009-11-06 14:35:00 +00:00
										 |  |  |         return true; | 
					
						
							|  |  |  |     }  | 
					
						
							|  |  |  | }  | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  | * Smarty Internal Plugin Compile BlockClose Class | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | class Smarty_Internal_Compile_Blockclose extends Smarty_Internal_CompileBase { | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |     * Compiles code for the {/block} 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->smarty = $compiler->smarty; | 
					
						
							|  |  |  |         $this->compiler->has_code = true;  | 
					
						
							|  |  |  |         // turn off block code extraction
 | 
					
						
							|  |  |  |         $compiler->template->extract_code = false;  | 
					
						
							|  |  |  |         // check and get attributes
 | 
					
						
							|  |  |  |         $this->optional_attributes = array('name'); | 
					
						
							|  |  |  |         $_attr = $this->_get_attributes($args); | 
					
						
							|  |  |  |         $saved_data = $this->_close_tag(array('block'));  | 
					
						
							|  |  |  |         // if name does match to opening tag
 | 
					
						
							|  |  |  |         if (isset($_attr['name']) && $saved_data[0]['name'] != $_attr['name']) { | 
					
						
							|  |  |  |             $this->compiler->trigger_template_error('mismatching name attributes "' . $saved_data[0]['name'] . '" and "' . $_attr['name'] . '"'); | 
					
						
							|  |  |  |         }  | 
					
						
							|  |  |  |         $_name = trim($saved_data[0]['name'], "\"'"); | 
					
						
							|  |  |  |         if (isset($this->smarty->block_data[$_name])) { | 
					
						
							| 
									
										
										
										
											2009-12-03 19:49:17 +00:00
										 |  |  |             $_tpl = $this->smarty->createTemplate('string:' . $this->smarty->block_data[$_name]['source'], null, null, $compiler->template); | 
					
						
							| 
									
										
										
										
											2010-01-07 19:33:18 +00:00
										 |  |  |             $_tpl->properties['nocache_hash'] = $compiler->template->properties['nocache_hash']; | 
					
						
							| 
									
										
										
										
											2009-12-03 19:49:17 +00:00
										 |  |  |             $_tpl->template_filepath = $this->smarty->block_data[$_name]['file']; | 
					
						
							| 
									
										
										
										
											2010-01-09 19:23:35 +00:00
										 |  |  |             if ($compiler->nocache) { | 
					
						
							|  |  |  |                 $_tpl->forceNocache = 2; | 
					
						
							|  |  |  |             } else { | 
					
						
							|  |  |  |                 $_tpl->forceNocache = 1; | 
					
						
							|  |  |  |             }  | 
					
						
							| 
									
										
										
										
											2009-12-10 17:23:32 +00:00
										 |  |  |             $_tpl->suppressHeader = true; | 
					
						
							|  |  |  |             $_tpl->suppressFileDependency = true; | 
					
						
							| 
									
										
										
										
											2009-12-03 19:49:17 +00:00
										 |  |  |             if (strpos($this->smarty->block_data[$_name]['source'], '%%%%SMARTY_PARENT%%%%') !== false) { | 
					
						
							|  |  |  |                 $_output = str_replace('%%%%SMARTY_PARENT%%%%', $compiler->template->extracted_compiled_code, $_tpl->getCompiledTemplate()); | 
					
						
							| 
									
										
										
										
											2009-11-06 14:35:00 +00:00
										 |  |  |             } elseif ($this->smarty->block_data[$_name]['mode'] == 'prepend') { | 
					
						
							| 
									
										
										
										
											2009-12-03 19:49:17 +00:00
										 |  |  |                 $_output = $_tpl->getCompiledTemplate() . $compiler->template->extracted_compiled_code; | 
					
						
							| 
									
										
										
										
											2009-11-06 14:35:00 +00:00
										 |  |  |             } elseif ($this->smarty->block_data[$_name]['mode'] == 'append') { | 
					
						
							| 
									
										
										
										
											2009-12-03 19:49:17 +00:00
										 |  |  |                 $_output = $compiler->template->extracted_compiled_code . $_tpl->getCompiledTemplate(); | 
					
						
							| 
									
										
										
										
											2009-11-06 14:35:00 +00:00
										 |  |  |             } elseif (!empty($this->smarty->block_data[$_name])) { | 
					
						
							| 
									
										
										
										
											2009-12-03 19:49:17 +00:00
										 |  |  |                 $_output = $_tpl->getCompiledTemplate(); | 
					
						
							| 
									
										
										
										
											2010-01-07 19:33:18 +00:00
										 |  |  |             }  | 
					
						
							| 
									
										
										
										
											2009-12-28 15:27:13 +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']); | 
					
						
							| 
									
										
										
										
											2010-02-05 17:03:22 +00:00
										 |  |  |             foreach($_tpl->required_plugins as $code => $tmp1) { | 
					
						
							|  |  |  |                 foreach($tmp1 as $name => $tmp) { | 
					
						
							|  |  |  |                     foreach($tmp as $type => $data) { | 
					
						
							|  |  |  |                         $compiler->template->required_plugins[$code][$name][$type] = $data; | 
					
						
							|  |  |  |                     }  | 
					
						
							|  |  |  |                 }  | 
					
						
							|  |  |  |             }  | 
					
						
							| 
									
										
										
										
											2009-12-10 17:23:32 +00:00
										 |  |  |             unset($_tpl); | 
					
						
							| 
									
										
										
										
											2009-11-06 14:35:00 +00:00
										 |  |  |         } else { | 
					
						
							|  |  |  |             $_output = $compiler->template->extracted_compiled_code; | 
					
						
							|  |  |  |         }  | 
					
						
							|  |  |  |         $compiler->template->extracted_compiled_code = $saved_data[1]; | 
					
						
							| 
									
										
										
										
											2010-01-11 20:44:01 +00:00
										 |  |  |         $compiler->template->extract_code = $saved_data[2]; | 
					
						
							|  |  |  |         $compiler->nocache = $saved_data[3];  | 
					
						
							| 
									
										
										
										
											2010-01-09 19:23:35 +00:00
										 |  |  |         // $_output content has already nocache code processed
 | 
					
						
							|  |  |  |         $compiler->suppressNocacheProcessing = true; | 
					
						
							| 
									
										
										
										
											2009-11-06 14:35:00 +00:00
										 |  |  |         return $_output; | 
					
						
							|  |  |  |     }  | 
					
						
							|  |  |  | }  | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ?>
 |