今天用到在線編輯器在asp環境下上傳竟然無效。找了好久才找到這介紹,現備份於此,需要的朋友可以參考下(1)精簡,言多必失,文件多了也是一種隱患。 FCKEditor支持多種服務器腳本語言,實際使用的時候我們根本用不了那麼多文件,我們要根據自己的需要對其進行精簡。
對於ASP系統來說:
FCKEditor根目錄,僅保留fckeditor.asp,fckconfig.js,fckeditor.js,fckpackager.xml,fckstyles.xml,
fcktemplates.xml這些文件以及editor目錄。刪除示例目錄_samples。
fckeditor/editor/filemanager/connectors目錄下面僅保留asp目錄,刪除其它目錄和文件。
(2)修改文件上傳採用的腳本程序(語言)。
默認的FCKEditor文件上傳程序為asp,如果是用在asp系統中,那就不用再修改了。
如果是用在PHP系統中的話,需要做如下修改,打開fckconfig.js
找到:
var _FileBrowserLang ge = asp
var _QuickUploadLang ge = asp
改成:
var _FileBrowserLang ge = php
var _QuickUploadLang ge = php
(3)開啟文件上傳,修改文件上傳目錄。
對於ASP系統來說:
打開fckeditor/editor/filemanager/connectors/asp/config.asp
啟用文件上傳:
找到:
ConfigIsEnabled = false
改成:
ConfigIsEnabled = tr
設置上傳存放目錄:
找到:
ConfigUserFilesPath = /admin/uppic/
改成:
ConfigUserFilesPath = 自定義的路徑
對於PHP系統來說:
打開fckeditor/editor/filemanager/browser/default/connectors/php/config.php
啟用文件上傳:
找到:
$Config[Enabled] = false
改成:
$Config[Enabled] = tr
設置上傳存放目錄:
找到:
$Config[UserFilesPath] = /userfiles/
改成:
$Config[UserFilesPath] = 自定義的路徑
(4)修改上傳文件命名方式。
FCKEditor上傳文件,文件名採用原文件名,如果想採用自定義的文件命名方式(比如,隨即名稱),可以修改如下地
方:
對於ASP系統來說:
打開fckeditor/sample/edit/editor/filemanager/connectors/asp/commands.asp
找到:
sFileName = SanitizeFileName( sFileName )
將該句改為自定義的文件命名格式,例如:
dim RndStr
Randomize
RndStr = Cstr(Fix(9000*rnd()+1000)) 產生一個隨機數
sFileName =year(date)&month(Date)&day(Date)&hour(time)&minute(time)&second(time)&RndStr &. &
**tension
對於PHP系統來說:
打開fckeditor/editor/editor/filemanager/connectors/php/commands.php
找到:
$sOriginalFileName = $sFileName ;
在該句前面加入:
// 初始化種子
$sstr =split( ,microtime(),5);
$seed =$sstr[0]*10000;
// 使用種子初始化隨機數發生器
srand($seed);
// 生成指定範圍內的隨機數
$random =rand(1000,10000);
// 合成隨即的文件名
$sFileName = date(YmdHis, time()).$random...$**tension;
(5)FCKEditor在程序中引用方式。
對於ASP系統來說:
需要包含下面的頭文件
<!--#incl? file=fckeditor/fckeditor.asp-->
在編輯器所在的位置添加如下代碼:
<%
Dim oFCKeditor
Set oFCKeditor = New FCKeditor
oFCKeditor.BasePath = /fckeditor/ 這個路徑必須是相對於站點根目錄的路徑,設置錯誤編輯器
將無法顯示
oFCKeditor.ToolbarSet=Default
oFCKeditor.Width = 98%
oFCKeditor.Height= 500px
oFCKeditor.Val = 設置默認值
oFCKeditor.Create shangpin_description 編輯器的id,相當於input標籤的name屬性值,這裡是
shangpin_description
%>
對於PHP來說:
在編輯器所在的位置添加如下代碼:
<?php
incl?(fckeditor/fckeditor.php); // 頭文件
$oFCKeditor = new FCKeditor(shangpin_description) ; // 編輯器的id,相當於input標籤的
name屬性值,這裡是shangpin_description
$oFCKeditor->BasePath=/fckeditor/ ; //設置FCKeditor路徑
$oFCKeditor->ToolbarSet =Default;
$oFCKeditor->Width=98%;
$oFCKeditor->Height=500px;
$oFCKeditor->Val =; // 設置默認值
$oFCKeditor->Create();
?>
(6)獲取FCKEditor中的數據。
對於服務器端腳本程序來說,將編輯器的id當做input標籤的name屬性值來獲取即可,例如:
在ASP中req st(shangpin_description),在PHP中$_REQ ST[shangpin_description]
JS中用FCKeditorAPI.GetInstance(shangpin_description).GetXHTML(tr )得到shangpin_description對應的值
ckEditor的ASP配置
在網上找了好久終於找到了! O(∩_∩)O哈哈~
一、使用方法:
1、在頁面<head>中引入ckeditor核心文件ckeditor.js
<script type=text/javascript src=ckeditor/ckeditor.js></script>
2、在使用編輯器的地方插入HTML控件<textarea>
<textarea id=TextArea1 cols=20 rows=2 class=ckeditor></textarea>
如果是ASP.NET環境,也可用服務器端控件<TextBox>
<asp:TextBox ID=tbContent runat=server TextMode=MultiLine class=ckeditor></asp:TextBox>
注意在控件中加上class=ckeditor 。
3、將相應的控件替換成編輯器代碼
<script type=text/javascript>
CKEDITOR.replace('TextArea1');
//如果是在ASP.NET環境下用的服務器端控件<TextBox>
CKEDITOR.replace('tbContent');
//如果<TextBox>控件在母版頁中,要這樣寫
CKEDITOR.replace('<%=tbContent.ClientID.Replace(_,$) %>');
</script>
4、配置編輯器
ckeditor的配置都集中在ckeditor/config.js 文件中,下面是一些常用的配置參數:
// 界面語言,默認為'en'
config.language = 'zh-cn';
// 設置寬高
config.width = 400;
config.height = 400;
// 編輯器樣式,有三種:'kama'(默認)、'office2003'、'v2'
config.skin = 'v2';
// 背景顏色
config.uiColor = '#FFF';
// 工具欄(基礎'Basic'、全能'Full'、自定義)plugins/toolbar/plugin.js
config.toolbar = 'Basic';
config.toolbar = 'Full';
這將配合:
config.toolbar_Full = [
['Source','-','Save','NewPage','Preview','-','Templates'],
['Cut','Copy','Paste','PasteText','PasteFromWord','-','Print', 'SpellChecker', 'Scayt'],
['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
['Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField'],
'/',
['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],
['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],
['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
['Link','Unlink','Anchor'],
['Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak'],
'/',
['Styles','Format','Font','FontSize'],
['TextColor','BGColor']
];
//工具欄是否可以被收縮
config.toolbarCanCollapse = true;
//工具欄的位置
config.toolbarLocation = 'top';//可選:bottom
//工具欄默認是否展開
config.toolbarStartupExpanded = true;
// 取消拖拽以改變尺寸功能plugins/resize/plugin.js
config.resize_enabled = false;
//改變大小的最大高度
config.resize_maxHeight = 3000;
//改變大小的最大寬度
config.resize_maxWidth = 3000;
//改變大小的最小高度
config.resize_minHeight = 250;
//改變大小的最小寬度
config.resize_minWidth = 750;
// 當提交包含有此編輯器的表單時,是否自動更新元素內的數據
config.autoUpdateElement = true;
// 設置是使用絕對目錄還是相對目錄,為空為相對目錄
config.baseHref = ''
// 編輯器的z-index值
config.baseFloatZIndex = 10000;
//設置快捷鍵
config.keystrokes = [
[ CKEDITOR.ALT + 121 /*F10*/, 'toolbarFocus' ], //獲取焦點
[ CKEDITOR.ALT + 122 /*F11*/, 'elementsPathFocus' ], //元素焦點
[ CKEDITOR.SHIFT + 121 /*F10*/, 'contextMenu' ], //文本菜單
[ CKEDITOR.CTRL + 90 /*Z*/, 'undo' ], //撤銷
[ CKEDITOR.CTRL + 89 /*Y*/, 'redo' ], //重做
[ CKEDITOR.CTRL + CKEDITOR.SHIFT + 90 /*Z*/, 'redo' ], //
[ CKEDITOR.CTRL + 76 /*L*/, 'link' ], //鏈接
[ CKEDITOR.CTRL + 66 /*B*/, 'bold' ], //粗體
[ CKEDITOR.CTRL + 73 /*I*/, 'italic' ], //斜體
[ CKEDITOR.CTRL + 85 /*U*/, 'underline' ], //下劃線
[ CKEDITOR.ALT + 109 /*-*/, 'toolbarCollapse' ]
]
//設置快捷鍵可能與瀏覽器快捷鍵衝突plugins/keystrokes/plugin.js.
config.blockedKeystrokes = [
CKEDITOR.CTRL + 66 /*B*/,
CKEDITOR.CTRL + 73 /*I*/,
CKEDITOR.CTRL + 85 /*U*/
]
//設置編輯內元素的背景色的取值plugins/colorbutton/plugin.js.
config.colorButton_backStyle = {
element : 'span',
styles : { 'background-color' : '#(color)' }
}
//設置前景色的取值plugins/colorbutton/plugin.js
config.colorButton_colors = '000,800000,8B4513,2F4F4F,008080,000080,4B0082,696969,B22222,A52A2A,DAA520,
006400,40E0D0,0000CD,800080,808080,F00,FF8C00,FFD700,008000,0FF,00F,EE82EE,
A9A9A9,FFA07A,FFA500,FFFF00,00FF00,AFEEEE,ADD8E6,DDA0DD,D3D3D3,FFF0F5,
FAEBD7,FFFFE0,F0FFF0,F0FFFF,F0F8FF,E6E6FA,FFF'
//是否在選擇顏色時顯示其它顏色選項plugins/colorbutton/plugin.js
config.colorButton_enableMore = false
//區塊的前景色默認值設置plugins/colorbutton/plugin.js
config.colorButton_foreStyle = {
element : 'span',
styles : { 'color' : '#(color)' }
};
//所需要添加的CSS文件在此添加可使用相對路徑和網站的絕對路徑
config.contentsCss = './contents.css';
//文字方向
config.contentsLangDirection = 'rtl'; //從左到右
//CKeditor的配置文件若不想配置留空即可
CKEDITOR.replace( 'myfiled', { customConfig : './config.js' } );
//界面編輯框的背景色plugins/dialog/plugin.js
config.dialog_backgroundCoverColor = 'rgb(255, 254, 253)'; //可設置參考
config.dialog_backgroundCoverColor = 'white' //默認
//背景的不透明度數值應該在:0.0~1.0 之間plugins/dialog/plugin.js
config.dialog_backgroundCoverOpacity = 0.5
//移動或者改變元素時邊框的吸附距離單位:像素plugins/dialog/plugin.js
config.dialog_magnetDistance = 20;
//是否拒絕本地拼寫檢查和提示默認為拒絕目前僅firefox和safari支持plugins/wysiwygarea/plugin.js.
config.disableNativeSpellChecker = true
//進行表格編輯功能如:添加行或列目前僅firefox支持plugins/wysiwygarea/plugin.js
config.disableNativeTableHandles = true; //默認為不開啟
//是否開啟圖片和表格的改變大小的功能config.disableObjectResizing = true;
config.disableObjectResizing = false //默認為開啟
//設置HTML文檔類型
config.docType = '<!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN ;
//是否對編輯區域進行渲染plugins/editingblock/plugin.js
config.editingBlock = true;
//編輯器中回車產生的標籤
config.enterMode = CKEDITOR.ENTER_P; //可選:CKEDITOR.ENTER_BR或CKEDITOR.ENTER_DIV
//是否使用HTML實體進行輸出plugins/entities/plugin.js
config.entities = true;
//定義更多的實體plugins/entities/plugin.js
config.entities_additional = '#39'; //其中#代替了&
//是否轉換一些難以顯示的字符為相應的HTML字符plugins/entities/plugin.js
config.entities_greek = true;
//是否轉換一些拉丁字符為HTML plugins/entities/plugin.js
config.entities_latin = true;
//是否轉換一些特殊字符為ASCII字符如This is Chinese: 漢語.轉換為This is Chinese: 漢語. plugins/entities/plugin.js
config.entities_processNumerical = false;
//添加新組件
config.extraPlugins = 'myplugin'; //非默認僅示例
//使用搜索時的高亮色plugins/find/plugin.js
config.find_highlight = {
element : 'span',
styles : { 'background-color' : '#ff0', 'color' : '#00f' }
};
//默認的字體名plugins/font/plugin.js
config.font_defaultLabel = 'Arial';
//字體編輯時的字符集可以添加常用的中文字符:宋體、楷體、黑體等plugins/font/plugin.js
config.font_names = 'Arial;Times New Roman;Verdana';
//文字的默認式樣plugins/font/plugin.js
config.font_style = {
element : 'span',
styles : { 'font-family' : '#(family)' },
overrides : [ { element : 'font', attributes : { 'face' : null } } ]
};
//字體默認大小plugins/font/plugin.js
config.fontSize_defaultLabel = '12px';
//字體編輯時可選的字體大小plugins/font/plugin.js
config.fontSize_sizes ='8/8px;9/9px;10/10px;11/11px;12/12px;14/14px;16/16px;18/18px;20/20px;22/22px;24/24px;26 /26px;28/28px;36/36px;48/48px;72/72px'
//設置字體大小時使用的式樣plugins/font/plugin.js
config.fontSize_style = {
element : 'span',
styles : { 'font-size' : '#(size)' },
overrides : [ { element : 'font', attributes : { 'size' : null } } ]
};
//是否強制複製來的內容去除格式plugins/pastetext/plugin.js
config.forcePasteAsPlainText =false //不去除
//是否強制用&來代替&plugins/htmldataprocessor/plugin.js
config.forceSimpleAmpersand = false;
//對address標籤進行格式化plugins/format/plugin.js
config.format_address = { element : 'address', attributes : { class : 'styledAddress' } };
//對DIV標籤自動進行格式化plugins/format/plugin.js
config.format_div = { element : 'div', attributes : { class : 'normalDiv' } };
//對H1標籤自動進行格式化plugins/format/plugin.js
config.format_h1 = { element : 'h1', attributes : { class : 'contentTitle1' } };
//對H2標籤自動進行格式化plugins/format/plugin.js
config.format_h2 = { element : 'h2', attributes : { class : 'contentTitle2' } };
//對H3標籤自動進行格式化plugins/format/plugin.js
config.format_h1 = { element : 'h3', attributes : { class : 'contentTitle3' } };
//對H4標籤自動進行格式化plugins/format/plugin.js
config.format_h1 = { element : 'h4', attributes : { class : 'contentTitle4' } };
//對H5標籤自動進行格式化plugins/format/plugin.js
config.format_h1 = { element : 'h5', attributes : { class : 'contentTitle5' } };
//對H6標籤自動進行格式化plugins/format/plugin.js
config.format_h1 = { element : 'h6', attributes : { class : 'contentTitle6' } };
//對P標籤自動進行格式化plugins/format/plugin.js
config.format_p = { element : 'p', attributes : { class : 'normalPara' } };
//對PRE標籤自動進行格式化plugins/format/plugin.js
config.format_pre = { element : 'pre', attributes : { class : 'code' } };
//用分號分隔的標籤名字在工具欄上顯示plugins/format/plugin.js
config.format_tags = 'p;h1;h2;h3;h4;h5;h6;pre;address;div';
//是否使用完整的html編輯模式如使用,其源碼將包含:<html><body></body></html>等標籤
config.fullPage = false;
//是否忽略段落中的空字符若不忽略則字符將以表示plugins/wysiwygarea/plugin.js
config.ignoreEmptyParagraph = true;
//在清除圖片屬性框中的鏈接屬性時是否同時清除兩邊的<a>標籤plugins/image/plugin.js
config.image_removeLinkByEmptyURL = true;
//一組用逗號分隔的標籤名稱,顯示在左下角的層次嵌套中plugins/menu/plugin.js.
config.menu_groups ='clipboard,form,tablecell,tablecellproperties,tablerow,tablecolumn,table,anchor,link,image,flash,checkbox,radio,textfield,hiddenfield,imagebutton,button,select,textarea';
//顯示子菜單時的延遲,單位:ms plugins/menu/plugin.js
config.menu_subMenuDelay = 400;
//當執行新建命令時,編輯器中的內容plugins/newpage/plugin.js
config.newpage_html = '';
//當從word裡複製文字進來時,是否進行文字的格式化去除plugins/pastefromword/plugin.js
config.pasteFromWordIgnoreFontFace = true; //默認為忽略格式
//是否使用<h1><h2>等標籤修飾或者代替從word文檔中粘貼過來的內容plugins/pastefromword/plugin.js
config.pasteFromWordKeepsStructure = false;
//從word中粘貼內容時是否移除格式plugins/pastefromword/plugin.js
config.pasteFromWordRemoveStyle = false;
//對應後台語言的類型來對輸出的HTML內容進行格式化,默認為空
config.protectedSource.push( /</?[/s/S]*?/?>/g ); // PHP Code
config.protectedSource.push( //g ); // ASP Code
config.protectedSource.push( /(]+>[/s|/S]*?<//asp:[^/>]+>)|(]+//>)/gi ); // ASP.Net Code
//當輸入:shift+Enter時插入的標籤
config.shiftEnterMode = CKEDITOR.ENTER_P; //可選:CKEDITOR.ENTER_BR或CKEDITOR.ENTER_DIV
//可選的表情替代字符plugins/smiley/plugin.js.
config.smiley_descriptions = [
':)', ':(', ';)', ':D', ':/', ':P',
'', '', '', '', '', '',
'', ';(', '', '', '', '',
'', ':kiss', '' ];
//對應的表情圖片plugins/smiley/plugin.js
config.smiley_images = [
'regular_smile.gif','sad_smile.gif','wink_smile.gif','teeth_smile.gif','confused_smile.gif','tounge_smile.gif',
'embaressed_smile.gif','omg_smile.gif','whatchutalkingabout_smile.gif','angry_smile.gif','angel_smile.gif','shades_smile.gif',
'devil_smile.gif','cry_smile.gif','lightbulb.gif','thumbs_down.gif','thumbs_up.gif','heart.gif',
'broken_heart.gif','kiss.gif','envelope.gif'];
//表情的地址plugins/smiley/plugin.js
config.smiley_path = 'plugins/smiley/images/';
//頁面載入時,編輯框是否立即獲得焦點plugins/editingblock/plugin.js plugins/editingblock/plugin.js.
config.startupFocus = false;
//載入時,以何種方式編輯源碼和所見即所得source和wysiwyg plugins/editingblock/plugin.js.
config.startupMode ='wysiwyg';
//載入時,是否顯示框體的邊框plugins/showblocks/plugin.js
config.startupOutlineBlocks = false;
//是否載入樣式文件plugins/stylescombo/plugin.js.
config.stylesCombo_stylesSet = 'default';
//以下為可選
config.stylesCombo_stylesSet = 'mystyles';
config.stylesCombo_stylesSet = 'mystyles:/editorstyles/styles.js';
config.stylesCombo_stylesSet = 'mystyles:http://www.example.com/editorstyles/styles.js';
//起始的索引值
config.tabIndex = 0;
//當用戶鍵入TAB時,編輯器走過的空格數,( ) 當值為0時,焦點將移出編輯框plugins/tab/plugin.js
config.tabSpaces = 0;
//默認使用的模板plugins/templates/plugin.js.
config.templates = 'default';
//用逗號分隔的模板文件plugins/templates/plugin.js.
config.templates_files = [ 'plugins/templates/templates/default.js' ]
//當使用模板時,編輯內容將被替換框是否選中plugins/templates/plugin.js
config.templates_replaceContent = true;
//主題
config.theme = 'default';
//撤銷的記錄步數plugins/undo/plugin.js
config.undoStackSize =20;
// 在CKEditor 中集成CKFinder,注意ckfinder 的路徑選擇要正確。
//CKFinder.SetupCKEditor(null, '/ckfinder/');