ホームページ php教程 PHP源码 Yii的smarty插件 ESmartyViewRenderer 中的错误更正

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

May 25, 2016 pm 05:13 PM

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

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

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 搭載アプリ

AI Clothes Remover

AI Clothes Remover

写真から衣服を削除するオンライン AI ツール。

Undress AI Tool

Undress AI Tool

脱衣画像を無料で

Clothoff.io

Clothoff.io

AI衣類リムーバー

Video Face Swap

Video Face Swap

完全無料の AI 顔交換ツールを使用して、あらゆるビデオの顔を簡単に交換できます。

ホットツール

メモ帳++7.3.1

メモ帳++7.3.1

使いやすく無料のコードエディター

SublimeText3 中国語版

SublimeText3 中国語版

中国語版、とても使いやすい

ゼンドスタジオ 13.0.1

ゼンドスタジオ 13.0.1

強力な PHP 統合開発環境

ドリームウィーバー CS6

ドリームウィーバー CS6

ビジュアル Web 開発ツール

SublimeText3 Mac版

SublimeText3 Mac版

神レベルのコード編集ソフト(SublimeText3)