Let's talk about how FCKeditor works in Asp.net. New Features: Image Classification storage, rename

Source: Internet
Author: User

1. Original functions:
A. when uploading an image, fckeditor2.6.6 and fckeditor2.3. net can create a folder named userfiles/image under the default userfiles according to the image [Image], animation [Flash], link [LINK], and so on.
B. renaming is not supported.

2. requirements: however, in many cases, the above functions cannot meet the specific project requirements, for example, there are news publishing pictures and product pictures in the project. all the images uploaded based on the above functions will be under the userfiles/image directory,

There is no way to distinguish between news images and product images.
To meet the above requirements, the FCKeditor Source Code was modified, and the imagesubfoldername and resetimagename attributes were added.

The imagesubfoldername attribute is the name of the image to be classified. [I call it the second-level Directory Name of the image]. The default value is image, that is, it is stored in userfiles/image. note: To be consistent with the original functions. the resetimagename attribute indicates whether the image name is renamed. The default value is false.

3. usage;
. first, add a hidden control on the page where the FCKeditor online editor is placed. You can only view the Code . The Code is as follows:




b. add the following code to the background code on the page where the FCKeditor online editor is placed:
protected string _ imagesubfoldername = string. empty;
protected void page_load (Object sender, eventargs e)
{< br> _ imagesubfoldername = fckeditor1.imagesubfoldername; // The created folder is named after this value.
// other code is followed
.....
}

The Code required for this new function is complete. After an image is uploaded, a folder with hidden control values will be automatically created under the userfiles directory [Create a news folder here]

Note: The red code is the new code to be added.

Download the source code of this example:Http://115.com/file/e6dlr2cb#FCKeditor2.6.6+FCKeditor.Net_2.6.3-New.zip

Cannot download please leave a message or QQ: 122388766
Reprinted please indicate the source: http://www.cnblogs.com/bicabo/archive/2010/06/25/1764960.html

 

1. Download components: (download two zip packages for fckeditor2.6.5.zip and FCKeditor. net2.6.3)
Note:
Fckeditor2.6.3.zip is the latest file and image;
Fckeditor.net.zip is the DLL called by ASP. NET.
2. Copy the FCKeditor directory in fckeditor2.6.3.zip to the website.
3.decompress the fckeditor.net.zip package, find fredck. fckeditorv2.dll in the FCKeditor. net_2.2 \ bin \ DEBUG directory, and add fredck. fckeditorv2.dll to the toolbox.
4. Drag the control to the web page after it is finished:
5. Now we have completed adding. Now we need to set it according to our needs ......
Go to the FCKeditor folder and edit the fckconfig. js file.
6.
Modify
VaR _ filebrowserlanguage = 'asp '; // ASP | aspx | CFM | lasso | Perl | PHP | py
VaR _ quickuploadlanguage = 'asp '; // ASP | aspx | CFM | lasso | PHP
Change
VaR _ filebrowserlanguage = 'aspx '; // ASP | aspx | CFM | lasso | Perl | PHP | py
VaR _ quickuploadlanguage = 'aspx '; // ASP | aspx | CFM | lasso | PHP
7. Configure the Language Pack. English and Traditional Chinese are available. Here we use simplified Chinese.
Modify
Fckconfig. defaultlanguage = 'en ';
Is
Fckconfig. defaultlanguage = 'zh-cn ';
8. Configure the skin. There are default, office2003, silver style, etc. here we can use the default.
Fckconfig. skinpath = fckconfig. basepath + 'Skins/default /';
9. You can use the tab key in the editor. (1 is yes, 0 is no)
Change fckconfig. tabspaces = 0; To fckconfig. tabspaces = 1;
10. add several common font Methods
Modify
Fckconfig. fontnames = 'arial; Comic Sans MS; Courier New; tahoma; Times New Roman; verdana ';
Is
Fckconfig. fontnames = '; _ gb2312; Arial; Comic Sans MS; Courier New; tahoma; Times New Roman; verdana'
11. The basic attribute settings are almost the same. For more settings, refer to the Attribute Table:
Fckconfig. customconfigurationspath = ''; // custom configuration file path and name
Fckconfigfckconfig. editorareacss = fckconfig. basepath + 'css/fck_editorarea.css '; // The style table file in the editing area
Fckconfig. editorareastyles = ''; // the style of the style sheet in the editing area.
Fckconfig. toolbarcombopreviewcss = ''; // preview CSS in the toolbar.
Fckconfig. doctype = ''; // Document Type
Fckconfig. basehref = ''; // The base address of the Relative Link
Fckconfig. fullpage = false; // whether to allow editing of the entire HTML file or only the content between the bodies
Fckconfig. startupshowblocks = false; // determines whether to enable the "display module"
Fckconfig. DEBUG = false; // whether debugging is enabled
Fckconfigfckconfig. skinpath = fckconfig. basepath + 'Skins/default/'; // skin path
Fckconfig. preloadimages =... // pre-installed Image
Fckconfigfckconfig. pluginspath = fckconfig. basepath + 'ins INS/'; // Plug-In Path
Fckconfig. autodetectlanguage = true; // whether to automatically detect the language
Fckconfig. defaultlanguage = 'zh-cn'; // default language
Fckconfig. contentlangdirection = 'ltr'; // default text direction. Optional, "LTR/RTL", that is, left-to-right or right-to-left
Fckconfig. processhtmlentities = true; // process HTML Objects
Fckconfig. includelatinentities = true; // including Latin
Fckconfig. includegreekentities = true; // includes Greek
Fckconfig. processnumericentities = false; // process numeric entities
Fckconfig. additionalnumericentities = ''; // additional numeric entity
Fckconfig. fillemptyblocks = true; // whether to fill an empty Block
Fckconfig. formatsource = true; // whether to automatically format the code when switching to the Code view
Fckconfig. formatoutput = true; // whether to automatically format the code when outputting the content
Fckconfig. formatindentator = ''; // The characters used to indent the code in the source code format
Fckconfig. startupfocus = false; // whether the focus is in the editor when it is enabled, that is, whether the time mark on the page is stuck on FCKeditor
Fckconfig. forcepasteasplaintext = false; // whether to forcibly paste the File Content
Fckconfig. autodetectpastefromword = true; // whether to automatically detect file pasting from word. Only Internet Explorer is supported.
Fckconfig. showdropdialog = true; // whether the drop-down menu is displayed
Fckconfig. forcesimpleampersand = false; // do not convert & into XML entities
Fckconfig. tabspaces = 0; // press the tab key. The default value is zero.
Fckconfig. showborders = true; // merge borders
Fckconfig. sourcepopup = false; // pop-up
Fckconfig. toolbarstartexpanded = true; // start the FCKeditor toolbar to show whether to expand by default.
Fckconfig. toolbarcancollapse = true; // whether to collapse or expand the toolbar
Fckconfig. ignoreemptyparagraphvalue = true; // whether to ignore empty paragraph values
Fckconfig. floatingpanelszindex = 10000; // floating panel Index
Fckconfig. htmlencodeoutput = false; // whether to output HTML Encoding
Fckconfig. templatereplaceall = true; // whether to replace all templates
Fckconfig. toolbarlocation = 'in'; // toolbar location,
Fckconfig. customconfigurationspath = ''; // custom configuration file path and name
Fckconfigfckconfig. editorareacss = fckconfig. basepath + 'css/fck_editorarea.css '; // The style table file in the editing area
Fckconfig. basehref = ''; // The base address of the Relative Link
Fckconfig. DEBUG = true/false; // whether to enable the debugging function. When you call fckdebug. Output (), the content is output in the debugging window.
Fckconfigfckconfig. skinpath = fckconfig. basepath + 'Skins/default/'; // set skin
Fckconfig. autodetectlanguage = true/false; // whether to automatically detect the language
Fckconfig. defaultlanguage = 'zh-cn'; // set the default language
Fckconfig. contentlangdirection = 'ltr/rtr'; // default text direction, left for LTr, right for RTR
Fckconfig. fillemptyblocks = true/false; // this function can be used to replace empty block-level elements with spaces.
Fckconfig. formatsource = true/false; // whether to automatically format the code when switching to the Code view
Fckconfig. formatoutput = true/false; // whether the code is automatically formatted when the content is output
Fckconfig. formatindentator = ""; // The characters used to indent the code in "Source code format"
Fckconfig. geckousespan = true/false; // whether to allow the span flag to replace the B, I, u flag
Fckconfig. startupfocus = true/false; // whether to focus to the editor when enabled
Fckconfig. forcepasteasplaintext = true/false; // force the paste to plain text
Fckconfig. forcesimpleampersand = true/false; // do not convert & into XML entities
Fckconfig. tabspaces = 0/1; // whether the tab is valid
Fckconfig. tabspaces = 4; // number of spaces generated by the tab key
Fckconfig. showborders = true/false; // whether to merge borders
Fckconfig. toolbarstartexpanded = true/false; // whether to expand the toolbar when loading the page. It appears only when you click "Expand toolbar ".
Fckconfig. toolbarcancollapse = true/false; // whether to show and collapse the toolbar
Fckconfig. toolbarsets = object; // The toolbar of the editor, which can be customized and deleted. For details, refer to the existing toolbar.
Fckconfig. entermode = 'P'; // press enter in the editor to generate the file in the Code. Optional values: p | Div | br
Fckconfig. shiftentermode = 'br '; // SHIFT + press enter in the editor, which is generated in the Code. Optional values: p | Div | br
Fckconfig. contextmenu = string array; // context menu content
Fckconfig. fontcolors = ""; // text color list
Fckconfig. fontnames = ""; // font list
Fckconfig. fontsizes = ""; // font size list
Fckconfig. fontformats = ""; // text format list
Fckconfig. stylesxmlpath = ""; // location of the XML file in the CSS style list
Fckconfig. templatesxmlpath = ""; // XML file location of the template
Fckconfig. spellchecker = "iespell/spellerpages"; // spell checker
Fckconfig. iespelldownloadurl = ""; // download the spelling checker URL
Fckconfigfckconfig. smileypath = fckconfig. basepath + 'images/smiley/MSN/'; // storage path of the emoticon File
Fckconfig. smileyimages = ''; // list of emoticon file names. For details, refer to the default settings.
Fckconfig. smileycolumns = 8; // Number of columns displayed in the emoticons window
Fckconfig. smiley1_wwidth = 320; // display width of the emoticon window. This window will be adjusted due to changes in the emoticon file.
Fckconfig. smiley1_wheight = 240; // The height of the emoticons window. This window will be adjusted due to changes in the emoticons file.
Fckconfig. fullpage = true/false; // whether to allow editing of the entire HTML file or only the content between the bodies


Upload settings

VaR _ filebrowserlanguage = 'php'; // ASP | aspx | CFM | lasso | Perl | PHP | py
VaR _ quickuploadlanguage = 'php'; // ASP | aspx | CFM | lasso | PHP [/Code]
// The first is the language used by the file browser, and the second is the language used for fast upload.
Fckconfig. linkuploadallowedextensions = ""; // empty for all
Fckconfig. linkuploaddeniedextensions = ". (PhP | php3 | PhP5 | phtml | ASP | aspx | ascx | JSP | CFM | CFC | PL | bat | exe | DLL | Reg | CGI) $"
// This is a list of two file types that allow and reject upload.
Fckconfig. imagebrowser = false; Whether to enable the Server File browsing function in the image inserting Function
Fckconfigfckconfig. imagebrowserurl = fckconfig. basepath + 'filemanager/Browser/default/browser.html? Type = imageconnector = connectors/'+ _ filebrowserlanguage +'/connector. '+ _ filebrowserextension;
Type = image indicates that the file type is image, which causes the file browser to locate the File Upload path/image/folder.
Fckconfig. flashbrowser = false; Whether to enable Server File browsing in the Flash insertion function
Fckconfig. linkupload = false; Whether to enable the quick upload function of the inserted Link
Fckconfig. imageupload = false; Whether to enable the image quick upload function
Fckconfig. flashupload = false; Whether to enable the flash upload function


Server File Settings

File browser settings:
FCKeditor \ editor \ filemanager \ connectors \ ASP \ config. asp

Configisenabled = true determines whether to enable the file browser. This is executed on the server.
Configuserfilespath = "/test/upload/" File Upload path (relative)
Configallowedextensions. Add "file ",""
Configdeniedextensions. add "file ", "php | PhP2 | php3 | PhP4 | PhP5 | phtml | pwml | Inc | ASP | aspx | ascx | JSP | CFM | CFC | PL | bat | exe | com | DLL | vbs | JS | Reg | cgi"
Configallowedextensions. Add "image", "JPG | GIF | JPEG | PNG | BMP"
Configdeniedextensions. Add "image ",""
Configallowedextensions. Add "Flash", "SWF | FLA"
Configdeniedextensions. Add "Flash ",""
Configallowedextensions. add "Media", "SWF | FLA | JPG | GIF | JPEG | PNG | Avi | MPG | MPEG | MP (1-4) | WMA | WMV | WAV | mid | MIDI | RMI | RM | Ram | rmvb | mov | QT"
Configdeniedextensions. Add "Media ",""
Four different filetypes correspond to the insert link of the front-end Editor, insert an image, insert Flash, and insert media.


12. Configure webconfig and add it on the <etettings> node as follows:
<Deleetask>
<Add key = "FCKeditor: basepath" value = "/FCKeditor/"/>
<Add key = "FCKeditor: userfilespath" value = "/Name of the directory where you want to store the image/"/>
</Appsettings>
Basepath is the path where FCKeditor is located. FCKeditor can be written directly in the website directory. If your website has more layers, make appropriate adjustments. Userfilespath is the directory of all uploaded files.
13. ASPX page:
<% @ Page Language = "C #" autoeventwireup = "true" codefile = "default. aspx. cs" inherits = "_ default" validaterequest = "false" %>
We need to add the parameter validaterequest = false. Otherwise, an error is returned when HTML code is submitted.
14. Delete unnecessary files:
Go to the FCKeditor folder and delete all files and folders starting with "_". These are examples. Only the Editor folder and fckconfig are retained. JS, FCKeditor. JS, fckstyles. XML, fcktemplates. XML is enough;
Go to the Editor folder and delete the "_ source" folder, which also contains the source file;
Go back to the upper-level directory and enter the filemanager folder. There are two folders: browser and upload. Go to browser \ Default \ connectors. Only the aspx folder is retained, and the rest are deleted. The mcpuk directory can also be deleted. The same is true for upload, and only the aspx folder is retained;
Return to the editor and enter the images folder. The smiley folder contains emoticon icons, including MSN and fun. If you want to use your own emoticon icons, you can delete them; if you want to use the emojis here, do not delete them;
Lang contains a Language Pack. If only simplified Chinese characters are used, only fck1_agemanager is retained. JS, zh-cn.js two files on the line, it is recommended to keep en. JS (English), Zh. JS (Traditional Chinese) files, fck1_agemanager. JS is a language configuration file. With it, it can be used with fckconfig. JS settings are paired, corresponding to the corresponding language file, must be retained!
Exit the Lang folder and enter the skins folder. If you want to use the default FCKeditor milk yellow, delete the other two folders except the default folder. If you want to use other folders, it depends on your preferences.
15. Usage: fckeditor1.value is his value ......

16. settings of the config. ascx file in the aspx directory (FCKeditor is in ASP. . Net)
Private bool checkauthentication ()
{
// Warning: do not simply return "true". By doing so, you are allowing
// "Anyone" to upload and list the files in your server. You must implement
// Some kind of session validation here. Even something very simple...
//
// Return (session ["isauthorized"]! = NULL & (bool) session ["isauthorized"] = true );
//
//... Where session ["isauthorized"] is set to "true" as soon as
// User logs in your system.
Return true; // The default value is false.
}

This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/nileel/archive/2009/09/25/4593110.aspx

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.