文章目錄
- 1.更改預設語言和程式設計語言:
- 2.開啟檔案上傳的功能:
- 說明:
- 1.修改工具列按鈕:
- 2.上傳中文名檔案時顯示亂碼怎麼辦
- 3、修本文件列表時中文檔案名稱顯示亂碼問題
- 4、修正建立中文檔案夾時的檔案夾名亂碼問題
- 5.給文章添加不同的樣式
- 6、配置皮膚。
- 7、在編輯器域內可以使用Tab鍵。
- 8、加上幾種常用的字型:
- 9、修改預設的顯示字型
- 10、在上傳檔案視窗點擊瀏覽伺服器出錯
一、下載
1、首先去官網下載FCKeditor2.6.6 多國語言版(可以搜尋“FCKeditor 2.6.6, released on 15
February 2010”)。:
http://ckeditor.com/download
。
二、精簡
按照如下步驟刪除其中一些不需要的測試檔案:
1.只保留/fckeditor/目錄下的fckconfig.js(設定檔)、fckeditor.js(js方式調用檔案)、
fckeditor.php(php方式調用檔案)、fckeditor_php4.php(php4的調用檔案)、
fckeditor_php5.php(php5的調用檔案)、fckstyles.xml(樣式)、fcktemplates.xml(模板)檔案和
editor檔案夾七個檔案以外的所有檔案;
2.刪除目錄/editor/_source(基本上,所有_開頭的檔案夾或檔案都是可選的);
3.刪除/editor/filemanager/connectors/(存放編輯器所支援的Web動態語言)下除了php目錄的所有目錄
;
4.刪除/editor/lang/(存放的是多語言設定檔)下的除了 en.js, zh.js, zh-cn.js三個檔案的所有檔案。
三、設定1.更改預設語言和程式設計語言:
開啟/fckeditor/fckconfig.js
;(千萬注意這個檔案是utf-8編碼,我第一次編輯的時候儲存成了ANSI格式結果出錯了,找了好長時間原因)修改->
FCKConfig.AutoDetectLanguage =false;(使其不能根據系統語言自動檢測載入相應的語言。)
var FCKConfig.DefaultLanguage = ‘zh-cn’ ;
var _FileBrowserLanguage = ‘php’ ;
var _QuickUploadLanguage = ‘php’ ;
2.開啟檔案上傳的功能:
配置editor/filemanager/connectors/php/config.php
將$Config['Enabled'] = false ;改為$Config['Enabled'] = true ;
更改$Config['UserFilesPath'] = ‘/userfiles/’ ;為你的上傳目錄(注意
:這個目錄要存在——自己建立好);
注意:
這個目錄是相對於主目錄的。
也就是說,這個目錄是相對於根目錄的,注意,如果你在本機上測試,那麼,這個根目錄就是 http://localhost
。
四、調用
可以按下面的例子在php(例子中的PHP檔案放在網站的子目錄中)中調用fckeditor編輯器:
include(”../fckeditor/fckeditor.php”); //
包含fckeditor類,fckeditor目錄放在網站根目錄下
$BasePath = “/fckeditor/”; // 編輯器路徑
$oFCKeditor = new FCKeditor(’CreMer’); //
建立一個fckeditor對象,表單的名稱為CreMer
$oFCKeditor->BasePath = $BasePath;
$oFCKeditor->Value = ‘test’; // 設定表單初始值
// 還可設定以下部分(“=”包含部分),並非必須:
//==================================================================================//
$oFCKeditor->Width = ‘800′; // 編輯器寬度,類中有預設值,如果不想修改可不管此項
$oFCKeditor->Height= ‘300′; //
同width,此處為高$oFCKeditor->ToolbarSet
$oFCKeditor->ToolbarSet = ‘Basic’; //
預設編輯器工具列有Basic(基本工具)和Default(所有工具)兩種選擇,另外還可以自己建立工具列
$oFCKeditor->Config['SkinPath'] =
‘/fckeditor/editor/skins/silver/’; // 設定編輯器皮膚
//==================================================================================//
$oFCKeditor->Create(); // 調用類中方法,必須
用$_POST['CreMer']就能擷取文字框裡面的值。
說明:
//包含fckeditor類
include(”../fckeditor/fckeditor.php”) ;
//設定編輯器路徑
$sBasePath = “fckeditor/”;
//建立一個Fckeditor,表單的txtarea名稱為content
$oFCKeditor = new FCKeditor(’content’) ;
$oFCKeditor->BasePath = $sBasePath ;
//設定表單初始值
$oFCKeditor->Value = ‘This is some <strong>sample
text</strong>’ ;
$oFCKeditor->Create() ;
//設定長寬
$oFCKeditor->Width
$oFCKeditor->Height
$oFCKeditor->ToolbarSet
五、其他例子
六、其他技巧1.修改工具列按鈕:
這樣做主要是為了提高安全性,減少一般使用者可以使用的功能:
FCKConfig.ToolbarSets["MyStyle"] = [
['Source','Preview','FitWindow','-','Templates'],
['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
['Image','Flash','Table','Rule','Smiley','SpecialChar','PageBreak'],
['ShowBlocks'],
‘/’,
['Bold','Italic','Underline','StrikeThrough','TextColor','BGColor'],
['OrderedList','UnorderedList','-','Outdent','Indent','Blockquote','CreateDiv'],
['JustifyLeft','JustifyCenter','JustifyRight','JustifyFull'],
['Link','Unlink','Anchor'],
‘/’,
['Style','FontFormat','FontName','FontSize']
// No comma for the last row.
] ;
或者更改
FCKConfig.ToolbarSets["Basic"] = [
['Bold','Italic','-','OrderedList','UnorderedList','-','Link','Unlink','Image','-','About']
] ;
在設定後,調用時添加這個語句:
$oFCKeditor->ToolbarSet = ‘MyStyle’ ;
2.上傳中文名檔案時顯示亂碼怎麼辦
在檔案connectors/php/commands.php中尋找:
...
3、修本文件列表時中文檔案名稱顯示亂碼問題
在檔案connectors/php/util.php中尋找:
return ( utf8_encode( htmlspecialchars( $value ) ) ) ;
修改為:
return iconv(”,’utf-8′,htmlspecialchars( $value ));
4、修正建立中文檔案夾時的檔案夾名亂碼問題
在檔案connectors/php/commands.php中尋找:
$sNewFolderName =
在後面添加一行:
$sNewFolderName = iconv(”utf-8″,”gbk”,$sNewFolderName);
2.6.3版及後續版本的fck下的html檔案已經加了utf-8的檔案頭。
5.給文章添加不同的樣式6、配置皮膚。
“fckeditor/editor/skins/”目錄中有default、office2003、silver等風格可供選擇。
開啟/fckeditor/fckconfig.js ;修改->
FCKConfig.SkinPath = FCKConfig.BasePath + ’skins/default/’ ;
7、在編輯器域內可以使用Tab鍵。
開啟/fckeditor/fckconfig.js ;修改(1為是,0為否)->
FCKConfig.TabSpaces = 0 ; 改為 FCKConfig.TabSpaces = 1 ;
8、加上幾種常用的字型:
開啟/fckeditor/fckconfig.js ;修改->
FCKConfig.FontNames = ‘宋體;黑體;隸書;楷體_GB2312;Arial;Comic Sans
MS;Courier New;Tahoma;Times New Roman;Verdana’;
9、修改預設的顯示字型
可以通過修改樣式表來達到要求,開啟/editor/css/fck_editorarea.css,修改font-size屬性即可。
10、在上傳檔案視窗點擊瀏覽伺服器出錯
可能會出現“the server didn’t send back a proper xml…..
”
的錯誤提示。
因為FCKeditor要求不同類型的檔案分別傳到不同的目錄,包括file,image,falsh,media 等目錄,可以先建立起來試試。