/EQT_V1/EQTWebApp/fckeditor/fckeditor.cfm

http://sgsoft-las.googlecode.com/ · ColdFusion · 159 lines · 106 code · 9 blank · 44 comment · 4 complexity · 25e020d091e1515af0f152a93513bcab MD5 · raw file

  1. <cfsetting enablecfoutputonly="Yes">
  2. <!---
  3. * FCKeditor - The text editor for Internet - http://www.fckeditor.net
  4. * Copyright (C) 2003-2009 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. * ColdFusion integration.
  23. * Note this module is created for use with Coldfusion 4.52 and above.
  24. * For a cfc version for coldfusion mx check the fckeditor.cfc.
  25. *
  26. * Syntax:
  27. *
  28. * <cfmodule name="path/to/cfc/fckeditor"
  29. * instanceName="myEditor"
  30. * toolbarSet="..."
  31. * width="..."
  32. * height="..:"
  33. * value="..."
  34. * config="..."
  35. * >
  36. --->
  37. <!--- ::
  38. * Attribute validation
  39. :: --->
  40. <cfparam name="attributes.instanceName" type="string">
  41. <cfparam name="attributes.width" type="string" default="100%">
  42. <cfparam name="attributes.height" type="string" default="200">
  43. <cfparam name="attributes.toolbarSet" type="string" default="Default">
  44. <cfparam name="attributes.value" type="string" default="">
  45. <cfparam name="attributes.basePath" type="string" default="/fckeditor/">
  46. <cfparam name="attributes.checkBrowser" type="boolean" default="true">
  47. <cfparam name="attributes.config" type="struct" default="#structNew()#">
  48. <cfinclude template="fckutils.cfm">
  49. <!--- ::
  50. * check browser compatibility via HTTP_USER_AGENT, if checkBrowser is true
  51. :: --->
  52. <cfscript>
  53. if( attributes.checkBrowser )
  54. {
  55. isCompatibleBrowser = FCKeditor_IsCompatibleBrowser();
  56. }
  57. else
  58. {
  59. // If we should not check browser compatibility, assume true
  60. isCompatibleBrowser = true;
  61. }
  62. </cfscript>
  63. <cfif isCompatibleBrowser>
  64. <!--- ::
  65. * show html editor area for compatible browser
  66. :: --->
  67. <cfscript>
  68. // try to fix the basePath, if ending slash is missing
  69. if( len( attributes.basePath) and right( attributes.basePath, 1 ) is not "/" )
  70. attributes.basePath = attributes.basePath & "/";
  71. // construct the url
  72. sURL = attributes.basePath & "editor/fckeditor.html?InstanceName=" & attributes.instanceName;
  73. // append toolbarset name to the url
  74. if( len( attributes.toolbarSet ) )
  75. sURL = sURL & "&amp;Toolbar=" & attributes.toolbarSet;
  76. // create configuration string: Key1=Value1&Key2=Value2&... (Key/Value:HTML encoded)
  77. /**
  78. * CFML doesn't store casesensitive names for structure keys, but the configuration names must be casesensitive for js.
  79. * So we need to find out the correct case for the configuration keys.
  80. * We "fix" this by comparing the caseless configuration keys to a list of all available configuration options in the correct case.
  81. * changed 20041206 hk@lwd.de (improvements are welcome!)
  82. */
  83. lConfigKeys = "";
  84. lConfigKeys = lConfigKeys & "CustomConfigurationsPath,EditorAreaCSS,ToolbarComboPreviewCSS,DocType";
  85. lConfigKeys = lConfigKeys & ",BaseHref,FullPage,Debug,AllowQueryStringDebug,SkinPath";
  86. lConfigKeys = lConfigKeys & ",PreloadImages,PluginsPath,AutoDetectLanguage,DefaultLanguage,ContentLangDirection";
  87. lConfigKeys = lConfigKeys & ",ProcessHTMLEntities,IncludeLatinEntities,IncludeGreekEntities,ProcessNumericEntities,AdditionalNumericEntities";
  88. lConfigKeys = lConfigKeys & ",FillEmptyBlocks,FormatSource,FormatOutput,FormatIndentator";
  89. lConfigKeys = lConfigKeys & ",StartupFocus,ForcePasteAsPlainText,AutoDetectPasteFromWord,ForceSimpleAmpersand";
  90. lConfigKeys = lConfigKeys & ",TabSpaces,ShowBorders,SourcePopup,ToolbarStartExpanded,ToolbarCanCollapse";
  91. lConfigKeys = lConfigKeys & ",IgnoreEmptyParagraphValue,FloatingPanelsZIndex,TemplateReplaceAll,TemplateReplaceCheckbox";
  92. lConfigKeys = lConfigKeys & ",ToolbarLocation,ToolbarSets,EnterMode,ShiftEnterMode,Keystrokes";
  93. lConfigKeys = lConfigKeys & ",ContextMenu,BrowserContextMenuOnCtrl,FontColors,FontNames,FontSizes";
  94. lConfigKeys = lConfigKeys & ",FontFormats,StylesXmlPath,TemplatesXmlPath,SpellChecker,IeSpellDownloadUrl";
  95. lConfigKeys = lConfigKeys & ",SpellerPagesServerScript,FirefoxSpellChecker,MaxUndoLevels,DisableObjectResizing,DisableFFTableHandles";
  96. lConfigKeys = lConfigKeys & ",LinkDlgHideTarget ,LinkDlgHideAdvanced,ImageDlgHideLink ,ImageDlgHideAdvanced,FlashDlgHideAdvanced";
  97. lConfigKeys = lConfigKeys & ",ProtectedTags,BodyId,BodyClass,DefaultLinkTarget,CleanWordKeepsStructure";
  98. lConfigKeys = lConfigKeys & ",LinkBrowser,LinkBrowserURL,LinkBrowserWindowWidth,LinkBrowserWindowHeight,ImageBrowser";
  99. lConfigKeys = lConfigKeys & ",ImageBrowserURL,ImageBrowserWindowWidth,ImageBrowserWindowHeight,FlashBrowser,FlashBrowserURL";
  100. lConfigKeys = lConfigKeys & ",FlashBrowserWindowWidth ,FlashBrowserWindowHeight,LinkUpload,LinkUploadURL,LinkUploadWindowWidth";
  101. lConfigKeys = lConfigKeys & ",LinkUploadWindowHeight,LinkUploadAllowedExtensions,LinkUploadDeniedExtensions,ImageUpload,ImageUploadURL";
  102. lConfigKeys = lConfigKeys & ",ImageUploadAllowedExtensions,ImageUploadDeniedExtensions,FlashUpload,FlashUploadURL,FlashUploadAllowedExtensions";
  103. lConfigKeys = lConfigKeys & ",FlashUploadDeniedExtensions,SmileyPath,SmileyImages,SmileyColumns,SmileyWindowWidth,SmileyWindowHeight";
  104. sConfig = "";
  105. for( key in attributes.config )
  106. {
  107. iPos = listFindNoCase( lConfigKeys, key );
  108. if( iPos GT 0 )
  109. {
  110. if( len( sConfig ) )
  111. sConfig = sConfig & "&amp;";
  112. fieldValue = attributes.config[key];
  113. fieldName = listGetAt( lConfigKeys, iPos );
  114. sConfig = sConfig & urlEncodedFormat( fieldName ) & '=' & urlEncodedFormat( fieldValue );
  115. }
  116. }
  117. </cfscript>
  118. <cfoutput>
  119. <input type="hidden" id="#attributes.instanceName#" name="#attributes.instanceName#" value="#HTMLEditFormat(attributes.value)#" style="display:none" />
  120. <input type="hidden" id="#attributes.instanceName#___Config" value="#sConfig#" style="display:none" />
  121. <iframe id="#attributes.instanceName#___Frame" src="#sURL#" width="#attributes.width#" height="#attributes.height#" frameborder="0" scrolling="no"></iframe>
  122. </cfoutput>
  123. <cfelse>
  124. <!--- ::
  125. * show plain textarea for non compatible browser
  126. :: --->
  127. <cfscript>
  128. // append unit "px" for numeric width and/or height values
  129. if( isNumeric( attributes.width ) )
  130. attributes.width = attributes.width & "px";
  131. if( isNumeric( attributes.height ) )
  132. attributes.height = attributes.height & "px";
  133. </cfscript>
  134. <!--- Fixed Bug ##1075166. hk@lwd.de 20041206 --->
  135. <cfoutput>
  136. <textarea name="#attributes.instanceName#" rows="4" cols="40" style="WIDTH: #attributes.width#; HEIGHT: #attributes.height#">#HTMLEditFormat(attributes.value)#</textarea>
  137. </cfoutput>
  138. </cfif>
  139. <cfsetting enablecfoutputonly="No"><cfexit method="exittag">