comparison wiki/htdocs/applets/FCKeditor/fckeditor.cfc @ 0:77665d8e2254

tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0 (automatically generated log message) imported from: moin--main--1.5--base-0
author Thomas Waldmann <tw-public@gmx.de>
date Thu, 22 Sep 2005 15:09:50 +0000
parents
children 79dbcefdff31
comparison
equal deleted inserted replaced
-1:000000000000 0:77665d8e2254
1 <cfcomponent output="false" displayname="FCKeditor" hint="Create an instance of the FCKeditor.">
2 <!--- @Packager.Header
3 <FileDescription>
4 ColdFusion MX integration.
5 Note this CFC is created for use only with Coldfusion MX and above.
6 For older version, check the fckeditor.cfm.
7
8 Syntax:
9
10 &lt;cfscript&gt;
11 fckEditor = createObject("component", "fckEditorV2/fckeditor");
12 fckEditor.instanceName="myEditor";
13 fckEditor.basePath="/fckEditorV2/";
14 fckEditor.value="This is my &lt;strong&gt;initial&lt;/strong&gt; html text.";
15 fckEditor.width="100%";
16 fckEditor.height="200";
17 // ... additional parameters ...
18 fckEditor.create(); // create instance now.
19 &lt;/cfscript&gt;
20
21 See your macromedia coldfusion mx documentation for more info.
22
23 *** Note:
24 Do not use path names with a "." (dot) in the name. This is a coldfusion
25 limitation with the cfc invocation.
26 </FileDescription>
27 <Author name="Hendrik Kramer" email="hk@lwd.de" />
28 --->
29 <cffunction
30 name="create"
31 access="public"
32 output="true"
33 returntype="void"
34 hint="Initialize the FCKeditor instance."
35 >
36
37 <cfparam name="this.instanceName" type="string" />
38 <cfparam name="this.width" type="string" default="100%" />
39 <cfparam name="this.height" type="string" default="200" />
40 <cfparam name="this.toolbarSet" type="string" default="Default" />
41 <cfparam name="this.value" type="string" default="" />
42 <cfparam name="this.basePath" type="string" default="/fckeditor/" />
43 <cfparam name="this.checkBrowser" type="boolean" default="true" />
44 <cfparam name="this.config" type="struct" default="#structNew()#" />
45
46 <cfscript>
47 // display the html editor or a plain textarea?
48 if( isCompatible() )
49 showHTMLEditor();
50 else
51 showTextArea();
52 </cfscript>
53
54 </cffunction>
55
56 <cffunction
57 name="isCompatible"
58 access="private"
59 output="false"
60 returnType="boolean"
61 hint="Check browser compatibility via HTTP_USER_AGENT, if checkBrowser is true"
62 >
63
64 <cfscript>
65 var sAgent = lCase( cgi.HTTP_USER_AGENT );
66 var stResult = "";
67 var sBrowserVersion = "";
68
69 // do not check if argument "checkBrowser" is false
70 if( not this.checkBrowser )
71 return true;
72
73 // check for Internet Explorer ( >= 5.5 )
74 if( find( "msie", sAgent ) and not find( "mac", sAgent ) and not find( "opera", sAgent ) )
75 {
76 // try to extract IE version
77 stResult = reFind( "msie ([5-9]\.[0-9])", sAgent, 1, true );
78 if( arrayLen( stResult.pos ) eq 2 )
79 {
80 // get IE Version
81 sBrowserVersion = mid( sAgent, stResult.pos[2], stResult.len[2] );
82 return ( sBrowserVersion GTE 5.5 );
83 }
84 }
85 // check for Gecko ( >= 20030210+ )
86 else if( find( "gecko/", sAgent ) )
87 {
88 // try to extract Gecko version date
89 stResult = reFind( "gecko/(200[3-9][0-1][0-9][0-3][0-9])", sAgent, 1, true );
90 if( arrayLen( stResult.pos ) eq 2 )
91 {
92 // get Gecko build (i18n date)
93 sBrowserVersion = mid( sAgent, stResult.pos[2], stResult.len[2] );
94 return ( sBrowserVersion GTE 20030210 );
95 }
96 }
97
98 return false;
99 </cfscript>
100 </cffunction>
101
102 <cffunction
103 name="showTextArea"
104 access="private"
105 output="true"
106 returnType="void"
107 hint="Create a textarea field for non-compatible browsers."
108 >
109
110 <cfscript>
111 // append unit "px" for numeric width and/or height values
112 if( isNumeric( this.width ) )
113 this.width = this.width & "px";
114 if( isNumeric( this.height ) )
115 this.height = this.height & "px";
116 </cfscript>
117
118 <cfoutput>
119 <div>
120 <textarea name="#this.instanceName#" rows="4" cols="40" style="WIDTH: #width#; HEIGHT: #height#" wrap="virtual">#HTMLEditFormat(this.value)#</textarea>
121 </div>
122 </cfoutput>
123
124 </cffunction>
125
126 <cffunction
127 name="showHTMLEditor"
128 access="private"
129 output="true"
130 returnType="void"
131 hint="Create the html editor instance for compatible browsers."
132 >
133
134 <cfscript>
135 var sURL = "";
136
137 // try to fix the basePath, if ending slash is missing
138 if( len( this.basePath) and right( this.basePath, 1 ) is not "/" )
139 this.basePath = this.basePath & "/";
140
141 // construct the url
142 sURL = this.basePath & "editor/fckeditor.html?InstanceName=" & this.instanceName;
143
144 // append toolbarset name to the url
145 if( len( this.toolbarSet ) )
146 sURL = sURL & "&amp;Toolbar=" & this.toolbarSet;
147 </cfscript>
148
149 <cfoutput>
150 <div>
151 <input type="hidden" id="#this.instanceName#" name="#this.instanceName#" value="#HTMLEditFormat(this.value)#" />
152 <input type="hidden" id="#this.instanceName#___Config" value="#GetConfigFieldString()#" />
153 <iframe id="#this.instanceName#___Frame" src="#sURL#" width="#this.width#" height="#this.height#" frameborder="no" scrolling="no"></iframe>
154 </div>
155 </cfoutput>
156
157 </cffunction>
158
159 <cffunction
160 name="GetConfigFieldString"
161 access="private"
162 output="false"
163 returnType="string"
164 hint="Create configuration string: Key1=Value1&Key2=Value2&... (Key/Value:HTML encoded)"
165 >
166
167 <cfscript>
168 var sParams = "";
169 var key = "";
170 var fieldValue = "";
171 var fieldLabel = "";
172 var lConfigKeys = "";
173 var iPos = "";
174
175 /**
176 * CFML doesn't store casesensitive names for structure keys, but the configuration names must be casesensitive for js.
177 * So we need to find out the correct case for the configuration keys.
178 * We "fix" this by comparing the caseless configuration keys to a list of all available configuration options in the correct case.
179 * changed 20041206 hk@lwd.de (improvements are welcome!)
180 */
181 lConfigKeys = lConfigKeys & "CustomConfigurationsPath,EditorAreaCSS,DocType,BaseHref,FullPage,Debug,SkinPath,PluginsPath,AutoDetectLanguage,DefaultLanguage,ContentLangDirection,EnableXHTML,EnableSourceXHTML,ProcessHTMLEntities,IncludeLatinEntities,IncludeGreekEntities";
182 lConfigKeys = lConfigKeys & ",FillEmptyBlocks,FormatSource,FormatOutput,FormatIndentator,GeckoUseSPAN,StartupFocus,ForcePasteAsPlainText,ForceSimpleAmpersand,TabSpaces,ShowBorders,UseBROnCarriageReturn";
183 lConfigKeys = lConfigKeys & ",ToolbarStartExpanded,ToolbarCanCollapse,ToolbarSets,ContextMenu,FontColors,FontNames,FontSizes,FontFormats,StylesXmlPath,SpellChecker,IeSpellDownloadUrl,MaxUndoLevels";
184 lConfigKeys = lConfigKeys & ",LinkBrowser,LinkBrowserURL,LinkBrowserWindowWidth,LinkBrowserWindowHeight";
185 lConfigKeys = lConfigKeys & ",LinkUpload,LinkUploadURL,LinkUploadWindowWidth,LinkUploadWindowHeight,LinkUploadAllowedExtensions,LinkUploadDeniedExtensions";
186 lConfigKeys = lConfigKeys & ",ImageBrowser,ImageBrowserURL,ImageBrowserWindowWidth,ImageBrowserWindowHeight,SmileyPath,SmileyImages,SmileyColumns,SmileyWindowWidth,SmileyWindowHeight";
187
188 for( key in this.config )
189 {
190 iPos = listFindNoCase( lConfigKeys, key );
191 if( iPos GT 0 )
192 {
193 if( len( sParams ) )
194 sParams = sParams & "&amp;";
195
196 fieldValue = this.config[key];
197 fieldName = listGetAt( lConfigKeys, iPos );
198
199 // set all boolean possibilities in CFML to true/false values
200 if( isBoolean( fieldValue) and fieldValue )
201 fieldValue = "true";
202 else if( isBoolean( fieldValue) )
203 fieldValue = "false";
204
205 sParams = sParams & HTMLEditFormat( fieldName ) & '=' & HTMLEditFormat( fieldValue );
206 }
207 }
208 return sParams;
209 </cfscript>
210
211 </cffunction>
212
213 </cfcomponent>