Projet

Général

Profil

Paste
Télécharger (3,82 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / admin_menu / admin_menu.map.inc @ 76df55b7

1
<?php
2

    
3
/**
4
 * @file
5
 * Implements hook_admin_menu_map() on behalf of core modules.
6
 *
7
 * @todo Replace all/most of those API functions with direct DB queries;
8
 *   we only need the menu arguments (keys), not fully loaded objects.
9
 */
10

    
11
/**
12
 * Implements hook_admin_menu_map() on behalf of Filter module.
13
 */
14
function filter_admin_menu_map() {
15
  if (!user_access('administer filters')) {
16
    return;
17
  }
18
  $map['admin/config/content/formats/%filter_format'] = array(
19
    'parent' => 'admin/config/content/formats',
20
    'arguments' => array(
21
      array('%filter_format' => array_keys(filter_formats())),
22
    ),
23
  );
24
  return $map;
25
}
26

    
27
/**
28
 * Implements hook_admin_menu_map() on behalf of Menu module.
29
 */
30
function menu_admin_menu_map() {
31
  if (!user_access('administer menu')) {
32
    return;
33
  }
34
  $map['admin/structure/menu/manage/%menu'] = array(
35
    'parent' => 'admin/structure/menu',
36
    'arguments' => array(
37
      array('%menu' => array_keys(menu_get_menus())),
38
    ),
39
  );
40
  return $map;
41
}
42

    
43
/**
44
 * Implements hook_admin_menu_map() on behalf of Node module.
45
 */
46
function node_admin_menu_map() {
47
  if (!user_access('administer content types')) {
48
    return;
49
  }
50
  $map['admin/structure/types/manage/%node_type'] = array(
51
    'parent' => 'admin/structure/types',
52
    'arguments' => array(
53
      array('%node_type' => array_keys(node_type_get_types())),
54
    ),
55
  );
56
  return $map;
57
}
58

    
59
/**
60
 * Implements hook_admin_menu_map() on behalf of Field UI module.
61
 *
62
 * @todo Figure out how to fix the comment entity bundle mappings.
63
 */
64
function field_ui_admin_menu_map() {
65
  $map = array();
66

    
67
  foreach (entity_get_info() as $entity_type => $entity_info) {
68
    if (!$entity_info['fieldable']) {
69
      continue;
70
    }
71

    
72
    foreach ($entity_info['bundles'] as $bundle => $bundle_info) {
73
      // @see field_ui_menu()
74
      if (!isset($bundle_info['admin'])) {
75
        continue;
76
      }
77

    
78
      // Check access to this bundle.
79
      $bundle_info['admin'] += array(
80
        'access callback' => 'user_access',
81
        'access arguments' => array('administer site configuration'),
82
      );
83
      if (!call_user_func_array($bundle_info['admin']['access callback'], $bundle_info['admin']['access arguments'])) {
84
        continue;
85
      }
86

    
87
      if ($fields = field_info_instances($entity_type, $bundle)) {
88
        $path = $bundle_info['admin']['path'];
89
        $argument = array();
90
        if (isset($bundle_info['admin']['bundle argument'])) {
91
          $bundle_arg = arg($bundle_info['admin']['bundle argument'], $path);
92
          $argument[$bundle_arg] = array($bundle);
93
        }
94
        $argument['%field_ui_menu'] = array_keys($fields);
95

    
96
        if (!isset($map["$path/fields/%field_ui_menu"])) {
97
          $map["$path/fields/%field_ui_menu"] = array(
98
            'parent' => "$path/fields",
99
            'arguments' => array(),
100
          );
101
        }
102
        $map["$path/fields/%field_ui_menu"]['arguments'][] = $argument;
103
      }
104
    }
105
  }
106

    
107
  return $map;
108
}
109

    
110
/**
111
 * Implements hook_admin_menu_map() on behalf of Taxonomy module.
112
 */
113
function taxonomy_admin_menu_map() {
114
  if (!user_access('administer taxonomy')) {
115
    return;
116
  }
117
  $map['admin/structure/taxonomy/%taxonomy_vocabulary_machine_name'] = array(
118
    'parent' => 'admin/structure/taxonomy',
119
    'arguments' => array(
120
      array('%taxonomy_vocabulary_machine_name' => array_keys(taxonomy_vocabulary_get_names())),
121
    ),
122
  );
123
  return $map;
124
}
125

    
126
/**
127
 * Implements hook_admin_menu_map() on behalf of Views UI module.
128
 */
129
function views_ui_admin_menu_map() {
130
  if (!user_access('administer views')) {
131
    return;
132
  }
133
  $views = array();
134
  foreach (views_get_enabled_views() as $name => $view) {
135
    $views[] = $name;
136
  }
137
  if (empty($views)) {
138
    return;
139
  }
140
  $map['admin/structure/views/view/%views_ui_cache'] = array(
141
    'parent' => 'admin/structure/views',
142
    'arguments' => array(
143
      array('%views_ui_cache' => $views),
144
    ),
145
  );
146
  return $map;
147
}