You are here

function ds_extras_field_ui_alter in Display Suite 7.2

Same name and namespace in other branches
  1. 7 modules/ds_extras/ds_extras.admin.inc \ds_extras_field_ui_alter()

Alter Manage display screen.

1 call to ds_extras_field_ui_alter()
ds_extras_form_field_ui_display_overview_form_alter in modules/ds_extras/ds_extras.module
Implements hook_form_FORM_ID_alter().

File

modules/ds_extras/includes/ds_extras.admin.inc, line 193
Display Suite Extras administrative functions.

Code

function ds_extras_field_ui_alter(&$form, &$form_state) {

  // Attach js.
  $form['#attached']['js'][] = drupal_get_path('module', 'ds_extras') . '/js/ds_extras.admin.js';

  // Views displays.
  if ($form['#entity_type'] == 'ds_views') {

    // Add an additional submit callback so we can ditch the extra title
    // which is added by ds_extras_field_extra_fields().
    $form['#submit'] = array_merge(array(
      'ds_extras_vd_field_ui_submit',
    ), $form['#submit']);
  }

  // Page title functionality, currently only works on nodes, users and taxonomy terms.
  if (variable_get('ds_extras_hide_page_title', FALSE) && isset($form['#ds_layout']) && (in_array($form['#entity_type'], array(
    'node',
    'user',
    'taxonomy_term',
    'profile2',
  )) && ($form['#view_mode'] == 'full' || $form['#view_mode'] == 'revision' || variable_get('ds_extras_switch_view_mode', FALSE) && $form['#entity_type'] == 'node') || $form['#entity_type'] == 'ds_views' || $form['#entity_type'] == 'profile2')) {
    $form['additional_settings']['ds_page_title'] = array(
      '#type' => 'fieldset',
      '#title' => t('Custom page title'),
    );
    $form['additional_settings']['ds_page_title']['ds_page_title_options'] = _ds_extras_page_title_options($form['#ds_layout']->settings, $form['#entity_type']);
  }

  // Disable page regions.
  if (variable_get('ds_extras_hide_page_sidebars', FALSE) && isset($form['#ds_layout']) && $form['#view_mode'] != 'form') {
    $form['additional_settings']['ds_layouts']['hide_sidebars'] = array(
      '#type' => 'checkbox',
      '#title' => t('Disable Drupal blocks/regions'),
      '#default_value' => isset($form['#ds_layout']->settings['hide_sidebars']) ? $form['#ds_layout']->settings['hide_sidebars'] : FALSE,
      '#weight' => 3,
    );
  }

  // Region to block only fires if there is a layout and we're working on the
  // a view mode which is not equal to default.
  if (isset($form['#ds_layout']) && $form['#view_mode'] != 'default' && variable_get('ds_extras_region_to_block', FALSE)) {
    $layout = $form['#ds_layout'];

    // Get the entity_type, bundle and view mode.
    $entity_type = $form['#entity_type'];
    $bundle = $form['#bundle'];
    $view_mode = $form['#view_mode'];
    $region_blocks_options = array();
    $region_blocks = variable_get('ds_extras_region_blocks', array());
    foreach ($region_blocks as $key => $block) {
      if ($block['info'] == "{$entity_type}_{$bundle}_{$view_mode}") {
        $region_blocks_options[$key] = t('Remove') . ' ' . $block['title'];
      }
    }
    $form['additional_settings']['region_to_block'] = array(
      '#type' => 'fieldset',
      '#title' => t('Block regions'),
      '#description' => t('Create additional regions in this layout which will be exposed as blocks. Note that preprocess fields will fail to print.'),
    );
    $form['additional_settings']['region_to_block']['new_block_region'] = array(
      '#type' => 'textfield',
      '#title' => t('Region name'),
      '#description' => t('Enter a name to create a new region.'),
    );
    $form['additional_settings']['region_to_block']['new_block_region_key'] = array(
      '#title' => t('Machine name'),
      '#type' => 'machine_name',
      '#default_value' => '',
      '#maxlength' => 32,
      '#required' => FALSE,
      '#description' => t('The machine-readable name of this block region. This name must contain only lowercase letters and underscores. This name must be unique.'),
      '#disabled' => FALSE,
      '#machine_name' => array(
        'exists' => 'ds_extras_region_to_block_unique',
        'source' => array(
          'additional_settings',
          'region_to_block',
          'new_block_region',
        ),
      ),
    );
    if (!empty($region_blocks_options)) {
      $form['additional_settings']['region_to_block']['remove_block_region'] = array(
        '#type' => 'checkboxes',
        '#title' => t('Existing block regions'),
        '#options' => $region_blocks_options,
        '#description' => t('Check the regions you want to remove.'),
      );
    }
    $form['#submit'][] = 'ds_extras_block_submit';
  }
}