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