~ubuntu-branches/ubuntu/natty/moin/natty-updates

« back to all changes in this revision

Viewing changes to wiki/htdocs/applets/FCKeditor/fckeditor.cfc

  • Committer: Bazaar Package Importer
  • Author(s): Jonas Smedegaard
  • Date: 2008-06-22 21:17:13 UTC
  • mto: This revision was merged to the branch mainline in revision 18.
  • Revision ID: james.westby@ubuntu.com-20080622211713-inlv5k4eifxckelr
ImportĀ upstreamĀ versionĀ 1.7.0

Show diffs side-by-side

added added

removed removed

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