"
" to $preg * * What's new: - Rewrote some preg expressions for more * stability. * - renamed CSS classes to be more generic. (Example * CSS file attached.) * - Support for escaped tags. Add a backslash * infront of a tag if you don't want to transform * it. For example: \[b] * * Version 1.3c * - Fixed a bug with
  • ...
  • tags (thanks * to Rob Schultz for pointing this out) * * Version 1.3b * - Added more support for phpBB2: * [list]...[/list:u] unordered lists * [list]...[/list:o] ordered lists * * Version 1.3 * - added support for phpBB2 like tag identifier * like [b:b6a0cef7ea]This is bold[/b:b6a0cef7ea] * (thanks to Rob Schultz) * - added support for quotes within the quote tag * so [quote="foo"]bar[/quote] does work now * correctly * - removed str_replace functions * * Version 1.2 * - now supports CSS classes: * ng_email (mailto links) * ng_url (www links) * ng_quote (quotes) * ng_quote_body (quotes) * ng_code (source code) * ng_list (html lists) * ng_list_item (list items) * - replaced slow ereg_replace() functions * - Alterned [quote] and [code] to use CSS classes * instead of HTML
    ,
    , ... tags. * - Additional BBCode tags [list] and [*] to display * nice HTML lists. Example: * [list] * [*]first item * [*]second item * [*]third item * [/list] * The [list] tag can have an additional parameter: * [list] unorderer list with bullets * [list=1] ordered list 1,2,3,4,... * [list=i] ordered list i,ii,iii,iv,... * [list=I] ordered list I,II,III,IV,... * [list=a] ordered list a,b,c,d,... * [list=A] ordered list A,B,C,D,... * - produces well-formed output * - cleaned up the code * ------------------------------------------------------------ */ function smarty_modifier_bbcode2html($message) { $preg = array( '/(? "\\2", '/(? "\\2", '/(? "\\2", '/(? "
    \\2
    ", '/(? "\\1", '/(? "\\1", '/(? "\\1", '/(? "
    \\1
    ", // [code] & [php] '/(? "
    \\1
    ", '/(? "
    \\1
    ", // [email] '/(? "\\1", '/(? "\\2", // [url] '/(? "\\1", '/(? "\\1", '/(? "\\2", // [img] '/(? "\"\\1\"", '/(? "\"\\3\"", // [quote] '/(? "
    Quote:
    \\1
    ", '/(? "
    Quote \\1:
    \\2
    ", // [list] '/(?\s*)?\[\*(?::\w+)?\](.*?)(?=(?:\s*\s*)?\[\*|(?:\s*\s*)?\[\/?list)/si' => "\n
  • \\1
  • ", '/(?\s*)?\[\/list(:(?!u|o)\w+)?\](?:)?/si' => "\n", '/(?\s*)?\[\/list:u(:\w+)?\](?:)?/si' => "\n", '/(?\s*)?\[\/list:o(:\w+)?\](?:)?/si' => "\n", '/(?\s*)?\[list(:(?!u|o)\w+)?\]\s*(?:)?/si' => "\n
      ", '/(?\s*)?\[list:u(:\w+)?\]\s*(?:)?/si' => "\n
        ", '/(?\s*)?\[list:o(:\w+)?\]\s*(?:)?/si' => "\n
          ", '/(?\s*)?\[list(?::o)?(:\w+)?=1\]\s*(?:)?/si' => "\n
            ", '/(?\s*)?\[list(?::o)?(:\w+)?=i\]\s*(?:)?/s' => "\n
              ", '/(?\s*)?\[list(?::o)?(:\w+)?=I\]\s*(?:)?/s' => "\n
                ", '/(?\s*)?\[list(?::o)?(:\w+)?=a\]\s*(?:)?/s' => "\n
                  ", '/(?\s*)?\[list(?::o)?(:\w+)?=A\]\s*(?:)?/s' => "\n
                    ", // escaped tags like \[b], \[color], \[url], ... '/\\\\(\[\/?\w+(?::\w+)*\])/' => "\\1" ); $message = preg_replace(array_keys($preg), array_values($preg), $message); for ($i=1; $i<10; $i++){ $newmessage = preg_replace('/(?Quote:
                    \\1
                    ", $message); if ($newmessage==$message) break; $message=$newmessage; } return $message; } ?>