File: fckeditor.afp

package info (click to toggle)
fckeditor 1:2.6.6-1squeeze1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 5,556 kB
  • ctags: 26,935
  • sloc: perl: 1,566; php: 1,097; python: 786; xml: 373; makefile: 32
file content (159 lines) | stat: -rw-r--r-- 4,307 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<%
 * FCKeditor - The text editor for Internet - http://www.fckeditor.net
 * Copyright (C) 2003-2010 Frederico Caldeira Knabben
 *
 * == BEGIN LICENSE ==
 *
 * Licensed under the terms of any of the following licenses at your
 * choice:
 *
 *  - GNU General Public License Version 2 or later (the "GPL")
 *    http://www.gnu.org/licenses/gpl.html
 *
 *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
 *    http://www.gnu.org/licenses/lgpl.html
 *
 *  - Mozilla Public License Version 1.1 or later (the "MPL")
 *    http://www.mozilla.org/MPL/MPL-1.1.html
 *
 * == END LICENSE ==
 *
 * This is the integration file for Active FoxPro Pages.
 *

DEFINE CLASS goFckeditor AS CONTAINER OLEPUBLIC

	cInstanceName =""
	BasePath =""
	cWIDTH =""
	cHEIGHT =""
	ToolbarSet =""
	cValue=""
	DIMENSION aConfig(10,2)

&& -----------------------------------------------------------------------
	FUNCTION fckeditor( tcInstanceName )
		LOCAL lnLoop,lnLoop2
		THIS.cInstanceName	= tcInstanceName
		THIS.BasePath	= '/fckeditor/'
		THIS.cWIDTH		= '100%'
		THIS.cHEIGHT	= '200'
		THIS.ToolbarSet	= 'Default'
		THIS.cValue		= ''
		FOR lnLoop=1 TO 10
			FOR lnLoop2=1 TO 2
				THIS.aConfig(lnLoop,lnLoop2)	= ""
			NEXT
		NEXT
		RETURN
	ENDFUNC


&& -----------------------------------------------------------------------
	FUNCTION CREATE()
		? THIS.CreateHtml()
		RETURN
	ENDFUNC

&& -----------------------------------------------------------------------
	FUNCTION CreateHtml()
		LOCAL html
		LOCAL lcLink

		HtmlValue = THIS.cValue		&& HTMLSPECIALCHARS()

		html = []
		IF THIS.IsCompatible()
			lcLink = THIS.BasePath+[editor/fckeditor.html?InstanceName=]+THIS.cInstanceName

			IF ( !THIS.ToolbarSet == '' )
				lcLink = lcLink + [&Toolbar=]+THIS.ToolbarSet
			ENDIF

			&& Render the LINKED HIDDEN FIELD.
			html = html + [<input type="hidden" id="]+THIS.cInstanceName +[" name="]+THIS.cInstanceName +[" value="]+HtmlValue+[" style="display:none" />]

			&& Render the configurations HIDDEN FIELD.
			html = html + [<input type="hidden" id="]+THIS.cInstanceName +[___Config" value="]+THIS.GetConfigFieldString() + [" style="display:none" />] +CHR(13)+CHR(10)

			&& Render the EDITOR IFRAME.
			html = html + [<iframe id="]+THIS.cInstanceName +[___Frame" src="Link" width="]+THIS.cWIDTH+[" height="]+THIS.cHEIGHT+[" frameborder="0" scrolling="no"></iframe>]
		ELSE
			IF ( AT("%", THIS.cWIDTH)=0 )
				WidthCSS = THIS.cWIDTH + 'px'
			ELSE
				WidthCSS = THIS.cWIDTH
			ENDIF

			IF ( AT("%",THIS.cHEIGHT)=0  )
				HeightCSS = THIS.cHEIGHT + 'px'
			ELSE
				HeightCSS = THIS.cHEIGHT
			ENDIF

			html = html + [<textarea name="]+THIS.cInstanceName +[" rows="4" cols="40" style="width: ]+WidthCSS+[ height: ]+HeightCSS+[">]+HtmlValue+[</textarea>]
		ENDIF

		RETURN (html)
	ENDFUNC


&& -----------------------------------------------------------------------
	FUNCTION IsCompatible()
		LOCAL llRetval
		LOCAL sAgent

		llRetval=.F.

		SET POINT TO "."

		sAgent = LOWER(ALLTRIM(request.servervariables("HTTP_USER_AGENT")))

		IF AT("msie",sAgent) >0 .AND. AT("mac",sAgent)=0 .AND. AT("opera",sAgent)=0
			iVersion=VAL(SUBSTR(sAgent,AT("msie",sAgent)+5,3))
			llRetval= iVersion > 5.5
		ELSE
			IF AT("gecko/",sAgent)>0
				iVersion=VAL(SUBSTR(sAgent,AT("gecko/",sAgent)+6,8))
				llRetval =iVersion > 20030210
			ENDIF
		ELSE
			IF AT("opera/",sAgent)>0
				iVersion=VAL(SUBSTR(sAgent,AT("opera/",sAgent)+6,4))
				llRetval =iVersion >= 9.5
			ENDIF
		ELSE
			IF AT("applewebkit/",sAgent)>0
				iVersion=VAL(SUBSTR(sAgent,AT("applewebkit/",sAgent)+12,3))
				llRetval =iVersion >= 522
			ENDIF
		ENDIF

		SET POINT TO

		RETURN (llRetval)
	ENDFUNC

&& -----------------------------------------------------------------------
	FUNCTION GetConfigFieldString()
		LOCAL sParams
		LOCAL bFirst
		LOCAL sKey
		sParams = ""
		bFirst = .T.
		FOR lnLoop=1 TO 10 && ALEN(this.aconfig)
			IF !EMPTY(THIS.aConfig(lnLoop,1))
				IF bFirst = .F.
					sParams = sParams + "&"
				ELSE
					bFirst = .F.
				ENDIF
				sParams = sParams +THIS.aConfig(lnLoop,1)+[=]+THIS.aConfig(lnLoop,2)
			ELSE
				EXIT
			ENDIF
		NEXT
		RETURN(sParams)
	ENDFUNC
ENDDEFINE
%>