Rev 1075 | Blame | Last modification | View Log | RSS feed
<!--* FCKeditor - The text editor for internet* Copyright (C) 2003-2006 Frederico Caldeira Knabben** Licensed under the terms of the GNU Lesser General Public License:* http://www.opensource.org/licenses/lgpl-license.php** For further information visit:* http://www.fckeditor.net/** "Support Open Source software. What about a donation today?"** File Name: fckeditor.asp* This is the integration file for ASP.** It defines the FCKeditor class that can be used to create editor* instances in ASP pages on server side.** File Authors:* Frederico Caldeira Knabben (fredck@fckeditor.net)--><%Class FCKeditorprivate sBasePathprivate sInstanceNameprivate sWidthprivate sHeightprivate sToolbarSetprivate sValueprivate oConfigPrivate Sub Class_Initialize()sBasePath = "/fckeditor/"sWidth = "100%"sHeight = "200"sToolbarSet = "Default"sValue = ""Set oConfig = CreateObject("Scripting.Dictionary")End SubPublic Property Let BasePath( basePathValue )sBasePath = basePathValueEnd PropertyPublic Property Let InstanceName( instanceNameValue )sInstanceName = instanceNameValueEnd PropertyPublic Property Let Width( widthValue )sWidth = widthValueEnd PropertyPublic Property Let Height( heightValue )sHeight = heightValueEnd PropertyPublic Property Let ToolbarSet( toolbarSetValue )sToolbarSet = toolbarSetValueEnd PropertyPublic Property Let Value( newValue )If ( IsNull( newValue ) OR IsEmpty( newValue ) ) ThensValue = ""ElsesValue = newValueEnd IfEnd PropertyPublic Property Let Config( configKey, configValue )oConfig.Add configKey, configValueEnd PropertyPublic Function Create( instanceName )Response.Write "<div>"If IsCompatible() ThenDim sFileIf Request.QueryString( "fcksource" ) = "true" ThensFile = "fckeditor.original.html"ElsesFile = "fckeditor.html"End IfDim sLinksLink = sBasePath & "editor/" & sFile & "?InstanceName=" + instanceNameIf (sToolbarSet & "") <> "" ThensLink = sLink + "&Toolbar=" & sToolbarSetEnd If' Render the linked hidden field.Response.Write "<input type=""hidden"" id=""" & instanceName & """ name=""" & instanceName & """ value=""" & Server.HTMLEncode( sValue ) & """ style=""display:none"" />"' Render the configurations hidden field.Response.Write "<input type=""hidden"" id=""" & instanceName & "___Config"" value=""" & GetConfigFieldString() & """ style=""display:none"" />"' Render the editor IFRAME.Response.Write "<iframe id=""" & instanceName & "___Frame"" src=""" & sLink & """ width=""" & sWidth & """ height=""" & sHeight & """ frameborder=""0"" scrolling=""no""></iframe>"ElseDim sWidthCSS, sHeightCSSIf InStr( sWidth, "%" ) > 0 ThensWidthCSS = sWidthElsesWidthCSS = sWidth & "px"End IfIf InStr( sHeight, "%" ) > 0 ThensHeightCSS = sHeightElsesHeightCSS = sHeight & "px"End IfResponse.Write "<textarea name=""" & instanceName & """ rows=""4"" cols=""40"" style=""width: " & sWidthCSS & "; height: " & sHeightCSS & """>" & Server.HTMLEncode( sValue ) & "</textarea>"End IfResponse.Write "</div>"End FunctionPrivate Function IsCompatible()Dim sAgentsAgent = Request.ServerVariables("HTTP_USER_AGENT")Dim iVersionIf InStr(sAgent, "MSIE") > 0 AND InStr(sAgent, "mac") <= 0 AND InStr(sAgent, "Opera") <= 0 TheniVersion = CInt( ToNumericFormat( Mid(sAgent, InStr(sAgent, "MSIE") + 5, 3) ) )IsCompatible = ( iVersion >= 5.5 )ElseIf InStr(sAgent, "Gecko/") > 0 TheniVersion = CLng( Mid( sAgent, InStr( sAgent, "Gecko/" ) + 6, 8 ) )IsCompatible = ( iVersion >= 20030210 )ElseIsCompatible = FalseEnd IfEnd Function' By Agrotic' On ASP, when converting string to numbers, the number decimal separator is localized' so 5.5 will not work on systems were the separator is "," and vice versa.Private Function ToNumericFormat( numberStr )If IsNumeric( "5.5" ) ThenToNumericFormat = Replace( numberStr, ",", ".")ElseToNumericFormat = Replace( numberStr, ".", ",")End IfEnd FunctionPrivate Function GetConfigFieldString()Dim sParamsDim bFirstbFirst = TrueDim sKeyFor Each sKey in oConfigIf bFirst = False ThensParams = sParams & "&"ElsebFirst = FalseEnd IfsParams = sParams & EncodeConfig( sKey ) & "=" & EncodeConfig( oConfig(sKey) )NextGetConfigFieldString = sParamsEnd FunctionPrivate Function EncodeConfig( valueToEncode )EncodeConfig = Replace( valueToEncode, "&", "%26" )EncodeConfig = Replace( EncodeConfig , "=", "%3D" )EncodeConfig = Replace( EncodeConfig , """", "%22" )End FunctionEnd Class%>