wysiwyg.api.php

  1. cis7 sites/all/modules/ulmus/wysiwyg/wysiwyg.api.php
  2. cle7 sites/all/modules/ulmus/wysiwyg/wysiwyg.api.php
  3. ecd7 sites/all/modules/ulmus/wysiwyg/wysiwyg.api.php
  4. elmsmedia7 sites/all/modules/ulmus/wysiwyg/wysiwyg.api.php
  5. harmony7 sites/all/modules/ulmus/wysiwyg/wysiwyg.api.php
  6. icor7 sites/all/modules/ulmus/wysiwyg/wysiwyg.api.php
  7. meedjum_blog7 sites/all/modules/ulmus/wysiwyg/wysiwyg.api.php
  8. mooc7 sites/all/modules/ulmus/wysiwyg/wysiwyg.api.php

API documentation for Wysiwyg module.

To implement a "Drupal plugin" button, you need to write a Wysiwyg plugin:

  • Implement hook_wysiwyg_include_directory() to register the directory containing plugin definitions.
  • In each plugin definition file, implement hook_INCLUDE_plugin().
  • For each plugin button, implement a JavaScript integration and an icon for the button.

@todo Icon: Recommended size and type of image.

For example implementations you may want to look at

  • Image Assist (img_assist)
  • Teaser break plugin (plugins/break; part of WYSIWYG)
  • IMCE (imce_wysiwyg)

Functions

Namesort descending Description
hook_INCLUDE_editor Define a Wysiwyg editor library.
hook_INCLUDE_plugin Define a Wysiwyg plugin.
hook_wysiwyg_editor_settings_alter Act on editor profile settings.
hook_wysiwyg_include_directory Register a directory containing Wysiwyg plugins.
hook_wysiwyg_plugin Return an array of native editor plugins.

File

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

Error

×

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/api.elmsln.org/includes/common.inc:2791) in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/api.elmsln.org/sites/all/modules/apc/drupal_apc_cache.inc).
The website encountered an unexpected error. Please try again later.