init
[garradin.git] / include / libs / template_lite / internal / compile.compile_custom_block.php
1 <?php
2 /**
3 * Template Lite compile custom block - template internal module
4 *
5 * Type: template
6 * Name: compile_custom_block
7 */
8
9 function compile_compile_custom_block($function, $modifiers, $arguments, &$_result, &$object)
10 {
11 if ($function{0} == '/')
12 {
13 $start_tag = false;
14 $function = substr($function, 1);
15 }
16 else
17 {
18 $start_tag = true;
19 }
20
21 if ($function = $object->_plugin_exists($function, "block"))
22 {
23 if ($start_tag)
24 {
25 $_args = $object->_parse_arguments($arguments);
26 foreach($_args as $key => $value)
27 {
28 if (is_bool($value))
29 {
30 $value = $value ? 'true' : 'false';
31 }
32 elseif (is_null($value))
33 {
34 $value = 'null';
35 }
36 elseif ($value[0] != '$')
37 {
38 $value = '"'.addslashes($value).'"';
39 }
40
41 $_args[$key] = "'$key' => $value";
42 }
43 $_result = "<?php \$this->_tag_stack[] = array('$function', array(".implode(',', (array)$_args).")); ";
44 $_result .= $function . '(array(' . implode(',', (array)$_args) .'), null, $this); ';
45 $_result .= 'ob_start(); ?>';
46 }
47 else
48 {
49 $_result .= '<?php $this->_block_content = ob_get_contents(); ob_end_clean(); ';
50 $_result .= '$this->_block_content = ' . $function . '($this->_tag_stack[count($this->_tag_stack) - 1][1], $this->_block_content, $this); ';
51 if (!empty($modifiers))
52 {
53 $_result .= '$this->_block_content = ' . $object->_parse_modifier('$this->_block_content', $modifiers) . '; ';
54 }
55 $_result .= 'echo $this->_block_content; array_pop($this->_tag_stack); ?>';
56 }
57 return true;
58 }
59 else
60 {
61 return false;
62 }
63 }
64
65 ?>