广州传奇网络

地址:广州市天河区东圃大马路富华楼C座

电话:13808825895

邮箱:gz020wbs@163.com

QQ:1564443073

网址:http://www.020wbs.com/

首页 > 二次开发Ecshop二次开发 > ecshop彻底编辑器为kindeditor实现在多张图片上传

二次开发Ecshop二次开发

二次开发Ecshop二次开发

ecshop彻底编辑器为kindeditor实现在多张图片上传

 ecshop彻底编辑器为kindeditor实现在多张图片上传

使用过ECSHOP后台产品、文章编辑的朋友都知道ECSHOP编辑器是'FCKeditor,'FCK官早已经不再更新FCKeditor了,但是ECSHOP却一直还在使用,FCKeditor浏览器的缺点:漏洞多,容易被不怀好意的人利用;不能一次上传多张图片。。。。。


最近发现有网友发过关于用kindeditor替换FCKeditor的文章,感觉FCKeditor还不错。于是就是baidu、google上搜,现把我的使用经验分享给大家。

先来欣赏一下kindeditor编辑器的多图上传功能


下面是实现替换kindeditor编辑器的步骤及方法:

1、从kindedito官网上下载最新版的kindeditor-4.1.10.zip

2、解压kindeditor-4.1.10.zip到kindeditor文件夹, 并将kindeditor上传 /includes目录下

3、打开/admin/includes/lib_main.php
找到 create_html_editor 函数,
/**
* 生成编辑器
* @param string input_name 输入框名称
* @param string input_value 输入框值
*/
function create_html_editor($input_name, $input_value = '')
{
global $smarty;

$editor = new FCKeditor($input_name);
$editor->BasePath = '../includes/fckeditor/';
$editor->ToolbarSet = 'Normal';
$editor->Width = '100%';
$editor->Height = '320';
$editor->Value = $input_value;
$FCKeditor = $editor->CreateHtml();
$smarty->assign('FCKeditor', $FCKeditor);
}

把它替换为: 
function create_new_kindedit($input_name, $input_value = '')
{
global $smarty;
$kindeditor="<script charset='utf-8' src='../includes/kindeditor/kindeditor-min.js'></script>
<script>
var editor;
KindEditor.ready(function(K) {
editor = K.create('textarea[name=\"$input_name\"]', {
allowFileManager : true,
width : '100%',
height: '400px',
resizeType: 0 //固定宽高
});
});
</script>
<textarea id=\"$input_name\" name=\"$input_name\" style='width:100%;height:400px;'>$input_value</textarea>
";
$smarty->assign('FCKeditor', $kindeditor); 
}

不管是UTF-8、还是 GBK都适用。 注意一定要加上charset='utf-8'


4、修改includes/kindeditor/php/upload_json.php :

(1)找到:
//文件保存目录路径
在它的下面添加:
$php_save_path=str_replace($php_url,'',$php_path). '/'; //将上传的文件保存根目录了


(2)找到:
$save_path = $php_path . '../attached/';
修改为:
$save_url = 'images/upload/'; //上传文件保存路径

(3)找到:
$save_url = $php_url . '../attached/';
修改为:
$save_url = '/images/upload/'; //上传文件保存路径

5、.浏览服务器路径修改includes/kindeditor/php/file_manager_json.php
(1)在$php_url = dirname($_SERVER['PHP_SELF']) . '/'; 的下面添加:
$php_save_path=str_replace($php_url,'',$php_path). '/';

(2)找到:
$root_path = $php_path . '../../../upload/';
修改为:
$root_path = $php_save_path . 'images/upload/'; //上传文件保存路径

(3)找到:
$root_url = $php_url . '../attached/';
修改为:
$save_url = '/images/upload/'; //上传文件保存路径


6、接下来修改ECSHOP后台编辑器调用
(1)打开后台产品 /admin/goods.php
找到:
create_html_editor('goods_desc', $goods['goods_desc']);
修改为
create_new_kindedit('goods_desc', $goods['goods_desc']);// 调用kindeditor编辑器


(2)后台文章:/admin/article.php
找到:
create_html_editor('FCKeditor1');
修改为
create_new_kindedit('FCKeditor1'); //调用kindeditor编辑器

找到:
create_html_editor('FCKeditor1',$article['content']);
修改为
create_new_kindedit('FCKeditor1',$article['content']); //调用kindeditor编辑器

kindeditor编辑器限制了最多只能上传20张图怎么办?
打开
/includes/kindeditor/kindeditor-all.js 中的
imageUploadLimit = K.undef(self.imageUploadLimit, 20),
修改红色数字为你想要的

打开
/includes/kindeditor/plugins/multiimage/multiimage.js

KindEditor.plugin('multiimage', function(K) {
var self = this, name = 'multiimage',
formatUploadUrl = K.undef(self.formatUploadUrl, true),
uploadJson = K.undef(self.uploadJson, self.basePath + 'php/upload_json.php'),
imgPath = self.pluginsPath + 'multiimage/images/',
imageSizeLimit = K.undef(self.imageSizeLimit, '1MB'),
imageFileTypes = K.undef(self.imageFileTypes, '*.jpg;*.gif;*.png'),
imageUploadLimit = K.undef(self.imageUploadLimit, 20),
filePostName = K.undef(self.filePostName, 'imgFile'),
lang = self.lang(name + '.');
修改红色数字为你想要的

如果你的kindeditor编辑器已经正常使用了,可以把:
/article.php /goods.php 里的
require_once(ROOT_PATH . "includes/fckeditor/fckeditor.php");
注释掉或者删除掉,再把/includes/fckeditor 目录删除,这样就完全更换了ECSHOP的编辑器了