From 22c304092ede6d2ee9e78065445f4451ce321110 Mon Sep 17 00:00:00 2001 From: "Marek A. R" Date: Fri, 28 Mar 2008 22:59:53 +0000 Subject: It's here and it's awesome! git-svn-id: file:///svn/phpbb/trunk@8476 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/bbcode/bbcode_parser.php | 241 ++++++++++++++++++++++++++++++++ 1 file changed, 241 insertions(+) create mode 100644 phpBB/includes/bbcode/bbcode_parser.php (limited to 'phpBB/includes/bbcode/bbcode_parser.php') diff --git a/phpBB/includes/bbcode/bbcode_parser.php b/phpBB/includes/bbcode/bbcode_parser.php new file mode 100644 index 0000000000..f76b3ade39 --- /dev/null +++ b/phpBB/includes/bbcode/bbcode_parser.php @@ -0,0 +1,241 @@ +tags = array( + // The exact B BBcode from phpBB + 'b' => array( + 'replace' => '', + 'close' => '', + 'attributes' => array(), + 'children' => array(true, 'quote' => true, 'code' => true, 'list' => true), + 'parents' => array(true), + ), + // The exact I BBcode from phpBB + 'i' => array( + 'replace' => '', + 'close' => '', + 'attributes' => array(), + 'children' => array(true, 'quote' => true, 'code' => true, 'list' => true), + 'parents' => array(true), + ), + // The exact U BBcode from phpBB + 'u' => array( + 'replace' => '', + 'close' => '', + 'attributes' => array(), + 'children' => array(true, 'quote' => true, 'code' => true, 'list' => true), + 'parents' => array(true), + ), + + // Quote tag attempt. + 'quote' => array( + 'replace' => '
{_}
', + 'close' => '
', + 'attributes' => array( + '_' => array( + 'replace' => '%s wrote:', + ), + ), + 'children' => array(true), + 'parents' => array(true), + ), + + // code tag (without the =php functionality) + 'code' => array( + 'replace' => '
Code:
', + 'close' => '
', + 'attributes' => array(), + 'children' => array(false), + 'parents' => array(true), + ), + + // list tag + 'list' => array( + 'replace' => '', + 'replace_func' => array($this, 'list_open'), + 'close' => '', + 'close_func' => array($this, 'list_close'), + 'attributes' => array( + '_' => array( + 'replace' => '', + ), + ), + 'children' => array(false, 'li' => true), + 'parents' => array(true), + ), + + // The exact * tag from phpBB. "*" is not a valid tag name in this parser... introducing li from HTML! + 'li' => array( + 'replace' => '
  • ', + 'close' => '
  • ', + 'close_shadow' => true, + 'attributes' => array(), + 'children' => array(true, 'li' => true), + 'parents' => array(false, 'list' => true), + ), + + // Almost exact img tag from phpBB... + 'img' => array( + 'replace' => 'Image', + 'attributes' => array( + '__' => array( + 'replace' => '%s', + ), + ), + 'children' => array(false), + 'parents' => array(true), + + ), + + 'url' => array( + 'replace' => '', + 'replace_func' => array($this, 'url_tag'), + 'close' => '', + 'attributes' => array( + // The replace value is not important empty because the replace_func handles this. + '_' => array( + 'replace' => '', + ), + '__' => array( + 'replace' => '', + ), + ), + 'children' => array(false), + 'parents' => array(true), + + ), + + 'color' => array( + 'replace' => '', + 'close' => '', + 'attributes' => array( + '_' => array( + 'replace' => '%s', + 'required' => true + ), + ), + 'children' => array(true, 'color' => true), + 'parents' => array(true), + ), + + 'size' => array( + 'replace' => '', + 'close' => '', + 'attributes' => array( + '_' => array( + 'replace' => '%s', + 'required' => true + ), + ), + 'children' => array(true, 'size' => true), + 'parents' => array(true), + ), + + + // FLASH tag implementation attempt. + 'flash' => array( + 'replace' => ' + + + + +', + 'close' => false, + 'attributes' => array( + 'm' => array( + 'replace' => '%s', + 'required' => true, + ), + 'w' => array( + 'replace' => ' width="%s"', + 'type_check' => 'ctype_digit', + ), + 'h' => array( + 'replace' => ' height="%s"', + 'type_check' => 'ctype_digit', + ), + ), + 'children' => array(false), + 'parents' => array(true), + ), + // The spoiler tag from area51.phpbb.com :p + 'spoiler' => array( + 'replace' => 'Spoiler:', + 'close' => '', + 'attributes' => array(), + 'children' => array(false), + 'parents' => array(true), + ), + // a noparse tag + 'noparse' => array( + 'replace' => '', + 'close' => '', + 'attributes' => array(), + 'children' => array(false), + 'parents' => array(true), + ), + ); + $this->smilies = array( + ':)' => '', + ':(' => '', + ); + + $this->text_callback = 'strtoupper'; + parent::__construct(); + } + + + protected function url_tag(array $attributes = array(), array $definition = array()) + { + if (isset($attributes['_'])) + { + return ''; + } + return ''; + } + + protected function list_open(array $attributes = array(), array $definition = array()) + { + if (isset($attributes['_'])) + { + return '
      '; + } + return '
        '; + } + + protected function list_close(array $attributes = array()) + { + if (isset($attributes['_'])) + { + return '
    '; + } + return ''; + } +} -- cgit v1.2.1