dede后台编辑器更改

1、下载百度开发的UEditor编辑器(对应版本);

2、 解压下载的zip文件;

3、将解压后得到的文件夹拷贝到您网站目录下的include文件夹下并改名为ueditor;

4、将inc文件夹里边的 inc_fun_funAdmin.php的代码改为:

  1 <?php   if(!defined('DEDEINC')) exit('dedecms');
  2 /**
  3  * 管理员后台基本函数
  4  *
  5  * @version        $Id:inc_fun_funAdmin.php 1 13:58 2010年7月5日Z tianya $
  6  * @package        DedeCMS.Libraries
  7  * @copyright      Copyright (c) 2007 - 2010, DesDev, Inc.
  8  * @license        http://help.dedecms.com/usersguide/license.html
  9  * @link           http://www.dedecms.com
 10  */
 11 
 12 /**
 13  *  获取拼音信息
 14  *
 15  * @access    public
 16  * @param     string  $str  字符串
 17  * @param     int  $ishead  是否为首字母
 18  * @param     int  $isclose  解析后是否释放资源
 19  * @return    string
 20  */
 21 function SpGetPinyin($str, $ishead=0, $isclose=1)
 22 {
 23     global $pinyins;
 24     $restr = '';
 25     $str = trim($str);
 26     $slen = strlen($str);
 27     if($slen < 2)
 28     {
 29         return $str;
 30     }
 31     if(count($pinyins) == 0)
 32     {
 33         $fp = fopen(DEDEINC.'/data/pinyin.dat', 'r');
 34         while(!feof($fp))
 35         {
 36             $line = trim(fgets($fp));
 37             $pinyins[$line[0].$line[1]] = substr($line, 3, strlen($line)-3);
 38         }
 39         fclose($fp);
 40     }
 41     for($i=0; $i<$slen; $i++)
 42     {
 43         if(ord($str[$i])>0x80)
 44         {
 45             $c = $str[$i].$str[$i+1];
 46             $i++;
 47             if(isset($pinyins[$c]))
 48             {
 49                 if($ishead==0)
 50                 {
 51                     $restr .= $pinyins[$c];
 52                 }
 53                 else
 54                 {
 55                     $restr .= $pinyins[$c][0];
 56                 }
 57             }else
 58             {
 59                 $restr .= "_";
 60             }
 61         }else if( preg_match("/[a-z0-9]/i", $str[$i]) )
 62         {
 63             $restr .= $str[$i];
 64         }
 65         else
 66         {
 67             $restr .= "_";
 68         }
 69     }
 70     if($isclose==0)
 71     {
 72         unset($pinyins);
 73     }
 74     return $restr;
 75 }
 76 
 77 
 78 /**
 79  *  创建目录
 80  *
 81  * @access    public
 82  * @param     string  $spath 目录名称
 83  * @return    string
 84  */
 85 function SpCreateDir($spath)
 86 {
 87     global $cfg_dir_purview,$cfg_basedir,$cfg_ftp_mkdir,$isSafeMode;
 88     if($spath=='')
 89     {
 90         return true;
 91     }
 92     $flink = false;
 93     $truepath = $cfg_basedir;
 94     $truepath = str_replace("\","/",$truepath);
 95     $spaths = explode("/",$spath);
 96     $spath = "";
 97     foreach($spaths as $spath)
 98     {
 99         if($spath=="")
100         {
101             continue;
102         }
103         $spath = trim($spath);
104         $truepath .= "/".$spath;
105         if(!is_dir($truepath) || !is_writeable($truepath))
106         {
107             if(!is_dir($truepath))
108             {
109                 $isok = MkdirAll($truepath,$cfg_dir_purview);
110             }
111             else
112             {
113                 $isok = ChmodAll($truepath,$cfg_dir_purview);
114             }
115             if(!$isok)
116             {
117                 echo "创建或修改目录:".$truepath." 失败!<br>";
118                 CloseFtp();
119                 return false;
120             }
121         }
122     }
123     CloseFtp();
124     return true;
125 }
126 
127 function jsScript($js)
128 {
129     $out = "<script type="text/javascript">";
130     $out .= "//<![CDATA[
";
131     $out .= $js;
132     $out .= "
//]]>";
133     $out .= "</script>
";
134 
135     return $out;
136 }
137 
138 /**
139  *  获取编辑器
140  *
141  * @access    public
142  * @param     string  $fname 表单名称
143  * @param     string  $fvalue 表单值
144  * @param     string  $nheight 内容高度
145  * @param     string  $etype 编辑器类型
146  * @param     string  $gtype 获取值类型
147  * @param     string  $isfullpage 是否全屏
148  * @return    string
149  */
150 function SpGetEditor($fname,$fvalue,$nheight="350",$etype="Basic",$gtype="print",$isfullpage="false",$bbcode=false)
151 {
152     global $cfg_ckeditor_initialized;
153     if(!isset($GLOBALS['cfg_html_editor']))
154     {
155         $GLOBALS['cfg_html_editor']='fck';
156     }
157     if($gtype=="")
158     {
159         $gtype = "print";
160     }
161     if($GLOBALS['cfg_html_editor']=='fck')
162     {
163         require_once(DEDEINC.'/FCKeditor/fckeditor.php');
164         $fck = new FCKeditor($fname);
165         $fck->BasePath        = $GLOBALS['cfg_cmspath'].'/include/FCKeditor/' ;
166         $fck->Width        = '100%' ;
167         $fck->Height        = $nheight ;
168         $fck->ToolbarSet    = $etype ;
169         $fck->Config['FullPage'] = $isfullpage;
170         if($GLOBALS['cfg_fck_xhtml']=='Y')
171         {
172             $fck->Config['EnableXHTML'] = 'true';
173             $fck->Config['EnableSourceXHTML'] = 'true';
174         }
175         $fck->Value = $fvalue ;
176         if($gtype=="print")
177         {
178             $fck->Create();
179         }
180         else
181         {
182             return $fck->CreateHtml();
183         }
184     }
185     else if($GLOBALS['cfg_html_editor']=='ueditor')
186     {
187      $fvalue = $fvalue=='' ? '<p></p>' : $fvalue;
188     $code = '<script type="text/javascript" charset="utf-8"
189     src="/include/ueditor/ueditor.config.js"></script>
190      <script type="text/javascript" charset="utf-8"
191     src="/include/ueditor/ueditor.all.js"></script>
192     <link rel="stylesheet" type="text/css"
193     href="/include/ueditor/themes/default/css/ueditor.css"/>
194     <textarea name="'.$fname.'" id="'.$fname.'"
195     style="100%;">'.$fvalue.'</textarea>
196     <script type="text/javascript">var ue = new
197     baidu.editor.ui.Editor();ue.render("'.$fname.'");</script>';
198     if($gtype=="print")
199     {
200       echo $code;
201      }
202      else
203     {
204      return $code;
205     }
206     }
207     else if($GLOBALS['cfg_html_editor']=='ckeditor')
208     {
209         require_once(DEDEINC.'/ckeditor/ckeditor.php');
210         $CKEditor = new CKEditor();
211         $CKEditor->basePath = $GLOBALS['cfg_cmspath'].'/include/ckeditor/' ;
212         $config = $events = array();
213         $config['extraPlugins'] = 'dedepage,multipic,addon';
214         if($bbcode)
215         {
216             $CKEditor->initialized = true;
217             $config['extraPlugins'] .= ',bbcode';
218             $config['fontSize_sizes'] = '30/30%;50/50%;100/100%;120/120%;150/150%;200/200%;300/300%';
219             $config['disableObjectResizing'] = 'true';
220             $config['smiley_path'] = $GLOBALS['cfg_cmspath'].'/images/smiley/';
221             // 获取表情信息
222             require_once(DEDEDATA.'/smiley.data.php');
223             $jsscript = array();
224             foreach($GLOBALS['cfg_smileys'] as $key=>$val)
225             {
226                 $config['smiley_images'][] = $val[0];
227                 $config['smiley_descriptions'][] = $val[3];
228                 $jsscript[] = '"'.$val[3].'":"'.$key.'"';
229             }
230             $jsscript = implode(',', $jsscript);
231             echo jsScript('CKEDITOR.config.ubb_smiley = {'.$jsscript.'}');
232         }
233 
234         $GLOBALS['tools'] = empty($toolbar[$etype])? $GLOBALS['tools'] : $toolbar[$etype] ;
235         $config['toolbar'] = $GLOBALS['tools'];
236         $config['height'] = $nheight;
237         $config['skin'] = 'kama';
238         $CKEditor->returnOutput = TRUE;
239         $code = $CKEditor->editor($fname, $fvalue, $config, $events);
240         if($gtype=="print")
241         {
242             echo $code;
243         }
244         else
245         {
246             return $code;
247         }
248     }
249     else { 
250         /*
251         // ------------------------------------------------------------------------
252         // 当前版本,暂时取消dedehtml编辑器的支持
253         // ------------------------------------------------------------------------
254         require_once(DEDEINC.'/htmledit/dede_editor.php');
255         $ded = new DedeEditor($fname);
256         $ded->BasePath        = $GLOBALS['cfg_cmspath'].'/include/htmledit/' ;
257         $ded->Width        = '100%' ;
258         $ded->Height        = $nheight ;
259         $ded->ToolbarSet = strtolower($etype);
260         $ded->Value = $fvalue ;
261         if($gtype=="print")
262         {
263             $ded->Create();
264         }
265         else
266         {
267             return $ded->CreateHtml();
268         }
269         */
270     }
271 }
272 
273 /**
274  *  获取更新信息
275  *
276  * @return    void
277  */
278 function SpGetNewInfo()
279 {
280     global $cfg_version,$dsql;
281     $nurl = $_SERVER['HTTP_HOST'];
282     if( preg_match("#[a-z-]{1,}.[a-z]{2,}#i",$nurl) ) {
283         $nurl = urlencode($nurl);
284     }
285     else {
286         $nurl = "test";
287     }
288     $phpv = phpversion();
289     $sp_os = PHP_OS;
290     $mysql_ver = $dsql->GetVersion();
291     $seo_info = $dsql->GetOne("SELECT * FROM `#@__plus_seoinfo` ORDER BY id DESC");
292     $add_query = '';
293     if ( $seo_info )
294     {
295         $add_query .= "&alexa_num={$seo_info['alexa_num']}&alexa_area_num={$seo_info['alexa_area_num']}&baidu_count={$seo_info['baidu_count']}&sogou_count={$seo_info['sogou_count']}&haosou360_count={$seo_info['haosou360_count']}";
296     }
297     $query = " SELECT COUNT(*) AS dd FROM `#@__member` ";
298     $row1 = $dsql->GetOne($query);
299     if ( $row1 ) $add_query .= "&mcount={$row1['dd']}";
300     $query = " SELECT COUNT(*) AS dd FROM `#@__arctiny` ";
301     $row2 = $dsql->GetOne($query);
302     if ( $row2 ) $add_query .= "&acount={$row2['dd']}";
303     
304     $offUrl = "http://new"."ver.a"."pi.de"."decms.com/index.php?c=info57&version={$cfg_version}&formurl={$nurl}&phpver={$phpv}&os={$sp_os}&mysqlver={$mysql_ver}{$add_query}";
305     return $offUrl;
306 }
307 
308 ?>

5、登陆网站后台依次点击系统==>系统设置==>系统基本参数==>核心设置,Html编辑器改为 ueditor,保存

原文地址:https://www.cnblogs.com/gaowy/p/10173920.html