tinymce.module

  1. 7.x modules/tinymce/tinymce.module
  2. 6.x modules/tinymce/tinymce.module
  3. 4.x modules/tinymce/tinymce.module
  4. 5.x modules/tinymce/tinymce.module

The TinyMCE module will init TinyMCE (the editor) on appropriate pages. This module is primarily for managing what those pages are.

File

modules/tinymce/tinymce.module
View source
  1. <?php
  2. /**
  3. * @file
  4. * The TinyMCE module will init TinyMCE (the editor) on appropriate pages. This module
  5. * is primarily for managing what those pages are.
  6. */
  7. function tinymce_init() {
  8. $bool_activate = FALSE;
  9. $include_paths = explode("\n", variable_get("tinymce_include_on_paths", ""));
  10. $include_paths = array_map("trim", $include_paths);
  11. // Wildcards are allowed at the END of the path.
  12. // So, "content/edit*" would be OK. We need to go through
  13. // our paths and look at this.
  14. foreach($include_paths as $ipath) {
  15. if ($ipath == "") continue;
  16. if ($ipath == @$_REQUEST["q"]) {
  17. $bool_activate = TRUE;
  18. break;
  19. }
  20. // Contains a wildcard! So, is the ipath partially in the request?
  21. if (strstr($ipath, "*")) {
  22. $ipath = str_replace("*", "", $ipath);
  23. if (substr(@$_REQUEST["q"], 0, strlen($ipath)) == $ipath) {
  24. $bool_activate = TRUE;
  25. break;
  26. }
  27. }
  28. }
  29. if ($bool_activate) {
  30. fp_add_js(array("tinymceModulePath" => fp_get_module_path("tinymce")), "setting");
  31. $toolbar = variable_get("tinymce_toolbar", "bold italic underline | cut copy paste | undo redo | alignleft aligncenter | bullist numlist outdent indent | link unlink | removeformat");
  32. fp_add_js(array("tinymceToolbar" => $toolbar), "setting");
  33. fp_add_js(fp_get_module_path("tinymce") . "/lib/tinymce/js/tinymce/tinymce.min.js");
  34. fp_add_js(fp_get_module_path("tinymce") . "/js/tinymce_module.js");
  35. // Set to TRUE for pages where tinymce is in use.
  36. $GLOBALS["tinymce_active"] = TRUE;
  37. }
  38. }
  39. /**
  40. * Implementation of hook_menu
  41. */
  42. function tinymce_menu() {
  43. $items = array();
  44. $items["admin/config/tinymce"] = array(
  45. "title" => "TinyMCE Settings",
  46. "description" => "Administer settings for the TinyMCE WYSIWYG editor",
  47. "page_callback" => "fp_render_form",
  48. "page_arguments" => array("tinymce_config_form", "system_settings"),
  49. "access_arguments" => array("administer_tinymce"),
  50. "page_settings" => array(
  51. "menu_icon" => fp_get_module_path('tinymce') . "/icons/text_dropcaps.png",
  52. "page_hide_report_error" => TRUE,
  53. "menu_links" => array(
  54. 0 => array(
  55. "text" => "Admin Console",
  56. "path" => "admin-tools/admin",
  57. "query" => "de_catalog_year=%DE_CATALOG_YEAR%",
  58. ),
  59. ),
  60. ),
  61. "type" => MENU_TYPE_NORMAL_ITEM,
  62. "tab_parent" => "admin-tools/admin",
  63. );
  64. return $items;
  65. }
  66. function tinymce_config_form() {
  67. $form = array();
  68. fp_add_css(fp_get_module_path("tinymce") . "/css/tinymce.css");
  69. $form["tinymce_include_on_paths"] = array(
  70. "label" => t("Include on paths:"),
  71. "type" => "textarea",
  72. "value" => variable_get("tinymce_include_on_paths", ""),
  73. "description" => t("Enter FlightPath paths, one per line, where
  74. the TinyMCE plugin should be included. This step is required before you
  75. can make use of the textarea_editor element type (see below).
  76. <br>Ex:<br>&nbsp; comments<br>&nbsp; content/*
  77. <br>
  78. Wildcards are also allowed at the END of the path only.
  79. Ex: content/*
  80. <br><br>
  81. Note: For developers, make sure you specify a <b>type=textarea_editor</b> for fields which
  82. should be rendered with TinyMCE. Use hook_form_alter to change ordinary textareas into textarea_editor."),
  83. );
  84. $form["tinymce_toolbar"] = array(
  85. "label" => t("Toolbar:"),
  86. "type" => "textfield",
  87. "value" => variable_get("tinymce_toolbar", "bold italic underline | cut copy paste | undo redo | alignleft aligncenter | bullist numlist outdent indent | link unlink | removeformat"),
  88. "description" => t("Enter the toolbar components (based on TinyMCE's documentation) that you would like to as part of TinyMCE.
  89. <br>If unsure what to enter, use:
  90. <br>&nbsp; &nbsp; bold italic underline | cut copy paste | undo redo | alignleft aligncenter | bullist numlist outdent indent | link unlink | removeformat"),
  91. );
  92. return $form;
  93. }
  94. function tinymce_perm() {
  95. return array(
  96. "administer_tinymce" => array(
  97. "title" => t("Administer TinyMCE"),
  98. "description" => t("Configure the TinyMCE module."),
  99. ),
  100. );
  101. }
  102. /**
  103. * Implementation of hook_form_alter
  104. */
  105. function tinymce_form_alter(&$form, $form_id) {
  106. // if tinymce is active, add instrcutions under the textareas.
  107. if (@$GLOBALS["tinymce_active"]) {
  108. fp_add_css(fp_get_module_path("tinymce") . "/css/tinymce.css");
  109. foreach($form as $key=>$val) {
  110. if (@$form[$key]["type"] == "textarea_editor") {
  111. @$form[$key]["description"] .= "<div class='tinymce-extra-instructions'>
  112. " . t("Trouble with Copy/Paste? Try keyboard
  113. shortcuts CTRL-C and CTRL-V. To single-space, press SHIFT-ENTER.") . "</div>";
  114. }
  115. }
  116. }
  117. }

Functions

Namesort descending Description
tinymce_config_form
tinymce_form_alter Implementation of hook_form_alter
tinymce_init
tinymce_menu Implementation of hook_menu
tinymce_perm