齐博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;
}
实际上官方是建议在里面写自己的函数,比如网上建议写成这样:
复制代码
-
if(isset($_SESSION['mySession'])){
-
return true;
-
} else {
-
return false;
-
}
|
不过实际上这样是有问题的,大家先用上面的return true吧。
这个是解决CKeditor安装CKfinder之后直接上传文件会出现一个权限的错误提示的问题。
2. 找到ckfinder\core\connector\php\php5\CommandHandler\FileUpload.php第 59-61行左右:
复制代码
-
-
if ($sFileName != $sUnsafeFileName) {
-
$iErrorNumber = CKFINDER_CONNECTOR_ERROR_UPLOADED_INVALID_NAME_RENAMED;
-
}
|
添加以下两行
$sExtension=CKFinder_Connector_Utils_FileSystem::getExtension($sFileName);
$sFileName=date("Ymd")."_".date("His").".".$sExtension;
这个是解决上传中文文件名文件时乱码的问题。
3. 上传文件的存放地址的修改,找到ckfinder/config.php第69行的这个代码:
复制代码
-
$baseUrl = '/upload_files/';
|
象这样填写了后文件就会存放在整站目录下的upload_files文件夹里,与168系统统一。
4.关于ckeditor编辑器的界面的修改等在ckeditor/config.js里面,我自己是将一些设置都注释掉了,但是没有删除,仍然保留在代码里面,这些东西网上可以找到,当然我也会在最后把我的东西放出来。
现在来将编辑器与我们的V6系统开始整合。
1. 先下载编辑器文件,然后放到168系统里面,具体的位置如下图:
1
(请注意,如果你不按我的这个位置来放,那么第2步和第3步里面的相关路径都要修改。)
2.找到member/template/head.htm第21行代码:
复制代码
-
<SCRIPT LANGUAGE="JavaScript" src="../images/default/default.js"></SCRIPT>
|
下面加上这段代码
复制代码
-
-
<script type="text/javascript" src="../ckeditor/ckeditor.js"></script>
-
<script type="text/javascript" src="../ckfinder/ckfinder.js"></script>
|
3.找到member/template/post.htm第447行到第477行代码:
复制代码
-
-
内容:
-
<!--
-
EOT;
-
}
-
$m_config[moduleSet][edit_w]=$m_config[moduleSet][edit_w]?$m_config[moduleSet][edit_w]:'100%';
-
$m_config[moduleSet][edit_h]=$m_config[moduleSet][edit_h]?$m_config[moduleSet][edit_h]:'450';
-
!$lfjid && $m_config[moduleSet][etype]='simple';
-
$simpleEdit=$m_config[moduleSet][etype]?",items : ['source', 'undo', 'redo', 'fontname', 'fontsize', 'textcolor', 'bgcolor', 'bold', 'italic', 'underline','removeformat', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist','insertunorderedlist','link', 'unlink']":"";
-
print <<<EOT
-
-->
-
(<font color="#FF0000">*</font>) </td>
-
<td width="85%">
-
<!--<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>
-
<input name="postdb[content]" type="hidden" id="content" value='$rsdb[content]'>-->
-
<!--
-
EOT;
-
if($mid||!$webdb[EditSystem]){print <<<EOT
-
-->
-
<script type="text/javascript" charset="utf-8" src="../ewebeditor/3.1.1/kindeditor.js"></script>
-
<script type="text/javascript">
-
KE.handpage=true;
-
KE.systype='article';
-
KE.show({
-
id : 'content1',
-
cssPath : '../ewebeditor/common.css'{$simpleEdit}
-
});
-
</script>
-
<textarea id="content1" name="postdb[content]" style="width:99%;height:{$m_config[moduleSet][edit_h]}px;visibility:hidden;">$rsdb[content]</textarea>
-
<!--
-
EOT;
-
}else{print <<<EOT
-
-->
-
<textarea style="display:none;" id="content1" name="postdb[content]">$rsdb[content]</textarea>
-
<iframe ID="eWebEditor1" src="../ewebeditor/v4.60/ewebeditor.php?id=content1&style=coolblue" frameborder="0" scrolling="no" width="750" HEIGHT="400"></iframe>
-
<!--
-
EOT;
-
}print <<<EOT
-
-->
-
</td>
-
</tr>
-
-
|
换成这个代码:
复制代码
-
-
内容:
-
<!--
-
EOT;
-
}
-
print <<<EOT
-
-->
-
(<font color="#FF0000">*</font>) </td>
-
<td width="85%">
-
<textarea class="ckeditor" id="editor" name="postdb[content]" style="width:100%; height:450px">$rsdb[content]
-
</textarea>
-
<script type="text/javascript">
-
if (typeof CKEDITOR == 'undefined') {
-
document.write('加载CKEditor失败');
-
}
-
else {
-
var editor = CKEDITOR.replace( 'postdb[content]',
-
{
-
filebrowserBrowseUrl : '../ckfinder/ckfinder.html',
-
filebrowserImageBrowseUrl : '../ckfinder/ckfinder.html?Type=Images',
-
filebrowserFlashBrowseUrl : '../ckfinder/ckfinder.html?Type=Flash',
-
filebrowserUploadUrl : '../ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files',
-
filebrowserImageUploadUrl : '../ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images',
-
filebrowserFlashUploadUrl : '../ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Flash'
-
});
-
CKFinder.setupCKEditor(editor, '../ckfinder/');
-
//ckfinder总目录的相对路径.
-
-
}
-
</script> </td>
-
</tr>
-
|
4.如果你用的是PHP168整站系统V6.02,那么请找到inc/article_function.php第1343行这个代码(如果你用的是V6.01,那么下面的可以不看了):
复制代码
-
-
$db->query("
-
INSERT INTO `{$pre}article$erp`
-
( `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)
-
VALUES
-
('$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]')
-
");
|
把这个”Forbidcomment”, “$postdb[forbidcomment]”连同他前面的逗号一起去掉,或者你直接把下面的句子换成上面的也可以:
复制代码
-
-
$db->query("
-
INSERT INTO `{$pre}article$erp`
-
( `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)
-
VALUES
-
('$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]')
-
");
|
总结一下,在HTML方面的修改就是修改模板,我这里已经给出了方法,其他的模板大家一样的修改方法使用即可。
|
来源:
阅读:3854 次
日期:2017-02-14
|
【 推荐朋友 】 【 评论 】
【 字体:大 中
小 】 |
|