為BBcode插入的程式碼添加複製功能
打開: includes/functions_bbcodeparse.php
查找:
PHP代碼:
// ###################### Start bbcodehandler_php #######################
function handle_bbcode_php($code)
{
global $vboptions, $vbphrase, $stylevar, $highlight_errors;
static $codefind1, $codereplace1, $codefind2, $codereplace2;
在下面添加:
PHP代碼:
$code_php_id = rand(1, 10000);
查找:
PHP代碼:
// ###################### Start bbcodehandler_code #######################
function handle_bbcode_code($code)
{
global $vboptions, $vbphrase, $stylevar;
在下面添加:
PHP代碼:
$code_id = rand(1, 10000);
查找:
PHP代碼:
// ###################### Start bbcodehandler_html #######################
function handle_bbcode_html($code)
{
global $vboptions, $vbphrase, $stylevar, $html_allowed;
static $regexfind, $regexreplace;
在下面添加:
PHP代碼:
$code_html_id = rand(1, 10000);
打開: clientscript/vbulletin_global.js
在最後加入:
HTML代碼:
// Copy Code By explon
function CopyText(obj) {
ie = (document.all)? true:false
if (ie){
var rng = document.body.createTextRange();
rng.moveToElementText(obj);
rng.scrollIntoView();
rng.select();
rng.execCommand("Copy");
rng.collapse(false);
}
}
編輯模板(用以下內容替換):
bbcode_code 模板:
HTML代碼:
<div style="margin:20px; margin-top:5px"> <div class="smallfont" style="margin-bottom:2px">$vbphrase[code]: <a href="#top"
onclick="CopyText(document.all.CODE_$code_id);return false">[複製程式碼]</a></div> <pre class="alt2" style="margin:0px; padding:$stylevar[cellpadding]px; border:1px inset; width:$stylevar[codeblockwidth];
height:{$blockheight}px; overflow:auto"><div id="CODE_$code_id" dir="ltr" style="text-align:left;">$code</div></pre> </div>
bbcode_html 模板:
HTML代碼:
<div style="margin:20px; margin-top:5px"> <div class="smallfont" style="margin-bottom:2px">$vbphrase[html_code]: <a href="#top"
onclick="CopyText(document.all.CODE_$code_html_id);return false">[複製程式碼]</a></div> <pre class="alt2" style="margin:0px; padding:$stylevar[cellpadding]px; border:1px inset; width:$stylevar[codeblockwidth];
height:{$blockheight}px; overflow:auto"><div id="CODE_$code_html_id" dir="ltr" style="text-align:left;">$code</div></pre> </div>
bbcode_php 模板:
HTML代碼:
<div style="margin:20px; margin-top:5px"> <div class="smallfont" style="margin-bottom:2px">$vbphrase[php_code]: <a href="#top"
onclick="CopyText(document.all.CODE_$code_php_id);return false">[複製程式碼]</a></div> <div class="alt2" style="margin:0px; padding:$stylevar[cellpadding]px; border:1px inset; width:$stylevar[codeblockwidth];
height:{$blockheight}px; overflow:auto"> <code style="white-space:nowrap"> <div id="CODE_$code_php_id" dir="ltr" style="text-align:left;"> <!-- php buffer start -->$code<!-- php buffer end --> </div> </code> </div> </div>
修改完成! ^_^
|