首頁  >  文章  >  php教程  >  在php中整合ckeditor、ckfinder详细终结版

在php中整合ckeditor、ckfinder详细终结版

WBOY
WBOY原創
2016-06-06 19:42:091111瀏覽

我博客前面有一篇是关于ckeditor的配置的文章,但那是急迫从网上复制下来的。由于自己写了个php程序,所以要html编辑器,老版本的fkeditor又不想用。所以就准备用ckeditor,(长沙seo)ckeditor有个缺点就是不能上传本地的图片和flash,就只好把ckeditor和ck

   我博客前面有一篇是关于ckeditor的配置的文章,但那是急迫从网上复制下来的。由于自己写了个php程序,所以要html编辑器,老版本的fkeditor又不想用。所以就准备用ckeditor,(长沙seo)ckeditor有个缺点就是不能上传本地的图片和flash,就只好把ckeditor和ckfinder整合了。下面就开始了。

   一、配置ckfinder

   1、先从官网下ckeditor和ckfinder,把他们(长沙seo)解压放在网站的跟目录下,然后再把ckfinder文件放到ckeditor的文件下。

   2、ckfinder没修改配置之前是不允许上传文件到服务器的,所以我们要对ckfinder文件下的config.php文件里的return false 改为return true。为了让大家能找到,这里贴出详细的代码=》

function 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 isset($_SESSION['IsAuthorized']) && $_SESSION['IsAuthorized'];

 // ... where $_SESSION['IsAuthorized'] is set to "true" as soon as the
 // user logs in your system. To be able to use session variables don't
 // forget to add session_start() at the top of this file.

 return flase;//改为人return false
}
  3、设置了开启上传功能之后,我们这不要做的就是要设置文件上传之后存放的路径。还是找到ckfinder文件下的config.php,打开config.php,找到"$baseUrl",给这个变量赋所要存放文件的路径值。也就是如果你要把文件存放在根目录下的“sp”文件家里,就给赋值"$baseurl='../sp/';",只要上穿了文件他会自动建立相应的文件夹。

   二、整合ckeditor和ckfinder

   1、新建一个php网页文件,在头部加载ckeditor和ckfinder,如://加载ckeditor,//加载ckfinder。
   2、在php网页文件里新建一个表单,然后再在表单里建一个textarea去,并命名name属性,如:
   3、在表单之后加入一段js代码,如下:  测试下看能不能上传文件。

   4、关于ckeditor的设置,由于ckeditor的菜单选项繁多,我们日常好多都用不上,所以我对ekeditor菜单进行了一些删减,在ekeditor的文件夹中找到config.js文件,在’CKEDITOR.editorConfig = function( config ){‘之后添加如下代码:

config.height=500;
config.width=700;//config.height和config.width是设置eckeditor的宽和高的,这里可以自行定义。

config.toolbar_Full = [
['Source','-','Save','Preview'],
['Cut','Copy','Paste','PasteText','PasteFromWord',],
['Undo','Redo','-','Find','Replace']
['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],
['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],
['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
['Link','Unlink','Anchor'],'/',
['Styles','Format','Font','FontSize'],
['TextColor','BGColor'],
['Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak']
];

   这里贴出php中整合ckeditor和ckfinder的php的测试源码

     /p>

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">



陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn