*/
protected $textArray = array();
+ /**
+ * regular expression for source code tags
+ * @var string
+ */
+ protected $sourceCodeRegEx = '';
+
/**
* @see \wcf\system\SingletonFactory::init()
*/
protected function init() {
// get bbcodes
$this->bbcodes = BBCodeCache::getInstance()->getBBCodes();
+
+ // handle source codes
+ $sourceCodeTags = array();
+ foreach ($this->bbcodes as $bbcode) {
+ if ($bbcode->isSourceCode) $sourceCodeTags[] = $bbcode->bbcodeTag;
+ }
+ if (!empty($sourceCodeTags)) $this->sourceCodeRegEx = implode('|', $sourceCodeTags);
}
/**
return $usedDisallowedBBCodes;
}
+
+ /**
+ * Removes code bbcode occurrences in given message.
+ *
+ * @param string $message
+ * @return string
+ */
+ public function removeCodeTags($message) {
+ if (!empty($this->sourceCodeRegEx)) {
+ return preg_replace("~(\[(?:".$this->sourceCodeRegEx.")
+ (?:=
+ (?:\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\'|[^,\]]*)
+ (?:,(?:\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\'|[^,\]]*))*
+ )?\])
+ (.*?)
+ (?:\[/code\])~six", '', $message);
+ }
+
+ return $message;
+ }
}
*/
protected $cachedCodes = array();
- /**
- * regular expression for source code tags
- * @var string
- */
- protected $sourceCodeRegEx = '';
-
/**
* currently parsed message
* @var string
protected function init() {
parent::init();
- // handle source codes
- $sourceCodeTags = array();
- foreach ($this->bbcodes as $bbcode) {
- if ($bbcode->isSourceCode) $sourceCodeTags[] = $bbcode->bbcodeTag;
- }
- if (!empty($sourceCodeTags)) $this->sourceCodeRegEx = implode('|', $sourceCodeTags);
-
if (MODULE_SMILEY == 1) {
// get smilies
$smilies = SmileyCache::getInstance()->getSmilies();
<?php
namespace wcf\system\message\embedded\object;
use wcf\data\object\type\ObjectTypeCache;
+use wcf\system\bbcode\BBCodeParser;
use wcf\system\database\util\PreparedStatementConditionBuilder;
use wcf\system\SingletonFactory;
use wcf\system\WCF;
*/
public function registerObjects($messageObjectType, $messageID, $message) {
// remove [code] tags
- $message = self::removeCodeTags($message);
+ $message = BBCodeParser::getInstance()->removeCodeTags($message);
// delete existing assignments
$this->removeObjects($messageObjectType, array($messageID));
*/
public function parseTemporaryMessage($message) {
// remove [code] tags
- $message = self::removeCodeTags($message);
+ $message = BBCodeParser::getInstance()->removeCodeTags($message);
// set active message information
$this->activeMessageObjectTypeID = -1;
return $this->embeddedObjectHandlers[$objectTypeID];
}
-
- /**
- * Removes code bbcode occurrences in given message.
- *
- * @param string $message
- * @return string
- */
- protected static function removeCodeTags($message) {
- return preg_replace("~(\[code
- (?:=
- (?:\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\'|[^,\]]*)
- (?:,(?:\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\'|[^,\]]*))*
- )?\])
- (.*?)
- (?:\[/code\])~six", '', $message);
- }
}
\ No newline at end of file