1 | <!--
|
---|
2 | * FCKeditor - The text editor for internet
|
---|
3 | * Copyright (C) 2003-2005 Frederico Caldeira Knabben
|
---|
4 | *
|
---|
5 | * Licensed under the terms of the GNU Lesser General Public License:
|
---|
6 | * http://www.opensource.org/licenses/lgpl-license.php
|
---|
7 | *
|
---|
8 | * For further information visit:
|
---|
9 | * http://www.fckeditor.net/
|
---|
10 | *
|
---|
11 | * "Support Open Source software. What about a donation today?"
|
---|
12 | *
|
---|
13 | * File Name: fckeditor.asp
|
---|
14 | * This is the integration file for ASP.
|
---|
15 | *
|
---|
16 | * It defines the FCKeditor class that can be used to create editor
|
---|
17 | * instances in ASP pages on server side.
|
---|
18 | *
|
---|
19 | * File Authors:
|
---|
20 | * Frederico Caldeira Knabben (fredck@fckeditor.net)
|
---|
21 | -->
|
---|
22 | <%
|
---|
23 | function FCKeditor(instanceName, width, height, toolbarSet, value)
|
---|
24 | {
|
---|
25 | // ASP Constructor (by Trent Jones<trenton.jones@gmail.com>)
|
---|
26 | // Author: Trent Jones
|
---|
27 | // Date: 17 May 2006
|
---|
28 | // Version: 1.0.0
|
---|
29 |
|
---|
30 | var SELF = "FCKeditor";
|
---|
31 | var VERSION = "1.0.0";
|
---|
32 |
|
---|
33 | this.BasePath = "/fckeditor/";
|
---|
34 | this.InstanceName = instanceName || "";
|
---|
35 | this.Width = width || "100%";
|
---|
36 | this.Height = height || "200";
|
---|
37 | this.ToolbarSet = toolbarSet || "Default";
|
---|
38 | this.Value = value || "";
|
---|
39 |
|
---|
40 | this.Config = new Object();//Server.CreateObject("Scripting.Dictionary");
|
---|
41 | }
|
---|
42 |
|
---|
43 | FCKeditor.prototype.CreateFCKeditor = function(instanceName, width, height)
|
---|
44 | {
|
---|
45 | this.Width = width;
|
---|
46 | this.Height = height;
|
---|
47 | return this.Create(instanceName);
|
---|
48 | }
|
---|
49 |
|
---|
50 | FCKeditor.prototype.Create = function(instanceName)
|
---|
51 | {
|
---|
52 | var text = "";
|
---|
53 | text += "<div>";
|
---|
54 |
|
---|
55 | if (this.IsCompatible())
|
---|
56 | {
|
---|
57 | var sFile;
|
---|
58 | if (Request.QueryString( "fcksource" ) == "true")
|
---|
59 | sFile = "fckeditor.original.html"
|
---|
60 | else
|
---|
61 | sFile = "fckeditor.html"
|
---|
62 |
|
---|
63 | var sLink
|
---|
64 | sLink = this.BasePath + "/editor/" + sFile + "?InstanceName=" + instanceName;
|
---|
65 |
|
---|
66 | if (this.ToolbarSet != "")
|
---|
67 | sLink = sLink + "&Toolbar=" + this.ToolbarSet;
|
---|
68 |
|
---|
69 | // Render the linked hidden field.
|
---|
70 | text += "<input type=\"hidden\" id=\"" + instanceName + "\" name=\"" + instanceName + "\" value=\"" + Server.HTMLEncode( this.Value ) + "\" style=\"display:none\" />";
|
---|
71 |
|
---|
72 | // Render the configurations hidden field.
|
---|
73 | text += "<input type=\"hidden\" id=\"" + instanceName + "___Config\" value=\"" + this.GetConfigFieldString() + "\" style=\"display:none\" />";
|
---|
74 |
|
---|
75 | // Render the editor IFRAME.
|
---|
76 | text += "<iframe id=\"" + instanceName + "___Frame\" src=\"" + sLink + "\" width=\"" + this.Width + "\" height=\"" + this.Height + "\" frameborder=\"no\" scrolling=\"no\"></iframe>";
|
---|
77 | }
|
---|
78 | else
|
---|
79 | {
|
---|
80 | var sWidthCSS, sHeightCSS;
|
---|
81 |
|
---|
82 | if (this.Width.indexOf("%") > 0)
|
---|
83 | sWidthCSS = this.Width;
|
---|
84 | else
|
---|
85 | sWidthCSS = this.Width + "px"
|
---|
86 |
|
---|
87 | if ( this.Height.indexOf("%") > 0 )
|
---|
88 | sHeightCSS = this.Height
|
---|
89 | else
|
---|
90 | sHeightCSS = this.Height + "px"
|
---|
91 |
|
---|
92 | text += "<textarea name=\"" + instanceName + "\" rows=\"4\" cols=\"40\" style=\"width: " + sWidthCSS + "; height: " + sHeightCSS + "\">" + Server.HTMLEncode( this.Value ) + "</textarea>";
|
---|
93 | }
|
---|
94 |
|
---|
95 | text += "</div>";
|
---|
96 | return text;
|
---|
97 | }
|
---|
98 |
|
---|
99 | FCKeditor.prototype.IsCompatible = function()
|
---|
100 | {
|
---|
101 | var sAgent
|
---|
102 | sAgent = "" + Request.ServerVariables("HTTP_USER_AGENT");
|
---|
103 | var iVersion;
|
---|
104 | var isCompatible;
|
---|
105 |
|
---|
106 | if (sAgent.indexOf("MSIE") > -1 && sAgent.indexOf("mac") <= 0 && sAgent.indexOf("Opera") <= 0 )
|
---|
107 | {
|
---|
108 | iVersion = 1*( this.ToNumericFormat( sAgent.substring((sAgent.indexOf("MSIE") + 5), (sAgent.indexOf("MSIE") + 8)) ) );
|
---|
109 | isCompatible = ( iVersion >= 5.5 )
|
---|
110 | }
|
---|
111 | else if (sAgent.indexOf("Gecko/") > 0)
|
---|
112 | {
|
---|
113 | iVersion = 1*( sAgent.substring((sAgent.indexOf("Gecko/") + 6), (sAgent.indexOf("Gecko/") + 14)) )
|
---|
114 | isCompatible = ( iVersion >= 20030210 )
|
---|
115 | }
|
---|
116 | else
|
---|
117 | {
|
---|
118 | IsCompatible = false;
|
---|
119 | }
|
---|
120 | return isCompatible;
|
---|
121 | }
|
---|
122 |
|
---|
123 | // By Agrotic
|
---|
124 | // On ASP, when converting string to numbers, the number decimal separator is localized
|
---|
125 | // so 5.5 will not work on systems were the separator is "," and vice versa.
|
---|
126 | FCKeditor.prototype.ToNumericFormat = function( numberStr )
|
---|
127 | {
|
---|
128 | if (!isNaN("5.5"))
|
---|
129 | numberStr = numberStr.replace(",", ".");
|
---|
130 | else
|
---|
131 | numberStr = numberStr.replace(".", ",");
|
---|
132 | return numberStr;
|
---|
133 | }
|
---|
134 |
|
---|
135 | FCKeditor.prototype.GetConfigFieldString = function()
|
---|
136 | {
|
---|
137 | var sParams = "";
|
---|
138 |
|
---|
139 | var bFirst;
|
---|
140 | bFirst = true;
|
---|
141 |
|
---|
142 | var sKey;
|
---|
143 | for (sKey in this.Config)
|
---|
144 | {
|
---|
145 | if (bFirst == false)
|
---|
146 | sParams += "&"
|
---|
147 | else
|
---|
148 | bFirst = false;
|
---|
149 | sParams += this.EncodeConfig( sKey ) + "=" + this.EncodeConfig( this.Config[sKey] );
|
---|
150 | }
|
---|
151 | return sParams;
|
---|
152 | }
|
---|
153 |
|
---|
154 | FCKeditor.prototype.EncodeConfig = function(valueToEncode)
|
---|
155 | {
|
---|
156 | valueToEncode += "";
|
---|
157 | valueToEncode = valueToEncode.replace("&", "%26" );
|
---|
158 | valueToEncode = valueToEncode.replace("=", "%3D" )
|
---|
159 | valueToEncode = valueToEncode.replace("\"\"", "%22" )
|
---|
160 | return valueToEncode;
|
---|
161 | }
|
---|
162 | %> |
---|