コード例 #1
0
ファイル: Parser.php プロジェクト: xiaobudongzhang/brainy
 function yy_r103()
 {
     if ($this->yystack[$this->yyidx + -1]->minor == '\'smarty\'') {
         switch (Decompile::decompileString($this->yystack[$this->yyidx + 0]->minor)) {
             case 'now':
                 $this->_retvalue = new Wrappers\StaticWrapper('time()');
                 break;
             case 'template':
                 $this->_retvalue = new Wrappers\StaticWrapper('basename($_smarty_tpl->source->filepath)');
                 break;
             case 'version':
                 $this->_retvalue = new Wrappers\StaticWrapper(var_export(\Box\Brainy\Brainy::SMARTY_VERSION));
                 break;
             case 'ldelim':
                 $this->_retvalue = new Wrappers\StaticWrapper(var_export($this->compiler->smarty->left_delimiter));
                 break;
             case 'rdelim':
                 $this->_retvalue = new Wrappers\StaticWrapper(var_export($this->compiler->smarty->right_delimiter));
                 break;
             default:
                 $this->compiler->trigger_template_error('$smarty.' . trim($this->yystack[$this->yyidx + 0]->minor, "'") . ' is invalid');
         }
     } else {
         $this->_retvalue = $this->compileSafeLookupWithBase($this->compileVariable($this->yystack[$this->yyidx + -1]->minor), $this->yystack[$this->yyidx + 0]->minor);
     }
 }
コード例 #2
0
ファイル: Parser.php プロジェクト: mattbasta/brainy
 function yy_r92()
 {
     if ($this->yystack[$this->yyidx + -1]->minor instanceof Wrappers\SmartyVarLookupWrapper) {
         $decompiled = Decompile::decompileString($this->yystack[$this->yyidx + 0]->minor);
         switch ($decompiled) {
             case 'now':
                 $this->_retvalue = new Wrappers\StaticWrapper('time()');
                 break;
             case 'template':
                 $this->compiler->assertIsNotStrict('$smarty.template is not supported in strict mode', $this);
                 $this->_retvalue = new Wrappers\StaticWrapper('basename($_smarty_tpl->source->filepath)');
                 break;
             case 'version':
                 $this->_retvalue = new Wrappers\StaticWrapper(var_export(\Box\Brainy\Brainy::SMARTY_VERSION, true));
                 break;
             case 'ldelim':
                 $this->_retvalue = new Wrappers\StaticWrapper(var_export($this->compiler->smarty->left_delimiter, true));
                 break;
             case 'rdelim':
                 $this->_retvalue = new Wrappers\StaticWrapper(var_export($this->compiler->smarty->right_delimiter, true));
                 break;
             case 'foreach':
             case 'capture':
             case 'block':
                 $this->_retvalue = new Wrappers\SmartyVarPoisonWrapper($decompiled);
                 break;
             default:
                 $this->compiler->trigger_template_error('$smarty[' . $this->yystack[$this->yyidx + 0]->minor . '] is invalid');
         }
     } elseif ($this->yystack[$this->yyidx + -1]->minor instanceof Wrappers\SmartyVarPoisonWrapper) {
         if ($this->yystack[$this->yyidx + -1]->minor->type === 'block') {
             $decompiled = Decompile::decompileString($this->yystack[$this->yyidx + 0]->minor);
             switch ($decompiled) {
                 case 'child':
                     $data = $this->compiler->assertIsInTag('block');
                     $childBlockVar = $data['childVar'];
                     $this->_retvalue = "({$childBlockVar} ? {$childBlockVar}(\$_smarty_tpl) ?: '' : '')";
                     break;
                 default:
                     $this->compiler->trigger_template_error('$smarty.block[' . $this->yystack[$this->yyidx + 0]->minor . '] is invalid');
             }
         } else {
             // foreach and capture
             $this->_retvalue = new Wrappers\StaticWrapper("\$_smarty_tpl->tpl_vars['smarty'][" . var_export($this->yystack[$this->yyidx + -1]->minor->type, true) . "][" . $this->yystack[$this->yyidx + 0]->minor . "]");
         }
     } else {
         $this->_retvalue = $this->compileSafeLookupWithBase($this->yystack[$this->yyidx + -1]->minor, $this->yystack[$this->yyidx + 0]->minor);
     }
 }