/** * @see \wcf\system\bbcode\IBBCode::getParsedTag() */ public function getParsedTag(array $openingTag, $content, array $closingTag, BBCodeParser $parser) { $url = ''; if (isset($openingTag['attributes'][0])) { $url = $openingTag['attributes'][0]; } $noTitle = $content == $url; $url = StringUtil::decodeHTML($url); // add protocol if necessary if (!preg_match("/[a-z]:\\/\\//si", $url)) { $url = 'http://' . $url; } return StringUtil::getAnchorTag($url, !$noTitle ? $content : '', false); }
/** * @see \wcf\system\bbcode\IBBCode::getParsedTag() */ public function getParsedTag(array $openingTag, $content, array $closingTag, BBCodeParser $parser) { $content = StringUtil::trim($content); if ($parser->getOutputType() == 'text/html') { foreach (BBCodeMediaProvider::getCache() as $provider) { if ($provider->matches($content)) { return $provider->getOutput($content); } } } if ($parser->getOutputType() == 'text/simplified-html') { foreach (BBCodeMediaProvider::getCache() as $provider) { if ($provider->matches($content)) { return StringUtil::getAnchorTag($content); } } } return StringUtil::encodeHTML($content); }
/** * Returns the website as anchor tag. * * @return string */ public function getWebsiteAnchorTag() { return StringUtil::getAnchorTag($this->website); }
/** * Returns the link of this source. * @return string */ public function getLink() { return StringUtil::getAnchorTag($this->sourceLink); }
/** * @see \wcf\system\bbcode\IBBCode::getParsedTag() */ public function getParsedTag(array $openingTag, $content, array $closingTag, BBCodeParser $parser) { // get attachment id $attachmentID = 0; if (isset($openingTag['attributes'][0])) { $attachmentID = $openingTag['attributes'][0]; } // get embedded object $attachment = MessageEmbeddedObjectManager::getInstance()->getObject('com.woltlab.wcf.attachment', $attachmentID); if ($attachment === null) { if (self::$attachmentList !== null) { $attachments = self::$attachmentList->getGroupedObjects(self::$objectID); if (isset($attachments[$attachmentID])) { $attachment = $attachments[$attachmentID]; // mark attachment as embedded $attachment->markAsEmbedded(); } } } if ($attachment !== null) { if ($attachment->showAsImage() && $attachment->canViewPreview() && $parser->getOutputType() == 'text/html') { // image $alignment = isset($openingTag['attributes'][1]) ? $openingTag['attributes'][1] : ''; $width = isset($openingTag['attributes'][2]) ? $openingTag['attributes'][2] : 0; // check if width is valid and the original is accessible by viewer if ($width > 0) { if ($attachment->canDownload()) { // check if width exceeds image width if ($width > $attachment->width) { $width = $attachment->width; } } else { $width = 0; } } $result = ''; if ($width > 0) { $class = ''; if ($alignment == 'left' || $alignment == 'right') { $class = 'messageFloatObject' . ucfirst($alignment); } $source = StringUtil::encodeHTML(LinkHandler::getInstance()->getLink('Attachment', array('object' => $attachment))); $title = StringUtil::encodeHTML($attachment->filename); $result = '<a href="' . $source . '" title="' . $title . '" class="embeddedAttachmentLink jsImageViewer' . ($class ? ' ' . $class : '') . '"><img src="' . $source . '" style="width: ' . $width . 'px" alt="" /></a>'; } else { $linkParameters = array('object' => $attachment); if ($attachment->hasThumbnail()) { $linkParameters['thumbnail'] = 1; } $class = ''; if ($alignment == 'left' || $alignment == 'right') { $class = 'messageFloatObject' . ucfirst($alignment); } $imageClasses = ''; if (!$attachment->hasThumbnail()) { $imageClasses = 'embeddedAttachmentLink jsResizeImage'; } if ($class && (!$attachment->hasThumbnail() || !$attachment->canDownload())) { $imageClasses .= ' ' . $class; } $result = '<img src="' . StringUtil::encodeHTML(LinkHandler::getInstance()->getLink('Attachment', $linkParameters)) . '"' . ($imageClasses ? ' class="' . $imageClasses . '"' : '') . ' style="width: ' . ($attachment->hasThumbnail() ? $attachment->thumbnailWidth : $attachment->width) . 'px; height: ' . ($attachment->hasThumbnail() ? $attachment->thumbnailHeight : $attachment->height) . 'px;" alt="" />'; if ($attachment->hasThumbnail() && $attachment->canDownload()) { $result = '<a href="' . StringUtil::encodeHTML(LinkHandler::getInstance()->getLink('Attachment', array('object' => $attachment))) . '" title="' . StringUtil::encodeHTML($attachment->filename) . '" class="embeddedAttachmentLink jsImageViewer' . ($class ? ' ' . $class : '') . '">' . $result . '</a>'; } } return $result; } else { // file return StringUtil::getAnchorTag(LinkHandler::getInstance()->getLink('Attachment', array('object' => $attachment)), !empty($content) && $content != $attachmentID ? $content : $attachment->filename); } } // fallback return StringUtil::getAnchorTag(LinkHandler::getInstance()->getLink('Attachment', array('id' => $attachmentID))); }
/** * Reinserts cached URLs and e-mails. * * @param string $text * @return string */ protected function insertCachedURLs($text) { foreach ($this->cachedURLs as $hash => $url) { // add protocol if necessary if (!preg_match("/[a-z]:\\/\\//si", $url)) { $url = 'http://' . $url; } $text = str_replace($hash, StringUtil::getAnchorTag($url), $text); } foreach ($this->cachedEmails as $hash => $email) { $email = StringUtil::encodeHTML($email); $text = str_replace($hash, '<a href="mailto:' . $email . '">' . $email . '</a>', $text); } return $text; }
/** * @see \wcf\system\bbcode\IBBCode::getParsedTag() */ public function getParsedTag(array $openingTag, $content, array $closingTag, BBCodeParser $parser) { // call copyright TeraliosBBCodesCopyright::callCopyright(); // default values $attachmentID = 0; $float = 'none'; $type = 'default'; $link = ''; $text = ''; $isImage = false; // parameter values $attachmentID = isset($openingTag['attributes'][0]) ? intval($openingTag['attributes'][0]) : 0; $float = isset($openingTag['attributes'][1]) ? mb_strtolower($openingTag['attributes'][1]) : 'none'; switch ($float) { case 'left': case 'right': case 'none': break; default: $float = 'none'; } $text = StringUtil::trim($content); $title = WCF::getLanguage()->getDynamicVariable('wcf.bbcode.xattach.title', array('xaID' => $attachmentID)); // get attachment $attachment = MessageEmbeddedObjectManager::getInstance()->getObject('de.teralios.bbcodes.attachment', $attachmentID); if ($attachment === null) { if (static::$attachmentList !== null) { $attachments = static::$attachmentList->getGroupedObjects(static::$objectID); if (isset($attachments[$attachmentID])) { $attachment = $attachments[$attachmentID]; $attachment->markAsEmbedded(); } } } // Attachment if ($attachment !== null) { $title = !empty($attachment->filename) ? WCF::getLanguage()->getDynamicVariable('wcf.bbcode.xattach.title.full', array('xaFilename' => $attachment->filename, 'xaDownloads' => $attachment->downloads)) : $title; $linkParameters = array('object' => $attachment); // can view image if ($attachment->showAsImage() && $attachment->canViewPreview()) { if ($attachment->hasThumbnail()) { $linkParameters['thumbnail'] = 1; } $isImage = true; $link = '<img src="' . StringUtil::encodeHTML(LinkHandler::getInstance()->getLink('Attachment', $linkParameters)) . '"' . (!$attachment->hasThumbnail() ? ' class="embeddedAttachmentLink jsResizeImage"' : '') . ' style="width: ' . ($attachment->hasThumbnail() ? $attachment->thumbnailWidth : $attachment->width) . 'px; height: ' . ($attachment->hasThumbnail() ? $attachment->thumbnailHeight : $attachment->height) . 'px" alt="" />'; if ($attachment->hasThumbnail() && $attachment->canDownload()) { $link = '<a href="' . StringUtil::encodeHTML(LinkHandler::getInstance()->getLink('Attachment', array('object' => $attachment))) . '" title="' . $title . '" class="embeddedAttachmentLink jsImageViewer">' . $link . '</a>'; } } else { if ($attachment->showAsImage()) { $link = StringUtil::encodeHTML(LinkHandler::getInstance()->getLink('Attachment', array('object' => $attachment))); $type = 'image'; } else { $link = StringUtil::encodeHTML(LinkHandler::getInstance()->getLink('Attachment', array('object' => $attachment))); $type = self::getType($attachment); } } } else { $link = StringUtil::encodeHTML(LinkHandler::getInstance()->getLink('Attachment', array('id' => $attachmentID))); } if ($parser->getOutputType() == 'text/html') { WCF::getTPL()->assign(array('xaLink' => $link, 'xaTitle' => $title, 'xaIcon' => self::choseIcon($type), 'xaIsImage' => $isImage, 'xaText' => $text, 'xaFloat' => $float, 'xaNoBorder' => BBCODES_XATTACH_FREESTYLE)); $result = WCF::getTPL()->fetch('xAttachBBCode'); } else { $result = StringUtil::getAnchorTag($link, $title) . (!empty($text) ? ' (' . $text . ')' : ''); } return $result; }