/**
  * Parses search keywords.
  * 
  * @param	string		$keywordString
  */
 protected static function parseKeywords($keywordString)
 {
     // convert encoding if necessary
     if (CHARSET == 'UTF-8' && !StringUtil::isASCII($keywordString) && !StringUtil::isUTF8($keywordString)) {
         $keywordString = StringUtil::convertEncoding('ISO-8859-1', 'UTF-8', $keywordString);
     }
     // remove bad wildcards
     $keywordString = preg_replace('/(?<!\\w)\\*/', '', $keywordString);
     // remove search operators
     $keywordString = preg_replace('/[\\+\\-><()~]+/', '', $keywordString);
     if (StringUtil::substring($keywordString, 0, 1) == '"' && StringUtil::substring($keywordString, -1) == '"') {
         // phrases search
         $keywordString = StringUtil::trim(StringUtil::substring($keywordString, 1, -1));
         if (!empty($keywordString)) {
             self::$keywords = array_merge(self::$keywords, array(StringUtil::encodeHTML($keywordString)));
         }
     } else {
         // replace word delimiters by space
         $keywordString = preg_replace('/[.,]/', ' ', $keywordString);
         $keywords = ArrayUtil::encodeHTML(ArrayUtil::trim(explode(' ', $keywordString)));
         if (count($keywords) > 0) {
             self::$keywords = array_merge(self::$keywords, $keywords);
         }
     }
 }
 /**
  * Returns the text of this post.
  *
  * @return 	string		the text of this post
  */
 public function getFormattedMessage()
 {
     // return message cache
     if ($this->messageCache) {
         return KeywordHighlighter::doHighlight($this->messageCache);
     }
     // parse message
     $parser = MessageParser::getInstance();
     $parser->setOutputType('text/html');
     AttachmentBBCode::setMessageID($this->postID);
     return $parser->parse($this->message, $this->enableSmilies, $this->enableHtml, $this->enableBBCodes, !$this->messagePreview);
 }
 /**
  * Formats a message for search result output.
  * 
  * @param	string		$text
  * @return	string
  */
 public static function parse($text)
 {
     // remove html codes
     $text = StringUtil::stripHTML($text);
     // decode html
     $text = StringUtil::decodeHTML($text);
     // get abstract
     $text = self::getMessageAbstract($text);
     // encode html
     $text = StringUtil::encodeHTML($text);
     // do highlighting
     return KeywordHighlighter::doHighlight($text);
 }
 /**
  * Gets the items for the current page.
  */
 protected function readItems()
 {
     for ($i = $this->startIndex - 1; $i < $this->endIndex; $i++) {
         // get item name
         $itemName = $this->result[$i];
         // get description
         $description = WCF::getLanguage()->getDynamicVariable('wcf.help.item.' . $itemName . '.description');
         // remove headlines
         $description = preg_replace('~<h4>.*?</h4>~', '', $description);
         // remove help images
         $description = preg_replace('~<p class="helpImage.*?</p>~s', '', $description);
         // add item
         $this->helpItems[] = array('item' => $itemName, 'title' => KeywordHighlighter::doHighlight(WCF::getLanguage()->get('wcf.help.item.' . $itemName)), 'description' => SearchResultTextParser::parse($description));
     }
 }
 /**
  * Parses a message.
  * 
  * @param	string		$message
  * @param	boolean		$enableSmilies
  * @param	boolean		$enableHtml
  * @param	boolean		$enableBBCodes
  * @return	string		parsed message
  */
 public function parse($message, $enableSmilies = true, $enableHtml = false, $enableBBCodes = true, $doKeywordHighlighting = true)
 {
     $this->cachedCodes = array();
     if ($this->getOutputType() != 'text/plain') {
         if ($enableBBCodes) {
             // cache codes
             $message = $this->cacheCodes($message);
         }
         if (!$enableHtml) {
             // encode html
             $message = StringUtil::encodeHTML($message);
             // converts newlines to <br />'s
             $message = nl2br($message);
         }
     }
     // parse bbcodes
     if ($enableBBCodes) {
         $message = parent::parse($message);
     }
     if ($this->getOutputType() != 'text/plain') {
         // parse smilies
         if ($enableSmilies) {
             $message = $this->parseSmilies($message, $enableHtml);
         }
         if ($enableBBCodes && count($this->cachedCodes) > 0) {
             // insert cached codes
             $message = $this->insertCachedCodes($message);
         }
         // highlight search query
         if ($doKeywordHighlighting) {
             $message = KeywordHighlighter::doHighlight($message);
         }
         // replace bad html tags (script etc.)
         $badSearch = array('/javascript:/i', '/about:/i', '/vbscript:/i');
         $badReplace = array('javascript<b></b>:', 'about<b></b>:', 'vbscript<b></b>:');
         $message = preg_replace($badSearch, $badReplace, $message);
         // wrap text
         //$message = $this->wrap($message);
     }
     return $message;
 }
 /**
  * @see Thread::getTopic()
  */
 public function getHighlightedTopic()
 {
     return KeywordHighlighter::doHighlight(StringUtil::encodeHTML($this->topic));
 }