搜尋
首頁php教程PHP源码Yii的smarty插件 ESmartyViewRenderer 中的错误更正

Yii的smarty插件 ESmartyViewRenderer 中的错误更正

class ESmartyViewRenderer extends CApplicationComponent implements IViewRenderer
{
    省略..................

    public function renderFile($context,$sourceFile,$data,$return) {
        // current controller properties will be accessible as {$this.property}
        $data['this'] = $context;
        // Yii::app()->... is available as {Yii->...} (deprecated, use {Yii::app()->...} instead, Smarty3 supports this.)
        $data['Yii'] = Yii::app();
        // time and memory information
        $data['TIME'] = sprintf('%0.5f',Yii::getLogger()->getExecutionTime());
        $data['MEMORY'] = round(Yii::getLogger()->getMemoryUsage()/(1024*1024),2).' MB';

        // check if view file exists
        if(!is_file($sourceFile) || ($file=realpath($sourceFile))===false)
            throw new CException(Yii::t('yiiext','View file "{file}" does not exist.', array('{file}'=>$sourceFile)));

        $template = $this->smarty->createTemplate($sourceFile, null, null, $data, false);

        //render or return
        if($return){
            /*
             * 源代码错误!
             * return $template->fetch($sourceFile);
             * 正确的调用方法如下,当指定参数时,必须指定所有相关的参数
             * return $this->smarty->fetch($sourceFile, null, null, $data, false);
             */

            return $template->fetch();    // 所有参数均从 $template 对象继承
        } else {
            /*
             * 源代码错误!
             * $template->display($sourceFile);
             * 正确的调用方法如下,当指定参数时,必须指定所有相关的参数
             * $this->smarty->display($sourceFile, null, null, $data, false);
             */

            $template->display();    // 所有参数均从 $template 对象继承
        }
    }
}

                   

陳述
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

AI Hentai Generator

AI Hentai Generator

免費產生 AI 無盡。

熱門文章

R.E.P.O.能量晶體解釋及其做什麼(黃色晶體)
2 週前By尊渡假赌尊渡假赌尊渡假赌
倉庫:如何復興隊友
4 週前By尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island冒險:如何獲得巨型種子
4 週前By尊渡假赌尊渡假赌尊渡假赌

熱工具

DVWA

DVWA

Damn Vulnerable Web App (DVWA) 是一個PHP/MySQL的Web應用程序,非常容易受到攻擊。它的主要目標是成為安全專業人員在合法環境中測試自己的技能和工具的輔助工具,幫助Web開發人員更好地理解保護網路應用程式的過程,並幫助教師/學生在課堂環境中教授/學習Web應用程式安全性。 DVWA的目標是透過簡單直接的介面練習一些最常見的Web漏洞,難度各不相同。請注意,該軟體中

PhpStorm Mac 版本

PhpStorm Mac 版本

最新(2018.2.1 )專業的PHP整合開發工具

SublimeText3 Mac版

SublimeText3 Mac版

神級程式碼編輯軟體(SublimeText3)

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

這個專案正在遷移到osdn.net/projects/mingw的過程中,你可以繼續在那裡關注我們。 MinGW:GNU編譯器集合(GCC)的本機Windows移植版本,可自由分發的導入函式庫和用於建置本機Windows應用程式的頭檔;包括對MSVC執行時間的擴展,以支援C99功能。 MinGW的所有軟體都可以在64位元Windows平台上運作。

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

強大的PHP整合開發環境