Changeset 697


Ignore:
Timestamp:
08/21/2007 05:49:31 PM (7 years ago)
Author:
wwalc
Message:

CF integration (ticket #73) part 1: added examples, CreateHtml and Create function

Location:
FCKeditor/trunk
Files:
7 added
3 edited

Legend:

Unmodified
Added
Removed
  • FCKeditor/trunk/_samples/cfm/sample01.cfm

    r136 r697  
    1 <cfsetting enablecfoutputonly="true" showdebugoutput="false"> 
     1<cfsetting enablecfoutputonly="true"> 
    22<!--- 
    33 * FCKeditor - The text editor for Internet - http://www.fckeditor.net 
     
    3232        <link href="../sample.css" rel="stylesheet" type="text/css" /> 
    3333</head> 
    34  
    3534<body> 
    36  
    3735<h1>FCKeditor - ColdFusion - Sample 1</h1> 
    3836 
    39 This sample displays a normal HTML form with a FCKeditor with full features enabled; invoked by a ColdFusion Custom Tag / Module. 
     37This sample displays a normal HTML form with a FCKeditor with full features enabled. 
    4038<hr> 
    41 <form method="POST" action="#cgi.script_name#"> 
     39 
     40<form method="POST" action="sampleposteddata.cfm"> 
    4241</cfoutput> 
     42 
     43<!--- Calculate basepath for FCKeditor. It's in the folder right above _samples ---> 
     44<cfset basePath = Left( cgi.script_name, FindNoCase( '_samples', cgi.script_name ) - 1 )> 
    4345 
    4446<cfmodule 
    4547        template="../../fckeditor.cfm" 
    46         basePath="#Left(cgi.script_name, FindNoCase('_samples', cgi.script_name)-1)#" 
     48        basePath="#basePath#" 
    4749        instanceName="myEditor" 
    4850        value='This is some sample text. You are using <a href="http://fckeditor.net/" target="_blank">FCKeditor</a>.' 
     
    5052        height="200" 
    5153> 
     54 
    5255<cfoutput> 
    5356<br /> 
    5457<input type="submit" value="Submit"> 
    55 <br /> 
     58<hr /> 
    5659</form> 
    57 </cfoutput> 
    58  
    59 <cfif isDefined( 'FORM.fieldnames' )> 
    60         <cfoutput> 
    61         <hr /> 
    62         <style> 
    63         <!-- 
    64                 td, th { font: 11px Verdana, Arial, Helv, Helvetica, sans-serif; } 
    65         --> 
    66         </style> 
    67         <table border="1" cellspacing="0" cellpadding="2" bordercolor="darkblue" bordercolordark="darkblue" bordercolorlight="darkblue"> 
    68         <tr> 
    69                 <th colspan="2" bgcolor="darkblue"><font color="white"><strong>Dump of FORM Variables</strong></font></th> 
    70         </tr> 
    71         <tr> 
    72                 <td bgcolor="lightskyblue">FieldNames</td> 
    73                 <td>#FORM.fieldNames#</td> 
    74         </tr> 
    75         <cfloop list="#FORM.fieldnames#" index="key"> 
    76         <tr> 
    77                 <td valign="top" bgcolor="lightskyblue">#key#</td> 
    78                 <td>#HTMLEditFormat(evaluate("FORM.#key#"))#</td> 
    79         </tr> 
    80         </cfloop> 
    81         </table> 
    82         </cfoutput> 
    83 </cfif> 
    84  
    8560</body> 
    8661</html> 
     62</cfoutput> 
    8763<cfsetting enablecfoutputonly="false"> 
  • FCKeditor/trunk/_samples/cfm/sample02_mx.cfm

    r132 r697  
    2323---> 
    2424 
    25 <!--- :: 
    26           * You must set the url path to the base directory for your media files (images, flash, files) 
    27           * The best position for this variable is in your Application.cfm file 
    28           * 
    29           * Possible variable scopes are: 
    30           * <cfset APPLICATION.userFilesPath = "/userfiles/"> 
    31           * OR: 
    32           * <cfset SERVER.userFilesPath = "/userfiles/"> 
    33           * OR: 
    34           * <cfset request.FCKeditor.userFilesPath = "/userfiles/"> 
    35           * OR: 
    36           * <cfset application.FCKeditor.userFilesPath = "/userfiles/"> 
    37           * OR: 
    38           * <cfset server.FCKeditor.userFilesPath = "/userfiles/"> 
    39           * 
    40           * Note #1: Do _not_ set the physical directory on your server, only a path relative to your current webroot 
    41           * Note #2: Directories will be automatically created 
    42           :: ---> 
    43  
    4425<cfoutput> 
    4526<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 
     
    5031        <meta name="robots" content="noindex, nofollow"> 
    5132        <link href="../sample.css" rel="stylesheet" type="text/css" /> 
     33                <script type="text/javascript"> 
     34 
     35function FCKeditor_OnComplete( editorInstance ) 
     36{ 
     37        var oCombo = document.getElementById( 'cmbLanguages' ) ; 
     38        for ( code in editorInstance.Language.AvailableLanguages ) 
     39        { 
     40                AddComboOption( oCombo, editorInstance.Language.AvailableLanguages[code] + ' (' + code + ')', code ) ; 
     41        } 
     42        oCombo.value = editorInstance.Language.ActiveLanguage.Code ; 
     43} 
     44 
     45function AddComboOption(combo, optionText, optionValue) 
     46{ 
     47        var oOption = document.createElement("OPTION") ; 
     48 
     49        combo.options.add(oOption) ; 
     50 
     51        oOption.innerHTML = optionText ; 
     52        oOption.value     = optionValue ; 
     53 
     54        return oOption ; 
     55} 
     56 
     57function ChangeLanguage( languageCode ) 
     58{ 
     59        window.location.href = window.location.pathname + "?Lang=" + languageCode ; 
     60} 
     61                </script> 
    5262</head> 
    5363<body> 
    5464<h1>FCKeditor - ColdFusion Component (CFC) - Sample 2</h1> 
    55  
    56 This sample displays a normal HTML form with a FCKeditor with full features enabled; invoked by a ColdFusion Component. 
     65This sample shows the editor in all its available languages. 
    5766<hr> 
    58  
    59 <form method="POST" action="#cgi.script_name#"> 
    6067</cfoutput> 
    61  
    6268<cfif listFirst( server.coldFusion.productVersion ) LT 6> 
    6369        <cfoutput><br><em style="color: red;">This sample works only with a ColdFusion MX server and higher, because it uses some advantages of this version.</em></cfoutput> 
    6470        <cfabort> 
    6571</cfif> 
     72<cfoutput> 
     73<table cellpadding="0" cellspacing="0" border="0"> 
     74        <tr> 
     75                <td> 
     76                        Select a language:&nbsp; 
     77                </td> 
     78                <td> 
     79                        <select id="cmbLanguages" onchange="ChangeLanguage(this.value);"> 
     80                        </select> 
     81                </td> 
     82        </tr> 
     83</table> 
     84<br> 
     85<form action="sampleposteddata.cfm" method="post" target="_blank"> 
     86</cfoutput> 
     87        <cfscript> 
     88                // Calculate basepath for FCKeditor. It's in the folder right above _samples 
     89                basePath = Left( cgi.script_name, FindNoCase( '_samples', cgi.script_name ) - 1 ) ; 
    6690 
    67 <cfscript> 
    68         // Calculate basepath for FCKeditor. It's in the folder right above _samples 
    69         basePath = Left(cgi.script_name, FindNoCase('_samples', cgi.script_name)-1); 
    70  
    71         fckEditor = createObject("component", "#basePath#fckeditor"); 
    72         fckEditor.instanceName  = "myEditor"; 
    73         fckEditor.value                 = 'This is some sample text. You are using <a href="http://fckeditor.net/" target="_blank">FCKeditor</a>.'; 
    74         fckEditor.basePath              = basePath; 
    75         fckEditor.width                 = "100%"; 
    76         fckEditor.height                = 300; 
    77         fckEditor.create(); // create the editor. 
    78 </cfscript> 
    79  
     91                fckEditor = createObject( "component", "#basePath#fckeditor" ) ; 
     92                fckEditor.instanceName  = "myEditor" ; 
     93                fckEditor.value                 = 'This is some sample text. You are using <a href="http://fckeditor.net/" target="_blank">FCKeditor</a>.' ; 
     94                fckEditor.basePath              = basePath ; 
     95                if ( isDefined( "URL.Lang" ) ) 
     96                { 
     97                        fckEditor.config["AutoDetectLanguage"]          = false ; 
     98                        fckEditor.config["DefaultLanguage"]                     = HTMLEditFormat( URL.Lang ) ; 
     99                } 
     100                else 
     101                { 
     102                        fckEeditor.config["AutoDetectLanguage"]         = true ; 
     103                        fckEeditor.config["DefaultLanguage"]            = 'en' ; 
     104                } 
     105                fckEditor.create() ; // create the editor. 
     106        </cfscript> 
    80107<cfoutput> 
    81 <br /> 
    82 <input type="submit" value="Submit"> 
    83 <hr /> 
     108        <br> 
     109        <input type="submit" value="Submit"> 
     110        </form> 
     111</body> 
     112</html> 
    84113</cfoutput> 
    85  
    86 <cfdump 
    87         var="#FORM#" 
    88         label="Dump of FORM Variables" 
    89 > 
    90  
    91 <cfoutput></form></body></html></cfoutput> 
    92  
    93114<cfsetting enablecfoutputonly="false"> 
  • FCKeditor/trunk/fckeditor.cfc

    r387 r697  
    11<cfcomponent output="false" displayname="FCKeditor" hint="Create an instance of the FCKeditor."> 
     2 
    23<!--- 
    34 * FCKeditor - The text editor for Internet - http://www.fckeditor.net 
     
    4344 * limitation with the cfc invocation. 
    4445---> 
    45 <cffunction 
    46         name="create" 
     46 
     47<cffunction 
     48        name="Create" 
    4749        access="public" 
    4850        output="true" 
    4951        returntype="void" 
    50         hint="Initialize the FCKeditor instance." 
     52        hint="Outputs the editor HTML in the place where the function is called" 
     53> 
     54        <cfoutput> 
     55                #CreateHtml()# 
     56        </cfoutput> 
     57</cffunction> 
     58 
     59<cffunction 
     60        name="CreateHtml" 
     61        access="public" 
     62        output="false" 
     63        returntype="string" 
     64        hint="Retrieves the editor HTML" 
    5165> 
    5266 
     
    6377        // display the html editor or a plain textarea? 
    6478        if( isCompatible() ) 
    65                 showHTMLEditor(); 
     79                return getHtmlEditor(); 
    6680        else 
    67                 showTextArea(); 
     81                return getTextArea(); 
    6882        </cfscript> 
    6983 
     
    117131 
    118132<cffunction 
    119         name="showTextArea" 
    120         access="private" 
    121         output="true" 
    122         returnType="void" 
     133        name="getTextArea" 
     134        access="private" 
     135        output="false" 
     136        returnType="string" 
    123137        hint="Create a textarea field for non-compatible browsers." 
    124138> 
     139        <cfset var result = "" /> 
    125140 
    126141        <cfscript> 
     
    132147        </cfscript> 
    133148 
    134         <cfoutput> 
    135         <div> 
    136         <textarea name="#this.instanceName#" rows="4" cols="40" style="WIDTH: #this.width#; HEIGHT: #this.height#">#HTMLEditFormat(this.value)#</textarea> 
    137         </div> 
    138         </cfoutput> 
    139  
    140 </cffunction> 
    141  
    142 <cffunction 
    143         name="showHTMLEditor" 
    144         access="private" 
    145         output="true" 
    146         returnType="void" 
     149        <cfscript> 
     150        result = result & "<div>" & chr(13) & chr(10); 
     151        result = result & "<textarea name=""#this.instanceName#"" rows=""4"" cols=""40"" style=""WIDTH: #this.width#; HEIGHT: #this.height#"">#HTMLEditFormat(this.value)#</textarea>" & chr(13) & chr(10); 
     152        result = result & "</div>" & chr(13) & chr(10); 
     153        </cfscript> 
     154        <cfreturn result /> 
     155</cffunction> 
     156 
     157<cffunction 
     158        name="getHtmlEditor" 
     159        access="private" 
     160        output="false" 
     161        returnType="string" 
    147162        hint="Create the html editor instance for compatible browsers." 
    148163> 
    149164        <cfset var sURL = "" /> 
    150          
     165        <cfset var result = "" /> 
     166 
    151167        <cfscript> 
    152168        // try to fix the basePath, if ending slash is missing 
     
    162178        </cfscript> 
    163179 
    164         <cfoutput> 
    165         <div> 
    166         <input type="hidden" id="#this.instanceName#" name="#this.instanceName#" value="#HTMLEditFormat(this.value)#" style="display:none" /> 
    167         <input type="hidden" id="#this.instanceName#___Config" value="#GetConfigFieldString()#" style="display:none" /> 
    168         <iframe id="#this.instanceName#___Frame" src="#sURL#" width="#this.width#" height="#this.height#" frameborder="0" scrolling="no"></iframe> 
    169         </div> 
    170         </cfoutput> 
    171  
     180        <cfscript> 
     181        result = result & "<div>" & chr(13) & chr(10); 
     182        result = result & "<input type=""hidden"" id=""#this.instanceName#"" name=""#this.instanceName#"" value=""#HTMLEditFormat(this.value)#"" style=""display:none"" />" & chr(13) & chr(10); 
     183        result = result & "<input type=""hidden"" id=""#this.instanceName#___Config"" value=""#GetConfigFieldString()#"" style=""display:none"" />" & chr(13) & chr(10); 
     184        result = result & "<iframe id=""#this.instanceName#___Frame"" src=""#sURL#"" width=""#this.width#"" height=""#this.height#"" frameborder=""0"" scrolling=""no""></iframe>" & chr(13) & chr(10); 
     185        result = result & "</div>" & chr(13) & chr(10); 
     186        </cfscript> 
     187        <cfreturn result /> 
    172188</cffunction> 
    173189 
     
    205221        lConfigKeys = lConfigKeys & ",FontFormats,StylesXmlPath,TemplatesXmlPath,SpellChecker,IeSpellDownloadUrl"; 
    206222        lConfigKeys = lConfigKeys & ",SpellerPagesServerScript,FirefoxSpellChecker,MaxUndoLevels,DisableObjectResizing,DisableFFTableHandles"; 
    207         lConfigKeys = lConfigKeys & ",LinkDlgHideTarget ,LinkDlgHideAdvanced,ImageDlgHideLink   ,ImageDlgHideAdvanced,FlashDlgHideAdvanced"; 
     223        lConfigKeys = lConfigKeys & ",LinkDlgHideTarget,LinkDlgHideAdvanced,ImageDlgHideLink,ImageDlgHideAdvanced,FlashDlgHideAdvanced"; 
    208224        lConfigKeys = lConfigKeys & ",ProtectedTags,BodyId,BodyClass,DefaultLinkTarget,CleanWordKeepsStructure"; 
    209225        lConfigKeys = lConfigKeys & ",LinkBrowser,LinkBrowserURL,LinkBrowserWindowWidth,LinkBrowserWindowHeight,ImageBrowser"; 
    210226        lConfigKeys = lConfigKeys & ",ImageBrowserURL,ImageBrowserWindowWidth,ImageBrowserWindowHeight,FlashBrowser,FlashBrowserURL"; 
    211         lConfigKeys = lConfigKeys & ",FlashBrowserWindowWidth ,FlashBrowserWindowHeight,LinkUpload,LinkUploadURL,LinkUploadWindowWidth"; 
     227        lConfigKeys = lConfigKeys & ",FlashBrowserWindowWidth,FlashBrowserWindowHeight,LinkUpload,LinkUploadURL,LinkUploadWindowWidth"; 
    212228        lConfigKeys = lConfigKeys & ",LinkUploadWindowHeight,LinkUploadAllowedExtensions,LinkUploadDeniedExtensions,ImageUpload,ImageUploadURL"; 
    213229        lConfigKeys = lConfigKeys & ",ImageUploadAllowedExtensions,ImageUploadDeniedExtensions,FlashUpload,FlashUploadURL,FlashUploadAllowedExtensions"; 
Note: See TracChangeset for help on using the changeset viewer.
© 2003 – 2012 CKSource – Frederico Knabben. All rights reserved. | Terms of use | Privacy policy