From 704dd5ead2bf3a6858bb07f1186183c84210d307 Mon Sep 17 00:00:00 2001 From: rojaro <> Date: Sun, 1 Nov 2009 21:19:12 +0000 Subject: Added ability to set width and height for images in both THyperLink and THyperLinkColumn (plus the imageurl for the latter) as suggested by junkee in http://www.pradosoft.com/forum/index.php?topic=8745.0 --- framework/Web/UI/WebControls/THyperLink.php | 40 +++++++++++++++- framework/Web/UI/WebControls/THyperLinkColumn.php | 58 ++++++++++++++++++++++- 2 files changed, 96 insertions(+), 2 deletions(-) (limited to 'framework') diff --git a/framework/Web/UI/WebControls/THyperLink.php b/framework/Web/UI/WebControls/THyperLink.php index 217fa267..d215cfe5 100644 --- a/framework/Web/UI/WebControls/THyperLink.php +++ b/framework/Web/UI/WebControls/THyperLink.php @@ -4,7 +4,7 @@ * * @author Qiang Xue * @link http://www.xisc.com/ - * @copyright Copyright © 2005-2008 PradoSoft + * @copyright Copyright © 2005-2008 PradoSoft * @license http://www.opensource.org/licenses/bsd-license.php BSD License * @version $Id$ * @package System.Web.UI.WebControls @@ -84,6 +84,10 @@ class THyperLink extends TWebControl implements IDataRenderer { $image=Prado::createComponent('System.Web.UI.WebControls.TImage'); $image->setImageUrl($imageUrl); + if(($width=$this->getImageWidth())!=='') + $image->setWidth($width); + if(($height=$this->getImageHeight())!=='') + $image->setHeight($height); if(($toolTip=$this->getToolTip())!=='') $image->setToolTip($toolTip); if(($text=$this->getText())!=='') @@ -109,6 +113,23 @@ class THyperLink extends TWebControl implements IDataRenderer $this->setViewState('Text',$value,''); } + /** + * @return string height of the image in the THyperLink + */ + public function getImageHeight() + { + return $this->getViewState('ImageHeight',''); + } + + /** + * Sets the height of the image in the THyperLink + * @param string height of the image in the THyperLink + */ + public function setImageHeight($value) + { + $this->setViewSTate('ImageHeight',$value,''); + } + /** * @return string the location of the image file for the THyperLink */ @@ -125,6 +146,23 @@ class THyperLink extends TWebControl implements IDataRenderer { $this->setViewState('ImageUrl',$value,''); } + + /** + * @return string width of the image in the THyperLink + */ + public function getImageWidth() + { + return $this->getViewState('ImageWidth',''); + } + + /** + * Sets the width of the image in the THyperLink + * @param string width of the image + */ + public function setImageWidth($value) + { + $this->setViewState('ImageWidth',$value,''); + } /** * @return string the URL to link to when the THyperLink component is clicked. diff --git a/framework/Web/UI/WebControls/THyperLinkColumn.php b/framework/Web/UI/WebControls/THyperLinkColumn.php index 7db6eda8..52ad7762 100644 --- a/framework/Web/UI/WebControls/THyperLinkColumn.php +++ b/framework/Web/UI/WebControls/THyperLinkColumn.php @@ -4,7 +4,7 @@ * * @author Qiang Xue * @link http://www.pradosoft.com/ - * @copyright Copyright © 2005-2008 PradoSoft + * @copyright Copyright © 2005-2008 PradoSoft * @license http://www.pradosoft.com/license/ * @version $Id$ * @package System.Web.UI.WebControls @@ -100,6 +100,54 @@ class THyperLinkColumn extends TDataGridColumn $this->setViewState('DataTextFormatString',$value,''); } + /** + * @return string height of the image in the THyperLink + */ + public function getImageHeight() + { + return $this->getViewState('ImageHeight',''); + } + + /** + * @param string height of the image in the THyperLink + */ + public function setImageHeight($value) + { + $this->setViewState('ImageHeight',$value,''); + } + + /** + * @return string url of the image in the THyperLink + */ + public function getImageUrl() + { + return $this->getViewState('ImageUrl',''); + } + + /** + * @param string url of the image in the THyperLink + */ + public function setImageUrl($value) + { + $this->setViewState('ImageUrl',$value,''); + } + + /** + * @return string width of the image in the THyperLink + */ + public function getImageWidth() + { + return $this->getViewState('ImageWidth',''); + } + + /** + * @param string width of the image in the THyperLink + */ + public function setImageWidth($value) + { + $this->setViewState('ImageWidth',$value,''); + } + /** * @return string the URL to link to when the hyperlink is clicked. */ @@ -179,6 +227,14 @@ class THyperLinkColumn extends TDataGridColumn if($itemType===TListItemType::Item || $itemType===TListItemType::AlternatingItem || $itemType===TListItemType::SelectedItem || $itemType===TListItemType::EditItem) { $link=new THyperLink; + if(($url = $this->getImageUrl())!=='') + { + $link->setImageUrl($url); + if(($width=$this->getImageWidth())!=='') + $link->setImageWidth($width); + if(($height=$this->getImageHeight())!=='') + $link->setImageHeight($height); + } $link->setText($this->getText()); $link->setNavigateUrl($this->getNavigateUrl()); $link->setTarget($this->getTarget()); -- cgit v1.2.3