/**
  * @see BBCode::getParsedTag()
  */
 public function getParsedTag($openingTag, $content, $closingTag, BBCodeParser $parser)
 {
     if (StringUtil::indexOf($content, '[*]') !== false) {
         // get list elements
         $listElements = preg_split('/\\[\\*\\]/', StringUtil::trim($content), -1, PREG_SPLIT_NO_EMPTY);
         // remove empty elements
         foreach ($listElements as $key => $val) {
             $listElements[$key] = StringUtil::trim($val);
             if (empty($listElements[$key]) || $listElements[$key] == '<br />') {
                 unset($listElements[$key]);
             }
         }
         if (count($listElements) > 0) {
             // get list style type
             $listType = 'disc';
             if (isset($openingTag['attributes'][0])) {
                 $listType = $openingTag['attributes'][0];
             }
             $listType = strtolower($listType);
             // replace old types
             if ($listType == '1') {
                 $listType = 'decimal';
             }
             if ($listType == 'a') {
                 $listType = 'lower-latin';
             }
             if ($parser->getOutputType() == 'text/html') {
                 // build list html
                 $listHTML = 'ol';
                 if ($listType == 'none' || $listType == 'circle' || $listType == 'square' || $listType == 'disc') {
                     $listHTML = 'ul';
                 }
                 return '<' . $listHTML . ' style="list-style-type: ' . $listType . '"><li>' . implode('</li><li>', $listElements) . '</li></' . $listHTML . '>';
             } else {
                 if ($parser->getOutputType() == 'text/plain') {
                     $result = '';
                     $i = 1;
                     foreach ($listElements as $listElement) {
                         switch ($listType) {
                             case 'decimal':
                                 $result .= $i . '. ';
                                 break;
                             default:
                                 $result .= '- ';
                         }
                         $result .= $listElement . "\n";
                         $i++;
                     }
                     return $result;
                 }
             }
         }
     }
     // no valid list
     // return bbcode as text
     return $openingTag['source'] . $content . $closingTag['source'];
 }
 /**
  * @see BBCode::getParsedTag()
  */
 public function getParsedTag($openingTag, $content, $closingTag, BBCodeParser $parser)
 {
     if ($parser->getOutputType() == 'text/html') {
         // show template
         WCF::getTPL()->assign(array('content' => $content, 'spoilerTitle' => !empty($openingTag['attributes'][0]) ? $openingTag['attributes'][0] : ''));
         return WCF::getTPL()->fetch('spoilerBBCodeTag');
     } else {
         if ($parser->getOutputType() == 'text/plain') {
             return "[SPOILER]\n";
         }
     }
 }
 /**
  * @see BBCode::getParsedTag()
  */
 public function getParsedTag($openingTag, $content, $closingTag, BBCodeParser $parser)
 {
     if ($parser->getOutputType() == 'text/html') {
         // encode html
         $content = self::trim($content);
         $content = StringUtil::encodeHTML($content);
         // show template
         WCF::getTPL()->assign(array('lineNumbers' => $this->makeLineNumbers($content, $this->getLineNumbersStart($openingTag)), 'content' => $content, 'codeBoxName' => WCF::getLanguage()->get('wcf.bbcode.code.title')));
         return WCF::getTPL()->fetch('codeBBCodeTag');
     } else {
         if ($parser->getOutputType() == 'text/plain') {
             return WCF::getLanguage()->get('wcf.bbcode.code.text', array('$content' => $content));
         }
     }
 }
 /**
  * @see BBCode::getParsedTag()
  */
 public function getParsedTag($openingTag, $content, $closingTag, BBCodeParser $parser)
 {
     if ($parser->getOutputType() == 'text/html') {
         // show template
         WCF::getTPL()->assign(array('content' => $content, 'quoteLink' => !empty($openingTag['attributes'][1]) ? $openingTag['attributes'][1] : '', 'quoteAuthor' => !empty($openingTag['attributes'][0]) ? $openingTag['attributes'][0] : ''));
         return WCF::getTPL()->fetch('quoteBBCodeTag');
     } else {
         if ($parser->getOutputType() == 'text/plain') {
             $cite = '';
             if (!empty($openingTag['attributes'][0])) {
                 $cite = WCF::getLanguage()->get('wcf.bbcode.quote.cite.text', array('$name' => $openingTag['attributes'][0]));
             }
             return WCF::getLanguage()->get('wcf.bbcode.quote.text', array('$content' => $content, '$cite' => $cite));
         }
     }
 }
 /**
  * @see BBCode::getParsedTag()
  */
 public function getParsedTag($openingTag, $content, $closingTag, BBCodeParser $parser)
 {
     if (WCF::getUser()->getPermission('user.message.canUseBBCodeThreadClosed')) {
         if ($parser->getOutputType() == 'text/html') {
             // show template
             WCF::getTPL()->assign(array('content' => $content));
             return WCF::getTPL()->fetch('threadclosedBBCodeTag');
         } else {
             if ($parser->getOutputType() == 'text/plain') {
                 return $content;
             }
         }
     } else {
         return false;
     }
 }
 /**
  * @see BBCode::getParsedTag()
  */
 public function getParsedTag($openingTag, $content, $closingTag, BBCodeParser $parser)
 {
     $url = '';
     if (isset($openingTag['attributes'][0])) {
         $url = $openingTag['attributes'][0];
     }
     $noTitle = $content == $url;
     // add protocol if necessary
     if (!preg_match("/[a-z]:\\/\\//si", $url)) {
         $url = 'http://' . $url;
     }
     if ($parser->getOutputType() == 'text/html') {
         $external = true;
         if (($newURL = $this->isInternalURL($url)) !== false) {
             $url = $newURL;
             $external = false;
         }
         // cut visible url
         if ($noTitle) {
             $decodedContent = StringUtil::decodeHTML($content);
             if (StringUtil::length($decodedContent) > 60) {
                 $content = StringUtil::encodeHTML(StringUtil::substring($decodedContent, 0, 40)) . '&hellip;' . StringUtil::encodeHTML(StringUtil::substring($decodedContent, -15));
             }
         } else {
             $content = StringUtil::trim($content);
         }
         return '<a href="' . $url . '"' . ($external ? ' class="externalURL"' : '') . '>' . $content . '</a>';
     } else {
         if ($parser->getOutputType() == 'text/plain') {
             if ($noTitle) {
                 return $url;
             }
             return $content . ': ' . $url;
         }
     }
 }
 /**
  * @see BBCode::getParsedTag()
  */
 public function getParsedTag($openingTag, $content, $closingTag, BBCodeParser $parser)
 {
     if (self::$messageID == 0 && !isset(self::$attachments[self::$messageID]) && count(self::$attachments) == 1) {
         // get first message id
         $keys = array_keys(self::$attachments);
         self::$messageID = reset($keys);
     }
     if (isset($openingTag['attributes'][0])) {
         $attachmentID = $openingTag['attributes'][0];
         if (isset(self::$attachments[self::$messageID]['images'][$attachmentID])) {
             // image
             $attachment = self::$attachments[self::$messageID]['images'][$attachmentID];
             if ($parser->getOutputType() == 'text/html') {
                 $align = isset($openingTag['attributes'][1]) ? $openingTag['attributes'][1] : '';
                 $result = '<img src="index.php?page=Attachment&amp;attachmentID=' . $attachmentID . ($attachment->thumbnailType ? '&amp;thumbnail=1' : '') . '&amp;embedded=1" alt="" class="embeddedAttachment" style="width: ' . ($attachment->thumbnailType ? $attachment->getThumbnailWidth() : $attachment->getWidth()) . 'px; height: ' . ($attachment->thumbnailType ? $attachment->getThumbnailHeight() : $attachment->getHeight()) . 'px;' . (!empty($align) ? ' float:' . StringUtil::encodeHTML($align) . '; margin: ' . ($align == 'left' ? '0 15px 7px 0' : '0 0 7px 15px') : '') . '" />';
                 if ($attachment->thumbnailType) {
                     $result = '<a href="index.php?page=Attachment&amp;attachmentID=' . $attachmentID . '" class="enlargable">' . $result . '</a>';
                 }
                 return $result;
             } else {
                 if ($parser->getOutputType() == 'text/plain') {
                     return ($content != $attachmentID ? $content : $attachment->attachmentName) . ': ' . PAGE_URL . '/index.php?page=Attachment&attachmentID=' . $attachmentID . ($attachment->thumbnailType ? '&thumbnail=1' : '');
                 }
             }
         } else {
             if (isset(self::$attachments[self::$messageID]['files'][$attachmentID])) {
                 // file
                 $attachment = self::$attachments[self::$messageID]['files'][$attachmentID];
                 if ($parser->getOutputType() == 'text/html') {
                     return '<a href="index.php?page=Attachment&amp;attachmentID=' . $attachmentID . '">' . (!empty($content) && $content != $attachmentID ? $content : StringUtil::encodeHTML($attachment->attachmentName)) . '</a>';
                 } else {
                     if ($parser->getOutputType() == 'text/plain') {
                         return ($content != $attachmentID ? $content : $attachment->attachmentName) . ': ' . PAGE_URL . '/index.php?page=Attachment&attachmentID=' . $attachmentID;
                     }
                 }
             }
         }
     }
     if ($parser->getOutputType() == 'text/html') {
         return '<a href="index.php?page=Attachment&amp;attachmentID=' . $attachmentID . '">index.php?page=Attachment&amp;attachmentID=' . $attachmentID . '</a>';
     } else {
         if ($parser->getOutputType() == 'text/plain') {
             return PAGE_URL . '/index.php?page=Attachment&attachmentID=' . $attachmentID;
         }
     }
 }