一直以来都感觉到PHPCMS自带的编辑器CKeditor不好用,编辑文章版面各种不方便
在百度了很多关于更换PHPCMS编辑器的方法,当然在论坛里也搜索不少关于编辑器更换的帖子
由于我用PHPCMS是做的站群(全HTTPS环境下多套PHPCMS,每套PHPCMS下有建立了多个子站点,同时通过PHPSSO和UC互通整合了DZ论坛,同步注册登陆,这个有需要的可以单独联系我),也整合了远程附件插件,在编辑器中上传图片或文件也都是存储到第三方存储返回远程地址的,这也给我想更换编辑器带来了一定难度,同时我还需要编辑器增加一个代码高亮插件。
注意 : 哪些文件需要修改?
statics/js/ckeditor/config.js(先替换,后修改)(主要就是注释掉部分php代码)
phpcms/libs/classes/form.class.php(增加几行php代码)
statics/js/ckeditor/skins/moono-lisa/editor.css(增加几行css代码)
详细步骤:
1、将statics/js/ckeditor目录更名成ckeditor_bak(备份以便以后恢复);
2、下载CKEditor 4.8.0 Full的压缩包,
3、将zip压缩包中的ckeditor目录解压到statics/js目录下;
4、将第一步原编辑器目录ckeditor_bak中的config.js文件复制并覆盖到ckeditor目录中;
5、接着修改覆盖后的ckeditor/config.js,注释掉以下几行代码
// config.language = 'fr'; 注释此行
config.uiColor = '#f7f5f4';
config.width = '';
//config.removePlugins = 'elementspath,scayt'; 注释此行
//config.disableNativeSpellChecker = false; 注释此行
//config.resize_dir = 'vertical'; 注释此行
config.keystrokes =[[ CKEDITOR.CTRL + 13 /*Enter*/, 'maximize' ]];
//config.extraPlugins = 'capture,videoforpc,flashplayer'; 注释此行
//config.enterMode = CKEDITOR.ENTER_BR; 注释此行
//config.shiftEnterMode = CKEDITOR.ENTER_P; 注释此行
config.font_names='宋体/宋体;黑体/黑体;仿宋/仿宋_GB2312;楷体/楷体_GB2312;隶书/隶书;幼圆/幼圆;微软雅黑/微软雅黑;'+ config.font_names;
6、修改phpcms/libs/classes/form.class.php,找到如下代码,大约第70行左右
$str .= '</script>'
在此行后增加以下代码:
$str .= '<div class="cke_footer">';
if($show_page == 'true') $str .= '<a href=\'javascript:insert_page("'.$textareaid.'")\'>分页符</a><a href=\'javascript:insert_page_title("'.$textareaid.'")\'>子标题</a>';
if($allowupload) $str .= '<a href="javascript:void(0);" onclick="flashupload(\'flashupload\', \'附件上传\',\''.$textareaid.'\',\'\',\''.$allowuploadnum.','.$alowuploadexts.','.$allowbrowser.'\',\''.$module.'\',\''.$catid.'\',\''.$authkey.'\');return false;">附件上传</a>'; $str .= '</div>';
7、复制以下CSS代码到statics/js/ckeditor/skins/moono-lisa/editor.css文件的最后面:
.cke_footer{ float:left; margin-top:3px}
.cke_footer a,.cke_footer a:hover, .cke_footer a:visited, .cke_footer a:active{display:block; float:left;border:1px solid #e0e0e0; margin-right:8px;height:19px;line-height:19px;padding:0 10px;color:#666;cursor: hand;!important;cursor: pointer}
.cke_footer a:hover{background-position: left top}
.editor_bottom{ position:relative; height:1px; clear:both}
#page_title_div{width:295px; height:78px;position:absolute;display:none; z-index:99999; top:-120px; left:18px}
#page_title_div table{border:2px solid #d5e0e6; background:#fff;width:295px; height:78px;}
#page_title_div table td{ border:none}#page_title_div table td.title{text-align:left;height:26px;*height:25px;font:18px/31px "MicroSoft YaHei","SimHei";color:#333;*line-height:25px; margin:0; padding:0 0 0 12px}
#page_title_div a.close span{ display:none}
#page_title_div a.close{background: url(images/cross.png) no-repeat left 3px; display:block; float:right; margin-right:10px; width:16px; height:16px;}
#page_title_div a.close:hover{background-position: left -46px}
.content_attr{ border:1px solid #CCC; padding:5px 8px; background:#FFC; margin-top:6px}
#Capture{color:#474747; font-size:12px; line-height:20px}
#Capture font{color:red}
#Capture a{color:#0075c0;display:inline-block;zoom:1;*display:inline; background:url(images/cdw.png) no-repeat; padding-left:20px; text-decoration:none}
#Capture a:hover{text-decoration: underline}
#Capture #CaptureDown {background-image:url(images/cd.png)}
8、完成修改。
清空浏览器缓存,重新打开phpcmsV9后台,进入内容编辑器页面查看编辑器效果。