tinymce.module

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

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