1、修改编辑器后会造成以前发过的帖子再次进行修改时(也就是编辑帖子操作)出现很多被DZ重写过的html标签,不方便进行修改,所以尽量在安装DZ后立刻进行修改。(当然,如果你有能力重写代码的话就可以无视啦)
2、修改前请先在本地进行尝试或备份相关文件。
需要修改的文件:
\template\default\forum\post_editor_body.htm
\template\default\forum\post.htm
\source\function\function_discuzcode.php
\source\include\post\post_editpost.php
一、首先下载百度的 ueditor utf-8 php 版,解压出来后将文件夹名改为ueditor,然后放在论坛根目录。
二、修改post_editor_body.htm(将下面代码复制,打开文件全选之后粘贴。)
< div id = "{$editorid}_body_loading" >< img src = "{IMGDIR}/loading.gif" width = "16" height = "16" class = "vm" /> {lang e_editor_loading}</ div > <!-- 编辑器 --> < div class = "edt" id = "{$editorid}_body" style = "display: none" > <!-- 加载百度编辑器的容器 --> < script id = "{$editorid}_textarea" name = "$editor[textarea]" type = "text/plain" > $editor[value] </ script > <!-- 配置文件 --> < script type = "text/javascript" src = "./ueditor/ueditor.config.js" ></ script > <!-- 编辑器源码文件 --> < script type = "text/javascript" src = "./ueditor/ueditor.all.js" ></ script > <!-- 实例化编辑器 --> < script type = "text/javascript" > var ue = UE.getEditor('{$editorid}_textarea'); </ script > <!-- 保存数据 --> < div id = "rstnotice" class = "ntc_l bbs" style = "display:none" > < a href = "javascript:;" title = "{lang post_topicreset}" class = "d y" onclick = "userdataoption(0)" >close</ a >{lang missed_data} < a class = "xi2" href = "javascript:;" onclick = "userdataoption(1)" >< strong >{lang post_autosave_restore}</ strong ></ a > </ div > <!-- 编辑器主输入框 --> <!-- --> <!--{subtemplate common/editor}--> </ div > |
三、修改post.htm
搜索 “switchpost(”,找到“$_GET[action] == 'newthread'” 下面的ul标签,之后将下面的代码替换掉整段ul。
< ul class = "tb cl mbw" > <!--{if $savecount}--> < li class = "y" >< a id = "draftlist" href = "javascript:;" class = "xi2" onmouseover = "showMenu({'ctrlid':'draftlist','ctrlclass':'a','duration':2,'pos':'34'})" >{lang draftbox}(< strong >$savecount</ strong >)</ a ></ li > <!--{/if}--> <!--{if !$_G['forum']['threadsorts']['required'] && !$_G['forum']['allowspecialonly']}--> < li $postspecialcheck[0]>< a href = "javascript:;" onclick = "switchpost('forum.php?mod=post&action=newthread')" >{lang post_newthread}</ a ></ li > <!--{/if}--> <!--{loop $_G['forum']['threadsorts'][types] $tsortid $name}--> < li {if $sortid == $tsortid} class = "a" {/if}>< a href="forum.php? mod = post & action = newthread &fid= <!--{echo $_GET[fid]}--> &sortid=$tsortid"> <!--{echo strip_tags($name);}--> </ a ></ li > <!--{/loop}--> <!--{if $_G['group']['allowpostpoll']}--> < li $postspecialcheck[1]>< a href="forum.php? mod = post & action = newthread &fid= <!--{echo $_GET[fid]}--> &special=1">{lang post_newthreadpoll}</ a ></ li > <!--{/if}--> <!--{if $_G['group']['allowpostreward']}--> < li $postspecialcheck[3]>< a href="forum.php? mod = post & action = newthread &fid= <!--{echo $_GET[fid]}--> &special=3">{lang post_newthreadreward}</ a ></ li > <!--{/if}--> <!--{if $_G['group']['allowpostdebate']}--> < li $postspecialcheck[5]>< a href="forum.php? mod = post & action = newthread &fid= <!--{echo $_GET[fid]}--> &special=5">{lang post_newthreaddebate}</ a ></ li > <!--{/if}--> <!--{if $_G['group']['allowpostactivity']}--> < li $postspecialcheck[4]>< a href="forum.php? mod = post & action = newthread &fid= <!--{echo $_GET[fid]}--> &special=4">{lang post_newthreadactivity}</ a ></ li > <!--{/if}--> <!--{if $_G['group']['allowposttrade']}--> < li $postspecialcheck[2]>< a href="forum.php? mod = post & action = newthread &fid= <!--{echo $_GET[fid]}--> &special=2">{lang post_newthreadtrade}</ a ></ li > <!--{/if}--> <!--{if $_G['setting']['threadplugins']}--> <!--{loop $_G['forum']['threadplugin'] $tpid}--> <!--{if array_key_exists($tpid, $_G['setting']['threadplugins']) && @in_array($tpid, $_G['group']['allowthreadplugin'])}--> < li {if $specialextra==$tpid} class = "a" {/if}>< a href="forum.php? mod = post & action = newthread &fid= <!--{echo $_GET[fid]}--> &specialextra=$tpid">{$_G[setting][threadplugins][$tpid][name]}</ a ></ li > <!--{/if}--> <!--{/loop}--> <!--{/if}--> </ ul > |
四、修改 function_discuzcode.php ,大约在第 97 行,或者搜索 $htmlon , 在下面加上 $htmlon=1;
注:改这里是 DZ在提交时将替换编辑框里html标签 的功能去掉了,如果不去掉会出现读取帖子内容的时候连标签一起显示出来的问题。因为时间紧迫,没有深入修改,就直接这么办了,不影响编辑器使用,但是可能会出现一些安全上的问题(如用户提交恶意js脚本等),有能力的朋友自己可以完善下。
五、修改 post_editpost.php ,大约在 217 行,或者搜索 dhtmlspecialchars ,第二个就是,然后将这一行注释掉。
注:这里的原因跟上面那个类似,因为我们写进数据库的时候并没有对标签进行重写,所以这里也不用再重写,不然会出现被编码后的html标签。
最后后台更新下缓存,完成。
欢迎光临 临海小憇 (http://czidea.cn/) | Powered by Discuz! X3.3 |