侯体宗的博客
  • 首页
  • Hyperf版
  • beego仿版
  • 人生(杂谈)
  • 技术
  • 关于我
  • 更多分类
    • 文件下载
    • 文字修仙
    • 中国象棋ai
    • 群聊
    • 九宫格抽奖
    • 拼图
    • 消消乐
    • 相册

phpcms中的ckeditor编辑器升级方法

php  /  管理员 发布于 7年前   148

准备:

1.当前phpcms最新版本(自带ckeditor 版本为3.6.6)

2.准备替换的最新ckeditor,版本4.2.1

 

一、开始之前说下原版ckeditor与phpcms的ckeditor的一些主要区别:

1.原版的分页符是一个div标签,而phpcms中编辑器的是[page]。

2.phpcms编辑器下方,多了3个按钮,“分页符”,“子标题”,“附件上传”。

3.由于ckeditor的版本不一样,一些自己开发的插件不能兼容。

二、下面开始替换。

1.备份phpcms的 /statics/js/ckeditor 文件夹(重命名即可)。以及/phpcms/libs/classes/form.class.php (这个文件中有个方法就是创建一个编辑器,使用一些编辑器的工具栏配置需要在这里操作)

2.把新版ckedtior复制到/statics/js/下。打开/statics/js/ckeditor/config.js 文件,用旧版的config.js替换。但请注释掉 config.extraPlugins = ''; 这一行(我想应该是插件不兼容问题)


复制代码代码如下:
/**
* @license Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.html or http://ckeditor.com/license
*/</p><p>CKEDITOR.editorConfig = function( config ) {
// Define changes to default configuration here. For example:
// config.language = 'fr';
// config.uiColor = '#AADC6E';

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 = '';
config.enterMode = CKEDITOR.ENTER_BR;
config.shiftEnterMode = CKEDITOR.ENTER_P;
config.font_names='宋体/宋体;黑体/黑体;仿宋/仿宋_GB2312;楷体/楷体_GB2312;隶书/隶书;幼圆/幼圆;微软雅黑/微软雅黑;'+ config.font_names;
};</p><p>
CKEDITOR.on( 'instanceReady', function( ev ){ with (ev.editor.dataProcessor.writer) { setRules("p", {indent : false, breakAfterOpen : false, breakBeforeClose : false} ); setRules("h1", {indent : false, breakAfterOpen : false, breakBeforeClose : false} ); setRules("h2", {indent : false, breakAfterOpen : false, breakBeforeClose : false} ); setRules("h3", {indent : false, breakAfterOpen : false, breakBeforeClose : false} ); setRules("h4", {indent : false, breakAfterOpen : false, breakBeforeClose : false} ); setRules("h5", {indent : false, breakAfterOpen : false, breakBeforeClose : false} ); setRules("div", {indent : false, breakAfterOpen : false, breakBeforeClose : false} ); setRules("table", {indent : false, breakAfterOpen : false, breakBeforeClose : false} ); setRules("tr", {indent : false, breakAfterOpen : false, breakBeforeClose : false} ); setRules("td", {indent : false, breakAfterOpen : false, breakBeforeClose : false} ); setRules("iframe", {indent : false, breakAfterOpen : false, breakBeforeClose : false} ); setRules("li", {indent : false, breakAfterOpen : false, breakBeforeClose : false} ); setRules("ul", {indent : false, breakAfterOpen : false, breakBeforeClose : false} ); setRules("ol", {indent : false, breakAfterOpen : false, breakBeforeClose : false} ); } });
//CKEDITOR.plugins.load('pgrfilemanager');
function insert_page(editorid)
{
var editor = CKEDITOR.instances[editorid];
editor.insertHtml('[page]');
if($('#paginationtype').val()) {
$('#paginationtype').val(2);
$('#paginationtype').css("color","red");
}
}</p><p>function insert_page_title(editorid,insertdata)
{
if(insertdata)
{
var editor = CKEDITOR.instances[editorid];
var data = editor.getData();
var page_title_value = $("#page_title_value").val();
if(page_title_value=='')
{
$("#msg_page_title_value").html("<font color='red'>请输入子标题</font>");
return false;
}
page_title_value = '[page]'+page_title_value+'[/page]';
editor.insertHtml(page_title_value);
$("#page_title_value").val('');
$("#msg_page_title_value").html('');
if($('#paginationtype').val()) {
$('#paginationtype').val(2);
$('#paginationtype').css("color","red");
}
}
else
{
$("#page_title_div").slideDown("fast");
}
}
var objid = MM_objid = key = 0;
function file_list(fn,url,obj) {
$('#MM_file_list_editor1').append('<div id="MM_file_list_'+fn+'">'+url+' <a href=\'#\' onMouseOver=\'javascript:FilePreview("'+url+'", 1);\' onMouseout=\'javascript:FilePreview("", 0);\'>查看</a> | <a href="'<img src='https:/cms/+url+'>\',\''+fn+'\')">插入</A> | <a href="''+fn+'\',\''+url+'\','+fn+')">删除</a>
');
}

3.打开/statics/js/ckeditor/ckeditor.js 做一些修改,目的是 把工具栏上的分页按钮与phpcms的分页保持一致。

找到:


复制代码代码如下:
CKEDITOR.plugins.pagebreakCmd={exec:function(a){var b=a.lang.pagebreak.alt,b=CKEDITOR.dom.element.createFromHtml('<div style="page-break-after: always;"contenteditable="false" title="'+b+'" aria-label="'+b+'" data-cke-display-name="pagebreak" class="cke_pagebreak"></div>',a.document);a.insertElement(b)},context:"div",allowedContent:{div:{styles:"!page-break-after"},span:{match:function(a){return(a=a.parent)&&"div"==a.name&&a.styles["page-break-after"]},styles:"display"}},requiredContent:"div{page-break-after}"};

替换为:


复制代码代码如下:
CKEDITOR.plugins.pagebreakCmd={exec:function(a){a.insertHtml('[page]');o=document.getElementById('paginationtype');o.options[2].selected = true}};

 4.打开/phpcms/libs/classes/form.class.php 添加一些内容,目的是加上编辑器底部的三个按钮。(phpcms之前是在 ckeditor.js中做的。)

在下面代码后面


复制代码代码如下:
if(!defined('IMAGES_INIT')) {
$ext_str .= '<script type="text/javascript" src="https:/cms/'.JS_PATH.'swfupload/swf2ckeditor.js"></script>';
define('IMAGES_INIT', 1);
}

添加:


复制代码代码如下:
$ext_str.="<div class=\"cke_footer\">";
if(!$disabled_page){
$ext_str.="<a href=\"javascript:insert_page('content')\">分页符</a><a href=\"javascript:insert_page_title('content')\">子标题</a>";
}
$ext_str.="<a onclick=\"flashupload('flashupload', '附件上传','{$textareaid}','','{$allowuploadnum},{$alowuploadexts},{$allowbrowser}','{$module}','{$catid}','{$authkey}');;return false;\" href=\"javascript:void(0);\">附件上传</a>
</div>";

5.复制旧版ckeditor/skins/kama/images/文件夹下的文件 到 新版ckeditor/skins/moono/images/下。目的是一些样式的需要。

6.打开ckeditor\skins\moonoeditor_gecko.css文件,在最后加入三个按钮的样式即可


复制代码代码如下:
/*phpcms 新增编辑器底部按钮样式*/
.cke_top {
background: url("images/line.png") repeat-x scroll 0 0 transparent;
}
.cke_footer {
float: left;
margin-top: 3px;
}
.cke_footer a, .cke_footer a:hover, .cke_footer a:visited,.cke_footer a:active {
background: url("images/cke_fot.gif") repeat-x scroll left bottom transparent;
border: 1px solid #E0E0E0;
color: #666666;
cursor: pointer;
display: block;
float: left;
height: 19px;
line-height: 19px;
margin-right: 8px;
padding: 0 10px;
}
.cke_footer a:hover {
background-position: left top;
}</p><p>
.editor_bottom {
clear: both;
height: 12px;
top:-28px;
position: relative;
}
#page_title_div {
display: none;
height: 78px;
left: 18px;
position: absolute;
top: -120px;
width: 295px;
z-index: 99999;
}
#page_title_div table {
background: none repeat scroll 0 0 #FFFFFF;
border: 2px solid #D5E0E6;
height: 78px;
width: 295px;
}
#page_title_div table td {
border: medium none;
}
#page_title_div table td.title {
color: #333333;
font: 18px/31px "MicroSoft YaHei","SimHei";
height: 26px;
margin: 0;
padding: 0 0 0 12px;
text-align: left;
}
#page_title_div a.close span {
display: none;
}
#page_title_div a.close {
background: url("images/cross.png") no-repeat scroll left 3px transparent;
display: block;
float: right;
height: 16px;
margin-right: 10px;
width: 16px;
}
#page_title_div a.close:hover {
background-position: left -46px;
}
.content_attr {
background: none repeat scroll 0 0 #FFFFCC;
border: 1px solid #CCCCCC;
margin-top: 6px;
padding: 5px 8px;
}
#Capture {
color: #474747;
font-size: 12px;
line-height: 20px;
}
#Capture font {
color: #FF0000;
}
#Capture a {
background: url("images/cdw.png") no-repeat scroll 0 0 transparent;
color: #0075C0;
display: inline-block;
padding-left: 20px;
text-decoration: none;
}
#Capture a:hover {
text-decoration: underline;
}
#Capture #CaptureDown {
background-image: url("images/cd.png");
}

到此,ckeditor编辑器升级完成,需要说明一下的是,phpcms本身自带一个capture插件,本次升级没有考虑它,一是用处不大,而是只能在ie中使用。

如有什么疑问或错误,请告知,谢谢!


  • 上一条:
    Phpcms V9 管理后台登陆及会员注册登录模板的修改方法
    下一条:
    PHPCMS v9过滤采集内容中CSS样式的实现方法
  • 昵称:

    邮箱:

    0条评论 (评论内容有缓存机制,请悉知!)
    最新最热
    • 分类目录
    • 人生(杂谈)
    • 技术
    • linux
    • Java
    • php
    • 框架(架构)
    • 前端
    • ThinkPHP
    • 数据库
    • 微信(小程序)
    • Laravel
    • Redis
    • Docker
    • Go
    • swoole
    • Windows
    • Python
    • 苹果(mac/ios)
    • 相关文章
    • Laravel从Accel获得5700万美元A轮融资(0个评论)
    • PHP 8.4 Alpha 1现已发布!(0个评论)
    • 用Time Warden监控PHP中的代码处理时间(0个评论)
    • 在PHP中使用array_pop + yield实现读取超大型目录功能示例(0个评论)
    • Property Hooks RFC在PHP 8.4中越来越接近现实(0个评论)
    • 近期文章
    • 在go语言中使用api.geonames.org接口实现根据国际邮政编码获取地址信息功能(1个评论)
    • 在go语言中使用github.com/signintech/gopdf实现生成pdf分页文件功能(0个评论)
    • gmail发邮件报错:534 5.7.9 Application-specific password required...解决方案(0个评论)
    • 欧盟关于强迫劳动的规定的官方举报渠道及官方举报网站(0个评论)
    • 在go语言中使用github.com/signintech/gopdf实现生成pdf文件功能(0个评论)
    • Laravel从Accel获得5700万美元A轮融资(0个评论)
    • 在go + gin中gorm实现指定搜索/区间搜索分页列表功能接口实例(0个评论)
    • 在go语言中实现IP/CIDR的ip和netmask互转及IP段形式互转及ip是否存在IP/CIDR(0个评论)
    • PHP 8.4 Alpha 1现已发布!(0个评论)
    • Laravel 11.15版本发布 - Eloquent Builder中添加的泛型(0个评论)
    • 近期评论
    • 122 在

      学历:一种延缓就业设计,生活需求下的权衡之选中评论 工作几年后,报名考研了,到现在还没认真学习备考,迷茫中。作为一名北漂互联网打工人..
    • 123 在

      Clash for Windows作者删库跑路了,github已404中评论 按理说只要你在国内,所有的流量进出都在监控范围内,不管你怎么隐藏也没用,想搞你分..
    • 原梓番博客 在

      在Laravel框架中使用模型Model分表最简单的方法中评论 好久好久都没看友情链接申请了,今天刚看,已经添加。..
    • 博主 在

      佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 @1111老铁这个不行了,可以看看近期评论的其他文章..
    • 1111 在

      佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 网站不能打开,博主百忙中能否发个APP下载链接,佛跳墙或极光..
    • 2016-10
    • 2016-11
    • 2017-06
    • 2017-07
    • 2017-08
    • 2017-09
    • 2017-11
    • 2017-12
    • 2018-01
    • 2018-02
    • 2018-03
    • 2020-03
    • 2020-04
    • 2020-05
    • 2020-06
    • 2020-07
    • 2020-09
    • 2021-02
    • 2021-03
    • 2021-04
    • 2021-05
    • 2021-06
    • 2021-07
    • 2021-08
    • 2021-09
    • 2021-10
    • 2021-11
    • 2021-12
    • 2022-01
    • 2022-02
    • 2022-05
    • 2022-06
    • 2022-07
    • 2022-08
    • 2022-09
    • 2022-10
    • 2022-11
    • 2022-12
    • 2023-01
    • 2023-02
    • 2023-03
    • 2023-04
    • 2023-05
    • 2023-06
    • 2023-07
    • 2023-08
    • 2023-09
    • 2023-10
    • 2023-11
    • 2023-12
    • 2024-01
    • 2024-02
    • 2024-03
    • 2024-04
    • 2024-05
    • 2024-06
    • 2024-07
    • 2024-09
    Top

    Copyright·© 2019 侯体宗版权所有· 粤ICP备20027696号 PHP交流群

    侯体宗的博客