示例#1
0
 /**
  * Overloaded Render allows us to generate dynamic content
  * @param string $view      The viewfile we want to render
  * @param array $data       The data that is passed to us from $this->render()
  * @param bool $return      Whether or not we should return the data as a variable or echo it.
  **/
 public function render($view, $data = null, $return = false)
 {
     if ($this->beforeRender($view)) {
         if (empty($this->params['meta'])) {
             $data['meta'] = array();
         }
         if (isset($data['data']) && is_object($data['data'])) {
             $this->params['data'] = $data['data']->attributes;
         }
         if (!$this->isInModule() && file_exists(Yii::getPathOfAlias('base.themes.') . DS . Yii::app()->theme->name . DS . 'Theme.php')) {
             Yii::import('base.themes.' . Yii::app()->theme->name . '.Theme');
             $this->theme = new Theme();
         }
         $output = $this->renderPartial($view, $data, true);
         if (($layoutFile = $this->getLayoutFile($this->layout)) !== false) {
             // Render the Comment functionality automatically
             if (!$this->isInModule()) {
                 $this->widget('cii.widgets.comments.CiiCommentMaster', array('type' => Cii::getCommentProvider(), 'content' => isset($data['data']) && is_a($data['data'], 'Content') ? $data['data']->attributes : false));
             }
             $output = $this->renderFile($layoutFile, array('content' => $output, 'meta' => $this->params['meta']), true);
         }
         $this->afterRender($view, $output);
         $output = $this->processOutput($output);
         if ($return) {
             return $output;
         } else {
             echo $output;
         }
     }
 }