phpcms编辑器替换成百度ueditor
首先去百度官网下载ueditor,也可以直接下载
下载完成解压出来目录如下:
然后复制文件夹到:/statics/js 这个目录下;
开始修改phpcms自带的富文本编辑框,修改文件:/phpcms/libs/classes/form.class.php,修改之前,清先备份一份文件,防止修改后错误导致网站出现问题。
把:
if(!defined('EDITOR_INIT')) { $str = ''; define('EDITOR_INIT', 1); } if($toolbar == 'basic') { $toolbar = defined('IN_ADMIN') ? "['Source']," : ''; $toolbar .= "['Bold', 'Italic', '-', 'NumberedList', 'BulletedList', '-', 'Link', 'Unlink' ],['Maximize'],\r\n"; } elseif($toolbar == 'full') { if(defined('IN_ADMIN')) { $toolbar = "['Source',"; } else { $toolbar = '['; } $toolbar .= "'-','Templates'], ['Cut','Copy','Paste','PasteText','PasteFromWord','-','Print'], ['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],['ShowBlocks'],['Image','Capture','Flash','flashplayer','MyVideo'],['Maximize'], '/', ['Bold','Italic','Underline','Strike','-'], ['Subscript','Superscript','-'], ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'], ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'], ['Link','Unlink','Anchor'], ['Table','HorizontalRule','Smiley','SpecialChar','PageBreak'], '/', ['Styles','Format','Font','FontSize'], ['TextColor','BGColor'], ['attachment'],\r\n"; } elseif($toolbar == 'desc') { $toolbar = "['Bold', 'Italic', '-', 'NumberedList', 'BulletedList', '-', 'Link', 'Unlink', '-', 'Image', '-','Source'],['Maximize'],\r\n"; } else { $toolbar = ''; } $str .= "\r\n"; $str .= "CKEDITOR.replace( '$textareaid',{"; $str .= "height:{$height},"; $show_page = ($module == 'content' && !$disabled_page) ? 'true' : 'false'; $str .="pages:$show_page,subtitle:$show_page,textareaid:'".$textareaid."',module:'".$module."',catid:'".$catid."',\r\n"; if($allowupload) { $authkey = upload_key("$allowuploadnum,$alowuploadexts,$allowbrowser"); $str .="flashupload:true,alowuploadexts:'".$alowuploadexts."',allowbrowser:'".$allowbrowser."',allowuploadnum:'".$allowuploadnum."',authkey:'".$authkey."',\r\n"; } if($allowupload) $str .= "filebrowserUploadUrl : 'index.php?m=attachment&c=attachments&a=upload&module=".$module."&catid=".$catid."&dosubmit=1',\r\n"; if($color) { $str .= "extraPlugins : 'uicolor',uiColor: '$color',"; } $str .= "toolbar :\r\n"; $str .= "[\r\n"; $str .= $toolbar; $str .= "]\r\n"; //$str .= "fullPage : true"; $str .= "});\r\n"; $str .= ''; $ext_str = ""; if(!defined('IMAGES_INIT')) { $ext_str .= ''; define('IMAGES_INIT', 1); } $ext_str .= "".L('subtitle')."× "; $ext_str .= ""; if(is_ie()) $ext_str .= ""; $str .= $ext_str;
替换成
//修改为百度编辑器 s if(!defined('EDITOR_INIT')) { $str = ''; $str .= ''; define('EDITOR_INIT', 1); } $str .= "\r\n"; $str .= "var ue = UE.getEditor('$textareaid',{ "; $str .= "autoHeightEnabled: true,"; $str .= "autoFloatEnabled: true,"; $str .= "initialFrameWidth: '99.9%',"; $str .= "initialFrameHeight: $height"; $str .= "});"; //创建百度编辑器的id $str .= ''; //修改为百度编辑器 e
这样替换完就可以了,需要定制工具栏的,请到百度编辑器官网查看文档,修改上面的配置就行了;
接下来修改文件上传的信息,修改文件:/statics/js/ueditor/php/config.json
把
"imagePathFormat": "/ueditor/php/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}",
替换成
"imagePathFormat": "./uploadfile/ueditor/image/{yyyy}{mm}{dd}/{time}{rand:6}",
把
"scrawlPathFormat": "/ueditor/php/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}",
替换成
"scrawlPathFormat": "./uploadfile/ueditor/image/{yyyy}{mm}{dd}/{time}{rand:6}",
把
"snapscreenPathFormat": "/ueditor/php/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}",
替换成
"snapscreenPathFormat": "./uploadfile/ueditor/image/{yyyy}{mm}{dd}/{time}{rand:6}",
把
"catcherPathFormat": "/ueditor/php/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}",
替换成
"catcherPathFormat": "./uploadfile/ueditor/image/{yyyy}{mm}{dd}/{time}{rand:6}"
把
"videoPathFormat": "/ueditor/php/upload/video/{yyyy}{mm}{dd}/{time}{rand:6}",
替换成
"videoPathFormat": "./uploadfile/ueditor/video/{yyyy}{mm}{dd}/{time}{rand:6}",
把
"filePathFormat": "/ueditor/php/upload/file/{yyyy}{mm}{dd}/{time}{rand:6}",
替换成
"filePathFormat": "./uploadfile/ueditor/file/{yyyy}{mm}{dd}/{time}{rand:6}",
把
"imageManagerListPath": "/ueditor/php/upload/image/",
替换成
"imageManagerListPath": "./uploadfile/ueditor/image/",
把
"fileManagerListPath": "/ueditor/php/upload/file/",
替换成
"fileManagerListPath": "./uploadfile/ueditor/file/",
这个文件 /statics/js/ueditor/php/config.json 修改完成;
修改文件:/statics/js/ueditor/php/Uploader.class.php
把
$rootPath = $_SERVER['DOCUMENT_ROOT'];
替换成
$rootPath = dirname(dirname(dirname(dirname(dirname(__FILE__))))); $rootPath = str_replace('\\','/',$rootPath);
这个文件:/statics/js/ueditor/php/Uploader.class.php,修改完成;
修改文件:/statics/js/ueditor/php/action_list.php
把
$path = $_SERVER['DOCUMENT_ROOT'] . (substr($path, 0, 1) == "/" ? "":"/") . $path;
替换成
$rootPath = dirname(dirname(dirname(dirname(dirname(__FILE__))))); $rootPath = str_replace('\\','/',$rootPath); $path = $rootPath.$path;
这个文件:/statics/js/ueditor/php/action_list.php, 修改完成。
修改\statics\css\zh-cn-system.css 下.fixed-bottom .fixed-but{}属性,添加z-index: 999;
这样整个phpcms编辑器替换百度ueditor就替换完成了
Dcr163的博客
http://dcr163.cn/391.html(转载时请注明本文出处及文章链接)