A-A+

dedecms5.7整合编辑器kindeditor4.1.10 版本插件 方法

2016年02月18日 17:18 学习笔记 暂无评论 阅读 349 views 次

【注意:此文章为博主原创文章!转载需注意,请带原文链接,至少也要是txt格式!】

首先这里说一下Kindeditor乱码问题,如果遇到乱码,那么说明你的网站是GBK编码,因为Kindeditor默认是UTF-8编码,所以,之需要更改kindeditor-4.1.10\lang\zh_CN.js 这个目录下的这个文件编码即可排除乱码问题。

首先修改dedecms下的这个文件:include/inc/inc_fun_funAdmin.php 添加如下代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
else  if($GLOBALS['cfg_html_editor']=='kindeditor'){
		$fvalue =htmlspecialchars($fvalue);
		$uploadJson = $GLOBALS['cfg_cmspath']."/include/dialog/kindeditor_post.php";
		$fileManagerJson =  $GLOBALS['cfg_cmspath']."/include/dialog/kindeditor_manager.php";
		$allowFileManager = 'true';
		$extendconfig = '';
		if($etype == 'Member' || $etype == 'MemberLit' || $etype == 'Diy')
		{
			$uploadJson = "";
			$fileManagerJson = "";
			$allowFileManager = 'false';
			$extendconfig = 'allowImageUpload : false,';
			$extendconfig .= 'allowFlashUpload : false,';
			$extendconfig .= 'allowMediaUpload : false,';
			$extendconfig .= 'allowFileUpload : false,';
		}
 
		$items['Member'] = "[
		'source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'code', 'runCode', 'cut', 'copy', 'paste',
		'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
		'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
		'superscript', 'clearhtml', 'quickformat', 'selectall', '|', 'fullscreen', '/',
		'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
		'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'image', 'multiimage',
		'flash', 'media', 'insertfile', 'table', 'hr', 'emoticons', 'baidumap', 'pagebreak',
		'anchor', 'link', 'unlink', '|', 'about']";
 
		$items['Small'] = $items['MemberLit'] = $items['Diy']= "[
		'source', '|', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
		'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
		'insertunorderedlist', '|', 'emoticons', 'image', 'multiimage', 'link', 'unlink']";
 
		$itemconfig = '';
		if(isset($items[$etype]))
		{
			$itemconfig = "items :{$items[$etype]},";
		}
 
		$code = <<<EOT
		<link rel="stylesheet" href="{$GLOBALS['cfg_cmspath']}/include/kindeditor/themes/default/default.css" />
		<link rel="stylesheet" href="{$GLOBALS['cfg_cmspath']}/include/kindeditor/plugins/code/prettify.css" />
		<script charset="GBK" src="{$GLOBALS['cfg_cmspath']}/include/kindeditor/kindeditor.js"></script>
		<script charset="GBK" src="{$GLOBALS['cfg_cmspath']}/include/kindeditor/lang/zh_CN.js"></script>
		<script charset="GBK" type="text/javascript">
			KindEditor.ready(function(K) {
				var editor1 = K.create('textarea[name="{$fname}"]', {
					cssPath : '{$GLOBALS['cfg_cmspath']}/include/plugins/code/prettify.css',
					uploadJson : '$uploadJson',
					fileManagerJson : '$fileManagerJson',
					$extendconfig
					$itemconfig
					allowFileManager : {$allowFileManager}
				});
				prettyPrint();
			});
		</script>
	<textarea name="{$fname}" style="height:{$nheight}px;visibility:hidden;width: 100%;">{$fvalue}</textarea>
EOT;
		//echo $reval;
        if($gtype=="print")
        {
            echo $code;
        }
        else
        {
            return $code;
        }
}

然后上传下面的文件覆盖即可。
http://pan.baidu.com/s/1c1dXPQC

标签:

给我留言