summaryrefslogtreecommitdiff
path: root/framework/Web/UI/ActiveControls
diff options
context:
space:
mode:
Diffstat (limited to 'framework/Web/UI/ActiveControls')
-rw-r--r--framework/Web/UI/ActiveControls/TActiveButton.php8
-rw-r--r--framework/Web/UI/ActiveControls/TActiveCheckBox.php8
-rw-r--r--framework/Web/UI/ActiveControls/TActiveCheckBoxList.php8
-rw-r--r--framework/Web/UI/ActiveControls/TActiveCustomValidator.php74
-rw-r--r--framework/Web/UI/ActiveControls/TActiveDropDownList.php8
-rw-r--r--framework/Web/UI/ActiveControls/TActiveImageButton.php8
-rw-r--r--framework/Web/UI/ActiveControls/TActiveLinkButton.php8
-rw-r--r--framework/Web/UI/ActiveControls/TActiveListBox.php8
-rw-r--r--framework/Web/UI/ActiveControls/TActiveRadioButton.php8
-rw-r--r--framework/Web/UI/ActiveControls/TActiveRadioButtonList.php8
-rw-r--r--framework/Web/UI/ActiveControls/TActiveRatingList.php125
-rw-r--r--framework/Web/UI/ActiveControls/TActiveTextBox.php8
-rw-r--r--framework/Web/UI/ActiveControls/TCallback.php8
13 files changed, 269 insertions, 18 deletions
diff --git a/framework/Web/UI/ActiveControls/TActiveButton.php b/framework/Web/UI/ActiveControls/TActiveButton.php
index 030361fb..62027264 100644
--- a/framework/Web/UI/ActiveControls/TActiveButton.php
+++ b/framework/Web/UI/ActiveControls/TActiveButton.php
@@ -55,6 +55,14 @@ class TActiveButton extends TButton implements ICallbackEventHandler, IActiveCon
}
/**
+ * @return TCallbackClientSide client side request options.
+ */
+ public function getClientSide()
+ {
+ return $this->getAdapter()->getBaseActiveControl()->getClientSide();
+ }
+
+ /**
* Raises the callback event. This method is required by {@link
* ICallbackEventHandler} interface. If {@link getCausesValidation
* CausesValidation} is true, it will invoke the page's {@link TPage::
diff --git a/framework/Web/UI/ActiveControls/TActiveCheckBox.php b/framework/Web/UI/ActiveControls/TActiveCheckBox.php
index 7cf5c005..2f60d9fb 100644
--- a/framework/Web/UI/ActiveControls/TActiveCheckBox.php
+++ b/framework/Web/UI/ActiveControls/TActiveCheckBox.php
@@ -53,6 +53,14 @@ class TActiveCheckBox extends TCheckBox implements ICallbackEventHandler, IActiv
}
/**
+ * @return TCallbackClientSide client side request options.
+ */
+ public function getClientSide()
+ {
+ return $this->getAdapter()->getBaseActiveControl()->getClientSide();
+ }
+
+ /**
* Raises the callback event. This method is required by {@link
* ICallbackEventHandler} interface.
* This method is mainly used by framework and control developers.
diff --git a/framework/Web/UI/ActiveControls/TActiveCheckBoxList.php b/framework/Web/UI/ActiveControls/TActiveCheckBoxList.php
index b18d0d0d..09ad9236 100644
--- a/framework/Web/UI/ActiveControls/TActiveCheckBoxList.php
+++ b/framework/Web/UI/ActiveControls/TActiveCheckBoxList.php
@@ -57,6 +57,14 @@ class TActiveCheckBoxList extends TCheckBoxList implements IActiveControl, ICall
}
/**
+ * @return TCallbackClientSide client side request options.
+ */
+ public function getClientSide()
+ {
+ return $this->getAdapter()->getBaseActiveControl()->getClientSide();
+ }
+
+ /**
* @return string javascript client-side control class name.
*/
protected function getClientClassName()
diff --git a/framework/Web/UI/ActiveControls/TActiveCustomValidator.php b/framework/Web/UI/ActiveControls/TActiveCustomValidator.php
index 686149eb..0a6b7b84 100644
--- a/framework/Web/UI/ActiveControls/TActiveCustomValidator.php
+++ b/framework/Web/UI/ActiveControls/TActiveCustomValidator.php
@@ -10,6 +10,8 @@
* @package System.Web.UI.ActiveControls
*/
+Prado::using('System.Web.UI.ActiveControls.TCallbackClientSide');
+
/**
* TActiveCustomValidator Class
*
@@ -55,6 +57,7 @@ class TActiveCustomValidator extends TCustomValidator
{
parent::__construct();
$this->setAdapter(new TActiveControlAdapter($this));
+ $this->getActiveControl()->setClientSide(new TActiveCustomValidatorClientSide);
}
/**
@@ -66,6 +69,14 @@ class TActiveCustomValidator extends TCustomValidator
}
/**
+ * @return TCallbackClientSide client side request options.
+ */
+ public function getClientSide()
+ {
+ return $this->getAdapter()->getBaseActiveControl()->getClientSide();
+ }
+
+ /**
* Client validation function is NOT supported.
*/
public function setClientValidationFunction($value)
@@ -131,4 +142,67 @@ class TActiveCustomValidator extends TCustomValidator
}
}
+/**
+ * Custom Validator callback client side options class.
+ *
+ * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
+ * @version $Id$
+ * @package System.Web.UI.ActiveControls
+ * @since 3.1
+ */
+class TActiveCustomValidatorClientSide extends TCallbackClientSide
+{
+ /**
+ * @return string javascript code for client-side OnValidate event.
+ */
+ public function getOnValidate()
+ {
+ return $this->getOption('OnValidate');
+ }
+
+ /**
+ * Client-side OnValidate validator event is raise before the validators
+ * validation functions are called.
+ * @param string javascript code for client-side OnValidate event.
+ */
+ public function setOnValidate($javascript)
+ {
+ $this->setFunction('OnValidate', $javascript);
+ }
+
+ /**
+ * Client-side OnError event is raised after validation failure.
+ * This will override the default client-side validator behaviour.
+ * @param string javascript code for client-side OnError event.
+ */
+ public function setOnError($javascript)
+ {
+ $this->setFunction('OnError', $javascript);
+ }
+
+ /**
+ * @return string javascript code for client-side OnError event.
+ */
+ public function getOnError()
+ {
+ return $this->getOption('OnError');
+ }
+
+ /**
+ * @param boolean true to revalidate when the control to validate changes value.
+ */
+ public function setObserveChanges($value)
+ {
+ $this->setOption('ObserveChanges', TPropertyValue::ensureBoolean($value));
+ }
+
+ /**
+ * @return boolean true to observe changes.
+ */
+ public function getObserveChanges()
+ {
+ $changes = $this->getOption('ObserveChanges');
+ return is_null($changes) ? true : $changes;
+ }
+}
?> \ No newline at end of file
diff --git a/framework/Web/UI/ActiveControls/TActiveDropDownList.php b/framework/Web/UI/ActiveControls/TActiveDropDownList.php
index c628e98c..215b1e5a 100644
--- a/framework/Web/UI/ActiveControls/TActiveDropDownList.php
+++ b/framework/Web/UI/ActiveControls/TActiveDropDownList.php
@@ -59,6 +59,14 @@ class TActiveDropDownList extends TDropDownList implements ICallbackEventHandler
}
/**
+ * @return TCallbackClientSide client side request options.
+ */
+ public function getClientSide()
+ {
+ return $this->getAdapter()->getBaseActiveControl()->getClientSide();
+ }
+
+ /**
* No client class for this control.
* This method overrides the parent implementation.
* @return null no javascript class name.
diff --git a/framework/Web/UI/ActiveControls/TActiveImageButton.php b/framework/Web/UI/ActiveControls/TActiveImageButton.php
index fe4cb385..bb20793e 100644
--- a/framework/Web/UI/ActiveControls/TActiveImageButton.php
+++ b/framework/Web/UI/ActiveControls/TActiveImageButton.php
@@ -47,6 +47,14 @@ class TActiveImageButton extends TImageButton implements IActiveControl, ICallba
}
/**
+ * @return TCallbackClientSide client side request options.
+ */
+ public function getClientSide()
+ {
+ return $this->getAdapter()->getBaseActiveControl()->getClientSide();
+ }
+
+ /**
* Sets the alternative text to be displayed in the TImage when the image is unavailable.
* @param string the alternative text
*/
diff --git a/framework/Web/UI/ActiveControls/TActiveLinkButton.php b/framework/Web/UI/ActiveControls/TActiveLinkButton.php
index 30c62723..8b86d11a 100644
--- a/framework/Web/UI/ActiveControls/TActiveLinkButton.php
+++ b/framework/Web/UI/ActiveControls/TActiveLinkButton.php
@@ -50,6 +50,14 @@ class TActiveLinkButton extends TLinkButton implements IActiveControl, ICallback
}
/**
+ * @return TCallbackClientSide client side request options.
+ */
+ public function getClientSide()
+ {
+ return $this->getAdapter()->getBaseActiveControl()->getClientSide();
+ }
+
+ /**
* Raises the callback event. This method is required by {@link
* ICallbackEventHandler} interface. If {@link getCausesValidation
* CausesValidation} is true, it will invoke the page's {@link TPage::
diff --git a/framework/Web/UI/ActiveControls/TActiveListBox.php b/framework/Web/UI/ActiveControls/TActiveListBox.php
index e433fa09..21816961 100644
--- a/framework/Web/UI/ActiveControls/TActiveListBox.php
+++ b/framework/Web/UI/ActiveControls/TActiveListBox.php
@@ -43,6 +43,14 @@ class TActiveListBox extends TListBox implements IActiveControl, ICallbackEventH
}
/**
+ * @return TCallbackClientSide client side request options.
+ */
+ public function getClientSide()
+ {
+ return $this->getAdapter()->getBaseActiveControl()->getClientSide();
+ }
+
+ /**
* Creates a collection object to hold list items. A specialized
* TActiveListItemCollection is created to allow the drop down list options
* to be added.
diff --git a/framework/Web/UI/ActiveControls/TActiveRadioButton.php b/framework/Web/UI/ActiveControls/TActiveRadioButton.php
index fe26165c..425cf1c7 100644
--- a/framework/Web/UI/ActiveControls/TActiveRadioButton.php
+++ b/framework/Web/UI/ActiveControls/TActiveRadioButton.php
@@ -52,6 +52,14 @@ class TActiveRadioButton extends TRadioButton implements IActiveControl, ICallba
}
/**
+ * @return TCallbackClientSide client side request options.
+ */
+ public function getClientSide()
+ {
+ return $this->getAdapter()->getBaseActiveControl()->getClientSide();
+ }
+
+ /**
* Raises the callback event. This method is required by {@link
* ICallbackEventHandler} interface.
* This method is mainly used by framework and control developers.
diff --git a/framework/Web/UI/ActiveControls/TActiveRadioButtonList.php b/framework/Web/UI/ActiveControls/TActiveRadioButtonList.php
index f971228f..0eb3f83a 100644
--- a/framework/Web/UI/ActiveControls/TActiveRadioButtonList.php
+++ b/framework/Web/UI/ActiveControls/TActiveRadioButtonList.php
@@ -52,6 +52,14 @@ class TActiveRadioButtonList extends TRadioButtonList implements IActiveControl,
}
/**
+ * @return TCallbackClientSide client side request options.
+ */
+ public function getClientSide()
+ {
+ return $this->getAdapter()->getBaseActiveControl()->getClientSide();
+ }
+
+ /**
* @return string javascript client-side control class name.
*/
protected function getClientClassName()
diff --git a/framework/Web/UI/ActiveControls/TActiveRatingList.php b/framework/Web/UI/ActiveControls/TActiveRatingList.php
index 1ce49a0c..ec8eee46 100644
--- a/framework/Web/UI/ActiveControls/TActiveRatingList.php
+++ b/framework/Web/UI/ActiveControls/TActiveRatingList.php
@@ -1,9 +1,35 @@
<?php
+/**
+ * TActiveRatingList class file.
+ *
+ * @author Wei Zhuo <weizhuo[at]gamil[dot]com>
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright &copy; 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Id$
+ * @package System.Web.UI.ActiveControls
+ */
+/**
+ * TActiveRatingList Class
+ *
+ * Displays clickable images that represent a TActiveRadioButtonList
+ *
+ * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
+ * @version $Id$
+ * @package System.Web.UI.ActiveControls
+ * @since 3.1
+ */
class TActiveRatingList extends TActiveRadioButtonList
{
+ /**
+ * @var array list of published rating images.
+ */
private $_ratingImages = array();
+ /**
+ * Sets the default repeat direction to horizontal.
+ */
public function __construct()
{
parent::__construct();
@@ -18,6 +44,19 @@ class TActiveRatingList extends TActiveRadioButtonList
return $this->getViewState('ReadOnly',false);
}
+ /**
+ * @param boolean whether the items in the column can be edited
+ */
+ public function setReadOnly($value)
+ {
+ $this->setViewState('ReadOnly',TPropertyValue::ensureBoolean($value),false);
+ }
+
+ /**
+ * The repeat layout must be Table.
+ * @param string repeat layout type
+ * @throws TInvaliddataValueException when repeat layout is not Table.
+ */
public function setRepeatLayout($value)
{
if($value!==TRepeatLayout::Table)
@@ -27,23 +66,24 @@ class TActiveRatingList extends TActiveRadioButtonList
}
/**
- * @param boolean whether the items in the column can be edited
+ * @return float rating value for read-only display.
*/
- public function setReadOnly($value)
- {
- $this->setViewState('ReadOnly',TPropertyValue::ensureBoolean($value),false);
- }
-
public function getRating()
{
return $this->getViewState('Rating',0);
}
+ /**
+ * @param float rating value for read-only display.
+ */
public function setRating($value)
{
$this->setViewState('Rating', TPropertyValue::ensureFloat($value),0);
}
+ /**
+ * @param int change the rating selection index
+ */
public function setSelectedIndex($value)
{
$canUpdate = $this->getActiveControl()->getEnableUpdate();
@@ -54,6 +94,11 @@ class TActiveRatingList extends TActiveRadioButtonList
$this->callClientFunction('setRating',$value);
}
+ /**
+ * Calls the client-side static method for this control class.
+ * @param string static method name
+ * @param mixed method parmaeter
+ */
protected function callClientFunction($func,$value)
{
$client = $this->getPage()->getCallbackClient();
@@ -62,7 +107,7 @@ class TActiveRatingList extends TActiveRadioButtonList
}
/**
- * @return string caption text.
+ * @return string control or html element ID for displaying a caption.
*/
public function getCaptionID()
{
@@ -70,13 +115,16 @@ class TActiveRatingList extends TActiveRadioButtonList
}
/**
- * @param string caption text
+ * @param string control or html element ID for displaying a caption.
*/
public function setCaptionID($value)
{
$this->setViewState('CaptionID', $value, '');
}
+ /**
+ * @param boolean true to enable the rating to be changed.
+ */
public function setEnabled($value)
{
parent::setEnabled($value);
@@ -85,7 +133,7 @@ class TActiveRatingList extends TActiveRadioButtonList
}
/**
- * @param string set the rating style
+ * @param string set the rating style, default is "default"
*/
public function setRatingStyle($value)
{
@@ -100,22 +148,36 @@ class TActiveRatingList extends TActiveRadioButtonList
return $this->getViewState('RatingStyle', 'default');
}
- public function setHalfRatingLimit($value)
+ /**
+ * Sets the interval such that those rating values within the interval
+ * will be considered as a half star rating.
+ * @param array rating display half value interval, default is array(0.3, 0.7);
+ */
+ public function setHalfRatingInterval($value)
{
$this->setViewState('HalfRating',
TPropertyValue::ensureArray($value), array(0.3, 0.7));
}
- public function getHalfRatingLimit()
+ /**
+ * @return array rating display half value interval, default is array(0.3, 0.7);
+ */
+ public function getHalfRatingInterval()
{
return $this->getViewState('HalfRating', array(0.3, 0.7));
}
+ /**
+ * @return string rating style css class name.
+ */
protected function getRatingStyleCssClass()
{
return 'TRatingList_'.$this->getRatingStyle();
}
+ /**
+ * @return array list of post back options.
+ */
protected function getPostBackOptions()
{
$options = parent::getPostBackOptions();
@@ -126,7 +188,8 @@ class TActiveRatingList extends TActiveRadioButtonList
}
/**
- * Registers the javascript code for initializing the active control.
+ * Registers the javascript code for initializing the active control
+ * only if {@link setReadOnly ReadOnly} property is false.
*/
protected function renderClientControlScript($writer)
{
@@ -134,6 +197,9 @@ class TActiveRatingList extends TActiveRadioButtonList
parent::renderClientControlScript($writer);
}
+ /**
+ * @return string find the client ID of the caption control.
+ */
protected function getCaptionControl()
{
if(($id=$this->getCaptionID())!=='')
@@ -149,6 +215,10 @@ class TActiveRatingList extends TActiveRadioButtonList
return '';
}
+ /**
+ * @param string rating style name
+ * @return string URL of the css style file
+ */
protected function publishRatingListStyle($style)
{
$cs = $this->getPage()->getClientScript();
@@ -161,7 +231,12 @@ class TActiveRatingList extends TActiveRadioButtonList
return $url;
}
- protected function publishRatingListImages($style, $fileExt='.png')
+ /**
+ * @param string rating style name
+ * @param string rating image file extension, default is '.gif'
+ * @return array URL of publish the rating images
+ */
+ protected function publishRatingListImages($style, $fileExt='.gif')
{
$images['blank'] = "System.Web.Javascripts.ratings.{$style}_blank";
$images['selected'] = "System.Web.Javascripts.ratings.{$style}_selected";
@@ -177,18 +252,21 @@ class TActiveRatingList extends TActiveRadioButtonList
return $files;
}
+ /**
+ * Add rating style class name to the class attribute
+ * when {@link setReadOnly ReadOnly} property is true and when the
+ * {@link setCssClass CssClass} property is empty.
+ * @param THtmlWriter renderer
+ */
public function render($writer)
{
if($this->getReadOnly())
- {
$writer->addAttribute('class', $this->getRatingStyleCssClass());
- $writer->addAttribute('title', $this->getRating());
- }
parent::render($writer);
}
/**
- * @param THtmlWriter writer
+ * Publish the the rating style css file and rating image files.
*/
public function onPreRender($param)
{
@@ -198,6 +276,10 @@ class TActiveRatingList extends TActiveRadioButtonList
$this->_ratingImages = $this->publishRatingListImages($this->getRatingStyle());
}
+ /**
+ * Renders the rating images if {@link setReadOnly ReadOnly} is true
+ * otherwise render the radio buttons.
+ */
public function renderItem($writer,$repeatInfo,$itemType,$index)
{
if($this->getReadOnly())
@@ -206,6 +288,9 @@ class TActiveRatingList extends TActiveRadioButtonList
parent::renderItem($writer, $repeatInfo, $itemType, $index);
}
+ /**
+ * Renders the static rating images.
+ */
protected function renderStaticRating($writer, $repeatInfo, $itemType, $index)
{
$image = new TImage;
@@ -214,11 +299,15 @@ class TActiveRatingList extends TActiveRadioButtonList
$image->render($writer);
}
+ /**
+ * @param integer rating image index
+ * @return string the rating image corresponding to current index to be rendered.
+ */
protected function getRatingImageType($index)
{
$rating = floatval($this->getRating());
$int = intval($rating);
- $limit = $this->getHalfRatingLimit();
+ $limit = $this->getHalfRatingInterval();
if($index < $int || ($rating < $index+1 && $rating > $index+$limit[1]))
return 'selected';
if($rating >= $index+$limit[0] && $rating <= $index+$limit[1])
diff --git a/framework/Web/UI/ActiveControls/TActiveTextBox.php b/framework/Web/UI/ActiveControls/TActiveTextBox.php
index bee97dbb..8e6c86dd 100644
--- a/framework/Web/UI/ActiveControls/TActiveTextBox.php
+++ b/framework/Web/UI/ActiveControls/TActiveTextBox.php
@@ -51,6 +51,14 @@ class TActiveTextBox extends TTextBox implements ICallbackEventHandler, IActiveC
}
/**
+ * @return TCallbackClientSide client side request options.
+ */
+ public function getClientSide()
+ {
+ return $this->getAdapter()->getBaseActiveControl()->getClientSide();
+ }
+
+ /**
* Client-side Text property can only be updated after the OnLoad stage.
* @param string text content for the textbox
*/
diff --git a/framework/Web/UI/ActiveControls/TCallback.php b/framework/Web/UI/ActiveControls/TCallback.php
index b7444127..60bdaf10 100644
--- a/framework/Web/UI/ActiveControls/TCallback.php
+++ b/framework/Web/UI/ActiveControls/TCallback.php
@@ -62,6 +62,14 @@ class TCallback extends TControl implements ICallbackEventHandler, IActiveContro
}
/**
+ * @return TCallbackClientSide client side request options.
+ */
+ public function getClientSide()
+ {
+ return $this->getAdapter()->getBaseActiveControl()->getClientSide();
+ }
+
+ /**
* Raises the callback event. This method is required by {@link
* ICallbackEventHandler} interface. If {@link getCausesValidation
* ActiveControl.CausesValidation} is true, it will invoke the page's {@link TPage::