效果演示
http://bbs.pickbar.com/thread-828-1-1.html
http://www.pickbar.com/bbs/thread-44-1-2.html
http://www.resday.com/bbs/thread-827-1-1.html
修改过程
修改./include/discuzcode.func.php文件
找到:
复制内容到剪贴板
代码:
'codehtml' => '',在其后添加:
复制内容到剪贴板
代码:
'phtmlcount' => -1,
'htmlcount' => 0,
'htmlhtml' => '',找到:
复制内容到剪贴板
代码:
function codedisp($code) {在其前添加:
复制内容到剪贴板
代码:
function htmldisp($code) {
global $discuzcodes;
$discuzcodes['phtmlcount']++;
$code = htmlspecialchars(str_replace('\\"', '"', preg_replace("/^[\n\r]*(.+?)[\n\r]*$/is", "\\1", $code)));
$discuzcodes['htmlhtml'][$discuzcodes['phtmlcount']] = "
<DIV class=smalltxt style=\"MARGIN-TOP: 1em; MARGIN-BOTTOM: 1em\"><TEXTAREA name=\"run$discuzcodes[htmlcount]\" rows=12 cols=95>$code</TEXTAREA>
<INPUT onclick=runCode(run$discuzcodes[htmlcount]) type=button value=运行代码> <INPUT onclick=copycode(run$discuzcodes[htmlcount]) type=button value=复制代码> <INPUT onclick=saveCode(run$discuzcodes[htmlcount]) type=button value=另存代码> 提示:您可以先修改部分代码再运行</DIV>";
$discuzcodes['htmlcount']++;
return "[\tDISCUZ_html_$discuzcodes[phtmlcount]\t]";
}找到:
复制内容到剪贴板
代码:
if(!$htmlon && !$allowhtml) {在其前添加:
复制内容到剪贴板
代码:
if($parsetype != 1 && !$bbcodeoff && $allowbbcode) {
$message = preg_replace("/\s*\[html\](.+?)\[\/html\]\s*/ies", "htmldisp('\\1')", $message);
}找到:
复制内容到剪贴板
代码:
return $htmlon || $allowhtml ? $message : nl2br(str_replace(array("\t", ' ', ' '), array(' ', ' ', ' '), $message));替换为:
复制内容到剪贴板
代码:
$message= $htmlon || $allowhtml ? $message : nl2br(str_replace(array("\t", ' ', ' '), array(' ', ' ', ' '), $message));
for($i = 0; $i <= $discuzcodes['phtmlcount']; $i++) {
$message = str_replace("[ DISCUZ_html_$i ]", $discuzcodes['htmlhtml'][$i], $message);
}
return $message;上面这个要注意了,请看图示:
很多朋友改了不成功都是这里出了问题
修改./templates/default/viewthread.html文件
找到:
复制内容到剪贴板
代码:
<!--{if !$iscircle || !empty($frombbs)}-->{template footer}<!--{else}-->在其前添加:
复制内容到剪贴板
代码:
<!--{if $discuzcodes['htmlcount']}-->
<script>
function runCode(obj)
{
var code=obj.value;
var newwin=window.open('','','');
newwin.opener = null;
newwin.document.write(code);
newwin.document.close();
}
function saveCode(obj) {
var newwin = window.open('', '_blank', 'top=10000');
newwin.document.open('text/html', 'replace');
newwin.document.write(obj.value);
newwin.document.execCommand('saveas','','code.htm');
newwin.close();
}
</script>
<!--{/if}-->修改./include/javascript/editor.js文件
查找
复制内容到剪贴板
代码:
in_array(tagname, ['code', 'quote', 'free', 'hide']) 替换为
复制内容到剪贴板
代码:
in_array(tagname, ['code', 'quote', 'html','free', 'hide']) 查找
复制内容到剪贴板
代码:
if(in_array(cmd, ['quote', 'code', 'free', 'hide'])) {替换为
复制内容到剪贴板
代码:
if(in_array(cmd, ['quote', 'code','html', 'free', 'hide'])) {修改./templates/default/post_editor.html文件 (如果你使用模板不是默认模板请确认当前模板是否有post_editor.html文件,然后进行修改)
找到:
复制内容到剪贴板
代码:
<!--{if $forum['allowbbcode'] && $allowcusbbcode}-->
<!--{loop $_DCACHE['bbcodes_display'] $tag $bbcode}-->
<td><a id="{$editorid}_cmd_custom{$bbcode[params]}_$tag"><img src="images/common/$bbcode[icon]" title="$bbcode[explanation]" alt="$tag" /></a></td>
<!--{/loop}-->
<!--{/if}-->在其后添加:
复制内容到剪贴板
代码:
<td><div class="editor_buttonnormal" id="{$editorid}_cmd_wrap0_code" onclick="discuzcode('html')" onMouseOver="buttonContext(this, 'mouseover')" onMouseOut="buttonContext(this, 'mouseout')"><img src="images/common/bb_html.gif" width="21" height="20" title="插入代码运行框" alt="插入代码运行框" /></div></td>