You are here

function _location_node_type_form_alter in Location 5.3

Alter the node_type_form form.

1 call to _location_node_type_form_alter()
location_node_form_alter in ./location_node.module
Implementation of hook_form_alter().

File

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

Code

function _location_node_type_form_alter($form_id, &$form) {
  $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.
  $form['#validate'] = array_merge(is_array($form['#validate']) ? $form['#validate'] : array(), array(
    'location_node_settings_validate' => array(),
  ));
  if (!is_array($form['#submit'])) {
    $form['#submit'] = array(
      'node_type_form_submit' => array(),
    );
  }
  $form['#submit'] = array_merge(array(
    '_location_node_type_save_submit' => array(),
  ), $form['#submit']);
  $settings = variable_get('location_settings_node_' . $type, array());
  $form['location_settings'] = location_settings($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.'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#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',
  );

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