TImage displays an image on a page. The image is specified via the
{@link setImageUrl ImageUrl} property which takes a relative or absolute
URL to the image file. The alignment of the image displayed is set by
the {@link setImageAlign ImageAlign} property. To set alternative texts
or long description of the image, use {@link setAlternateText AlternateText}
or {@link setDescriptionUrl DescriptionUrl} property, respectively.
/** * Renders this imagemap. * @param THtmlWriter */ public function render($writer) { parent::render($writer); $hotspots = $this->getHotSpots(); if ($hotspots->getCount() > 0) { $clientID = $this->getClientID(); $cs = $this->getPage()->getClientScript(); $writer->writeLine(); $writer->addAttribute('name', self::MAP_NAME_PREFIX . $clientID); $writer->renderBeginTag('map'); $writer->writeLine(); if (($mode = $this->getHotSpotMode()) === THotSpotMode::NotSet) { $mode = THotSpotMode::Navigate; } $target = $this->getTarget(); $i = 0; $options['EventTarget'] = $this->getUniqueID(); $options['StopEvent'] = true; $cs = $this->getPage()->getClientScript(); foreach ($hotspots as $hotspot) { if ($hotspot->getHotSpotMode() === THotSpotMode::NotSet) { $hotspot->setHotSpotMode($mode); } if ($target !== '' && $hotspot->getTarget() === '') { $hotspot->setTarget($target); } if ($hotspot->getHotSpotMode() === THotSpotMode::PostBack) { $id = $clientID . '_' . $i; $writer->addAttribute('id', $id); $writer->addAttribute('href', '#' . $id); //create unique no-op url references $options['ID'] = $id; $options['EventParameter'] = "{$i}"; $options['CausesValidation'] = $hotspot->getCausesValidation(); $options['ValidationGroup'] = $hotspot->getValidationGroup(); $cs->registerPostBackControl($this->getClientClassName(), $options); } $hotspot->render($writer); $writer->writeLine(); $i++; } $writer->renderEndTag(); } }
/** * Registers the image button to receive postback data during postback. * This is necessary because an image button, when postback, does not have * direct mapping between post data and the image button name. * This method overrides the parent implementation and is invoked before render. * @param mixed event parameter */ public function onPreRender($param) { parent::onPreRender($param); $this->getPage()->registerRequiresPostData($this); }
/** * Configures the image URL that shows the token. * @param mixed event parameter */ public function onPreRender($param) { parent::onPreRender($param); if (!self::checkRequirements()) { throw new TConfigurationException('captcha_imagettftext_required'); } if (!$this->getViewState('TokenGenerated', 0)) { $manager = $this->getApplication()->getAssetManager(); $manager->publishFilePath($this->getFontFile()); $url = $manager->publishFilePath($this->getCaptchaScriptFile()); $url .= '?options=' . urlencode($this->getTokenImageOptions()); $this->setImageUrl($url); $this->setViewState('TokenGenerated', time()); } }
/** * @param string the URL to the long description of the image. */ public function setDescriptionUrl($value) { if (parent::getDescriptionUrl() === $value) { return; } parent::setDescriptionUrl($value); if ($this->getActiveControl()->canUpdateClientSide()) { $this->getPage()->getCallbackClient()->setAttribute($this, 'longdesc', $value); } }
/** * 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(' '); } } } 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(' '); } } } } }
/** * 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; }