CContentDecorator

CDbHttpSession

Yii Framework v1.1.10 类参考

CContentDecorator

system.web.widgets
继承 class CContentDecorator » COutputProcessor » CFilterWidget » CWidget » CBaseController » CComponent
实现 IFilter
源自 1.0
版本 $Id: CContentDecorator.php 3515 2011-12-28 12:29:24Z mdomba $
源码 framework/web/widgets/CContentDecorator.php
CContentDecorator 装饰放置在指定的view中的内容。

CContentDecorator 通常用于实现嵌套布局,也就是说,一个布局 嵌入到另一个布局之中。CBaseController 定义了一对方 便的方法以使用CContentDecorator:
$this->beginContent('path/to/view');
// ... 需要被装饰的内容
$this->endContent();


属性view指定了将用于装饰内容的视图的名字。 在视图中,被装饰的内容可以通过变量$content 进行访问。

公共属性

隐藏继承属性

属性类型描述定义在
actionPrefix string actions的ID的前缀。 当微件在CController::actions中声明了 动作提供者,可以为其动作的ID指定前缀以区别 于别的微件或控制器。当微件用于控制器 的视图中时,必须配置同样的前缀。 CWidget
controller CController 返回此微件所属的控制器。 CWidget
data array 被提取出来使之可以在装饰的视图中使用的变量集 (name=>value)。 CContentDecorator
id string 返回此微件的ID。如果需要的话,将生产一个新的ID并将其返回。 CWidget
isFilter boolean 这个widget是否作为一个过滤器使用。 CFilterWidget
owner CBaseController 返回此微件的所有者或创建者。 CWidget
skin mixed 微件使用的皮肤的名称。默认为“default”。 如果此属性设置为false,微件将不会有皮肤被使用。 CWidget
stopAction boolean 当这个widget用作一个过滤器时是否停止动作的执行。 此属性应当仅在CWidget::init方法中进行改变。 默认值是false,表示动作将会被执行。 CFilterWidget
view mixed 用于装饰被捕获的内容的视图的名字。 如果此属性值为null(默认值),那么默认的布局视图将被使用。 注意:如果当前控制器不属于任何模块,默认布局指应用的 default layout; 如果当前控制器属于一个模块,默认布局指所属模块的 default layout CContentDecorator
viewPath string 返回包含此微件所需的视图文件的路径。 CWidget

公共方法

隐藏继承方法

方法描述定义在
__call() 如果类中没有调的方法名,则调用这个方法。 CComponent
__construct() 构造器。 CFilterWidget
__get() 返回一个属性值、一个事件处理程序列表或一个行为名称。 CComponent
__isset() 检查一个属性是否为null。 CComponent
__set() 设置一个组件的属性值。 CComponent
__unset() 设置一个组件的属性为null。 CComponent
actions() 返回此widget使用的动作的列表。 CWidget
asa() 返回这个名字的行为对象。 CComponent
attachBehavior() 附加一个行为到组件。 CComponent
attachBehaviors() 附加一个行为列表到组件。 CComponent
attachEventHandler() 为事件附加一个事件处理程序。 CComponent
beginCache() Begins fragment caching. CBaseController
beginClip() Begins recording a clip. CBaseController
beginContent() Begins the rendering of content that is to be decorated by the specified view. CBaseController
beginWidget() Creates a widget and executes it. CBaseController
canGetProperty() 确定属性是否可读。 CComponent
canSetProperty() 确定属性是否可写。 CComponent
createWidget() Creates a widget and initializes it. CBaseController
detachBehavior() 从组件中分离一个行为。 CComponent
detachBehaviors() 从组件中分离所有行为。 CComponent
detachEventHandler() 分离一个存在的事件处理程序。 CComponent
disableBehavior() 禁用一个附加行为。 CComponent
disableBehaviors() 禁用组件附加的所有行为。 CComponent
enableBehavior() 启用一个附加行为。 CComponent
enableBehaviors() 启用组件附加的所有行为。 CComponent
endCache() Ends fragment caching. CBaseController
endClip() Ends recording a clip. CBaseController
endContent() Ends the rendering of content. CBaseController
endWidget() Ends the execution of the named widget. CBaseController
evaluateExpression() 计算一个PHP表达式,或根据组件上下文执行回调。 CComponent
filter() 执行过滤。 CFilterWidget
getController() 返回此微件所属的控制器。 CWidget
getEventHandlers() 返回一个事件的附加处理程序列表。 CComponent
getId() 返回此微件的ID。如果需要的话,将生产一个新的ID并将其返回。 CWidget
getIsFilter() 检查这个widget是否作为一个过滤器使用。 CFilterWidget
getOwner() 返回此微件的所有者或创建者。 CWidget
getViewFile() 根据视图名查找视图文件。 CWidget
getViewPath() 返回包含此微件所需的视图文件的路径。 CWidget
hasEvent() 确定一个事件是否定义。 CComponent
hasEventHandler() 检查事件是否有附加的处理程序。 CComponent
hasProperty() 确定属性是否被定义。 CComponent
init() 初始化此小物件。 COutputProcessor
onProcessOutput() 当获取到输出时激发。 COutputProcessor
processOutput() 处理已捕获的输出。 CContentDecorator
raiseEvent() 发起一个事件。 CComponent
render() 渲染一个视图。 CWidget
renderFile() Renders a view file. CBaseController
renderInternal() Renders a view file. CBaseController
run() 运行此小物件。 COutputProcessor
setId() 设置此微件的ID。 CWidget
widget() Creates a widget and executes it. CBaseController

受保护方法

隐藏继承方法

方法描述定义在
decorate() 通过渲染一个视图,并将内容嵌入其中来装饰内容。 CContentDecorator

事件

隐藏继承事件

事件描述定义在
onProcessOutput 当获取到输出时激发。 COutputProcessor

属性详细

data 属性
public array $data;

被提取出来使之可以在装饰的视图中使用的变量集 (name=>value)。

view 属性
public mixed $view;

用于装饰被捕获的内容的视图的名字。 如果此属性值为null(默认值),那么默认的布局视图将被使用。 注意:如果当前控制器不属于任何模块,默认布局指应用的 default layout; 如果当前控制器属于一个模块,默认布局指所属模块的 default layout

方法详细

decorate() 方法
protected string decorate(string $content)
$content string 需要被装饰的内容
{return} string 已装饰过的内容
源码: framework/web/widgets/CContentDecorator.php#66 (显示)
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;
}

通过渲染一个视图,并将内容嵌入其中来装饰内容。 嵌入的内容可以在视图中通过变量$content进行访问。 被装饰的内容将直接显示出来。

processOutput() 方法
public void processOutput(string $output)
$output string 需要被处理的捕获到的输出。
源码: framework/web/widgets/CContentDecorator.php#53 (显示)
public function processOutput($output)
{
    
$output=$this->decorate($output);
    
parent::processOutput($output);
}

处理已捕获的输出。 此方法使用指定的view来装饰输出。

Copyright © 2008-2011 by Yii Software LLC
All Rights Reserved.