ckeditor.api.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <?php
  2. /**
  3. * CKEditor - The text editor for the Internet - http://ckeditor.com
  4. * Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved.
  5. *
  6. * == BEGIN LICENSE ==
  7. *
  8. * Licensed under the terms of any of the following licenses of your
  9. * choice:
  10. *
  11. * - GNU General Public License Version 2 or later (the "GPL")
  12. * http://www.gnu.org/licenses/gpl.html
  13. *
  14. * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
  15. * http://www.gnu.org/licenses/lgpl.html
  16. *
  17. * - Mozilla Public License Version 1.1 or later (the "MPL")
  18. * http://www.mozilla.org/MPL/MPL-1.1.html
  19. *
  20. * == END LICENSE ==
  21. *
  22. * @file
  23. * CKEditor Module for Drupal 7.x
  24. *
  25. * This module allows Drupal to replace textarea fields with CKEditor.
  26. *
  27. * CKEditor is an online rich text editor that can be embedded inside web pages.
  28. * It is a WYSIWYG (What You See Is What You Get) editor which means that the
  29. * text edited in it looks as similar as possible to the results end users will
  30. * see after the document gets published. It brings to the Web popular editing
  31. * features found in desktop word processors such as Microsoft Word and
  32. * OpenOffice.org Writer. CKEditor is truly lightweight and does not require any
  33. * kind of installation on the client computer.
  34. */
  35. /**
  36. * Hook to register the CKEditor plugin - it would appear in the plugins list on the profile setting page.
  37. */
  38. function hook_ckeditor_plugin() {
  39. return array(
  40. 'plugin_name' => array(
  41. // Name of the plugin used to write it.
  42. 'name' => 'plugin_name',
  43. // Description of the plugin - it would be displayed in the plugins management section of profile settings.
  44. 'desc' => t('Plugin description'),
  45. // The full URL to the CKEditor plugins directory, with the trailing slash.
  46. 'path' => base_path() . drupal_get_path('module', 'my_module') . '/plugin_dir/',
  47. 'buttons' => array(
  48. 'button_name' => array(
  49. // Path to the button icon. Relative to the plugin directory 'path' unless 'icon_path' is specified.
  50. 'icon' => 'icon/plugin_name.png',
  51. // Optional full path to the directory the icon is located in.
  52. 'icon_path' => base_path() . drupal_get_path('theme', 'my_theme') . '/icon_dir/',
  53. 'label' => 'Button Label',
  54. )
  55. )
  56. )
  57. );
  58. }
  59. /**
  60. * Hook to extend/change CKEditor plugins.
  61. *
  62. * @param $plugins
  63. * An associative array of plugins.
  64. */
  65. function hook_ckeditor_plugin_alter(&$plugins) {
  66. // Remove a plugin button.
  67. unset($plugins['plugin_name']['buttons']['button']);
  68. }
  69. /**
  70. * Hook to register the CKEditor security filter - it would appear in the security filters list on the profile setting page.
  71. */
  72. function hook_ckeditor_security_filter() {
  73. return array(
  74. 'security_filter_name' => array(
  75. // Title of the security filter - it would be displayed in the security filters section of profile settings.
  76. 'title' => t('Security filter title'),
  77. // Description of the security filter - it would be displayed in the security filters section of profile settings.
  78. 'description' => t('Security filter description'),
  79. )
  80. );
  81. }
  82. /**
  83. * Hook to alter CKEditor security filters.
  84. */
  85. function hook_ckeditor_security_filter_alter(&$security_filters) {
  86. // Modify a $security_filter.
  87. }
  88. /**
  89. * Hook to extend/change the ckeditor settings.
  90. *
  91. * This hook is invoked from ckeditor_profile_settings_compile(). The settings
  92. * may be customized or enhanced; typically with options that cannot be
  93. * controlled though the administrative UI from the ckeditor module.
  94. *
  95. * @param $settings
  96. * An associative array of settings.
  97. * @param $conf
  98. * An associative array with access to raw profile settings that might be helpful to alter the real $settings.
  99. */
  100. function hook_ckeditor_settings_alter(&$settings, $conf) {
  101. // Change the ckeditor config path.
  102. $settings['customConfig'] = drupal_get_path('module', 'ckeditor') . '/ckeditor.config.js';
  103. }
  104. /**
  105. * Hook that allows to alter the user default settings.
  106. *
  107. * @param $settings
  108. * An associative array of settings.
  109. */
  110. function hook_ckeditor_default_settings_alter(&$settings) {
  111. $settings['show_toggle'] = 'f';
  112. }
  113. /**
  114. * Hook to extend CKEditor security allowed tags list.
  115. *
  116. * This hook is invoked from ckeditor_filter_xss() where text is filtered from potentially insecure tags.
  117. */
  118. function hook_ckeditor_filter_xss_allowed_tags() {
  119. // Return an array of additional allowed tags
  120. }