佳木斯湛栽影视文化发展公司

主頁 > 知識(shí)庫 > php版本CKEditor 4和CKFinder安裝及配置方法圖文教程

php版本CKEditor 4和CKFinder安裝及配置方法圖文教程

熱門標(biāo)簽:電子圍欄 科大訊飛語音識(shí)別系統(tǒng) 服務(wù)器配置 Mysql連接數(shù)設(shè)置 阿里云 Linux服務(wù)器 團(tuán)購網(wǎng)站 銀行業(yè)務(wù)

本文實(shí)例講述了php版本CKEditor 4和CKFinder安裝及配置方法。分享給大家供大家參考,具體如下:

下載并解壓CKEditor 4和CKFinder

CKEditor 4下載地址:https://ckeditor.com/cke4/builder,選擇自定義的版本,記得加上中文語言包

CKFinder下載地址:https://download.cksource.com/CKFinder/CKFinder%20for%20PHP/3.4.4/ckfinder_php_3.4.4.zip

查看CKEditor的示例文件,http://127.0.0.1/ckeditor/samples/

根據(jù)你的需求選擇自定義工具欄,選好之后點(diǎn)擊Get toolbar config,把這個(gè)配置代碼復(fù)制,備用

在CKEditor 4同級(jí)目錄新建index.html,和myconfig.js

index.html的源代碼為:

!DOCTYPE html>
html>
head>
    meta charset="utf-8">
    title>CKEditor Sample/title>
    !-- 加載ckeditor.js -->
    script src="./ckeditor/ckeditor.js">/script>
/head>
body id="main">
    textarea name="editor1" id="editor1" cols="30" rows="10">
        這是一個(gè)CKEditor測(cè)試
    /textarea>
script>
    // 這樣就可以使用啦
    CKEDITOR.replace('editor1',{
        //toolbar : 'Basic',      //方式1,在此直接寫配置
        //uiColor : '#9ab8f5'
        customConfig : '../myconfig.js' //方式2,加載配置js,相對(duì)于ckeditor.js的路徑
    });
/script>
/body>
/html>

myconfig.js的源代碼為:

//特別注意,每次修改都要ctrl+f5 清除緩存后查看
CKEDITOR.editorConfig = function( config ) {
  config.language = "zh-cn" ; //語言,對(duì)應(yīng)ckeditor下的lang文件夾
    config.uiColor = '#9ab8f5';  //編輯器顏色
    config.width = '900';     //編輯器寬
    config.height = '500';    //編輯器高
    //自定義工具欄,剛才從示例哪里復(fù)制的代碼
    config.toolbarGroups = [
        '/',
        { name: 'document', groups: [ 'mode', 'document', 'doctools' ] },
        { name: 'clipboard', groups: [ 'clipboard', 'undo' ] },
        { name: 'editing', groups: [ 'find', 'selection', 'spellchecker', 'editing' ] },
        { name: 'forms', groups: [ 'forms' ] },
        { name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] },
        { name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi', 'paragraph' ] },
        { name: 'links', groups: [ 'links' ] },
        { name: 'insert', groups: [ 'insert' ] },
        { name: 'styles', groups: [ 'styles' ] },
        { name: 'colors', groups: [ 'colors' ] },
        { name: 'tools', groups: [ 'tools' ] },
        { name: 'others', groups: [ 'others' ] },
        { name: 'about', groups: [ 'about' ] }
    ];
    config.removeButtons = 'NewPage,Save,Preview,Cut,Copy,Paste,PasteText,PasteFromWord,Find,Replace,SelectAll,Scayt,HiddenField,Form,Radio,TextField,Textarea,Select,Button,ImageButton,Outdent,Indent,Subscript,Superscript,Strike,Blockquote,CreateDiv,BidiLtr,BidiRtl,Language,Anchor,Table,HorizontalRule,Smiley,SpecialChar,PageBreak,Iframe,ShowBlocks,About,Source';
    //ckfinder的相關(guān)配置項(xiàng)
    config.filebrowserBrowseUrl = './ckfinder/ckfinder.html' ;
  config.filebrowserImageBrowseUrl = './ckfinder/ckfinder.html?type=Images' ;
  config.filebrowserFlashBrowseUrl = './ckfinder/ckfinder.html?type=Flash' ;
  config.filebrowserUploadUrl = './ckfinder/core/connector/php/connector.php?command=QuickUploadtype=Files' ;
  config.filebrowserImageUploadUrl = './ckfinder/core/connector/php/connector.php?command=QuickUploadtype=Images' ;
  config.filebrowserFlashUploadUrl = './ckfinder/core/connector/php/connector.php?command=QuickUploadtype=Flash' ;
  config.filebrowserWindowWidth = '600';   //文件瀏覽寬
  config.filebrowserWindowHeight = '300';   //文件瀏覽寬
};

網(wǎng)上搜索有同學(xué)總結(jié)了最全的配置項(xiàng),詳見附錄說明

圖片上傳,點(diǎn)擊瀏覽服務(wù)器,會(huì)出下面的提示

修改ckfinder文件夾下config.php,將29行的return false;改為return true;

ckfinder即可正常使用,上傳圖片的默認(rèn)保存位置為根目錄下的ckfinder->userfiles->images。

附:CKEditor基本配置示例

CKEDITOR.editorConfig = function( config )
{
    // config.language = 'fr';
    // config.uiColor = '#AADC6E';
    config.filebrowserBrowseUrl = '/CKEditorAndCKFinder/ckfinder/ckfinder.html' ;
  config.filebrowserImageBrowseUrl = '/CKEditorAndCKFinder/ckfinder/ckfinder.html?type=Images' ;
  config.filebrowserFlashBrowseUrl = '/CKEditorAndCKFinder/ckfinder/ckfinder.html?type=Flash' ;
  config.filebrowserUploadUrl = '/CKEditorAndCKFinder/ckfinder/core/connector/java/connector.java?command=QuickUploadtype=Files' ;
  config.filebrowserImageUploadUrl = '/CKEditorAndCKFinder/ckfinder/core/connector/java/connector.java?command=QuickUploadtype=Images' ;
  config.filebrowserFlashUploadUrl = '/CKEditorAndCKFinder/ckfinder/core/connector/java/connector.java?command=QuickUploadtype=Flash' ;
  config.filebrowserWindowWidth = '1000';
  config.filebrowserWindowHeight = '700';
  config.language = "zh-cn" ;
  //編輯器樣式,有三種:'kama'(默認(rèn))、'office2003'、'v2'
  //config.skin = "v2";
  //背景顏色
  //config.uiColor = "#FFF";
  //工具欄(基礎(chǔ)'Basic'、全能'Full'、自定義)
  config.toolbar = 'Full';
  //工具欄是否可以被收縮
  //config.toolbarCanCollapse = false;
  //工具欄的位置
  //config.toolbarLocation = "bottom";
  //工具欄默認(rèn)是否展開
  //config.toolbarStartupExpanded = false;
  //取消“拖拽以改變尺寸”的功能
  //config.resize_enabled = false;
  //改變大小的最大高度
  //config.resize_maxHeight = 3000;
  //改變大小的最大寬度
  //config.resize_minWidth = 3000;
  //改變大小的最小高度
  //config.resize_minHeight = 250;
  //改變大小的最小寬度
  //config.resize_minWidth = 750;
  //當(dāng)提交包含有此編輯器的表單時(shí),是否自動(dòng)更新元素內(nèi)的數(shù)據(jù)
  //config.autoUpdateElement = true;
  //設(shè)置是使用絕對(duì)目錄還是相對(duì)目錄,為空為相對(duì)目錄
  //config.baseHref = "";
  //編輯器的z-index值
  //config.baseFloatZIndex = 10000;
  //設(shè)置快捷鍵
  //config.keystrokes = [];
  //設(shè)置快捷鍵 可能與瀏覽器快捷鍵沖突
  //config.blockedKeystrokes = [];
  //設(shè)置編輯內(nèi)元素的背景色的取值
  //config.colorButton_backStyle = {
  //    element : 'span',
  //    styles : {'background-color' : '#(color)'}
  //}
  //設(shè)置前景色的取值
  //config.colorButton_colors
  //是否在選擇顏色時(shí)顯示“其它顏色”選項(xiàng)
  //config.colorButton_enableMore = false;
  //前景色默認(rèn)值設(shè)置
  //config.colorButton_foreStyle = {
  //    element : 'span',
  //    styles : {'background-color' : '#(color)'}
  //}
  //所需要添加的CSS文件 在此添加 可使用相對(duì)路徑和網(wǎng)站的絕對(duì)路徑
  //config.contentsCss = "ckeditor/contents.css"
  //文字方向
  //config.contentsLangDirection = "rtl";
  //CKeditor的配置文件 若不想配置 留空即可
  //CKEDITOR.replace("myfield",{customConfig : "ckeditor/config.js"});
  //界面編輯框的背景色
  //config.dialog_backgroundCoverColor = "rgb(a,b,c)";
  //config.dialog_backgroundCoverColor = "white";
  //背景的不透明度
  //config.dialog_backgroundCoverOpacity = 0.5;
  //移動(dòng)或者改變?cè)貢r(shí) 邊框的吸附距離 單位:像素
  //config.dialog_magnetDistance = 20;
  //是否拒絕本地拼寫檢查和提示 默認(rèn)為拒絕 目前僅firefox和safari支持
  //config.disableNativeSpellChecker = true;
  //進(jìn)行表格編輯功能 如:添加行或列 目前僅firefox支持
  //sconfig.disableNativeTableHandles = true; 默認(rèn)不開啟
  //設(shè)置HTML文檔類型
  //config.docType = '!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">';
  //是否對(duì)編輯區(qū)域進(jìn)行渲染
  //config.editingBlock = true;
  //編輯器中回車產(chǎn)生的標(biāo)簽
  //config.enterMode = CKEDITOR_ENTER_BR;
  //是否使用HTML實(shí)體進(jìn)行輸出
  //config.entities = true;
  //定義更多的實(shí)體
  //config.entities_additional = "#1049";
  //是否轉(zhuǎn)換一些難以顯示的字符為相應(yīng)的HTML字符
  //config.entities_greek = true;
  //是否轉(zhuǎn)換一些拉丁字符為HTML
  //cofig.entities_latin = true;
  //是否轉(zhuǎn)換一些特殊字符為ASCII字符
  //config.entities_processNumerical = false;
  //添加新組件
  //config.extraPlugins = "myplugin";
  //使用搜索時(shí)的高亮色
  //config.find_highlight = {
  //    element : "span",
  //    style : {"background-color" : "#ff0", "color" : "#00f"}
  //}
  //默認(rèn)的字體名
  //config.font_defaultLabel = "Arial";
  //字體編輯時(shí)的字符集 可以添加常用的中文字符:宋體、楷體、黑體等
  //config.font_names = "Arial;Times New Roman;Verdana";
  //文字的默認(rèn)式樣
  //config.font_style = {};
  //字體默認(rèn)大小
  //config.fontSize_defaultLabel = "12px";
  //字體編輯時(shí)可選的字體大小
  //config.fontSize_sizes = "8/8px;9/9px;10/10px;11/11px;12/12px;14/14px;16/16px;18/18px;20/20px;22/22px;24/24px;26/26px;28/28px;36/36px;48/48px;72/72px";
  //設(shè)置字體大小時(shí) 使用的式樣
  //config.fontSize_style = {};
  //是否強(qiáng)制復(fù)制來的內(nèi)容去除格式
  //config.forcePasteAsPlainText = false;//不去除
  //是否強(qiáng)制用“”來代替“”
  //config.forceSimpleAmpersand = false;
  //對(duì)address標(biāo)簽進(jìn)行格式化
  //config.format_address = { element : 'address', attributes : { class : 'styledAddress' } };
  //對(duì)DIV標(biāo)簽自動(dòng)進(jìn)行格式化
  //config.format_div = { element : 'div', attributes : { class : 'normalDiv' } };
  //對(duì)H1標(biāo)簽自動(dòng)進(jìn)行格式化
  //config.format_h1 = { element : 'h1', attributes : { class : 'contentTitle1' } };
  //對(duì)H2標(biāo)簽自動(dòng)進(jìn)行格式化
  //config.format_h2 = { element : 'h2', attributes : { class : 'contentTitle2' } };
  //對(duì)H3標(biāo)簽自動(dòng)進(jìn)行格式化
  //config.format_h3 = { element : 'h3', attributes : { class : 'contentTitle3' } };
  //對(duì)H4標(biāo)簽自動(dòng)進(jìn)行格式化
  //config.format_h4 = { element : 'h4', attributes : { class : 'contentTitle4' } };
  //對(duì)H5標(biāo)簽自動(dòng)進(jìn)行格式化
  //config.format_h5 = { element : 'h5', attributes : { class : 'contentTitle5' } };
  //對(duì)H6標(biāo)簽自動(dòng)進(jìn)行格式化
  //config.format_h6 = { element : 'h6', attributes : { class : 'contentTitle6' } };
  //對(duì)P標(biāo)簽自動(dòng)進(jìn)行格式化
  //config.format_p = { element : 'p', attributes : { class : 'normalPara' } };
  //對(duì)PRE標(biāo)簽自動(dòng)進(jìn)行格式化
  //config.format_pre = { element : 'pre', attributes : { class : 'code' } };
  //用分號(hào)分隔的標(biāo)簽名字 在工具欄上顯示
  //config.format_tags = "p;h1;h2;h3;h4;h5;h6;pre;address;div";
  //是否使用完整的html編輯模式 如使用,其源碼將包含:html>body>/body>/html>等標(biāo)簽
  //config.fullPage = false;
  //是否忽略段落中的空字符
  //config.ignoreEmptyParagraph = true;
  //在清除圖片屬性框中的鏈接屬性時(shí) 是否同時(shí)清除兩邊的a>標(biāo)簽
  //config.image_removeLinkByEmptyURL = true;
  //一組用逗號(hào)分隔的標(biāo)簽名稱,顯示在左下角的層次嵌套中
  //config.menu_groups ='clipboard,form,tablecell,tablecellproperties,tablerow,tablecolumn,table,anchor,link,image,flash,checkbox,radio,textfield,hiddenfield,imagebutton,button,select,textarea';
  //顯示子菜單時(shí)的延遲,單位:ms
  //config.menu_subMenuDelay = 400;
  //當(dāng)執(zhí)行“新建”命令時(shí),編輯器中的內(nèi)容
  //config.newpage_html = "";
  //當(dāng)從word里復(fù)制文字進(jìn)來時(shí),是否進(jìn)行文字的格式化去除
  //config.pasteFromWorldIgnoreFontFace = true; //默認(rèn)忽略格式
  //是否使用h1>h2>等標(biāo)簽修飾或者代替從word文檔中粘貼過來的內(nèi)容
  //config.pasteFromWorkKeepsStructure = false;
  //從word中粘貼內(nèi)容時(shí)是否移除格式
  //config.pasteFromWorkRemoveStyle = false;
  //對(duì)應(yīng)后臺(tái)語言的類型來對(duì)輸出的HTML內(nèi)容進(jìn)行格式化,默認(rèn)為空
  //config.protectedSource.push( /\&;[\s\S]*?\&;>/g );  // PHP code
  //config.protectedSource.push( /%[\s\S]*?%>/g );  // ASP code
  //config.protectedSource.push( /(]+>[\s|\S]*?\/asp:[^\&;]+>)|(]+\/>)/gi );  // ASP.Net code
  //當(dāng)輸入:shift+Enter時(shí)插入的標(biāo)簽
  //config.shiftEnterMode = CKEDITOR.ENTER_P;
  //可選的表情替代字符
  //config.smiley_descriptions = [
  //     ':)', ':(', ';)', ':D', ':/', ':P',
  //     '', '', '', '', '', '',
  //     '', ';(', '', '', '', '',
  //     '', ':kiss', '' ];
  //對(duì)應(yīng)的表情圖片
  //config.smiley_images = [
  //  'regular_smile.gif','sad_smile.gif','wink_smile.gif','teeth_smile.gif','confused_smile.gif','tounge_smile.gif',
  //  'embaressed_smile.gif','omg_smile.gif','whatchutalkingabout_smile.gif','angry_smile.gif','angel_smile.gif','shades_smile.gif',
  //  'devil_smile.gif','cry_smile.gif','lightbulb.gif','thumbs_down.gif','thumbs_up.gif','heart.gif',
  //  'broken_heart.gif','kiss.gif','envelope.gif'];
  //表情的地址
  //config.smiley_path = "plugins/smiley/images";
  //頁面載入時(shí),編輯框是否立即獲得焦點(diǎn)
  //config.startupForce = false;
  //載入時(shí),以何種方式編輯 源碼和所見即所得 "source"和"wysiwyg"
  //config.startupMode = "wysiwyg";
  //載入時(shí),是否顯示框體的邊框
  //config.startupOutlineBlocks = false;
  //是否載入樣式文件
  // Load from the styles' styles folder (mystyles.js file).
  //config.stylesSet = 'mystyles';
  // Load from a relative URL.
  //config.stylesSet = 'mystyles:/editorstyles/styles.js';
  // Load from a full URL.
  //config.stylesSet = 'mystyles:http://www.example.com/editorstyles/styles.js';
  // Load from a list of definitions.
  //config.stylesSet = [
  //{ name : 'Strong Emphasis', element : 'strong' },
  //{ name : 'Emphasis', element : 'em' }, ... ];
  //起始的索引值
  //config.tabIndex = 0;
  //當(dāng)用戶鍵入TAB時(shí),編輯器走過的空格數(shù),( ) 當(dāng)值為0時(shí),焦點(diǎn)將移出編輯框
  //config.tabSpaces = 4;
  //默認(rèn)使用的模板
  //config.templates = "default";
  //用逗號(hào)分隔的模板文件
  //config.templates_files = ['plugins/templates/templates/default.js'];
  //當(dāng)使用模板時(shí),“編輯內(nèi)容將被替換”框是否選中
  //config.templates_replaceContent = true;
  //主題
  //config.theme = "default";
  //撤銷的記錄步數(shù)
  //config.undoStackSize = 20;
  //config.contentsCss = "/CKEditorAndCKFinder/ckeditor/css/mysitestyles.css";
};

更多關(guān)于PHP相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《PHP擴(kuò)展開發(fā)教程》、《PHP網(wǎng)絡(luò)編程技巧總結(jié)》、《php curl用法總結(jié)》、《PHP數(shù)組(Array)操作技巧大全》、《PHP數(shù)據(jù)結(jié)構(gòu)與算法教程》、《php程序設(shè)計(jì)算法總結(jié)》及《php字符串(string)用法總結(jié)》

希望本文所述對(duì)大家PHP程序設(shè)計(jì)有所幫助。

您可能感興趣的文章:
  • CKEditor4配置與開發(fā)詳細(xì)中文說明文檔
  • 網(wǎng)頁編輯器FCKeditor 2.6.4精簡配置方法
  • 手把手教你 CKEDITOR 4 擴(kuò)展插件制作
  • 手把手教你 CKEDITOR 4 實(shí)現(xiàn)Dialog 內(nèi)嵌 IFrame操作詳解
  • CKEditor 4.4.1 添加代碼高亮顯示插件功能教程【使用官方推薦Code Snippet插件】
  • ckeditor的使用和配置方法分享
  • PHP CKEditor 上傳圖片實(shí)現(xiàn)代碼
  • CKEditor網(wǎng)頁編輯器 中文使用說明
  • 通過Fckeditor把圖片上傳到獨(dú)立圖片服務(wù)器的方法
  • 限制ckeditor上傳圖片文件大小的方法
  • CKeditor4 字體顏色功能配置方法教程

標(biāo)簽:衢州 大理 廣元 蚌埠 棗莊 江蘇 衡水 萍鄉(xiāng)

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《php版本CKEditor 4和CKFinder安裝及配置方法圖文教程》,本文關(guān)鍵詞  ;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 收縮
    • 微信客服
    • 微信二維碼
    • 電話咨詢

    • 400-1100-266
    建阳市| 三亚市| 宁武县| 六安市| 秦安县| 横山县| 贡嘎县| 阆中市| 赣州市| 六安市| 故城县| 桐梓县| 柳林县| 当雄县| 安图县| 禄丰县| 乐亭县| 左云县| 金乡县| 格尔木市| 天津市| 福鼎市| 廉江市| 新田县| 额敏县| 如东县| 湖州市| 通州市| 绥芬河市| 廊坊市| 乌鲁木齐市| 霍林郭勒市| 霍邱县| 吉首市| 阜阳市| 宁陕县| 双鸭山市| 雅江县| 峨边| 高平市| 虹口区|