| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  | <?php | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							| 
									
										
										
										
											2010-02-12 01:14:34 +00:00
										 |  |  |  * Smarty Internal Plugin Compile extend | 
					
						
							|  |  |  |  *  | 
					
						
							|  |  |  |  * Compiles the {extends} tag | 
					
						
							|  |  |  |  *  | 
					
						
							|  |  |  |  * @package Smarty | 
					
						
							|  |  |  |  * @subpackage Compiler | 
					
						
							|  |  |  |  * @author Uwe Tews  | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2010-08-17 15:39:51 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  | /** | 
					
						
							| 
									
										
										
										
											2010-02-12 01:14:34 +00:00
										 |  |  |  * Smarty Internal Plugin Compile extend Class | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2009-11-17 19:03:06 +00:00
										 |  |  | class Smarty_Internal_Compile_Extends extends Smarty_Internal_CompileBase { | 
					
						
							| 
									
										
										
										
											2010-11-11 21:34:36 +00:00
										 |  |  | 	// attribute definitions
 | 
					
						
							|  |  |  |     public $required_attributes = array('file'); | 
					
						
							|  |  |  |     public $shorttag_order = array('file'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     /** | 
					
						
							| 
									
										
										
										
											2010-02-12 01:14:34 +00:00
										 |  |  |      * Compiles code for the {extends} tag | 
					
						
							|  |  |  |      *  | 
					
						
							|  |  |  |      * @param array $args array with attributes from parser | 
					
						
							|  |  |  |      * @param object $compiler compiler object | 
					
						
							|  |  |  |      * @return string compiled code | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     public function compile($args, $compiler) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         $this->compiler = $compiler; | 
					
						
							| 
									
										
										
										
											2009-11-30 19:56:17 +00:00
										 |  |  |         $this->smarty = $compiler->smarty; | 
					
						
							| 
									
										
										
										
											2010-01-06 18:48:50 +00:00
										 |  |  |         $this->_rdl = preg_quote($this->smarty->right_delimiter); | 
					
						
							|  |  |  |         $this->_ldl = preg_quote($this->smarty->left_delimiter); | 
					
						
							| 
									
										
										
										
											2010-11-11 21:34:36 +00:00
										 |  |  |         $filepath = $compiler->template->getTemplateFilepath(); | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |         // check and get attributes
 | 
					
						
							|  |  |  |         $_attr = $this->_get_attributes($args); | 
					
						
							| 
									
										
										
										
											2010-11-11 21:34:36 +00:00
										 |  |  |         if ($_attr['nocache'] === true) { | 
					
						
							|  |  |  |         	$this->compiler->trigger_template_error('nocache option not allowed', $this->compiler->lex->taglineno); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-12 05:40:30 +00:00
										 |  |  |         $_smarty_tpl = $compiler->template;  | 
					
						
							| 
									
										
										
										
											2010-08-23 14:40:10 +00:00
										 |  |  |         $include_file = null; | 
					
						
							| 
									
										
										
										
											2010-11-22 22:03:47 +00:00
										 |  |  |         if (strpos($_attr['file'],'$_tmp') !== false) { | 
					
						
							|  |  |  |         	$this->compiler->trigger_template_error('illegal value for file attribute', $this->compiler->lex->taglineno); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2009-04-12 02:30:54 +00:00
										 |  |  |         eval('$include_file = ' . $_attr['file'] . ';');  | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |         // create template object
 | 
					
						
							| 
									
										
										
										
											2009-12-01 22:24:31 +00:00
										 |  |  |         $_template = new $compiler->smarty->template_class($include_file, $this->smarty, $compiler->template);  | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |         // save file dependency
 | 
					
						
							| 
									
										
										
										
											2010-10-13 20:26:12 +00:00
										 |  |  |         if (in_array($_template->resource_type,array('eval','string'))) { | 
					
						
							|  |  |  |         	$template_sha1 = sha1($include_file); | 
					
						
							|  |  |  |     	} else { | 
					
						
							|  |  |  |         	$template_sha1 = sha1($_template->getTemplateFilepath()); | 
					
						
							|  |  |  |     	} | 
					
						
							| 
									
										
										
										
											2010-07-06 20:00:41 +00:00
										 |  |  |         if (isset($compiler->template->properties['file_dependency'][$template_sha1])) { | 
					
						
							|  |  |  |             $this->compiler->trigger_template_error("illegal recursive call of \"{$include_file}\"",$compiler->lex->line-1); | 
					
						
							|  |  |  |         }  | 
					
						
							| 
									
										
										
										
											2010-11-11 21:34:36 +00:00
										 |  |  |         $compiler->template->properties['file_dependency'][$template_sha1] = array($_template->getTemplateFilepath(), $_template->getTemplateTimestamp(),$_template->resource_type); | 
					
						
							| 
									
										
										
										
											2010-11-20 15:24:32 +00:00
										 |  |  |         $_content = substr($compiler->template->template_source,$compiler->lex->counter-1); | 
					
						
							| 
									
										
										
										
											2010-04-30 18:11:34 +00:00
										 |  |  |         if (preg_match_all("!({$this->_ldl}block\s(.+?){$this->_rdl})!", $_content, $s) != | 
					
						
							| 
									
										
										
										
											2010-10-13 15:44:03 +00:00
										 |  |  |                 preg_match_all("!({$this->_ldl}/block{$this->_rdl})!", $_content, $c)) { | 
					
						
							| 
									
										
										
										
											2010-01-06 18:48:50 +00:00
										 |  |  |             $this->compiler->trigger_template_error('unmatched {block} {/block} pairs'); | 
					
						
							| 
									
										
										
										
											2009-07-20 15:38:11 +00:00
										 |  |  |         }  | 
					
						
							| 
									
										
										
										
											2010-10-13 15:44:03 +00:00
										 |  |  |         preg_match_all("!{$this->_ldl}block\s(.+?){$this->_rdl}|{$this->_ldl}/block{$this->_rdl}!", $_content, $_result, PREG_OFFSET_CAPTURE); | 
					
						
							| 
									
										
										
										
											2010-02-12 01:14:34 +00:00
										 |  |  |         $_result_count = count($_result[0]); | 
					
						
							| 
									
										
										
										
											2010-02-12 15:56:17 +00:00
										 |  |  |         $_start = 0; | 
					
						
							|  |  |  |         while ($_start < $_result_count) { | 
					
						
							|  |  |  |             $_end = 0; | 
					
						
							|  |  |  |             $_level = 1; | 
					
						
							|  |  |  |             while ($_level != 0) { | 
					
						
							|  |  |  |                 $_end++; | 
					
						
							|  |  |  |                 if (!strpos($_result[0][$_start + $_end][0], '/')) { | 
					
						
							|  |  |  |                     $_level++; | 
					
						
							|  |  |  |                 } else { | 
					
						
							|  |  |  |                     $_level--; | 
					
						
							|  |  |  |                 }  | 
					
						
							| 
									
										
										
										
											2010-02-12 01:14:34 +00:00
										 |  |  |             }  | 
					
						
							| 
									
										
										
										
											2010-02-12 15:56:17 +00:00
										 |  |  |             $_block_content = str_replace($this->smarty->left_delimiter . '$smarty.block.parent' . $this->smarty->right_delimiter, '%%%%SMARTY_PARENT%%%%', | 
					
						
							|  |  |  |                 substr($_content, $_result[0][$_start][1] + strlen($_result[0][$_start][0]), $_result[0][$_start + $_end][1] - $_result[0][$_start][1] - + strlen($_result[0][$_start][0]))); | 
					
						
							| 
									
										
										
										
											2010-11-11 21:34:36 +00:00
										 |  |  |             Smarty_Internal_Compile_Block::saveBlockData($_block_content, $_result[0][$_start][0], $compiler->template, $filepath); | 
					
						
							| 
									
										
										
										
											2010-02-12 15:56:17 +00:00
										 |  |  |             $_start = $_start + $_end + 1; | 
					
						
							| 
									
										
										
										
											2009-09-10 23:08:06 +00:00
										 |  |  |         }  | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |         $compiler->template->template_source = $_template->getTemplateSource(); | 
					
						
							| 
									
										
										
										
											2009-12-03 19:49:17 +00:00
										 |  |  |         $compiler->template->template_filepath = $_template->getTemplateFilepath(); | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |         $compiler->abort_and_recompile = true; | 
					
						
							| 
									
										
										
										
											2010-07-30 13:09:52 +00:00
										 |  |  |         return ''; | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     }  | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | }  | 
					
						
							| 
									
										
										
										
											2010-02-12 01:14:34 +00:00
										 |  |  | ?>
 |