FCKeditor2.6.5及後續版本 for PHP配置及中文上傳亂碼問題

來源:互聯網
上載者:User

1、首先去官網下載FCKeditor2.6.5 多國語言版。http://ckeditor.com/download,注意:第一個為最新3.0.1版,第二個才是FCKeditor 2.6.5

2、刪除不必要的東西:

刪除/FCKeditor/目錄下除fckconfig.js,fckeditor.js,fckstyles.xml,fcktemplates.xml,fckeditor.php,fckeditor_php5.php,fckeditor_php4.php
七個檔案以外的所有檔案;
刪除目錄/editor/_source(基本上,所有_開頭的檔案夾或檔案都是可選的);
刪除/editor/filemanager/connectors/下除了php目錄的所有目錄;
刪除/editor/lang/下的除了 en.js, zh.js, zh-cn.js三個檔案的所有檔案。

3、開啟/FCKeditor/fckconfig.js
修改
var FCKConfig.DefaultLanguage = 'zh-cn' ;
var _FileBrowserLanguage   = 'php' ;
var _QuickUploadLanguage   = 'php' ;
要開啟檔案上傳的話,還需要配置editor\filemanager\connectors\php\config.php
將$Config['Enabled'] = false ;改為$Config['Enabled'] = true ;
更改$Config['UserFilesPath'] = '/userfiles/' ;為你的上傳目錄;

4.調用方法(例子)
將FCKeditor放在網站根目錄
在PHP檔案裡面,包含/FCKeditor/fckeditor.php檔案
//包含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
......................................................................................................................................................
<textarea name="content" style="display:none">這是文章內容測試!</textarea>
<?php
include_once("fckeditor/fckeditor.php");

$oFCKeditor=new fckeditor('content');
$oFCKeditor->BasePath='fckeditor/';
$oFCKeditor->value='default text in editor';
$oFCKeditor->Width='800px';
$oFCKeditor->Height='300px';
$oFCKeditor->create();
//$fck=$oFCKeditor->CreateHtml();
?>
......................................................................................................................................................

對於Fckeditor上傳中文名檔案時顯示亂碼的問題,現公布方法如下:
測試環境:php 5 , utf-8編碼

1、修正上傳中文檔案時檔案名稱亂碼問題
在檔案connectors/php/commands.php中尋找:
$sFileName = $oFile['name'] ;
在後面添加一行:
$sFileName = iconv("utf-8","gbk",$sFileName);

2、修本文件列表時中文檔案名稱顯示亂碼問題
在檔案connectors/php/util.php中尋找:
return ( utf8_encode( htmlspecialchars( $value ) ) ) ;
修改為:
return iconv('','utf-8',htmlspecialchars( $value ));

3、修正建立中文檔案夾時的檔案夾名亂碼問題
在檔案connectors/php/commands.php中尋找:
$sNewFolderName =
在後面添加一行:
$sNewFolderName = iconv("utf-8","gbk",$sNewFolderName);

2.6.3版及後續版本的fck下的html檔案已經加了utf-8的檔案頭。

文章出處:標準之路(http://www.aa25.cn/Tech/824.shtml)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.