diff options
Diffstat (limited to 'framework/Web/UI/WebControls')
-rw-r--r-- | framework/Web/UI/WebControls/TListBox.php | 2 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TListControl.php | 65 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TRadioButton.php | 2 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TRepeatInfo.php | 4 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TWebControl.php | 4 |
5 files changed, 66 insertions, 11 deletions
diff --git a/framework/Web/UI/WebControls/TListBox.php b/framework/Web/UI/WebControls/TListBox.php index 7f47a49e..02e07013 100644 --- a/framework/Web/UI/WebControls/TListBox.php +++ b/framework/Web/UI/WebControls/TListBox.php @@ -130,7 +130,7 @@ class TListBox extends TListControl implements IPostBackDataHandler * Sets the selection mode of the component (Single, Multiple)
* @param string the selection mode
*/
- function setSelectionMode($value)
+ public function setSelectionMode($value)
{
$this->setViewState('SelectionMode',TPropertyValue::ensureEnum($value,array('Single','Multiple')),'Single');
}
diff --git a/framework/Web/UI/WebControls/TListControl.php b/framework/Web/UI/WebControls/TListControl.php index ec7df0c9..b32471fb 100644 --- a/framework/Web/UI/WebControls/TListControl.php +++ b/framework/Web/UI/WebControls/TListControl.php @@ -213,6 +213,11 @@ abstract class TListControl extends TDataBoundControl $this->setViewState('DataValueField',$value,'');
}
+ public function getHasItems()
+ {
+ return ($this->_items && $this->_items->getCount()>0);
+ }
+
public function getItems()
{
if(!$this->_items)
@@ -376,12 +381,18 @@ abstract class TListControl extends TDataBoundControl {
if($item->getEnabled())
{
- $str='<option';
if($item->getSelected())
- $str.=' selected="selected"';
- $str.=' value="'.THttpUtility::htmlEncode($item->getValue()).'"';
- $str.='>'.THttpUtility::htmlEncode($item->getText()).'</option>';
- $writer->writeLine($str);
+ $writer->addAttribute('selected','selected');
+ $writer->addAttribute('value',$item->getValue());
+ if($item->getHasAttributes())
+ {
+ foreach($item->getAttributes() as $name=>$value)
+ $writer->addAttribute($name,$value);
+ }
+ $writer->renderBeginTag('option');
+ $writer->write(THttpUtility::htmlEncode($item->getText()));
+ $writer->renderEndTag();
+ $writer->writeLine();
}
}
}
@@ -533,6 +544,50 @@ class TListItem extends TComponent {
$this->_value=TPropertyValue::ensureString($value);
}
+
+ public function getAttributes()
+ {
+ if(!$this->_attributes)
+ $this->_attributes=new TMap;
+ return $this->_attributes;
+ }
+
+ public function getHasAttributes()
+ {
+ return $this->_attributes!==null;
+ }
+
+ public function hasAttribute($name)
+ {
+ return $this->_attributes?$this->_attributes->contains($name):false;
+ }
+
+ /**
+ * @return string attribute value, '' if attribute does not exist
+ */
+ public function getAttribute($name)
+ {
+ return $this->_attributes?$this->_attributes->itemAt($name):null;
+ }
+
+ /**
+ * @param string attribute name
+ * @param string value of the attribute
+ */
+ public function setAttribute($name,$value)
+ {
+ $this->getAttributes()->add($name,$value);
+ }
+
+ /**
+ * Removes the named attribute.
+ * @param string the name of the attribute to be removed.
+ * @return string attribute value removed, empty string if attribute does not exist.
+ */
+ public function removeAttribute($name)
+ {
+ return $this->_attributes?$this->_attributes->remove($name):null;
+ }
}
?>
\ No newline at end of file diff --git a/framework/Web/UI/WebControls/TRadioButton.php b/framework/Web/UI/WebControls/TRadioButton.php index 85a28941..d7901ec8 100644 --- a/framework/Web/UI/WebControls/TRadioButton.php +++ b/framework/Web/UI/WebControls/TRadioButton.php @@ -128,7 +128,7 @@ class TRadioButton extends TCheckBox */
private function getValueAttribute()
{
- if(($value=$this->getAttribute('value'))==='')
+ if(($value=$this->getAttribute('value'))===null)
{
$value=$this->getID();
return empty($value)?$this->getUniqueID():$value;
diff --git a/framework/Web/UI/WebControls/TRepeatInfo.php b/framework/Web/UI/WebControls/TRepeatInfo.php index 414f5db9..ffb10c12 100644 --- a/framework/Web/UI/WebControls/TRepeatInfo.php +++ b/framework/Web/UI/WebControls/TRepeatInfo.php @@ -2,12 +2,12 @@ interface IRepeatInfoUser
{
- public function getItemStyle($itemType,$index);
- public function renderItem($writer,$repeatInfo,$itemType,$index);
public function getHasFooter();
public function getHasHeader();
public function getHasSeparators();
public function getRepeatedItemCount();
+ public function getItemStyle($itemType,$index);
+ public function renderItem($writer,$repeatInfo,$itemType,$index);
}
class TRepeatInfo extends TComponent
diff --git a/framework/Web/UI/WebControls/TWebControl.php b/framework/Web/UI/WebControls/TWebControl.php index e86b9161..8ef47ede 100644 --- a/framework/Web/UI/WebControls/TWebControl.php +++ b/framework/Web/UI/WebControls/TWebControl.php @@ -352,9 +352,9 @@ class TWebControl extends TControl $writer->addAttribute('title',$toolTip);
if($style=$this->getViewState('Style',null))
$style->addAttributesToRender($writer);
- if($attributes=$this->getViewState('Attributes',null))
+ if($this->getHasAttributes())
{
- foreach($attributes as $name=>$value)
+ foreach($this->getAttributes() as $name=>$value)
$writer->addAttribute($name,$value);
}
}
|