ThinkPHP 3.2.3 Smarty模版引擎 调用$Think系统变量



修改文件 ThinkPHP\Library\Vendor\Smarty\sysplugins\smarty_internal_templateparser.php


位置在2690行左右

修改函数yy_r121()

function yy_r121(){
        if ($this->yystack[$this->yyidx + 0]->minor['var'] == '\'smarty\'') {
            $smarty_var = $this->compiler->compileTag('private_special_variable',array(),$this->yystack[$this->yyidx + 0]->minor['smarty_internal_index']);
            $this->_retvalue = $smarty_var;
        } else {       
            // used for array reset,next,prev,end,current
            $this->last_variable = $this->yystack[$this->yyidx + 0]->minor['var'];
            $this->last_index = $this->yystack[$this->yyidx + 0]->minor['smarty_internal_index'];
            if($this->yystack[$this->yyidx + 0]->minor['var']=="'Think'"){
                $ConstName=$this->yystack[$this->yyidx + 0]->minor['smarty_internal_index'];
                $ConstNameList=explode("']['",$ConstName);
                switch(count($ConstNameList)){
                    case 1:                       
                        $ConstName=str_replace("['",'',$ConstName);
                        $ConstName=str_replace("']",'',$ConstName);
                        $ConstName='('.strtoupper($ConstName).')';
                        break;
                    case 2:                       
                        $ConstName0=str_replace("['",'',$ConstNameList[0]);
                        $ConstName0=str_replace("']",'',$ConstName0);
                        $ConstName1=str_replace("['",'',$ConstNameList[1]);
                        $ConstName1=str_replace("']",'',$ConstName1);
                        $ConstName='$_'.strtoupper($ConstName0).'[\''.strtoupper($ConstName1).'\']';
                        break;
                    case 3:break;
                }
                $this->_retvalue='('.strtoupper($ConstName).')';
            }else{               
                $this->_retvalue = $this->compileVariable($this->yystack[$this->yyidx + 0]->minor['var']).$this->yystack[$this->yyidx + 0]->minor['smarty_internal_index'];
            }
        }
    }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值