您的位置:首页 > 产品设计 > UI/UE

修改dedecms中某个页面ueditor的宽度

2013-05-10 14:01 253 查看
应用:dedecms有时由于前台会员中心自制模板原因,使得前后台编辑框宽度不一致,这时就要对不同页面进行不同的宽度设置。这里提供的方法主要是使用不同的调取编辑器函数。

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"); ?>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: