Overview

Packages

  • application
    • commands
    • components
      • actions
      • filters
      • leftWidget
      • permissions
      • sortableWidget
      • util
      • webupdater
      • x2flow
        • actions
        • triggers
      • X2GridView
      • X2Settings
    • controllers
    • models
      • embedded
    • modules
      • accounts
        • controllers
        • models
      • actions
        • controllers
        • models
      • calendar
        • controllers
        • models
      • charts
        • models
      • contacts
        • controllers
        • models
      • docs
        • components
        • controllers
        • models
      • groups
        • controllers
        • models
      • marketing
        • components
        • controllers
        • models
      • media
        • controllers
        • models
      • mobile
        • components
      • opportunities
        • controllers
        • models
      • products
        • controllers
        • models
      • quotes
        • controllers
        • models
      • services
        • controllers
        • models
      • template
        • models
      • users
        • controllers
        • models
      • workflow
        • controllers
        • models
      • x2Leads
        • controllers
        • models
  • Net
  • None
  • PHP
  • system
    • base
    • caching
      • dependencies
    • collections
    • console
    • db
      • ar
      • schema
        • cubrid
        • mssql
        • mysql
        • oci
        • pgsql
        • sqlite
    • i18n
      • gettext
    • logging
    • test
    • utils
    • validators
    • web
      • actions
      • auth
      • filters
      • form
      • helpers
      • renderers
      • services
      • widgets
        • captcha
        • pagers
  • Text
    • Highlighter
  • zii
    • behaviors
    • widgets
      • grid
      • jui

Classes

  • ActionFormModelBase
  • CActiveDataProvider
  • CalendarEventFormModel
  • CallFormModel
  • CArrayDataProvider
  • CAssetManager
  • CBaseController
  • CBaseUrlRule
  • CCacheHttpSession
  • CClientScript
  • CController
  • CCookieCollection
  • CDataProvider
  • CDataProviderIterator
  • CDbHttpSession
  • CExtController
  • CFormModel
  • CHttpCookie
  • CHttpRequest
  • CHttpSession
  • CHttpSessionIterator
  • COutputEvent
  • CPagination
  • CreatePageFormModel
  • CSort
  • CSqlDataProvider
  • CTheme
  • CThemeManager
  • CUploadedFile
  • CUrlManager
  • CUrlRule
  • CWebApplication
  • CWebModule
  • CWidgetFactory
  • EditMobileFormsFormModel
  • EventCommentPublisherFormModel
  • EventFormModel
  • EventPublisherFormModel
  • FileSystemObjectDataProvider
  • MassActionFormModel
  • MobilePagination
  • NoteFormModel
  • NotificationsController
  • TimeFormModel
  • UploadLogoFormModel
  • X2FormModel
  • X2HttpRequest

Interfaces

  • IDataProvider
  • IWidgetFactory
  • Overview
  • Package
  • Class
  • Tree

Class CWidgetFactory

CWidgetFactory creates new widgets to be used in views.

CWidgetFactory is used as the default "widgetFactory" application component.

When calling CBaseController::createWidget(), CBaseController::widget() or CBaseController::beginWidget(), if the "widgetFactory" component is installed, it will be used to create the requested widget. To install the "widgetFactory" component, we should have the following application configuration:

return array(
    'components'=>array(
        'widgetFactory'=>array(
            'class'=>'CWidgetFactory',
        ),
    ),
)

CWidgetFactory implements the "skin" feature, which allows a new widget to be created and initialized with a set of predefined property values (called skin).

When CWidgetFactory is used to create a new widget, it will first instantiate the widget instance. It then checks if there is a skin available for this widget according to the widget class name and the widget CWidget::$skin property. If a skin is found, it will be merged with the initial properties passed via CWidgetFactory::createWidget(). Then the merged initial properties will be used to initialize the newly created widget instance.

As aforementioned, a skin is a set of initial property values for a widget. It is thus represented as an associative array of name-value pairs. Skins are stored in PHP scripts like other configurations. Each script file stores the skins for a particular widget type and is named as the widget class name (e.g. CLinkPager.php). Each widget type may have one or several skins, identified by the skin name set via CWidget::$skin property. If the CWidget::$skin property is not set for a given widget, it means the default skin would be used. The following shows the possible skins for the CLinkPager widget:

return array(
    'default'=>array(
        'nextPageLabel'=>'>>',
        'prevPageLabel'=>'<<',
    ),
    'short'=>array(
        'header'=>'',
        'maxButtonCount'=>5,
    ),
);

In the above, there are two skins. The first one is the default skin which is indexed by the string "default". Note that CWidget::$skin defaults to "default". Therefore, this is the skin that will be applied if we do not explicitly specify the CWidget::$skin property. The second one is named as the "short" skin which will be used only when we set CWidget::$skin to be "short".

By default, CWidgetFactory looks for the skin of a widget under the "skins" directory of the current application's CWebApplication::viewPath (e.g. protected/views/skins). If a theme is being used, it will look for the skin under the "skins" directory of the theme's CTheme::viewPath (as well as the aforementioned skin directory). In case the specified skin is not found, a widget will still be created normally without causing any error.

CComponent
Extended by CApplicationComponent implements IApplicationComponent
Extended by CWidgetFactory implements IWidgetFactory
Package: system\web
Copyright: 2008-2013 Yii Software LLC
License: http://www.yiiframework.com/license/
Author: Qiang Xue <qiang.xue@gmail.com>
Since: 1.1
Located at x2engine/framework/web/CWidgetFactory.php
Methods summary
public
# init( )

Initializes the application component. This method overrides the parent implementation by resolving the skin path.

Initializes the application component. This method overrides the parent implementation by resolving the skin path.

Overrides

CApplicationComponent::init()
public CWidget
# createWidget( CBaseController $owner, string $className, array $properties = array() )

Creates a new widget based on the given class name and initial properties.

Creates a new widget based on the given class name and initial properties.

Parameters

$owner
CBaseController
$owner the owner of the new widget
$className
string
$className the class name of the widget. This can also be a path alias (e.g. system.web.widgets.COutputCache)
$properties
array
$properties the initial property values (name=>value) of the widget.

Returns

CWidget
the newly created widget whose properties have been initialized with the given values.

Implementation of

IWidgetFactory::createWidget()
protected array
# getSkin( string $className, string $skinName )

Returns the skin for the specified widget class and skin name.

Returns the skin for the specified widget class and skin name.

Parameters

$className
string
$className the widget class name
$skinName
string
$skinName the widget skin name

Returns

array
the skin (name=>value) for the widget
Methods inherited from CApplicationComponent
getIsInitialized()
Methods inherited from CComponent
__call(), __get(), __isset(), __set(), __unset(), asa(), attachBehavior(), attachBehaviors(), attachEventHandler(), canGetProperty(), canSetProperty(), detachBehavior(), detachBehaviors(), detachEventHandler(), disableBehavior(), disableBehaviors(), enableBehavior(), enableBehaviors(), evaluateExpression(), getEventHandlers(), hasEvent(), hasEventHandler(), hasProperty(), raiseEvent()
Properties summary
public boolean $enableSkin false
#

whether to enable widget skinning. Defaults to false.

whether to enable widget skinning. Defaults to false.

Since

1.1.3

See

CWidgetFactory::$skinnableWidgets
public array $widgets array()
#

widget initial property values. Each array key-value pair represents the initial property values for a single widget class, with the array key being the widget class name, and array value being the initial property value array. For example,

array(
    'CLinkPager'=>array(
        'maxButtonCount'=>5,
        'cssFile'=>false,
    ),
    'CJuiDatePicker'=>array(
        'language'=>'ru',
    ),
)

Note that the initial values specified here may be overridden by the values given in CBaseController::createWidget() calls. They may also be overridden by widget skins, if CWidgetFactory::$enableSkin is true.

widget initial property values. Each array key-value pair represents the initial property values for a single widget class, with the array key being the widget class name, and array value being the initial property value array. For example,

array(
    'CLinkPager'=>array(
        'maxButtonCount'=>5,
        'cssFile'=>false,
    ),
    'CJuiDatePicker'=>array(
        'language'=>'ru',
    ),
)

Note that the initial values specified here may be overridden by the values given in CBaseController::createWidget() calls. They may also be overridden by widget skins, if CWidgetFactory::$enableSkin is true.

Since

1.1.3
public array $skinnableWidgets
#

list of widget class names that can be skinned. Because skinning widgets has performance impact, you may want to specify this property to limit skinning only to specific widgets. Any widgets that are not in this list will not be skinned. Defaults to null, meaning all widgets can be skinned.

list of widget class names that can be skinned. Because skinning widgets has performance impact, you may want to specify this property to limit skinning only to specific widgets. Any widgets that are not in this list will not be skinned. Defaults to null, meaning all widgets can be skinned.

Since

1.1.3
public string $skinPath
#

the directory containing all the skin files. Defaults to null, meaning using the "skins" directory under the current application's CWebApplication::viewPath.

the directory containing all the skin files. Defaults to null, meaning using the "skins" directory under the current application's CWebApplication::viewPath.

Properties inherited from CApplicationComponent
$behaviors
Magic properties inherited from CApplicationComponent
$isInitialized
API documentation generated by ApiGen 2.8.0