admin_menu.map.inc 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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. function field_ui_admin_menu_map() {
  58. $map = array();
  59. foreach (entity_get_info() as $obj_type => $info) {
  60. foreach ($info['bundles'] as $bundle_name => $bundle_info) {
  61. if (isset($bundle_info['admin'])) {
  62. $arguments = array();
  63. switch ($obj_type) {
  64. case 'comment':
  65. $fields = array();
  66. foreach (field_info_instances($obj_type, $bundle_name) as $field) {
  67. $fields[] = $field['field_name'];
  68. }
  69. // @todo Make Comment module expose the original node type bundle,
  70. // pretty please.
  71. if (drupal_substr($bundle_name, 0, 13) == 'comment_node_') {
  72. $bundle_name = drupal_substr($bundle_name, 13);
  73. }
  74. // @todo Doesn't work yet. Why?
  75. $arguments = array(
  76. '%comment_node_type' => array($bundle_name),
  77. '%field_ui_menu' => $fields,
  78. );
  79. break;
  80. case 'node':
  81. $fields = array();
  82. foreach (field_info_instances($obj_type, $bundle_name) as $field) {
  83. $fields[] = $field['field_name'];
  84. }
  85. $arguments = array(
  86. '%node_type' => array($bundle_name),
  87. '%field_ui_menu' => $fields,
  88. );
  89. break;
  90. case 'taxonomy_term':
  91. $fields = array();
  92. foreach (field_info_instances($obj_type, $bundle_name) as $field) {
  93. $fields[] = $field['field_name'];
  94. }
  95. // Map machine_name to vid.
  96. $arguments = array(
  97. '%taxonomy_vocabulary_machine_name' => array($bundle_name),
  98. '%field_ui_menu' => $fields,
  99. );
  100. break;
  101. case 'user':
  102. $arguments = array(
  103. '%field_ui_menu' => array_keys(field_info_fields('user')),
  104. );
  105. break;
  106. }
  107. if (!empty($arguments)) {
  108. $path = $bundle_info['admin']['path'];
  109. $map["$path/fields/%field_ui_menu"]['parent'] = "$path/fields";
  110. $map["$path/fields/%field_ui_menu"]['arguments'][] = $arguments;
  111. }
  112. }
  113. }
  114. }
  115. return $map;
  116. }
  117. /**
  118. * Implements hook_admin_menu_map() on behalf of Taxonomy module.
  119. */
  120. function taxonomy_admin_menu_map() {
  121. if (!user_access('administer taxonomy')) {
  122. return;
  123. }
  124. $map['admin/structure/taxonomy/%taxonomy_vocabulary_machine_name'] = array(
  125. 'parent' => 'admin/structure/taxonomy',
  126. 'arguments' => array(
  127. array('%taxonomy_vocabulary_machine_name' => array_keys(taxonomy_vocabulary_get_names())),
  128. ),
  129. );
  130. return $map;
  131. }
  132. /**
  133. * Implements hook_admin_menu_map() on behalf of Views UI module.
  134. */
  135. function views_ui_admin_menu_map() {
  136. if (!user_access('administer views')) {
  137. return;
  138. }
  139. $views = array();
  140. foreach (views_get_enabled_views() as $name => $view) {
  141. $views[] = $name;
  142. }
  143. if (empty($views)) {
  144. return;
  145. }
  146. $map['admin/structure/views/view/%views_ui_cache'] = array(
  147. 'parent' => 'admin/structure/views',
  148. 'arguments' => array(
  149. array('%views_ui_cache' => $views),
  150. ),
  151. );
  152. return $map;
  153. }