標籤:style http color io ar 使用 strong sp 檔案
1、/ckeditor/config.js, 設定檔,如果不想寫太多,可以直接寫好預設配置(語言,功能表列,寬度),有需要可以百度config配置
config.language = ‘en’;config.skin = ‘v2’;config.uiColor = ‘#AADC6E’;config.toolbar = ‘Basic’;…。
2、官方的demo大多都喜歡用js配置editor地區,習慣寫php的我就嫌麻煩,只好看內建的php類。
require_once ROOTPATH 。 “ckeditor/ckeditor.php”;$CKEditor = new CKEditor();$CKEditor-》returnOutput = true; //設定輸出可用變數的情況$CKEditor-》basePath = ‘/ckeditor/’;//設定路徑$contentarea = $CKEditor-》editor(“content”, $rs[‘contents’]); //產生一個以name為content的textarea
echo $contentarea;
3、需要上傳了 ,只好加入ckfinder.把ckfinder和ckeditor放在同級目錄下。
開啟/ckfinder/config.php, 首先設定第一個函數CheckAuthentication(),這個函數需要按照自己的規則寫,只要return true的情況才能允許上傳檔案到伺服器的,當然不建議直接寫return true,這將導致安全問題。可以採用session來處理比較方便。
session_start();function CheckAuthentication(){ if(isset($_SESSION[‘UseEidtor’]))
return true;else return false;}
4、上傳檔案位置:也在/ckfinder/config.php, 找到$baseUrl,之前一直想自己寫一個方法用來定位路徑,實在不好辦,後來只好用sesssion,如果一個網站中,有需要上傳到不同的足浴粉位置,正好可以利用session定位。
if (isset($_SESSION[‘UseEidtor’])) {
switch ($_SESSION[‘UseEidtor’]) { case ‘Addr1’:$baseUrl = ‘/addr1/uploadfile/’;case ‘Addr2’:$baseUrl = ‘/addr2/upfiles/’;}
} else {
$baseUrl = ‘/upfiles/’;
} 5、對於上傳檔案名稱,ckfinder會按照原有的名字命名,中文的情況下可能會亂碼,所以建議使用日期重新命名。開啟/ckfinder/core/connector/php/php5/CommandHandler/FileUpload.php 找到《 /p》
$sUnsafeFileName =CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding(CKFinder_Connector_Utils_Misc::mbBasename($uploadedFile[‘name’]));後面加上
$sExtension = CKFinder_Connector_Utils_FileSystem::getExtension($sUnsafeFileName);$sUnsafeFileName=date(‘YmdHis’)。‘。’.$sExtension;6、 最後就是使用ckfinder
require_once ROOTPATH 。 “ckeditor/ckeditor.php”;require_once ROOTPATH 。 ‘ckfinder/ckfinder.php’ ;
$CKEditor = new CKEditor();$CKEditor-》returnOutput = true;$CKEditor-》basePath = ‘/ckeditor/’;
CKFinder::SetupCKEditor($CKEditor, ‘/ckfinder/’) ;//注意這裡是相對路徑,相對於根目錄,不能用絕對路徑
$contentarea = $CKEditor-》editor(“content”, $rs[‘contents’]);兩者配合用起來還是挺不錯的,更重要的原因是安全性高了很多。
PHP中CKEditor和CKFinder配置