1 | DEFINE CLASS fckeditor AS custom
|
---|
2 | cInstanceName =""
|
---|
3 | BasePath =""
|
---|
4 | cWIDTH =""
|
---|
5 | cHEIGHT =""
|
---|
6 | ToolbarSet =""
|
---|
7 | cValue=""
|
---|
8 | DIMENSION aConfig(10,2)
|
---|
9 |
|
---|
10 | && -----------------------------------------------------------------------
|
---|
11 | FUNCTION fckeditor( tcInstanceName )
|
---|
12 | LOCAL lnLoop,lnLoop2
|
---|
13 | THIS.cInstanceName = tcInstanceName
|
---|
14 | THIS.BasePath = '../../'
|
---|
15 | THIS.cWIDTH = '100%'
|
---|
16 | THIS.cHEIGHT = '200'
|
---|
17 | THIS.ToolbarSet = 'Default'
|
---|
18 | THIS.cValue = ''
|
---|
19 | FOR lnLoop=1 TO 10
|
---|
20 | FOR lnLoop2=1 TO 2
|
---|
21 | THIS.aConfig(lnLoop,lnLoop2) = ""
|
---|
22 | NEXT
|
---|
23 | NEXT
|
---|
24 | RETURN
|
---|
25 | ENDFUNC
|
---|
26 |
|
---|
27 |
|
---|
28 | && -----------------------------------------------------------------------
|
---|
29 | FUNCTION CREATE()
|
---|
30 | RETURN(THIS.CreateHtml())
|
---|
31 | ENDFUNC
|
---|
32 |
|
---|
33 | && -----------------------------------------------------------------------
|
---|
34 | FUNCTION CreateHtml()
|
---|
35 | LOCAL html
|
---|
36 | LOCAL lcLink
|
---|
37 |
|
---|
38 | HtmlValue = THIS.cValue && HTMLSPECIALCHARS()
|
---|
39 |
|
---|
40 | html = [<div>]
|
---|
41 | IF THIS.IsCompatible()
|
---|
42 | lcLink = THIS.BasePath+[editor/fckeditor.html?InstanceName=]+THIS.cInstanceName
|
---|
43 |
|
---|
44 | IF ( THIS.ToolbarSet # '' )
|
---|
45 | lcLink = lcLink + [Toolbar=]+THIS.ToolbarSet
|
---|
46 | ENDIF
|
---|
47 |
|
---|
48 | && Render the LINKED HIDDEN FIELD.
|
---|
49 | html = html + [<input type="hidden" id="]+THIS.cInstanceName +[" name="]+THIS.cInstanceName +[" value="]+HtmlValue+[">]
|
---|
50 |
|
---|
51 | && Render the configurations HIDDEN FIELD.
|
---|
52 | html = html + [<input type="hidden" id="]+THIS.cInstanceName +[___Config" value="]+THIS.GetConfigFieldString() + [">] +CHR(13)+CHR(10)
|
---|
53 |
|
---|
54 | && Render the EDITOR IFRAME.
|
---|
55 | html = html + [<iframe id="]+THIS.cInstanceName +[___Frame" src="]+lcLink+[" width="]+THIS.cWIDTH+[" height="]+THIS.cHEIGHT+[" frameborder="0" scrolling="no"></iframe>]
|
---|
56 | ELSE
|
---|
57 | IF ( AT("%", THIS.cWIDTH)=0 )
|
---|
58 | WidthCSS = THIS.cWIDTH + 'px'
|
---|
59 | ELSE
|
---|
60 | WidthCSS = THIS.cWIDTH
|
---|
61 | ENDIF
|
---|
62 |
|
---|
63 | IF ( AT("%",THIS.cHEIGHT)=0 )
|
---|
64 | HeightCSS = THIS.cHEIGHT + 'px'
|
---|
65 | ELSE
|
---|
66 | HeightCSS = THIS.cHEIGHT
|
---|
67 | ENDIF
|
---|
68 |
|
---|
69 | html = html + [<textarea name="]+THIS.cInstanceName +[" rows="4" cols="40" style="width: ]+WidthCSS+[ height: ]+HeightCSS+[" wrap="virtual">]+HtmlValue+[</textarea>]
|
---|
70 | ENDIF
|
---|
71 |
|
---|
72 | html = html + [</div>]
|
---|
73 |
|
---|
74 | RETURN (html)
|
---|
75 | ENDFUNC
|
---|
76 |
|
---|
77 |
|
---|
78 | && -----------------------------------------------------------------------
|
---|
79 | FUNCTION IsCompatible()
|
---|
80 | LOCAL llRetval
|
---|
81 | LOCAL sAgent
|
---|
82 |
|
---|
83 | llRetval=.F.
|
---|
84 |
|
---|
85 | sAgent= LOWER(Request.ServerVariables("HTTP_USER_AGENT"))
|
---|
86 |
|
---|
87 | IF AT("msie",sAgent) >0 .AND. AT("mac",sAgent)=0 .AND. AT("opera",sAgent)=0
|
---|
88 | iVersion=VAL(SUBSTR(sAgent,AT("msie",sAgent)+5,3))
|
---|
89 | llRetval= iVersion > 5.5
|
---|
90 | ELSE
|
---|
91 | IF AT("gecko",sAgent)>0
|
---|
92 | iVersion=VAL(SUBSTR(sAgent,AT("gecko/",sAgent)+6,8))
|
---|
93 | llRetval =iVersion > 20030210
|
---|
94 | ENDIF
|
---|
95 | ENDIF
|
---|
96 | RETURN (llRetval)
|
---|
97 | ENDFUNC
|
---|
98 |
|
---|
99 | && -----------------------------------------------------------------------
|
---|
100 | FUNCTION GetConfigFieldString()
|
---|
101 | LOCAL sParams
|
---|
102 | LOCAL bFirst
|
---|
103 | LOCAL sKey
|
---|
104 | sParams = ""
|
---|
105 | bFirst = .T.
|
---|
106 | FOR lnLoop=1 TO 10 && ALEN(this.aconfig)
|
---|
107 | IF !EMPTY(THIS.aConfig(lnLoop,1))
|
---|
108 | IF bFirst = .F.
|
---|
109 | sParams = sParams + "&"
|
---|
110 | ELSE
|
---|
111 | bFirst = .F.
|
---|
112 | ENDIF
|
---|
113 | sParams = sParams +THIS.aConfig(lnLoop,1)+[=]+THIS.aConfig(lnLoop,2)
|
---|
114 | ELSE
|
---|
115 | EXIT
|
---|
116 | ENDIF
|
---|
117 | NEXT
|
---|
118 | RETURN(sParams)
|
---|
119 | ENDFUNC
|
---|
120 | ENDDEFINE
|
---|
121 |
|
---|