summaryrefslogtreecommitdiff
path: root/framework/Web/UI/WebControls
diff options
context:
space:
mode:
authorxue <>2006-07-16 01:50:23 +0000
committerxue <>2006-07-16 01:50:23 +0000
commitaf68030fcf0c266300feb2c100149ecadef7d364 (patch)
tree76b7c8ad5d8227870b9ef10c3e7b92a36336b320 /framework/Web/UI/WebControls
parent4b78404c20490a615459267426ce9e6737bf4485 (diff)
Merge from 3.0 branch till 1264.
Diffstat (limited to 'framework/Web/UI/WebControls')
-rw-r--r--framework/Web/UI/WebControls/TCheckBox.php2
-rw-r--r--framework/Web/UI/WebControls/TClientScript.php42
-rw-r--r--framework/Web/UI/WebControls/TCustomValidator.php10
-rw-r--r--framework/Web/UI/WebControls/TRadioButton.php66
-rw-r--r--framework/Web/UI/WebControls/TTextHighlighter.php2
5 files changed, 38 insertions, 84 deletions
diff --git a/framework/Web/UI/WebControls/TCheckBox.php b/framework/Web/UI/WebControls/TCheckBox.php
index 04733f95..c938950d 100644
--- a/framework/Web/UI/WebControls/TCheckBox.php
+++ b/framework/Web/UI/WebControls/TCheckBox.php
@@ -143,7 +143,7 @@ class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatabl
*/
public function setValue($value)
{
- $this->setViewState('Value',$value,'');
+ $this->setViewState('Value',TPropertyValue::ensureString($value),'');
}
/**
diff --git a/framework/Web/UI/WebControls/TClientScript.php b/framework/Web/UI/WebControls/TClientScript.php
index 88f7f7d4..ff236c42 100644
--- a/framework/Web/UI/WebControls/TClientScript.php
+++ b/framework/Web/UI/WebControls/TClientScript.php
@@ -31,11 +31,6 @@
* Contents within TClientScript will be treated as javascript code and will be
* rendered in place.
*
- * The {@link setPreRenderControlTypes PreRenderControlTypes} property can
- * be used to specify that controls type/class names that should pre-render itself
- * even though they may not be rendered on the page. This is useful to publish
- * controls that require assets and is only visible after a callback response.
- *
* @author Wei Zhuo <weizhuo[at]gmail[dot]com>
* @version $Revision: $ $Date: $
* @package System.Web.UI.WebControls
@@ -82,23 +77,6 @@ class TClientScript extends TControl
}
/**
- * @param string comma delimited list of controls that wish to be prerendered
- * so as to publish its assets.
- */
- public function setPreRenderControlTypes($value)
- {
- $this->setViewState('PreRenderControls', $value);
- }
-
- /**
- * @return string comma delimited list of controls types that require prerendering.
- */
- public function getPreRenderControlTypes()
- {
- return $this->getViewState('PreRenderControls', '');
- }
-
- /**
* Calls the client script manager to add each of the requested client
* script libraries.
* @param mixed event parameter
@@ -113,7 +91,6 @@ class TClientScript extends TControl
if(($script = trim($script))!=='')
$cs->registerPradoScript($script);
}
- $this->preRenderControls($param);
}
/**
@@ -151,25 +128,6 @@ class TClientScript extends TControl
$writer->write("\n/*]]>*/\n</script>\n");
}
}
-
- /**
- * PreRender other controls to allow them to publish their assets. Useful
- * when callback response components that require assets to be present on the page.
- * @param mixed event paramater
- */
- protected function preRenderControls($param)
- {
- $types = preg_split('/,|\s+/', $this->getPreRenderControlTypes());
- foreach($types as $type)
- {
- if(strlen($type))
- {
- $control = Prado::createComponent(trim($type));
- $control->setPage($this->getPage());
- $control->onPreRender($param);
- }
- }
- }
}
?>
diff --git a/framework/Web/UI/WebControls/TCustomValidator.php b/framework/Web/UI/WebControls/TCustomValidator.php
index 32510f89..2afa48dc 100644
--- a/framework/Web/UI/WebControls/TCustomValidator.php
+++ b/framework/Web/UI/WebControls/TCustomValidator.php
@@ -120,6 +120,16 @@ class TCustomValidator extends TBaseValidator
$options['ClientValidationFunction']=$clientJs;
return $options;
}
+
+ /**
+ * Only register the client-side validator if
+ * {@link setClientValidationFunction ClientValidationFunction} is set.
+ */
+ protected function registerClientScriptValidator()
+ {
+ if($this->getClientValidationFunction()!=='')
+ parent::registerClientScriptValidator();
+ }
}
/**
diff --git a/framework/Web/UI/WebControls/TRadioButton.php b/framework/Web/UI/WebControls/TRadioButton.php
index 974a431c..244244cb 100644
--- a/framework/Web/UI/WebControls/TRadioButton.php
+++ b/framework/Web/UI/WebControls/TRadioButton.php
@@ -56,39 +56,44 @@ Prado::using('System.Web.UI.WebControls.TRadioButtonList');
class TRadioButton extends TCheckBox
{
/**
- * @param array list of radio buttons registered.
+ * @param array list of radio buttons that are on the current page hierarchy
*/
- private static $_radiobuttons=array();
+ private static $_activeButtons=array();
/**
- * @var string the name used to fetch radiobutton post data
+ * @var integer number of radio buttons created
*/
- private $_uniqueGroupName=null;
+ private static $_buttonCount=0;
/**
- * @var int number radio buttons created
+ * @var integer global ID of this radiobutton
*/
- private static $_counter=0;
+ private $_globalID;
/**
- * @var int unique unmutable radio button id
+ * @var string the name used to fetch radiobutton post data
*/
- private $_radioUid;
+ private $_uniqueGroupName=null;
+ /**
+ * Constructor.
+ * Registers the radiobutton in a global radiobutton collection.
+ * If overridden, the parent implementation must be invoked first.
+ */
public function __construct()
{
parent::__construct();
- $this->_radioUid = self::$_counter++;
+ $this->_globalID = self::$_buttonCount++;
}
-
+
/**
- * Registers the radio button groupings. If overriding onInit method,
+ * Registers the radio button groupings. If overriding onInit method,
* ensure to call parent implemenation.
* @param TEventParameter event parameter to be passed to the event handlers
*/
public function onInit($param)
{
parent::onInit($param);
- $this->registerRadioButton($this);
+ self::$_activeButtons[$this->_globalID]=$this;
}
-
+
/**
* Unregisters the radio button groupings. If overriding onInit method,
* ensure to call parent implemenation.
@@ -96,10 +101,10 @@ class TRadioButton extends TCheckBox
*/
public function onUnLoad($param)
{
+ unset(self::$_activeButtons[$this->_globalID]);
parent::onUnLoad($param);
- $this->unregisterRadioButton($this);
}
-
+
/**
* Loads user input data.
* This method is primarly used by framework developers.
@@ -142,42 +147,23 @@ class TRadioButton extends TCheckBox
{
$this->setViewState('GroupName',$value,'');
}
-
- /**
- * Register radio button control grouping.
- * @param TRadioButton control to add
- */
- protected function registerRadioButton(TRadioButton $control)
- {
- if(!isset(self::$_radiobuttons[$control->_radioUid]))
- self::$_radiobuttons[$control->_radioUid] = $control;
- }
-
+
/**
- * Unregister radio button control for grouping
- * @param TRadioButton control to unregister.
- */
- protected function unregisterRadioButton(TRadioButton $control)
- {
- if(isset(self::$_radiobuttons[$control->_radioUid]))
- unset(self::$_radiobuttons[$control->_radioUid]);
- }
-
- /**
- * Gets an array of RadioButtons with same group name. This method will
- * always return at least the current radio button in the array.
+ * Gets an array of radiobuttons whose group name is the same as this radiobutton's.
+ * Note, only those radiobuttons that are on the current page hierarchy may be
+ * returned in the result.
* @return array list of TRadioButton with the same group
*/
public function getRadioButtonsInGroup()
{
$group = $this->getUniqueGroupName();
$buttons = array();
- foreach(self::$_radiobuttons as $control)
+ foreach(self::$_activeButtons as $control)
{
if($control->getUniqueGroupName() === $group)
$buttons[] = $control;
}
- return count($buttons) > 0 ? $buttons : array($this);
+ return $buttons;
}
/**
diff --git a/framework/Web/UI/WebControls/TTextHighlighter.php b/framework/Web/UI/WebControls/TTextHighlighter.php
index a9ccf5bb..f4e72895 100644
--- a/framework/Web/UI/WebControls/TTextHighlighter.php
+++ b/framework/Web/UI/WebControls/TTextHighlighter.php
@@ -136,7 +136,7 @@ class TTextHighlighter extends TTextProcessor
$geshi->enable_classes();
if($this->getEnableCopyCode())
$geshi->set_header_content($this->getHeaderTemplate());
-
+
return $geshi->parse_code();
}