@@ 28-73 (lines=46) @@ | ||
25 | * This software is provided 'as-is', without any express or implied warranty. |
|
26 | * In no event will the authors be held liable for any damages arising from the use of this software. |
|
27 | */ |
|
28 | class PluginForeachelse extends BlockPlugin implements ICompilableBlock |
|
29 | { |
|
30 | public function init() |
|
31 | { |
|
32 | } |
|
33 | ||
34 | /** |
|
35 | * @param Compiler $compiler |
|
36 | * @param array $params |
|
37 | * @param string $prepend |
|
38 | * @param string $append |
|
39 | * @param string $type |
|
40 | * |
|
41 | * @return string |
|
42 | */ |
|
43 | public static function preProcessing(Compiler $compiler, array $params, $prepend, $append, $type) |
|
44 | { |
|
45 | $with = &$compiler->findBlock('foreach', true); |
|
46 | ||
47 | $params['initialized'] = true; |
|
48 | $compiler->injectBlock($type, $params); |
|
49 | ||
50 | return ''; |
|
51 | } |
|
52 | ||
53 | /** |
|
54 | * @param Compiler $compiler |
|
55 | * @param array $params |
|
56 | * @param string $prepend |
|
57 | * @param string $append |
|
58 | * @param string $content |
|
59 | * |
|
60 | * @return string |
|
61 | */ |
|
62 | public static function postProcessing(Compiler $compiler, array $params, $prepend, $append, $content) |
|
63 | { |
|
64 | if (!isset($params['initialized'])) { |
|
65 | return ''; |
|
66 | } |
|
67 | ||
68 | $block = &$compiler->getCurrentBlock(); |
|
69 | $block['params']['hasElse'] = Compiler::PHP_OPEN . "else {\n" . Compiler::PHP_CLOSE . $content . Compiler::PHP_OPEN . "\n}" . Compiler::PHP_CLOSE; |
|
70 | ||
71 | return ''; |
|
72 | } |
|
73 | } |
|
74 |
@@ 28-73 (lines=46) @@ | ||
25 | * This software is provided 'as-is', without any express or implied warranty. |
|
26 | * In no event will the authors be held liable for any damages arising from the use of this software. |
|
27 | */ |
|
28 | class PluginForelse extends BlockPlugin implements ICompilableBlock |
|
29 | { |
|
30 | public function init() |
|
31 | { |
|
32 | } |
|
33 | ||
34 | /** |
|
35 | * @param Compiler $compiler |
|
36 | * @param array $params |
|
37 | * @param string $prepend |
|
38 | * @param string $append |
|
39 | * @param string $type |
|
40 | * |
|
41 | * @return string |
|
42 | */ |
|
43 | public static function preProcessing(Compiler $compiler, array $params, $prepend, $append, $type) |
|
44 | { |
|
45 | $with = &$compiler->findBlock('for', true); |
|
46 | ||
47 | $params['initialized'] = true; |
|
48 | $compiler->injectBlock($type, $params); |
|
49 | ||
50 | return ''; |
|
51 | } |
|
52 | ||
53 | /** |
|
54 | * @param Compiler $compiler |
|
55 | * @param array $params |
|
56 | * @param string $prepend |
|
57 | * @param string $append |
|
58 | * @param string $content |
|
59 | * |
|
60 | * @return string |
|
61 | */ |
|
62 | public static function postProcessing(Compiler $compiler, array $params, $prepend, $append, $content) |
|
63 | { |
|
64 | if (!isset($params['initialized'])) { |
|
65 | return ''; |
|
66 | } |
|
67 | ||
68 | $block = &$compiler->getCurrentBlock(); |
|
69 | $block['params']['hasElse'] = Compiler::PHP_OPEN . "else {\n" . Compiler::PHP_CLOSE . $content . Compiler::PHP_OPEN . "\n}" . Compiler::PHP_CLOSE; |
|
70 | ||
71 | return ''; |
|
72 | } |
|
73 | } |
|
74 |
@@ 28-73 (lines=46) @@ | ||
25 | * This software is provided 'as-is', without any express or implied warranty. |
|
26 | * In no event will the authors be held liable for any damages arising from the use of this software. |
|
27 | */ |
|
28 | class PluginWithelse extends BlockPlugin implements ICompilableBlock |
|
29 | { |
|
30 | public function init() |
|
31 | { |
|
32 | } |
|
33 | ||
34 | /** |
|
35 | * @param Compiler $compiler |
|
36 | * @param array $params |
|
37 | * @param string $prepend |
|
38 | * @param string $append |
|
39 | * @param string $type |
|
40 | * |
|
41 | * @return string |
|
42 | */ |
|
43 | public static function preProcessing(Compiler $compiler, array $params, $prepend, $append, $type) |
|
44 | { |
|
45 | $with = &$compiler->findBlock('with', true); |
|
46 | ||
47 | $params['initialized'] = true; |
|
48 | $compiler->injectBlock($type, $params); |
|
49 | ||
50 | return ''; |
|
51 | } |
|
52 | ||
53 | /** |
|
54 | * @param Compiler $compiler |
|
55 | * @param array $params |
|
56 | * @param string $prepend |
|
57 | * @param string $append |
|
58 | * @param string $content |
|
59 | * |
|
60 | * @return string |
|
61 | */ |
|
62 | public static function postProcessing(Compiler $compiler, array $params, $prepend, $append, $content) |
|
63 | { |
|
64 | if (!isset($params['initialized'])) { |
|
65 | return ''; |
|
66 | } |
|
67 | ||
68 | $block = &$compiler->getCurrentBlock(); |
|
69 | $block['params']['hasElse'] = Compiler::PHP_OPEN . "else {\n" . Compiler::PHP_CLOSE . $content . Compiler::PHP_OPEN . "\n}" . Compiler::PHP_CLOSE; |
|
70 | ||
71 | return ''; |
|
72 | } |
|
73 | } |
|
74 |