setAlternateText() 공개 메소드

Sets the alternative text to be displayed in the TImage when the image is unavailable.
public setAlternateText ( $value )
예제 #1
0
 /**
  * Sets the alternative text to be displayed in the TImage when the image is unavailable.
  * @param string the alternative text
  */
 public function setAlternateText($value)
 {
     if (parent::getAlternateText() === $value) {
         return;
     }
     parent::setAlternateText($value);
     if ($this->getActiveControl()->canUpdateClientSide()) {
         $this->getPage()->getCallbackClient()->setAttribute($this, 'alt', $value);
     }
 }
예제 #2
0
 /**
  * Initializes the header cell.
  *
  * This method attempts to use {@link getHeaderRenderer HeaderRenderer} to
  * instantiate the header cell. If that is not available, it will populate
  * the cell with an image or a text string, depending on {@link getHeaderImageUrl HeaderImageUrl}
  * and {@link getHeaderText HeaderText} property values.
  *
  * If the column allows sorting, image or text will be created as
  * a button which issues <b>Sort</b> command upon user click.
  *
  * @param TTableCell the cell to be initialized
  * @param integer the index to the Columns property that the cell resides in.
  */
 protected function initializeHeaderCell($cell, $columnIndex)
 {
     $text = $this->getHeaderText();
     if (($classPath = $this->getHeaderRenderer()) !== '') {
         $control = Prado::createComponent($classPath);
         $cell->getControls()->add($control);
         if ($control instanceof \Prado\IDataRenderer) {
             if ($control instanceof IItemDataRenderer) {
                 $item = $cell->getParent();
                 $control->setItemIndex($item->getItemIndex());
                 $control->setItemType($item->getItemType());
             }
             $control->setData($text);
         }
     } else {
         if ($this->getAllowSorting()) {
             $sortExpression = $this->getSortExpression();
             if (($url = $this->getHeaderImageUrl()) !== '') {
                 $button = new TImageButton();
                 $button->setImageUrl($url);
                 $button->setCommandName(TDataGrid::CMD_SORT);
                 $button->setCommandParameter($sortExpression);
                 if ($text !== '') {
                     $button->setAlternateText($text);
                 }
                 $button->setCausesValidation(false);
                 $cell->getControls()->add($button);
             } else {
                 if ($text !== '') {
                     $button = new TLinkButton();
                     $button->setText($text);
                     $button->setCommandName(TDataGrid::CMD_SORT);
                     $button->setCommandParameter($sortExpression);
                     $button->setCausesValidation(false);
                     $cell->getControls()->add($button);
                 } else {
                     $cell->setText('&nbsp;');
                 }
             }
         } else {
             if (($url = $this->getHeaderImageUrl()) !== '') {
                 $image = new TImage();
                 $image->setImageUrl($url);
                 if ($text !== '') {
                     $image->setAlternateText($text);
                 }
                 $cell->getControls()->add($image);
             } else {
                 if ($text !== '') {
                     $cell->setText($text);
                 } else {
                     $cell->setText('&nbsp;');
                 }
             }
         }
     }
 }
예제 #3
0
 /**
  * Gets the TImage for rendering the ImageUrl property. This is not for
  * creating dynamic images.
  * @param string image url.
  * @return TImage image control for rendering.
  */
 protected function createImage($imageUrl)
 {
     $image = new 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()) !== '') {
         $image->setAlternateText($text);
     }
     if (($align = $this->getImageAlign()) !== '') {
         $image->setImageAlign($align);
     }
     $image->setBorderWidth('0');
     return $image;
 }