PHPIN.NET

 找回密码
 立即注册
查看: 15367|回复: 1

[7.X版] 帝国CMS整合百度编辑器(UEditor)

[复制链接]

469

主题

31

回帖

5497

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
5497
发表于 2014-8-8 09:19:13 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

x
帝国CMS整合百度编辑器
本文关键字词:百度编辑器,帝国编辑器,整合百度编辑器,UEditor,帝国CMS整合百度编辑器

UEditor深度整合帝国ECMS。UEditor提供非常完善的后端通信API接口,使得UE编辑器整合CMS项目相当简单方便。所有图片、附件、视频等文件存放目录与后台数据记录,都延续使用ECMS的存放方式。本项目将持续已插件形式更新最新的UEditor和ECMS。

百度编辑器(ueditor)使用说明:
•第一步:下载百度编辑器原版(PHP版),解压到帝国/e/extend/ueditor/目录下, [下载地址]
•第二步:使用本项目上controller.php action_crawler.php文件替换/e/extend/ueditor/php/目录下的controller.php action_crawler.php文件。
•复制ueditor.toolbarconfig.js在/e/extend/ueditor/目录下
•第三步:修改帝国CMS字段HTML,在编辑器字段增加处理和编辑器引入代码。[字段管理方法]

  1. <?php
  2. $ziduan = 'newstext'; //编辑器使用的字段名称
  3. if ($enews == 'MAddInfo' || $enews == 'MEditInfo') { //前台投稿
  4.     $qiantai = 1;
  5.     $ziduanzhi = $ecmsfirstpost == 1 ? "" : DoReqValue($mid, $ziduan, stripSlashes($r[$ziduan]));
  6. } else { //后台
  7.     $qiantai = 0;
  8.     $ziduanzhi = $ecmsfirstpost == 1 ? "" : stripSlashes($r[$ziduan]);
  9. }
  10. ?>
  11. <script>var ClassId='<?=$classid?>',InfoId='<?=$id?>',FilePass='<?=$filepass?>',Ehash='<?=$ecms_hashur['ehref']?>',QianTai='<?=$qiantai?>';</script>
  12. <script type="text/javascript" charset="utf-8" src="/e/extend/ueditor/ueditor.config.js"></script>
  13. <script type="text/javascript" charset="utf-8" src="/e/extend/ueditor/ueditor.all.min.js"></script>
  14. <script type="text/javascript" charset="utf-8" src="/e/extend/ueditor/ueditor.toolbarconfig.js"></script>
  15. <textarea id="<?=$ziduan?>" name="<?=$ziduan?>"><?=$ziduanzhi?></textarea>
  16. <script type="text/javascript">
  17. <?=$ziduan?> = UE.getEditor('<?=$ziduan?>',{
  18.     serverUrl: "/e/extend/ueditor/php/controller.php",//自己的请求接口
  19.     toolbars:Default,//工具栏配置文件,具体参考ueditor.toolbarconfig.js文件中说明
  20.     pageBreakTag:'[!--empirenews.page--]',//帝国分页标签
  21.     initialFrameWidth:'100%',//编辑器宽
  22.     initialFrameHeight:300//编辑器高
  23.     //等等其它配置自行添加,参考UE默认配置文件复制修改即可
  24. });
  25. //自定义请求参数
  26. <?=$ziduan?>.ready(function(){
  27.     <?=$ziduan?>.execCommand('serverparam',{
  28.         'filepass':'<?=$filepass?>',//修改时候是信息ID
  29.         'classid' :'<?=$classid?>',
  30.         'qiantai':<?=$qiantai?>
  31.     });
  32. });
  33. </script>
  34. <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#DBEAF5">
  35.     <tr>
  36.         <td bgcolor="#FFFFFF">
  37.             <input name="dokey" type="checkbox" value="1"<?=$r[dokey]==1?' checked':''?>>关键字替换&nbsp;&nbsp;
  38.             <input name="copyimg" type="checkbox" id="copyimg" value="1">远程保存图片(
  39.             <input name="mark" type="checkbox" id="mark" value="1">
  40.             <a href="SetEnews.php" target="_blank">加水印</a>)&nbsp;&nbsp;
  41.             <input name="copyflash" type="checkbox" id="copyflash" value="1">远程保存FLASH(地址前缀:
  42.             <input name="qz_url" type="text" id="qz_url" size="">)
  43.         </td>
  44.     </tr>
  45.     <tr>
  46.     <td bgcolor="#FFFFFF">
  47.         <input name="repimgnexturl" type="checkbox" id="repimgnexturl" value="1"> 图片链接转为下一页&nbsp;&nbsp; <input name="autopage" type="checkbox" id="autopage" value="1">自动分页,每 <input name="autosize" type="text" id="autosize" value="5000" size="5">个字节为一页&nbsp;&nbsp; 取第
  48.         <input name="getfirsttitlepic" type="text" id="getfirsttitlepic" value="" size="1">张上传图为标题图片(
  49.         <input name="getfirsttitlespic" type="checkbox" id="getfirsttitlespic" value="1">缩略图: 宽
  50.         <input name="getfirsttitlespicw" type="text" id="getfirsttitlespicw" size="3" value="<?=$public_r[spicwidth]?>">*高
  51.         <input name="getfirsttitlespich" type="text" id="getfirsttitlespich" size="3" value="<?=$public_r[spicheight]?>">)
  52.     </td>
  53.     </tr>
  54. </table>
复制代码


字段HMTL代码修改截图:
字段HTML代码修改截图.jpg


编辑器调用截图:
编辑器调用截图.jpg

注释:
编辑器的字段代码修改为你当前字段的字段名即可。
controller.php为上传等接口文件,替换官方原版的即可,在php目录下。
ueditor.toolbarconfig.js为工具栏配置文件js,默认配置两项,全功能和演示简版两种,其他的自行添加。另外此文件还提供了一个附件管理的外部接口js
注意:
修改百度编辑器的目录的时候,对应的文件也需要修改,比如引入的js路径,php文件路径等

ueditor.toolbarconfig.js源码:
  1. /*其他的工具栏配置选项自定义即可,编辑器实例化的时候使用 “toolbars:变量名” 即可,比如toolbars:Basic*/
  2. /*最原始的配置
  3. var Default=[['fullscreen', 'source', '|', 'undo', 'redo', '|','bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc', '|','rowspacingtop', 'rowspacingbottom', 'lineheight', '|','customstyle', 'paragraph', 'fontfamily', 'fontsize', '|','directionalityltr', 'directionalityrtl', 'indent', '|','justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|', 'touppercase', 'tolowercase', '|','link', 'unlink', 'anchor', '|', 'imagenone', 'imageleft', 'imageright', 'imagecenter', '|','simpleupload', 'insertimage', 'emotion', 'scrawl', 'insertvideo', 'music', 'attachment', 'map', 'gmap', 'insertframe', 'insertcode', 'webapp', 'pagebreak', 'template', 'background', '|','horizontal', 'date', 'time', 'spechars', 'snapscreen', 'wordimage', '|','inserttable', 'deletetable', 'insertparagraphbeforetable', 'insertrow', 'deleterow', 'insertcol', 'deletecol', 'mergecells', 'mergeright', 'mergedown', 'splittocells', 'splittorows', 'splittocols', 'charts', '|','print', 'preview', 'searchreplace', 'help', 'drafts']];
  4. */
  5. /*以下配置我去除了一些无用的功能 比如谷歌地图国内打不开,百度APP等,代码高亮有BUG,暂时禁用*/
  6. var Default=[['fullscreen','source','|','undo','redo','|','bold','italic','underline','fontborder','strikethrough','superscript','subscript','removeformat','formatmatch','autotypeset','blockquote','pasteplain','|','forecolor','backcolor','insertorderedlist','insertunorderedlist','selectall','cleardoc','|','rowspacingtop','rowspacingbottom','lineheight','|','customstyle','paragraph','fontfamily','fontsize','|','directionalityltr','directionalityrtl','indent','|','justifyleft','justifycenter','justifyright','justifyjustify','|','touppercase','tolowercase','|','link','unlink','anchor','|','imagenone','imageleft','imageright','imagecenter','|','simpleupload','insertimage','scrawl','insertvideo','attachment','map','insertframe','template','background','|','horizontal','date','time','spechars','snapscreen','wordimage','|','inserttable','deletetable','insertparagraphbeforetable','insertrow','deleterow','insertcol','deletecol','mergecells','mergeright','mergedown','splittocells','splittorows','splittocols','charts','|','print','preview','searchreplace','help','drafts','|','pagebreak']],/*Basic为测试简版,自己添加需要的即可*/Basic=[['fullscreen','source','undo','redo','|','bold','italic','underline','fontborder','strikethrough','superscript','subscript','|','removeformat','formatmatch','autotypeset','blockquote','pasteplain','|','forecolor','backcolor','insertorderedlist','insertunorderedlist','|','link','unlink','anchor','|','selectall','cleardoc','|','simpleupload','insertimage','attachment']];



  7. /*********************************帝国CMS附件管理***************************************/
  8. /*暂时未做此文件,使用的是官方默认的,有点小BUG,但是不影响大的使用,后期开发,后台更改路径的话,下面也做响应的修改*/
  9. if(QianTai==0){//判断是后台
  10. UE.registerUI('FileMain',function(editor,uiName){
  11. var btn=new UE.ui.Button({name:'FileMain',title:'帝国CMS附件管理',cssRules:'',/*需要添加的额外样式,指定icon图标,这里默认使用一个重复的icon*/
  12. onclick:function(){
  13. window.open('/e/admin/ecmseditor/FileMain.php?type=1&classid='+ClassId+'&infoid='+InfoId+'&filepass='+FilePass+'&sinfo=1&doing=1'+Ehash,'','width=700,height=550,scrollbars=yes');
  14. }});/*执行*/
  15. return btn;},58/*index 指定添加到工具栏上的那个位置,默认时追加到最后,editorId 指定这个UI是那个编辑器实例上的,默认是页面上所有的编辑器都会添加这个按钮*/
  16. );
  17. }else if(QianTai==1){//判断是前台

  18. }
复制代码


controller.php源码:
  1. <?php
  2. //header('Access-Control-Allow-Origin: http://www.baidu.com'); //设置http://www.baidu.com允许跨域访问
  3. //header('Access-Control-Allow-Headers: X-Requested-With,X_Requested_With'); //设置允许的跨域header
  4. require ('../../../class/connect.php'); //引入数据库配置文件和公共函数文件
  5. require ('../../../class/db_sql.php'); //引入数据库操作文件
  6. require ('../../../data/dbcache/class.php'); //栏目缓存
  7. $CONFIG = json_decode(preg_replace("/\/\*[\s\S]+?\*\//", "", file_get_contents("config.json")), true);
  8. $link = db_connect(); //连接MYSQL
  9. $empire = new mysqlquery(); //声明数据库操作
  10. $qiantai = (int)$_GET['qiantai']; //是否前台
  11. if ($qiantai) {
  12.     $userid = (int)getcvar('mluserid');
  13.     $username = RepPostVar(getcvar('mlusername'));
  14.     $user_fj = '[Member]' . $username;
  15. } else {
  16.     $userid = getcvar('loginuserid', 1);
  17.     $username = getcvar('loginusername', 1);
  18.     $rnd = getcvar('loginrnd', 1);
  19.     $adminr = $empire->fetch1("select userid,groupid,classid,userprikey from {$dbtbpre}enewsuser where userid='$userid' and username='" . $username . "' and rnd='" . $rnd . "' and checked=0 limit 1");
  20.     $user_fj = $username;
  21. }
  22. $classid = (int)$_GET['classid'];
  23. $filepass = (int)$_GET['filepass'];
  24. $action = RepPostVar($_GET['action']);
  25. //验证权限并用帝国的配置项
  26. if ($action != 'config') {
  27.     //获取配置
  28.     $pr = $empire->fetch1("select * from {$dbtbpre}enewspublic");
  29.     $check = check();
  30.     if ($check) {
  31.         echo $check;
  32.         exit();
  33.     } else { //通过验证用帝国配置项及目录等
  34.         if ($qiantai) {
  35.             //前台大小 后缀等限制
  36.             $qaddtransize = $public_r['qaddtransize'] * 1024;
  37.             $CONFIG['imageMaxSize'] = $qaddtransize;
  38.             $CONFIG['scrawlMaxSize'] = $qaddtransize;
  39.             $CONFIG['catcherMaxSize'] = $qaddtransize;
  40.             $qaddtranimgtype = substr($pr['qaddtranimgtype'], 1, -1);
  41.             $qaddtranimgtype = explode('|', $qaddtranimgtype);
  42.             $CONFIG['imageAllowFiles'] = $qaddtranimgtype;
  43.             $CONFIG['imageManagerAllowFiles'] = $qaddtranimgtype;
  44.             $CONFIG['catcherAllowFiles'] = $qaddtranimgtype;
  45.             $qaddtranfilesize = $pr['qaddtranfilesize'] * 1024;
  46.             $CONFIG['fileMaxSize'] = $qaddtranfilesize;
  47.             $CONFIG['videoMaxSize'] = $qaddtranfilesize;
  48.             $qaddtranfiletype = substr($pr['qaddtranfiletype'], 1, -1);
  49.             $qaddtranfiletype = explode('|', $qaddtranfiletype);
  50.             $CONFIG['fileAllowFiles'] = $qaddtranfiletype;
  51.             $CONFIG['fileManagerAllowFiles'] = $qaddtranfiletype;
  52.         } else {
  53.             //后台大小 后缀等限制
  54.             $filesize = $public_r['filesize'] * 1024;
  55.             $CONFIG['imageMaxSize'] = $filesize;
  56.             $CONFIG['scrawlMaxSize'] = $filesize;
  57.             $CONFIG['catcherMaxSize'] = $filesize;
  58.             $CONFIG['videoMaxSize'] = $filesize;
  59.             $CONFIG['fileMaxSize'] = $filesize;
  60.             $filetype = substr($pr['filetype'], 1, -1);
  61.             $filetype = explode('|', $filetype);
  62.             $CONFIG['fileAllowFiles'] = $filetype;
  63.             $CONFIG['fileManagerAllowFiles'] = $filetype;
  64.         }
  65.         $classpath = ReturnFileSavePath($classid); //栏目附件目录
  66.         $time = time();
  67.         $filedir = '';
  68.         if ($public_r['filepath']) {
  69.             $filedir = date($public_r['filepath'], $time) . '/';
  70.             $filedir2 = date($public_r['filepath'], $time);
  71.         }
  72.         $uepath = $pr['newsurl'] . $classpath['filepath'] . $filedir . '{time}{rand:6}'; //百度编辑器上传路径
  73.         //$uepath='/'.$classpath['filepath'].$filedir.md5(uniqid());//百度编辑器上传路径
  74.         if ($pr['openfileserver'] == 1) { //开启远程附件
  75.             $ftp_r = $empire->fetch1("select * from {$dbtbpre}enewspostserver where pid=1"); //返回FTP
  76.             $truepath = $ftp_r['purl'] . $filedir; //日期栏目目录filepath
  77.             $bdpath = ECMS_PATH . $classpath['filepath'] . $filedir;
  78.         } else {
  79.             $truepath = $bdpath . $filedir;
  80.             $bdpath = ECMS_PATH . $classpath['filepath'] . $filedir;
  81.         }
  82.         //$CONFIG['imageUrlPrefix']=$public_r['fileurl'];
  83.         //$CONFIG['scrawlUrlPrefix']=$public_r['fileurl'];
  84.         //$CONFIG['snapscreenUrlPrefix']=$public_r['fileurl'];
  85.         //$CONFIG['catcherUrlPrefix']=$public_r['fileurl'];
  86.         //$CONFIG['videoUrlPrefix']=$public_r['fileurl'];
  87.         //$CONFIG['fileUrlPrefix']=$public_r['fileurl'];
  88.         $CONFIG['imagePathFormat'] = $uepath;
  89.         $CONFIG['scrawlPathFormat'] = $uepath;
  90.         $CONFIG['snapscreenPathFormat'] = $uepath;
  91.         $CONFIG['videoPathFormat'] = $uepath;
  92.         $CONFIG['filePathFormat'] = $uepath;
  93.         $CONFIG['catcherPathFormat'] = $uepath;
  94.     }
  95. }
  96. //验证函数
  97. function check() {
  98.     global $adminr, $dbtbpre, $action, $empire, $pr, $qiantai;
  99.     if ($qiantai == 1) { //前台的验证
  100.         if ($pr['addnews_ok'] == 1) {
  101.             $error = '{"state": "网站已关闭投稿功能!"}';
  102.         } else if (($action == 'uploadimage' || $action == 'uploadscrawl' || $action == 'catchimage') && (!$pr['qaddtran'])) {
  103.             $error = '{"state": "网站已关闭上传图片功能!"}';
  104.         } else if (($action == 'uploadvideo' || $action == 'uploadfile') && !$pr['qaddtranfile']) {
  105.             $error = '{"state": "网站已关闭上传附件功能!"}';
  106.         }
  107.     } else { //后台的验证
  108.         if ($adminr) {
  109.             //通过验证
  110.             
  111.         } else {
  112.             $error = '{"state": "请重新登录"}';
  113.         }
  114.     }
  115.     return $error;
  116. }
  117. switch ($action) {
  118.     case 'config':
  119.         $result = json_encode($CONFIG);
  120.     break;
  121.         /* 上传图片 */
  122.     case 'uploadimage':
  123.         /* 上传涂鸦 */
  124.     case 'uploadscrawl':
  125.         /* 上传视频 */
  126.     case 'uploadvideo':
  127.         /* 上传文件 */
  128.     case 'uploadfile':
  129.         $result = include ("action_upload.php");
  130.         $result = json_decode($result, TRUE);
  131.         if ($pr['openfileserver'] == 1) { //开启远程附件补充前缀
  132.             $result['url'] = str_replace('/d/file/', '', $ftp_r['purl']) . $result['url']; //FTP前缀
  133.             //$result['original']=$result['title'];//标题是路径还是名称
  134.             $result = json_encode($result);
  135.         } else {
  136.             $result['url'] = str_replace('/d/file/', '', $pr['fileurl']) . $result['url']; //FTP前缀
  137.             $result = json_encode($result);
  138.         }
  139.     break;
  140.         /* 列出图片 */
  141.     case 'listimage':
  142.         //$result = include("action_list.php");
  143.         $result = action_list();
  144.     break;
  145.         /* 列出文件 */
  146.     case 'listfile':
  147.         // $result = include("action_list.php");
  148.         $result = action_list();
  149.     break;
  150.         /* 抓取远程文件 */
  151.     case 'catchimage':
  152.         $result = include ("action_crawler.php");
  153.         $result = json_decode($result, TRUE);
  154.         if ($pr['openfileserver'] == 1) { //开启远程附件补充前缀
  155.             $result['url'] = str_replace('/d/file/', '', $ftp_r['purl']) . $result['url']; //FTP前缀
  156.             //$result['original']=$result['title'];//标题是路径还是名称
  157.             $result = json_encode($result);
  158.         } else {
  159.             $result['url'] = str_replace('/d/file/', '', $pr['fileurl']) . $result['url']; //FTP前缀
  160.             $result = json_encode($result);
  161.         }
  162.     break;
  163.     default:
  164.         $result = json_encode(array('state' => '请求地址出错'));
  165.     break;
  166. }
  167. /* 输出结果 */
  168. if (isset($_GET["callback"])) {
  169.     if (preg_match("/^[\w_]+$/", $_GET["callback"])) {
  170.         echo htmlspecialchars($_GET["callback"]) . '(' . $result . ')';
  171.     } else {
  172.         echo json_encode(array('state' => 'callback参数不合法'));
  173.     }
  174. } else {
  175.     echo $result;
  176. }
  177. $actionarr = array('uploadimage', 'uploadscrawl', 'uploadvideo', 'uploadfile', 'catchimage');
  178. if (in_array($action, $actionarr)) {
  179.     $file_r = json_decode($result, true);
  180.     if ($action == 'uploadimage' || $action == 'catchimage' || $action == 'uploadscrawl') {
  181.         $type = 1;
  182.     } elseif ($action == 'uploadvideo') {
  183.         $type = 3;
  184.     } else {
  185.         $type = 0;
  186.     }
  187.     if ($action == "catchimage") //远程保存
  188.     {
  189.         for ($i = 0;$i < count($file_r['list']);$i++) {
  190.             if ($file_r['list'][$i]['state'] == "SUCCESS") {
  191.                 $title = RepPostStr(trim($file_r['list'][$i]['title']));
  192.                 $filesize = RepPostStr(trim($file_r['list'][$i]['size']));
  193.                 $original = RepPostStr(trim($file_r['list'][$i]['original']));
  194.                 eInsertFileTable($title, $filesize, $filedir2, $user_fj, $classid, $original, $type, $filepass, $filepass, $public_r[fpath], 0, 0, 0);
  195.             }
  196.         }
  197.     } else if ($file_r['state'] == "SUCCESS") {
  198.         $title = RepPostStr(trim($file_r[title]));
  199.         //判断是否FLASH
  200.         $typearr = explode('.', $title);
  201.         if ($typearr[1] == 'swf') {
  202.             $type = 2;
  203.         }
  204.         $filesize = RepPostStr(trim($file_r[size]));
  205.         $original = RepPostStr(trim($file_r[original]));
  206.         //帝国上传附件是md5的文件名
  207.         if (!$type) {
  208.             $original = $title;
  209.         }
  210.         eInsertFileTable($title, $filesize, $filedir2, $user_fj, $classid, $original, $type, $filepass, $filepass, $public_r[fpath], 0, 0, 0);
  211.     }
  212.     $efileftp_fr = array(); //远程附件的图片数组
  213.     $efileftp_fr[0] = $bdpath . '/' . $title; //远程附件所用的本地图片路径
  214.    
  215. }
  216. // 列出已经上传的图像和文件
  217. function action_list() {
  218.     global $empire, $dbtbpre, $filepass, $classid, $user_fj, $action, $qiantai, $pr, $ftp_r;
  219.     $list = array();
  220.     $result = json_encode(array("state" => "no match file", "list" => $list, "start" => 0, "total" => 0));
  221.     $where = "classid='$classid' and id='$filepass'";
  222.     if ($qiantai == 1) {
  223.         $where.= " and adduser='$user_fj'";
  224.     }
  225.     if ($action == 'listimage') //图片
  226.     {
  227.         $where.= ' and type=1';
  228.     } else if ($action == 'listfile') //附件、多媒体、FLASH
  229.     {
  230.         $where.= ' and type<>1';
  231.     } else {
  232.         return $result;
  233.     }
  234.     $size = (int)$_GET['size'];
  235.     $start = (int)$_GET['start'];
  236.     $limit = $start . "," . $size;
  237.     $total = $empire->gettotal("select count(*) as total from {$dbtbpre}enewsfile_1 where " . $where);
  238.     $sql = $empire->query("select * from {$dbtbpre}enewsfile_1 where " . $where . " order by fileid DESC limit " . $limit);
  239.     $i = 0;
  240.     while ($r = $empire->fetch($sql)) {
  241.         $classpath = ReturnFileSavePath($r[classid], $r[fpath]); //栏目附件目录
  242.         if ($pr['openfileserver'] == 1) { //开启远程附件补充前缀
  243.             $classpath['filepath'] = str_replace('d/file/', '', $ftp_r['purl']) . $classpath['filepath']; //FTP前缀
  244.             
  245.         } else {
  246.             $classpath['filepath'] = str_replace('d/file/', '', $pr['fileurl']) . $classpath['filepath'];
  247.         }
  248.         $list[$i]['url'] = $classpath['filepath'] . ($r['path'] ? $r['path'] . '/' : $r[path]) . $r['filename'];
  249.         $list[$i]['mtime'] = $r['filetime'];
  250.         $i++;
  251.     }
  252.     /* 返回数据 */
  253.     if (!count($list)) {
  254.         return $result;
  255.     }
  256.     return $result = json_encode(array("state" => "SUCCESS", "list" => $list, "start" => $start, "total" => $total));
  257. }
  258. db_close();
  259. $empire = null;
  260. exit();
  261. ?>
复制代码


action_crawler.php源码:
  1. <?php
  2. /**
  3. * 抓取远程图片
  4. * User: Jinqn
  5. * Date: 14-04-14
  6. * Time: 下午19:18
  7. */
  8. set_time_limit(0);
  9. include("Uploader.class.php");

  10. /* 上传配置 */
  11. $config = array(
  12.     "pathFormat" => $CONFIG['catcherPathFormat'],
  13.     "maxSize" => $CONFIG['catcherMaxSize'],
  14.     "allowFiles" => $CONFIG['catcherAllowFiles'],
  15.     "oriName" => "remote.png"
  16. );
  17. $fieldName = $CONFIG['catcherFieldName'];

  18. /* 抓取远程图片 */
  19. $list = array();
  20. if (isset($_POST[$fieldName])) {
  21.     $source = $_POST[$fieldName];
  22. } else {
  23.     $source = $_GET[$fieldName];
  24. }
  25. foreach ($source as $imgUrl) {
  26.     $item = new Uploader($imgUrl, $config, "remote");
  27.     $info = $item->getFileInfo();
  28. /* URL处理 */
  29. if($pr['openfileserver']==1){//开启远程附件补充前缀
  30. $info["url"]=  str_replace('/d/file/', '', $ftp_r['purl']).$info["url"];//FTP前缀
  31. }else{
  32. $info["url"]=  str_replace('/d/file/', '', $pr['fileurl']).$info["url"];//非FTP前缀
  33. }
  34. /* URL处理 */
  35.     array_push($list, array(
  36.         "state" => $info["state"],
  37.         "url" => $info["url"],
  38.         "size" => $info["size"],
  39.         "title" => htmlspecialchars($info["title"]),
  40.         "original" => htmlspecialchars($info["original"]),
  41.         "source" => htmlspecialchars($imgUrl)
  42.     ));
  43. }

  44. /* 返回抓取数据 */
  45. return json_encode(array(
  46.     'state'=> count($list) ? 'SUCCESS':'ERROR',
  47.     'list'=> $list
  48. ));
复制代码


前台使用:
  1. 前台使用例子:

  2. 修改内容模板加入下面代码(注意:#newstext为前台编辑器容器ID)

  3. <style type="text/css">
  4. /*解决代码高亮太长不换行*/
  5. .syntaxhighlighter{word-break:break-all;}
  6. </style>
  7. <script src="/e/extend/ueditor/ueditor.parse.min.js"></script>
  8. <script>uParse('#newstext', {rootPath: '/e/extend/ueditor/'})</script>
  9. <div id="newstext">[!--newstext--]</div>
复制代码


本项目仅测试于帝国CMS7.0(UFT-8)正式版,其他版本暂时未测,请自行测试,支持帝国商业版的远程附件功能。
未修改百度UE(UEditor)的其他代码,为了确保后期升级。至于图片水印和附件删除等功能,考虑到帝国CMS升级所以未作整合,暂时可以依靠帝国CMS自身的管理功能即可,水印也可批量添加。

前台高亮等使用参考百度编辑器官方说明。这里不多说。后期会开发附件管理,图片水印,以及在线图片裁剪等功能性融合系统。

水印及附件管理说明截图:
水印和附件管理.jpg





项目源码打包:
ueditor.zip (66.52 KB, 下载次数: 26)







469

主题

31

回帖

5497

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
5497
 楼主| 发表于 2015-2-5 09:10:12 | 显示全部楼层
编辑器7.2问题请参考7.2安全参数做响应修改即可。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|PHPIN.NET ( 冀ICP备12000898号-14 )|网站地图

GMT+8, 2024-3-29 08:06

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表