2
* FCKeditor - The text editor for internet
3
* Copyright (C) 2003-2005 Frederico Caldeira Knabben
5
* Licensed under the terms of the GNU Lesser General Public License:
6
* http://www.opensource.org/licenses/lgpl-license.php
8
* For further information visit:
9
* http://www.fckeditor.net/
11
* "Support Open Source software. What about a donation today?"
13
* File Name: fckeditor.asp
14
* This is the integration file for ASP.
16
* It defines the FCKeditor class that can be used to create editor
17
* instances in ASP pages on server side.
20
* Frederico Caldeira Knabben (fredck@fckeditor.net)
34
Private Sub Class_Initialize()
35
sBasePath = "/FCKeditor/"
38
sToolbarSet = "Default"
41
Set oConfig = CreateObject("Scripting.Dictionary")
44
Public Property Let BasePath( basePathValue )
45
sBasePath = basePathValue
48
Public Property Let InstanceName( instanceNameValue )
49
sInstanceName = instanceNameValue
52
Public Property Let Width( widthValue )
56
Public Property Let Height( heightValue )
60
Public Property Let ToolbarSet( toolbarSetValue )
61
sToolbarSet = toolbarSetValue
64
Public Property Let Value( newValue )
65
If ( IsNull( newValue ) OR IsEmpty( newValue ) ) Then
72
Public Property Let Config( configKey, configValue )
73
oConfig.Add configKey, configValue
76
Public Function Create( instanceName )
78
Response.Write "<div>"
80
If IsCompatible() Then
83
If Request.QueryString( "fcksource" ) = "true" Then
84
sFile = "fckeditor.original.html"
86
sFile = "fckeditor.html"
90
sLink = sBasePath & "editor/" & sFile & "?InstanceName=" + instanceName
92
If (sToolbarSet & "") <> "" Then
93
sLink = sLink + "&Toolbar=" & sToolbarSet
96
' Render the linked hidden field.
97
Response.Write "<input type=""hidden"" id=""" & instanceName & """ name=""" & instanceName & """ value=""" & Server.HTMLEncode( sValue ) & """ style=""display:none"" />"
99
' Render the configurations hidden field.
100
Response.Write "<input type=""hidden"" id=""" & instanceName & "___Config"" value=""" & GetConfigFieldString() & """ style=""display:none"" />"
102
' Render the editor IFRAME.
103
Response.Write "<iframe id=""" & instanceName & "___Frame"" src=""" & sLink & """ width=""" & sWidth & """ height=""" & sHeight & """ frameborder=""no"" scrolling=""no""></iframe>"
107
Dim sWidthCSS, sHeightCSS
109
If InStr( sWidth, "%" ) > 0 Then
112
sWidthCSS = sWidth & "px"
115
If InStr( sHeight, "%" ) > 0 Then
118
sHeightCSS = sHeight & "px"
121
Response.Write "<textarea name=""" & instanceName & """ rows=""4"" cols=""40"" style=""width: " & sWidthCSS & "; height: " & sHeightCSS & """>" & Server.HTMLEncode( sValue ) & "</textarea>"
125
Response.Write "</div>"
129
Private Function IsCompatible()
132
sAgent = Request.ServerVariables("HTTP_USER_AGENT")
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 )
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 )
153
If IsNumeric( "5.5" ) Then
154
ToNumericFormat = Replace( numberStr, ",", ".")
156
ToNumericFormat = Replace( numberStr, ".", ",")
161
Private Function GetConfigFieldString()
169
For Each sKey in oConfig
171
If bFirst = False Then
172
sParams = sParams & "&"
177
sParams = sParams & EncodeConfig( sKey ) & "=" & EncodeConfig( oConfig(sKey) )
181
GetConfigFieldString = sParams
185
Private Function EncodeConfig( valueToEncode )
186
EncodeConfig = Replace( valueToEncode, "&", "%26" )
187
EncodeConfig = Replace( EncodeConfig , "=", "%3D" )
188
EncodeConfig = Replace( EncodeConfig , """", "%22" )
b'\\ No newline at end of file'