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