[1257] | 1 | <cfsetting enablecfoutputonly="Yes">
|
---|
| 2 | <!---
|
---|
| 3 | * FCKeditor - The text editor for internet
|
---|
| 4 | * Copyright (C) 2003-2006 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.cfm
|
---|
| 15 | * ColdFusion integration.
|
---|
| 16 | * Note this module is created for use with Coldfusion 4.52 and above.
|
---|
| 17 | * For a cfc version for coldfusion mx check the fckeditor.cfc.
|
---|
| 18 | *
|
---|
| 19 | * Syntax:
|
---|
| 20 | *
|
---|
| 21 | * <cfmodule name="path/to/cfc/fckeditor"
|
---|
| 22 | * instanceName="myEditor"
|
---|
| 23 | * toolbarSet="..."
|
---|
| 24 | * width="..."
|
---|
| 25 | * height="..:"
|
---|
| 26 | * value="..."
|
---|
| 27 | * config="..."
|
---|
| 28 | * >
|
---|
| 29 | *
|
---|
| 30 | * File Authors:
|
---|
| 31 | * Hendrik Kramer (hk@lwd.de)
|
---|
| 32 | * Mark Woods (mark@thickpaddy.com)
|
---|
| 33 | --->
|
---|
| 34 | <!--- ::
|
---|
| 35 | * Attribute validation
|
---|
| 36 | :: --->
|
---|
| 37 | <cfparam name="attributes.instanceName" type="string">
|
---|
| 38 | <cfparam name="attributes.width" type="string" default="100%">
|
---|
| 39 | <cfparam name="attributes.height" type="string" default="200">
|
---|
| 40 | <cfparam name="attributes.toolbarSet" type="string" default="Default">
|
---|
| 41 | <cfparam name="attributes.value" type="string" default="">
|
---|
| 42 | <cfparam name="attributes.basePath" type="string" default="/fckeditor/">
|
---|
| 43 | <cfparam name="attributes.checkBrowser" type="boolean" default="true">
|
---|
| 44 | <cfparam name="attributes.config" type="struct" default="#structNew()#">
|
---|
| 45 |
|
---|
| 46 | <!--- ::
|
---|
| 47 | * check browser compatibility via HTTP_USER_AGENT, if checkBrowser is true
|
---|
| 48 | :: --->
|
---|
| 49 |
|
---|
| 50 | <cfscript>
|
---|
| 51 | if( attributes.checkBrowser )
|
---|
| 52 | {
|
---|
| 53 | sAgent = lCase( cgi.HTTP_USER_AGENT );
|
---|
| 54 | isCompatibleBrowser = false;
|
---|
| 55 |
|
---|
| 56 | // check for Internet Explorer ( >= 5.5 )
|
---|
| 57 | if( find( "msie", sAgent ) and not find( "mac", sAgent ) and not find( "opera", sAgent ) )
|
---|
| 58 | {
|
---|
| 59 | // try to extract IE version
|
---|
| 60 | stResult = reFind( "msie ([5-9]\.[0-9])", sAgent, 1, true );
|
---|
| 61 | if( arrayLen( stResult.pos ) eq 2 )
|
---|
| 62 | {
|
---|
| 63 | // get IE Version
|
---|
| 64 | sBrowserVersion = mid( sAgent, stResult.pos[2], stResult.len[2] );
|
---|
| 65 | if( sBrowserVersion GTE 5.5 )
|
---|
| 66 | isCompatibleBrowser = true;
|
---|
| 67 | }
|
---|
| 68 | }
|
---|
| 69 | // check for Gecko ( >= 20030210+ )
|
---|
| 70 | else if( find( "gecko/", sAgent ) )
|
---|
| 71 | {
|
---|
| 72 | // try to extract Gecko version date
|
---|
| 73 | stResult = reFind( "gecko/(200[3-9][0-1][0-9][0-3][0-9])", sAgent, 1, true );
|
---|
| 74 | if( arrayLen( stResult.pos ) eq 2 )
|
---|
| 75 | {
|
---|
| 76 | // get Gecko build (i18n date)
|
---|
| 77 | sBrowserVersion = mid( sAgent, stResult.pos[2], stResult.len[2] );
|
---|
| 78 | if( sBrowserVersion GTE 20030210 )
|
---|
| 79 | isCompatibleBrowser = true;
|
---|
| 80 | }
|
---|
| 81 | }
|
---|
| 82 | }
|
---|
| 83 | else
|
---|
| 84 | {
|
---|
| 85 | // If we should not check browser compatibility, assume true
|
---|
| 86 | isCompatibleBrowser = true;
|
---|
| 87 | }
|
---|
| 88 | </cfscript>
|
---|
| 89 |
|
---|
| 90 | <cfif isCompatibleBrowser>
|
---|
| 91 |
|
---|
| 92 | <!--- ::
|
---|
| 93 | * show html editor area for compatible browser
|
---|
| 94 | :: --->
|
---|
| 95 |
|
---|
| 96 | <cfscript>
|
---|
| 97 | // try to fix the basePath, if ending slash is missing
|
---|
| 98 | if( len( attributes.basePath) and right( attributes.basePath, 1 ) is not "/" )
|
---|
| 99 | attributes.basePath = attributes.basePath & "/";
|
---|
| 100 |
|
---|
| 101 | // construct the url
|
---|
| 102 | sURL = attributes.basePath & "editor/fckeditor.html?InstanceName=" & attributes.instanceName;
|
---|
| 103 |
|
---|
| 104 | // append toolbarset name to the url
|
---|
| 105 | if( len( attributes.toolbarSet ) )
|
---|
| 106 | sURL = sURL & "&Toolbar=" & attributes.toolbarSet;
|
---|
| 107 |
|
---|
| 108 | // create configuration string: Key1=Value1&Key2=Value2&... (Key/Value:HTML encoded)
|
---|
| 109 |
|
---|
| 110 | /**
|
---|
| 111 | * CFML doesn't store casesensitive names for structure keys, but the configuration names must be casesensitive for js.
|
---|
| 112 | * So we need to find out the correct case for the configuration keys.
|
---|
| 113 | * We "fix" this by comparing the caseless configuration keys to a list of all available configuration options in the correct case.
|
---|
| 114 | * changed 20041206 hk@lwd.de (improvements are welcome!)
|
---|
| 115 | */
|
---|
| 116 | lConfigKeys = "";
|
---|
| 117 | lConfigKeys = lConfigKeys & "CustomConfigurationsPath,EditorAreaCSS,DocType,BaseHref,FullPage,Debug,SkinPath,PluginsPath,AutoDetectLanguage,DefaultLanguage,ContentLangDirection,EnableXHTML,EnableSourceXHTML,ProcessHTMLEntities,IncludeLatinEntities,IncludeGreekEntities";
|
---|
| 118 | lConfigKeys = lConfigKeys & ",FillEmptyBlocks,FormatSource,FormatOutput,FormatIndentator,GeckoUseSPAN,StartupFocus,ForcePasteAsPlainText,ForceSimpleAmpersand,TabSpaces,ShowBorders,UseBROnCarriageReturn";
|
---|
| 119 | lConfigKeys = lConfigKeys & ",ToolbarStartExpanded,ToolbarCanCollapse,ToolbarSets,ContextMenu,FontColors,FontNames,FontSizes,FontFormats,StylesXmlPath,SpellChecker,IeSpellDownloadUrl,MaxUndoLevels";
|
---|
| 120 | lConfigKeys = lConfigKeys & ",LinkBrowser,LinkBrowserURL,LinkBrowserWindowWidth,LinkBrowserWindowHeight";
|
---|
| 121 | lConfigKeys = lConfigKeys & ",LinkUpload,LinkUploadURL,LinkUploadWindowWidth,LinkUploadWindowHeight,LinkUploadAllowedExtensions,LinkUploadDeniedExtensions";
|
---|
| 122 | lConfigKeys = lConfigKeys & ",ImageBrowser,ImageBrowserURL,ImageBrowserWindowWidth,ImageBrowserWindowHeight,SmileyPath,SmileyImages,SmileyColumns,SmileyWindowWidth,SmileyWindowHeight";
|
---|
| 123 |
|
---|
| 124 | sConfig = "";
|
---|
| 125 |
|
---|
| 126 | for( key in attributes.config )
|
---|
| 127 | {
|
---|
| 128 | iPos = listFindNoCase( lConfigKeys, key );
|
---|
| 129 | if( iPos GT 0 )
|
---|
| 130 | {
|
---|
| 131 | if( len( sConfig ) )
|
---|
| 132 | sConfig = sConfig & "&";
|
---|
| 133 |
|
---|
| 134 | fieldValue = attributes.config[key];
|
---|
| 135 | fieldName = listGetAt( lConfigKeys, iPos );
|
---|
| 136 |
|
---|
| 137 | sConfig = sConfig & urlEncodedFormat( fieldName ) & '=' & urlEncodedFormat( fieldValue );
|
---|
| 138 | }
|
---|
| 139 | }
|
---|
| 140 | </cfscript>
|
---|
| 141 |
|
---|
| 142 | <cfoutput>
|
---|
| 143 | <div>
|
---|
| 144 | <input type="hidden" id="#attributes.instanceName#" name="#attributes.instanceName#" value="#HTMLEditFormat(attributes.value)#" style="display:none" />
|
---|
| 145 | <input type="hidden" id="#attributes.instanceName#___Config" value="#sConfig#" style="display:none" />
|
---|
| 146 | <iframe id="#attributes.instanceName#___Frame" src="#sURL#" width="#attributes.width#" height="#attributes.height#" frameborder="0" scrolling="no"></iframe>
|
---|
| 147 | </div>
|
---|
| 148 | </cfoutput>
|
---|
| 149 |
|
---|
| 150 | <cfelse>
|
---|
| 151 |
|
---|
| 152 | <!--- ::
|
---|
| 153 | * show plain textarea for non compatible browser
|
---|
| 154 | :: --->
|
---|
| 155 |
|
---|
| 156 | <cfscript>
|
---|
| 157 | // append unit "px" for numeric width and/or height values
|
---|
| 158 | if( isNumeric( attributes.width ) )
|
---|
| 159 | attributes.width = attributes.width & "px";
|
---|
| 160 | if( isNumeric( attributes.height ) )
|
---|
| 161 | attributes.height = attributes.height & "px";
|
---|
| 162 | </cfscript>
|
---|
| 163 |
|
---|
| 164 | <!--- Fixed Bug ##1075166. hk@lwd.de 20041206 --->
|
---|
| 165 | <cfoutput>
|
---|
| 166 | <div>
|
---|
| 167 | <textarea name="#attributes.instanceName#" rows="4" cols="40" style="WIDTH: #attributes.width#; HEIGHT: #attributes.height#">#HTMLEditFormat(attributes.value)#</textarea>
|
---|
| 168 | </div>
|
---|
| 169 | </cfoutput>
|
---|
| 170 |
|
---|
| 171 | </cfif>
|
---|
| 172 |
|
---|
| 173 | <cfsetting enablecfoutputonly="No"><cfexit method="exittag"> |
---|