bueditor.module

Tracking 6.x-2.x branch
  1. drupal
    1. 5 contributions/bueditor/bueditor.module
    2. 6 contributions/bueditor/bueditor.module

Implements the necessary hooks for the editor to work properly.

Functions & methods

NameDescription
bueditor_editor_loadload editor by id. used by menu system
bueditor_elementsImplementation of hook_elements().
bueditor_file_downloadImplementation of hook_file_download().
bueditor_incLoad bueditor.inc file
bueditor_menuImplementation of hook_menu().
bueditor_permImplementation of hook_perm().
bueditor_settleInclude necessary js and css files for editor settlement.
bueditor_textareaIntegrate the editor into textareas.
bueditor_themeImplementation of hook_theme().

File

View source
  1. <?php
  2. /**
  3. * @file
  4. * Implements the necessary hooks for the editor to work properly.
  5. */
  6. /**
  7. * Implementation of hook_menu().
  8. */
  9. function bueditor_menu() {
  10. $items = array();
  11. $path = 'admin/settings/bueditor';
  12. $common = array('access arguments' => array('administer bueditor(execute PHP)'), 'file' => 'admin/bueditor.admin.inc');
  13. $form = array('page callback' => 'drupal_get_form', 'type' => MENU_CALLBACK) + $common;
  14. $items[$path] = $common + array(
  15. 'title' => 'BUEditor',
  16. 'description' => 'Customize your text editor.',
  17. 'page callback' => 'bueditor_admin',
  18. );
  19. $items[$path .'/new'] = $form + array(
  20. 'title' => 'Add new editor',
  21. 'page arguments' => array('bueditor_editor_form'),
  22. );
  23. $items[$path .'/import'] = $form + array(
  24. 'title' => 'Import editor',
  25. 'page arguments' => array('bueditor_editor_import_form'),
  26. );
  27. $items[$path .'/%bueditor_editor'] = $form + array(
  28. 'title' => 'Editor settings',
  29. 'page arguments' => array('bueditor_editor_form', 3),
  30. );
  31. $items[$path .'/%bueditor_editor/delete'] = $form + array(
  32. 'title' => 'Delete editor',
  33. 'page arguments' => array('bueditor_delete_form', 3),
  34. );
  35. return $items;
  36. }
  37. /**
  38. * Implementation of hook_perm().
  39. */
  40. function bueditor_perm() {
  41. return array('administer bueditor(execute PHP)');
  42. }
  43. /**
  44. * Implementation of hook_theme().
  45. */
  46. function bueditor_theme() {
  47. $theme['bueditor_admin']['function'] = 'bueditor_admin_theme';
  48. $theme['bueditor_editor']['function'] = 'bueditor_editor_theme';
  49. return $theme;
  50. }
  51. /**
  52. * Implementation of hook_elements().
  53. */
  54. function bueditor_elements() {
  55. return array('textarea' => array('#process' => array('bueditor_textarea')));
  56. }
  57. /**
  58. * Integrate the editor into textareas.
  59. */
  60. function bueditor_textarea($element) {
  61. bueditor_inc();
  62. return _bueditor_textarea($element);
  63. }
  64. /**
  65. * Include necessary js and css files for editor settlement.
  66. */
  67. function bueditor_settle($editor) {
  68. bueditor_inc();
  69. return _bueditor_settle($editor);
  70. }
  71. /**
  72. * load editor by id. used by menu system
  73. */
  74. function bueditor_editor_load($eid) {
  75. return db_fetch_object(db_query("SELECT * FROM {bueditor_editors} WHERE eid = %d", $eid));
  76. }
  77. /**
  78. * Implementation of hook_file_download().
  79. */
  80. function bueditor_file_download($file) {
  81. if (strpos($file, variable_get('bueditor_sprites_dir', 'bueditor-sprites') . '/') === 0) {
  82. $path = file_create_path($file);
  83. return array('Content-type: '. file_get_mimetype($path), 'Content-Length: '. filesize($path));
  84. }
  85. }
  86. /**
  87. * Load bueditor.inc file
  88. */
  89. function bueditor_inc() {
  90. static $loaded;
  91. if (!isset($loaded)) {
  92. include_once './' . drupal_get_path('module', 'bueditor') . '/bueditor.inc';
  93. $loaded = TRUE;
  94. }
  95. }