phpcms 整合ueditor
1、去ueditor官方下载ueditor
http://ueditor.baidu.com/website/download.html#ueditor 我下载的是[1.4.3.3 PHP 版本]
2、解压ueditor把utf8-php重命名为ueditor放到/statics/js/目录下
3、修改/phpcms/libs/classes/form.class.php添加ueditor方法与修改默认editor调用方法
<?php
class form {
/**
* 编辑器
*
* @param int $textareaid
* @param int $toolbar
* @param string $module 模块名称
* @param int $catid 栏目id
* @param int $color 编辑器颜色
* @param boole $allowupload 是否允许上传
* @param boole $allowbrowser 是否允许浏览文件
* @param string $alowuploadexts 允许上传类型
* @param string $height 编辑器高度
* @param string $disabled_page 是否禁用分页和子标题
*/
public static function editor( $textareaid = 'content', $toolbar = 'basic', $module = '', $catid = '', $color = '', $allowupload = 0, $allowbrowser = 1, $alowuploadexts = '', $height = 200, $disabled_page = 0, $allowuploadnum = '10' ) {
return self::ueditor( $textareaid, $toolbar, $module, $catid, $color, $allowupload, $allowbrowser, $alowuploadexts, $height, $disabled_page, $allowuploadnum );
$str ='';
if ( !defined( 'EDITOR_INIT' ) ) {
$str = '<script type="text/javascript" src="'.JS_PATH.'ckeditor/ckeditor.js"></script>';
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 .= "<script type=\"text/javascript\">\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 .= '</script>';
$ext_str = "<div class='editor_bottom'>";
if ( !defined( 'IMAGES_INIT' ) ) {
$ext_str .= '<script type="text/javascript" src="'.JS_PATH.'swfupload/swf2ckeditor.js"></script>';
define( 'IMAGES_INIT', 1 );
}
$ext_str .= "<div id='page_title_div'>
<table cellpadding='0' cellspacing='1' border='0'><tr><td class='title'>".L( 'subtitle' )."<span id='msg_page_title_value'></span></td><td>
<a class='close' href='javascript:;' onclick='javascript:$(\"#page_title_div\").hide();'><span>×</span></a></td>
<tr><td colspan='2'><input name='page_title_value' id='page_title_value' class='input-text' value='' size='30'> <input type='button' class='button' value='".L( 'submit' )."' onclick=insert_page_title(\"$textareaid\",1)></td></tr>
</table></div>";
$ext_str .= "</div>";
if ( is_ie() ) $ext_str .= "<div style='display:none'><OBJECT id='PC_Capture' classid='clsid:021E8C6F-52D4-42F2-9B36-BCFBAD3A0DE4'><PARAM NAME='_Version' VALUE='0'><PARAM NAME='_ExtentX' VALUE='0'><PARAM NAME='_ExtentY' VALUE='0'><PARAM NAME='_StockProps' VALUE='0'></OBJECT></div>";
$str .= $ext_str;
return $str;
}
/**
*
*
* @param string $name 表单名称
* @param int $id 表单id
* @param string $value 表单默认值
* @param string $moudle 模块名称
* @param int $catid 栏目id
* @param int $size 表单大小
* @param string $class 表单风格
* @param string $ext 表单扩展属性 如果 js事件等
* @param string $alowexts 允许图片格式
* @param array $thumb_setting
* @param int $watermark_setting 0或1
*/
public static function images( $name, $id = '', $value = '', $moudle='', $catid='', $size = 50, $class = '', $ext = '', $alowexts = '', $thumb_setting = array(), $watermark_setting = 0 ) {
if ( !$id ) $id = $name;
if ( !$size ) $size= 50;
if ( !empty( $thumb_setting ) && count( $thumb_setting ) ) $thumb_ext = $thumb_setting[0].','.$thumb_setting[1];
else $thumb_ext = ',';
if ( !$alowexts ) $alowexts = 'jpg|jpeg|gif|bmp|png';
if ( !defined( 'IMAGES_INIT' ) ) {
$str = '<script type="text/javascript" src="'.JS_PATH.'swfupload/swf2ckeditor.js"></script>';
define( 'IMAGES_INIT', 1 );
}
$value = new_html_special_chars( $value );
$authkey = upload_key( "1,$alowexts,1,$thumb_ext,$watermark_setting" );
return $str."<input type=\"text\" name=\"$name\" id=\"$id\" value=\"$value\" size=\"$size\" class=\"$class\" $ext/> <input type=\"button\" class=\"button\" onclick=\"javascript:flashupload('{$id}_images', '".L( 'attachmentupload' )."','{$id}',submit_images,'1,{$alowexts},1,{$thumb_ext},{$watermark_setting}','{$moudle}','{$catid}','{$authkey}')\"/ value=\"".L( 'imagesupload' )."\">";
}
/**
*
*
* @param string $name 表单名称
* @param int $id 表单id
* @param string $value 表单默认值
* @param string $moudle 模块名称
* @param int $catid 栏目id
* @param int $size 表单大小
* @param string $class 表单风格
* @param string $ext 表单扩展属性 如果 js事件等
* @param string $alowexts 允许上传的文件格式
* @param array $file_setting
*/
public static function upfiles( $name, $id = '', $value = '', $moudle='', $catid='', $size = 50, $class = '', $ext = '', $alowexts = '', $file_setting = array() ) {
if ( !$id ) $id = $name;
if ( !$size ) $size= 50;
if ( !empty( $file_setting ) && count( $file_setting ) ) $file_ext = $file_setting[0].','.$file_setting[1];
else $file_ext = ',';
if ( !$alowexts ) $alowexts = 'rar|zip';
if ( !defined( 'IMAGES_INIT' ) ) {
$str = '<script type="text/javascript" src="'.JS_PATH.'swfupload/swf2ckeditor.js"></script>';
define( 'IMAGES_INIT', 1 );
}
$authkey = upload_key( "1,$alowexts,1,$file_ext" );
return $str."<input type=\"text\" name=\"$name\" id=\"$id\" value=\"$value\" size=\"$size\" class=\"$class\" $ext/> <input type=\"button\" class=\"button\" onclick=\"javascript:flashupload('{$id}_files', '".L( 'attachmentupload' )."','{$id}',submit_attachment,'1,{$alowexts},1,{$file_ext}','{$moudle}','{$catid}','{$authkey}')\"/ value=\"".L( 'filesupload' )."\">";
}
/**
* 日期时间控件
*
* @param unknown $name 控件name,id
* @param unknown $value 选中值
* @param unknown $isdatetime 是否显示时间
* @param unknown $loadjs 是否重复加载js,防止页面程序加载不规则导致的控件无法显示
* @param unknown $showweek 是否显示周,使用,true | false
*/
public static function date( $name, $value = '', $isdatetime = 0, $loadjs = 0, $showweek = 'true', $timesystem = 1 ) {
if ( $value == '0000-00-00 00:00:00' ) $value = '';
$id = preg_match( "/\[(.*)\]/", $name, $m ) ? $m[1] : $name;
if ( $isdatetime ) {
$size = 21;
$format = '%Y-%m-%d %H:%M:%S';
if ( $timesystem ) {
$showsTime = 'true';
} else {
$showsTime = '12';
}
} else {
$size = 10;
$format = '%Y-%m-%d';
$showsTime = 'false';
}
$str = '';
if ( $loadjs || !defined( 'CALENDAR_INIT' ) ) {
define( 'CALENDAR_INIT', 1 );
$str .= '<link rel="stylesheet" type="text/css" href="'.JS_PATH.'calendar/jscal2.css"/>
<link rel="stylesheet" type="text/css" href="'.JS_PATH.'calendar/border-radius.css"/>
<link rel="stylesheet" type="text/css" href="'.JS_PATH.'calendar/win2k.css"/>
<script type="text/javascript" src="'.JS_PATH.'calendar/calendar.js"></script>
<script type="text/javascript" src="'.JS_PATH.'calendar/lang/en.js"></script>';
}
$str .= '<input type="text" name="'.$name.'" id="'.$id.'" value="'.$value.'" size="'.$size.'" class="date" readonly> ';
$str .= '<script type="text/javascript">
Calendar.setup({
weekNumbers: '.$showweek.',
inputField : "'.$id.'",
trigger : "'.$id.'",
dateFormat: "'.$format.'",
showTime: '.$showsTime.',
minuteStep: 1,
onSelect : function() {this.hide();}
});
</script>';
return $str;
}
/**
* 栏目选择
*
* @param string $file 栏目缓存文件名
* @param intval/array $catid 别选中的ID,多选是可以是数组
* @param string $str 属性
* @param string $default_option 默认选项
* @param intval $modelid 按所属模型筛选
* @param intval $type 栏目类型
* @param intval $onlysub 只可选择子栏目
* @param intval $siteid 如果设置了siteid 那么则按照siteid取
*/
public static function select_category( $file = '', $catid = 0, $str = '', $default_option = '', $modelid = 0, $type = -1, $onlysub = 0, $siteid = 0, $is_push = 0 ) {
$tree = pc_base::load_sys_class( 'tree' );
if ( !$siteid ) $siteid = param::get_cookie( 'siteid' );
if ( !$file ) {
$file = 'category_content_'.$siteid;
}
$result = getcache( $file, 'commons' );
$string = '<select '.$str.'>';
if ( $default_option ) $string .= "<option value='0'>$default_option</option>";
//加载权限表模型 ,获取会员组ID值,以备下面投入判断用
if ( $is_push=='1' ) {
$priv = pc_base::load_model( 'category_priv_model' );
$user_groupid = param::get_cookie( '_groupid' ) ? param::get_cookie( '_groupid' ) : 8;
}
if ( is_array( $result ) ) {
foreach ( $result as $r ) {
//检查当前会员组,在该栏目处是否允许投稿?
if ( $is_push=='1' and $r['child']=='0' ) {
$sql = array( 'catid'=>$r['catid'], 'roleid'=>$user_groupid, 'action'=>'add' );
$array = $priv->get_one( $sql );
if ( !$array ) {
continue;
}
}
if ( $siteid != $r['siteid'] || ( $type >= 0 && $r['type'] != $type ) ) continue;
$r['selected'] = '';
if ( is_array( $catid ) ) {
$r['selected'] = in_array( $r['catid'], $catid ) ? 'selected' : '';
} elseif ( is_numeric( $catid ) ) {
$r['selected'] = $catid==$r['catid'] ? 'selected' : '';
}
$r['html_disabled'] = "0";
if ( !empty( $onlysub ) && $r['child'] != 0 ) {
$r['html_disabled'] = "1";
}
$categorys[$r['catid']] = $r;
if ( $modelid && $r['modelid']!= $modelid ) unset( $categorys[$r['catid']] );
}
}
$str = "<option value='\$catid' \$selected>\$spacer \$catname</option>;";
$str2 = "<optgroup label='\$spacer \$catname'></optgroup>";
$tree->init( $categorys );
$string .= $tree->get_tree_category( 0, $str, $str2 );
$string .= '</select>';
return $string;
}
public static function select_linkage( $keyid = 0, $parentid = 0, $name = 'parentid', $id ='', $alt = '', $linkageid = 0, $property = '' ) {
$tree = pc_base::load_sys_class( 'tree' );
$result = getcache( $keyid, 'linkage' );
$id = $id ? $id : $name;
$string = "<select name='$name' id='$id' $property>\n<option value='0'>$alt</option>\n";
if ( $result['data'] ) {
foreach ( $result['data'] as $area ) {
$categorys[$area['linkageid']] = array( 'id'=>$area['linkageid'], 'parentid'=>$area['parentid'], 'name'=>$area['name'] );
}
}
$str = "<option value='\$id' \$selected>\$spacer \$name</option>";
$tree->init( $categorys );
$string .= $tree->get_tree( $parentid, $str, $linkageid );
$string .= '</select>';
return $string;
}
/**
* 下拉选择框
*/
public static function select( $array = array(), $id = 0, $str = '', $default_option = '' ) {
$string = '<select '.$str.'>';
$default_selected = ( empty( $id ) && $default_option ) ? 'selected' : '';
if ( $default_option ) $string .= "<option value='' $default_selected>$default_option</option>";
if ( !is_array( $array ) || count( $array )== 0 ) return false;
$ids = array();
if ( isset( $id ) ) $ids = explode( ',', $id );
foreach ( $array as $key=>$value ) {
$selected = in_array( $key, $ids ) ? 'selected' : '';
$string .= '<option value="'.$key.'" '.$selected.'>'.$value.'</option>';
}
$string .= '</select>';
return $string;
}
/**
* 复选框
*
* @param unknown $array 选项 二维数组
* @param unknown $id 默认选中值,多个用 '逗号'分割
* @param unknown $str 属性
* @param unknown $defaultvalue 是否增加默认值 默认值为 -99
* @param unknown $width 宽度
*/
public static function checkbox( $array = array(), $id = '', $str = '', $defaultvalue = '', $width = 0, $field = '' ) {
$string = '';
$id = trim( $id );
if ( $id != '' ) $id = strpos( $id, ',' ) ? explode( ',', $id ) : array( $id );
if ( $defaultvalue ) $string .= '<input type="hidden" '.$str.' value="-99">';
$i = 1;
foreach ( $array as $key=>$value ) {
$key = trim( $key );
$checked = ( $id && in_array( $key, $id ) ) ? 'checked' : '';
if ( $width ) $string .= '<label class="ib" style="width:'.$width.'px">';
$string .= '<input type="checkbox" '.$str.' id="'.$field.'_'.$i.'" '.$checked.' value="'.new_html_special_chars( $key ).'"> '.new_html_special_chars( $value );
if ( $width ) $string .= '</label>';
$i++;
}
return $string;
}
/**
* 单选框
*
* @param unknown $array 选项 二维数组
* @param unknown $id 默认选中值
* @param unknown $str 属性
*/
public static function radio( $array = array(), $id = 0, $str = '', $width = 0, $field = '' ) {
$string = '';
foreach ( $array as $key=>$value ) {
$checked = trim( $id )==trim( $key ) ? 'checked' : '';
if ( $width ) $string .= '<label class="ib" style="width:'.$width.'px">';
$string .= '<input type="radio" '.$str.' id="'.$field.'_'.new_html_special_chars( $key ).'" '.$checked.' value="'.$key.'"> '.$value;
if ( $width ) $string .= '</label>';
}
return $string;
}
/**
* 模板选择
*
* @param unknown $style 风格
* @param unknown $module 模块
* @param unknown $id 默认选中值
* @param unknown $str 属性
* @param unknown $pre 模板前缀
*/
public static function select_template( $style, $module, $id = '', $str = '', $pre = '' ) {
$tpl_root = pc_base::load_config( 'system', 'tpl_root' );
$templatedir = PC_PATH.$tpl_root.DIRECTORY_SEPARATOR.$style.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR;
$confing_path = PC_PATH.$tpl_root.DIRECTORY_SEPARATOR.$style.DIRECTORY_SEPARATOR.'config.php';
$localdir = str_replace( array( '/', '\\' ), '', $tpl_root ).'|'.$style.'|'.$module;
$templates = glob( $templatedir.$pre.'*.html' );
if ( empty( $templates ) ) {
$style = 'default';
$templatedir = PC_PATH.$tpl_root.DIRECTORY_SEPARATOR.$style.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR;
$confing_path = PC_PATH.$tpl_root.DIRECTORY_SEPARATOR.$style.DIRECTORY_SEPARATOR.'config.php';
$localdir = str_replace( array( '/', '\\' ), '', $tpl_root ).'|'.$style.'|'.$module;
$templates = glob( $templatedir.$pre.'*.html' );
}
if ( empty( $templates ) ) return false;
$files = @array_map( 'basename', $templates );
$names = array();
if ( file_exists( $confing_path ) ) {
$names = include $confing_path;
}
$templates = array();
if ( is_array( $files ) ) {
foreach ( $files as $file ) {
$key = substr( $file, 0, -5 );
$templates[$key] = isset( $names['file_explan'][$localdir][$file] ) && !empty( $names['file_explan'][$localdir][$file] ) ? $names['file_explan'][$localdir][$file].'('.$file.')' : $file;
}
}
ksort( $templates );
return self::select( $templates, $id, $str, L( 'please_select' ) );
}
/**
* 验证码
*
* @param string $id 生成的验证码ID
* @param integer $code_len 生成多少位验证码
* @param integer $font_size 验证码字体大小
* @param integer $width 验证图片的宽
* @param integer $height 验证码图片的高
* @param string $font 使用什么字体,设置字体的URL
* @param string $font_color 字体使用什么颜色
* @param string $background 背景使用什么颜色
*/
public static function checkcode( $id = 'checkcode', $code_len = 4, $font_size = 20, $width = 130, $height = 50, $font = '', $font_color = '', $background = '' ) {
return "<img id='$id' onclick='this.src=this.src+\"&\"+Math.random()' src='".SITE_PROTOCOL.SITE_URL.WEB_PATH."api.php?op=checkcode&code_len=$code_len&font_size=$font_size&width=$width&height=$height&font_color=".urlencode( $font_color )."&background=".urlencode( $background )."'>";
}
/**
* url 规则调用
*
* @param unknown $module 模块
* @param unknown $file 文件名
* @param unknown $ishtml 是否为静态规则
* @param unknown $id 选中值
* @param unknown $str 表单属性
* @param unknown $default_option 默认选项
*/
public static function urlrule( $module, $file, $ishtml, $id, $str = '', $default_option = '' ) {
if ( !$module ) $module = 'content';
$urlrules = getcache( 'urlrules_detail', 'commons' );
$array = array();
foreach ( $urlrules as $roleid=>$rules ) {
if ( $rules['module'] == $module && $rules['file']==$file && $rules['ishtml']==$ishtml ) $array[$roleid] = $rules['example'];
}
return form::select( $array, $id, $str, $default_option );
}
public static function ueditor( $textareaid = 'content', $toolbar = 'basic', $module = '', $catid = '', $color = '', $allowupload = 0, $allowbrowser = 1, $alowuploadexts = '', $height = 200, $disabled_page = 0, $allowuploadnum = '32' ) {//$toolbar = 'admpub';
if ( $toolbar == 'basic' ) {
$toolbar = "['FullScreen',";
$toolbar .= defined( 'IN_ADMIN' ) ? "'Source'," : '';
$toolbar .= "'|', 'Undo', 'Redo', '|',
'Bold', 'Italic', 'Underline','InsertOrderedList', 'InsertUnorderedList','|',
'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyJustify', '|',
'Link', 'Unlink']";
} elseif ( $toolbar == 'full' ) {
$toolbar = "['FullScreen',";
if ( defined( 'IN_ADMIN' ) ) {
$toolbar .= "'Source',";
} else {
$toolbar .= '';
}
$toolbar .= "'|', 'Undo', 'Redo', '|',
'Bold', 'Italic', 'Underline', 'StrikeThrough', 'Superscript', 'Subscript', 'RemoveFormat', 'FormatMatch', '|',
'BlockQuote', '|', 'PastePlain', '|', 'ForeColor', 'BackColor', 'InsertOrderedList', 'InsertUnorderedList', '|', 'CustomStyle',
'Paragraph', 'RowSpacing', 'LineHeight', 'FontFamily', 'FontSize', '|',
'DirectionalityLtr', 'DirectionalityRtl', '|', '', 'Indent', '|',
'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyJustify', '|',
'Link', 'Unlink', 'Anchor', '|', 'ImageNone', 'ImageLeft', 'ImageRight', 'ImageCenter', '|', 'InsertImage', 'Emotion', 'InsertVideo', 'Map', 'GMap', 'InsertFrame', 'PageBreak','PageTitle', 'HighlightCode', '|',
'Horizontal', 'Date', 'Time', 'Spechars', '|',
'InsertTable', 'DeleteTable', 'InsertParagraphBeforeTable', 'InsertRow', 'DeleteRow', 'InsertCol', 'DeleteCol', 'MergeCells', 'MergeRight', 'MergeDown', 'SplittoCells', 'SplittoRows', 'SplittoCols', '|',
'SelectAll', 'ClearDoc', 'SearchReplace', 'Print', 'Preview', 'CheckImage', 'Help']";
} elseif ( $toolbar == 'desc' ) {
$toolbar = "['FullScreen','Source','Undo', 'Redo', '|',";
$toolbar .= "'Bold', 'Italic', '|', 'InsertOrderedList', 'InsertUnorderedList', '|', 'Link', 'Unlink', '|', 'ImageNone', 'ImageLeft', 'ImageRight', 'ImageCenter', '|', 'InsertImage','HighlightCode']";
} else {
$toolbar = "['FullScreen','Undo', 'Redo', '|','ForeColor', 'BackColor']";
}
if ( !defined( 'EDITOR_INIT' ) ) {
$str .= '<script type="text/javascript" src="'.JS_PATH.'ueditor/ueditor.config.js" charset="utf-8"></script>';
$str .= '<script type="text/javascript" src="'.JS_PATH.'ueditor/ueditor.all.js" charset="utf-8"></script>';
$str .= '<script type="text/javascript" src="'.JS_PATH.'ueditor/ueditor.parse.js" charset="utf-8"></script>';
$str .= '<link rel="stylesheet" href="'.JS_PATH.'ueditor/themes/default/css/ueditor.css"/>';
define( 'EDITOR_INIT', 1 );
}
$str .= "<script type=\"text/javascript\">\r\n";
$str .= "var editor = new baidu.editor.ui.Editor({textarea:'$textareaid',wordCount:false,initialFrameWidth:null,initialFrameHeight:400,pageBreakTag:'[page]',allowDivTransToP:true,xssFilterRules:false,inputXssFilter:false,outputXssFilter:false });\r\n";
$str .= "editor.render('$textareaid');\r\n";
$str .= '</script>';
$ext_str = "<div class='editor_bottom'>";
if ( !defined( 'IMAGES_INIT' ) ) {
$ext_str .= '<script type="text/javascript" src="'.JS_PATH.'swfupload/swf2ckeditor.js"></script>';
define( 'IMAGES_INIT', 1 );
}
$ext_str .= '</div>';
if ( $module == 'content' && !$disabled_page ) {
$ext_str .= '<div class="cke_footer"><input type="button" style="width:66px;" class="button" onclick="editor.execCommand(\'pagebreak\');$(\'#paginationtype\').val(2).css(\'color\',\'red\');" value="分页符"></div>';
}
$str .= $ext_str;
return $str;
}
}
?>
4、新建/phpcms/libs/classes/MY_attachment.class.php 修改默认mkhtml方法
<?php
class MY_attachment extends attachment {
var $contentid;
var $module;
var $catid;
var $attachments;
var $field;
var $imageexts = array( 'gif', 'jpg', 'jpeg', 'png', 'bmp' );
var $uploadedfiles = array();
var $downloadedfiles = array();
var $error;
var $upload_root;
var $siteid;
var $site = array();
function __construct( $module='', $catid = 0, $siteid = 0, $upload_dir = '' ) {
parent::__construct();
}
/**
* ck编辑器返回
*
* @param unknown $fn
* @param unknown $fileurl 路径
* @param unknown $message 显示信息
*/
function mkhtml($fn, $fileurl, $message,$editor=null) {
if (!$editor && !empty($_REQUEST['editortype'])) {
$editor=$_REQUEST['editortype'];
}
switch ($editor) {
case 'ueditor':
$title = htmlspecialchars($_POST['pictitle'], ENT_QUOTES);
$message || $message='SUCCESS';
$str='{\'url\':\''.$fileurl.'\',\'title\':\''.$title.'\',\'state\':\''.$message.'\'}';
break;
default:
$str='<script type="text/javascript">window.parent.CKEDITOR.tools.callFunction('.$fn.', \''.$fileurl.'\', \''.$message.'\');</script>';
}
exit($str);
}
}
?>
5、修改/statics/js/ueditor/php/config.json 文件,让上传目录与命名上传文件方法与phpcms一致(如果phpcms上传目录不是uploadfile记得做相应修改)
/* 前后端通信相关的配置,注释只允许使用多行方式 */
{
/* 上传图片配置项 */
"imageActionName": "uploadimage", /* 执行上传图片的action名称 */
"imageFieldName": "upfile", /* 提交的图片表单名称 */
"imageMaxSize": 2048000, /* 上传大小限制,单位B */
"imageAllowFiles": [".png", ".jpg", ".jpeg", ".gif", ".bmp"], /* 上传图片格式显示 */
"imageCompressEnable": true, /* 是否压缩图片,默认是true */
"imageCompressBorder": 1600, /* 图片压缩最长边限制 */
"imageInsertAlign": "none", /* 插入的图片浮动方式 */
"imageUrlPrefix": "", /* 图片访问路径前缀 */
"imagePathFormat": "/uploadfile/{yyyy}/{mm}{dd}/{yyyy}{mm}{dd}{hh}{ii}{ss}{rand:3}", /* 上传保存路径,可以自定义保存路径和文件名格式 */
/* {filename} 会替换成原文件名,配置这项需要注意中文乱码问题 */
/* {rand:6} 会替换成随机数,后面的数字是随机数的位数 */
/* {time} 会替换成时间戳 */
/* {yyyy} 会替换成四位年份 */
/* {yy} 会替换成两位年份 */
/* {mm} 会替换成两位月份 */
/* {dd} 会替换成两位日期 */
/* {hh} 会替换成两位小时 */
/* {ii} 会替换成两位分钟 */
/* {ss} 会替换成两位秒 */
/* 非法字符 \ : * ? " < > | */
/* 具请体看线上文档: fex.baidu.com/ueditor/#use-format_upload_filename */
/* 涂鸦图片上传配置项 */
"scrawlActionName": "uploadscrawl", /* 执行上传涂鸦的action名称 */
"scrawlFieldName": "upfile", /* 提交的图片表单名称 */
"scrawlPathFormat": "/uploadfile/{yyyy}/{mm}{dd}/{yyyy}{mm}{dd}{hh}{ii}{ss}{rand:3}", /* 上传保存路径,可以自定义保存路径和文件名格式 */
"scrawlMaxSize": 2048000, /* 上传大小限制,单位B */
"scrawlUrlPrefix": "", /* 图片访问路径前缀 */
"scrawlInsertAlign": "none",
/* 截图工具上传 */
"snapscreenActionName": "uploadimage", /* 执行上传截图的action名称 */
"snapscreenPathFormat": "/uploadfile/{yyyy}/{mm}{dd}/{yyyy}{mm}{dd}{hh}{ii}{ss}{rand:3}", /* 上传保存路径,可以自定义保存路径和文件名格式 */
"snapscreenUrlPrefix": "", /* 图片访问路径前缀 */
"snapscreenInsertAlign": "none", /* 插入的图片浮动方式 */
/* 抓取远程图片配置 */
"catcherLocalDomain": ["127.0.0.1", "localhost", "img.baidu.com"],
"catcherActionName": "catchimage", /* 执行抓取远程图片的action名称 */
"catcherFieldName": "source", /* 提交的图片列表表单名称 */
"catcherPathFormat": "/uploadfile/{yyyy}/{mm}{dd}/{yyyy}{mm}{dd}{hh}{ii}{ss}{rand:3}", /* 上传保存路径,可以自定义保存路径和文件名格式 */
"catcherUrlPrefix": "", /* 图片访问路径前缀 */
"catcherMaxSize": 2048000, /* 上传大小限制,单位B */
"catcherAllowFiles": [".png", ".jpg", ".jpeg", ".gif", ".bmp"], /* 抓取图片格式显示 */
/* 上传视频配置 */
"videoActionName": "uploadvideo", /* 执行上传视频的action名称 */
"videoFieldName": "upfile", /* 提交的视频表单名称date('Ymdhis').rand(100, 999) */
"videoPathFormat": "/uploadfile/{yyyy}/{mm}{dd}/{yyyy}{mm}{dd}{hh}{ii}{ss}{rand:3}", /* 上传保存路径,可以自定义保存路径和文件名格式 */
"videoUrlPrefix": "", /* 视频访问路径前缀 */
"videoMaxSize": 102400000, /* 上传大小限制,单位B,默认100MB */
"videoAllowFiles": [
".flv", ".swf", ".mkv", ".avi", ".rm", ".rmvb", ".mpeg", ".mpg",
".ogg", ".ogv", ".mov", ".wmv", ".mp4", ".webm", ".mp3", ".wav", ".mid"], /* 上传视频格式显示 */
/* 上传文件配置 */
"fileActionName": "uploadfile", /* controller里,执行上传视频的action名称 */
"fileFieldName": "upfile", /* 提交的文件表单名称 */
"filePathFormat": "/uploadfile/{yyyy}/{mm}{dd}/{yyyy}{mm}{dd}{hh}{ii}{ss}{rand:3}", /* 上传保存路径,可以自定义保存路径和文件名格式 */
"fileUrlPrefix": "", /* 文件访问路径前缀 */
"fileMaxSize": 51200000, /* 上传大小限制,单位B,默认50MB */
"fileAllowFiles": [
".png", ".jpg", ".jpeg", ".gif", ".bmp",
".flv", ".swf", ".mkv", ".avi", ".rm", ".rmvb", ".mpeg", ".mpg",
".ogg", ".ogv", ".mov", ".wmv", ".mp4", ".webm", ".mp3", ".wav", ".mid",
".rar", ".zip", ".tar", ".gz", ".7z", ".bz2", ".cab", ".iso",
".doc", ".docx", ".xls", ".xlsx", ".ppt", ".pptx", ".pdf", ".txt", ".md", ".xml"
], /* 上传文件格式显示 */
/* 列出指定目录下的图片 */
"imageManagerActionName": "listimage", /* 执行图片管理的action名称 */
"imageManagerListPath": "/uploadfile/", /* 指定要列出图片的目录 */
"imageManagerListSize": 20, /* 每次列出文件数量 */
"imageManagerUrlPrefix": "", /* 图片访问路径前缀 */
"imageManagerInsertAlign": "none", /* 插入的图片浮动方式 */
"imageManagerAllowFiles": [".png", ".jpg", ".jpeg", ".gif", ".bmp"], /* 列出的文件类型 */
/* 列出指定目录下的文件 */
"fileManagerActionName": "listfile", /* 执行文件管理的action名称 */
"fileManagerListPath": "/uploadfile/", /* 指定要列出文件的目录 */
"fileManagerUrlPrefix": "", /* 文件访问路径前缀 */
"fileManagerListSize": 20, /* 每次列出文件数量 */
"fileManagerAllowFiles": [
".png", ".jpg", ".jpeg", ".gif", ".bmp",
".flv", ".swf", ".mkv", ".avi", ".rm", ".rmvb", ".mpeg", ".mpg",
".ogg", ".ogv", ".mov", ".wmv", ".mp4", ".webm", ".mp3", ".wav", ".mid",
".rar", ".zip", ".tar", ".gz", ".7z", ".bz2", ".cab", ".iso",
".doc", ".docx", ".xls", ".xlsx", ".ppt", ".pptx", ".pdf", ".txt", ".md", ".xml"
] /* 列出的文件类型 */
}
6、修改/statics/js/ueditor/ueditor.config.js将xssFilterRules: falseinputXssFilter: falseoutputXssFilter: false(不修改phpcms默认分页标记[page]会丢失,目前只能这样处理,暂时没有找到解决办法。。。)
/**
* ueditor完整配置项
* 可以在这里配置整个编辑器的特性
*/
/**************************提示********************************
* 所有被注释的配置项均为UEditor默认值。
* 修改默认配置请首先确保已经完全明确该参数的真实用途。
* 主要有两种修改方案,一种是取消此处注释,然后修改成对应参数;另一种是在实例化编辑器时传入对应参数。
* 当升级编辑器时,可直接使用旧版配置文件替换新版配置文件,不用担心旧版配置文件中因缺少新功能所需的参数而导致脚本报错。
**************************提示********************************/
(function () {
/**
* 编辑器资源文件根路径。它所表示的含义是:以编辑器实例化页面为当前路径,指向编辑器资源文件(即dialog等文件夹)的路径。
* 鉴于很多同学在使用编辑器的时候出现的种种路径问题,此处强烈建议大家使用"相对于网站根目录的相对路径"进行配置。
* "相对于网站根目录的相对路径"也就是以斜杠开头的形如"/myProject/ueditor/"这样的路径。
* 如果站点中有多个不在同一层级的页面需要实例化编辑器,且引用了同一UEditor的时候,此处的URL可能不适用于每个页面的编辑器。
* 因此,UEditor提供了针对不同页面的编辑器可单独配置的根路径,具体来说,在需要实例化编辑器的页面最顶部写上如下代码即可。当然,需要令此处的URL等于对应的配置。
* window.UEDITOR_HOME_URL = "/xxxx/xxxx/";
*/
//设置window.UEDITOR_HOME_URL 确保PHPCMS后台设置了后台访问域名时UEDITOR上传图片可用
window.UEDITOR_HOME_URL='/statics/js/ueditor/'
var URL = window.UEDITOR_HOME_URL || getUEBasePath();
/**
* 配置项主体。注意,此处所有涉及到路径的配置别遗漏URL变量。
*/
window.UEDITOR_CONFIG = {
//为编辑器实例添加一个路径,这个不能被注释
UEDITOR_HOME_URL: URL
// 服务器统一请求接口路径
, serverUrl: URL + "php/controller.php"
//工具栏上的所有的功能按钮和下拉框,可以在new编辑器的实例时选择自己需要的重新定义
, toolbars: [[
'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', 'drafts', 'help'
]]
//当鼠标放在工具栏上时显示的tooltip提示,留空支持自动多语言配置,否则以配置值为准
//,labelMap:{
// 'anchor':'', 'undo':''
//}
//语言配置项,默认是zh-cn。有需要的话也可以使用如下这样的方式来自动多语言切换,当然,前提条件是lang文件夹下存在对应的语言文件:
//lang值也可以通过自动获取 (navigator.language||navigator.browserLanguage ||navigator.userLanguage).toLowerCase()
//,lang:"zh-cn"
//,langPath:URL +"lang/"
//主题配置项,默认是default。有需要的话也可以使用如下这样的方式来自动多主题切换,当然,前提条件是themes文件夹下存在对应的主题文件:
//现有如下皮肤:default
//,theme:'default'
//,themePath:URL +"themes/"
//,zIndex : 900 //编辑器层级的基数,默认是900
//针对getAllHtml方法,会在对应的head标签中增加该编码设置。
//,charset:"utf-8"
//若实例化编辑器的页面手动修改的domain,此处需要设置为true
//,customDomain:false
//常用配置项目
//,isShow : true //默认显示编辑器
//,textarea:'editorValue' // 提交表单时,服务器获取编辑器提交内容的所用的参数,多实例时可以给容器name属性,会将name给定的值最为每个实例的键值,不用每次实例化的时候都设置这个值
//,initialContent:'欢迎使用ueditor!' //初始化编辑器的内容,也可以通过textarea/script给值,看官网例子
//,autoClearinitialContent:true //是否自动清除编辑器初始内容,注意:如果focus属性设置为true,这个也为真,那么编辑器一上来就会触发导致初始化的内容看不到了
//,focus:false //初始化时,是否让编辑器获得焦点true或false
//如果自定义,最好给p标签如下的行高,要不输入中文时,会有跳动感
//,initialStyle:'p{line-height:1em}'//编辑器层级的基数,可以用来改变字体等
//,iframeCssUrl: URL + '/themes/iframe.css' //给编辑区域的iframe引入一个css文件
//indentValue
//首行缩进距离,默认是2em
//,indentValue:'2em'
//,initialFrameWidth:1000 //初始化编辑器宽度,默认1000
//,initialFrameHeight:320 //初始化编辑器高度,默认320
//,readonly : false //编辑器初始化结束后,编辑区域是否是只读的,默认是false
//,autoClearEmptyNode : true //getContent时,是否删除空的inlineElement节点(包括嵌套的情况)
//启用自动保存
//,enableAutoSave: true
//自动保存间隔时间, 单位ms
//,saveInterval: 500
//,fullscreen : false //是否开启初始化时即全屏,默认关闭
//,imagePopup:true //图片操作的浮层开关,默认打开
//,autoSyncData:true //自动同步编辑器要提交的数据
//,emotionLocalization:false //是否开启表情本地化,默认关闭。若要开启请确保emotion文件夹下包含官网提供的images表情文件夹
//粘贴只保留标签,去除标签所有属性
//,retainOnlyLabelPasted: false
//,pasteplain:false //是否默认为纯文本粘贴。false为不使用纯文本粘贴,true为使用纯文本粘贴
//纯文本粘贴模式下的过滤规则
//'filterTxtRules' : function(){
// function transP(node){
// node.tagName = 'p';
// node.setStyle();
// }
// return {
// //直接删除及其字节点内容
// '-' : 'script style object iframe embed input select',
// 'p': {$:{}},
// 'br':{$:{}},
// 'div':{'$':{}},
// 'li':{'$':{}},
// 'caption':transP,
// 'th':transP,
// 'tr':transP,
// 'h1':transP,'h2':transP,'h3':transP,'h4':transP,'h5':transP,'h6':transP,
// 'td':function(node){
// //没有内容的td直接删掉
// var txt = !!node.innerText();
// if(txt){
// node.parentNode.insertAfter(UE.uNode.createText(' '),node);
// }
// node.parentNode.removeChild(node,node.innerText())
// }
// }
//}()
//,allHtmlEnabled:false //提交到后台的数据是否包含整个html字符串
//insertorderedlist
//有序列表的下拉配置,值留空时支持多语言自动识别,若配置值,则以此值为准
//,'insertorderedlist':{
// //自定的样式
// 'num':'1,2,3...',
// 'num1':'1),2),3)...',
// 'num2':'(1),(2),(3)...',
// 'cn':'一,二,三....',
// 'cn1':'一),二),三)....',
// 'cn2':'(一),(二),(三)....',
// //系统自带
// 'decimal' : '' , //'1,2,3...'
// 'lower-alpha' : '' , // 'a,b,c...'
// 'lower-roman' : '' , //'i,ii,iii...'
// 'upper-alpha' : '' , lang //'A,B,C'
// 'upper-roman' : '' //'I,II,III...'
//}
//insertunorderedlist
//无序列表的下拉配置,值留空时支持多语言自动识别,若配置值,则以此值为准
//,insertunorderedlist : { //自定的样式
// 'dash' :'— 破折号', //-破折号
// 'dot':' 。 小圆圈', //系统自带
// 'circle' : '', // '○ 小圆圈'
// 'disc' : '', // '● 小圆点'
// 'square' : '' //'■ 小方块'
//}
//,listDefaultPaddingLeft : '30'//默认的左边缩进的基数倍
//,listiconpath : 'http://bs.baidu.com/listicon/'//自定义标号的路径
//,maxListLevel : 3 //限制可以tab的级数, 设置-1为不限制
//,autoTransWordToList:false //禁止word中粘贴进来的列表自动变成列表标签
//fontfamily
//字体设置 label留空支持多语言自动切换,若配置,则以配置值为准
//,'fontfamily':[
// { label:'',name:'songti',val:'宋体,SimSun'},
// { label:'',name:'kaiti',val:'楷体,楷体_GB2312, SimKai'},
// { label:'',name:'yahei',val:'微软雅黑,Microsoft YaHei'},
// { label:'',name:'heiti',val:'黑体, SimHei'},
// { label:'',name:'lishu',val:'隶书, SimLi'},
// { label:'',name:'andaleMono',val:'andale mono'},
// { label:'',name:'arial',val:'arial, helvetica,sans-serif'},
// { label:'',name:'arialBlack',val:'arial black,avant garde'},
// { label:'',name:'comicSansMs',val:'comic sans ms'},
// { label:'',name:'impact',val:'impact,chicago'},
// { label:'',name:'timesNewRoman',val:'times new roman'}
//]
//fontsize
//字号
//,'fontsize':[10, 11, 12, 14, 16, 18, 20, 24, 36]
//paragraph
//段落格式 值留空时支持多语言自动识别,若配置,则以配置值为准
//,'paragraph':{'p':'', 'h1':'', 'h2':'', 'h3':'', 'h4':'', 'h5':'', 'h6':''}
//rowspacingtop
//段间距 值和显示的名字相同
//,'rowspacingtop':['5', '10', '15', '20', '25']
//rowspacingBottom
//段间距 值和显示的名字相同
//,'rowspacingbottom':['5', '10', '15', '20', '25']
//lineheight
//行内间距 值和显示的名字相同
//,'lineheight':['1', '1.5','1.75','2', '3', '4', '5']
//customstyle
//自定义样式,不支持国际化,此处配置值即可最后显示值
//block的元素是依据设置段落的逻辑设置的,inline的元素依据BIU的逻辑设置
//尽量使用一些常用的标签
//参数说明
//tag 使用的标签名字
//label 显示的名字也是用来标识不同类型的标识符,注意这个值每个要不同,
//style 添加的样式
//每一个对象就是一个自定义的样式
//,'customstyle':[
// {tag:'h1', name:'tc', label:'', style:'border-bottom:#ccc 2px solid;padding:0 4px 0 0;text-align:center;margin:0 0 20px 0;'},
// {tag:'h1', name:'tl',label:'', style:'border-bottom:#ccc 2px solid;padding:0 4px 0 0;margin:0 0 10px 0;'},
// {tag:'span',name:'im', label:'', style:'font-style:italic;font-weight:bold'},
// {tag:'span',name:'hi', label:'', style:'font-style:italic;font-weight:bold;color:rgb(51, 153, 204)'}
//]
//打开右键菜单功能
//,enableContextMenu: true
//右键菜单的内容,可以参考plugins/contextmenu.js里边的默认菜单的例子,label留空支持国际化,否则以此配置为准
//,contextMenu:[
// {
// label:'', //显示的名称
// cmdName:'selectall',//执行的command命令,当点击这个右键菜单时
// //exec可选,有了exec就会在点击时执行这个function,优先级高于cmdName
// exec:function () {
// //this是当前编辑器的实例
// //this.ui._dialogs['inserttableDialog'].open();
// }
// }
//]
//快捷菜单
//,shortcutMenu:["fontfamily", "fontsize", "bold", "italic", "underline", "forecolor", "backcolor", "insertorderedlist", "insertunorderedlist"]
//elementPathEnabled
//是否启用元素路径,默认是显示
//,elementPathEnabled : true
//wordCount
//,wordCount:true //是否开启字数统计
//,maximumWords:10000 //允许的最大字符数
//字数统计提示,{#count}代表当前字数,{#leave}代表还可以输入多少字符数,留空支持多语言自动切换,否则按此配置显示
//,wordCountMsg:'' //当前已输入 {#count} 个字符,您还可以输入{#leave} 个字符
//超出字数限制提示 留空支持多语言自动切换,否则按此配置显示
//,wordOverFlowMsg:'' //<span style="color:red;">你输入的字符个数已经超出最大允许值,服务器可能会拒绝保存!</span>
//tab
//点击tab键时移动的距离,tabSize倍数,tabNode什么字符做为单位
//,tabSize:4
//,tabNode:' '
//removeFormat
//清除格式时可以删除的标签和属性
//removeForamtTags标签
//,removeFormatTags:'b,big,code,del,dfn,em,font,i,ins,kbd,q,samp,small,span,strike,strong,sub,sup,tt,u,var'
//removeFormatAttributes属性
//,removeFormatAttributes:'class,style,lang,width,height,align,hspace,valign'
//undo
//可以最多回退的次数,默认20
//,maxUndoCount:20
//当输入的字符数超过该值时,保存一次现场
//,maxInputCount:1
//autoHeightEnabled
// 是否自动长高,默认true
//,autoHeightEnabled:true
//scaleEnabled
//是否可以拉伸长高,默认true(当开启时,自动长高失效)
//,scaleEnabled:false
//,minFrameWidth:800 //编辑器拖动时最小宽度,默认800
//,minFrameHeight:220 //编辑器拖动时最小高度,默认220
//autoFloatEnabled
//是否保持toolbar的位置不动,默认true
//,autoFloatEnabled:true
//浮动时工具栏距离浏览器顶部的高度,用于某些具有固定头部的页面
//,topOffset:30
//编辑器底部距离工具栏高度(如果参数大于等于编辑器高度,则设置无效)
//,toolbarTopOffset:400
//设置远程图片是否抓取到本地保存
//,catchRemoteImageEnable: true //设置是否抓取远程图片
//pageBreakTag
//分页标识符,默认是_ueditor_page_break_tag_
//,pageBreakTag:'_ueditor_page_break_tag_'
//autotypeset
//自动排版参数
//,autotypeset: {
// mergeEmptyline: true, //合并空行
// removeClass: true, //去掉冗余的class
// removeEmptyline: false, //去掉空行
// textAlign:"left", //段落的排版方式,可以是 left,right,center,justify 去掉这个属性表示不执行排版
// imageBlockLine: 'center', //图片的浮动方式,独占一行剧中,左右浮动,默认: center,left,right,none 去掉这个属性表示不执行排版
// pasteFilter: false, //根据规则过滤没事粘贴进来的内容
// clearFontSize: false, //去掉所有的内嵌字号,使用编辑器默认的字号
// clearFontFamily: false, //去掉所有的内嵌字体,使用编辑器默认的字体
// removeEmptyNode: false, // 去掉空节点
// //可以去掉的标签
// removeTagNames: {标签名字:1},
// indent: false, // 行首缩进
// indentValue : '2em', //行首缩进的大小
// bdc2sb: false,
// tobdc: false
//}
//tableDragable
//表格是否可以拖拽
//,tableDragable: true
//sourceEditor
//源码的查看方式,codemirror 是代码高亮,textarea是文本框,默认是codemirror
//注意默认codemirror只能在ie8+和非ie中使用
//,sourceEditor:"codemirror"
//如果sourceEditor是codemirror,还用配置一下两个参数
//codeMirrorJsUrl js加载的路径,默认是 URL + "third-party/codemirror/codemirror.js"
//,codeMirrorJsUrl:URL + "third-party/codemirror/codemirror.js"
//codeMirrorCssUrl css加载的路径,默认是 URL + "third-party/codemirror/codemirror.css"
//,codeMirrorCssUrl:URL + "third-party/codemirror/codemirror.css"
//编辑器初始化完成后是否进入源码模式,默认为否。
//,sourceEditorFirst:false
//iframeUrlMap
//dialog内容的路径 ~会被替换成URL,垓属性一旦打开,将覆盖所有的dialog的默认路径
//,iframeUrlMap:{
// 'anchor':'~/dialogs/anchor/anchor.html',
//}
//allowLinkProtocol 允许的链接地址,有这些前缀的链接地址不会自动添加http
//, allowLinkProtocols: ['http:', 'https:', '#', '/', 'ftp:', 'mailto:', 'tel:', 'git:', 'svn:']
//webAppKey 百度应用的APIkey,每个站长必须首先去百度官网注册一个key后方能正常使用app功能,注册介绍,http://app.baidu.com/static/cms/getapikey.html
//, webAppKey: ""
//默认过滤规则相关配置项目
//,disabledTableInTable:true //禁止表格嵌套
//,allowDivTransToP:true //允许进入编辑器的div标签自动变成p标签
//,rgb2Hex:true //默认产出的数据中的color自动从rgb格式变成16进制格式
// xss 过滤是否开启,inserthtml等操作
,xssFilterRules: false
//input xss过滤
,inputXssFilter: false
//output xss过滤
,outputXssFilter: false
// xss过滤白名单 名单来源: https://raw.githubusercontent.com/leizongmin/js-xss/master/lib/default.js
,whitList: {
a: ['target', 'href', 'title', 'class', 'style'],
abbr: ['title', 'class', 'style'],
address: ['class', 'style'],
area: ['shape', 'coords', 'href', 'alt'],
article: [],
aside: [],
audio: ['autoplay', 'controls', 'loop', 'preload', 'src', 'class', 'style'],
b: ['class', 'style'],
bdi: ['dir'],
bdo: ['dir'],
big: [],
blockquote: ['cite', 'class', 'style'],
br: [],
caption: ['class', 'style'],
center: [],
cite: [],
code: ['class', 'style'],
col: ['align', 'valign', 'span', 'width', 'class', 'style'],
colgroup: ['align', 'valign', 'span', 'width', 'class', 'style'],
dd: ['class', 'style'],
del: ['datetime'],
details: ['open'],
div: ['class', 'style'],
dl: ['class', 'style'],
dt: ['class', 'style'],
em: ['class', 'style'],
font: ['color', 'size', 'face'],
footer: [],
h1: ['class', 'style'],
h2: ['class', 'style'],
h3: ['class', 'style'],
h4: ['class', 'style'],
h5: ['class', 'style'],
h6: ['class', 'style'],
header: [],
hr: [],
i: ['class', 'style'],
img: ['src', 'alt', 'title', 'width', 'height', 'id', '_src', 'loadingclass', 'class', 'data-latex'],
ins: ['datetime'],
li: ['class', 'style'],
mark: [],
nav: [],
ol: ['class', 'style'],
p: ['class', 'style'],
pre: ['class', 'style'],
s: [],
section:[],
small: [],
span: ['class', 'style'],
sub: ['class', 'style'],
sup: ['class', 'style'],
strong: ['class', 'style'],
table: ['width', 'border', 'align', 'valign', 'class', 'style'],
tbody: ['align', 'valign', 'class', 'style'],
td: ['width', 'rowspan', 'colspan', 'align', 'valign', 'class', 'style'],
tfoot: ['align', 'valign', 'class', 'style'],
th: ['width', 'rowspan', 'colspan', 'align', 'valign', 'class', 'style'],
thead: ['align', 'valign', 'class', 'style'],
tr: ['rowspan', 'align', 'valign', 'class', 'style'],
tt: [],
u: [],
ul: ['class', 'style'],
video: ['autoplay', 'controls', 'loop', 'preload', 'src', 'height', 'width', 'class', 'style']
}
};
function getUEBasePath(docUrl, confUrl) {
return getBasePath(docUrl || self.document.URL || self.location.href, confUrl || getConfigFilePath());
}
function getConfigFilePath() {
var configPath = document.getElementsByTagName('script');
return configPath[ configPath.length - 1 ].src;
}
function getBasePath(docUrl, confUrl) {
var basePath = confUrl;
if (/^(\/|\\\\)/.test(confUrl)) {
basePath = /^.+?\w(\/|\\\\)/.exec(docUrl)[0] + confUrl.replace(/^(\/|\\\\)/, '');
} else if (!/^[a-z]+:/i.test(confUrl)) {
docUrl = docUrl.split("#")[0].split("?")[0].replace(/[^\\\/]+$/, '');
basePath = docUrl + "" + confUrl;
}
return optimizationPath(basePath);
}
function optimizationPath(path) {
var protocol = /^[a-z]+:\/\//.exec(path)[ 0 ],
tmp = null,
res = [];
path = path.replace(protocol, "").split("?")[0].split("#")[0];
path = path.replace(/\\/g, '/').split(/\//);
path[ path.length - 1 ] = "";
while (path.length) {
if (( tmp = path.shift() ) === "..") {
res.pop();
} else if (tmp !== ".") {
res.push(tmp);
}
}
return protocol + res.join("/");
}
window.UE = {
getUEBasePath: getUEBasePath
};
})();
这样就完成了phpcms从ckeditor转成了 ueditor