+ Moved variables resolution in the compiler Parser. (Temp. solution until the new...
[haanga.git] / lib / Haanga / Extension / Tag / Exec.php
blob44fb3ce938f17d18d368f0fa1d32789959ce1e47
1 <?php
4 class Haanga_Extension_Tag_Exec
6 public $is_block = FALSE;
8 static function generator($cmp, $args, $assign=NULL)
10 if (!$cmp->getOption('allow_exec')) {
11 $cmp->Error("Tag exec is disabled for security reasons");
15 $code = hcode();
16 if (Haanga_AST::is_var($args[0])) {
17 $args[0] = $args[0]['var'];
18 } else if (Haanga_AST::is_str($args[0])) {
19 $args[0] = $args[0]['string'];
20 } else {
21 $cmp->Error("invalid param");
24 // fix for static calls {{{
25 if (is_array($args[0])) {
26 $end = end($args[0]);
27 if (isset($end['class'])) {
28 $args[0][ key($args[0]) ]['class'] = substr($end['class'], 1);
31 // }}}
33 $exec = hexec($args[0]);
34 for ($i=1; $i < count($args); $i++) {
35 $exec->param($args[$i]);
37 $exec->end();
38 if ($assign) {
39 $code->decl($assign, $exec);
40 } else {
41 $cmp->do_print($code, $exec);
43 return $code;