| 1 field_group.module | field_group_menu() |
Implements hook_menu().
File
- core/
modules/ field_group/ field_group.module, line 39 - Field Group module.
Code
function field_group_menu() {
$items = array();
// Ensure the following is not executed until field_bundles is working and
// tables are updated. Needed to avoid errors on initial installation.
if (defined('MAINTENANCE_MODE')) {
return $items;
}
// Create tabs for all possible bundles.
foreach (entity_get_info() as $entity_type => $entity_info) {
if (isset($entity_info['fieldable']) && $entity_info['fieldable']) {
foreach ($entity_info['bundles'] as $bundle_name => $bundle_info) {
if (isset($bundle_info['admin'])) {
// Extract path information from the bundle.
$path = $bundle_info['admin']['path'];
// Different bundles can appear on the same path (e.g. %node_type and
// %comment_node_type). To allow field_group_menu_load() to extract
// the actual bundle object from the translated menu router path
// arguments, we need to identify the argument position of the bundle
// name string ('bundle argument') and pass that position to the menu
// loader. The position needs to be casted into a string; otherwise it
// would be replaced with the bundle name string.
if (isset($bundle_info['admin']['bundle argument'])) {
$bundle_arg = $bundle_info['admin']['bundle argument'];
$bundle_pos = (string) $bundle_arg;
}
else {
$bundle_arg = $bundle_name;
$bundle_pos = '0';
}
// This is the position of the %field_group_menu placeholder in the
// items below.
$group_position = count(explode('/', $path)) + 1;
// Extract access information, providing defaults.
$access = array_intersect_key($bundle_info['admin'], backdrop_map_assoc(array(
'access callback', 'access arguments',
)));
$access += array(
'access callback' => 'user_access',
'access arguments' => array('administer fields'),
);
// Add the "administer fields" permission on top of the access
// restriction because the field UI should only be accessible to
// trusted users. The bundle argument is passed to
// field_ui_admin_access() to allow for substitution.
if ($access['access callback'] != 'user_access' || $access['access arguments'] != array('administer fields')) {
$access = array(
'access callback' => 'field_ui_admin_access',
'access arguments' => array(
$access['access callback'],
$access['access arguments'],
$bundle_pos,
$bundle_arg,
),
);
}
$items["$path/groups/%field_group_menu"] = array(
'load arguments' => array(
$entity_type, $bundle_arg, $bundle_pos, '%map',
),
'title callback' => 'field_group_menu_title',
'title arguments' => array($group_position),
'page callback' => 'backdrop_get_form',
'page arguments' => array(
'field_group_configure_form', $group_position,
),
'file' => 'field_group.field_ui.inc',
) + $access;
$items["$path/groups/%field_group_menu/configure"] = array(
'load arguments' => array(
$entity_type, $bundle_arg, $bundle_pos, '%map',
),
'title' => 'Edit',
'page callback' => 'backdrop_get_form',
'page arguments' => array(
'field_group_configure_form', $group_position,
),
'type' => MENU_DEFAULT_LOCAL_TASK,
'file' => 'field_group.field_ui.inc',
) + $access;
$items["$path/groups/%field_group_menu/format-type"] = array(
'load arguments' => array(
$entity_type, $bundle_arg, $bundle_pos, '%map',
),
'title' => 'Format type',
'page callback' => 'backdrop_get_form',
'page arguments' => array(
'field_group_format_type_form', $group_position,
),
'type' => MENU_LOCAL_TASK,
'file' => 'field_group.field_ui.inc',
) + $access;
$items["$path/groups/%field_group_menu/delete"] = array(
'load arguments' => array(
$entity_type, $bundle_arg, $bundle_pos, '%map',
),
'title' => 'Delete',
'page callback' => 'backdrop_get_form',
'page arguments' => array(
'field_group_delete_form', $group_position,
),
'type' => MENU_CALLBACK,
'file' => 'field_group.field_ui.inc',
) + $access;
$items["$path/groups/%field_group_menu/enable"] = array(
'load arguments' => array(
$entity_type, $bundle_arg, $bundle_pos, '%map',
),
'title' => 'Enable',
'page callback' => 'backdrop_get_form',
'page arguments' => array(
'field_group_enable_form', $group_position,
),
'type' => MENU_CALLBACK,
'file' => 'field_group.field_ui.inc',
) + $access;
}
}
}
}
return $items;
}