1 | * FCKeditor - The text editor for Internet - http://www.fckeditor.net
|
---|
2 | * Copyright (C) 2003-2009 Frederico Caldeira Knabben
|
---|
3 | *
|
---|
4 | * == BEGIN LICENSE ==
|
---|
5 | *
|
---|
6 | * Licensed under the terms of any of the following licenses at your
|
---|
7 | * choice:
|
---|
8 | *
|
---|
9 | * - GNU General Public License Version 2 or later (the "GPL")
|
---|
10 | * http://www.gnu.org/licenses/gpl.html
|
---|
11 | *
|
---|
12 | * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
|
---|
13 | * http://www.gnu.org/licenses/lgpl.html
|
---|
14 | *
|
---|
15 | * - Mozilla Public License Version 1.1 or later (the "MPL")
|
---|
16 | * http://www.mozilla.org/MPL/MPL-1.1.html
|
---|
17 | *
|
---|
18 | * == END LICENSE ==
|
---|
19 | *
|
---|
20 | * This is the class definition file for the sample pages.
|
---|
21 | *
|
---|
22 |
|
---|
23 | DEFINE CLASS fckeditor AS custom
|
---|
24 | cInstanceName =""
|
---|
25 | BasePath =""
|
---|
26 | cWIDTH =""
|
---|
27 | cHEIGHT =""
|
---|
28 | ToolbarSet =""
|
---|
29 | cValue=""
|
---|
30 | DIMENSION aConfig(10,2)
|
---|
31 |
|
---|
32 | && -----------------------------------------------------------------------
|
---|
33 | FUNCTION fckeditor( tcInstanceName )
|
---|
34 | LOCAL lnLoop,lnLoop2
|
---|
35 | THIS.cInstanceName = tcInstanceName
|
---|
36 | THIS.BasePath = '../../../FCKeditor/'
|
---|
37 | THIS.cWIDTH = '100%'
|
---|
38 | THIS.cHEIGHT = '200'
|
---|
39 | THIS.ToolbarSet = 'Default'
|
---|
40 | THIS.cValue = ''
|
---|
41 | FOR lnLoop=1 TO 10
|
---|
42 | FOR lnLoop2=1 TO 2
|
---|
43 | THIS.aConfig(lnLoop,lnLoop2) = ""
|
---|
44 | NEXT
|
---|
45 | NEXT
|
---|
46 | RETURN
|
---|
47 | ENDFUNC
|
---|
48 |
|
---|
49 |
|
---|
50 | && -----------------------------------------------------------------------
|
---|
51 | FUNCTION CREATE()
|
---|
52 | RETURN(THIS.CreateHtml())
|
---|
53 | ENDFUNC
|
---|
54 |
|
---|
55 | && -----------------------------------------------------------------------
|
---|
56 | FUNCTION CreateHtml()
|
---|
57 | LOCAL html
|
---|
58 | LOCAL lcLink
|
---|
59 |
|
---|
60 | HtmlValue = THIS.cValue && HTMLSPECIALCHARS()
|
---|
61 |
|
---|
62 | html = [<div>]
|
---|
63 | IF THIS.IsCompatible()
|
---|
64 | lcLink = THIS.BasePath+[editor/fckeditor.html?InstanceName=]+THIS.cInstanceName
|
---|
65 |
|
---|
66 | IF ( !THIS.ToolbarSet == '' )
|
---|
67 | lcLink = lcLink + [&Toolbar=]+THIS.ToolbarSet
|
---|
68 | ENDIF
|
---|
69 |
|
---|
70 | && Render the LINKED HIDDEN FIELD.
|
---|
71 | html = html + [<input type="hidden" id="]+THIS.cInstanceName +[" name="]+THIS.cInstanceName +[" value="]+HtmlValue+[">]
|
---|
72 |
|
---|
73 | && Render the configurations HIDDEN FIELD.
|
---|
74 | html = html + [<input type="hidden" id="]+THIS.cInstanceName +[___Config" value="]+THIS.GetConfigFieldString() + [">] +CHR(13)+CHR(10)
|
---|
75 |
|
---|
76 | && Render the EDITOR IFRAME.
|
---|
77 | html = html + [<iframe id="]+THIS.cInstanceName +[___Frame" src="]+lcLink+[" width="]+THIS.cWIDTH+[" height="]+THIS.cHEIGHT+[" frameborder="no" scrolling="no"></iframe>]
|
---|
78 | ELSE
|
---|
79 | IF ( AT("%", THIS.cWIDTH)=0 )
|
---|
80 | WidthCSS = THIS.cWIDTH + 'px'
|
---|
81 | ELSE
|
---|
82 | WidthCSS = THIS.cWIDTH
|
---|
83 | ENDIF
|
---|
84 |
|
---|
85 | IF ( AT("%",THIS.cHEIGHT)=0 )
|
---|
86 | HeightCSS = THIS.cHEIGHT + 'px'
|
---|
87 | ELSE
|
---|
88 | HeightCSS = THIS.cHEIGHT
|
---|
89 | ENDIF
|
---|
90 |
|
---|
91 | html = html + [<textarea name="]+THIS.cInstanceName +[" rows="4" cols="40" style="width: ]+WidthCSS+[ height: ]+HeightCSS+[" wrap="virtual">]+HtmlValue+[</textarea>]
|
---|
92 | ENDIF
|
---|
93 |
|
---|
94 | html = html + [</div>]
|
---|
95 |
|
---|
96 | RETURN (html)
|
---|
97 | ENDFUNC
|
---|
98 |
|
---|
99 |
|
---|
100 | && -----------------------------------------------------------------------
|
---|
101 | FUNCTION IsCompatible()
|
---|
102 | LOCAL llRetval
|
---|
103 | LOCAL sAgent
|
---|
104 |
|
---|
105 | llRetval=.F.
|
---|
106 |
|
---|
107 | sAgent= LOWER(Request.ServerVariables("HTTP_USER_AGENT"))
|
---|
108 |
|
---|
109 | IF AT("msie",sAgent) >0 .AND. AT("mac",sAgent)=0 .AND. AT("opera",sAgent)=0
|
---|
110 | iVersion=VAL(SUBSTR(sAgent,AT("msie",sAgent)+5,3))
|
---|
111 | llRetval= iVersion > 5.5
|
---|
112 | ELSE
|
---|
113 | IF AT("gecko",sAgent)>0
|
---|
114 | iVersion=VAL(SUBSTR(sAgent,AT("gecko/",sAgent)+6,8))
|
---|
115 | llRetval =iVersion > 20030210
|
---|
116 | ENDIF
|
---|
117 | ENDIF
|
---|
118 | RETURN (llRetval)
|
---|
119 | ENDFUNC
|
---|
120 |
|
---|
121 | && -----------------------------------------------------------------------
|
---|
122 | FUNCTION GetConfigFieldString()
|
---|
123 | LOCAL sParams
|
---|
124 | LOCAL bFirst
|
---|
125 | LOCAL sKey
|
---|
126 | sParams = ""
|
---|
127 | bFirst = .T.
|
---|
128 | FOR lnLoop=1 TO 10 && ALEN(this.aconfig)
|
---|
129 | IF !EMPTY(THIS.aConfig(lnLoop,1))
|
---|
130 | IF bFirst = .F.
|
---|
131 | sParams = sParams + "&"
|
---|
132 | ELSE
|
---|
133 | bFirst = .F.
|
---|
134 | ENDIF
|
---|
135 | sParams = sParams +THIS.aConfig(lnLoop,1)+[=]+THIS.aConfig(lnLoop,2)
|
---|
136 | ELSE
|
---|
137 | EXIT
|
---|
138 | ENDIF
|
---|
139 | NEXT
|
---|
140 | RETURN(sParams)
|
---|
141 | ENDFUNC
|
---|
142 | && -----------------------------------------------------------------------
|
---|
143 | && This function removes unwanted characters in URL parameters mostly entered by hackers
|
---|
144 |
|
---|
145 | FUNCTION StripAttacks
|
---|
146 | LPARAMETERS tcString
|
---|
147 | IF !EMPTY(tcString)
|
---|
148 | tcString=STRTRAN(tcString,"&","")
|
---|
149 | tcString=STRTRAN(tcString,"?","")
|
---|
150 | tcString=STRTRAN(tcString,";","")
|
---|
151 | tcString=STRTRAN(tcString,"!","")
|
---|
152 | tcString=STRTRAN(tcString,"<%","")
|
---|
153 | tcString=STRTRAN(tcString,"%>","")
|
---|
154 | tcString=STRTRAN(tcString,"<","")
|
---|
155 | tcString=STRTRAN(tcString,">","")
|
---|
156 | tcString=STRTRAN(tcString,"..","")
|
---|
157 | tcString=STRTRAN(tcString,"/","")
|
---|
158 | tcString=STRTRAN(tcString,"\","")
|
---|
159 | tcString=STRTRAN(tcString,":","")
|
---|
160 | ELSE
|
---|
161 | tcString=""
|
---|
162 | ENDIF
|
---|
163 | RETURN (tcString)
|
---|
164 |
|
---|
165 | ENDDEFINE
|
---|