PHP中CKEditor和CKFinder配置問題小結(jié)
更新時間:2012年03月07日 22:43:58 作者:
PHP中CKEditor和CKFinder配置問題小結(jié),使用CKEditor和CKFinder編輯器的朋友可以參考下
1、/ckeditor/config.js, 配置文件,如果不想寫太多,可以直接寫好默認配置(語言,菜單欄,寬度),有需要可以百度config配置
config.language = 'en';config.skin = 'v2';config.uiColor = '#AADC6E';config.toolbar = 'Basic';…。
2、官方的demo大多都喜歡用js配置editor區(qū)域,習慣寫php的我就嫌麻煩,只好看內(nèi)置的php類。
require_once ROOTPATH 。 "ckeditor/ckeditor.php";$CKEditor = new CKEditor();$CKEditor-》returnOutput = true; //設(shè)置輸出可用變量的情況$CKEditor-》basePath = '/ckeditor/';//設(shè)置路徑$contentarea = $CKEditor-》editor("content", $rs['contents']); //生成一個以name為content的textarea
echo $contentarea;
3、需要上傳了 ,只好加入ckfinder.把ckfinder和ckeditor放在同級目錄下。
打開/ckfinder/config.php, 首先設(shè)置第一個函數(shù)CheckAuthentication(),這個函數(shù)需要按照自己的規(guī)則寫,只要return true的情況才能允許上傳文件到服務(wù)器的,當然不建議直接寫return true,這將導(dǎo)致安全問題。可以采用session來處理比較方便。
session_start();function CheckAuthentication(){ if(isset($_SESSION['UseEidtor']))
return true;else return false;}
4、上傳文件位置:也在/ckfinder/config.php, 找到$baseUrl,之前一直想自己寫一個方法用來定位路徑,實在不好辦,后來只好用sesssion,如果一個網(wǎng)站中,有需要上傳到不同的位置,正好可以利用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']);兩者配合用起來還是挺不錯的,更重要的原因是安全性高了很多。
config.language = 'en';config.skin = 'v2';config.uiColor = '#AADC6E';config.toolbar = 'Basic';…。
2、官方的demo大多都喜歡用js配置editor區(qū)域,習慣寫php的我就嫌麻煩,只好看內(nèi)置的php類。
require_once ROOTPATH 。 "ckeditor/ckeditor.php";$CKEditor = new CKEditor();$CKEditor-》returnOutput = true; //設(shè)置輸出可用變量的情況$CKEditor-》basePath = '/ckeditor/';//設(shè)置路徑$contentarea = $CKEditor-》editor("content", $rs['contents']); //生成一個以name為content的textarea
echo $contentarea;
3、需要上傳了 ,只好加入ckfinder.把ckfinder和ckeditor放在同級目錄下。
打開/ckfinder/config.php, 首先設(shè)置第一個函數(shù)CheckAuthentication(),這個函數(shù)需要按照自己的規(guī)則寫,只要return true的情況才能允許上傳文件到服務(wù)器的,當然不建議直接寫return true,這將導(dǎo)致安全問題。可以采用session來處理比較方便。
session_start();function CheckAuthentication(){ if(isset($_SESSION['UseEidtor']))
return true;else return false;}
4、上傳文件位置:也在/ckfinder/config.php, 找到$baseUrl,之前一直想自己寫一個方法用來定位路徑,實在不好辦,后來只好用sesssion,如果一個網(wǎng)站中,有需要上傳到不同的位置,正好可以利用session定位。
復(fù)制代碼 代碼如下:
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環(huán)境下Fckeditor編輯器上傳圖片配置詳細教程
- 探討fckeditor在Php中的配置詳解
- fckeditor編輯器在php中的配置方法
- php下安裝配置fckeditor編輯器的方法
- php下FCKeditor2.6.5網(wǎng)頁編輯器的使用方法
- php ckeditor上傳圖片文件名亂碼解決方法
- php fckeditor 調(diào)用的函數(shù)
- fckeditor在php中的用法(添加于修改寫成了函數(shù))
- 將FCKeditor導(dǎo)入PHP+SMARTY的實現(xiàn)方法
- jQuery+PHP發(fā)布的內(nèi)容進行無刷新分頁(Fckeditor)
- php版本CKEditor 4和CKFinder安裝及配置方法圖文教程
相關(guān)文章
Ueditor和CKeditor 兩款編輯器的使用與配置方法
這篇文章主要介紹了Ueditor和CKeditor 兩款編輯器的使用與配置方法,需要的朋友可以參考下2017-03-03