system system.base system.caching system.caching.dependencies system.collections system.console system.db system.db.ar system.db.schema system.db.schema.cubrid system.db.schema.mssql system.db.schema.mysql system.db.schema.oci system.db.schema.pgsql system.db.schema.sqlite system.gii system.i18n system.i18n.gettext system.logging system.test system.utils system.validators system.web system.web.actions system.web.auth system.web.filters system.web.form system.web.helpers system.web.renderers system.web.services system.web.widgets system.web.widgets.captcha system.web.widgets.pagers zii.behaviors zii.widgets zii.widgets.grid zii.widgets.jui

CJuiWidget

zii.widgets.jui
继承 abstract class CJuiWidget » CWidget » CBaseController » CComponent
子类 CJuiAccordion, CJuiDialog, CJuiDraggable, CJuiDroppable, CJuiInputWidget, CJuiProgressBar, CJuiResizable, CJuiSelectable, CJuiSlider, CJuiSortable, CJuiTabs
可用自 1.1
源码 framework/zii/widgets/jui/CJuiWidget.php
This is the base class for all JUI widget classes.

公共属性

隐藏继承的属性

属性类型描述被定义在
actionPrefix string the prefix to the IDs of the actions. CWidget
controller CController Returns the controller that this widget belongs to. CWidget
cssFile mixed the theme CSS file name. CJuiWidget
htmlOptions array the HTML attributes that should be rendered in the HTML tag representing the JUI widget. CJuiWidget
id string Returns the ID of the widget or generates a new one if requested. CWidget
options array the initial JavaScript options that should be passed to the JUI plugin. CJuiWidget
owner CBaseController Returns the owner/creator of this widget. CWidget
scriptFile mixed the main JUI JavaScript file. CJuiWidget
scriptUrl string the root URL that contains all JUI JavaScript files. CJuiWidget
skin mixed the name of the skin to be used by this widget. CWidget
theme string the JUI theme name. CJuiWidget
themeUrl string the root URL that contains all JUI theme folders. CJuiWidget
viewPath string Returns the directory containing the view files for this widget. CWidget

公共方法

隐藏继承的方法

方法描述被定义在
__call() Calls the named method which is not a class method. CComponent
__construct() Constructor. CWidget
__get() Returns a property value, an event handler list or a behavior based on its name. CComponent
__isset() Checks if a property value is null. CComponent
__set() Sets value of a component property. CComponent
__unset() Sets a component property to be null. CComponent
actions() Returns a list of actions that are used by this widget. CWidget
asa() Returns the named behavior object. CComponent
attachBehavior() Attaches a behavior to this component. CComponent
attachBehaviors() Attaches a list of behaviors to the component. CComponent
attachEventHandler() Attaches an event handler to an event. 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() Determines whether a property can be read. CComponent
canSetProperty() Determines whether a property can be set. CComponent
createWidget() Creates a widget and initializes it. CBaseController
detachBehavior() Detaches a behavior from the component. CComponent
detachBehaviors() Detaches all behaviors from the component. CComponent
detachEventHandler() Detaches an existing event handler. CComponent
disableBehavior() Disables an attached behavior. CComponent
disableBehaviors() Disables all behaviors attached to this component. CComponent
enableBehavior() Enables an attached behavior. CComponent
enableBehaviors() Enables all behaviors attached to this component. 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() Evaluates a PHP expression or callback under the context of this component. CComponent
getController() Returns the controller that this widget belongs to. CWidget
getEventHandlers() Returns the list of attached event handlers for an event. CComponent
getId() Returns the ID of the widget or generates a new one if requested. CWidget
getOwner() Returns the owner/creator of this widget. CWidget
getViewFile() Looks for the view script file according to the view name. CWidget
getViewPath() Returns the directory containing the view files for this widget. CWidget
hasEvent() Determines whether an event is defined. CComponent
hasEventHandler() Checks whether the named event has attached handlers. CComponent
hasProperty() Determines whether a property is defined. CComponent
init() Initializes the widget. CJuiWidget
raiseEvent() Raises an event. CComponent
render() Renders a view. CWidget
renderFile() Renders a view file. CBaseController
renderInternal() Renders a view file. CBaseController
run() Executes the widget. CWidget
setId() Sets the ID of the widget. CWidget
widget() Creates a widget and executes it. CBaseController

受保护的方法

隐藏继承的方法

方法描述被定义在
registerCoreScripts() Registers the core script files. CJuiWidget
registerScriptFile() Registers a JavaScript file under scriptUrl. CJuiWidget
resolvePackagePath() Determine the JUI package installation path. CJuiWidget

属性详情

cssFile 属性
public mixed $cssFile;

the theme CSS file name. Defaults to 'jquery-ui.css'. Note the file must exist under the URL specified by themeUrl/theme. If you need to include multiple theme CSS files (e.g. during development, you want to include individual plugin CSS files), you may set this property as an array of the CSS file names. This property can also be set as false, which means the widget will not include any theme CSS file, and it is your responsibility to explicitly include it somewhere else.

htmlOptions 属性
public array $htmlOptions;

the HTML attributes that should be rendered in the HTML tag representing the JUI widget.

options 属性
public array $options;

the initial JavaScript options that should be passed to the JUI plugin.

scriptFile 属性
public mixed $scriptFile;

the main JUI JavaScript file. Defaults to 'jquery-ui.min.js'. Note the file must exist under the URL specified by scriptUrl. If you need to include multiple script files (e.g. during development, you want to include individual plugin script files rather than the minized JUI script file), you may set this property as an array of the script file names. This property can also be set as false, which means the widget will not include any script file, and it is your responsibility to explicitly include it somewhere else.

scriptUrl 属性
public string $scriptUrl;

the root URL that contains all JUI JavaScript files. If this property is not set (default), Yii will publish the JUI package included in the zii release and use that to infer the root script URL. You should set this property if you intend to use a JUI package whose version is different from the one included in zii. Note that under this URL, there must be a file whose name is specified by scriptFile. Do not append any slash character to the URL.

theme 属性
public string $theme;

the JUI theme name. Defaults to 'base'. Make sure that under themeUrl there is a directory whose name is the same as this property value (case-sensitive).

themeUrl 属性
public string $themeUrl;

the root URL that contains all JUI theme folders. If this property is not set (default), Yii will publish the JUI package included in the zii release and use that to infer the root theme URL. You should set this property if you intend to use a theme that is not found in the JUI package included in zii. Note that under this URL, there must be a directory whose name is specified by theme. Do not append any slash character to the URL.

方法详情

init() 方法
public void init()
源码: framework/zii/widgets/jui/CJuiWidget.php#79 (显示)
public function init()
{
    
$this->resolvePackagePath();
    
$this->registerCoreScripts();
    
parent::init();
}

Initializes the widget. This method will publish JUI assets if necessary. It will also register jquery and JUI JavaScript files and the theme CSS file. If you override this method, make sure you call the parent implementation first.

registerCoreScripts() 方法
protected void registerCoreScripts()
源码: framework/zii/widgets/jui/CJuiWidget.php#108 (显示)
protected function registerCoreScripts()
{
    
$cs=Yii::app()->getClientScript();
    if(
is_string($this->cssFile))
        
$cs->registerCssFile($this->themeUrl.'/'.$this->theme.'/'.$this->cssFile);
    elseif(
is_array($this->cssFile))
    {
        foreach(
$this->cssFile as $cssFile)
            
$cs->registerCssFile($this->themeUrl.'/'.$this->theme.'/'.$cssFile);
    }

    
$cs->registerCoreScript('jquery');
    if(
is_string($this->scriptFile))
        
$this->registerScriptFile($this->scriptFile);
    elseif(
is_array($this->scriptFile))
    {
        foreach(
$this->scriptFile as $scriptFile)
            
$this->registerScriptFile($scriptFile);
    }
}

Registers the core script files. This method registers jquery and JUI JavaScript files and the theme CSS file.

registerScriptFile() 方法
protected void registerScriptFile(string $fileName, integer $position=2)
$fileName string JavaScript file name
$position integer the position of the JavaScript file. Valid values include the following:
  • CClientScript::POS_HEAD : the script is inserted in the head section right before the title element.
  • CClientScript::POS_BEGIN : the script is inserted at the beginning of the body section.
  • CClientScript::POS_END : the script is inserted at the end of the body section.
源码: framework/zii/widgets/jui/CJuiWidget.php#140 (显示)
protected function registerScriptFile($fileName,$position=CClientScript::POS_END)
{
    
Yii::app()->getClientScript()->registerScriptFile($this->scriptUrl.'/'.$fileName,$position);
}

Registers a JavaScript file under scriptUrl. Note that by default, the script file will be rendered at the end of a page to improve page loading speed.

resolvePackagePath() 方法
protected void resolvePackagePath()
源码: framework/zii/widgets/jui/CJuiWidget.php#92 (显示)
protected function resolvePackagePath()
{
    if(
$this->scriptUrl===null || $this->themeUrl===null)
    {
        
$cs=Yii::app()->getClientScript();
        if(
$this->scriptUrl===null)
            
$this->scriptUrl=$cs->getCoreScriptUrl().'/jui/js';
        if(
$this->themeUrl===null)
            
$this->themeUrl=$cs->getCoreScriptUrl().'/jui/css';
    }
}

Determine the JUI package installation path. This method will identify the JavaScript root URL and theme root URL. If they are not explicitly specified, it will publish the included JUI package and use that to resolve the needed paths.