¡¡¡¡µÚÒ»²½£º»ù±¾ÅäÖÃ
CKEditor + CKFinder ÅäÖÃÁ÷Ë®ÕË£º
CKEditor£º
1.½âѹCKEditorµ½webRootĿ¼£¬ÔÚÓ¦ÓÃÒ³Ãæ¼ÓÔØÆäckeditor.js ;
2.Ò³Ãætextarea£º
[html];[/html]
CKFinder£º
3.½âѹCKFinderµ½webRootĿ¼£¨×îºÃÓëCKEditorͬ¼¶£©£¬ÔÚÓ¦ÓÃÒ³Ãæ¼ÓÔØÆäckfinder.js ;
4.Ò³Ãæscript£º£¨×îºÃtextareaÖ®ºó£©
[javascript]
if (typeof CKEDITOR == ¡®undefined¡¯) {
document.write(¡¯¼ÓÔØCKEditorʧ°Ü¡¯);
}
else {
var editor = CKEDITOR.replace(¡¯editor1¡ä);
CKFinder.SetupCKEditor(editor, ¡®../ckeditor/ckfinder/¡¯); //ckfinder×ÜĿ¼µÄÏà¶Ô·¾¶.
}
[/javascript]
ÕûºÏ£º
£¨°ÑÁ©js¼ÓÔØµ½Í¬Ò»ÎļþÆäʵ¾ÍÒѾ»ù±¾ÕûºÏºÃÁË£¬»¹ÐèÒªÐ޸ĵÄÅäÖÃÈçÏ£©
5.´ò¿ª\ckfinder\config.php£¬ÐÞ¸Ä$baseUrl = ¡®£¨ÉÏ´«¸½¼þµÄ´æ·Å·¾¶£©¡¯; //ÒÔwebRootΪÆðʼµÄ¾ø¶Ô·¾¶£¬ÆäĿ¼Ï»á×Ô¶¯Éú³Éimages¡¢flashµÈ×ÓĿ¼£»Ä¬ÈÏÊÇÔÚwebRootµÄ¸ùĿ¼Ï£¬×¢ÒâÐ޸ġ£
ÖÁ´ËÅäÖÃÍê±Ï£¬Èç¹ûÐèÒª×Ô¶¨Òå½çÃæ£¬¿É½øÐÐÒÔϵĸ߼¶Ð޸ģº
6.ÔÚckeditor\config.jsÖеÄCKEDITOR.editorConfigÀï¼ÓÈëÒÔÏÂÐèÒª×Ô¶¨ÒåµÄÅäÖôúÂ룺
[css]
//×ÖÌå.
config.font_names = ¡®ËÎÌå;¿¬Ìå_GB2312;ÐÂËÎÌå;ºÚÌå;Á¥Êé;Ó×Ô²;΢ÈíÑźÚ;Arial;
Comic Sans MS;Courier New;Tahoma;Times New Roman;Verdana;¡¯ ;
//¹¤¾ß°´Å¥.
config.toolbar=
[
['Source','-','Save','NewPage','Preview','-','Templates'],
['Cut','Copy','Paste','PasteText','PasteFromWord','-','Print','SpellChecker','Scayt'],
['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
['Form','Checkbox','Radio','TextField','Textarea','Select','Button',
'ImageButton','HiddenField'],
¡®/¡¯,
['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],
['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],
['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
['Link','Unlink','Anchor'],
['Image','Flash','Table','HorizontalRule','Smiley','SpecialChar',
'PageBreak'],
¡®/¡¯,
['Styles','Format','Font','FontSize'],
['TextColor','BGColor'],
['Maximize','ShowBlocks','-','About']
];
//¿í¶È
config.width = 500;
//¸ß¶È
config.height = 400;
//Ƥ·ô
config.skin=¡¯v2¡ä;
//µÈµÈ¡ ¡
[/css]
°²×°CKFinderºó²ÅÄÜÓÐÉÏ´«¹¦ÄÜ:
µÚ¶þ²½£ºÉèÖÃCKFinderµÄÉÏ´«¹¦ÄÜ
ÓÉÓÚ±¾´ÎCKEditorȫиİ棬ûÓÐÌṩÎļþÉÏ´«¹¦ÄÜ£¬ËùÒÔÑ¡ÔñÕûºÏCKFinderÊǸö²»´íµÄÑ¡Ôñ
ÐèÒªÐÞ¸ÄÒ»ÏÂCKEditor²å¼þÎļþ¼ÐϵÄJSÔ´Â룬ÒÔimage²å¼þΪÀý£¨Flash¼°FilesͬÀí£©£º
Code
//½«Ï±ߵĴúÂë×öһЩÐÞ¸Ä
//{type:'button',id:'browse',align:'center',label:m.lang.common.browseServer,hidden:false,filebrowser:'info:txtUrl'}]}]},
//2009-07-13 ½«ä¯ÀÀ·þÎñÆ÷°´Å¥ÖÃΪÏÔʾ״̬ £¨hidden: false£©,Ôö¼ÓonClickº¯Êý£¬ÓÃÓÚ´ò¿ªckfinderÒ³Ãæ,½ô½Ó×ÅÉÏÃæµÄ´úÂëÌí¼Ó
{ type: 'button', id: 'browse', align: 'center', label: m.lang.common.browseServer, hidden: false, filebrowser: 'info:txtUrl', onClick: function() { var finder = new CKFinder(); finder.BasePath = '../ckfinder20090716/'; finder.SelectFunction = SetFileField; finder.Popup(); } }]}]},
ÔÚ·½·¨ÌåÍâÔö¼Óϱߵĺ¯Êý
//ÓÃÓÚÈ¡»Ø ckfinder ·µ»ØµÄͼƬµØÖ·²¢¶Ô·¾¶Îı¾¿òºÍÔ¤ÀÀͼƬ½øÐи³Öµ
function SetFileField(fileUrl)
{
//»ñÈ¡Ö÷DivϵÄËùÓÐÎı¾¿ò¿Ø¼þ
var inputStr = document.getElementById("cke_txtContent_dialog").getElementsByTagName("Input");
for(var i=0; i
if(inputStr[i].type=="text")
{
//µÚÒ»¸öÊäÈë¿ò¿Ø¼þÊÇͼÏñ·¾¶£¬µÃµ½ID£¬ÉèÖÃеÄͼƬ·¾¶
CKEDITOR.document.getById(inputStr[i].id).setValue(fileUrl);
break ;
}
}
CKEDITOR.document.getById('previewImage').setAttribute('src', decodeURI(fileUrl));
}
µÚÈý²½£ºCKFINDERÉÏ´«ÎÊÌ⣺³öÏÖ¡°ÒòΪ°²È«ÔÒò£¬Îļþ²»¿Éä¯ÀÀ. ÇëÁªÏµÏµÍ³¹ÜÀíÔ±²¢¼ì²éCKFinderÅäÖÃÎļþ¡°
ÕûºÏºó»á³öÏÖ¡°ÒòΪ°²È«ÔÒò£¬Îļþ²»¿Éä¯ÀÀ. ÇëÁªÏµÏµÍ³¹ÜÀíÔ±²¢¼ì²éCKFinderÅäÖÃÎļþ¡°
The Solution:
1. There is no write access for the default upload folder $baseUrl = '/userfiles/'; in ckfinder/config.php.
¶ÔÓÚÄ¿±êÎļþ¼Ð$baseUrl = '/userfiles/';ûÓÐдÈëȨÏÞ
2. This is maybe because the Return value of Funcation CheckAuthentication() is always FALSE by default in ckfinder/config.php. Change the Validation Condition according to your condition, not recommend to set the return value to true directly.
ÒòΪ³öÓÚ°²È«¿¼ÂÇckfinder/config.phpÎļþÖеÄCheckAuthentication()º¯ÊýĬÈÏ·µ»ØÖµÊÇfalse, ÐèÒªÊÖ¶¯ÐÞ¸ÄÑéÖ¤Ìõ¼þ, ²»½¨ÒéÖ±½Ó·µ»Øtrue
ckeditorÖÐĬÈÏÌí¼Óp±êÇ©¡£ºÜ·³ÈË¡£
½â¾ö·½·¨ÈçÏ£º
ÔÚckeditorÎļþÏÂconfig.jsÖмÓ
config.shiftEnterMode = CKEDITOR.ENTER_P;
¾ÍÐÐÁË
config.enterMode = CKEDITOR.ENTER_BR;
ÊÇÆÁ±Îbr±êÇ©µÄ¡£»Ø³µ»á²úÉúbr±êÇ©
config.startupMode = 'source';
ĬÈϽøÈëÔ´Âëģʽ£¬ÓÃÀ´´¦ÀíhtmlÎļþ²»´í£¬ÎÒ×Ô¼ºÉèÖÃÁËĬÈÏÔ´Âëģʽ£¬ÕâÑùһĿÁËÈ»¡£