- Added method calling to Exec tag
[haanga.git] / lib / Haanga / Extension / Tag / Exec.php
blob8aa3454771e326ed9aaf1ab47d41b61426386d00
1 <?php
4 class Haanga_Extension_Tag_Exec
6 public $is_block = FALSE;
8 function generator($cmp, $args, $assign=NULL)
10 if (!$cmp->isExecAllowed()) {
11 throw new Haanga_Compiler_Exception("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 throw new Haanga_Compiler_Exception("invalid param");
24 $exec = hexec($args[0]);
25 for ($i=1; $i < count($args); $i++) {
26 $exec->param($args[$i]);
28 $exec->end();
29 if ($assign) {
30 $code->decl($assign, $exec);
31 } else {
32 $cmp->do_print($code, $exec);
34 return $code;