0 follower

CJuiWidget

Package zii.widgets.jui
Inheritance abstract class CJuiWidget » CWidget » CBaseController » CComponent
Subclasses CJuiAccordion, CJuiDialog, CJuiDraggable, CJuiDroppable, CJuiInputWidget, CJuiProgressBar, CJuiResizable, CJuiSelectable, CJuiSlider, CJuiSortable, CJuiTabs
Since 1.1
Source Code framework/zii/widgets/jui/CJuiWidget.php
This is the base class for all JUI widget classes.

Public Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
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

Public Methods

Hide inherited methods

MethodDescriptionDefined By
__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

Protected Methods

Hide inherited methods

MethodDescriptionDefined By
registerCoreScripts() Registers the core script files. CJuiWidget
registerScriptFile() Registers a JavaScript file under scriptUrl. CJuiWidget
resolvePackagePath() Determine the JUI package installation path. CJuiWidget

Property Details

cssFile property
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 property
public array $htmlOptions;

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

options property
public array $options;

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

scriptFile property
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 property
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 property
public string $theme;

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

themeUrl property
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.

Method Details

init() method
public void init()
Source Code: framework/zii/widgets/jui/CJuiWidget.php#79 (show)
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() method
protected void registerCoreScripts()
Source Code: framework/zii/widgets/jui/CJuiWidget.php#108 (show)
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() method
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.
Source Code: framework/zii/widgets/jui/CJuiWidget.php#140 (show)
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() method
protected void resolvePackagePath()
Source Code: framework/zii/widgets/jui/CJuiWidget.php#92 (show)
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.