/** * Constructs a new namespace decorator * @param string $action URL where the link behind the namespace name will point to. The name of the namespace will be concatted to this URL * @return null */ public function __construct($action) { $this->action = $action; $this->translator = I18n::getInstance()->getTranslator(); $image = new Image(ModuleNamespace::ICON); $this->image = $image->getHtml(); }
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; }
/** * Decorates a cell which contains an Advertisement object * @param zibo\library\html\table\Cell $cell * @param zibo\library\html\table\Row $row * @param int $rowNumber * @param array $remainingValues * @return null */ public function decorate(Cell $cell, Row $row, $rowNumber, array $remainingValues) { $advertisement = $cell->getValue(); if (!$advertisement instanceof AdvertisementData) { return; } $cell->appendToClass('advertisement'); try { $image = new Image($advertisement->image); $image->appendToClass('data'); $image->setThumbnailer('crop', 50, 50); $value = $image->getHtml(); } catch (Exception $e) { $value = 'Could not load image: ' . $e->getMessage(); } $anchor = new Anchor($advertisement->name, $this->action . $advertisement->id); $value .= $anchor->getHtml(); if (!$advertisement->clicks) { $advertisement->clicks = '0'; } $translateParams = array('from' => $this->locale->formatDate($advertisement->dateStart), 'till' => $this->locale->formatDate($advertisement->dateStop), 'clicks' => $advertisement->clicks); $value .= '<div class="info">'; $value .= $advertisement->website . '<br />'; $value .= $this->translator->translate(self::TRANSLATION_DISPLAY, $translateParams) . '<br />'; $value .= $this->translator->translate(self::TRANSLATION_CLICKS, $translateParams); $value .= '</div>'; $cell->setValue($value); }
/** * Decorates the cell with a order handle for the category * @param zibo\library\html\table\Cell $cell * @param zibo\library\html\table\Row $row * @param integer $rowNumber * @param array $remainingValues * @return null */ public function decorate(Cell $cell, Row $row, $rowNumber, array $remainingValues) { $data = $cell->getValue(); $row->setId('data_' . $data->id); $cell->appendToClass('action'); $image = new Image(self::IMAGE_HANDLE); $image->appendToClass('handle'); $cell->setValue($image->getHtml()); }
/** * 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; }
public function getStarsHtml() { if ($this->stars) { $image = new Image(ForumRankingModel::STAR); $star = $image->getHtml(); } $html = ''; for ($i = 0; $i < $this->stars; $i++) { $html .= $star; } return $html; }
/** * Decorates the cell * @param zibo\library\html\table\Cell $cell Cell of the value to decorate * @param zibo\library\html\table\Row $row Row containing the cell * @param int $rowNumber Number of the current row * @param array $remainingValues Array containing the values of the remaining rows of the table * @return null */ public function decorate(Cell $cell, Row $row, $rowNumber, array $remainingValues) { $field = $cell->getValue(); if (!$field instanceof ModelField) { return; } $row->setId('field_' . $field->getName()); $cell->appendToClass('action'); $image = new Image(self::IMAGE_HANDLE); $image->appendToClass('handle'); $cell->setValue($image->getHtml()); }
/** * 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; }
/** * Gets the HTML for the image of the data * @param mixed $data * @return string */ private function getImageHtml($data) { $modelTable = $this->meta->getModelTable(); if (!$modelTable->hasDataFormat(DataFormatter::FORMAT_IMAGE)) { return ''; } $image = $this->meta->formatData($data, DataFormatter::FORMAT_IMAGE); if ($image) { $image = new Image($image); } else { $image = new Image($this->defaultImage); } $image->setThumbnailer('crop', 50, 50); $image->appendToClass(self::STYLE_IMAGE); return $image->getHtml(); }
/** * Get the HTML of a node * @param joppa\model\Node $node the node to render * @param int $defaultNodeId id of the node of the default page * @param joppa\model\Node $selectedNode the current node in the ui * @param boolean $addUnlocalizedClass Set to true to add the unlocalized class to nodes which are not localized in the current locale * @param int $truncateSize number of characters to truncate the name to * @return string HTML representation of the node */ private function getNodeHtml(Node $node, $defaultNodeId, $addUnlocalizedClass, Node $selectedNode = null, $truncateSize = 20) { $isNodeSelected = false; if ($selectedNode && $selectedNode->id == $node->id) { $isNodeSelected = true; } $nodeClass = 'node'; if ($isNodeSelected) { $nodeClass .= ' selected'; } if ($addUnlocalizedClass) { if ($node->dataLocale != $this->locale) { $nodeClass .= ' unlocalized'; } else { $nodeClass .= ' localized'; } } if (AjaxTreeController::isNodeCollapsed($node->id)) { $nodeClass .= ' closed'; } $html = '<li class="' . $nodeClass . '" id="node_' . $node->id . '">'; if ($this->nodeTypeFacade->isAvailableInFrontend($node->type)) { if ($node->isSecured()) { $nodeClass = 'secured' . ucfirst($node->type); } else { $nodeClass = $node->type; } if ($node->id == $defaultNodeId) { $nodeClass .= 'Default'; } if (!$node->isPublished()) { $nodeClass .= 'Hidden'; } } else { $nodeClass = $node->type; } if ($node->children) { $html .= '<a href="#" class="toggle"></a>'; } else { $html .= '<span class="toggle"></span>'; } $icon = new Image($this->getIcon($nodeClass)); $html .= '<div class="handle ' . $nodeClass . '">'; $html .= $icon->getHtml(); $html .= '</div>'; $html .= '<div class="menu">'; $html .= $this->getAnchorHtml('/node/' . $node->id, String::truncate($node->name, $truncateSize, '...', true, true), false, 'name', null, $node->name); $html .= $this->getAnchorHtml('#', ' ', false, 'actionMenuNode', 'nodeActions_' . $node->id); // $html .= $this->getAnchorHtml(' <a href="#" class="actionMenuNode" id="nodeActions_' . $node->id . '" title="' . $node->name . '"></a>'; // $html .= ' <a href="#" class="actionMenuNode" id="nodeActions_' . $node->id . '" title="' . $node->name . '"></a>'; $html .= '<ul class="actions" id="nodeActions_' . $node->id . 'Menu">'; $addedActions = false; foreach ($this->actions as $action) { if (!$action->isAvailableForNode($node)) { continue; } $addedActions = true; $html .= '<li>'; $html .= $this->getAnchorHtml('/node/' . $action->getRoute() . '/' . $node->id, $action->getLabel($this->translator), false, $action->getRoute()); $html .= '</li>'; } $html .= '<li' . ($addedActions ? ' class="separator"' : '') . '>' . $this->getAnchorHtml('/node/edit/' . $node->id, 'button.edit', true, 'edit') . '</li>'; $html .= '<li>' . $this->getAnchorHtml('/node/copy/' . $node->id, 'joppa.button.copy', true, 'copy') . '</li>'; $html .= '<li>' . $this->getAnchorHtml('/node/delete/' . $node->id, 'button.delete', true, 'delete confirm') . '</li>'; $html .= '</ul>'; $html .= '</div>'; if ($node->children) { $html .= '<ul class="children">'; foreach ($node->children as $child) { $html .= $this->getNodeHtml($child, $defaultNodeId, $addUnlocalizedClass, $selectedNode, $truncateSize - 1); } $html .= '</ul>'; } $html .= '</li>'; return $html; }
/** * Optimizes the provided CSS source * @param string $source CSS source * @param zibo\library\filesystem\File $file The file of the source * @return string optimized and minified CSS source */ protected function optimizeSource($source, File $file) { $source = preg_replace(CSSMin::REGEX_IMPORT, '', $source); $source = $this->getCssMinifier()->minify($source, true); $zibo = Zibo::getInstance(); $parent = $file->getParent(); $source = preg_replace_callback('/url( )?\\(["\']?([^;\\\\"\')]*)(["\']?)\\)([^;\\)]*);/', function ($matches) use($zibo, $parent) { try { $source = new File($parent, $matches[2]); $source = $zibo->getRelativeFile($source); $source = $source->getPath(); } catch (ZiboException $e) { $zibo->runEvent(Zibo::EVENT_LOG, $e->getMessage(), $e->getTraceAsString()); $source = $matches[2]; } try { $image = new Image($source); $image->getHtml(); $source = $image->getSource(); } catch (ZiboException $e) { $zibo->runEvent(Zibo::EVENT_LOG, $e->getMessage(), $e->getTraceAsString()); } return "url(" . $source . ")" . $matches[4] . ';'; }, $source); return $source; }
/** * Gets a preview of the provided value * @param string $value Path to the current file * @return string HTML of the value */ protected function getPreviewHtml($value) { try { $file = new File($value); $image = new CoreImage($file); } catch (Exception $e) { return; } $image = new HtmlImage($value); $image->setThumbnailer(ThumbnailFactory::CROP, $this->previewWidth, $this->previewHeight); return '<span class="image">' . $image->getHtml() . '</span>'; }