/** * Gets the HTML for the image * @param string $src The URL to the image * @param integer $width The width in pixels * @param integer $height The height in pixels * @param string $alt The alternative text for the image * @return string The HTML of the image */ private function getImageHtml($src, $width = 0, $height = 0, $alt = null) { $image = new Image($src); if ($width) { $image->setAttribute('width', $width); } if ($height) { $image->setAttribute('height', $height); } if ($alt) { $image->setAttribute('alt', $alt); } return $image->getHtml(); }
public function getHtml() { $html = parent::getHtml(); $id = $this->getId(); $ep = $this->getEmoticonParser(); if ($ep) { $emoticons = $ep->getEmoticons(); $toolbar = '<div id="' . $id . 'EmoticonToolbar" class="bbcodeToolbar">'; $images = array(); foreach ($emoticons as $emoticon => $image) { if (in_array($image, $images)) { continue; } $images[] = $image; $image = new Image($image); $image->setAttribute('alt', $emoticon); $image->setAttribute('title', $emoticon); $emoticon = addslashes($emoticon); $toolbar .= '<a href="#" onclick="return bbcodeAdd(\'' . $id . "', ' " . $emoticon . '\');">'; $toolbar .= $image->getHtml(); $toolbar .= '</a> '; } $toolbar .= '</div>'; $html = $toolbar . $html; } $toolbar = '<div id="' . $id . 'BBCodeToolbar" class="bbcodeToolbar">'; foreach ($this->bbcode as $code => $bbcode) { $open = $bbcode['open']; if (isset($bbcode['close'])) { $close = $bbcode['close']; } else { $close = false; } $image = new Image($bbcode['image']); $image->setAttribute('alt', $code); $image->setAttribute('title', $code); if (!$close) { $toolbar .= '<a href="#" onclick="return bbcodeAdd(\'' . $id . "', '" . $open . '\');">'; } else { $toolbar .= '<a href="#" onclick="return bbcodeAdd(\'' . $id . "', '" . $open . "', '" . $close . '\');">'; } $toolbar .= $image->getHtml(); $toolbar .= '</a> '; } $toolbar .= '</div>'; $html = $toolbar . $html; return $html; }
function smarty_function_image($params, &$smarty) { try { if (empty($params['src'])) { throw new Exception('No src parameter provided for the image'); } $src = $params['src']; unset($params['src']); $image = new Image($src); if (!empty($params['thumbnail'])) { if (empty($params['width'])) { throw new Exception('No width parameter provided for the thumbnailer'); } if (empty($params['height'])) { throw new Exception('No height parameter provided for the thumbnailer'); } $image->setThumbnailer($params['thumbnail'], $params['width'], $params['height']); unset($params['thumbnail']); unset($params['width']); unset($params['height']); } foreach ($params as $key => $value) { $image->setAttribute($key, $value); } $html = $image->getHtml(); } catch (Exception $exception) { Zibo::getInstance()->runEvent(Zibo::EVENT_LOG, $exception->getMessage(), $exception->getTraceAsString(), 1); $html = '<span class="red" style="color: red;">Could not load image: ' . $exception->getMessage() . '</span>'; } return $html; }
/** * Gets the HTML of the localized image * @return string The HTML of the localized image */ private function getLocalizedImageHtml() { if ($this->localizedImage) { return $this->localizedImage; } $translator = I18n::getInstance()->getTranslator(); $image = new Image(self::IMAGE_LOCALIZED); $image->setAttribute('title', $translator->translate(self::TRANSLATION_LOCALIZED)); $this->localizedImage = $image->getHtml(); return $this->localizedImage; }