addCodeDefinitionSet(new DefaultCodeDefinitionSet()); // Header tag $builder = new CodeDefinitionBuilder('header', '

{param}

'); self::$bbcode->addCodeDefinition($builder->build()); // Strike tag $builder = new CodeDefinitionBuilder('s', '{param}'); self::$bbcode->addCodeDefinition($builder->build()); // Spoiler tag $builder = new CodeDefinitionBuilder('spoiler', '{param}'); self::$bbcode->addCodeDefinition($builder->build()); // Box tag $builder = new CodeDefinitionBuilder('box', '
Click to open
'); self::$bbcode->addCodeDefinition($builder->build()); // Box tag $builder = new CodeDefinitionBuilder('box', '
{option}
'); $builder->setUseOption(true); self::$bbcode->addCodeDefinition($builder->build()); // Quote tag $builder = new CodeDefinitionBuilder('quote', '
Quote
{param}
'); self::$bbcode->addCodeDefinition($builder->build()); // Quote tag $builder = new CodeDefinitionBuilder('quote', '
{option} wrote
{param}
'); $builder->setUseOption(true); self::$bbcode->addCodeDefinition($builder->build()); // Add special definitions (PHP files MUST have the same name as the definition class foreach (glob(ROOT . 'libraries/BBcodeDefinitions/*.php') as $ext) { // Include the class require_once $ext; // Clean the file path $ext = str_replace(ROOT . 'libraries/', '', $ext); $ext = str_replace('.php', '', $ext); $ext = str_replace('/', '\\', $ext); // Build the classname $className = __NAMESPACE__ . '\\' . $ext; // Add the BBcode definition self::$bbcode->addCodeDefinition(new $className); } } // Set text public static function text($text) { // Check if $bbcode is still null if (self::$bbcode == null) { self::init(); } self::$bbcode->parse($text); } // Get as HTML public static function toHTML($text = null) { // Check if text isn't null if ($text !== null) { self::text($text); } $parsed = nl2br(self::$bbcode->getAsHtml()); $parsed = Utils::fixCodeTags($parsed); $parsed = Utils::parseEmotes($parsed); return $parsed; } // Get as BBmarkup public static function toEditor($text = null) { // Check if text isn't null if ($text !== null) { self::text($text); } return self::$bbcode->getAsBBCode(); } // Get as plaintext public static function toPlain($text = null) { // Check if text isn't null if ($text !== null) { self::text($text); } return self::$bbcode->getAsText(); } }