[ Index ]
 

Code source de FCKeditor 2.4

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/ -> fckeditor.cfc (source)

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


Généré le : Sun Feb 25 15:28:05 2007 par Balluche grâce à PHPXref 0.7