找回密码
 注册
首页 ≡≡网络技术≡≡ PHP语言 Discuz! discuz(DZ)论坛更换百度ueditor编辑器

discuz(DZ)论坛更换百度ueditor编辑器

灰儿 2017-1-11 10:21:23


    修改前必读:
    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,然后放在论坛根目录。
    20141126101219_57309.jpg

    二、修改post_editor_body.htm(将下面代码复制,打开文件全选之后粘贴。)
    1. <div id="{$editorid}_body_loading"><img src="{IMGDIR}/loading.gif" width="16" height="16" class="vm" /> {lang e_editor_loading}</div>
    2. <!-- 编辑器 -->
    3. <div class="edt" id="{$editorid}_body" style="display: none">
    4. <!-- 加载百度编辑器的容器 -->
    5.     <script id="{$editorid}_textarea" name="$editor[textarea]" type="text/plain">
    6.     $editor[value]
    7.     </script>
    8.     <!-- 配置文件 -->
    9.     <script type="text/javascript" src="./ueditor/ueditor.config.js"></script>
    10.     <!-- 编辑器源码文件 -->
    11.     <script type="text/javascript" src="./ueditor/ueditor.all.js"></script>
    12.     <!-- 实例化编辑器 -->
    13.     <script type="text/javascript">
    14.         var ue = UE.getEditor('{$editorid}_textarea');
    15.     </script>
    16. <!-- 保存数据 -->
    17.     <div id="rstnotice" class="ntc_l bbs" style="display:none">
    18.         <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>
    19.     </div>
    20. <!-- 编辑器主输入框 -->

    21. <!--  -->
    22.     <!--{subtemplate common/editor}-->
    23. </div>
    复制代码



      三、修改post.htm



      搜索 “switchpost(”,找到“$_GET[action] == 'newthread'” 下面的ul标签,之后将下面的代码替换掉整段ul。

      1. <ul class="tb cl mbw">
      2.                 <!--{if $savecount}-->
      3.                     <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>
      4.                 <!--{/if}-->
      5.                 <!--{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}-->
      6.                 <!--{loop $_G['forum']['threadsorts'][types] $tsortid $name}-->
      7.                     <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>
      8.                 <!--{/loop}-->
      9.                 <!--{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}-->
      10.                 <!--{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}-->
      11.                 <!--{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}-->
      12.                 <!--{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}-->
      13.                 <!--{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}-->
      14.                 <!--{if $_G['setting']['threadplugins']}-->
      15.                     <!--{loop $_G['forum']['threadplugin'] $tpid}-->
      16.                         <!--{if array_key_exists($tpid, $_G['setting']['threadplugins']) && @in_array($tpid, $_G['group']['allowthreadplugin'])}-->
      17.                             <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>
      18.                         <!--{/if}-->
      19.                     <!--{/loop}-->
      20.                 <!--{/if}-->
      21.             </ul>
      复制代码

      四、修改 function_discuzcode.php ,大约在第 97 行,或者搜索 $htmlon , 在下面加上 $htmlon=1;
      20141126181845_92020.jpg

      注:改这里是 DZ在提交时将替换编辑框里html标签 的功能去掉了,如果不去掉会出现读取帖子内容的时候连标签一起显示出来的问题。因为时间紧迫,没有深入修改,就直接这么办了,不影响编辑器使用,但是可能会出现一些安全上的问题(如用户提交恶意js脚本等),有能力的朋友自己可以完善下。


      五、修改 post_editpost.php ,大约在 217 行,或者搜索 dhtmlspecialchars ,第二个就是,然后将这一行注释掉。
      20141126182055_20200.jpg

      注:这里的原因跟上面那个类似,因为我们写进数据库的时候并没有对标签进行重写,所以这里也不用再重写,不然会出现被编码后的html标签。
      最后后台更新下缓存,完成。

      附件:
      DZ编辑器修改.rar (2.82 MB, 下载次数: 294)

      http://pan.baidu.com/s/1bn1u8Pp   提取码:0txq
      (解压至网站根目录即可)


    相关文章:
您需要登录后才可以回帖 登录 | 注册
学习中心
站长自定义文字内容,利用碎片时间,随时随地获取优质内容。
Q设计语言 了解更多
Q Design 提供商家设计所需的指导与资源,帮商家快速完成产品设计、降低生产成本。
学习中心
站长自定义文字内容,利用碎片时间,随时随地获取优质内容。
Q设计语言 了解更多
Q Design 提供商家设计所需的指导与资源,帮商家快速完成产品设计、降低生产成本。