From f4c525abc3d4d3f3eecf1019770936e4ca39fd62 Mon Sep 17 00:00:00 2001 From: xue <> Date: Fri, 9 Feb 2007 22:48:31 +0000 Subject: added two item renderer demos. --- framework/Web/UI/WebControls/THyperLink.php | 36 +++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) (limited to 'framework/Web/UI/WebControls/THyperLink.php') diff --git a/framework/Web/UI/WebControls/THyperLink.php b/framework/Web/UI/WebControls/THyperLink.php index af28acef..13a9ab41 100644 --- a/framework/Web/UI/WebControls/THyperLink.php +++ b/framework/Web/UI/WebControls/THyperLink.php @@ -27,7 +27,7 @@ * @package System.Web.UI.WebControls * @since 3.0 */ -class THyperLink extends TWebControl +class THyperLink extends TWebControl implements IDataRenderer { /** * @return string tag name of the hyperlink @@ -63,16 +63,18 @@ class THyperLink extends TWebControl { if(($text=$this->getText())!=='') $writer->write(THttpUtility::htmlEncode($text)); - else + else if($this->getHasControls()) parent::renderContents($writer); + else + $writer->write(THttpUtility::htmlEncode($this->getNavigateUrl())); } else { $this->createImage($imageUrl)->renderControl($writer); } } - - /** + + /** * Gets the TImage for rendering the ImageUrl property. This is not for * creating dynamic images. * @param string image url. @@ -140,6 +142,32 @@ class THyperLink extends TWebControl $this->setViewState('NavigateUrl',$value,''); } + /** + * Returns the URL to link to when the THyperLink component is clicked. + * This method is required by {@link IDataRenderer}. + * It is the same as {@link getNavigateUrl()}. + * @return string the URL to link to when the THyperLink component is clicked + * @see getNavigateUrl + * @since 3.1.0 + */ + public function getData() + { + return $this->getNavigateUrl(); + } + + /** + * Sets the URL to link to when the THyperLink component is clicked. + * This method is required by {@link IDataRenderer}. + * It is the same as {@link setNavigateUrl()}. + * @param string the URL to link to when the THyperLink component is clicked + * @see setNavigateUrl + * @since 3.1.0 + */ + public function setData($value) + { + $this->setNavigateUrl($value); + } + /** * @return string the target window or frame to display the Web page content linked to when the THyperLink component is clicked. */ -- cgit v1.2.3