@@ -20,47 +20,47 @@ |
||
20 | 20 | */ |
21 | 21 | class Dwoo_Plugin_elseif extends Dwoo_Plugin_if implements Dwoo_ICompilable_Block, Dwoo_IElseable |
22 | 22 | { |
23 | - public function init(array $rest) |
|
24 | - { |
|
25 | - } |
|
23 | + public function init(array $rest) |
|
24 | + { |
|
25 | + } |
|
26 | 26 | |
27 | - public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $type) |
|
28 | - { |
|
29 | - $preContent = ''; |
|
30 | - while (true) { |
|
31 | - $preContent .= $compiler->removeTopBlock(); |
|
32 | - $block = &$compiler->getCurrentBlock(); |
|
33 | - $interfaces = class_implements($block['class'], false); |
|
34 | - if (in_array('Dwoo_IElseable', $interfaces) !== false) { |
|
35 | - break; |
|
36 | - } |
|
37 | - } |
|
27 | + public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $type) |
|
28 | + { |
|
29 | + $preContent = ''; |
|
30 | + while (true) { |
|
31 | + $preContent .= $compiler->removeTopBlock(); |
|
32 | + $block = &$compiler->getCurrentBlock(); |
|
33 | + $interfaces = class_implements($block['class'], false); |
|
34 | + if (in_array('Dwoo_IElseable', $interfaces) !== false) { |
|
35 | + break; |
|
36 | + } |
|
37 | + } |
|
38 | 38 | |
39 | - $params['initialized'] = true; |
|
40 | - $compiler->injectBlock($type, $params); |
|
39 | + $params['initialized'] = true; |
|
40 | + $compiler->injectBlock($type, $params); |
|
41 | 41 | |
42 | - return $preContent; |
|
43 | - } |
|
42 | + return $preContent; |
|
43 | + } |
|
44 | 44 | |
45 | - public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $content) |
|
46 | - { |
|
47 | - if (!isset($params['initialized'])) { |
|
48 | - return ''; |
|
49 | - } |
|
45 | + public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $content) |
|
46 | + { |
|
47 | + if (!isset($params['initialized'])) { |
|
48 | + return ''; |
|
49 | + } |
|
50 | 50 | |
51 | - $tokens = $compiler->getParamTokens($params); |
|
52 | - $params = $compiler->getCompiledParams($params); |
|
51 | + $tokens = $compiler->getParamTokens($params); |
|
52 | + $params = $compiler->getCompiledParams($params); |
|
53 | 53 | |
54 | - $pre = Dwoo_Compiler::PHP_OPEN.'elseif ('.implode(' ', self::replaceKeywords($params['*'], $tokens['*'], $compiler)).") {\n".Dwoo_Compiler::PHP_CLOSE; |
|
55 | - $post = Dwoo_Compiler::PHP_OPEN."\n}".Dwoo_Compiler::PHP_CLOSE; |
|
54 | + $pre = Dwoo_Compiler::PHP_OPEN.'elseif ('.implode(' ', self::replaceKeywords($params['*'], $tokens['*'], $compiler)).") {\n".Dwoo_Compiler::PHP_CLOSE; |
|
55 | + $post = Dwoo_Compiler::PHP_OPEN."\n}".Dwoo_Compiler::PHP_CLOSE; |
|
56 | 56 | |
57 | - if (isset($params['hasElse'])) { |
|
58 | - $post .= $params['hasElse']; |
|
59 | - } |
|
57 | + if (isset($params['hasElse'])) { |
|
58 | + $post .= $params['hasElse']; |
|
59 | + } |
|
60 | 60 | |
61 | - $block = &$compiler->getCurrentBlock(); |
|
62 | - $block['params']['hasElse'] = $pre.$content.$post; |
|
61 | + $block = &$compiler->getCurrentBlock(); |
|
62 | + $block['params']['hasElse'] = $pre.$content.$post; |
|
63 | 63 | |
64 | - return ''; |
|
65 | - } |
|
64 | + return ''; |
|
65 | + } |
|
66 | 66 | } |
@@ -36,30 +36,30 @@ |
||
36 | 36 | */ |
37 | 37 | class Dwoo_Plugin_capture extends Dwoo_Block_Plugin implements Dwoo_ICompilable_Block |
38 | 38 | { |
39 | - public function init($name = 'default', $assign = null, $cat = false, $trim = false) |
|
40 | - { |
|
41 | - } |
|
39 | + public function init($name = 'default', $assign = null, $cat = false, $trim = false) |
|
40 | + { |
|
41 | + } |
|
42 | 42 | |
43 | - public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $type) |
|
44 | - { |
|
45 | - return Dwoo_Compiler::PHP_OPEN.$prepend.'ob_start();'.$append.Dwoo_Compiler::PHP_CLOSE; |
|
46 | - } |
|
43 | + public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $type) |
|
44 | + { |
|
45 | + return Dwoo_Compiler::PHP_OPEN.$prepend.'ob_start();'.$append.Dwoo_Compiler::PHP_CLOSE; |
|
46 | + } |
|
47 | 47 | |
48 | - public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $content) |
|
49 | - { |
|
50 | - $params = $compiler->getCompiledParams($params); |
|
48 | + public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $content) |
|
49 | + { |
|
50 | + $params = $compiler->getCompiledParams($params); |
|
51 | 51 | |
52 | - $out = $content.Dwoo_Compiler::PHP_OPEN.$prepend."\n".'$tmp = ob_get_clean();'; |
|
53 | - if ($params['trim'] !== 'false' && $params['trim'] !== 0) { |
|
54 | - $out .= "\n".'$tmp = trim($tmp);'; |
|
55 | - } |
|
56 | - if ($params['cat'] === 'true' || $params['cat'] === 1) { |
|
57 | - $out .= "\n".'$tmp = $this->readVar(\'dwoo.capture.\'.'.$params['name'].') . $tmp;'; |
|
58 | - } |
|
59 | - if ($params['assign'] !== 'null') { |
|
60 | - $out .= "\n".'$this->scope['.$params['assign'].'] = $tmp;'; |
|
61 | - } |
|
52 | + $out = $content.Dwoo_Compiler::PHP_OPEN.$prepend."\n".'$tmp = ob_get_clean();'; |
|
53 | + if ($params['trim'] !== 'false' && $params['trim'] !== 0) { |
|
54 | + $out .= "\n".'$tmp = trim($tmp);'; |
|
55 | + } |
|
56 | + if ($params['cat'] === 'true' || $params['cat'] === 1) { |
|
57 | + $out .= "\n".'$tmp = $this->readVar(\'dwoo.capture.\'.'.$params['name'].') . $tmp;'; |
|
58 | + } |
|
59 | + if ($params['assign'] !== 'null') { |
|
60 | + $out .= "\n".'$this->scope['.$params['assign'].'] = $tmp;'; |
|
61 | + } |
|
62 | 62 | |
63 | - return $out."\n".'$this->globals[\'capture\']['.$params['name'].'] = $tmp;'.$append.Dwoo_Compiler::PHP_CLOSE; |
|
64 | - } |
|
63 | + return $out."\n".'$this->globals[\'capture\']['.$params['name'].'] = $tmp;'.$append.Dwoo_Compiler::PHP_CLOSE; |
|
64 | + } |
|
65 | 65 | } |
@@ -43,101 +43,101 @@ |
||
43 | 43 | */ |
44 | 44 | class Dwoo_Plugin_loop extends Dwoo_Block_Plugin implements Dwoo_ICompilable_Block, Dwoo_IElseable |
45 | 45 | { |
46 | - public static $cnt = 0; |
|
46 | + public static $cnt = 0; |
|
47 | 47 | |
48 | - public function init($from, $name = 'default') |
|
49 | - { |
|
50 | - } |
|
48 | + public function init($from, $name = 'default') |
|
49 | + { |
|
50 | + } |
|
51 | 51 | |
52 | - public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $type) |
|
53 | - { |
|
54 | - // get block params and save the current template pointer to use it in the postProcessing method |
|
55 | - $currentBlock = &$compiler->getCurrentBlock(); |
|
56 | - $currentBlock['params']['tplPointer'] = $compiler->getPointer(); |
|
52 | + public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $type) |
|
53 | + { |
|
54 | + // get block params and save the current template pointer to use it in the postProcessing method |
|
55 | + $currentBlock = &$compiler->getCurrentBlock(); |
|
56 | + $currentBlock['params']['tplPointer'] = $compiler->getPointer(); |
|
57 | 57 | |
58 | - return ''; |
|
59 | - } |
|
58 | + return ''; |
|
59 | + } |
|
60 | 60 | |
61 | - public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $content) |
|
62 | - { |
|
63 | - $params = $compiler->getCompiledParams($params); |
|
64 | - $tpl = $compiler->getTemplateSource($params['tplPointer']); |
|
61 | + public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $content) |
|
62 | + { |
|
63 | + $params = $compiler->getCompiledParams($params); |
|
64 | + $tpl = $compiler->getTemplateSource($params['tplPointer']); |
|
65 | 65 | |
66 | - // assigns params |
|
67 | - $src = $params['from']; |
|
68 | - $name = $params['name']; |
|
66 | + // assigns params |
|
67 | + $src = $params['from']; |
|
68 | + $name = $params['name']; |
|
69 | 69 | |
70 | - // evaluates which global variables have to be computed |
|
71 | - $varName = '$dwoo.loop.'.trim($name, '"\'').'.'; |
|
72 | - $shortVarName = '$.loop.'.trim($name, '"\'').'.'; |
|
73 | - $usesAny = strpos($tpl, $varName) !== false || strpos($tpl, $shortVarName) !== false; |
|
74 | - $usesFirst = strpos($tpl, $varName.'first') !== false || strpos($tpl, $shortVarName.'first') !== false; |
|
75 | - $usesLast = strpos($tpl, $varName.'last') !== false || strpos($tpl, $shortVarName.'last') !== false; |
|
76 | - $usesIndex = $usesFirst || strpos($tpl, $varName.'index') !== false || strpos($tpl, $shortVarName.'index') !== false; |
|
77 | - $usesIteration = $usesLast || strpos($tpl, $varName.'iteration') !== false || strpos($tpl, $shortVarName.'iteration') !== false; |
|
78 | - $usesShow = strpos($tpl, $varName.'show') !== false || strpos($tpl, $shortVarName.'show') !== false; |
|
79 | - $usesTotal = $usesLast || strpos($tpl, $varName.'total') !== false || strpos($tpl, $shortVarName.'total') !== false; |
|
70 | + // evaluates which global variables have to be computed |
|
71 | + $varName = '$dwoo.loop.'.trim($name, '"\'').'.'; |
|
72 | + $shortVarName = '$.loop.'.trim($name, '"\'').'.'; |
|
73 | + $usesAny = strpos($tpl, $varName) !== false || strpos($tpl, $shortVarName) !== false; |
|
74 | + $usesFirst = strpos($tpl, $varName.'first') !== false || strpos($tpl, $shortVarName.'first') !== false; |
|
75 | + $usesLast = strpos($tpl, $varName.'last') !== false || strpos($tpl, $shortVarName.'last') !== false; |
|
76 | + $usesIndex = $usesFirst || strpos($tpl, $varName.'index') !== false || strpos($tpl, $shortVarName.'index') !== false; |
|
77 | + $usesIteration = $usesLast || strpos($tpl, $varName.'iteration') !== false || strpos($tpl, $shortVarName.'iteration') !== false; |
|
78 | + $usesShow = strpos($tpl, $varName.'show') !== false || strpos($tpl, $shortVarName.'show') !== false; |
|
79 | + $usesTotal = $usesLast || strpos($tpl, $varName.'total') !== false || strpos($tpl, $shortVarName.'total') !== false; |
|
80 | 80 | |
81 | - if (strpos($name, '$this->scope[') !== false) { |
|
82 | - $usesAny = $usesFirst = $usesLast = $usesIndex = $usesIteration = $usesShow = $usesTotal = true; |
|
83 | - } |
|
81 | + if (strpos($name, '$this->scope[') !== false) { |
|
82 | + $usesAny = $usesFirst = $usesLast = $usesIndex = $usesIteration = $usesShow = $usesTotal = true; |
|
83 | + } |
|
84 | 84 | |
85 | - // gets foreach id |
|
86 | - $cnt = self::$cnt++; |
|
85 | + // gets foreach id |
|
86 | + $cnt = self::$cnt++; |
|
87 | 87 | |
88 | - // builds pre processing output |
|
89 | - $pre = Dwoo_Compiler::PHP_OPEN."\n".'$_loop'.$cnt.'_data = '.$src.';'; |
|
90 | - // adds foreach properties |
|
91 | - if ($usesAny) { |
|
92 | - $pre .= "\n".'$this->globals["loop"]['.$name.'] = array'."\n("; |
|
93 | - if ($usesIndex) { |
|
94 | - $pre .= "\n\t".'"index" => 0,'; |
|
95 | - } |
|
96 | - if ($usesIteration) { |
|
97 | - $pre .= "\n\t".'"iteration" => 1,'; |
|
98 | - } |
|
99 | - if ($usesFirst) { |
|
100 | - $pre .= "\n\t".'"first" => null,'; |
|
101 | - } |
|
102 | - if ($usesLast) { |
|
103 | - $pre .= "\n\t".'"last" => null,'; |
|
104 | - } |
|
105 | - if ($usesShow) { |
|
106 | - $pre .= "\n\t".'"show" => $this->isTraversable($_loop'.$cnt.'_data, true),'; |
|
107 | - } |
|
108 | - if ($usesTotal) { |
|
109 | - $pre .= "\n\t".'"total" => $this->count($_loop'.$cnt.'_data),'; |
|
110 | - } |
|
111 | - $pre .= "\n);\n".'$_loop'.$cnt.'_glob =& $this->globals["loop"]['.$name.'];'; |
|
112 | - } |
|
113 | - // checks if the loop must be looped |
|
114 | - $pre .= "\n".'if ($this->isTraversable($_loop'.$cnt.'_data'.(isset($params['hasElse']) ? ', true' : '').') == true)'."\n{"; |
|
115 | - // iterates over keys |
|
116 | - $pre .= "\n\t".'foreach ($_loop'.$cnt.'_data as $tmp_key => $this->scope["-loop-"])'."\n\t{"; |
|
117 | - // updates properties |
|
118 | - if ($usesFirst) { |
|
119 | - $pre .= "\n\t\t".'$_loop'.$cnt.'_glob["first"] = (string) ($_loop'.$cnt.'_glob["index"] === 0);'; |
|
120 | - } |
|
121 | - if ($usesLast) { |
|
122 | - $pre .= "\n\t\t".'$_loop'.$cnt.'_glob["last"] = (string) ($_loop'.$cnt.'_glob["iteration"] === $_loop'.$cnt.'_glob["total"]);'; |
|
123 | - } |
|
124 | - $pre .= "\n\t\t".'$_loop'.$cnt.'_scope = $this->setScope(array("-loop-"));'."\n/* -- loop start output */\n".Dwoo_Compiler::PHP_CLOSE; |
|
88 | + // builds pre processing output |
|
89 | + $pre = Dwoo_Compiler::PHP_OPEN."\n".'$_loop'.$cnt.'_data = '.$src.';'; |
|
90 | + // adds foreach properties |
|
91 | + if ($usesAny) { |
|
92 | + $pre .= "\n".'$this->globals["loop"]['.$name.'] = array'."\n("; |
|
93 | + if ($usesIndex) { |
|
94 | + $pre .= "\n\t".'"index" => 0,'; |
|
95 | + } |
|
96 | + if ($usesIteration) { |
|
97 | + $pre .= "\n\t".'"iteration" => 1,'; |
|
98 | + } |
|
99 | + if ($usesFirst) { |
|
100 | + $pre .= "\n\t".'"first" => null,'; |
|
101 | + } |
|
102 | + if ($usesLast) { |
|
103 | + $pre .= "\n\t".'"last" => null,'; |
|
104 | + } |
|
105 | + if ($usesShow) { |
|
106 | + $pre .= "\n\t".'"show" => $this->isTraversable($_loop'.$cnt.'_data, true),'; |
|
107 | + } |
|
108 | + if ($usesTotal) { |
|
109 | + $pre .= "\n\t".'"total" => $this->count($_loop'.$cnt.'_data),'; |
|
110 | + } |
|
111 | + $pre .= "\n);\n".'$_loop'.$cnt.'_glob =& $this->globals["loop"]['.$name.'];'; |
|
112 | + } |
|
113 | + // checks if the loop must be looped |
|
114 | + $pre .= "\n".'if ($this->isTraversable($_loop'.$cnt.'_data'.(isset($params['hasElse']) ? ', true' : '').') == true)'."\n{"; |
|
115 | + // iterates over keys |
|
116 | + $pre .= "\n\t".'foreach ($_loop'.$cnt.'_data as $tmp_key => $this->scope["-loop-"])'."\n\t{"; |
|
117 | + // updates properties |
|
118 | + if ($usesFirst) { |
|
119 | + $pre .= "\n\t\t".'$_loop'.$cnt.'_glob["first"] = (string) ($_loop'.$cnt.'_glob["index"] === 0);'; |
|
120 | + } |
|
121 | + if ($usesLast) { |
|
122 | + $pre .= "\n\t\t".'$_loop'.$cnt.'_glob["last"] = (string) ($_loop'.$cnt.'_glob["iteration"] === $_loop'.$cnt.'_glob["total"]);'; |
|
123 | + } |
|
124 | + $pre .= "\n\t\t".'$_loop'.$cnt.'_scope = $this->setScope(array("-loop-"));'."\n/* -- loop start output */\n".Dwoo_Compiler::PHP_CLOSE; |
|
125 | 125 | |
126 | - // build post processing output and cache it |
|
127 | - $post = Dwoo_Compiler::PHP_OPEN."\n".'/* -- loop end output */'."\n\t\t".'$this->setScope($_loop'.$cnt.'_scope, true);'; |
|
128 | - // update properties |
|
129 | - if ($usesIndex) { |
|
130 | - $post .= "\n\t\t".'$_loop'.$cnt.'_glob["index"]+=1;'; |
|
131 | - } |
|
132 | - if ($usesIteration) { |
|
133 | - $post .= "\n\t\t".'$_loop'.$cnt.'_glob["iteration"]+=1;'; |
|
134 | - } |
|
135 | - // end loop |
|
136 | - $post .= "\n\t}\n}\n".Dwoo_Compiler::PHP_CLOSE; |
|
137 | - if (isset($params['hasElse'])) { |
|
138 | - $post .= $params['hasElse']; |
|
139 | - } |
|
126 | + // build post processing output and cache it |
|
127 | + $post = Dwoo_Compiler::PHP_OPEN."\n".'/* -- loop end output */'."\n\t\t".'$this->setScope($_loop'.$cnt.'_scope, true);'; |
|
128 | + // update properties |
|
129 | + if ($usesIndex) { |
|
130 | + $post .= "\n\t\t".'$_loop'.$cnt.'_glob["index"]+=1;'; |
|
131 | + } |
|
132 | + if ($usesIteration) { |
|
133 | + $post .= "\n\t\t".'$_loop'.$cnt.'_glob["iteration"]+=1;'; |
|
134 | + } |
|
135 | + // end loop |
|
136 | + $post .= "\n\t}\n}\n".Dwoo_Compiler::PHP_CLOSE; |
|
137 | + if (isset($params['hasElse'])) { |
|
138 | + $post .= $params['hasElse']; |
|
139 | + } |
|
140 | 140 | |
141 | - return $pre.$content.$post; |
|
142 | - } |
|
141 | + return $pre.$content.$post; |
|
142 | + } |
|
143 | 143 | } |
@@ -19,29 +19,29 @@ |
||
19 | 19 | */ |
20 | 20 | class Dwoo_Plugin_forelse extends Dwoo_Block_Plugin implements Dwoo_ICompilable_Block |
21 | 21 | { |
22 | - public function init() |
|
23 | - { |
|
24 | - } |
|
22 | + public function init() |
|
23 | + { |
|
24 | + } |
|
25 | 25 | |
26 | - public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $type) |
|
27 | - { |
|
28 | - $with = &$compiler->findBlock('for', true); |
|
26 | + public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $type) |
|
27 | + { |
|
28 | + $with = &$compiler->findBlock('for', true); |
|
29 | 29 | |
30 | - $params['initialized'] = true; |
|
31 | - $compiler->injectBlock($type, $params); |
|
30 | + $params['initialized'] = true; |
|
31 | + $compiler->injectBlock($type, $params); |
|
32 | 32 | |
33 | - return ''; |
|
34 | - } |
|
33 | + return ''; |
|
34 | + } |
|
35 | 35 | |
36 | - public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $content) |
|
37 | - { |
|
38 | - if (!isset($params['initialized'])) { |
|
39 | - return ''; |
|
40 | - } |
|
36 | + public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $content) |
|
37 | + { |
|
38 | + if (!isset($params['initialized'])) { |
|
39 | + return ''; |
|
40 | + } |
|
41 | 41 | |
42 | - $block = &$compiler->getCurrentBlock(); |
|
43 | - $block['params']['hasElse'] = Dwoo_Compiler::PHP_OPEN."else {\n".Dwoo_Compiler::PHP_CLOSE.$content.Dwoo_Compiler::PHP_OPEN."\n}".Dwoo_Compiler::PHP_CLOSE; |
|
42 | + $block = &$compiler->getCurrentBlock(); |
|
43 | + $block['params']['hasElse'] = Dwoo_Compiler::PHP_OPEN."else {\n".Dwoo_Compiler::PHP_CLOSE.$content.Dwoo_Compiler::PHP_OPEN."\n}".Dwoo_Compiler::PHP_CLOSE; |
|
44 | 44 | |
45 | - return ''; |
|
46 | - } |
|
45 | + return ''; |
|
46 | + } |
|
47 | 47 | } |
@@ -19,17 +19,17 @@ |
||
19 | 19 | */ |
20 | 20 | final class Dwoo_Plugin_topLevelBlock extends Dwoo_Block_Plugin implements Dwoo_ICompilable_Block |
21 | 21 | { |
22 | - public function init() |
|
23 | - { |
|
24 | - } |
|
22 | + public function init() |
|
23 | + { |
|
24 | + } |
|
25 | 25 | |
26 | - public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $type) |
|
27 | - { |
|
28 | - return '/* end template head */ ob_start(); /* template body */ '.Dwoo_Compiler::PHP_CLOSE; |
|
29 | - } |
|
26 | + public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $type) |
|
27 | + { |
|
28 | + return '/* end template head */ ob_start(); /* template body */ '.Dwoo_Compiler::PHP_CLOSE; |
|
29 | + } |
|
30 | 30 | |
31 | - public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $content) |
|
32 | - { |
|
33 | - return $content.Dwoo_Compiler::PHP_OPEN.' /* end template body */'."\n".'return $this->buffer . ob_get_clean();'; |
|
34 | - } |
|
31 | + public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $content) |
|
32 | + { |
|
33 | + return $content.Dwoo_Compiler::PHP_OPEN.' /* end template body */'."\n".'return $this->buffer . ob_get_clean();'; |
|
34 | + } |
|
35 | 35 | } |
@@ -19,29 +19,29 @@ |
||
19 | 19 | */ |
20 | 20 | class Dwoo_Plugin_foreachelse extends Dwoo_Block_Plugin implements Dwoo_ICompilable_Block |
21 | 21 | { |
22 | - public function init() |
|
23 | - { |
|
24 | - } |
|
22 | + public function init() |
|
23 | + { |
|
24 | + } |
|
25 | 25 | |
26 | - public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $type) |
|
27 | - { |
|
28 | - $with = &$compiler->findBlock('foreach', true); |
|
26 | + public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $type) |
|
27 | + { |
|
28 | + $with = &$compiler->findBlock('foreach', true); |
|
29 | 29 | |
30 | - $params['initialized'] = true; |
|
31 | - $compiler->injectBlock($type, $params); |
|
30 | + $params['initialized'] = true; |
|
31 | + $compiler->injectBlock($type, $params); |
|
32 | 32 | |
33 | - return ''; |
|
34 | - } |
|
33 | + return ''; |
|
34 | + } |
|
35 | 35 | |
36 | - public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $content) |
|
37 | - { |
|
38 | - if (!isset($params['initialized'])) { |
|
39 | - return ''; |
|
40 | - } |
|
36 | + public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $content) |
|
37 | + { |
|
38 | + if (!isset($params['initialized'])) { |
|
39 | + return ''; |
|
40 | + } |
|
41 | 41 | |
42 | - $block = &$compiler->getCurrentBlock(); |
|
43 | - $block['params']['hasElse'] = Dwoo_Compiler::PHP_OPEN."else {\n".Dwoo_Compiler::PHP_CLOSE.$content.Dwoo_Compiler::PHP_OPEN."\n}".Dwoo_Compiler::PHP_CLOSE; |
|
42 | + $block = &$compiler->getCurrentBlock(); |
|
43 | + $block['params']['hasElse'] = Dwoo_Compiler::PHP_OPEN."else {\n".Dwoo_Compiler::PHP_CLOSE.$content.Dwoo_Compiler::PHP_OPEN."\n}".Dwoo_Compiler::PHP_CLOSE; |
|
44 | 44 | |
45 | - return ''; |
|
46 | - } |
|
45 | + return ''; |
|
46 | + } |
|
47 | 47 | } |
@@ -21,17 +21,17 @@ |
||
21 | 21 | */ |
22 | 22 | class Dwoo_Plugin_block extends Dwoo_Block_Plugin implements Dwoo_ICompilable_Block |
23 | 23 | { |
24 | - public function init($name = '') |
|
25 | - { |
|
26 | - } |
|
24 | + public function init($name = '') |
|
25 | + { |
|
26 | + } |
|
27 | 27 | |
28 | - public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $type) |
|
29 | - { |
|
30 | - return ''; |
|
31 | - } |
|
28 | + public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $type) |
|
29 | + { |
|
30 | + return ''; |
|
31 | + } |
|
32 | 32 | |
33 | - public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $content) |
|
34 | - { |
|
35 | - return $content; |
|
36 | - } |
|
33 | + public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $content) |
|
34 | + { |
|
35 | + return $content; |
|
36 | + } |
|
37 | 37 | } |
@@ -43,36 +43,36 @@ |
||
43 | 43 | */ |
44 | 44 | class Dwoo_Plugin_with extends Dwoo_Block_Plugin implements Dwoo_ICompilable_Block, Dwoo_IElseable |
45 | 45 | { |
46 | - protected static $cnt = 0; |
|
46 | + protected static $cnt = 0; |
|
47 | 47 | |
48 | - public function init($var) |
|
49 | - { |
|
50 | - } |
|
48 | + public function init($var) |
|
49 | + { |
|
50 | + } |
|
51 | 51 | |
52 | - public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $type) |
|
53 | - { |
|
54 | - return ''; |
|
55 | - } |
|
52 | + public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $type) |
|
53 | + { |
|
54 | + return ''; |
|
55 | + } |
|
56 | 56 | |
57 | - public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $content) |
|
58 | - { |
|
59 | - $rparams = $compiler->getRealParams($params); |
|
60 | - $cparams = $compiler->getCompiledParams($params); |
|
57 | + public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $content) |
|
58 | + { |
|
59 | + $rparams = $compiler->getRealParams($params); |
|
60 | + $cparams = $compiler->getCompiledParams($params); |
|
61 | 61 | |
62 | - $compiler->setScope($rparams['var']); |
|
62 | + $compiler->setScope($rparams['var']); |
|
63 | 63 | |
64 | - $pre = Dwoo_Compiler::PHP_OPEN.'if ('.$cparams['var'].')'."\n{\n". |
|
65 | - '$_with'.(self::$cnt).' = $this->setScope("'.$rparams['var'].'");'. |
|
66 | - "\n/* -- start with output */\n".Dwoo_Compiler::PHP_CLOSE; |
|
64 | + $pre = Dwoo_Compiler::PHP_OPEN.'if ('.$cparams['var'].')'."\n{\n". |
|
65 | + '$_with'.(self::$cnt).' = $this->setScope("'.$rparams['var'].'");'. |
|
66 | + "\n/* -- start with output */\n".Dwoo_Compiler::PHP_CLOSE; |
|
67 | 67 | |
68 | - $post = Dwoo_Compiler::PHP_OPEN."\n/* -- end with output */\n". |
|
69 | - '$this->setScope($_with'.(self::$cnt++).', true);'. |
|
70 | - "\n}\n".Dwoo_Compiler::PHP_CLOSE; |
|
68 | + $post = Dwoo_Compiler::PHP_OPEN."\n/* -- end with output */\n". |
|
69 | + '$this->setScope($_with'.(self::$cnt++).', true);'. |
|
70 | + "\n}\n".Dwoo_Compiler::PHP_CLOSE; |
|
71 | 71 | |
72 | - if (isset($params['hasElse'])) { |
|
73 | - $post .= $params['hasElse']; |
|
74 | - } |
|
72 | + if (isset($params['hasElse'])) { |
|
73 | + $post .= $params['hasElse']; |
|
74 | + } |
|
75 | 75 | |
76 | - return $pre.$content.$post; |
|
77 | - } |
|
76 | + return $pre.$content.$post; |
|
77 | + } |
|
78 | 78 | } |
@@ -19,29 +19,29 @@ |
||
19 | 19 | */ |
20 | 20 | class Dwoo_Plugin_withelse extends Dwoo_Block_Plugin implements Dwoo_ICompilable_Block |
21 | 21 | { |
22 | - public function init() |
|
23 | - { |
|
24 | - } |
|
22 | + public function init() |
|
23 | + { |
|
24 | + } |
|
25 | 25 | |
26 | - public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $type) |
|
27 | - { |
|
28 | - $with = &$compiler->findBlock('with', true); |
|
26 | + public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $type) |
|
27 | + { |
|
28 | + $with = &$compiler->findBlock('with', true); |
|
29 | 29 | |
30 | - $params['initialized'] = true; |
|
31 | - $compiler->injectBlock($type, $params); |
|
30 | + $params['initialized'] = true; |
|
31 | + $compiler->injectBlock($type, $params); |
|
32 | 32 | |
33 | - return ''; |
|
34 | - } |
|
33 | + return ''; |
|
34 | + } |
|
35 | 35 | |
36 | - public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $content) |
|
37 | - { |
|
38 | - if (!isset($params['initialized'])) { |
|
39 | - return ''; |
|
40 | - } |
|
36 | + public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $content) |
|
37 | + { |
|
38 | + if (!isset($params['initialized'])) { |
|
39 | + return ''; |
|
40 | + } |
|
41 | 41 | |
42 | - $block = &$compiler->getCurrentBlock(); |
|
43 | - $block['params']['hasElse'] = Dwoo_Compiler::PHP_OPEN."else {\n".Dwoo_Compiler::PHP_CLOSE.$content.Dwoo_Compiler::PHP_OPEN."\n}".Dwoo_Compiler::PHP_CLOSE; |
|
42 | + $block = &$compiler->getCurrentBlock(); |
|
43 | + $block['params']['hasElse'] = Dwoo_Compiler::PHP_OPEN."else {\n".Dwoo_Compiler::PHP_CLOSE.$content.Dwoo_Compiler::PHP_OPEN."\n}".Dwoo_Compiler::PHP_CLOSE; |
|
44 | 44 | |
45 | - return ''; |
|
46 | - } |
|
45 | + return ''; |
|
46 | + } |
|
47 | 47 | } |