Another nice fckeditor. 2.2 Installation, modification and invocation Method _ Web page Editor

Source: Internet
Author: User
Suddenly found oneself Blog FCKeditor can't use, good surprise! Incredibly optimistic about the Pjblog will have no time. Look online and Copy some of the main things. The following are the main elements
FCKeditor's official website: www.fckeditor.com
As with other script class programs, the FCKeditor installation is actually a copy of the source code.
We follow the official method of creating a FCKeditor folder in the root directory of the site,
The downloaded package is then released into the folder.
Configure and streamline the source files for general use only (ASP environment).

1. Default language
Open fckconfig.js file (relative FCKeditor folder, below), change the automatic detection language to not detect, change the default language to Simplified Chinese:
Copy Code code as follows:

Fckconfig.autodetectlanguage = false;
Fckconfig.defaultlanguage = ' ZH-CN ';



2. Font list
Open fckconfig.js file, add the commonly used "XXFarEastFont-Arial" in the Font list _gb2312 ":
Copy Code code as follows:

Fckconfig.fontnames = ' song body; bold; official script; italics _gb2312; Arial; Comic Sans MS; Courier New; Tahoma; Times New Roman; Verdana ';

3, File Upload
FCKeditor file Management program in the FileManager folder, but also divided into browse (browser) and upload (upload) two kinds. Browsing refers to browsing server files and optionally uploading local files to the server; upload refers to fast upload (quickupload), in the window of the "Upload" tab open is, with the UBB editor we use a bit similar, select the local file upload on the line. That is, there is a file browsing in FCKeditor, there are two files uploaded, and some of these settings in a file, some in multiple files. More complex, more changes, we have a few small points to say.

1 open and close the file browsing and uploading function
There are three files with this switch has a relationship, a JS file, two are ASP files, the former closed after the interface does not appear related to the window or button, the latter closed after the relevant features are not available. The first is the Fckconfig.js file, and the following is set to true and false to off.

File browsing and browsing in the upload function:
Copy Code code as follows:

Fckconfig.linkbrowser = false;
Fckconfig.imagebrowser = false;
Fckconfig.flashbrowser = false;

Quick File Upload function:
Copy Code code as follows:

Fckconfig.linkupload = true;
Fckconfig.imageupload = true;
Fckconfig.flashupload = true;

Second, set up two ASP files:
Editor\filemanager\browser\default\connectors\asp\config.asp


Copy Code code as follows:

configisenabled = False


Indicates file browsing shutdown

Editor\filemanager\upload\asp\config.asp


Copy Code code as follows:

configisenabled = True


Indicates file fast upload Open

2 File upload or browse the path set
Note that FCKeditor does not support virtual directories, all of your paths are absolute paths to the root directory of your Web site, which is not easy for developers who use virtual directories for local testing to publish to remote site directories. This is my case, the WinXP system can only be a site, only the virtual directory to represent different sites, in the local test well, before uploading to temporarily change this setting.
File browse path, opening file:
Editor\filemanager\browser\default\connectors\asp\config.asp

Copy Code code as follows:

Configuserfilespath = "/attachments/"



Quick upload Path, open file: editor\filemanager\upload\asp\config.asp


Copy Code code as follows:

Configuserfilespath = "/attachments/"



My file directory is below http://www.xxx.com/attachments/, just follow the above settings.
If you are testing this site locally in virtual directory xxx, you should set it to:
Copy Code code as follows:

Configuserfilespath = "/xxx/attachments/"



3 file Fast upload a source file bug
After the above settings, file browsing and browsing upload can be carried out smoothly, but you will find that "fast upload" can not be used. The phenomenon is that when you select a good local file, click on the "Upload to the Server" button after no response. This is due to a bug in the Fckconfig.js file.
Open fckconfig.js file, place Fckconfig.quickuploadlanguage typeface, replace into _quickuploadlanguage, replace three places altogether. The former is not defined on the use, so the error, according to the code intent should be the same as the value of the latter.

4) Upload file name automatically renamed
FCKeditor does not support Chinese file names, so we want to change the name when the file is saved to the server. Because there are two places to upload, and the file is different, so two files should be changed at the same time, we first look at the fast upload file, open: editor\filemanager\upload\asp\upload.asp, in the end of the file add the following function:

Copy Code code as follows:

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 date of the year and the two-digit random number as the filename, so that both the file upload time can be resolved, nor is it easy to duplicate the name.
And then still this file, find:
Copy Code code as follows:

' Get the uploaded file name.
sFileName = Ouploader.file ("NewFile"). Name


Change it to:
Copy Code code as follows:

' Get the uploaded file name.
sFileName = Getnewfilename () & "." & Split (Ouploader.file ("NewFile"). Name, ".") (1)



It says the files are uploaded quickly, and the file browsing is a change of another file (editor\filemanager\browser\default\connectors\asp\commands.asp), The method is the same as the one above: Add a function and modify one line of code.

4, in the ASP source program reference FCKeditor Editor
First insert the server-side include statement at the top of the ASP page:

Copy Code code as follows:

<!--#include file= "fckeditor/fckeditor.asp"-->


Then add the following code inside the form:
Copy Code code as follows:


' Define variables
Dim Ofckeditor
' Initialization of the class
Set ofckeditor = New FCKeditor
' Define path (default path:/fckeditor/)
Ofckeditor.basepath= "fckeditor/"
' Define the toolbar (default: Defaults)
ofckeditor.toolbarset= "Basic"
' Define width (default width: 100%)
Ofckeditor.width= "100%"
' Define height (default height: 200)
ofckeditor.height=350
' The initial value of the input box
Ofckeditor.value= "This is the sample text. "
' Create an input box named: Content
Ofckeditor.create "Content"


This creates an input box with a hidden name content in the form that can be used like any other form element, such as using the following code to get the value of the input box:

Copy Code code as follows:

Dim Content
Content=checkstr (Request.Form ("content"))


Above, the input data is detected with CHECKSTR, and if the original data contains single quotes or the like, then updating the database will be an error. =====================================
There are some areas of doubt:
1, the file upload path problem Compare the effort, see later version and no improvement.
2, Linkbrowser and Linkupload did not understand what the meaning (up2006-3-20: The original Insert hyperlink, the link to the target file can also be uploaded, and this file format by default only specify not allowed to upload the format. In fact, we can use this function to upload rar or doc and so on format files)

When you insert a hyperlink, you only specify a format that prohibits uploading in the official default configuration, rather than a format that allows uploads like pictures or flash, especially if you see a file that you can upload "any" type. Follow the configuration file:

Copy Code code as follows:

Fckconfig.linkuploaddeniedextensions = ". (php|php3|php5|phtml|asp|aspx|ascx|jsp|cfm|cfc|pl|bat|exe|dll|reg|cgi) $ "; Empty for no one


Except that these are not allowed, the others are allowed.

For the option to remove the Insert form, modify the following section of the Fckconfig.js (note form line):

Copy Code code as follows:

fckconfig.toolbarsets["Default"] = [ 
[' Source ', ' Docprops ', '-', ' Save ', ' newpage ', ' Preview ', '-', ' Templates '], 
[' Cut ', ' Copy ', ' Paste ', ' pastetext ', ' Pasteword ', '-', ' Print ', ' spellcheck '], 
[' Undo ', ' Redo ', '-', ' find ', ' Replace ', '-', ' SelectAll ', ' Removeformat '], 
[' Bold ', ' italic ', ' underline ', ' strikethrough ', '-', ' subscript ', ' superscript '], 
[' orderedlist ', ' unorderedlist ', '-', ' outdent ', ' Indent '], 
[' justifyleft ', ' justifycenter ', ' Justifyright ', ' justifyfull '], 
[' Link ', ' Unlink ', ' Anchor '], 
[' Image ', ' Flash ', ' Table ', ' rule ', ' Smiley ', ' Specialchar ', ' pagebreak ', ' Universalkey '], 
//[' Form ', ' Checkbox ', ' Radio ', ' TextField ', ' Textarea ', ' Select ', ' Button ', ' ImageButton ', ' HiddenField '], 
'/', 
[' Style ', ' Fontformat ', ' FontName ', ' fontsize '], 
[' textcolor ', ' bgcolor '],  '
[' about '] 
] ;

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.