taxonomy_wrangler.module 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. /**
  3. * @file
  4. * Taxonomy wrangler main module file
  5. */
  6. /**
  7. * Implements hook_menu_alter().
  8. *
  9. * Override the main taxonomy overview page.
  10. */
  11. function taxonomy_wrangler_menu_alter(&$items) {
  12. $items['admin/structure/taxonomy/%taxonomy_vocabulary_machine_name']['page arguments'] = array('taxonomy_wrangler_overview_terms', 3);
  13. $items['admin/structure/taxonomy/%taxonomy_vocabulary_machine_name']['file'] = 'taxonomy_wrangler.admin.inc';
  14. $items['admin/structure/taxonomy/%taxonomy_vocabulary_machine_name']['file path'] = drupal_get_path('module', 'taxonomy_wrangler');
  15. }
  16. /**
  17. * Implements hook_theme().
  18. */
  19. function taxonomy_wrangler_theme() {
  20. return array(
  21. 'taxonomy_wrangler_overview_terms' => array(
  22. 'render element' => 'form',
  23. ),
  24. );
  25. }
  26. /**
  27. * Copy of drupal_add_tabledrag().
  28. *
  29. * This is a copy of drupal_add_tabledrag used just to instantiate
  30. * our own tabledrag class vs Drupal's.
  31. * @see drupal_add_tabledrag
  32. */
  33. function taxonomy_wrangler_add_tabledrag($table_id, $action, $relationship, $group, $subgroup = NULL, $source = NULL, $hidden = TRUE, $limit = 0) {
  34. $js_added = &drupal_static(__FUNCTION__, FALSE);
  35. if (!$js_added) {
  36. // Add the table drag JavaScript to the page before the module JavaScript
  37. // to ensure that table drag behaviors are registered before any module
  38. // uses it.
  39. drupal_add_library('system', 'jquery.cookie');
  40. drupal_add_js('misc/tabledrag.js', array('weight' => -1));
  41. $js_added = TRUE;
  42. }
  43. // If a subgroup or source isn't set, assume it is the same as the group.
  44. $target = isset($subgroup) ? $subgroup : $group;
  45. $source = isset($source) ? $source : $target;
  46. $settings['taxonomyWrangler']['tables'][$table_id][$group][] = array(
  47. 'target' => $target,
  48. 'source' => $source,
  49. 'relationship' => $relationship,
  50. 'action' => $action,
  51. 'hidden' => $hidden,
  52. 'limit' => $limit,
  53. );
  54. drupal_add_js($settings, 'setting');
  55. }