Xataface CKeditor Module 0.3
CKeditor Widget for Xataface
lib/ckeditor/_samples/php/events.php
Go to the documentation of this file.
00001 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
00002 <!--
00003 Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
00004 For licensing, see LICENSE.html or http://ckeditor.com/license
00005 -->
00006 <html xmlns="http://www.w3.org/1999/xhtml">
00007 <head>
00008         <title>Sample - CKEditor</title>
00009         <meta content="text/html; charset=utf-8" http-equiv="content-type"/>
00010         <link href="../sample.css" rel="stylesheet" type="text/css"/>
00011 </head>
00012 <body>
00013         <h1>
00014                 CKEditor Sample
00015         </h1>
00016         <!-- This <div> holds alert messages to be display in the sample page. -->
00017         <div id="alerts">
00018                 <noscript>
00019                         <p>
00020                                 <strong>CKEditor requires JavaScript to run</strong>. In a browser with no JavaScript
00021                                 support, like yours, you should still see the contents (HTML data) and you should
00022                                 be able to edit it normally, without a rich editor interface.
00023                         </p>
00024                 </noscript>
00025         </div>
00026         <!-- This <fieldset> holds the HTML that you will usually find in your pages. -->
00027         <fieldset title="Output">
00028                 <legend>Output</legend>
00029                 <form action="../sample_posteddata.php" method="post">
00030                         <p>
00031                                 <label>Editor 1:</label><br/>
00032                         </p>
00033 <?php
00034 
00038 function CKEditorHideLinkTargetTab(&$CKEditor) {
00039 
00040         $function = 'function (ev) {
00041                 // Take the dialog name and its definition from the event data
00042                 var dialogName = ev.data.name;
00043                 var dialogDefinition = ev.data.definition;
00044 
00045                 // Check if the definition is from the Link dialog.
00046                 if ( dialogName == "link" )
00047                         dialogDefinition.removeContents("target")
00048         }';
00049 
00050         $CKEditor->addGlobalEventHandler('dialogDefinition', $function);
00051 }
00052 
00056 function CKEditorNotifyAboutOpenedDialog(&$CKEditor) {
00057         $function = 'function (evt) {
00058                 alert("Loading dialog: " + evt.data.name);
00059         }';
00060 
00061         $CKEditor->addGlobalEventHandler('dialogDefinition', $function);
00062 }
00063 
00064 // Include CKEditor class.
00065 include("../../ckeditor.php");
00066 
00067 // Create class instance.
00068 $CKEditor = new CKEditor();
00069 
00070 // Set configuration option for all editors.
00071 $CKEditor->config['width'] = 750;
00072 
00073 // Path to CKEditor directory, ideally instead of relative dir, use an absolute path:
00074 //   $CKEditor->basePath = '/ckeditor/'
00075 // If not set, CKEditor will try to detect the correct path.
00076 $CKEditor->basePath = '../../';
00077 
00078 // The initial value to be displayed in the editor.
00079 $initialValue = '<p>This is some <strong>sample text</strong>. You are using <a href="http://ckeditor.com/">CKEditor</a>.</p>';
00080 
00081 // Event that will be handled only by the first editor.
00082 $CKEditor->addEventHandler('instanceReady', 'function (evt) {
00083         alert("Loaded editor: " + evt.editor.name);
00084 }');
00085 
00086 // Create first instance.
00087 $CKEditor->editor("editor1", $initialValue);
00088 
00089 // Clear event handlers, instances that will be created later will not have
00090 // the 'instanceReady' listener defined a couple of lines above.
00091 $CKEditor->clearEventHandlers();
00092 ?>
00093                         <p>
00094                                 <label>Editor 2:</label><br/>
00095                         </p>
00096 <?php
00097 // Configuration that will be used only by the second editor.
00098 $config['width'] = '600';
00099 $config['toolbar'] = 'Basic';
00100 
00101 // Add some global event handlers (for all editors).
00102 CKEditorHideLinkTargetTab($CKEditor);
00103 CKEditorNotifyAboutOpenedDialog($CKEditor);
00104 
00105 // Event that will be handled only by the second editor.
00106 // Instead of calling addEventHandler(), events may be passed as an argument.
00107 $events['instanceReady'] = 'function (evt) {
00108         alert("Loaded second editor: " + evt.editor.name);
00109 }';
00110 
00111 // Create second instance.
00112 $CKEditor->editor("editor2", $initialValue, $config, $events);
00113 ?>
00114                         <p>
00115                                 <input type="submit" value="Submit"/>
00116                         </p>
00117                 </form>
00118         </fieldset>
00119         <div id="footer">
00120                 <hr />
00121                 <p>
00122                         CKEditor - The text editor for Internet - <a href="http://ckeditor.com/">http://ckeditor.com</a>
00123                 </p>
00124                 <p id="copy">
00125                         Copyright &copy; 2003-2010, <a href="http://cksource.com/">CKSource</a> - Frederico
00126                         Knabben. All rights reserved.
00127                 </p>
00128         </div>
00129 </body>
00130 </html>
 All Data Structures Files Functions Variables