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