2009-12-14 54 views
3

我使用的是CKEditor 3,我需要集成一個免費的文件瀏覽器/上傳器。我試圖整合附帶FCKEditor的一個,但我always get this XML errorCKeditor與FCKeditor文件瀏覽器的集成

The server didn't send back a proper XML response. Please contact your system administrator.

XML request error: OK (200)

Requested URL: http://example.com/admin/filemanager/browser/default/?Command=GetFoldersAndFiles&Type=File&CurrentFolder=%2F&uuid=1260817820353

Response text:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> 
<html> 
<head> 
    <title>Index of /admin/filemanager/browser/default</title> 
</head> 
<body> 
<h1>Index of /admin/filemanager/browser/default</h1> 
<table><tr><th><img src="/icons/blank.gif" alt="[ICO]"></th> 
    <th><a href="?C=N;O=D">Name</a></th> 
    <th><a href="?C=M;O=A">Last modified</a></th> 
    <th><a href="?C=S;O=A">Size</a></th> 
    <th><a href="?C=D;O=A">Description</a></th></tr> 
<!-- edited for brevity --> 

我試圖做這樣:

<script type="text/javascript"> 
window.onload = function(){ 
    CKEDITOR.config.language='es'; 
    CKEDITOR.config.forcePasteAsPlainText = true; 
    CKEDITOR.config.enterMode = CKEDITOR.ENTER_DIV; 
    CKEDITOR.replace('ncCont',{ 
    filebrowserBrowseUrl: 'filemanager/browser/default/browser.html', 
    filebrowserUploadUrl : 'filemanager/connectors/php/upload.php' 
    }); 
}; 
</script> 

能的FCKeditor與CKEditor的整合?如果是,那怎麼辦?如果沒有,是否有免費的filebrowser/uploader替代方案?

回答

0

我使用自定義文件瀏覽器與我的ckeditor實現,所以我不明白你爲什麼不能使用舊的文件瀏覽器。它使用相同的JavaScript來填充編輯器。

只需將舊的FCK編輯器安裝在任何目錄中,並確保在配置中具有該瀏覽器的正確路徑。我猜你上面有一個路徑問題。

8

要回答你的問題,我已經在我的博客上發佈了一個小教程,一步一步地將FCKEditor的文件瀏覽器集成到CKEditor中。請轉到:

http://www.mixedwaves.com/2010/02/integrating-fckeditor-filemanager-in-ckeditor/

我這樣做的PHP接口,但應該是對其他語言非常簡單爲好。

您也可以下載已經完成的示例或查看本文中的演示。

+0

我遵循這個指南,而是選擇要上傳的圖片,按下後「發送至服務器」,我總是得到「不能發佈/文件管理器/連接器/ php/upload.php?type = Images & CKEditor = htmlSlide0 & CKEditorFuncNum = 0 & langCode = de「我假設」&「被替換爲」&amp;「,它破壞了字符串,但我找不到代碼不知道PHP)。任何幫助/建議? – MJB 2014-06-10 19:21:27

9

想要背誦Penuel的代碼幫了我很多。

添加這/filemanager/connectors/php/upload.php

// Get the CKEditor Callback 
$CKEcallback = $_GET['CKEditorFuncNum']; 

//modify the next line adding in the new param 
FileUpload($sType, $sCurrentFolder, $sCommand, $CKEcallback); 

添加這/filemanager/connectors/php/io.php

// This is the function that sends the results of the uploading process to CKE. 
function SendCKEditorResults ($callback, $sFileUrl, $customMsg = '') 
{ 
    echo '<script type="text/javascript">'; 

    $rpl = array('\\' => '\\\\', '"' => '\\"') ; 

    echo 'window.parent.CKEDITOR.tools.callFunction("'. $callback. '","'. 
    strtr($sFileUrl, $rpl). '", "'. strtr($customMsg, $rpl). '");' ; 

    echo '</script>'; 
} 

修改此/文件管理器/連接器/php/commands.php

//line 158 
function FileUpload($resourceType, $currentFolder, $sCommand, $CKEcallback = '') 

//line 166 

    if ((isset($_FILES['NewFile']) && !is_null($_FILES['NewFile']['tmp_name'])) 
    # This is for the QuickUpload tab box 
    or (isset($_FILES['upload']) and !is_null($_FILES['upload']['tmp_name']))) 
    { 
    global $Config ; 

    $oFile = isset($_FILES['NewFile']) ? $_FILES['NewFile'] : $_FILES['upload']; 

... 

    if($CKEcallback == '') 
    { 
    // this line already exists so wrap the if block around it 
    SendUploadResults($sErrorNumber, $sFileUrl, $sFileName) ; 
    } 
    else 
    { 
    //issue the CKEditor Callback 
    SendCKEditorResults ($CKEcallback, $sFileUrl, 
    ($sErrorNumber != 0 
     ? 'Error '. $sErrorNumber. ' upload failed. '. $sErrorMsg 
     : 'Upload Successful')); 
    } 

你需要上傳的URL添加到您的CKEDITOR定義,像這樣:

var filemanager = '/js/ckeditor/filemanager/'; 
    var browser = filemanager + 'browser/default/browser.html'; 
    var connector = filemanager + 'connectors/php/connector.php'; 
    var upload = filemanager + 'connectors/php/upload.php'; 
    CKEDITOR.replace(id, 
    {  
    customConfig : this.config, 
    filebrowserBrowseUrl : browser +'?Connector=' + connector, 
    filebrowserImageBrowseUrl : browser + '?Type=Image&Connector=' 
     + connector, 
    filebrowserFlashBrowseUrl : browser + '?Type=Flash&Connector=' 
     + connector, 
    filebrowserUploadUrl : upload + '?type=Files', 
    filebrowserImageUploadUrl : upload + '?type=Images', 
    filebrowserFlashUploadUrl : upload + '?type=Flash' 
    }); 

我認爲,涵蓋了由努伊勒不放過

+0

我遵循本指南(上圖),但在選擇上傳圖片並按下「發送到服務器」後,我總是得到「無法POST /filemanager/connectors/php/upload.php?type=Images & CKEditor = htmlSlide0 & CKEditorFuncNum = 0 & langCode = de「我假設」&「被替換爲」&amp「,這會破壞字符串,但是我找不到執行該操作的代碼(不知道php)。任何幫助/建議? – MJB 2014-06-10 19:21:56