虚拟主机域名注册-常见问题CMS教程问题 → 齐博CMS


齐博cms整合ck编辑器 php网站整合ck编辑器包含上传图片
作者:
  如题,相信你一定很想知道是什么或者很想快速体验吧,由于官方新版V6.5还没有发布,我自己鼓捣了一下,现已经成功应用到了V6.01,V6.02上来了

    最近因为有些需要碰到了需要弄ckeditor编辑器,网上关于其安装很多都是一样,很鄙视,而且有很多都是错的,当然他们也给了我正确安装和使用一点点提示和方向,下面我来具体说说。

    关于ckeditor的相关介绍我在这里只说一小段:
    [quote]CKEditor经过FCKeditor的重写,提供了丰富而强大的集成和互动的API。新版编辑器是完全基于插件,它可以扩展所有部件以符合需求。FCKeditor升级后的CKEditor去掉了上传功能,只提供了基本的文本编辑功能,上传模块由另一个组件CKFinder来实现。换句话说编辑器如果需要上传功能,就需要再下载CKFinder(http://www.ckfinder.com/)


    那么大家请先下载ckeditor和ckfinder最新文件,具体版本号;
   ckeditor_3.3.1.zip    (http://ckeditor.com/download)

    ckfinder_php_2.0.zip  ([url]http://ckfinder.com/download[/url])

    
  
先看效果:  
3
  
  
页面显示:
2

 
现在我们来配置ckeditor相关文件
1.      找到ckfinder/config.php的这个CheckAuthentication函数,默认是返回false,我们让他返回true,也就是将整个函数换成这个:
function CheckAuthentication(){
return true;  
}

实际上官方是建议在里面写自己的函数,比如网上建议写成这样:
 
复制代码
  1. if(isset($_SESSION['mySession'])){  
  2.               return true;  
  3. } else {  
  4.               return false;  
  5. }

不过实际上这样是有问题的,大家先用上面的return true吧。

这个是解决CKeditor安装CKfinder之后直接上传文件会出现一个权限的错误提示的问题。
2.      找到ckfinder\core\connector\php\php5\CommandHandler\FileUpload.php 59-61行左右:
 
复制代码
  1.  
  2. if ($sFileName != $sUnsafeFileName) {
  3.     $iErrorNumber = CKFINDER_CONNECTOR_ERROR_UPLOADED_INVALID_NAME_RENAMED;
  4. }

添加以下两行
  $sExtension=CKFinder_Connector_Utils_FileSystem::getExtension($sFileName);  
  $sFileName=date("Ymd")."_".date("His").".".$sExtension;
这个是解决上传中文文件名文件时乱码的问题。
3.      上传文件的存放地址的修改,找到ckfinder/config.php69行的这个代码:

 
复制代码
  1. $baseUrl = '/upload_files/';


象这样填写了后文件就会存放在整站目录下的upload_files文件夹里,与168系统统一。

4.关于ckeditor编辑器的界面的修改等在ckeditor/config.js里面,我自己是将一些设置都注释掉了,但是没有删除,仍然保留在代码里面,这些东西网上可以找到,当然我也会在最后把我的东西放出来。
现在来将编辑器与我们的V6系统开始整合。
1. 先下载编辑器文件,然后放到168系统里面,具体的位置如下图:

1

(请注意,如果你不按我的这个位置来放,那么第2步和第3步里面的相关路径都要修改。)


2.找到member/template/head.htm21行代码:

 
复制代码
  1. <SCRIPT LANGUAGE="JavaScript" src="../images/default/default.js"></SCRIPT>


下面加上这段代码

 
复制代码
  1.  
  2. <script type="text/javascript" src="../ckeditor/ckeditor.js"></script>
  3. <script type="text/javascript" src="../ckfinder/ckfinder.js"></script>
  

3.找到member/template/post.htm447行到第477行代码:
 
复制代码
  1.  
  2. 内容:
  3.                     <!--
  4. EOT;
  5. }
  6. $m_config[moduleSet][edit_w]=$m_config[moduleSet][edit_w]?$m_config[moduleSet][edit_w]:'100%';
  7. $m_config[moduleSet][edit_h]=$m_config[moduleSet][edit_h]?$m_config[moduleSet][edit_h]:'450';
  8. !$lfjid && $m_config[moduleSet][etype]='simple';
  9. $simpleEdit=$m_config[moduleSet][etype]?",items : ['source', 'undo', 'redo', 'fontname', 'fontsize', 'textcolor', 'bgcolor', 'bold', 'italic', 'underline','removeformat', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist','insertunorderedlist','link', 'unlink']":"";
  10. print <<<EOT
  11. -->
  12.                     (<font color="#FF0000">*</font>) </td>
  13.                   <td  width="85%">
  14.                     <!--<iframe id="eWebEditor1" name="eWebEditor1"  src="../ewebeditor/ewebeditor.php?id=content&style=standard&etype={$m_config[moduleSet][etype]}" frameborder="0" scrolling="no" width="{$m_config[moduleSet][edit_w]}" height="{$m_config[moduleSet][edit_h]}"></iframe>
  15.                     <input name="postdb[content]" type="hidden" id="content" value='$rsdb[content]'>-->
  16. <!--
  17. EOT;
  18. if($mid||!$webdb[EditSystem]){print <<<EOT
  19. -->
  20. <script type="text/javascript" charset="utf-8" src="../ewebeditor/3.1.1/kindeditor.js"></script>
  21. <script type="text/javascript">
  22. KE.handpage=true;
  23. KE.systype='article';
  24.     KE.show({
  25.         id : 'content1',
  26.         cssPath : '../ewebeditor/common.css'{$simpleEdit}
  27.     });
  28. </script>
  29. <textarea id="content1" name="postdb[content]" style="width:99%;height:{$m_config[moduleSet][edit_h]}px;visibility:hidden;">$rsdb[content]</textarea>
  30. <!--
  31. EOT;
  32. }else{print <<<EOT
  33. -->
  34. <textarea style="display:none;" id="content1" name="postdb[content]">$rsdb[content]</textarea>
  35. <iframe ID="eWebEditor1" src="../ewebeditor/v4.60/ewebeditor.php?id=content1&style=coolblue" frameborder="0" scrolling="no" width="750" HEIGHT="400"></iframe>
  36. <!--
  37. EOT;
  38. }print <<<EOT
  39. -->
  40. </td>
  41.                 </tr>
  42.  
  43.  


换成这个代码:
 
复制代码
  1.  
  2. 内容:
  3.                     <!--
  4. EOT;
  5. }
  6. print <<<EOT
  7. -->
  8.                     (<font color="#FF0000">*</font>) </td>
  9.                   <td  width="85%">
  10.   <textarea class="ckeditor" id="editor" name="postdb[content]"  style="width:100%; height:450px">$rsdb[content]
  11. </textarea>
  12. <script type="text/javascript">  
  13.             if (typeof CKEDITOR == 'undefined') {  
  14.                 document.write('加载CKEditor失败');  
  15.                 }  
  16.                 else {  
  17.                var editor = CKEDITOR.replace( 'postdb[content]',
  18.                  {
  19.               filebrowserBrowseUrl : '../ckfinder/ckfinder.html',
  20.               filebrowserImageBrowseUrl : '../ckfinder/ckfinder.html?Type=Images',
  21.               filebrowserFlashBrowseUrl : '../ckfinder/ckfinder.html?Type=Flash',
  22.               filebrowserUploadUrl : '../ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files',
  23.               filebrowserImageUploadUrl : '../ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images',
  24.               filebrowserFlashUploadUrl : '../ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Flash'
  25.              });  
  26.                 CKFinder.setupCKEditor(editor, '../ckfinder/');
  27. //ckfinder总目录的相对路径.
  28.                 
  29.               }  
  30. </script> </td>
  31.                 </tr>
  32.  


4.如果你用的是PHP168整站系统V6.02,那么请找到inc/article_function.php1343行这个代码(如果你用的是V6.01,那么下面的可以不看了)



 
复制代码
  1.  
  2. $db->query("
  3. INSERT INTO `{$pre}article$erp`
  4. ( `title`, `smalltitle`,  `fid`,`fname`, `hits`, `pages`, `posttime`, `list`, `uid`, `username`, `author`, `copyfrom`, `copyfromurl`, `titlecolor`, `fonttype`, `picurl`, `ispic`, `yz`, `provinceid`, `cityid`, `yzer`, `yztime`, `keywords`, `jumpurl`, `iframeurl`, `style`, `template`, `target`,`ip`, `lastfid`, `money`, `passwd`, `editer`, `edittime`, `begintime`, `endtime`, `description`, `levels`,allowdown,allowview,mid,htmlname,forbidcomment)
  5. VALUES
  6. ('$postdb[title]','$postdb[smalltitle]','$fid','$fidDB[name]','$postdb[hits]','1','$postdb[posttime]','$postdb[list]','$lfjdb[uid]','$lfjdb[username]','$postdb[author]','$postdb[copyfrom]','$postdb[copyfromurl]','$postdb[titlecolor]','$postdb[fonttype]','$postdb[picurl]','$postdb[ispic]','$postdb[yz]','$provinceid', '$postdb[cityid]','$postdb[yzer]','$postdb[yztime]','$postdb[keywords]','$postdb[jumpurl]','$postdb[iframeurl]','$postdb[style]','$postdb[template]','$postdb[target]','$onlineip','0','$postdb[money]','$postdb[passwd]','$postdb[editer]','$postdb[edittime]','$postdb[begintime]','$postdb[endtime]','$postdb[description]','$postdb[levels]','$postdb[allowdown]','$postdb[allowview]','$mid','$postdb[htmlname]','$postdb[forbidcomment]')
  7. ");
 
 


把这个Forbidcomment”,$postdb[forbidcomment]”连同他前面的逗号一起去掉,或者你直接把下面的句子换成上面的也可以:


 
复制代码
  1.  
  2. $db->query("
  3.     INSERT INTO `{$pre}article$erp`
  4.    ( `title`, `smalltitle`,  `fid`,`fname`, `hits`, `pages`, `posttime`, `list`, `uid`, `username`, `author`, `copyfrom`, `copyfromurl`, `titlecolor`, `fonttype`, `picurl`, `ispic`, `yz`, `provinceid`, `cityid`, `yzer`, `yztime`, `keywords`, `jumpurl`, `iframeurl`, `style`, `template`, `target`,`ip`, `lastfid`, `money`, `passwd`, `editer`, `edittime`, `begintime`, `endtime`, `description`, `levels`,allowdown,allowview,mid,htmlname,forbidcomment)
  5.     VALUES
  6.     ('$postdb[title]','$postdb[smalltitle]','$fid','$fidDB[name]','$postdb[hits]','1','$postdb[posttime]','$postdb[list]','$lfjdb[uid]','$lfjdb[username]','$postdb[author]','$postdb[copyfrom]','$postdb[copyfromurl]','$postdb[titlecolor]','$postdb[fonttype]','$postdb[picurl]','$postdb[ispic]','$postdb[yz]','$provinceid', '$postdb[cityid]','$postdb[yzer]','$postdb[yztime]','$postdb[keywords]','$postdb[jumpurl]','$postdb[iframeurl]','$postdb[style]','$postdb[template]','$postdb[target]','$onlineip','0','$postdb[money]','$postdb[passwd]','$postdb[editer]','$postdb[edittime]','$postdb[begintime]','$postdb[endtime]','$postdb[description]','$postdb[levels]','$postdb[allowdown]','$postdb[allowview]','$mid','$postdb[htmlname]','$postdb[forbidcomment]')
  7.     ");



    总结一下,在HTML方面的修改就是修改模板,我这里已经给出了方法,其他的模板大家一样的修改方法使用即可。


来源:
阅读:3854
日期:2017-02-14

推荐朋友 】 【 评论 】  【 字体: 】 
上一篇:wait_timeout设置不生效是什么原因
下一篇:mysql充分利用CPU多核的处理能力
  >> 相关文章
 
发表评论


点  评: 字数0
用户名:  密码:

  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款