You are here

function location_node_form_node_type_form_alter in Location 7.3

Same name and namespace in other branches
  1. 6.3 location_node.module \location_node_form_node_type_form_alter()
  2. 7.4 location_node.module \location_node_form_node_type_form_alter()

Implements hook_form_FORM_ID_alter().

Alter the node_type_form form.

File

./location_node.module, line 150
Associate locations with nodes.

Code

function location_node_form_node_type_form_alter(&$form, &$form_state, $form_id) {
  $type = $form['#node_type']->type;

  // Hook the form handlers so we can correctly extract our information;
  // the node type form doesn't handle nested values correctly.
  array_unshift($form['#validate'], 'location_node_settings_validate');
  array_unshift($form['#submit'], '_location_node_type_save_submit');
  $settings = variable_get('location_settings_node_' . $type, array());
  $form['location_settings'] = location_settings($settings);
  $form['location_settings']['#group'] = 'additional_settings';

  // Tack on customizations for node settings.
  $form['location_settings']['display']['teaser'] = array(
    '#type' => 'checkbox',
    '#title' => t('Display location in teaser view'),
    '#default_value' => isset($settings['display']['teaser']) ? $settings['display']['teaser'] : TRUE,
    '#weight' => -2,
  );
  $form['location_settings']['display']['full'] = array(
    '#type' => 'checkbox',
    '#title' => t('Display location in full view'),
    '#default_value' => isset($settings['display']['full']) ? $settings['display']['full'] : TRUE,
    '#weight' => -1,
  );
  $form['location_settings']['rss'] = array(
    '#type' => 'fieldset',
    '#title' => t('RSS Settings'),
    '#description' => t('Here, you can change how locative data affects RSS feeds on nodes.'),
    '#tree' => TRUE,
    '#weight' => 5,
  );
  $form['location_settings']['rss']['mode'] = array(
    '#type' => 'select',
    '#title' => t('RSS mode'),
    '#description' => t('Select how to use locations in RSS feeds for this content type.'),
    '#options' => array(
      'none' => t('None (Do not put locational data in RSS feeds)'),
      'w3c' => t('W3C Geo (deprecated)'),
      'w3c_bugcompat' => t('Location 1.x-2.x compatible (buggy W3C)'),
      'simple' => t('GeoRSS-Simple'),
      'gml' => t('GeoRSS GML'),
    ),
    '#default_value' => isset($settings['rss']['mode']) ? $settings['rss']['mode'] : 'simple',
  );

  // Make the weights inaccessible if CCK is being used.
  if (module_exists('content')) {
    $form['location_settings']['form']['weight']['#type'] = 'value';
    $form['location_settings']['form']['weight']['#value'] = $form['location_settings']['form']['weight']['#default_value'];
    $form['location_settings']['display']['weight']['#type'] = 'value';
    $form['location_settings']['display']['weight']['#value'] = $form['location_settings']['display']['weight']['#default_value'];
  }

  // @@@ THIS IS NOT GOOD. --Bdragon
  // clear the views cache in case anything was changed
  if (function_exists('views_invalidate_cache')) {
    views_invalidate_cache();
  }
}