[ Index ]

PHP Cross Reference of Drupal 6 (gatewave)

title

Body

[close]

/sites/all/libraries/ckeditor/_samples/php/ -> events.php (source)

   1  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
   2  <!--
   3  Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
   4  For licensing, see LICENSE.html or http://ckeditor.com/license
   5  -->
   6  <html xmlns="http://www.w3.org/1999/xhtml">
   7  <head>
   8      <title>Sample - CKEditor</title>
   9      <meta content="text/html; charset=utf-8" http-equiv="content-type"/>
  10      <link href="../sample.css" rel="stylesheet" type="text/css"/>
  11  </head>
  12  <body>
  13      <h1>
  14          CKEditor Sample
  15      </h1>
  16      <!-- This <div> holds alert messages to be display in the sample page. -->
  17      <div id="alerts">
  18          <noscript>
  19              <p>
  20                  <strong>CKEditor requires JavaScript to run</strong>. In a browser with no JavaScript
  21                  support, like yours, you should still see the contents (HTML data) and you should
  22                  be able to edit it normally, without a rich editor interface.
  23              </p>
  24          </noscript>
  25      </div>
  26      <!-- This <fieldset> holds the HTML that you will usually find in your pages. -->
  27      <fieldset title="Output">
  28          <legend>Output</legend>
  29          <form action="../sample_posteddata.php" method="post">
  30              <p>
  31                  <label>Editor 1:</label><br/>
  32              </p>
  33  <?php
  34  
  35  /**

  36   * Adds global event, will hide "Target" tab in Link dialog in all instances.

  37   */
  38  function CKEditorHideLinkTargetTab(&$CKEditor) {
  39  
  40      $function = 'function (ev) {
  41          // Take the dialog name and its definition from the event data

  42          var dialogName = ev.data.name;
  43          var dialogDefinition = ev.data.definition;
  44  
  45          // Check if the definition is from the Link dialog.

  46          if ( dialogName == "link" )
  47              dialogDefinition.removeContents("target")
  48      }';
  49  
  50      $CKEditor->addGlobalEventHandler('dialogDefinition', $function);
  51  }
  52  
  53  /**

  54   * Adds global event, will notify about opened dialog.

  55   */
  56  function CKEditorNotifyAboutOpenedDialog(&$CKEditor) {
  57      $function = 'function (evt) {
  58          alert("Loading dialog: " + evt.data.name);
  59      }';
  60  
  61      $CKEditor->addGlobalEventHandler('dialogDefinition', $function);
  62  }
  63  
  64  // Include CKEditor class.

  65  include ("../../ckeditor.php");
  66  
  67  // Create class instance.

  68  $CKEditor = new CKEditor();
  69  
  70  // Set configuration option for all editors.

  71  $CKEditor->config['width'] = 750;
  72  
  73  // Path to CKEditor directory, ideally instead of relative dir, use an absolute path:

  74  //   $CKEditor->basePath = '/ckeditor/'

  75  // If not set, CKEditor will try to detect the correct path.

  76  $CKEditor->basePath = '../../';
  77  
  78  // The initial value to be displayed in the editor.

  79  $initialValue = '<p>This is some <strong>sample text</strong>. You are using <a href="http://ckeditor.com/">CKEditor</a>.</p>';
  80  
  81  // Event that will be handled only by the first editor.

  82  $CKEditor->addEventHandler('instanceReady', 'function (evt) {
  83      alert("Loaded editor: " + evt.editor.name);
  84  }');
  85  
  86  // Create first instance.

  87  $CKEditor->editor("editor1", $initialValue);
  88  
  89  // Clear event handlers, instances that will be created later will not have

  90  // the 'instanceReady' listener defined a couple of lines above.

  91  $CKEditor->clearEventHandlers();
  92  ?>
  93              <p>
  94                  <label>Editor 2:</label><br/>
  95              </p>
  96  <?php
  97  // Configuration that will be used only by the second editor.

  98  $config['width'] = '600';
  99  $config['toolbar'] = 'Basic';
 100  
 101  // Add some global event handlers (for all editors).

 102  CKEditorHideLinkTargetTab($CKEditor);
 103  CKEditorNotifyAboutOpenedDialog($CKEditor);
 104  
 105  // Event that will be handled only by the second editor.

 106  // Instead of calling addEventHandler(), events may be passed as an argument.

 107  $events['instanceReady'] = 'function (evt) {
 108      alert("Loaded second editor: " + evt.editor.name);
 109  }';
 110  
 111  // Create second instance.

 112  $CKEditor->editor("editor2", $initialValue, $config, $events);
 113  ?>
 114              <p>
 115                  <input type="submit" value="Submit"/>
 116              </p>
 117          </form>
 118      </fieldset>
 119      <div id="footer">
 120          <hr />
 121          <p>
 122              CKEditor - The text editor for Internet - <a href="http://ckeditor.com/">http://ckeditor.com</a>
 123          </p>
 124          <p id="copy">
 125              Copyright &copy; 2003-2010, <a href="http://cksource.com/">CKSource</a> - Frederico
 126              Knabben. All rights reserved.
 127          </p>
 128      </div>
 129  </body>
 130  </html>


Generated: Thu Mar 24 11:18:33 2011 Cross-referenced by PHPXref 0.7