YAFLogo

jackiechou
  • jackiechou
  • 66.4% (Friendly)
  • YAF Camper Topic Starter
8 years ago
Hi,
Please help me to customize CKeditor to upload and insert image for admin. I'd like to set up for ckeditor to upload image for admin right. Please tell me how to do this.

Best Regards,
Jackie
Sponsor

tha_watcha
  • tha_watcha
  • 100% (Exalted)
  • YAF.NET Project Lead 🤴 YAF Version: 3.0.3
8 years ago
Well the easiest way would be to allow attachments for admins via the Access Mask Admin (enable upload).

If you want to allow uploads directly from the CKEditor, then the only way would be to use the NOT FREE CKFinder. If you want that option let me know, i have to update the guide on how to integrate CKFinder into YAF.
jackiechou
  • jackiechou
  • 66.4% (Friendly)
  • YAF Camper Topic Starter
8 years ago
Hi,
I'd like to upload directly from the CKEditor by using CKFinder. Please tell me how to integrate CKFinder into YAF.
Thanks,
Best regards,
Jackie
tha_watcha
  • tha_watcha
  • 100% (Exalted)
  • YAF.NET Project Lead 🤴 YAF Version: 3.0.3
8 years ago
Originally Posted by: jackiechou 

Hi,
I'd like to upload directly from the CKEditor by using CKFinder. Please tell me how to integrate CKFinder into YAF.
Thanks,
Best regards,
Jackie



Updated Guide is online here...
http://yetanotherforum.net/forum/posts/m53613-Post-Support-Questions-in-this-Forum#post53613 
Zero2Cool
8 years ago
Originally Posted by: tha_watcha 

Originally Posted by: jackiechou 

Hi,
I'd like to upload directly from the CKEditor by using CKFinder. Please tell me how to integrate CKFinder into YAF.
Thanks,
Best regards,
Jackie



Updated Guide is online here...
http://yetanotherforum.net/forum/posts/m53613-Post-Support-Questions-in-this-Forum#post53613 




I went to that link and got this.
Access Denied
You tried to enter an area where you didn't have access.
tha_watcha
  • tha_watcha
  • 100% (Exalted)
  • YAF.NET Project Lead 🤴 YAF Version: 3.0.3
8 years ago
Sorry this was posted in a closed forum, here is the Guide...

Quick CKFinder Integrate Guide

- Go to the Website of CKFinder and Download File (CKFinder for ASP.NET )
- Extract the Zip file and copy the file CKFinder.dll from the folder bin\Release to your YAF Forum Root folder
- Copy the folders core, help, lang, plugins, skins and userfiles to the YAF Forum ~\Scripts\ckeditor\ckfinder\
- Copy the files ckfinder.html, config.js, config.ascx and ckfinder.js to the YAF Forum ~\Scripts\ckeditor\ckfinder\
- Modify the ckeditor_init.js and ckeditor_initbbcode.js

change the line from...

jQuery("a[id*='_PostReply'],a[id*='_Save']").click(function () {

to...

CKEDITOR.scriptLoader.load('Scripts/ckeditor/ckfinder/ckfinder.js', function (){
			  CKFinder.setupCKEditor( null, 'Scripts/ckeditor/ckfinder/' );
		  });

jQuery("a[id*='_PostReply'],a[id*='_Save']").click(function () {


You also need to add some authentication check to the ckfinder change the CheckAuthentication Check in the file ~/Scripts/ckeditor/ckfinder/config.ascx

Add an import namespace to the header of the file

<%@ Import Namespace="YAF.Core" %>

change the CheckAuthentication from...

public override bool CheckAuthentication()
	{
		// WARNING : DO NOT simply return "true". By doing so, you are allowing
		// "anyone" to upload and list the files in your server. You must implement
		// some kind of session validation here. Even something very simple as...
		//
		//		return ( Session[ "IsAuthorized" ] != null && (bool)Session[ "IsAuthorized" ] == true );
		//
		// ... where Session[ "IsAuthorized" ] is set to "true" as soon as the
		// user logs on your system.

		return false;
	}


to..

public override bool CheckAuthentication()
	{
		return !YafContext.Current.IsGuest;
	}

(You could also add check if the user is in a allowed role if you want to limit the access)

also change the line

BaseUrl = "";

to..

BaseUrl = HttpContext.Current.Request.Url.Scheme + "://" + HttpContext.Current.Request.Url.Authority + HttpContext.Current.Request.ApplicationPath + "/Scripts/ckeditor/ckfinder/";

and basedir to...

BaseDir = Server.MapPath("~/Scripts/ckeditor/ckfinder/userfiles/");
jackiechou
  • jackiechou
  • 66.4% (Friendly)
  • YAF Camper Topic Starter
8 years ago
Hi,
Thanks for your reply. I appreciate you very high for your kind to help me.
I try to folow all your steps you have intructed, but I unable to upload file to files to Scripts\ckeditor\ckfinder\userfiles
When I press "Insert Image" Browse file and choose and press button "Upload to server" but no happens here. No file is in this folder "Scripts\ckeditor\ckfinder\userfiles"
Error :
XML Parsing Error: not well-formed Location:
http://localhost:50165/Scripts/ckeditor/ckfinder/ckfinder.html?type=Images&CKEditor=forum_ctl03_YafTextEditor&CKEditorFuncNum=1&langCode=vi
Line Number 214, Column 30: if ((messageId == 0 && lastMessageId != 0) || lastMessageId < messageId)
UserPostedImage

I suppose that there is a problem in settings that cfkinder is unable to find the uploading folder "Scripts\ckeditor\ckfinder\userfiles"

ckeditor_init.js - ckeditor_initbbcode.js
CKEDITOR.scriptLoader.load('Scripts/ckeditor/ckfinder/ckfinder.js', function (){
CKFinder.setupCKEditor( null, 'Scripts/ckeditor/ckfinder/' );
});

jQuery("a[id*='_PostReply'],a[id*='_Save']").click(function() {
yafCKEditor.editor.updateElement();
});

config.ascx

public override bool CheckAuthentication()
{
return !YafContext.Current.IsGuest;
}

BaseUrl = HttpContext.Current.Request.Url.Scheme + "://" + HttpContext.Current.Request.Url.Authority + HttpContext.Current.Request.ApplicationPath + "/Scripts/ckeditor/ckfinder/";

BaseDir = Server.MapPath("~/Scripts/ckeditor/ckfinder/userfiles/");


Please help me!
Best regards,
Jackie
tha_watcha
  • tha_watcha
  • 100% (Exalted)
  • YAF.NET Project Lead 🤴 YAF Version: 3.0.3
8 years ago
This issue is caused by the url rewriter. To resolve this issue open up the UrlRewriter.config and change line from...

<if url="^((?!\.ashx|\.asmx|\.axd|\.gif|\.png|\.jpg|\.ico|\.pdf|\.css|\.js|install|error|auth\.aspx|default\.aspx|popup\.aspx|advanced\.aspx|digest\.aspx|ftb.imagegallery\.aspx).)*$">

to

<if url="^((?!\.ashx|\.asmx|\.axd|\.gif|\.png|\.jpg|\.ico|\.pdf|\.css|\.js|install|error|auth\.aspx|default\.aspx|popup\.aspx|advanced\.aspx|digest\.aspx|ftb.imagegallery\.aspx|ckfinder).)*$">
YAF Logo Copyright © YetAnotherForum.NET & Ingo Herbote. All rights reserved
About Us

The YAF.NET is an open source .NET forum project. YAF.NET is supported by an team of international developers who are build community by building community software.

Powered by Resharper Donate with PayPal button