(2012-02-27, 11:16 AM)CivilEA Wrote: thank you,
there is a problem with this code, when I user [test]http://test.com[/test] it works fine but when use multiple row between tag like this:
[test]http://test.com
http://test2.com
http://test3.com
[/test]
do not works fine with code tag, as you know all links in code tags are not click-able, when I put multiple row between new mycode tag, only first row is not click-able and other are click-able.
The problem is, inorder to actually make the "code" function to work, we must pass it to mycode_parse_code function in inc/class_parser. But custom MyCode replacement allows only allow HTML.
We can achieve what you asked by editing inc/class_parser.php
Find:
preg_match_all("#\[(code|php)\](.*?)\[/\\1\](\r\n?|\n?)#si", $message, $code_matches, PREG_SET_ORDER);
Replace with:
preg_match_all("#\[(code|php|test)\](.*?)\[/\\1\](\r\n?|\n?)#si", $message, $code_matches, PREG_SET_ORDER);
Find:
$message = preg_replace("#\[(code|php)\](.*?)\[/\\1\](\r\n?|\n?)#si", "<mybb-code>\n", $message);
Replace with:
$message = preg_replace("#\[(code|php|test)\](.*?)\[/\\1\](\r\n?|\n?)#si", "<mybb-code>\n", $message);
Find:
if(my_strtolower($text[1]) == "code")
{
$code = $this->mycode_parse_code($text[2]);
}
After that add:
elseif(my_strtolower($text[1]) == "test")
{
$code = $this->mycode_parse_test($text[2]);
}
Find:
return "<div class=\"codeblock\">\n<div class=\"title\">".$lang->code."\n</div><div class=\"body\" dir=\"ltr\"><code>".$code."</code></div></div>\n";
}
After that add:
function mycode_parse_test($code, $text_only=false)
{
global $lang;
if($text_only == true)
{
return "\n{$lang->code}\n--\n{$code}\n--\n";
}
// Clean the string before parsing.
$code = preg_replace('#^(\t*)(\n|\r|\0|\x0B| )*#', '\\1', $code);
$code = rtrim($code);
$original = preg_replace('#^\t*#', '', $code);
if(empty($original))
{
return;
}
$code = str_replace('$', '$', $code);
$code = preg_replace('#\$([0-9])#', '\\\$\\1', $code);
$code = str_replace('\\', '\', $code);
$code = str_replace("\t", ' ', $code);
$code = str_replace(" ", ' ', $code);
return "<img src=\"http://test.com/test.png\"/>
<br /><div class=\"codeblock\">\n<div class=\"title\">".$lang->code."\n</div><div class=\"body\" dir=\"ltr\"><code>".$code."</code></div></div>\n";
}