TypechoJoeTheme

Dcr163的博客

统计

phpcms编辑器替换成百度ueditor

2018-08-29
/
0 评论
/
829 阅读
/
正在检测是否收录...
08/29

首先去百度官网下载ueditor,也可以直接下载 

ueditor1_4_3_3-utf8-php.zip

下载完成解压出来目录如下:

然后复制文件夹到:/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就替换完成了

朗读
赞(2)
版权属于:

Dcr163的博客

本文链接:

https://dcr163.cn/391.html(转载时请注明本文出处及文章链接)

评论 (0)

人生倒计时

今日已经过去小时
这周已经过去
本月已经过去
今年已经过去个月

最新回复

  1. William Tardent
    2024-02-27
  2. Maryann Hamer
    2024-02-27
  3. Sanora Pantano
    2024-02-24
  4. aa
    2024-02-21
  5. Kassie Baum
    2024-01-28

标签云