What is FCKeditor? What does he do? We will not discuss this today. Today we will go directly to the topic, that is, installing and setting FCKeditor 2.2. You can download the latest FCKeditor 2.2 from the official FCKeditor website.
Like other scripts, the installation of FCKeditor is actually a copy of the source code. Follow the official method to create a folder like FCKeditor under the root directory of the website, and then release the downloaded package to this folder.
After the installation, it is configured and used. I only configure the general use (ASP environment), the source file is simplified, and complex applications do not care about it. Several files need to be modified during configuration. We divide the files by function instead of file, which makes it easier for readers to understand.
1. default language
Open the fckconfig. js file (the same as the FCKeditor folder), change the automatic detection language to not detect, and change the default language to simplified Chinese: the program code FCKConfig. AutoDetectLanguage = false;
FCKConfig. DefaultLanguage = 'zh-cn ';
2. Font list
Open fckconfig. js file, add frequently-used "; _ GB2312" to the font list: program code FCKConfig. fontNames = '; _ GB2312; Arial; Comic Sans MS; Courier New; Tahoma; Times New Roman; Verdana ';
3. File Upload
The file management program of FCKeditor is in the filemanager folder and can be divided into browser and upload. Browsing refers to browsing server files, selecting them, or uploading local files to the server. Uploading refers to quick upload. In the window, click the "Upload" tab to open it, similar to the UBB editor we use, select a local file and upload it.
That is to say, FCKeditor has a file browsing and two files are uploaded. Some of these settings are in one file, while others are in multiple files. It's complicated and there are many changes. Let's talk about it in a few moments.
① Open and close the file browsing and uploading Functions
There are three files related to this switch. One is a JS file and the other is an ASP file. when the former is disabled, no related windows or buttons are displayed on the interface, and the latter is disabled and related functions are unavailable.
The first is the fckconfig. js file. The following content is set to true and false to off.
Upload in file browsing and browsing: the program code fckconfig. linkbrowser = false;
Fckconfig. imagebrowser = false;
Fckconfig. flashbrowser = false;
File quick upload: the program code fckconfig. linkupload = true;
Fckconfig. imageupload = true;
Fckconfig. flashupload = true;
Set two asp files:
Editor \ filemanager \ browser \ Default \ connectors \ ASP \ config. ASP program code configisenabled = false
Indicates that file browsing is disabled.
Editor \ filemanager \ upload \ asp \ config. asp program code ConfigIsEnabled = True
Indicates that files are uploaded and opened quickly.
② File Upload or browsing path settings
Note that FCKeditor does not support virtual directories. All your paths are absolute paths for the root directory of the website, it is not convenient for developers to publish to remote website directories. In this case, the WinXP system can only have one site, and only use virtual directories to represent different websites. After testing locally, you must temporarily change this setting before uploading.
Open the file editor \ filemanager \ browser \ default \ connectors \ asp \ config. asp: program code ConfigUserFilesPath = "/attachments /"
In the quick upload path, open the file editor \ filemanager \ upload \ asp \ config. asp: program code ConfigUserFilesPath = "/attachments /"
My file directory is located at http://www.xxx.com/attachments. If you test the website locally in the virtual directory xxx, set it to: program code ConfigUserFilesPath = "/xxx/attachments /"
③ A source file BUG for Fast File Upload
After the preceding settings are complete, you can smoothly upload files during file browsing and browsing, but you will find that "quick upload" is unavailable. After selecting a local file, click "upload to server" without any response. This is because of a bug in the fckconfig. js file.
Open the fckconfig. js file, replace the fckconfig. quickuploadlanguage with _ quickuploadlanguage, and replace it with three places in total. The former is used without definition, so there is a mistake. The Code intent should be the same as the latter value.
④ Automatic renaming of uploaded file names
FCKeditor does not support Chinese file names, so we need to change the name when saving the file to the server. Because there are two parts to be uploaded, and the files used are different, the two files should be modified at the same time. Let's take a look at the files to be uploaded quickly and open editor \ filemanager \ upload \ ASP \ upload. ASP: Add the following function at the end of the file: the program code public function getnewfilename ()
Dim rannum
Dim dtnow
Dtnow = now ()
Randomize
Rannum = int (90 * RND) + 10
GetNewFileName = year (dtNow) & right ("0" & month (dtNow), 2) & right ("0" & day (dtNow), 2) & right ("0" & hour (dtNow), 2) & right ("0" & minute (dtNow), 2) & right ("0" & second (dtNow ), 2) & ranNum
End Function
We use the year, month, day, hour, minute, and two random numbers as the file name, so that we can identify the File Upload time, and it is not easy to duplicate the name.
The file is still located. Find the program code 'get the uploaded file name.
SFileName = oUploader. File ("NewFile"). Name
Change it to: program code 'get the uploaded file name.
SFileName = GetNewFileName () & "." & split (oUploader. File ("NewFile"). Name, ".") (1)
The above is a fast upload file, while the upload in the file browsing is to change another file (editor \ filemanager \ browser \ default \ connectors \ asp \ commands. asp), the modification method is the same as the above file: Add a function and modify a line of code.
4. Reference The FCKeditor editor in the ASP source program.
First, insert the server-side containing statement: program code at the top of the asp page <! -- # Include file = "FCKeditor/fckeditor. asp" -->
Then add the following code in the form: program code 'defines the variable
Dim oFCKeditor
'Class initialization
Set oFCKeditor = New FCKeditor
'Define the path (default path:/FCKeditor /)
OFCKeditor. BasePath = "FCKeditor /"
'Define toolbar (Default)
OFCKeditor. ToolbarSet = "Basic"
'Define the width (default width: 100%)
OFCKeditor. Width = "100%"
'Defines the height (default Height: 200)
OFCKeditor. Height = 350
'Initial value of the input box
OFCKeditor. Value = "this is the sample text. "
'Create an input box named: content
OFCKeditor. Create "content"
In this way, a hidden input box named content is created in the form, which can be used like other form elements. For example, you can use the following code to obtain the value of the input box: program code Dim content
Content = CheckStr (Request. Form ("content "))
The preceding Code uses CheckStr to check the input data. If the original data contains single quotation marks, an error occurs when updating the database.
This is the settings when I use FCKeditor 2.2. I hope it will be helpful to you.
In addition, it was found that the upload class used by the program was written by a Chinese guy called "NetRube (Network folks)". The copyright statement does not contain a website address, or else you may need to visit this senior user.