Use and configuration of FCKeditor 2.6.6 in PHP (Full Version)

Source: Internet
Author: User
Document directory
  • 1. Change the default language and programming language:
  • 2. Enable the file upload function:
  • Note:
  • 1. Modify the toolbar button:
  • 2. What should I do if garbled characters are displayed when I upload a Chinese name file?
  • 3. fixed the problem of garbled characters in Chinese file names during file list
  • 4. Fixed the garbled folder name issue when creating a Chinese folder.
  • 5. add different styles to the article
  • 6. Configure the skin.
  • 7. You can use the tab key in the editor.
  • 8. add several common fonts:
  • 9. Modify the default font
  • 10. An error occurred while browsing the server in the Upload File window.
1. Download

1. First, go to the official website to download the fckeditor2.6.6 multi-language edition (you can search for "FCKeditor 2.6.6, released on 15
February 2010 "). :

Http://ckeditor.com/download

.

Ii. Streamlining

Follow these steps to delete unnecessary test files:

1. Only fckconfig. js (configuration file), FCKeditor. js (JS call file), and ),
FCKeditor. php (PhP call file), fckeditor_php4.php (PhP4 call file ),
Fckeditor_php5.php (PhP5 call file), fckstyles. XML (style), fcktemplates. XML (Template), and
All files other than the seven files in the Editor folder;
2. Delete the directory/Editor/_ source (basically, all folders or files starting with _ are optional );
3. Delete all directories except the PHP Directory in/Editor/filemanager/connectors/(which stores the web dynamic language supported by the editor)
;
4. Delete all files except en. JS, Zh. JS, and zh-cn.js under/Editor/lang/(which stores multilingual configuration files.

3. Set 1. Change the default language and programming language:

Open/FCKeditor/fckconfig. js
(Please note that this file is UTF-8 encoded. When I edited it for the first time, an error occurred while saving the result in the ANSI format. I found the cause for a long time.) modify->
Fckconfig. autodetectlanguage = false .)

VaR fckconfig. defaultlanguage = 'zh-cn ';
VaR _ filebrowserlanguage = 'php ';
VaR _ quickuploadlanguage = 'php ';

2. Enable the file upload function:

Configure Editor/filemanager/connectors/PHP/config. php
Change $ config ['enabled'] = false; to $ config ['enabled'] = true;
Change $ config ['userfilespath'] = '/userfiles/'; To your upload directory (note
: This directory must exist-you have created it yourself );

Note:
This directory 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.
.

Iv. Call

You can use the following example to call the FCKeditor editor in PHP (the PHP file in the example is placed in the subdirectory of the website:

Include ("../FCKeditor. php ");//
Contains the FCKeditor class. The FCKeditor directory is placed under the website root directory.
$ Basepath = "/FCKeditor/"; // editor path
$ Ofckeditor = new FCKeditor ('cremer ');//
Create a FCKeditor object named Cremer
$ Ofckeditor-> basepath = $ basepath;
$ Ofckeditor-> value = 'test'; // you can specify the initial value of a form.
// You can also set the following parts ("="), not required:
// ================================================ ========================================================== ===== //
$ Ofckeditor-> width = '000000'; // editor width. The default value exists in the class. If you do not want to modify the value, skip this item.
$ Ofckeditor-> Height = '000000 ′;//
Same width, which is high $ ofckeditor-> toolbarset
$ Ofckeditor-> toolbarset = 'basic ';//
The Default Editor toolbar has two options: Basic (basic tool) and default (all tools). You can also create a toolbar by yourself.
$ Ofckeditor-> config ['skiconpath'] =
'/FCKeditor/Editor/skins/silver/'; // sets the editor skin.
// ================================================ ========================================================== ===== //

$ Ofckeditor-> Create (); // call the method in the class, required

You can use $ _ post ['cremer '] to obtain the value in the text box.

Note:

// Contains the FCKeditor class
Include ("../FCKeditor. php ");
// Set the editor path
$ Sbasepath = "FCKeditor /";
// Create a FCKeditor with the txtarea name of the form as content
$ Ofckeditor = new FCKeditor ('content ');
$ Ofckeditor-> basepath = $ sbasepath;
// Set the initial value of the form.
$ Ofckeditor-> value = 'this is some <strong> sample
Text </strong> ';
$ Ofckeditor-> Create ();
// Set the length and width
$ Ofckeditor-> width
$ Ofckeditor-> height
$ Ofckeditor-> toolbarset

V. Other examples

 

6. Other Tips 1. Modify the toolbar button:

In this way, the functions that can be used by general users are reduced to improve security:

Fckconfig. toolbarsets ["mystyle"] = [
['Source', 'preview', 'fitwindow', '-', 'templates'],
['Undo ', 'redo', '-', 'Find ', 'replace', '-', 'selectall', 'removeformat'],
['Image', 'flash', 'table', 'rule', 'smilil', 'specialchar ', 'pagebreak'],
['Showbuckets'],
'/',
['Bold ', 'italic', 'underline', 'strikethangout', 'textcolor', 'bgcolor'],
['Orderedlist', 'unorderedlist', '-', 'outdent ', 'indent', 'blockquote ', 'creatediv'],
['Justifyleft', 'justifycenter', 'justifyright', 'justifyfull'],
['Link', 'unlink', 'anchor '],
'/',
['Style', 'fontformat', 'fontname', 'fontsize']
// No comma for the last row.
];

Or change

Fckconfig. toolbarsets ["Basic"] = [

 
['Bold ', 'italic', '-', 'orderedlist', 'unorderedlist', '-', 'link', 'unlink', 'image ', '-', 'about']

];

After setting, add this statement when calling:

$ Ofckeditor-> toolbarset = 'mystyle ';

2. What should I do if garbled characters are displayed when I upload a Chinese name file?

Find the following in the connectors/PHP/commands. php file:
...

3. 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 ));

4. 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.

5. add different styles to the Article. 6. Configure the skin.

The "FCKeditor/Editor/skins/" directory contains default, office2003, silver, and other styles to choose from.

Open/FCKeditor/fckconfig. js; modify->

Fckconfig. skinpath = fckconfig. basepath + 'Skins/default /';

7. You can use the tab key in the editor.

Open/FCKeditor/fckconfig. js; Modify (1 to yes, 0 to no)->

Change fckconfig. tabspaces = 0; To fckconfig. tabspaces = 1;

8. add several common fonts:

Open/FCKeditor/fckconfig. js; modify->

Fckconfig. fontnames = '; _ gb2312; Arial; Comic Sans
MS; Courier New; tahoma; Times New Roman; verdana ';

9. Modify the default font

You can modify the style sheet to meet the requirements. Open/Editor/CSS/fck_editorarea.css and modify the font-size attribute.

10. An error occurred while browsing the server in the Upload File window.

"The server didn't send back a proper XML .....
"
Error message.

Because FCKeditor requires different types of files to be uploaded to different directories, including directories such as file, image, falsh, and media, you can create them first.

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.