1 | <!--
|
---|
2 | * FCKeditor - The text editor for internet
|
---|
3 | * Copyright (C) 2003-2006 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 | Class FCKeditor
|
---|
24 |
|
---|
25 | private sBasePath
|
---|
26 | private sInstanceName
|
---|
27 | private sWidth
|
---|
28 | private sHeight
|
---|
29 | private sToolbarSet
|
---|
30 | private sValue
|
---|
31 |
|
---|
32 | private oConfig
|
---|
33 |
|
---|
34 | Private Sub Class_Initialize()
|
---|
35 | sBasePath = "/fckeditor/"
|
---|
36 | sWidth = "100%"
|
---|
37 | sHeight = "200"
|
---|
38 | sToolbarSet = "Default"
|
---|
39 | sValue = ""
|
---|
40 |
|
---|
41 | Set oConfig = CreateObject("Scripting.Dictionary")
|
---|
42 | End Sub
|
---|
43 |
|
---|
44 | Public Property Let BasePath( basePathValue )
|
---|
45 | sBasePath = basePathValue
|
---|
46 | End Property
|
---|
47 |
|
---|
48 | Public Property Let InstanceName( instanceNameValue )
|
---|
49 | sInstanceName = instanceNameValue
|
---|
50 | End Property
|
---|
51 |
|
---|
52 | Public Property Let Width( widthValue )
|
---|
53 | sWidth = widthValue
|
---|
54 | End Property
|
---|
55 |
|
---|
56 | Public Property Let Height( heightValue )
|
---|
57 | sHeight = heightValue
|
---|
58 | End Property
|
---|
59 |
|
---|
60 | Public Property Let ToolbarSet( toolbarSetValue )
|
---|
61 | sToolbarSet = toolbarSetValue
|
---|
62 | End Property
|
---|
63 |
|
---|
64 | Public Property Let Value( newValue )
|
---|
65 | If ( IsNull( newValue ) OR IsEmpty( newValue ) ) Then
|
---|
66 | sValue = ""
|
---|
67 | Else
|
---|
68 | sValue = newValue
|
---|
69 | End If
|
---|
70 | End Property
|
---|
71 |
|
---|
72 | Public Property Let Config( configKey, configValue )
|
---|
73 | oConfig.Add configKey, configValue
|
---|
74 | End Property
|
---|
75 |
|
---|
76 | Public Function Create( instanceName )
|
---|
77 |
|
---|
78 | Response.Write "<div>"
|
---|
79 |
|
---|
80 | If IsCompatible() Then
|
---|
81 |
|
---|
82 | Dim sFile
|
---|
83 | If Request.QueryString( "fcksource" ) = "true" Then
|
---|
84 | sFile = "fckeditor.original.html"
|
---|
85 | Else
|
---|
86 | sFile = "fckeditor.html"
|
---|
87 | End If
|
---|
88 |
|
---|
89 | Dim sLink
|
---|
90 | sLink = sBasePath & "editor/" & sFile & "?InstanceName=" + instanceName
|
---|
91 |
|
---|
92 | If (sToolbarSet & "") <> "" Then
|
---|
93 | sLink = sLink + "&Toolbar=" & sToolbarSet
|
---|
94 | End If
|
---|
95 |
|
---|
96 | ' Render the linked hidden field.
|
---|
97 | Response.Write "<input type=""hidden"" id=""" & instanceName & """ name=""" & instanceName & """ value=""" & Server.HTMLEncode( sValue ) & """ style=""display:none"" />"
|
---|
98 |
|
---|
99 | ' Render the configurations hidden field.
|
---|
100 | Response.Write "<input type=""hidden"" id=""" & instanceName & "___Config"" value=""" & GetConfigFieldString() & """ style=""display:none"" />"
|
---|
101 |
|
---|
102 | ' Render the editor IFRAME.
|
---|
103 | Response.Write "<iframe id=""" & instanceName & "___Frame"" src=""" & sLink & """ width=""" & sWidth & """ height=""" & sHeight & """ frameborder=""0"" scrolling=""no""></iframe>"
|
---|
104 |
|
---|
105 | Else
|
---|
106 |
|
---|
107 | Dim sWidthCSS, sHeightCSS
|
---|
108 |
|
---|
109 | If InStr( sWidth, "%" ) > 0 Then
|
---|
110 | sWidthCSS = sWidth
|
---|
111 | Else
|
---|
112 | sWidthCSS = sWidth & "px"
|
---|
113 | End If
|
---|
114 |
|
---|
115 | If InStr( sHeight, "%" ) > 0 Then
|
---|
116 | sHeightCSS = sHeight
|
---|
117 | Else
|
---|
118 | sHeightCSS = sHeight & "px"
|
---|
119 | End If
|
---|
120 |
|
---|
121 | Response.Write "<textarea name=""" & instanceName & """ rows=""4"" cols=""40"" style=""width: " & sWidthCSS & "; height: " & sHeightCSS & """>" & Server.HTMLEncode( sValue ) & "</textarea>"
|
---|
122 |
|
---|
123 | End If
|
---|
124 |
|
---|
125 | Response.Write "</div>"
|
---|
126 |
|
---|
127 | End Function
|
---|
128 |
|
---|
129 | Private Function IsCompatible()
|
---|
130 |
|
---|
131 | Dim sAgent
|
---|
132 | sAgent = Request.ServerVariables("HTTP_USER_AGENT")
|
---|
133 |
|
---|
134 | Dim iVersion
|
---|
135 |
|
---|
136 | If InStr(sAgent, "MSIE") > 0 AND InStr(sAgent, "mac") <= 0 AND InStr(sAgent, "Opera") <= 0 Then
|
---|
137 | iVersion = CInt( ToNumericFormat( Mid(sAgent, InStr(sAgent, "MSIE") + 5, 3) ) )
|
---|
138 | IsCompatible = ( iVersion >= 5.5 )
|
---|
139 | ElseIf InStr(sAgent, "Gecko/") > 0 Then
|
---|
140 | iVersion = CLng( Mid( sAgent, InStr( sAgent, "Gecko/" ) + 6, 8 ) )
|
---|
141 | IsCompatible = ( iVersion >= 20030210 )
|
---|
142 | Else
|
---|
143 | IsCompatible = False
|
---|
144 | End If
|
---|
145 |
|
---|
146 | End Function
|
---|
147 |
|
---|
148 | ' By Agrotic
|
---|
149 | ' On ASP, when converting string to numbers, the number decimal separator is localized
|
---|
150 | ' so 5.5 will not work on systems were the separator is "," and vice versa.
|
---|
151 | Private Function ToNumericFormat( numberStr )
|
---|
152 |
|
---|
153 | If IsNumeric( "5.5" ) Then
|
---|
154 | ToNumericFormat = Replace( numberStr, ",", ".")
|
---|
155 | Else
|
---|
156 | ToNumericFormat = Replace( numberStr, ".", ",")
|
---|
157 | End If
|
---|
158 |
|
---|
159 | End Function
|
---|
160 |
|
---|
161 | Private Function GetConfigFieldString()
|
---|
162 |
|
---|
163 | Dim sParams
|
---|
164 |
|
---|
165 | Dim bFirst
|
---|
166 | bFirst = True
|
---|
167 |
|
---|
168 | Dim sKey
|
---|
169 | For Each sKey in oConfig
|
---|
170 |
|
---|
171 | If bFirst = False Then
|
---|
172 | sParams = sParams & "&"
|
---|
173 | Else
|
---|
174 | bFirst = False
|
---|
175 | End If
|
---|
176 |
|
---|
177 | sParams = sParams & EncodeConfig( sKey ) & "=" & EncodeConfig( oConfig(sKey) )
|
---|
178 |
|
---|
179 | Next
|
---|
180 |
|
---|
181 | GetConfigFieldString = sParams
|
---|
182 |
|
---|
183 | End Function
|
---|
184 |
|
---|
185 | Private Function EncodeConfig( valueToEncode )
|
---|
186 | EncodeConfig = Replace( valueToEncode, "&", "%26" )
|
---|
187 | EncodeConfig = Replace( EncodeConfig , "=", "%3D" )
|
---|
188 | EncodeConfig = Replace( EncodeConfig , """", "%22" )
|
---|
189 | End Function
|
---|
190 |
|
---|
191 | End Class
|
---|
192 | %> |
---|