On-line editor FCKeditor 2.0PHP Environment trial in small memory
First, Introduction
November 30, 2004 launched the FCKeditor 2.0 RC1 version, according to its official website said: This is the FCKeditor 2.0 version of the first stable version. You can now consider the formal use of it. The background languages currently supported are ASP, ASP.net, PHP, and ColdFusion.
After a simple trial, the author found that the online Editor version 2.0 does have a lot of improvement over the 1.6 edition. The first is that the FCKeditor file structure is clearer and can be more easily deployed in its own system. The other 2.0 version finally supported the Firefox 1.0 browser, which will win more users for FCKeditor. Nonsense not to say, let us quickly to learn how to install, configure FCKeditor 2.0 bar.
Ii. Installation and Example
First go to http://sourceforge.net/projects/fckeditor/to download FCKeditor 2.0 RC1 (554K) and unzip it to your Web site directory, and change the folder name to FCKeditor. For example, if your site is under the Shaof directory, create 3 subdirectories in this directory:
N FCKeditor: Store downloaded from the website of the FCKeditor online editor n upimages: for storing uploaded pictures N admin: The inside Store test page
The structure of the website is as follows:/fckeditor//fckeditor directory
/userfiles//Upload file directory
/admin
test.php//Submit data page
testsubmit.php//Display data page
Into the FCKeditor directory, open the _samples directory, which contains a variety of programming languages call FCKeditor Sample Program page, where the PHP directory contains some use PHP to invoke the example of FCKeditor, you can see, To understand the Fckeditord invocation method, here is a test.php program that I have abbreviated, placed in the admin directory under the root directory of the site:
if ($_post["ADD"]) {
$Content =$_post[' Editordefault '];
Echo $Content;
Variable $content is what we edit in the Fckeditord, which can be saved to the database, the code omitted.
} -->Here we look at the call FCKeditor function, the 2.0 version of the call and 1.6 version of the change is not much, if you have previously installed FCKeditor 1.6, then only need to modify a small number of code upgrades to 2.0. FCKeditor (instancename[, width, height, toolbarset, value)
Reference value |
Meaning |
InstanceName |
The unique name that is required to instantiate the editor |
Width |
The width of the editor, in pixels or as a percentage (optionally, by default: 100%) |
Height |
The height of the editor, in pixels or as a percentage (optionally, by default: 200) |
ToolbarSet |
The name of the toolbar (optionally, default: defaults) |
Value |
Content (HTML) initial value of the editor (optional) |
OK, let's use this function to customize the FCKeditor. $oFCKeditor = new FCKeditor (' FCKeditor1 ');
$oFCKeditor->basepath = '.. /fckeditor/';
$oFCKeditor->toolbarset = ' Default ';
$oFCKeditor->instancename = ' Editordefault ';
$oFCKeditor->width = ' 100% ';
$oFCKeditor->height = ' 400 ';
$oFCKeditor->create ();
Third, the configurationOnline Editor
The configuration file for FCKeditor 2.0 is fckeditor\fckconfig.js, and several important configuration items are as follows:
1, the toolbar settings
By default, FCKeditor will invoke the following toolbar button, you can add or subtract according to your needs. Note that the 2.0 version and the 1.6 version of the button are not exactly the same, some buttons and deleted or renamed.
//##
# # Toolbar Buttons Sets
//##
fckconfig.toolbarsets["Default" = [
[' Source ', '-', ' Save ', ' newpage ', ' Preview '],
[' Cut ', ' Copy ', ' Paste ', ' pastetext ', ' Pasteword ', '-', ' Print '],
[' Undo ', ' Redo ', '-', ' find ', ' Replace ', '-', ' selectall ', ' Removeformat '],
[' Bold ', ' italic ', ' underline ', ' strikethrough ', '-', ' subscript ', ' superscript '],
[' Orderedlist ', ' unorderedlist ', '-', ' outdent ', ' Indent '],
[' Justifyleft ', ' justifycenter ', ' justifyright ', ' justifyfull '],
[' Link ', ' Unlink '],
[' Image ', ' Table ', ' rule ', ' Specialchar ', ' Smiley '],
[' Style ', ' Fontformat ', ' fontname ', ' fontsize '],
[' TextColor ', ' bgcolor '],
[' About ']
] ;
2, Simplified Chinese set
Edit Edit/lang/fcklanguagemanager.js
The following statement
Fcklanguagemanager.availablelanguages =
{
' ar ': ' Arabic ',
' BS ': ' Bosnian ',
' Ca ': ' Catalan ',
' En ': ' 中文版 ',
' es ': ' Spanish ',
' et ': ' Estonian ',
' fi ': ' Finnish ',
' FR ': ' French ',
' gr ': ' Greek ',
' He ': ' Hebrew ',
' HR ': ' Croatian ',
' It ': ' Italian ',
' ko ': ' Korean ',
' LT ': ' Lithuanian ',
' No ': ' Norwegian ',
' PL ': ' Polish ',
' SR ': ' Serbian (Cyrillic) ',
' Sr-latn ': ' Serbian (Latin) ',
' SV ': ' Swedish '
}
Add a line of ' ZH-CN ': ' Chinese ' to become
Fcklanguagemanager.availablelanguages =
{
' ar ': ' Arabic ',
' BS ': ' Bosnian ',
' Ca ': ' Catalan ',
' En ': ' 中文版 ',
' es ': ' Spanish ',
' et ': ' Estonian ',
' fi ': ' Finnish ',
' FR ': ' French ',
' gr ': ' Greek ',
' He ': ' Hebrew ',
' HR ': ' Croatian ',
' It ': ' Italian ',
' ko ': ' Korean ',
' LT ': ' Lithuanian ',
' No ': ' Norwegian ',
' PL ': ' Polish ',
' SR ': ' Serbian (Cyrillic) ',
' Sr-latn ': ' Serbian (Latin) ',
' SV ': ' Swedish ',
' ZH-CN ': ' Chinese '
}
And then here http://www.shaof.com/download/zh-cn.js download the Chinese good zh-cn.js saved to the Editor/lang directory.
iv. Setup File upload
The FCKeditor 2.0 online editor uses a technique called "Connector" (a connector) to browse and upload files. The following illustration shows the workflow flowchart for file browsing.
As you can see from the diagram, when a client sends a request for a file operation to the server, connector responds to the request, performing actions on the server's filesystem, such as browsing for files and folders, and creating operations. Finally, the results are answered in XML format to the client. Specific technical details You can read FCKeditor instructions guide.
Implementation to the application, first we have to choose a background language to implement this function, here we take PHP as an example to illustrate.
1, modify the configuration file Fckeditor\fckconfig.js in the two paragraph content
Link Browsing
Fckconfig.linkbrowser = true;
Fckconfig.linkbrowserurl = Fckconfig.basepath + "filemanager/browser/default/browser.html?" Connector=connectors/php/connector.php ";
Fckconfig.linkbrowserwindowwidth = screen.width * 0.7; 70%
Fckconfig.linkbrowserwindowheight = screen.height * 0.7; 70%
Image Browsing
Fckconfig.imagebrowser = true;
Fckconfig.imagebrowserurl = Fckconfig.basepath + "filemanager/browser/default/browser.html?" Type=image&connector=connectors/php/connector.php ";
Fckconfig.imagebrowserwindowwidth = screen.width * 0.7; 70%;
Fckconfig.imagebrowserwindowheight = screen.height * 0.7; 70%;
2, modify the configuration file
fckeditor\editor\filemanager\browser\default\connectors\php\connector.php Get the "userfiles" path. $GLOBALS ["userfilespath"] = '/userfiles/'; |
Userfiles for the file upload path, and the example given at the beginning of this article corresponds to, we can modify their own.
OK, only need two steps to complete the file upload configuration work, really simple ah. Later we upload the files through the FCKeditor will be saved in the Userfiles directory of the site.
v. End
finally you can save space by removing the _docs and _samples two directories in the FCKeditor directory. This article is the author has written a previous article called "Online editor FCKeditor in PHP use Method" (1.6 version) Article upgrade version, the article if there is something wrong, but also please correct me.
Another, the problem encountered
1, picture file upload path problem
Install my article inside the settings, upload path set to userfiles/, but upload picture files, FCKeditor automatically upload files to Userfiles/im The age directory, since the creation of a claim to create an image directory, is very unpleasant. The reason is unknown.