Changeset 417

Show
Ignore:
Timestamp:
2007-07-07 17:21:51 (18 months ago)
Author:
alfonsoml
Message:

changes to the Creator for asp (#72)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • FCKeditor/trunk/fckeditor.asp

    r347 r417  
    7878        End Property 
    7979 
    80         Public Function Create( instanceName ) 
    81  
    82                 Response.Write "<div>" 
     80        ' Generates the instace of the editor in the HTML output of the page. 
     81        Public Sub Create( instanceName ) 
     82                response.write CreateHtml( instanceName ) 
     83        end Sub 
     84 
     85        ' Returns the html code that must be used to generate an instance of FCKeditor. 
     86        Public Function CreateHtml( instanceName ) 
     87                dim html 
    8388 
    8489                If IsCompatible() Then 
    8590 
    86                         Dim sFile 
     91                        Dim sFile, sLink 
    8792                        If Request.QueryString( "fcksource" ) = "true" Then 
    8893                                sFile = "fckeditor.original.html" 
     
    9196                        End If 
    9297 
    93                         Dim sLink 
    9498                        sLink = sBasePath & "editor/" & sFile & "?InstanceName=" + instanceName 
    9599 
     
    98102                        End If 
    99103 
     104                        html = "" 
    100105                        ' Render the linked hidden field. 
    101                         Response.Write "<input type=""hidden"" id=""" & instanceName & """ name=""" & instanceName & """ value=""" & Server.HTMLEncode( sValue ) & """ style=""display:none"" />" 
     106                        html = html & "<input type=""hidden"" id=""" & instanceName & """ name=""" & instanceName & """ value=""" & Server.HTMLEncode( sValue ) & """ style=""display:none"" />" 
    102107 
    103108                        ' Render the configurations hidden field. 
    104                         Response.Write "<input type=""hidden"" id=""" & instanceName & "___Config"" value=""" & GetConfigFieldString() & """ style=""display:none"" />" 
     109                        html = html & "<input type=""hidden"" id=""" & instanceName & "___Config"" value=""" & GetConfigFieldString() & """ style=""display:none"" />" 
    105110 
    106111                        ' Render the editor IFRAME. 
    107                         Response.Write "<iframe id=""" & instanceName & "___Frame"" src=""" & sLink & """ width=""" & sWidth & """ height=""" & sHeight & """ frameborder=""0"" scrolling=""no""></iframe>" 
     112                        html = html & "<iframe id=""" & instanceName & "___Frame"" src=""" & sLink & """ width=""" & sWidth & """ height=""" & sHeight & """ frameborder=""0"" scrolling=""no""></iframe>" 
    108113 
    109114                Else 
     
    123128                        End If 
    124129 
    125                         Response.Write "<textarea name=""" & instanceName & """ rows=""4"" cols=""40"" style=""width: " & sWidthCSS & "; height: " & sHeightCSS & """>" & Server.HTMLEncode( sValue ) & "</textarea>" 
     130                        html = "<textarea name=""" & instanceName & """ rows=""4"" cols=""40"" style=""width: " & sWidthCSS & "; height: " & sHeightCSS & """>" & Server.HTMLEncode( sValue ) & "</textarea>" 
    126131 
    127132                End If 
    128133 
    129                 Response.Write "</div>" 
     134                CreateHtml = "<div>" & html & "</div>" 
    130135 
    131136        End Function 
     
    133138        Private Function IsCompatible() 
    134139 
    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 
     140                IsCompatible = FCKeditor_IsCompatibleBrowser() 
    149141 
    150142        End Function 
     
    205197 
    206198End Class 
     199 
     200 
     201' A function that can be used to check if the current browser is compatible with FCKeditor 
     202' without the need to create an instance of the class. 
     203Function FCKeditor_IsCompatibleBrowser() 
     204 
     205        Dim sAgent 
     206        sAgent = Request.ServerVariables("HTTP_USER_AGENT") 
     207 
     208        Dim iVersion 
     209 
     210        If InStr(sAgent, "MSIE") > 0 AND InStr(sAgent, "mac") <= 0  AND InStr(sAgent, "Opera") <= 0 Then 
     211                iVersion = CInt( ToNumericFormat( Mid(sAgent, InStr(sAgent, "MSIE") + 5, 3) ) ) 
     212                FCKeditor_IsCompatibleBrowser = ( iVersion >= 5.5 ) 
     213        ElseIf InStr(sAgent, "Gecko/") > 0 Then 
     214                iVersion = CLng( Mid( sAgent, InStr( sAgent, "Gecko/" ) + 6, 8 ) ) 
     215                FCKeditor_IsCompatibleBrowser = ( iVersion >= 20030210 ) 
     216        Else 
     217                FCKeditor_IsCompatibleBrowser = False 
     218        End If 
     219 
     220End Function 
    207221%>