admin_menu.map.inc 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <?php
  2. /**
  3. * @file
  4. * Implements hook_admin_menu_map() on behalf of core modules.
  5. *
  6. * @todo Replace all/most of those API functions with direct DB queries;
  7. * we only need the menu arguments (keys), not fully loaded objects.
  8. */
  9. /**
  10. * Implements hook_admin_menu_map() on behalf of Filter module.
  11. */
  12. function filter_admin_menu_map() {
  13. if (!user_access('administer filters')) {
  14. return;
  15. }
  16. $map['admin/config/content/formats/%filter_format'] = array(
  17. 'parent' => 'admin/config/content/formats',
  18. 'arguments' => array(
  19. array('%filter_format' => array_keys(filter_formats())),
  20. ),
  21. );
  22. return $map;
  23. }
  24. /**
  25. * Implements hook_admin_menu_map() on behalf of Menu module.
  26. */
  27. function menu_admin_menu_map() {
  28. if (!user_access('administer menu')) {
  29. return;
  30. }
  31. $map['admin/structure/menu/manage/%menu'] = array(
  32. 'parent' => 'admin/structure/menu',
  33. 'arguments' => array(
  34. array('%menu' => array_keys(menu_get_menus())),
  35. ),
  36. );
  37. return $map;
  38. }
  39. /**
  40. * Implements hook_admin_menu_map() on behalf of Node module.
  41. */
  42. function node_admin_menu_map() {
  43. if (!user_access('administer content types')) {
  44. return;
  45. }
  46. $map['admin/structure/types/manage/%node_type'] = array(
  47. 'parent' => 'admin/structure/types',
  48. 'arguments' => array(
  49. array('%node_type' => array_keys(node_type_get_types())),
  50. ),
  51. );
  52. return $map;
  53. }
  54. /**
  55. * Implements hook_admin_menu_map() on behalf of Field UI module.
  56. *
  57. * @todo Figure out how to fix the comment entity bundle mappings.
  58. */
  59. function field_ui_admin_menu_map() {
  60. $map = array();
  61. foreach (entity_get_info() as $entity_type => $entity_info) {
  62. if (!$entity_info['fieldable']) {
  63. continue;
  64. }
  65. foreach ($entity_info['bundles'] as $bundle => $bundle_info) {
  66. // @see field_ui_menu()
  67. if (!isset($bundle_info['admin'])) {
  68. continue;
  69. }
  70. // Check access to this bundle.
  71. $bundle_info['admin'] += array(
  72. 'access callback' => 'user_access',
  73. 'access arguments' => array('administer site configuration'),
  74. );
  75. if (!call_user_func_array($bundle_info['admin']['access callback'], $bundle_info['admin']['access arguments'])) {
  76. continue;
  77. }
  78. if ($fields = field_info_instances($entity_type, $bundle)) {
  79. $path = $bundle_info['admin']['path'];
  80. $argument = array();
  81. if (isset($bundle_info['admin']['bundle argument'])) {
  82. $bundle_arg = arg($bundle_info['admin']['bundle argument'], $path);
  83. $argument[$bundle_arg] = array($bundle);
  84. }
  85. $argument['%field_ui_menu'] = array_keys($fields);
  86. if (!isset($map["$path/fields/%field_ui_menu"])) {
  87. $map["$path/fields/%field_ui_menu"] = array(
  88. 'parent' => "$path/fields",
  89. 'arguments' => array(),
  90. );
  91. }
  92. $map["$path/fields/%field_ui_menu"]['arguments'][] = $argument;
  93. }
  94. }
  95. }
  96. return $map;
  97. }
  98. /**
  99. * Implements hook_admin_menu_map() on behalf of Taxonomy module.
  100. */
  101. function taxonomy_admin_menu_map() {
  102. if (!user_access('administer taxonomy')) {
  103. return;
  104. }
  105. $map['admin/structure/taxonomy/%taxonomy_vocabulary_machine_name'] = array(
  106. 'parent' => 'admin/structure/taxonomy',
  107. 'arguments' => array(
  108. array('%taxonomy_vocabulary_machine_name' => array_keys(taxonomy_vocabulary_get_names())),
  109. ),
  110. );
  111. return $map;
  112. }
  113. /**
  114. * Implements hook_admin_menu_map() on behalf of Views UI module.
  115. */
  116. function views_ui_admin_menu_map() {
  117. if (!user_access('administer views')) {
  118. return;
  119. }
  120. $views = array();
  121. foreach (views_get_enabled_views() as $name => $view) {
  122. $views[] = $name;
  123. }
  124. if (empty($views)) {
  125. return;
  126. }
  127. $map['admin/structure/views/view/%views_ui_cache'] = array(
  128. 'parent' => 'admin/structure/views',
  129. 'arguments' => array(
  130. array('%views_ui_cache' => $views),
  131. ),
  132. );
  133. return $map;
  134. }