CStarRating
包 | system.web.widgets |
---|---|
继承 | class CStarRating » CInputWidget » CWidget » CBaseController » CComponent |
可用自 | 1.0 |
版本 | $Id$ |
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 |
属性详情
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.
Callback when the stars are not focused.
Callback when the stars are clicked.
the javascript options for the star rating
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.
Callback when the stars are focused.
the maximum rating allowed. This can be either an integer or a double value. Defaults to 1.
the minimum rating allowed. This can be either an integer or a double value. Defaults to 1.
the step size of rating. This is the minimum difference between two rating values. Defaults to 1.
whether the rating value is read-only or not. Defaults to false. When this is true, the rating cannot be changed.
the hint text for the reset button. Defaults to null, meaning using the system-defined text (which is 'Cancel Rating').
the value taken when the rating is cleared. Defaults to null, meaning using the system-defined value (which is '').
the number of stars. Defaults to 5.
the width of star image. Defaults to null, meaning using the system-defined value (which is 16).
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.
方法详情
protected array getClientOptions()
| ||
{return} | array | the javascript options for the star rating |
public void registerClientScript(string $id)
| ||
$id | string | the ID of the container |
Registers the necessary javascript and css scripts.
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.
protected void renderStars(string $id, string $name)
| ||
$id | string | the ID of the container |
$name | string | the name of the input |
Renders the stars.
public void run()
|
Executes the widget. This method registers all needed client scripts and renders the text field.