From: Alexander Ebert Date: Mon, 24 Mar 2014 16:33:22 +0000 (+0100) Subject: Added method to retrieve sourcecode-BBCodes X-Git-Tag: 2.1.0_Alpha_1~984 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=978d789ee5a432a0034ed0597750b4977d824a7d;p=GitHub%2FWoltLab%2FWCF.git Added method to retrieve sourcecode-BBCodes --- diff --git a/wcfsetup/install/files/lib/system/bbcode/BBCodeHandler.class.php b/wcfsetup/install/files/lib/system/bbcode/BBCodeHandler.class.php index 7ad13d4277..f84142cd7a 100644 --- a/wcfsetup/install/files/lib/system/bbcode/BBCodeHandler.class.php +++ b/wcfsetup/install/files/lib/system/bbcode/BBCodeHandler.class.php @@ -26,6 +26,12 @@ class BBCodeHandler extends SingletonFactory { */ protected $buttonBBCodes = array(); + /** + * list of BBCodes which contain raw code (disabled BBCode parsing) + * @var array<\wcf\data\bbcode\BBCode> + */ + protected $sourceBBCodes = null; + /** * @see \wcf\system\SingletonFactory::init() */ @@ -83,4 +89,31 @@ class BBCodeHandler extends SingletonFactory { public function setAllowedBBCodes(array $bbCodes) { $this->allowedBBCodes = $bbCodes; } + + /** + * Returns a list of BBCodes which contain raw code (disabled BBCode parsing) + * + * @return array<\wcf\data\bbcode\BBCode> + */ + public function getSourceBBCodes() { + if (empty($this->allowedBBCodes)) { + return array(); + } + + if ($this->sourceBBCodes === null) { + $this->sourceBBCodes = array(); + + foreach (BBCodeCache::getInstance()->getBBCodes() as $bbcode) { + if (!$bbcode->isSourceCode) { + continue; + } + + if ($this->isAvailableBBCode($bbcode->bbcodeTag)) { + $this->sourceBBCodes[] = $bbcode; + } + } + } + + return $this->sourceBBCodes; + } }