您好,欢迎访问一九零五行业门户网

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

我博客前面有一篇是关于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>
其它类似信息

推荐信息