* @link http://www.yiiframework.com/ * @copyright 2008-2013 Yii Software LLC * @license http://www.yiiframework.com/license/ */ /** * CContentDecorator decorates the content it encloses with the specified view. * * CContentDecorator is mostly used to implement nested layouts, i.e., a layout * is embedded within another layout. {@link CBaseController} defines a pair of * convenient methods to use CContentDecorator: *
* $this->beginContent('path/to/view'); * // ... content to be decorated * $this->endContent(); ** * The property {@link view} specifies the name of the view that is used to * decorate the content. In the view, the content being decorated may be * accessed with variable
$content
.
*
* @author Qiang Xue $content
* The decorated content will be displayed directly.
* @param string $content the content to be decorated
* @return string the decorated content
*/
protected function decorate($content)
{
$owner=$this->getOwner();
if($this->view===null)
$viewFile=Yii::app()->getController()->getLayoutFile(null);
else
$viewFile=$owner->getViewFile($this->view);
if($viewFile!==false)
{
$data=$this->data;
$data['content']=$content;
return $owner->renderFile($viewFile,$data,true);
}
else
return $content;
}
}