Added method to retrieve sourcecode-BBCodes
authorAlexander Ebert <ebert@woltlab.com>
Mon, 24 Mar 2014 16:33:22 +0000 (17:33 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Mon, 24 Mar 2014 16:33:22 +0000 (17:33 +0100)
wcfsetup/install/files/lib/system/bbcode/BBCodeHandler.class.php

index 7ad13d42770f90e6e309f2a3b232ea52c2471045..f84142cd7adf9cb3c5f8cb06ec1e56f9b39297ab 100644 (file)
@@ -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;
+       }
 }