diff options
author | xue <> | 2007-05-08 15:59:13 +0000 |
---|---|---|
committer | xue <> | 2007-05-08 15:59:13 +0000 |
commit | 18fd558413d5dec2bd074030a5c6bf111965c0c0 (patch) | |
tree | 85cfd34dec57bf3eeb487d8d1afac987c4a78551 /framework/Web/UI | |
parent | 17a2a8440f7ecd5756456528f584424acae27957 (diff) |
fixed #601.
Diffstat (limited to 'framework/Web/UI')
-rw-r--r-- | framework/Web/UI/WebControls/TImageMap.php | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/framework/Web/UI/WebControls/TImageMap.php b/framework/Web/UI/WebControls/TImageMap.php index c5041205..875a8ae0 100644 --- a/framework/Web/UI/WebControls/TImageMap.php +++ b/framework/Web/UI/WebControls/TImageMap.php @@ -489,6 +489,80 @@ abstract class THotSpot extends TComponent }
/**
+ * @return boolean whether the hotspot has custom attributes
+ */
+ public function getHasAttributes()
+ {
+ if($attributes=$this->getViewState('Attributes',null))
+ return $attributes->getCount()>0;
+ else
+ return false;
+ }
+
+ /**
+ * Returns the list of custom attributes.
+ * Custom attributes are name-value pairs that may be rendered
+ * as HTML tags' attributes.
+ * @return TAttributeCollection the list of custom attributes
+ */
+ public function getAttributes()
+ {
+ if($attributes=$this->getViewState('Attributes',null))
+ return $attributes;
+ else
+ {
+ $attributes=new TAttributeCollection;
+ $this->setViewState('Attributes',$attributes,null);
+ return $attributes;
+ }
+ }
+
+ /**
+ * @return boolean whether the named attribute exists
+ */
+ public function hasAttribute($name)
+ {
+ if($attributes=$this->getViewState('Attributes',null))
+ return $attributes->contains($name);
+ else
+ return false;
+ }
+
+ /**
+ * @return string attribute value, null if attribute does not exist
+ */
+ public function getAttribute($name)
+ {
+ if($attributes=$this->getViewState('Attributes',null))
+ return $attributes->itemAt($name);
+ else
+ return null;
+ }
+
+ /**
+ * Sets a custom hotspot attribute.
+ * @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, null if attribute does not exist.
+ */
+ public function removeAttribute($name)
+ {
+ if($attributes=$this->getViewState('Attributes',null))
+ return $attributes->remove($name);
+ else
+ return null;
+ }
+
+ /**
* Renders this hotspot.
* @param THtmlWriter
*/
@@ -513,6 +587,11 @@ abstract class THotSpot extends TComponent $writer->addAttribute('accesskey',$accessKey);
if(($tabIndex=$this->getTabIndex())!==0)
$writer->addAttribute('tabindex',"$tabIndex");
+ if($this->getHasAttributes())
+ {
+ foreach($this->getAttributes() as $name=>$value)
+ $writer->addAttribute($name,$value);
+ }
$writer->renderBeginTag('area');
$writer->renderEndTag();
}
|