summaryrefslogtreecommitdiff
path: root/framework/Web/UI/WebControls/TListControl.php
diff options
context:
space:
mode:
Diffstat (limited to 'framework/Web/UI/WebControls/TListControl.php')
-rw-r--r--framework/Web/UI/WebControls/TListControl.php65
1 files changed, 60 insertions, 5 deletions
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