7
Here's some mods I've been using... Just replace the &xoopsCodeDecode function with this one in /class/module.textsanitizer.php
function &xoopsCodeDecode(&$text, $allowimage = 1)
{
// - added sub, sup, hr, ol (with list-style-type support), ul and made all bbcodes case insensitive
// - changed [b],[i],[u] to use html styles instead of <b>,<i>,<u> respectively
// Notes:
// 1) Default 2.0.16 theme style sheet defines <ul> and <li> list-styles which effect bullet types
// 2) Supported <ol> list-style-type(s) vary by browser (e.g. IE supports lower-alpha, Firefox supports lower-latin)
$patterns = array();
$replacements = array();
//$patterns[] = "/[code](.*)[/code]/esU";
//$replacements[] = "'<div class="xoopsCode"><code><pre>'.wordwrap(MyTextSanitizer::htmlSpecialChars('\1'), 100).'</pre></code></div>'";
// RMV: added new markup for intrasite url (allows easier site moves)
// TODO: automatically convert other URLs to this format if XOOPS_URL matches??
$patterns[] = "/[siteurl=(['"]?)([^"'<>]*)\1](.*)[/siteurl]/sUi";
$replacements[] = '<a href="'.XOOPS_URL.'/\2">\3</a>';
$patterns[] = "/[url=(['"]?)(http[s]?://[^"'<>]*)\1](.*)[/url]/sUi";
$replacements[] = '<a href="\2" target="_blank">\3</a>';
$patterns[] = "/[url=(['"]?)([Ff][Tt][Pp]?://[^"'<>]*)\1](.*)[/url]/sUi";
$replacements[] = '<a href="\2" target="_blank">\3</a>';
$patterns[] = "/[url=(['"]?)([^"'<>]*)\1](.*)[/url]/sU";
$replacements[] = '<a href="http://\2" target="_blank">\3</a>';
$patterns[] = "/[color=(['"]?)([a-zA-Z0-9]*)\1](.*)[/color]/sUi";
$replacements[] = '<span style="color: #\2;">\3</span>';
$patterns[] = "/[size=(['"]?)([a-z0-9-]*)\1](.*)[/size]/sUi";
$replacements[] = '<span style="font-size: \2;">\3</span>';
$patterns[] = "/[font=(['"]?)([^;<>*()"']*)\1](.*)[/font]/sUi";
$replacements[] = '<span style="font-family: \2;">\3</span>';
$patterns[] = "/[email]([^;<>*()"']*)[/email]/sU";
$replacements[] = '<a href="mailto:\1">\1</a>';
$patterns[] = "/[[Bb]](.*)[/[Bb]]/sU";
$replacements[] = '<span style="font-weight: bold;">\1</span>';
$patterns[] = "/[[Ii]](.*)[/[Ii]]/sU";
$replacements[] = '<span style="font-style: italic;">\1</span>';
$patterns[] = "/[[Uu]](.*)[/[Uu]]/sU";
$replacements[] = '<span style="text-decoration: underline;">\1</span>';
$patterns[] = "/[[Dd]](.*)[/[Dd]]/sU";
$replacements[] = '<del>\1</del>';
$patterns[] = "/[sub](.*)[/sub]/sUi";
$replacements[] = '<sub>\1</sub>';
$patterns[] = "/[sup](.*)[/sup]/sUi";
$replacements[] = '<sup>\1</sup>';
$patterns[] = "/[hr]/sUi";
$replacements[] = '<hr />';
$patterns[] = "/[hr=([0-9]+)(.*)]/sUi";
$replacements[] = '<hr style="width: \1\2;" />';
$patterns[] = "/[list](.*)[/list]/sUi";
$replacements[] = '<ul>\1</ul>';
$patterns[] = "/[list=(.*)](.*)[/list]/sUi";
$replacements[] = '<ol style="list-style-type: \1;">\2</ol>';
$patterns[] = "/[li](.*)[/li]/sUi";
$replacements[] = '<li>\1</li>';
//$patterns[] = "/[li](.*)[/li]/sU";
//$replacements[] = '<li>\1</li>';
$patterns[] = "/[[Ii][Mm][Gg] [Aa][Ll][Ii][Gg][Nn]=(['"]?)([Ll][Ee][Ff][Tt]|[Cc][Ee][Nn][Tt][Ee][Rr]|[Rr][Ii][Gg][Hh][Tt])\1]([^"()?&'<>]*)[/[Ii][Mm][Gg]]/sU";
$patterns[] = "/[[Ii][Mm][Gg]]([^"()?&'<>]*)[/[Ii][Mm][Gg]]/sU";
$patterns[] = "/[[Ii][Mm][Gg] [Aa][Ll][Ii][Gg][Nn]=(['"]?)([Ll][Ee][Ff][Tt]|[Cc][Ee][Nn][Tt][Ee][Rr]|[Rr][Ii][Gg][Hh][Tt])\1 [Ii][Dd]=(['"]?)([0-9]*)\3]([^"()?&'<>]*)[/[Ii][Mm][Gg]]/sU";
$patterns[] = "/[[Ii][Mm][Gg] [Ii][Dd]=(['"]?)([0-9]*)\1]([^"()?&'<>]*)[/[Ii][Mm][Gg]]/sU";
if ($allowimage != 1) {
$replacements[] = '<a href="\3" target="_blank">\3</a>';
$replacements[] = '<a href="\1" target="_blank">\1</a>';
$replacements[] = '<a href="'.XOOPS_URL.'/image.php?id=\4" target="_blank">\4</a>';
$replacements[] = '<a href="'.XOOPS_URL.'/image.php?id=\2" target="_blank">\3</a>';
} else {
$replacements[] = '<img src="\3" align="\2" alt="" />';
$replacements[] = '<img src="\1" alt="" />';
$replacements[] = '<img src="'.XOOPS_URL.'/image.php?id=\4" align="\2" alt="\4" />';
$replacements[] = '<img src="'.XOOPS_URL.'/image.php?id=\2" alt="\3" />';
}
// REMOVE THE SPACE BEFORE the word quote in the next line...
$patterns[] = "/[ quote]/sUi";
$replacements[] = _QUOTEC.'<div class="xoopsQuote"><blockquote>';
//$replacements[] = 'Quote: <div class="xoopsQuote"><blockquote>';
$patterns[] = "/[/quote]/sUi";
$replacements[] = '</blockquote></div>';
$text = str_replace( "x00", "", $text );
$c = "[x01-x1f]*";
$patterns[] = "/j{$c}a{$c}v{$c}a{$c}s{$c}c{$c}r{$c}i{$c}p{$c}t{$c}:/si";
$replacements[] = "(script removed)";
$patterns[] = "/a{$c}b{$c}o{$c}u{$c}t{$c}:/si";
$replacements[] = "about :";
$text = preg_replace($patterns, $replacements, $text);
return $text;
}
NOTE: You must delete a space (x020) in the code above (about 1/3 of the way up from the bottom of the code) before you 'cut-n-paste' this into the file.
I had to do this so it would show okay in the forum You'll note I've also added support for:
- [sub] & [sup]
- [hr] & [hr=xx] (where xx is width - can use either % or px)
- [list] (unordered lists)
- [list=xyz] (ordered list with list-style-type support)
- changed [b],[i],[u] to use html styles