You are here

function taxonomy_display_admin_form in Taxonomy display 7

Helper callback; perform form alterations for taxonomy display admin form.

_state

Parameters

array $form:

Return value

void

See also

taxonomy_display_form_fieldset()

1 call to taxonomy_display_admin_form()
taxonomy_display_form_field_ui_display_overview_form_alter in ./taxonomy_display.module
Implements hook_form_FORM_ID_alter().

File

./taxonomy_display.admin.inc, line 18
Administration form functions for taxonomy display configuration.

Code

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

  // Only proceed if we are on taxonomy_term entity type and the user has admin
  // taxonomy display.
  if ($form['#entity_type'] != 'taxonomy_term' || !user_access('administer taxonomy display')) {
    return;
  }

  // Ensure 'additional_settings' exists.
  taxonomy_display_admin_form_setup_additional_settings($form);

  // Make things easy on users getting started with the module.
  // We require the 'full' #view_mode to configure the taxonomy term page.
  if ($form['#view_mode'] == 'default') {
    $field = array(
      '#title' => t('Term page display'),
      '#type' => 'fieldset',
    );

    // Find out if full mode is enabled and change the description for term page
    // display to match.
    $entity_info = entity_get_info('taxonomy_term');
    $view_mode_settings = field_view_mode_settings('taxonomy_term', $form['#bundle']);
    if (isset($view_mode_settings['full']['custom_settings'])) {
      $field['#description'] = t('To alter the term page display you need to go to the <em>Taxonomy term page</em> view mode.');
    }
    else {
      $field['#description'] = t('Enable the <em>Taxonomy term page</em> view mode under the <em>Custom display settings</em> tab to alter the term page display.');
    }
    $form['additional_settings']['taxonomy_display'] = $field;
  }

  // Only proceed if we are on the full display mode.
  if ($form['#view_mode'] != 'full') {
    return;
  }

  // Retrieve the stored taxonomy display settings for the vocabulary.
  $stored_settings = taxonomy_display_fetch_taxonomy_display($form['#bundle']);
  $form['additional_settings']['taxonomy_display'] = array(
    '#description' => t('Configure how the taxonomy term display page should be presented when viewed for this vocabulary.'),
    '#title' => t('Term page display'),
    '#type' => 'fieldset',
  );
  $fieldset =& $form['additional_settings']['taxonomy_display'];

  // Build the plugin forms for term and associated content display.
  $plugin_types = _taxonomy_display_plugin_types();
  foreach ($plugin_types as $k => $v) {
    _taxonomy_display_admin_form_build_plugin_form($k, $fieldset, $form_state, $stored_settings);
  }

  // Add selection for adding taxonomy term core feed to page
  $fieldset['add_feed'] = array(
    '#default_value' => $stored_settings->add_feed,
    '#description' => t('Drupal, by default, includes a feed of content referencing the term, by unchecking this you can prevent the feed from being added.'),
    '#title' => t('Include feed'),
    '#type' => 'checkbox',
  );

  // Add our #validate and #submit callback which will call plugins' methods.
  $form['#validate'][] = 'taxonomy_display_admin_form_validate';
  $form['#submit'][] = 'taxonomy_display_admin_form_submit';
}