Ðăng Nhập

View Full Version : Hỏi về Pugin Multi {option} BBcode



trapstraps
08-09-2011, 10:49 AM
Plugin Multi {option} BBcode là Plugin cho phép sử dụng nhiều giá trị {option} khi viết BBcode, vd: {option1}, {option2} , nhưng vấn đề là nó chỉ cho phép sử dụng 2 giá trị {option}, có cách nào tăng thêm 5-6 giá trị được ko (vd: {option1}, {option2}, {option3}, {option4}, {option5},......)
đây là code của Plugin:

<?xml version="1.0" encoding="ISO-8859-1"?>

<plugins>
<plugin active="1" executionorder="5" product="vbulletin">
<title>VnTopic Multiple BBCode Option</title>
<hookname>bbcode_parse_start</hookname>
<phpcode><![CDATA[foreach ($this->tag_list['option'] AS $tag => $bbcode)
{
unset($this->tag_list['option']["$tag"]['html']);

$this->tag_list['option']["$tag"]['callback'] = 'handle_external';
$this->tag_list['option']["$tag"]['external_callback'] = 'handle_options';
}]]></phpcode>
</plugin>
<plugin active="1" executionorder="5" product="vbulletin">
<title>Multiple BBCode Option Variables</title>
<hookname>bbcode_fetch_tags</hookname>
<phpcode><![CDATA[if (!function_exists('handle_options'))
{
function handle_options(&$parser, $param, $options='')
{
$tagname = $parser->current_tag['name'];
$replace = array($param);
$replace = array_merge($param, explode(';', $options));

$array_max = array_keys($parser->registry->bbcodecache);

for ($i = 0; $i <= max($array_max); $i++) {
if (strtolower($parser->registry->bbcodecache[$i]['bbcodetag']) == strtolower($tagname)) {
$array = $parser->registry->bbcodecache[$i];
}
}

$html = preg_replace('/\{option(\d+)\}/e', "'%' . (intval('\\1')+1) . '\$s'", $array['bbcodereplacement']);

$return = vsprintf($html, $replace);
return $return;
}

}]]></phpcode>
</plugin>
</plugins>


Ai pro code giúp mình nha