by sun: Minor code clean-up.
[project/wysiwyg.git] / wysiwyg.api.php
CommitLineData
eb714832 1<?php
2// $Id$
3
4/**
5 * hook_wysiwyg_plugin(). Return an array of editor plugins.
6 *
7623c9ce 7 * @todo Completely outdated; rewrite necessary.
8 *
eb714832 9 * Each wysiwyg editor as well as each contrib module implementing an editor
10 * plugin has to return an associative array of available plugins. Each module
11 * can add one or more plugins and editor buttons.
12 *
13 * Notes for TinyMCE:
14 * A module is able to override almost all TinyMCE initialization settings.
15 * However, modules should only make use of that if a plugin really needs to,
16 * because customized configuration settings may clash with overrides by another
17 * module. TinyMCE automatically assigns the baseURL of your plugin to the plugin
18 * object. If you need to load or access additional files from your plugin
19 * directory, retrieve the path via this.baseURL. tinyMCE.baseURL returns the
20 * path of TinyMCE and not your module. For example:
21 * @code
22 * initInstance: function(inst) {
23 * tinyMCE.importCSS(inst.getDoc(), this.baseURL + '/myplugin.css');
24 * },
25 * @endcode
26 *
27 * @param string $editor
28 * An (lowercase) editor name to return plugins for.
29 * @return array
30 * An associative array having internal plugin names as keys, an array of
31 * plugin meta-information as values:
32 * - type: 'external' (optional); if omitted, wysiwyg editors will likely
33 * search for the plugin in their own plugins folder.
34 * - title: A human readable title of the plugin.
35 * - description: A (one-line) description of the plugin.
36 * - path: The patch to the javascript plugin.
37 * - callback: A Drupal menu callback returning the plugin UI. A plugin
38 * should return a callback *or* a path.
39 * - icon: An icon (usually 16x16 pixels) for the plugin button (optional).
40 * - ... Any other custom editor settings (optional).
41 *
42 * @todo Move this template into hooks.php.
43 */
44function hook_wysiwyg_plugin($editor) {
45 switch ($editor) {
46 case 'tinymce':
47 return array(
48 'myplugin' => array(
49 'type' => 'external',
50 'title' => t('My plugin title'),
51 'description' => t('My plugin title'),
52 // Regular callback URL for external TinyMCE plugins.
53 'path' => drupal_get_path('module', 'mymodule') .'/myplugin',
54 // Wysiwyg wrapper plugin AJAX callback.
55 'callback' => url('myplugin/browse'),
56 'icon' => drupal_get_path('module', 'mymodule') .'/myplugin/myplugin.png',
57 'extended_valid_elements' => array('tag[attribute1|attribute2=default_value]'),
58 // Might need to be set later on; after retrieving customized editor
59 // layout.
60 'theme_advanced_buttons1' => array(t('Button title (optional)') => 'myplugin'),
61 ),
62 );
63 }
64}
65