温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:博客源代码(课程设计,3层架构)
当前文件:
MVCBlog/fckeditor/fckeditor.asp,打开代码结构图
MVCBlog/fckeditor/fckeditor.asp,打开代码结构图1<!-- 2
* FCKeditor - The text editor for Internet - http://www.fckeditor.net 3
* Copyright (C) 2003-2008 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
<% 27
Class 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
' 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 88
89
If IsCompatible() Then 90
91
Dim sFile, sLink 92
If Request.QueryString( "fcksource" ) = "true" Then 93
sFile = "fckeditor.original.html" 94
Else 95
sFile = "fckeditor.html" 96
End If 97
98
sLink = sBasePath & "editor/" & sFile & "?InstanceName=" + instanceName 99
100
If (sToolbarSet & "") <> "" Then 101
sLink = sLink + "&Toolbar=" & sToolbarSet 102
End If 103
104
html = "" 105
' Render the linked hidden field. 106
html = html & "<input type=""hidden"" id=""" & instanceName & """ name=""" & instanceName & """ value=""" & Server.HTMLEncode( sValue ) & """ style=""display:none"" />" 107
108
' Render the configurations hidden field. 109
html = html & "<input type=""hidden"" id=""" & instanceName & "___Config"" value=""" & GetConfigFieldString() & """ style=""display:none"" />" 110
111
' Render the editor IFRAME. 112
html = html & "<iframe id=""" & instanceName & "___Frame"" src=""" & sLink & """ width=""" & sWidth & """ height=""" & sHeight & """ frameborder=""0"" scrolling=""no""></iframe>" 113
114
Else 115
116
Dim sWidthCSS, sHeightCSS 117
118
If InStr( sWidth, "%" ) > 0 Then 119
sWidthCSS = sWidth 120
Else 121
sWidthCSS = sWidth & "px" 122
End If 123
124
If InStr( sHeight, "%" ) > 0 Then 125
sHeightCSS = sHeight 126
Else 127
sHeightCSS = sHeight & "px" 128
End If 129
130
html = "<textarea name=""" & instanceName & """ rows=""4"" cols=""40"" style=""width: " & sWidthCSS & "; height: " & sHeightCSS & """>" & Server.HTMLEncode( sValue ) & "</textarea>" 131
132
End If 133
134
CreateHtml = html 135
136
End Function 137
138
Private Function IsCompatible() 139
140
IsCompatible = FCKeditor_IsCompatibleBrowser() 141
142
End Function 143
144
Private Function GetConfigFieldString() 145
146
Dim sParams 147
148
Dim bFirst 149
bFirst = True 150
151
Dim sKey 152
For Each sKey in oConfig 153
154
If bFirst = False Then 155
sParams = sParams & "&" 156
Else 157
bFirst = False 158
End If 159
160
sParams = sParams & EncodeConfig( sKey ) & "=" & EncodeConfig( oConfig(sKey) ) 161
162
Next 163
164
GetConfigFieldString = sParams 165
166
End Function 167
168
Private Function EncodeConfig( valueToEncode ) 169
' The locale of the asp server makes the conversion of a boolean to string different to "true" or "false" 170
' so we must do it manually 171
If vartype(valueToEncode) = vbBoolean then 172
If valueToEncode=True Then 173
EncodeConfig="True" 174
Else 175
EncodeConfig="False" 176
End If 177
Else 178
EncodeConfig = Replace( valueToEncode, "&", "%26" ) 179
EncodeConfig = Replace( EncodeConfig , "=", "%3D" ) 180
EncodeConfig = Replace( EncodeConfig , """", "%22" ) 181
End if 182
183
End Function 184
185
End Class 186
187
188
' A function that can be used to check if the current browser is compatible with FCKeditor 189
' without the need to create an instance of the class. 190
Function FCKeditor_IsCompatibleBrowser() 191
192
193
Dim sAgent 194
sAgent = Request.ServerVariables("HTTP_USER_AGENT") 195
196
Dim iVersion 197
Dim re, Matches 198
199
If InStr(sAgent, "MSIE") > 0 AND InStr(sAgent, "mac") <= 0 AND InStr(sAgent, "Opera") <= 0 Then 200
iVersion = CInt( FCKeditor_ToNumericFormat( Mid(sAgent, InStr(sAgent, "MSIE") + 5, 3) ) ) 201
FCKeditor_IsCompatibleBrowser = ( iVersion >= 5.5 ) 202
ElseIf InStr(sAgent, "Gecko/") > 0 Then 203
iVersion = CLng( Mid( sAgent, InStr( sAgent, "Gecko/" ) + 6, 8 ) ) 204
FCKeditor_IsCompatibleBrowser = ( iVersion >= 20030210 ) 205
ElseIf InStr(sAgent, "Opera/") > 0 Then 206
iVersion = CSng( FCKeditor_ToNumericFormat( Mid( sAgent, InStr( sAgent, "Opera/" ) + 6, 4 ) ) ) 207
FCKeditor_IsCompatibleBrowser = ( iVersion >= 9.5 ) 208
ElseIf InStr(sAgent, "AppleWebKit/") > 0 Then 209
Set re = new RegExp 210
re.IgnoreCase = true 211
re.global = false 212
re.Pattern = "AppleWebKit/(\d+)" 213
Set Matches = re.Execute(sAgent) 214
FCKeditor_IsCompatibleBrowser = ( re.Replace(Matches.Item(0).Value, "$1") >= 522 ) 215
Else 216
FCKeditor_IsCompatibleBrowser = False 217
End If 218
219
End Function 220
221
222
' By Agrotic 223
' On ASP, when converting string to numbers, the number decimal separator is localized 224
' so 5.5 will not work on systems were the separator is "," and vice versa. 225
Private Function FCKeditor_ToNumericFormat( numberStr ) 226
227
If IsNumeric( "5.5" ) Then 228
FCKeditor_ToNumericFormat = Replace( numberStr, ",", ".") 229
Else 230
FCKeditor_ToNumericFormat = Replace( numberStr, ".", ",") 231
End If 232
233
End Function 234
235
%> 236




Class FCKeditor
