function ds_display_overview_form in Display Suite 6.3
Same name and namespace in other branches
- 6 includes/ds.display.inc \ds_display_overview_form()
- 6.2 includes/ds.display.inc \ds_display_overview_form()
Menu callback; presents a listing of fields display settings for an object type.
Form includes form widgets to select which fields appear for teaser, full node etc and how the field labels should be rendered.
This function is based on content_display_overview_form from content.admin.inc of cck, but altered to have weights and regions.
1 string reference to 'ds_display_overview_form'
- _ds_ui_menu in includes/
ds.registry.inc - Return menu items and import default settings.
File
- includes/
ds.display.inc, line 169 - Display overview form.
Code
function ds_display_overview_form(&$form_state, $type, $build_mode = 'full', $module = 'nd') {
// Gather information.
$api_info = ds_api_info($module);
$display_settings = ds_get_settings($module, $type, $build_mode);
// See if this build mode isn't synced from another build mode.
$synced = FALSE;
$all_build_modes = ds_get_build_modes('nd');
foreach ($all_build_modes as $build_mode_key => $value) {
$values = ds_get_settings($module, $type, $build_mode_key);
if (isset($values['sync'])) {
foreach ($values['sync'] as $sync => $sync_value) {
if ($sync == $build_mode && isset($all_build_modes[$build_mode_key])) {
$synced = $build_mode_key;
break;
}
}
}
}
$settings_status = isset($display_settings['status']) ? $display_settings['status'] : DS_SETTINGS_UI;
$form = array(
'#synced' => FALSE,
'#tree' => TRUE,
'#module' => $module,
'#type_name' => $type,
'#fields' => array(),
'#build_mode' => $build_mode,
'#plugins' => FALSE,
'#extra' => array(),
'#status' => $settings_status,
'#regions' => ds_regions(variable_get('ds_build_mode_' . $build_mode, 'all')),
);
// Navigation to other build modes
$options = array(
'none' => '-- select --',
);
$build_modes = ds_get_active_build_modes($module, $type);
$type_url_str = str_replace('_', '-', $type);
foreach ($build_modes as $key => $mode) {
$mode_path = DS_PATH_LAYOUT . '/' . $type_url_str . '/' . $key;
$group = isset($mode['group']) ? $mode['group'] : t('Other');
$options[$group][$mode_path] = $mode['title'];
}
$form['nav'] = array(
'#type' => 'select',
'#options' => $options,
'#title' => t('Edit build mode'),
);
// Sync information
if (isset($synced) && !empty($synced)) {
$form['#synced'] = t('You can not edit this build mode right now because it is synchronised with !bm.', array(
'!bm' => l($all_build_modes[$synced]['title'], DS_PATH_LAYOUT . '/' . $type . '/' . $synced),
));
}
// Build style selects for region classes.
$region_style_options = ds_styles('regions');
$region_styles = ds_default_value($display_settings, 'region_styles');
foreach ($form['#regions'] as $key => $region_name) {
if ($key != 'disabled') {
$default_value = isset($region_styles[$key]) ? explode(' ', $region_styles[$key]) : array();
$form['region_styles_' . $key] = array(
'#type' => 'select',
'#title' => t('Region style'),
'#multiple' => TRUE,
'#options' => $region_style_options,
'#default_value' => $default_value,
'#description' => t('Select styles to apply to this region.'),
'#attributes' => array(
'class' => 'ds-style-change',
),
);
$human_names = array();
if (!empty($default_value)) {
$human_names = _ds_styles_match_options($region_style_options, array_filter($default_value));
}
$form['region_styles_' . $key . '_summary'] = array(
'#type' => 'markup',
'#value' => implode(', ', $human_names),
);
}
}
// Extra info.
if (isset($api_info['extra']) && !empty($api_info['extra'])) {
$types = $api_info['types']();
$type_info = $types[$type];
foreach ($api_info['extra'] as $key) {
$form['#extra'][$key] = $type_info->{$key};
}
}
// Add the fields.
ds_fields_display_form($form, $display_settings);
// Sync / copy tab.
ds_sync_copy_form($form, $display_settings, $build_mode, $module, $type);
// Plugins.
$plugins = TRUE;
if (isset($api_info['plugins_exclude']) && in_array($build_mode, $api_info['plugins_exclude'])) {
$plugins = FALSE;
}
if ($plugins) {
ds_plugins_display_form($form, $display_settings);
}
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save'),
);
return $form;
}