CWidget
| Package |
system.web.widgets |
| Inheritance |
class CWidget »
CBaseController »
CComponent |
| Subclasses |
CActiveForm, CBaseListView, CBasePager, CBreadcrumbs, CCaptcha, CClipWidget, CDetailView, CFilterWidget, CFlexWidget, CInputWidget, CJuiWidget, CMenu, CMultiFileUpload, CPortlet, CTabView, CTreeView |
| Since |
1.0 |
| Version |
$Id: CWidget.php 2145 2010-05-19 21:28:55Z alexander.makarow $ |
CWidget is the base class for widgets.
A widget is a self-contained component that may generate presentation
based on model data. It can be viewed as a micro-controller that embeds
into the controller-managed views.
Compared with
controller, a widget has neither actions nor filters.
Usage is described at
CBaseController and
CBaseController::widget.
Property Details
public string $actionPrefix;
the prefix to the IDs of the actions.
When a widget is declared an action provider in CController::actions,
a prefix can be specified to differentiate its action IDs from others.
The same prefix should then also be used to configure this property
when the widget is used in a view of the controller.
the controller that this widget belongs to.
public string
getId(boolean $autoGenerate=true)
public void
setId(string $value)
id of the widget.
owner/creator of this widget. It could be either a widget or a controller.
public mixed $skin;
the name of the skin to be used by this widget. Defaults to 'default'.
If this is set as false, no skin will be applied to this widget.
Returns the directory containing the view files for this widget.
The default implementation returns the 'views' subdirectory of the directory containing the widget class file.
Method Details
|
|
| $owner |
CBaseController |
owner/creator of this widget. It could be either a widget or a controller. |
Constructor.
|
public static void actions()
|
Returns a list of actions that are used by this widget.
The structure of this method's return value is similar to
that returned by CController::actions.
When a widget uses several actions, you can declare these actions using
this method. The widget will then become an action provider, and the actions
can be easily imported into a controller.
Note, when creating URLs referring to the actions listed in this method,
make sure the action IDs are prefixed with actionPrefix.
|
|
| {return} |
CController |
the controller that this widget belongs to. |
|
public string getId(boolean $autoGenerate=true)
|
| $autoGenerate |
boolean |
whether to generate an ID if it is not set previously |
| {return} |
string |
id of the widget. |
|
|
| {return} |
CBaseController |
owner/creator of this widget. It could be either a widget or a controller. |
|
public string getViewFile(string $viewName)
|
| $viewName |
string |
name of the view (without file extension) |
| {return} |
string |
the view file path. False if the view file does not exist |
Looks for the view script file according to the view name.
This method will look for the view under the widget's viewPath.
The view script file is named as "ViewName.php". A localized view file
may be returned if internationalization is needed. See CApplication::findLocalizedFile
for more details.
Since version 1.0.2, the view name can also refer to a path alias
if it contains dot characters.
|
public string getViewPath()
|
| {return} |
string |
the directory containing the view files for this widget. |
Returns the directory containing the view files for this widget.
The default implementation returns the 'views' subdirectory of the directory containing the widget class file.
Initializes the widget.
This method is called by CBaseController::createWidget
and CBaseController::beginWidget after the widget's
properties have been initialized.
|
public string render(string $view, array $data=NULL, boolean $return=false)
|
| $view |
string |
name of the view to be rendered. See getViewFile for details
about how the view script is resolved. |
| $data |
array |
data to be extracted into PHP variables and made available to the view script |
| $return |
boolean |
whether the rendering result should be returned instead of being displayed to end users |
| {return} |
string |
the rendering result. Null if the rendering result is not required. |
Renders a view.
The named view refers to a PHP script (resolved via getViewFile)
that is included by this method. If $data is an associative array,
it will be extracted as PHP variables and made available to the script.
Executes the widget.
This method is called by CBaseController::endWidget.
|
public void setId(string $value)
|
| $value |
string |
id of the widget. |