From 18fd558413d5dec2bd074030a5c6bf111965c0c0 Mon Sep 17 00:00:00 2001 From: xue <> Date: Tue, 8 May 2007 15:59:13 +0000 Subject: fixed #601. --- framework/Web/UI/WebControls/TImageMap.php | 79 ++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) (limited to 'framework/Web/UI') 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 @@ -488,6 +488,80 @@ abstract class THotSpot extends TComponent $this->setViewState('Target',TPropertyValue::ensureString($value),''); } + /** + * @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(); } -- cgit v1.2.3