/**
* Parses list MyCode.
*
* @param string $message The message to be parsed
* @param string $type The list type
* @return string The parsed message.
*/
function mycode_parse_list($message, $type="")
{
// No list elements? That's invalid HTML
if(strpos($message, '
[*]') === false)
{
$message = "
[*]{$message}";
}
$message = preg_replace("#[^\S\n\r]*\[\*\]\s*#", "</li>\n<li>", $message);
$message .= "</li>";
/* - PL:patches - /* if($type)
/* - PL:patches - /* {
/* - PL:patches - /* $list = "\n<ol type=\"$type\" class=\"mycode_list\">$message</ol>\n";
/* - PL:patches - /* }
/* - PL:patches - /* else
/* - PL:patches - /* {
/* - PL:patches - /* $list = "<ul class=\"mycode_list\">$message</ul>\n";
/* - PL:patches - /* }
/* + PL:patches + */ if($type)
/* + PL:patches + */ {
/* + PL:patches + */ $list = "\n<ol type=\"$type\" class=\"mycode_list\">$message</ol>\n";
/* + PL:patches + */ $list = str_replace("<ol type=\"$type\" class=\"mycode_list\">\n</li>", "<ol type=\"$type\" class=\"mycode_list\">\n", $list);
/* + PL:patches + */ }
/* + PL:patches + */ else
/* + PL:patches + */ {
/* + PL:patches + */ $list = "<ul class=\"mycode_list\">$message</ul>\n";
/* + PL:patches + */ $list = str_replace("<ul class=\"mycode_list\">\n</li>", "<ul class=\"mycode_list\">\n", $list);
/* + PL:patches + */ }
$list = preg_replace("#<(ol type=\"$type\"|ul)>\s*</li>#", "<$1>", $list);
return $list;
}
/**
* Parses list MyCode.
*
* @param array $matches Matches
* @return string The parsed message.
*/
function mycode_parse_list_callback($matches)
{
return $this->mycode_parse_list($matches[3], $matches[2]);
}