From e0c9de073cce5b5c9975694c03e2dbe63788bd66 Mon Sep 17 00:00:00 2001 From: xue <> Date: Sat, 29 Jul 2006 14:43:53 +0000 Subject: Merge from 3.0 branch till 1305. --- framework/Web/UI/WebControls/TRadioButton.php | 84 ++++++++++++++++++--------- 1 file changed, 57 insertions(+), 27 deletions(-) (limited to 'framework/Web/UI/WebControls/TRadioButton.php') diff --git a/framework/Web/UI/WebControls/TRadioButton.php b/framework/Web/UI/WebControls/TRadioButton.php index 244244cb..9b6786aa 100644 --- a/framework/Web/UI/WebControls/TRadioButton.php +++ b/framework/Web/UI/WebControls/TRadioButton.php @@ -67,6 +67,10 @@ class TRadioButton extends TCheckBox * @var integer global ID of this radiobutton */ private $_globalID; + /** + * @var string previous UniqueID (used to calculate UniqueGroup) + */ + private $_previousUniqueID=null; /** * @var string the name used to fetch radiobutton post data */ @@ -140,12 +144,64 @@ class TRadioButton extends TCheckBox } /** - * Sets the name of the group that the radio button belongs to + * Sets the name of the group that the radio button belongs to. + * The group is unique among the control's naming container. * @param string the group name + * @see setUniqueGroupName */ public function setGroupName($value) { $this->setViewState('GroupName',$value,''); + $this->_uniqueGroupName=null; + } + + /** + * @return string the name used to fetch radiobutton post data + */ + public function getUniqueGroupName() + { + if(($groupName=$this->getViewState('UniqueGroupName',''))!=='') + return $groupName; + else if(($uniqueID=$this->getUniqueID())!==$this->_previousUniqueID || $this->_uniqueGroupName===null) + { + $groupName=$this->getGroupName(); + $this->_previousUniqueID=$uniqueID; + if($uniqueID!=='') + { + if(($pos=strrpos($uniqueID,TControl::ID_SEPARATOR))!==false) + { + if($groupName!=='') + $groupName=substr($uniqueID,0,$pos+1).$groupName; + else if($this->getNamingContainer() instanceof TRadioButtonList) + $groupName=substr($uniqueID,0,$pos); + } + if($groupName==='') + $groupName=$uniqueID; + } + $this->_uniqueGroupName=$groupName; + } + return $this->_uniqueGroupName; + } + + /** + * Sets the unique group name that the radio button belongs to. + * A unique group is a radiobutton group unique among the whole page hierarchy, + * while the {@link setGroupName GroupName} specifies a group that is unique + * among the control's naming container only. + * For example, each cell of a {@link TDataGrid} is a naming container. + * If you specify {@link setGroupName GroupName} for a radiobutton in a cell, + * it groups together radiobutton within a cell, but not the other, even though + * they have the same {@link setGroupName GroupName}. + * On the contratry, if {@link setUniqueGroupName UniqueGroupName} is used instead, + * it will group all appropriate radio buttons on the whole page hierarchy. + * Note, when both {@link setUniqueGroupName UniqueGroupName} and + * {@link setGroupName GroupName}, the former takes precedence. + * @param string the group name + * @see setGroupName + */ + public function setUniqueGroupName($value) + { + $this->setViewState('UniqueGroupName',$value,''); } /** @@ -177,32 +233,6 @@ class TRadioButton extends TCheckBox return $value; } - /** - * @return string the name used to fetch radiobutton post data - */ - private function getUniqueGroupName() - { - if($this->_uniqueGroupName===null) - { - $groupName=$this->getGroupName(); - $uniqueID=$this->getUniqueID(); - if($uniqueID!=='') - { - if(($pos=strrpos($uniqueID,TControl::ID_SEPARATOR))!==false) - { - if($groupName!=='') - $groupName=substr($uniqueID,0,$pos+1).$groupName; - else if($this->getNamingContainer() instanceof TRadioButtonList) - $groupName=substr($uniqueID,0,$pos); - } - if($groupName==='') - $groupName=$uniqueID; - } - $this->_uniqueGroupName=$groupName; - } - return $this->_uniqueGroupName; - } - /** * Renders a radiobutton input element. * @param THtmlWriter the writer for the rendering purpose -- cgit v1.2.3