How to Use the fckeditor2.6.5 Web Editor in PHP

Source: Internet
Author: User

1. First download fckeditor2.6.5 from the official website. Http://ckeditor.com/download,#:the first is the latest version 3.0.1, and the second is FCKeditor 2.6.5.

2. Delete unnecessary items:

Delete fckconfig. JS, FCKeditor. JS, fckstyles. XML, fcktemplates. XML, FCKeditor. php, fckeditor_php5.php, and fckeditor_php4.php under the/FCKeditor/directory.
All files other than seven files;
Delete directory/Editor/_ source (basically, all folders or files starting with _ are optional );
Delete all directories except the PHP Directory in/Editor/filemanager/connectors;
Delete all files except en. JS, Zh. JS, and zh-cn.js under/Editor/lang.

3. Open/FCKeditor/fckconfig. js
Modify
VaR fckconfig. defaultlanguage = 'zh-cn ';
VaR _ filebrowserlanguage = 'php ';
VaR _ quickuploadlanguage = 'php ';
To enable file upload, you also need to configure editor \ filemanager \ connectors \ PHP \ config. php
Change $ config ['enabled'] = false; to $ config ['enabled'] = true;
Change $ config ['userfilespath'] = '/userfiles/' to your upload directory;

4. call method (example)
place FCKeditor in the website root directory
in the PHP file, including/FCKeditor. PHP file copy Code the code is as follows: // contains the FCKeditor class
include (".. /FCKeditor. PHP ");
// set the editor path
$ sbasepath ="/FCKeditor/";
// create a FCKeditor, the txtarea name of the form is content
$ ofckeditor = new FCKeditor ('content');
$ ofckeditor-> basepath = $ sbasepath;
// set the initial form value
$ ofckeditor-> value = 'this is some sample text ';
$ ofckeditor-> Create ();

// You can also set
$ Ofckeditor-> width
$ Ofckeditor-> height
$ Ofckeditor-> toolbarset
........................................ ........................................ ........................................ ..............................
<Textarea name = "content" style = "display: none"> This isArticleContent test! </Textarea>
<? PHP
Include_once ("FCKeditor/FCKeditor. php ");

$ Ofckeditor = new FCKeditor ('content ');
$ Ofckeditor-> basepath = 'fckeditor /';
$ Ofckeditor-> value = 'default text in editor ';
$ Ofckeditor-> width = '800px ';
$ Ofckeditor-> Height = '300px ';
$ Ofckeditor-> Create ();
// $ Fck = $ ofckeditor-> createhtml ();
?>

The FCKeditor displays garbled characters when uploading a Chinese name file. The method is as follows:
Test environment: PHP 5, UTF-8 encoding

1. Fixed the file name garbled during uploading of Chinese files.
Find the following in the connectors/PHP/commands. php file:
$ Sfilename = $ ofile ['name'];
Add a line after:
$ Sfilename = iconv ("UTF-8", "GBK", $ sfilename );

2. fixed the problem of garbled characters in Chinese file names during file list
Find the following in the connectors/PHP/util. php file:
Return (utf8_encode (htmlspecialchars ($ value )));
To:
Return iconv ('', 'utf-8', htmlspecialchars ($ value ));

3. Fixed the garbled folder name issue when creating a Chinese folder.
Find the following in the connectors/PHP/commands. php file:
$ Snewfoldername =
Add a line after:
$ Snewfoldername = iconv ("UTF-8", "GBK", $ snewfoldername );

HTML files in versions 2.6.3 and later fck have added UTF-8 file headers.

Below are some supplements
Maybe you often go to the background of the website, or publish articles or something. You can add different styles, fonts, and things to your articles. Maybe you will wonder how this works, in fact, this is very simple. You only need to use the FCKeditor plug-in to implement it. Let's take a look at the example below!
Download the latest source code on the FCKeditor official website, http://ckeditor.com/download download the latest FCKeditor source code package.
The configuration will be completed after the download. The source code package contains the FCKeditor/_ samples file, which contains a written example that can be run directly. In this way, you can refer to such source files, it should be noted that most of the editors can be used here, But uploading images cannot be used,
Next, configure the image upload function.

Open the file FCKeditor/Editor/filemanager/Browser/default/connectors/PHP/config. php:
Find $ config ['enabled'] and set it to 'true'; find $ config ['userfilespath'] and set it to the image Directory, which is relative to the main directory. That is to say, this directory is relative to the root directory. Note that if you test it on the local machine, the root directory is http: // localhost,

The basic configuration has been written. The following is a small example I wrote: index. php

<Form name = "form1" method = "Post" Action = "index. php" target = "_ blank">
<? PHP
// Reference the FCKeditor. php file. The basic classes and data structures are all here.
Include ("FCKeditor/FCKeditor. php ");

?>
<Input id = "content" name = "content" value = "" type = "hidden"/> <IFRAME id = "content ___ frame" frameborder = "0" Height =" 100% "scrolling =" no "width =" 100% "src ="/test/bianyiqi/FCKeditor/Editor/fckeditor.html? InstanceName = content & toolbar = default "> </iframe>
<Input name = "Haiyang" value = "I will be better tomorrow" type = "text"/>
<Input type = "Submit" name = "Submit" value = "Submit"/>
</Form>

echo stripslashes ($ _ post ['content']);
echo "
";
echo $ _ post ['haiyang'];
?>
test the function directly. Note that index. php and FCKeditor are in the same level directory.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.