You are here

function gmap_taxonomy_form_alter in GMap Module 5

Same name and namespace in other branches
  1. 6.2 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_id, &$form) {
  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],
    );
    $form['submit']['#weight']++;
    if ($form['delete']) {
      $form['delete']['#weight'] += 2;
    }
  }
  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,
      );
      $form['submit']['#weight']++;
      if ($form['delete']) {
        $form['delete']['#weight'] += 2;
      }
    }
  }
}