2013-05-02
相信正在使用织梦dedecms作为网站管理程序的站长朋友对织梦自带的ckeditor编辑器一定感到非常纠心:其难看的外观,不太好用的添加视频功能,超级弱智的图片上传项,就连按个"tab"键都要跳出编辑框...这些无不让我们对其深恶痛绝(可能说得有点夸张)!
本人最近开了一个新站,最初因为这个ckeditor编辑器给编辑工作带来了诸多不便,所以最后痛下决心:改成百度ueditor。
为什么改成ueditor而不是别的编辑器呢?原因主要有三点:
一、ueditor界面相当美观,用起来舒服;
二、功能强悍,比如图片上传功能:它支持批量上传,图片搜索,还有非常不错的图片管理器;再比如视频添加功能:直接填写优酷土豆等视频网址即可,不用像ckeditor那样非常麻烦地去找".swf"的flash地址;
三、基于百度雄厚的实力,相信这个ueditor功能也会越来越强大。
是不是心动了?想体验ueditor的朋友可以去我的小创意网(www.smallcy.com)看看,相信会带给你不错的体验。
不过ueditor装上后也不是马上就能用的(至于怎么安装,大家可以在官方论坛上找),一般都会存在一些小问题。下面我就来谈谈其中一个非常重要的问题的解决方案。
安装完ueditor后,我们可以在ueditor的配置文件中对其界面宽度进行设置,但问题就出在这里,在这里设置的宽度是对全局而言,即所有网站内的编辑器宽度都一样。但对于我们dedecms用户而言,一般前台和后台编辑器宽度不一致,这样就会造成编辑器越界的问题。解决方案:将ueditor宽度设置放在编辑器调用阶段,具体做法如下:
1. /include/helpers/util.helper.php中增加以下代码:
if ( ! function_exists('GetEditorD'))
{
function GetEditorD($fname, $fvalue, $nheight="350", $etype="Basic", $gtype="print", $isfullpage="FALSE",$bbcode=false)
{
if(!function_exists('SpGetEditorD'))
{
require_once(DEDEINC."/inc/inc_fun_funAdmin.php");
}
return SpGetEditorD($fname, $fvalue, $nheight, $etype, $gtype, $isfullpage, $bbcode);
}
}
2. /include/inc/inc_fun_funAdmin.php中增加以下代码:
function SpGetEditorD($fname,$fvalue,$nheight="350",$etype="Basic",$gtype="print",$isfullpage="false",$bbcode=false)
{
global $cfg_ckeditor_initialized;
if(!isset($GLOBALS['cfg_html_editor']))
{
$GLOBALS['cfg_html_editor']='fck';
}
if($gtype=="")
{
$gtype = "print";
}
if($GLOBALS['cfg_html_editor']=='fck')
{
require_once(DEDEINC.'/FCKeditor/fckeditor.php');
$fck = new FCKeditor($fname);
$fck->BasePath = $GLOBALS['cfg_cmspath'].'/include/FCKeditor/' ;
$fck->Width = '100%' ;
$fck->Height = $nheight ;
$fck->ToolbarSet = $etype ;
$fck->Config['FullPage'] = $isfullpage;
if($GLOBALS['cfg_fck_xhtml']=='Y')
{
$fck->Config['EnableXHTML'] = 'true';
$fck->Config['EnableSourceXHTML'] = 'true';
}
$fck->Value = $fvalue ;
if($gtype=="print")
{
$fck->Create();
}
else
{
return $fck->CreateHtml();
}
}
else if($GLOBALS['cfg_html_editor']=='ckeditor')
{
require_once(DEDEINC.'/ckeditor/ckeditor.php');
$CKEditor = new CKEditor();
$CKEditor->basePath = $GLOBALS['cfg_cmspath'].'/include/ckeditor/' ;
$config = $events = array();
$config['extraPlugins'] = 'dedepage,multipic,addon';
if($bbcode)
{
$CKEditor->initialized = true;
$config['extraPlugins'] .= ',bbcode';
$config['fontSize_sizes'] = '30/30%;50/50%;100/100%;120/120%;150/150%;200/200%;300/300%';
$config['disableObjectResizing'] = 'true';
$config['smiley_path'] = $GLOBALS['cfg_cmspath'].'/images/smiley/';
// 获取表情信息
require_once(DEDEDATA.'/smiley.data.php');
$jsscript = array();
foreach($GLOBALS['cfg_smileys'] as $key=>$val)
{
$config['smiley_images'][] = $val[0];
$config['smiley_descriptions'][] = $val[3];
$jsscript[] = '"'.$val[3].'":"'.$key.'"';
}
$jsscript = implode(',', $jsscript);
echo jsscript('CKEDITOR.config.ubb_smiley = {'.$jsscript.'}');
}
$GLOBALS['tools'] = empty($toolbar[$etype])? $GLOBALS['tools'] : $toolbar[$etype] ;
$config['toolbar'] = $GLOBALS['tools'];
$config['height'] = $nheight;
$config['skin'] = 'kama';
$CKEditor->returnOutput = TRUE;
$code = $CKEditor->editor($fname, $fvalue, $config, $events);
if($gtype=="print")
{
echo $code;
}
else
{
return $code;
}
}else if($GLOBALS['cfg_html_editor']=='ueditor')
{
$fvalue = $fvalue=='' ? '<p></p>' : $fvalue;
$code = '<script type="text/javascript" charset="gbk" src="'.$GLOBALS['cfg_cmspath'].'/include/ueditor/editor_config.js"></script>
<script type="text/javascript" charset="gbk" src="'.$GLOBALS['cfg_cmspath'].'/include/ueditor/editor_all_min.js"></script>
<link rel="stylesheet" type="text/css" href="'.$GLOBALS['cfg_cmspath'].'/include/ueditor/themes/default/ueditor.css"/>
<textarea name="'.$fname.'" id="'.$fname.'" style="width:100%;">'.$fvalue.'</textarea>
<script type="text/javascript">
var ue = new baidu.editor.ui.Editor({ initialFrameWidth:824 });ue.render("'.$fname.'"); //红色处为修改宽度
</script>';
if($gtype=="print")
{
echo $code;
}
else
{
return $code;
}
}
else {
/*
// ------------------------------------------------------------------------
// 当前版本,暂时取消dedehtml编辑器的支持
// ------------------------------------------------------------------------
require_once(DEDEINC.'/htmledit/dede_editor.php');
$ded = new DedeEditor($fname);
$ded->BasePath = $GLOBALS['cfg_cmspath'].'/include/htmledit/' ;
$ded->Width = '100%' ;
$ded->Height = $nheight ;
$ded->ToolbarSet = strtolower($etype);
$ded->Value = $fvalue ;
if($gtype=="print")
{
$ded->Create();
}
else
{
return $ded->CreateHtml();
}
*/
}
}
3. 在编辑器调取页面将以下代码:
<?php GetEditor("body","",350,"Member"); ?>
改为:
<?php GetEditorD("body","",350,"Member"); ?>
以上方案的思想是:在不同界面使用不同的编辑器调用函数。
当然你可以根据需要对以上代码进行删改,还有什么问题可以去小创意网(www.smallcy.com)咨询。
荒野乱斗腾讯版最新版下载v61.108.1 安卓qq登录版
策略塔防 1.14G
下载益智拼图游戏免费版下载v2.3 安卓版
休闲益智 15.7M
下载宝宝摄影师游戏下载v9.87.00.00 安卓版
其它手游 96.3M
下载宝宝日常安全宝宝巴士最新版下载v9.87.00.00 安卓手机版
其它手游 92.1M
下载绝区零越南服(ZenlessZoneZero)下载v2.0.0 安卓版
角色扮演 309.5M
下载宝宝认知大全宝宝巴士最新版下载v9.87.00.00 安卓版
其它手游 111.9M
下载宝宝情商养成宝宝巴士游戏下载v9.87.00.00 安卓版
其它手游 104.4M
下载海岛奇兵多酷版下载v59.1.1 安卓版
策略塔防 475.0M
下载豌豆荚海岛奇兵手游下载v59.1.1 安卓最新版
下载
海岛奇兵魅族账号登陆版下载v59.1.1 安卓最新版
下载
美美小店微信登录版下载v1.8.3420 安卓版
下载
宝宝巴士百变职业游戏(改名奇妙的职业)下载v9.87.58.00 安卓最新版
下载
奇妙美食总动员官方版下载v9.86.00.00 安卓版
下载
宝宝果汁商店宝宝巴士下载v9.86.00.00 安卓官方版
下载
奇妙的节日手工宝宝巴士下载v9.87.00.00 安卓手机版
下载
2025使命召唤手游官方正版下载v1.9.51 安卓手机版
下载