You are here

function gmap_taxonomy_form_alter in GMap Module 6.2

Same name and namespace in other branches
  1. 5 gmap_taxonomy.module \gmap_taxonomy_form_alter()
  2. 6 gmap_taxonomy.module \gmap_taxonomy_form_alter()
  3. 7.2 gmap_taxonomy.module \gmap_taxonomy_form_alter()
  4. 7 gmap_taxonomy.module \gmap_taxonomy_form_alter()

Implementation of hook_form_alter().

File

./gmap_taxonomy.module, line 13
GMap Taxonomy Markers

Code

function gmap_taxonomy_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'taxonomy_form_vocabulary') {
    $form['gmap_taxonomy'] = array(
      '#type' => 'fieldset',
      '#title' => t('GMap markers'),
    );
    $vid = isset($form['vid']) ? $form['vid']['#value'] : -1;
    $temp = variable_get('gmap_taxonomy_vocabs', array());
    if (!isset($temp[$vid])) {
      $temp[$vid] = 0;
    }
    $form['gmap_taxonomy']['gmap_taxonomy_enable'] = array(
      '#type' => 'checkbox',
      '#title' => t('Enable'),
      '#description' => t('Enable choosing a marker for terms in this vocabulary.'),
      '#default_value' => $temp[$vid],
    );
  }
  if ($form_id == 'taxonomy_form_term') {
    $vid = $form['vid']['#value'];
    $vocs = variable_get('gmap_taxonomy_vocabs', array());
    if (isset($vocs[$vid]) && $vocs[$vid]) {
      $temp = '';
      if (isset($form['tid'])) {
        if ($t = db_result(db_query('SELECT marker FROM {gmap_taxonomy_term} WHERE tid = %d', $form['tid']['#value']))) {
          $temp = $t;
        }
      }
      $form['gmap_taxonomy_marker'] = array(
        '#title' => t('GMap Marker'),
        '#type' => 'select',
        '#options' => array(
          '' => t('No Marker'),
        ) + gmap_get_marker_titles(),
        '#description' => t('If you would like nodes tagged as this term to have a special marker, choose one here.'),
        '#default_value' => $temp,
      );
    }
  }

  // Move the Save and Delete buttons down below our additions.
  if ($form_id == 'taxonomy_form_vocabulary' || $form_id == 'taxonomy_form_term') {
    if (isset($form['submit']['#weight'])) {
      $form['submit']['#weight']++;
    }
    else {
      $form['submit']['#weight'] = 1;
    }
    if (isset($form['delete'])) {
      if (isset($form['delete']['#weight'])) {
        $form['delete']['#weight'] += 2;
      }
      else {
        $form['delete']['#weight'] = 2;
      }
    }
  }
}