You are here

function ds_display_overview_form in Display Suite 6

Same name and namespace in other branches
  1. 6.3 includes/ds.display.inc \ds_display_overview_form()
  2. 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 = variable_get($module . '_display_settings_' . $type, array());
  $settings_status = isset($display_settings[$build_mode]['status']) ? $display_settings[$build_mode]['status'] : DS_SETTINGS_UI;

  // See if this build mode isn't synced from another build mode.
  $synced = FALSE;
  $all_build_modes = ds_get_build_modes('nd');
  foreach ($display_settings as $build_mode_key => $values) {
    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;
        }
      }
    }
  }
  $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')),
  );
  if ($synced) {
    $form['#synced'] = t('You can not edit this buildmode right now because it is synchronised with !bm.', array(
      '!bm' => l($all_build_modes[$synced]['title'], 'admin/build/ds/layout/' . $type . '/' . $synced),
    ));
  }

  // Build style selects for region classes.
  $region_style_options = ds_styles('regions');
  $region_styles = ds_default_value($display_settings, $build_mode, '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;
}