2015-05-11 78 views
0

我在我的項目中使用了CK編輯器。我的要求是圖像上傳,源代碼編輯器,字體樣式等,使CK_Editor可調大小如何自定義ckeditor中的工具並顯示自定義工具

要顯示在網頁的編輯,我已搜查谷歌和我有類似

CKEDITOR.editorConfig = function(config) { 
    // Define changes to default configuration here. For example: 
    // config.language = 'fr'; 
    // config.uiColor = '#AADC6E'; 
    config.removePlugins = 'forms'; 

}; 

但不起作用。請在此幫助我。請按步驟提供步驟 。

我會很感激。

回答

0

首先下載最新的CK編輯的版本,然後在下面添加行config.js

config.extraPlugins = 'filebrowser'; 
config.filebrowserUploadUrl = 'Baseurl/controller_name/ckeditorImageUpload'; 

以下功能添加到您所需的控制器

/** 
* 
* This function used to upload images from ckeditor 
*/ 
public function ckeditorImageUpload(){ 
     $time = time(); 

     //echo $_SERVER['DOCUMENT_ROOT'];exit; 
     //$url = '../../uploads/'.$time."_".$_FILES['upload']['name']; 

     $url = './images/ckeditor/uploads/' . $time . "_" . $_FILES['upload']['name']; 

     $furl = 'http' . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; 
     $fdata = explode('ckupload.php', $furl); 

     //extensive suitability check before doing anything with the file... 
     if (($_FILES['upload'] == "none") OR (empty($_FILES['upload']['name']))) { 
      $message = "No file uploaded."; 
     } else if ($_FILES['upload']["size"] == 0) { 
      $message = "The file is of zero length."; 
     } else if (($_FILES['upload']["type"] != "image/pjpeg") AND ($_FILES['upload']["type"] != "image/jpeg") AND ($_FILES['upload']["type"] != "image/png")) { 
      $message = "The image must be in either JPG or PNG format. Please upload a JPG or PNG instead."; 
     } else if (!is_uploaded_file($_FILES['upload']["tmp_name"])) { 
      $message = "You may be attempting to hack our server. We're on to you; expect a knock on the door sometime soon."; 
     } else { 
      $message = ""; 
      echo $url; 
      //echo "<pre>";print_r($fdata); 
      //exit; 
      $move = @ move_uploaded_file($_FILES['upload']['tmp_name'], $url); 
      if (!$move) { 
       $message = "Error moving uploaded file. Check the script is granted Read/Write/Modify permissions."; 
      } 
      //$url = $fdata[0]."uploads/" . $time."_".$_FILES['upload']['name']; 
      $url = base_url() . "images/ckeditor/uploads/" . $time . "_" . $_FILES['upload']['name']; 
     } 

     $CKEditorFuncNum = $_GET['CKEditorFuncNum']; 
     echo "<script type='text/javascript'>window.parent.CKEDITOR.tools.callFunction($CKEditorFuncNum, '$url', '$message');</script>"; 



} 
+0

我試圖自定義編輯器中的工具...不僅圖像上傳部分...我需要從視圖中刪除剪切,粘貼,複製,刪除,重做按鈕和其他按鈕地區...請幫助... – Nayanz

0

在您的config.js文件,下面的代碼粘貼:

config.toolbar = 'Full'; 
config.toolbar_Full = 
    [ 
     { name: 'document', items: ['Source', '-', 'Save', 'NewPage', 'DocProps', 'Preview', 'Print', '-', 'Templates'] }, 
     { name: 'clipboard', items: ['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo'] }, 
     { name: 'editing', items: ['Find', 'Replace', '-', 'SelectAll', '-', 'SpellChecker', 'Scayt'] }, 
     { name: 'forms', items: ['Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 
      'HiddenField'] }, 
     '/', 
     { name: 'basicstyles', items: ['Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat'] }, 
     { name: 'paragraph', items: ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote', 'CreateDiv', 
      '-', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock', '-', 'BidiLtr', 'BidiRtl'] }, 
     { name: 'links', items: ['Link', 'Unlink', 'Anchor'] }, 
     { name: 'insert', items: ['Image', 'Flash', 'Table', 'HorizontalRule', 'Smiley', 'SpecialChar', 'PageBreak', 'Iframe'] }, 
     '/', 
     { name: 'styles', items: ['Styles', 'Format', 'Font', 'FontSize'] }, 
     { name: 'colors', items: ['TextColor', 'BGColor'] } 
     ,{ name: 'tools', items: ['Maximize', 'ShowBlocks', '-', 'About'] } 
    ]; 

如果你想刪除剪切,複製和粘貼按鈕,然後刪除或commen在行下面,對其他按鈕做同樣的操作。

{ name: 'clipboard', items: ['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo'] },