annotate sites/all/modules/wysiwyg/wysiwyg.api.php @ 9:830c812b520f

added smtp module
author root <root@paio.local>
date Mon, 28 Oct 2013 15:34:27 +0000
parents ff03f76ab3fe
children
rev   line source
danielebarchiesi@0 1 <?php
danielebarchiesi@0 2
danielebarchiesi@0 3 /**
danielebarchiesi@0 4 * @file
danielebarchiesi@0 5 * API documentation for Wysiwyg module.
danielebarchiesi@0 6 *
danielebarchiesi@0 7 * To implement a "Drupal plugin" button, you need to write a Wysiwyg plugin:
danielebarchiesi@0 8 * - Implement hook_wysiwyg_include_directory() to register the directory
danielebarchiesi@0 9 * containing plugin definitions.
danielebarchiesi@0 10 * - In each plugin definition file, implement hook_INCLUDE_plugin().
danielebarchiesi@0 11 * - For each plugin button, implement a JavaScript integration and an icon for
danielebarchiesi@0 12 * the button.
danielebarchiesi@0 13 *
danielebarchiesi@0 14 * @todo Icon: Recommended size and type of image.
danielebarchiesi@0 15 *
danielebarchiesi@0 16 * For example implementations you may want to look at
danielebarchiesi@0 17 * - Image Assist (img_assist)
danielebarchiesi@0 18 * - Teaser break plugin (plugins/break; part of WYSIWYG)
danielebarchiesi@0 19 * - IMCE (imce_wysiwyg)
danielebarchiesi@0 20 */
danielebarchiesi@0 21
danielebarchiesi@0 22 /**
danielebarchiesi@0 23 * Return an array of native editor plugins.
danielebarchiesi@0 24 *
danielebarchiesi@0 25 * Only to be used for native (internal) editor plugins.
danielebarchiesi@0 26 *
danielebarchiesi@0 27 * @see hook_wysiwyg_include_directory()
danielebarchiesi@0 28 *
danielebarchiesi@0 29 * @param $editor
danielebarchiesi@0 30 * The internal name of the currently processed editor.
danielebarchiesi@0 31 * @param $version
danielebarchiesi@0 32 * The version of the currently processed editor.
danielebarchiesi@0 33 *
danielebarchiesi@0 34 * @return
danielebarchiesi@0 35 * An associative array having internal plugin names as keys and an array of
danielebarchiesi@0 36 * plugin meta-information as values.
danielebarchiesi@0 37 */
danielebarchiesi@0 38 function hook_wysiwyg_plugin($editor, $version) {
danielebarchiesi@0 39 switch ($editor) {
danielebarchiesi@0 40 case 'tinymce':
danielebarchiesi@0 41 if ($version > 3) {
danielebarchiesi@0 42 return array(
danielebarchiesi@0 43 'myplugin' => array(
danielebarchiesi@0 44 // A URL to the plugin's homepage.
danielebarchiesi@0 45 'url' => 'http://drupal.org/project/img_assist',
danielebarchiesi@0 46 // The full path to the native editor plugin, no trailing slash.
danielebarchiesi@0 47 // Ignored when 'internal' is set to TRUE below.
danielebarchiesi@0 48 'path' => drupal_get_path('module', 'img_assist') . '/drupalimage',
danielebarchiesi@0 49 // The name of the plugin's main JavaScript file.
danielebarchiesi@0 50 // Ignored when 'internal' is set to TRUE below.
danielebarchiesi@0 51 // Default value depends on which editor the plugin is for.
danielebarchiesi@0 52 'filename' => 'editor_plugin.js',
danielebarchiesi@0 53 // A list of buttons provided by this native plugin. The key has to
danielebarchiesi@0 54 // match the corresponding JavaScript implementation. The value is
danielebarchiesi@0 55 // is displayed on the editor configuration form only.
danielebarchiesi@0 56 'buttons' => array(
danielebarchiesi@0 57 'img_assist' => t('Image Assist'),
danielebarchiesi@0 58 ),
danielebarchiesi@0 59 // A list of editor extensions provided by this native plugin.
danielebarchiesi@0 60 // Extensions are not displayed as buttons and touch the editor's
danielebarchiesi@0 61 // internals, so you should know what you are doing.
danielebarchiesi@0 62 'extensions' => array(
danielebarchiesi@0 63 'imce' => t('IMCE'),
danielebarchiesi@0 64 ),
danielebarchiesi@0 65 // A list of global, native editor configuration settings to
danielebarchiesi@0 66 // override. To be used rarely and only when required.
danielebarchiesi@0 67 'options' => array(
danielebarchiesi@0 68 'file_browser_callback' => 'imceImageBrowser',
danielebarchiesi@0 69 'inline_styles' => TRUE,
danielebarchiesi@0 70 ),
danielebarchiesi@0 71 // Boolean whether the editor needs to load this plugin. When TRUE,
danielebarchiesi@0 72 // the editor will automatically load the plugin based on the 'path'
danielebarchiesi@0 73 // variable provided. If FALSE, the plugin either does not need to
danielebarchiesi@0 74 // be loaded or is already loaded by something else on the page.
danielebarchiesi@0 75 // Most plugins should define TRUE here.
danielebarchiesi@0 76 'load' => TRUE,
danielebarchiesi@0 77 // Boolean whether this plugin is a native plugin, i.e. shipped with
danielebarchiesi@0 78 // the editor. Definition must be ommitted for plugins provided by
danielebarchiesi@0 79 // other modules. TRUE means 'path' and 'filename' above are ignored
danielebarchiesi@0 80 // and the plugin is instead loaded from the editor's plugin folder.
danielebarchiesi@0 81 'internal' => TRUE,
danielebarchiesi@0 82 // TinyMCE-specific: Additional HTML elements to allow in the markup.
danielebarchiesi@0 83 'extended_valid_elements' => array(
danielebarchiesi@0 84 'img[class|src|border=0|alt|title|width|height|align|name|style]',
danielebarchiesi@0 85 ),
danielebarchiesi@0 86 ),
danielebarchiesi@0 87 );
danielebarchiesi@0 88 }
danielebarchiesi@0 89 break;
danielebarchiesi@0 90 }
danielebarchiesi@0 91 }
danielebarchiesi@0 92
danielebarchiesi@0 93 /**
danielebarchiesi@0 94 * Register a directory containing Wysiwyg plugins.
danielebarchiesi@0 95 *
danielebarchiesi@0 96 * @param $type
danielebarchiesi@0 97 * The type of objects being collected: either 'plugins' or 'editors'.
danielebarchiesi@0 98 * @return
danielebarchiesi@0 99 * A sub-directory of the implementing module that contains the corresponding
danielebarchiesi@0 100 * plugin files. This directory must only contain integration files for
danielebarchiesi@0 101 * Wysiwyg module.
danielebarchiesi@0 102 */
danielebarchiesi@0 103 function hook_wysiwyg_include_directory($type) {
danielebarchiesi@0 104 switch ($type) {
danielebarchiesi@0 105 case 'plugins':
danielebarchiesi@0 106 // You can just return $type, if you place your Wysiwyg plugins into a
danielebarchiesi@0 107 // sub-directory named 'plugins'.
danielebarchiesi@0 108 return $type;
danielebarchiesi@0 109 }
danielebarchiesi@0 110 }
danielebarchiesi@0 111
danielebarchiesi@0 112 /**
danielebarchiesi@0 113 * Define a Wysiwyg plugin.
danielebarchiesi@0 114 *
danielebarchiesi@0 115 * Supposed to be used for "Drupal plugins" (cross-editor plugins) only.
danielebarchiesi@0 116 *
danielebarchiesi@0 117 * @see hook_wysiwyg_plugin()
danielebarchiesi@0 118 *
danielebarchiesi@0 119 * Each plugin file in the specified plugin directory of a module needs to
danielebarchiesi@0 120 * define meta information about the particular plugin provided.
danielebarchiesi@0 121 * The plugin's hook implementation function name is built out of the following:
danielebarchiesi@0 122 * - 'hook': The name of the module providing the plugin.
danielebarchiesi@0 123 * - 'INCLUDE': The basename of the file containing the plugin definition.
danielebarchiesi@0 124 * - 'plugin': Static.
danielebarchiesi@0 125 *
danielebarchiesi@0 126 * For example, if your module's name is 'mymodule' and
danielebarchiesi@0 127 * mymodule_wysiwyg_include_directory() returned 'plugins' as plugin directory,
danielebarchiesi@0 128 * and this directory contains an "awesome" plugin file named 'awesome.inc', i.e.
danielebarchiesi@0 129 * sites/all/modules/mymodule/plugins/awesome.inc
danielebarchiesi@0 130 * then the corresponding plugin hook function name is:
danielebarchiesi@0 131 * mymodule_awesome_plugin()
danielebarchiesi@0 132 *
danielebarchiesi@0 133 * @see hook_wysiwyg_include_directory()
danielebarchiesi@0 134 *
danielebarchiesi@0 135 * @return
danielebarchiesi@0 136 * Meta information about the buttons provided by this plugin.
danielebarchiesi@0 137 */
danielebarchiesi@0 138 function hook_INCLUDE_plugin() {
danielebarchiesi@0 139 $plugins['awesome'] = array(
danielebarchiesi@0 140 // The plugin's title; defaulting to its internal name ('awesome').
danielebarchiesi@0 141 'title' => t('Awesome plugin'),
danielebarchiesi@0 142 // The (vendor) homepage of this plugin; defaults to ''.
danielebarchiesi@0 143 'vendor url' => 'http://drupal.org/project/wysiwyg',
danielebarchiesi@0 144 // The path to the button's icon; defaults to
danielebarchiesi@0 145 // '/[path-to-module]/[plugins-directory]/[plugin-name]/images'.
danielebarchiesi@0 146 'icon path' => 'path to icon',
danielebarchiesi@0 147 // The button image filename; defaults to '[plugin-name].png'.
danielebarchiesi@0 148 'icon file' => 'name of the icon file with extension',
danielebarchiesi@0 149 // The button title to display on hover.
danielebarchiesi@0 150 'icon title' => t('Do something'),
danielebarchiesi@0 151 // An alternative path to the integration JavaScript; defaults to
danielebarchiesi@0 152 // '[path-to-module]/[plugins-directory]/[plugin-name]'.
danielebarchiesi@0 153 'js path' => drupal_get_path('module', 'mymodule') . '/awesomeness',
danielebarchiesi@0 154 // An alternative filename of the integration JavaScript; defaults to
danielebarchiesi@0 155 // '[plugin-name].js'.
danielebarchiesi@0 156 'js file' => 'awesome.js',
danielebarchiesi@0 157 // An alternative path to the integration stylesheet; defaults to
danielebarchiesi@0 158 // '[path-to-module]/[plugins-directory]/[plugin-name]'.
danielebarchiesi@0 159 'css path' => drupal_get_path('module', 'mymodule') . '/awesomeness',
danielebarchiesi@0 160 // An alternative filename of the integration stylesheet; defaults to
danielebarchiesi@0 161 // '[plugin-name].css'.
danielebarchiesi@0 162 'css file' => 'awesome.css',
danielebarchiesi@0 163 // An array of settings for this button. Required, but API is still in flux.
danielebarchiesi@0 164 'settings' => array(
danielebarchiesi@0 165 ),
danielebarchiesi@0 166 // TinyMCE-specific: Additional HTML elements to allow in the markup.
danielebarchiesi@0 167 'extended_valid_elements' => array(
danielebarchiesi@0 168 'tag1[attribute1|attribute2]',
danielebarchiesi@0 169 'tag2[attribute3|attribute4]',
danielebarchiesi@0 170 ),
danielebarchiesi@0 171 );
danielebarchiesi@0 172 return $plugins;
danielebarchiesi@0 173 }
danielebarchiesi@0 174
danielebarchiesi@0 175 /**
danielebarchiesi@0 176 * Define a Wysiwyg editor library.
danielebarchiesi@0 177 *
danielebarchiesi@0 178 * @todo Complete this documentation.
danielebarchiesi@0 179 */
danielebarchiesi@0 180 function hook_INCLUDE_editor() {
danielebarchiesi@0 181 $editor['ckeditor'] = array(
danielebarchiesi@0 182 // The official, human-readable label of the editor library.
danielebarchiesi@0 183 'title' => 'CKEditor',
danielebarchiesi@0 184 // The URL to the library's homepage.
danielebarchiesi@0 185 'vendor url' => 'http://ckeditor.com',
danielebarchiesi@0 186 // The URL to the library's download page.
danielebarchiesi@0 187 'download url' => 'http://ckeditor.com/download',
danielebarchiesi@0 188 // A definition of available variants for the editor library.
danielebarchiesi@0 189 // The first defined is used by default.
danielebarchiesi@0 190 'libraries' => array(
danielebarchiesi@0 191 '' => array(
danielebarchiesi@0 192 'title' => 'Default',
danielebarchiesi@0 193 'files' => array(
danielebarchiesi@0 194 'ckeditor.js' => array('preprocess' => FALSE),
danielebarchiesi@0 195 ),
danielebarchiesi@0 196 ),
danielebarchiesi@0 197 'src' => array(
danielebarchiesi@0 198 'title' => 'Source',
danielebarchiesi@0 199 'files' => array(
danielebarchiesi@0 200 'ckeditor_source.js' => array('preprocess' => FALSE),
danielebarchiesi@0 201 ),
danielebarchiesi@0 202 ),
danielebarchiesi@0 203 ),
danielebarchiesi@0 204 // (optional) A callback to invoke to return additional notes for installing
danielebarchiesi@0 205 // the editor library in the administrative list/overview.
danielebarchiesi@0 206 'install note callback' => 'wysiwyg_ckeditor_install_note',
danielebarchiesi@0 207 // A callback to determine the library's version.
danielebarchiesi@0 208 'version callback' => 'wysiwyg_ckeditor_version',
danielebarchiesi@0 209 // A callback to return available themes/skins for the editor library.
danielebarchiesi@0 210 'themes callback' => 'wysiwyg_ckeditor_themes',
danielebarchiesi@0 211 // (optional) A callback to perform editor-specific adjustments or
danielebarchiesi@0 212 // enhancements for the administrative editor profile settings form.
danielebarchiesi@0 213 'settings form callback' => 'wysiwyg_ckeditor_settings_form',
danielebarchiesi@0 214 // (optional) A callback to return an initialization JavaScript snippet for
danielebarchiesi@0 215 // this editor library, loaded before the actual library files. The returned
danielebarchiesi@0 216 // JavaScript is executed as inline script in a primitive environment,
danielebarchiesi@0 217 // before the DOM is loaded; typically used to prime a base path and other
danielebarchiesi@0 218 // global window variables for the editor library before it is loaded.
danielebarchiesi@0 219 // All implementations should verbosely document what they are doing and
danielebarchiesi@0 220 // why that is required.
danielebarchiesi@0 221 'init callback' => 'wysiwyg_ckeditor_init',
danielebarchiesi@0 222 // A callback to convert administrative profile/editor settings into
danielebarchiesi@0 223 // JavaScript settings.
danielebarchiesi@0 224 'settings callback' => 'wysiwyg_ckeditor_settings',
danielebarchiesi@0 225 // A callback to supply definitions of available editor plugins.
danielebarchiesi@0 226 'plugin callback' => 'wysiwyg_ckeditor_plugins',
danielebarchiesi@0 227 // A callback to convert administrative plugin settings for a editor profile
danielebarchiesi@0 228 // into JavaScript settings.
danielebarchiesi@0 229 'plugin settings callback' => 'wysiwyg_ckeditor_plugin_settings',
danielebarchiesi@0 230 // (optional) Defines the proxy plugin that handles plugins provided by
danielebarchiesi@0 231 // Drupal modules, which work in all editors that support proxy plugins.
danielebarchiesi@0 232 'proxy plugin' => array(
danielebarchiesi@0 233 'drupal' => array(
danielebarchiesi@0 234 'load' => TRUE,
danielebarchiesi@0 235 'proxy' => TRUE,
danielebarchiesi@0 236 ),
danielebarchiesi@0 237 ),
danielebarchiesi@0 238 // (optional) A callback to convert proxy plugin settings into JavaScript
danielebarchiesi@0 239 // settings.
danielebarchiesi@0 240 'proxy plugin settings callback' => 'wysiwyg_ckeditor_proxy_plugin_settings',
danielebarchiesi@0 241 // Defines the list of supported (minimum) versions of the editor library,
danielebarchiesi@0 242 // and the respective Drupal integration files to load.
danielebarchiesi@0 243 'versions' => array(
danielebarchiesi@0 244 '3.0.0.3665' => array(
danielebarchiesi@0 245 'js files' => array('ckeditor-3.0.js'),
danielebarchiesi@0 246 ),
danielebarchiesi@0 247 ),
danielebarchiesi@0 248 );
danielebarchiesi@0 249 return $editor;
danielebarchiesi@0 250 }
danielebarchiesi@0 251
danielebarchiesi@0 252 /**
danielebarchiesi@0 253 * Act on editor profile settings.
danielebarchiesi@0 254 *
danielebarchiesi@0 255 * This hook is invoked from wysiwyg_get_editor_config() after the JavaScript
danielebarchiesi@0 256 * settings have been generated for an editor profile and before the settings
danielebarchiesi@0 257 * are added to the page. The settings may be customized or enhanced; typically
danielebarchiesi@0 258 * with options that cannot be controlled through Wysiwyg module's
danielebarchiesi@0 259 * administrative UI currently.
danielebarchiesi@0 260 *
danielebarchiesi@0 261 * Modules implementing this hook to enforce settings that can also be
danielebarchiesi@0 262 * controlled through the UI should also implement
danielebarchiesi@0 263 * hook_form_wysiwyg_profile_form_alter() to adjust or at least indicate on the
danielebarchiesi@0 264 * editor profile configuration form that certain/affected settings cannot be
danielebarchiesi@0 265 * changed.
danielebarchiesi@0 266 *
danielebarchiesi@0 267 * @param $settings
danielebarchiesi@0 268 * An associative array of JavaScript settings to pass to the editor.
danielebarchiesi@0 269 * @param $context
danielebarchiesi@0 270 * An associative array containing additional context information:
danielebarchiesi@0 271 * - editor: The plugin definition array of the editor.
danielebarchiesi@0 272 * - profile: The editor profile object, as loaded from the database.
danielebarchiesi@0 273 * - theme: The name of the editor theme/skin.
danielebarchiesi@0 274 */
danielebarchiesi@0 275 function hook_wysiwyg_editor_settings_alter(&$settings, $context) {
danielebarchiesi@0 276 // Each editor has its own collection of native settings that may be extended
danielebarchiesi@0 277 // or overridden. Please consult the respective official vendor documentation
danielebarchiesi@0 278 // for details.
danielebarchiesi@0 279 if ($context['profile']->editor == 'tinymce') {
danielebarchiesi@0 280 // Supported values to JSON data types.
danielebarchiesi@0 281 $settings['cleanup_on_startup'] = TRUE;
danielebarchiesi@0 282 }
danielebarchiesi@0 283 }