Пример #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;');
                 }
             }
         }
     }
 }