2
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
3
* Copyright (C) 2003-2009 Frederico Caldeira Knabben
7
* Licensed under the terms of any of the following licenses at your
10
* - GNU General Public License Version 2 or later (the "GPL")
11
* http://www.gnu.org/licenses/gpl.html
13
* - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
14
* http://www.gnu.org/licenses/lgpl.html
16
* - Mozilla Public License Version 1.1 or later (the "MPL")
17
* http://www.mozilla.org/MPL/MPL-1.1.html
21
* This is the integration file for ASP.
23
* It defines the FCKeditor class that can be used to create editor
24
* instances in ASP pages on server side.
38
Private Sub Class_Initialize()
39
sBasePath = "/fckeditor/"
42
sToolbarSet = "Default"
45
Set oConfig = CreateObject("Scripting.Dictionary")
48
Public Property Let BasePath( basePathValue )
49
sBasePath = basePathValue
52
Public Property Let InstanceName( instanceNameValue )
53
sInstanceName = instanceNameValue
56
Public Property Let Width( widthValue )
60
Public Property Let Height( heightValue )
64
Public Property Let ToolbarSet( toolbarSetValue )
65
sToolbarSet = toolbarSetValue
68
Public Property Let Value( newValue )
69
If ( IsNull( newValue ) OR IsEmpty( newValue ) ) Then
76
Public Property Let Config( configKey, configValue )
77
oConfig.Add configKey, configValue
80
' Generates the instace of the editor in the HTML output of the page.
81
Public Sub Create( instanceName )
82
response.write CreateHtml( instanceName )
85
' Returns the html code that must be used to generate an instance of FCKeditor.
86
Public Function CreateHtml( instanceName )
89
If IsCompatible() Then
92
If Request.QueryString( "fcksource" ) = "true" Then
93
sFile = "fckeditor.original.html"
95
sFile = "fckeditor.html"
98
sLink = sBasePath & "editor/" & sFile & "?InstanceName=" + instanceName
100
If (sToolbarSet & "") <> "" Then
101
sLink = sLink + "&Toolbar=" & sToolbarSet
105
' Render the linked hidden field.
106
html = html & "<input type=""hidden"" id=""" & instanceName & """ name=""" & instanceName & """ value=""" & Server.HTMLEncode( sValue ) & """ style=""display:none"" />"
108
' Render the configurations hidden field.
109
html = html & "<input type=""hidden"" id=""" & instanceName & "___Config"" value=""" & GetConfigFieldString() & """ style=""display:none"" />"
111
' Render the editor IFRAME.
112
html = html & "<iframe id=""" & instanceName & "___Frame"" src=""" & sLink & """ width=""" & sWidth & """ height=""" & sHeight & """ frameborder=""0"" scrolling=""no""></iframe>"
116
Dim sWidthCSS, sHeightCSS
118
If InStr( sWidth, "%" ) > 0 Then
121
sWidthCSS = sWidth & "px"
124
If InStr( sHeight, "%" ) > 0 Then
127
sHeightCSS = sHeight & "px"
130
html = "<textarea name=""" & instanceName & """ rows=""4"" cols=""40"" style=""width: " & sWidthCSS & "; height: " & sHeightCSS & """>" & Server.HTMLEncode( sValue ) & "</textarea>"
138
Private Function IsCompatible()
140
IsCompatible = FCKeditor_IsCompatibleBrowser()
144
Private Function GetConfigFieldString()
152
For Each sKey in oConfig
154
If bFirst = False Then
155
sParams = sParams & "&"
160
sParams = sParams & EncodeConfig( sKey ) & "=" & EncodeConfig( oConfig(sKey) )
164
GetConfigFieldString = sParams
168
Private Function EncodeConfig( valueToEncode )
169
' The locale of the asp server makes the conversion of a boolean to string different to "true" or "false"
170
' so we must do it manually
171
If vartype(valueToEncode) = vbBoolean then
172
If valueToEncode=True Then
178
EncodeConfig = Replace( valueToEncode, "&", "%26" )
179
EncodeConfig = Replace( EncodeConfig , "=", "%3D" )
180
EncodeConfig = Replace( EncodeConfig , """", "%22" )
188
' A function that can be used to check if the current browser is compatible with FCKeditor
189
' without the need to create an instance of the class.
190
Function FCKeditor_IsCompatibleBrowser()
194
sAgent = Request.ServerVariables("HTTP_USER_AGENT")
199
If InStr(sAgent, "MSIE") > 0 AND InStr(sAgent, "mac") <= 0 AND InStr(sAgent, "Opera") <= 0 Then
200
iVersion = CInt( FCKeditor_ToNumericFormat( Mid(sAgent, InStr(sAgent, "MSIE") + 5, 3) ) )
201
FCKeditor_IsCompatibleBrowser = ( iVersion >= 5.5 )
202
ElseIf InStr(sAgent, "Gecko/") > 0 Then
203
iVersion = CLng( Mid( sAgent, InStr( sAgent, "Gecko/" ) + 6, 8 ) )
204
FCKeditor_IsCompatibleBrowser = ( iVersion >= 20030210 )
205
ElseIf InStr(sAgent, "Opera/") > 0 Then
206
iVersion = CSng( FCKeditor_ToNumericFormat( Mid( sAgent, InStr( sAgent, "Opera/" ) + 6, 4 ) ) )
207
FCKeditor_IsCompatibleBrowser = ( iVersion >= 9.5 )
208
ElseIf InStr(sAgent, "AppleWebKit/") > 0 Then
212
re.Pattern = "AppleWebKit/(\d+)"
213
Set Matches = re.Execute(sAgent)
214
FCKeditor_IsCompatibleBrowser = ( re.Replace(Matches.Item(0).Value, "$1") >= 522 )
216
FCKeditor_IsCompatibleBrowser = False
223
' On ASP, when converting string to numbers, the number decimal separator is localized
224
' so 5.5 will not work on systems were the separator is "," and vice versa.
225
Private Function FCKeditor_ToNumericFormat( numberStr )
227
If IsNumeric( "5.5" ) Then
228
FCKeditor_ToNumericFormat = Replace( numberStr, ",", ".")
230
FCKeditor_ToNumericFormat = Replace( numberStr, ".", ",")