1 field_ui.module | field_ui_menu() |
Implements hook_menu().
File
- core/
modules/ field_ui/ field_ui.module, line 30 - Allows administrators to attach custom fields to fieldable types.
Code
function field_ui_menu() {
$items['admin/reports/fields'] = array(
'title' => 'Fields',
'description' => 'Overview of fields on all entity types.',
'page callback' => 'field_ui_fields_list',
'access arguments' => array('administer content types'),
'type' => MENU_NORMAL_ITEM,
'file' => 'field_ui.admin.inc',
);
// Create tabs for all possible bundles.
foreach (entity_get_info() as $entity_type => $entity_info) {
if ($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_menu_node_type). To allow field_ui_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_position = (string) $bundle_arg;
}
else {
$bundle_arg = $bundle_name;
$bundle_position = '0';
}
// This is the position of the %field_ui_menu placeholder in the
// items below.
$field_position = count(explode('/', $path)) + 1;
$view_mode_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.
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']),
);
}
$items["$path/fields"] = array(
'title' => 'Manage fields',
'page callback' => 'backdrop_get_form',
'page arguments' => array('field_ui_field_overview_form', $entity_type, $bundle_arg),
'type' => MENU_LOCAL_TASK,
'weight' => 1,
'file' => 'field_ui.admin.inc',
) + $access;
$items["$path/fields/%field_ui_menu"] = array(
'load arguments' => array($entity_type, $bundle_arg, $bundle_position, '%map'),
'title callback' => 'field_ui_menu_title',
'title arguments' => array($field_position),
'page callback' => 'backdrop_get_form',
'page arguments' => array('field_ui_field_edit_form', $field_position),
'file' => 'field_ui.admin.inc',
) + $access;
$items["$path/fields/%field_ui_menu/edit"] = array(
'load arguments' => array($entity_type, $bundle_arg, $bundle_position, '%map'),
'title' => 'Edit',
'page callback' => 'backdrop_get_form',
'page arguments' => array('field_ui_field_edit_form', $field_position),
'type' => MENU_DEFAULT_LOCAL_TASK,
'file' => 'field_ui.admin.inc',
) + $access;
$items["$path/fields/%field_ui_menu/field-settings"] = array(
'load arguments' => array($entity_type, $bundle_arg, $bundle_position, '%map'),
'title' => 'Field settings',
'page callback' => 'backdrop_get_form',
'page arguments' => array('field_ui_field_settings_form', $field_position),
'type' => MENU_LOCAL_TASK,
'file' => 'field_ui.admin.inc',
) + $access;
$items["$path/fields/%field_ui_menu/widget-type"] = array(
'load arguments' => array($entity_type, $bundle_arg, $bundle_position, '%map'),
'title' => 'Widget type',
'page callback' => 'backdrop_get_form',
'page arguments' => array('field_ui_widget_type_form', $field_position),
'type' => MENU_LOCAL_TASK,
'file' => 'field_ui.admin.inc',
) + $access;
$items["$path/fields/%field_ui_menu/delete"] = array(
'load arguments' => array($entity_type, $bundle_arg, $bundle_position, '%map'),
'title' => 'Delete',
'page callback' => 'backdrop_get_form',
'page arguments' => array('field_ui_field_delete_form', $field_position),
'type' => MENU_VISIBLE_IN_BREADCRUMB,
'weight' => 10,
'file' => 'field_ui.admin.inc',
) + $access;
// 'Manage displays' overview.
$items["$path/display"] = array(
'title' => 'Manage displays',
'page callback' => 'field_ui_display_overview',
'page arguments' => array($entity_type, $bundle_arg),
'type' => MENU_LOCAL_TASK,
'weight' => 2,
'file' => 'field_ui.admin.inc',
) + $access;
// Secondary tab for 'Manage display' overview.
$items["$path/display/overview"] = array(
'title' => 'Overview',
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => -99,
) + $access;
// Display modes.
// The same base $path for the menu item (with a placeholder) can be
// used for all bundles of a given entity type; but depending on
// administrator settings, each bundle has a different set of view
// modes available for customization. So we define menu items for all
// Display modes, and use an access callback to determine which ones
// are actually visible for a given bundle.
$view_modes = array(
'default' => array(
'label' => t('Default'),
),
) + $entity_info['view modes'];
foreach ($view_modes as $view_mode => $view_mode_info) {
$items["$path/display/$view_mode"] = array(
'title' => $view_mode_info['label'],
'page callback' => 'backdrop_get_form',
'page arguments' => array(
'field_ui_display_form',
$entity_type,
$bundle_arg,
$view_mode,
),
// The access callback needs to check both the current 'custom
// display' setting for the view mode, and the overall access
// rules for the bundle admin pages.
'access callback' => '_field_ui_view_mode_menu_access',
'access arguments' => array_merge(
array(
$entity_type,
$bundle_arg,
$view_mode,
$access['access callback'],
), $access['access arguments']),
'type' => MENU_LOCAL_TASK,
'file' => 'field_ui.admin.inc',
);
}
// Display mode administration.
$items["$path/display/add"] = array(
'title' => 'Add display mode',
'page callback' => 'backdrop_get_form',
'page arguments' => array('field_ui_view_mode_form', $entity_type, $bundle_arg),
'access arguments' => array('administer view modes'),
'file' => 'field_ui.admin.inc',
'type' => MENU_LOCAL_ACTION,
);
$items["$path/display/%/configure"] = array(
'title' => 'Configure Display mode',
'page callback' => 'backdrop_get_form',
'page arguments' => array('field_ui_view_mode_form', $entity_type, $bundle_arg, $view_mode_position),
'access arguments' => array('administer view modes'),
'file' => 'field_ui.admin.inc',
);
$items["$path/display/%/delete"] = array(
'title' => 'Delete Display mode',
'page callback' => 'backdrop_get_form',
'page arguments' => array('field_ui_view_mode_delete_form', $entity_type, $bundle_arg, $view_mode_position),
'access arguments' => array('administer view modes'),
'file' => 'field_ui.admin.inc',
);
$items["$path/display/%/enable"] = array(
'title' => 'Enable Display mode',
'page callback' => 'field_ui_view_mode_enable',
'page arguments' => array($entity_type, $bundle_arg, $view_mode_position),
'access callback' => 'field_ui_view_mode_enable_access',
'file' => 'field_ui.admin.inc',
);
$items["$path/display/%/reset"] = array(
'title' => 'Reset to default',
'page callback' => 'backdrop_get_form',
'page arguments' => array('field_ui_view_mode_reset_form', $entity_type, $bundle_arg, $view_mode_position),
'access arguments' => array('administer view modes'),
'file' => 'field_ui.admin.inc',
);
}
}
}
}
return $items;
}