[ Index ]
 

Code source de PRADO 3.0.6

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/framework/Web/UI/WebControls/ -> THyperLink.php (source)

   1  <?php
   2  /**
   3   * THyperLink class file.
   4   *
   5   * @author Qiang Xue <qiang.xue@gmail.com>
   6   * @link http://www.xisc.com/
   7   * @copyright Copyright &copy; 2004-2005, Qiang Xue
   8   * @license http://www.opensource.org/licenses/bsd-license.php BSD License
   9   * @version $Id: THyperLink.php 1397 2006-09-07 07:55:53Z wei $
  10   * @package System.Web.UI.WebControls
  11   */
  12  
  13  /**
  14   * THyperLink class
  15   *
  16   * THyperLink displays a hyperlink on a page. The hyperlink URL is specified
  17   * via the {@link setNavigateUrl NavigateUrl} property, and link text is via
  18   * the {@link setText Text} property. It is also possible to display an image
  19   * by setting the {@link setImageUrl ImageUrl} property. In this case,
  20   * {@link getText Text} is displayed as the alternate text of the image.
  21   * The link target is specified via the {@link setTarget Target} property.
  22   * If both {@link getImageUrl ImageUrl} and {@link getText Text} are empty,
  23   * the content enclosed within the control tag will be rendered.
  24   *
  25   * @author Qiang Xue <qiang.xue@gmail.com>
  26   * @version $Id: THyperLink.php 1397 2006-09-07 07:55:53Z wei $
  27   * @package System.Web.UI.WebControls
  28   * @since 3.0
  29   */
  30  class THyperLink extends TWebControl
  31  {
  32      /**
  33       * @return string tag name of the hyperlink
  34       */
  35  	protected function getTagName()
  36      {
  37          return 'a';
  38      }
  39  
  40      /**
  41       * Adds attributes related to a hyperlink element to renderer.
  42       * @param THtmlWriter the writer used for the rendering purpose
  43       */
  44  	protected function addAttributesToRender($writer)
  45      {
  46          $isEnabled=$this->getEnabled(true);
  47          if($this->getEnabled() && !$isEnabled)
  48              $writer->addAttribute('disabled','disabled');
  49          parent::addAttributesToRender($writer);
  50          if(($url=$this->getNavigateUrl())!=='' && $isEnabled)
  51              $writer->addAttribute('href',$url);
  52          if(($target=$this->getTarget())!=='')
  53              $writer->addAttribute('target',$target);
  54      }
  55  
  56      /**
  57       * Renders the body content of the hyperlink.
  58       * @param THtmlWriter the writer for rendering
  59       */
  60  	public function renderContents($writer)
  61      {
  62          if(($imageUrl=$this->getImageUrl())==='')
  63          {
  64              if(($text=$this->getText())!=='')
  65                  $writer->write(THttpUtility::htmlEncode($text));
  66              else
  67                  parent::renderContents($writer);
  68          }
  69          else
  70          {
  71              $image=Prado::createComponent('System.Web.UI.WebControls.TImage');
  72              $image->setImageUrl($imageUrl);
  73              if(($toolTip=$this->getToolTip())!=='')
  74                  $image->setToolTip($toolTip);
  75              if(($text=$this->getText())!=='')
  76                  $image->setAlternateText($text);
  77              $image->renderControl($writer);
  78          }
  79      }
  80  
  81      /**
  82       * @return string the text caption of the THyperLink
  83       */
  84  	public function getText()
  85      {
  86          return $this->getViewState('Text','');
  87      }
  88  
  89      /**
  90       * Sets the text caption of the THyperLink.
  91       * @param string the text caption to be set
  92       */
  93  	public function setText($value)
  94      {
  95          $this->setViewState('Text',$value,'');
  96      }
  97  
  98      /**
  99       * @return string the location of the image file for the THyperLink
 100       */
 101  	public function getImageUrl()
 102      {
 103          return $this->getViewState('ImageUrl','');
 104      }
 105  
 106      /**
 107       * Sets the location of image file of the THyperLink.
 108       * @param string the image file location
 109       */
 110  	public function setImageUrl($value)
 111      {
 112          $this->setViewState('ImageUrl',$value,'');
 113      }
 114  
 115      /**
 116       * @return string the URL to link to when the THyperLink component is clicked.
 117       */
 118  	public function getNavigateUrl()
 119      {
 120          return $this->getViewState('NavigateUrl','');
 121      }
 122  
 123      /**
 124       * Sets the URL to link to when the THyperLink component is clicked.
 125       * @param string the URL
 126       */
 127  	public function setNavigateUrl($value)
 128      {
 129          $this->setViewState('NavigateUrl',$value,'');
 130      }
 131  
 132      /**
 133       * @return string the target window or frame to display the Web page content linked to when the THyperLink component is clicked.
 134       */
 135  	public function getTarget()
 136      {
 137          return $this->getViewState('Target','');
 138      }
 139  
 140      /**
 141       * Sets the target window or frame to display the Web page content linked to when the THyperLink component is clicked.
 142       * @param string the target window, valid values include '_blank', '_parent', '_self', '_top' and empty string.
 143       */
 144  	public function setTarget($value)
 145      {
 146          $this->setViewState('Target',$value,'');
 147      }
 148  }
 149  
 150  ?>


Généré le : Sun Feb 25 21:07:04 2007 par Balluche grâce à PHPXref 0.7