bbcode = new Parser(); // Add the standard definitions $this->loadStandardCodes(); // Immediately parse the text if set if ($text != null) { $this->bbcode->parse($text); } } // Add basic bbcodes public function loadStandardCodes() { // Add the standard definitions $this->bbcode->addCodeDefinitionSet(new DefaultCodeDefinitionSet()); // Header tag $builder = new CodeDefinitionBuilder('header', '
'); $this->bbcode->addCodeDefinition($builder->build()); // Quote tag $builder = new CodeDefinitionBuilder('quote', '{param}
'); $builder->setUseOption(true); $this->bbcode->addCodeDefinition($builder->build()); // Add special definitions (PHP files MUST have the same name as the definition class foreach (glob(ROOT . '_sakura/components/BBcodeDefinitions/*.php') as $ext) { // Include the class require_once $ext; // Clean the file path $ext = str_replace(ROOT . '_sakura/components/', '', $ext); $ext = str_replace('.php', '', $ext); $ext = str_replace('/', '\\', $ext); // Build the classname $className = __NAMESPACE__ . '\\' . $ext; // Add the BBcode definition $this->bbcode->addCodeDefinition(new $className); } } // Set text public function text($text) { $this->bbcode->parse($text); } // Get as HTML public function toHTML() { $parsed = nl2br($this->bbcode->getAsHtml()); $parsed = Main::fixCodeTags($parsed); $parsed = Main::parseEmotes($parsed); return $parsed; } // Get as BBmarkup public function toEditor() { return $this->bbcode->getAsBBCode(); } // Get as plaintext public function toPlain() { return $this->bbcode->getAsText(); } }{option} wrote:{param}