system system.base system.caching system.caching.dependencies system.collections system.console system.db system.db.ar system.db.schema system.db.schema.mssql system.db.schema.mysql system.db.schema.oci system.db.schema.pgsql system.db.schema.sqlite system.i18n system.i18n.gettext system.logging system.utils system.validators system.web system.web.actions system.web.auth system.web.filters system.web.helpers system.web.renderers system.web.services system.web.widgets system.web.widgets.captcha system.web.widgets.pagers

CStarRating

system.web.widgets
继承 class CStarRating » CInputWidget » CWidget » CBaseController » CComponent
可用自 1.0
版本 $Id$
CStarRating displays a star rating control that can collect user rating input.

CStarRating is based on jQuery Star Rating Plugin. It displays a list of stars indicating the rating values. Users can toggle these stars to indicate their rating input. On the server side, when the rating input is submitted, the value can be retrieved in the same way as working with a normal HTML input. For example, using
$this->widget('CStarRating',array('name'=>'rating'));
we can retrieve the rating value via $_POST['rating'].

CStarRating allows customization of its appearance. It also supports empty rating as well as read-only rating.

公共属性

隐藏继承的属性

属性类型描述被定义在
actionPrefix string the prefix to the IDs of the actions. CWidget
allowEmpty boolean whether the rating value can be empty (not set). CStarRating
attribute string the attribute associated with this widget. CInputWidget
blur string Callback when the stars are not focused. CStarRating
callback string Callback when the stars are clicked. CStarRating
controller CController the controller that this widget belongs to. CWidget
cssFile mixed the CSS file used for the widget. CStarRating
focus string Callback when the stars are focused. CStarRating
htmlOptions array additional HTML options to be rendered in the input tag CInputWidget
id string id of the widget. CWidget
maxRating mixed the maximum rating allowed. CStarRating
minRating mixed the minimum rating allowed. CStarRating
model CModel the data model associated with this widget. CInputWidget
name string the input name. CInputWidget
owner CBaseController owner/creator of this widget. CWidget
ratingStepSize mixed the step size of rating. CStarRating
readOnly boolean whether the rating value is read-only or not. CStarRating
resetText string the hint text for the reset button. CStarRating
resetValue string the value taken when the rating is cleared. CStarRating
starCount integer the number of stars. CStarRating
starWidth integer the width of star image. CStarRating
titles array the titles associated with the rating options. CStarRating
value string the input value CInputWidget
viewPath string Returns the directory containing the view files for this widget. CWidget

受保护的属性

隐藏继承的属性

属性类型描述被定义在
clientOptions array the javascript options for the star rating CStarRating

公共方法

隐藏继承的方法

方法描述被定义在
__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
getController() CWidget
getEventHandlers() Returns the list of attached event handlers for an event. CComponent
getId() CWidget
getOwner() 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. CWidget
raiseEvent() Raises an event. CComponent
registerClientScript() Registers the necessary javascript and css scripts. CStarRating
registerCssFile() Registers the needed CSS file. CStarRating
render() Renders a view. CWidget
renderFile() Renders a view file. CBaseController
renderInternal() Renders a view file. CBaseController
run() Executes the widget. CStarRating
setId() CWidget
widget() Creates a widget and executes it. CBaseController

受保护的方法

隐藏继承的方法

方法描述被定义在
getClientOptions() CStarRating
hasModel() CInputWidget
renderStars() Renders the stars. CStarRating
resolveNameID() CInputWidget

属性详情

allowEmpty 属性
public boolean $allowEmpty;

whether the rating value can be empty (not set). Defaults to true. When this is true, a reset button will be displayed in front of stars.

blur 属性
public string $blur;

Callback when the stars are not focused.

callback 属性
public string $callback;

Callback when the stars are clicked.

clientOptions 属性 只读
protected array getClientOptions()

the javascript options for the star rating

cssFile 属性
public mixed $cssFile;

the CSS file used for the widget. Defaults to null, meaning using the default CSS file included together with the widget. If false, no CSS file will be used. Otherwise, the specified CSS file will be included when using this widget.

focus 属性
public string $focus;

Callback when the stars are focused.

maxRating 属性
public mixed $maxRating;

the maximum rating allowed. This can be either an integer or a double value. Defaults to 1.

minRating 属性
public mixed $minRating;

the minimum rating allowed. This can be either an integer or a double value. Defaults to 1.

ratingStepSize 属性
public mixed $ratingStepSize;

the step size of rating. This is the minimum difference between two rating values. Defaults to 1.

readOnly 属性
public boolean $readOnly;

whether the rating value is read-only or not. Defaults to false. When this is true, the rating cannot be changed.

resetText 属性
public string $resetText;

the hint text for the reset button. Defaults to null, meaning using the system-defined text (which is 'Cancel Rating').

resetValue 属性
public string $resetValue;

the value taken when the rating is cleared. Defaults to null, meaning using the system-defined value (which is '').

starCount 属性
public integer $starCount;

the number of stars. Defaults to 5.

starWidth 属性
public integer $starWidth;

the width of star image. Defaults to null, meaning using the system-defined value (which is 16).

titles 属性
public array $titles;

the titles associated with the rating options. The keys are ratings and the values are the corresponding titles. Defaults to null, meaning using the rating value as the title.

方法详情

getClientOptions() 方法
protected array getClientOptions()
{return} array the javascript options for the star rating

registerClientScript() 方法
public void registerClientScript(string $id)
$id string the ID of the container

Registers the necessary javascript and css scripts.

registerCssFile() 方法 (自版本 v1.0.2 可用)
public static void registerCssFile(string $url=NULL)
$url string the CSS URL. If null, a default CSS URL will be used.

Registers the needed CSS file.

renderStars() 方法
protected void renderStars(string $id, string $name)
$id string the ID of the container
$name string the name of the input

Renders the stars.

run() 方法
public void run()

Executes the widget. This method registers all needed client scripts and renders the text field.