admin_menu.map.inc 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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. $access_arguments = $bundle_info['admin']['access arguments'];
  76. if (isset($bundle_info['admin']['real path'])) {
  77. $menu_item = menu_get_item($bundle_info['admin']['real path']);
  78. if (isset($menu_item['map'])) {
  79. $access_arguments = menu_unserialize(serialize($access_arguments), $menu_item['map']);
  80. }
  81. }
  82. if (!call_user_func_array($bundle_info['admin']['access callback'], $access_arguments)) {
  83. continue;
  84. }
  85. if ($fields = field_info_instances($entity_type, $bundle)) {
  86. $path = $bundle_info['admin']['path'];
  87. $argument = array();
  88. if (isset($bundle_info['admin']['bundle argument'])) {
  89. $bundle_arg = arg($bundle_info['admin']['bundle argument'], $path);
  90. $argument[$bundle_arg] = array($bundle);
  91. }
  92. $argument['%field_ui_menu'] = array_keys($fields);
  93. if (!isset($map["$path/fields/%field_ui_menu"])) {
  94. $map["$path/fields/%field_ui_menu"] = array(
  95. 'parent' => "$path/fields",
  96. 'arguments' => array(),
  97. );
  98. }
  99. $map["$path/fields/%field_ui_menu"]['arguments'][] = $argument;
  100. }
  101. }
  102. }
  103. return $map;
  104. }
  105. /**
  106. * Implements hook_admin_menu_map() on behalf of Taxonomy module.
  107. */
  108. function taxonomy_admin_menu_map() {
  109. if (!user_access('administer taxonomy')) {
  110. return;
  111. }
  112. $map['admin/structure/taxonomy/%taxonomy_vocabulary_machine_name'] = array(
  113. 'parent' => 'admin/structure/taxonomy',
  114. 'arguments' => array(
  115. array('%taxonomy_vocabulary_machine_name' => array_keys(taxonomy_vocabulary_get_names())),
  116. ),
  117. );
  118. return $map;
  119. }
  120. /**
  121. * Implements hook_admin_menu_map() on behalf of Views UI module.
  122. */
  123. function views_ui_admin_menu_map() {
  124. if (!user_access('administer views')) {
  125. return;
  126. }
  127. $views = array();
  128. foreach (views_get_enabled_views() as $name => $view) {
  129. $views[] = $name;
  130. }
  131. if (empty($views)) {
  132. return;
  133. }
  134. $map['admin/structure/views/view/%views_ui_cache'] = array(
  135. 'parent' => 'admin/structure/views',
  136. 'arguments' => array(
  137. array('%views_ui_cache' => $views),
  138. ),
  139. );
  140. return $map;
  141. }