К новейшей редакции | Содержимое файла | Последнее изменение | Открыть журнал | RSS
Редакция | Автор | № строки | Строка |
---|---|---|---|
304 | alex-w | 1 | <?php |
2 | /** |
||
3 | * Smarty Internal Plugin Compile Block Close |
||
4 | * |
||
5 | * Compiles the {/block} tag |
||
6 | * |
||
7 | * @package Smarty |
||
8 | * @subpackage Compiler |
||
9 | * @author Uwe Tews |
||
10 | */ |
||
11 | /** |
||
12 | * Smarty Internal Plugin Compile BlockClose Class |
||
13 | */ |
||
14 | class Smarty_Internal_Compile_BlockClose extends Smarty_Internal_CompileBase { |
||
15 | /** |
||
16 | * Compiles code for the {/block} tag |
||
17 | * |
||
18 | * @param array $args array with attributes from parser |
||
19 | * @param object $compiler compiler object |
||
20 | * @return string compiled code |
||
21 | */ |
||
22 | public function compile($args, $compiler) |
||
23 | { |
||
24 | $this->compiler = $compiler; |
||
25 | $this->compiler->has_code = true; |
||
26 | // turn off block code extraction |
||
27 | $compiler->template->extract_code = false; |
||
28 | // check and get attributes |
||
29 | $this->optional_attributes = array('name'); |
||
30 | $_attr = $this->_get_attributes($args); |
||
31 | $saved_data = $this->_close_tag(array('block')); |
||
32 | // if name does match to opening tag |
||
33 | if (isset($_attr['name']) && $saved_data[0]['name'] != $_attr['name']) { |
||
34 | $this->compiler->trigger_template_error('mismatching name attributes "' . $saved_data[0]['name'] . '" and "' . $_attr['name'] . '"'); |
||
35 | } |
||
36 | $_name = trim($saved_data[0]['name'], "\"'"); |
||
37 | if (isset($compiler->template->block_data[$_name])) { |
||
38 | if (strpos($compiler->template->block_data[$_name]['compiled'], '%%%%SMARTY_PARENT%%%%') !== false) { |
||
39 | $_output = str_replace('%%%%SMARTY_PARENT%%%%', $_compiled_content, $compiler->template->block_data[$_name]['compiled']); |
||
40 | } elseif ($compiler->template->block_data[$_name]['mode'] == 'prepend') { |
||
41 | $_output = $compiler->template->block_data[$_name]['compiled'] . $compiler->template->extracted_compiled_code; |
||
42 | } elseif ($compiler->template->block_data[$_name]['mode'] == 'append') { |
||
43 | $_output = $compiler->template->extracted_compiled_code . $compiler->template->block_data[$_name]['compiled']; |
||
44 | } elseif (!empty($compiler->template->block_data[$_name])) { |
||
45 | $_output = $compiler->template->block_data[$_name]['compiled']; |
||
46 | } |
||
47 | } else { |
||
48 | $_output = $compiler->template->extracted_compiled_code; |
||
49 | } |
||
50 | $compiler->template->extracted_compiled_code = $saved_data[1]; |
||
51 | $compiler->template->extract_code = $saved_data[2]; |
||
52 | return $_output; |
||
53 | } |
||
54 | } |
||
55 | |||
56 | ?> |