1 field_ui.admin.inc | field_ui_display_overview($entity_type, $bundle) |
Form constructor for the field display settings for a given display mode.
See also
Related topics
File
- core/
modules/ field_ui/ field_ui.admin.inc, line 870 - Admin page callbacks for the Field UI module.
Code
function field_ui_display_overview($entity_type, $bundle) {
if (is_object($bundle) && property_exists($bundle, 'name')) {
$bundle_label = check_plain($bundle->name);
}
$bundle = field_extract_bundle($entity_type, $bundle);
$admin_path = _field_ui_bundle_admin_path($entity_type, $bundle);
$entity_info = entity_get_info($entity_type);
if (!isset($bundle_label)) {
$bundle_label = check_plain($entity_info['label']);
}
$view_mode_settings = field_view_mode_settings($entity_type, $bundle);
$custom_view_modes = config_get('entity.view_modes', 'view_modes');
$view_modes = $entity_info['view modes'];
if (is_array($view_modes)) {
backdrop_sort($view_modes, array('label' => SORT_STRING));
}
$custom = array();
$default = array();
// Sort display modes into active/default, and merge in display mode settings.
foreach ($view_modes as $view_mode_name => $mode) {
$custom_settings = isset($view_mode_settings[$view_mode_name]['custom_settings']) ? (bool) $view_mode_settings[$view_mode_name]['custom_settings'] : (bool) $mode['custom settings'];
$custom[$view_mode_name] = array(
'label' => $mode['label'],
'custom settings' => $custom_settings,
'storage' => !empty($custom_view_modes[$entity_type][$view_mode_name]) ? 'Custom' : 'Default (module-provided)',
'status' => $custom_settings ? 'Customized' : 'Using the <em>Default display</em>',
);
if (!($custom_settings)) {
$default[$view_mode_name] = $custom[$view_mode_name];
unset($custom[$view_mode_name]);
}
}
$build = array(
'#entity_type' => $entity_type,
'#bundle' => $bundle,
'#attached' => array(
'css' => array(backdrop_get_path('module', 'field_ui') . '/css/field_ui.css'),
),
);
$build['help'] = array(
'#type' => 'help',
'#markup' => t('<strong>Display modes</strong> are variations of how an item can be displayed. Each @label display mode can be configured differently. For example: individual fields can be displayed using a different format, or hidden entirely.', array('@label' => $bundle_label)),
);
$build['view_modes'] = array(
'#theme' => 'field_ui_view_modes',
'#tree' => TRUE,
'#view_modes' => $custom + $default,
'#entity_type' => $entity_type,
'#bundle' => $bundle,
'#bundle_label' => $bundle_label,
'#admin_path' => $admin_path,
);
return $build;
}