You are here

function theme_getlocations_settings_form in Get Locations 7

Same name and namespace in other branches
  1. 7.2 getlocations.module \theme_getlocations_settings_form()

Returns HTML of the getlocations settings form.

Parameters

array $variables: An associative array containing:

  • form: The form array.

Return value

string The rendered form

File

./getlocations.module, line 7450
getlocations.module @author Bob Hutchinson http://drupal.org/user/52366 @copyright GNU GPL

Code

function theme_getlocations_settings_form($variables) {
  $form = $variables['form'];
  $output = '';
  $form['getlocations_default']['returnlink_page_link']['#prefix'] = '<div id="wrap-page-link">';
  $form['getlocations_default']['returnlink_page_link']['#suffix'] = '</div>';
  if (isset($form['getlocations_default']['returnlink_user_link'])) {
    $form['getlocations_default']['returnlink_user_link']['#prefix'] = '<div id="wrap-user-link">';
    $form['getlocations_default']['returnlink_user_link']['#suffix'] = '</div>';
  }
  if (isset($form['getlocations_default']['returnlink_term_link'])) {
    $form['getlocations_default']['returnlink_term_link']['#prefix'] = '<div id="wrap-term-link">';
    $form['getlocations_default']['returnlink_term_link']['#suffix'] = '</div>';
  }
  if (isset($form['getlocations_default']['returnlink_comment_link'])) {
    $form['getlocations_default']['returnlink_comment_link']['#prefix'] = '<div id="wrap-comment-link">';
    $form['getlocations_default']['returnlink_comment_link']['#suffix'] = '</div>';
  }
  if (isset($form['getlocations_colorbox']['width']) && isset($form['getlocations_colorbox']['height'])) {
    $form['getlocations_colorbox']['width']['#prefix'] = '<div id="wrap-getlocations-colorbox">';
    $form['getlocations_colorbox']['height']['#suffix'] = '</div>';
  }
  if (isset($form['getlocations_colorbox']['marker_width']) && isset($form['getlocations_colorbox']['marker_height'])) {
    $form['getlocations_colorbox']['marker_width']['#prefix'] = '<div id="wrap-getlocations-marker-colorbox">';
    $form['getlocations_colorbox']['marker_height']['#suffix'] = '</div>';
  }

  // marker colorbox
  if (module_exists('colorbox')) {
    $getlocations_colorbox = getlocations_colorbox_settings();
    if ($getlocations_colorbox['marker_enable']) {
      $link = getlocations_markerpicker_link($form['getlocations_default']['node_map_marker']['#id'], 'n');
      $form['getlocations_default']['node_map_marker']['#field_suffix'] = '&nbsp;' . $link;
      if (isset($form['getlocations_default']['user_map_marker'])) {
        $link = getlocations_markerpicker_link($form['getlocations_default']['user_map_marker']['#id'], 'u');
        $form['getlocations_default']['user_map_marker']['#field_suffix'] = '&nbsp;' . $link;
      }
      if (module_exists('taxonomy')) {
        if (isset($form['getlocations_default']['vocabulary_map_marker'])) {
          $link = getlocations_markerpicker_link($form['getlocations_default']['vocabulary_map_marker']['#id'], 'v');
          $form['getlocations_default']['vocabulary_map_marker']['#field_suffix'] = '&nbsp;' . $link;
        }
        if (isset($form['getlocations_default']['term_map_marker'])) {
          $link = getlocations_markerpicker_link($form['getlocations_default']['term_map_marker']['#id'], 't');
          $form['getlocations_default']['term_map_marker']['#field_suffix'] = '&nbsp;' . $link;
        }
      }
      if (isset($form['getlocations_default']['comment_map_marker'])) {
        $link = getlocations_markerpicker_link($form['getlocations_default']['comment_map_marker']['#id'], 'c');
        $form['getlocations_default']['comment_map_marker']['#field_suffix'] = '&nbsp;' . $link;
      }
      if (module_exists('getlocations_fields')) {
        $link = getlocations_markerpicker_link($form['getlocations_default']['input_map_marker']['#id'], 'i');
        $form['getlocations_default']['input_map_marker']['#field_suffix'] = '&nbsp;' . $link;
      }
      if ($types = getlocations_get_types()) {
        foreach ($types as $type => $name) {
          $field_names = getlocations_get_fieldname2($type, 'node');
          foreach ($field_names as $field_name) {
            if (isset($form['getlocations_node_marker']['content_type'][$type]['field_name'][$field_name]['map_marker'])) {
              $link = getlocations_markerpicker_link($form['getlocations_node_marker']['content_type'][$type]['field_name'][$field_name]['map_marker']['#id'], 'n');
              $form['getlocations_node_marker']['content_type'][$type]['field_name'][$field_name]['map_marker']['#field_suffix'] = '&nbsp;' . $link;
            }
          }
        }
      }
      if (module_exists('taxonomy')) {
        if ($types = getlocations_get_vocabularies()) {
          foreach ($types as $type => $name) {
            if (isset($form['getlocations_vocabulary_marker']['vocabulary'][$type]['map_marker'])) {
              $link = getlocations_markerpicker_link($form['getlocations_vocabulary_marker']['vocabulary'][$type]['map_marker']['#id'], 'v');
              $form['getlocations_vocabulary_marker']['vocabulary'][$type]['map_marker']['#field_suffix'] = '&nbsp;' . $link;
            }
          }
        }

        // term
        $getlocations_term_marker = variable_get('getlocations_term_marker', array(
          'enable' => 0,
          'vids' => 0,
          'max_depth' => '',
        ));
        if ($getlocations_term_marker['enable'] && $getlocations_term_marker['vids']) {
          $depth = is_numeric($getlocations_term_marker['max_depth']) && $getlocations_term_marker['max_depth'] > 0 ? $getlocations_term_marker['max_depth'] : NULL;
          $vids = $getlocations_term_marker['vids'];
          foreach ($vids as $vid) {
            $terms = taxonomy_get_tree($vid, 0, $depth);
            $tct = 0;
            foreach ($terms as $term) {
              $tid = $term->tid;
              if (isset($form['getlocations_term_marker']['vid'][$vid]['term'][$tid]['map_marker'])) {
                $link = getlocations_markerpicker_link($form['getlocations_term_marker']['vid'][$vid]['term'][$tid]['map_marker']['#id'], 't');
                $form['getlocations_term_marker']['vid'][$vid]['term'][$tid]['map_marker']['#field_suffix'] = '&nbsp;' . $link;
                if (!$tct) {
                  $v = taxonomy_vocabulary_load($vid);
                  $vocab_name = $v->name;
                  $form['getlocations_term_marker']['vid'][$vid]['term'][$tid]['map_marker']['#prefix'] = t('Terms for %name', array(
                    '%name' => $vocab_name,
                  ));
                }
              }
              $tct++;
            }
          }
        }
      }
    }
  }
  $form['getlocations_default']['useclustermanager']['#prefix'] = '<div id="wrap-getlocations-clusteropts">';
  $form['getlocations_default']['markerclusterer_minsize']['#suffix'] = '</div>';
  $form['getlocations_default']['usemarkermanager']['#prefix'] = '<div id="wrap-getlocations-markeropts">';
  $form['getlocations_default']['maxzoom']['#suffix'] = '</div>';
  if (isset($form['getlocations_default']['gps_button']) && $form['getlocations_default']['gps_button']['#type'] !== 'value') {
    $form['getlocations_default']['gps_button']['#prefix'] = '<fieldset class="collapsible getlocations_fieldset form-wrapper"><legend><span class="fieldset-legend">' . t('GPS Button') . '</span></legend><div class="fieldset-wrapper">';
    $tsuf = $form['getlocations_default']['gps_center']['#suffix'];
    $form['getlocations_default']['gps_center']['#suffix'] = $tsuf . '</div></fieldset>';
  }
  if (isset($form['getlocations_default']['smartip_button']) && $form['getlocations_default']['smartip_button']['#type'] !== 'value') {
    $form['getlocations_default']['smartip_button']['#prefix'] = '<fieldset class="collapsible getlocations_fieldset form-wrapper"><legend><span class="fieldset-legend">' . t('Smartip Button') . '</span></legend><div class="fieldset-wrapper">';
    $tsuf = $form['getlocations_default']['smartip_center']['#suffix'];
    $form['getlocations_default']['smartip_center']['#suffix'] = $tsuf . '</div></fieldset>';
  }

  // preview
  $getlocations_defaults = getlocations_defaults();
  $getlocations_defaults['extcontrol'] = 'preview_map';
  $mapid = getlocations_setup_map($getlocations_defaults);
  $minmaxes = '';
  $latlons = array();
  getlocations_js_settings_do($getlocations_defaults, $latlons, $minmaxes, $mapid, FALSE, $getlocations_defaults['extcontrol']);
  $preview_map = theme('getlocations_show', array(
    'width' => $getlocations_defaults['width'],
    'height' => $getlocations_defaults['height'],
    'defaults' => $getlocations_defaults,
    'mapid' => $mapid,
    'latlons' => $latlons,
    'minmaxes' => $minmaxes,
    'type' => '',
    'node' => '',
  ));
  $form['getlocations_preview']['preview_map']['#markup'] = '<div id="getlocations_preview_map">' . $preview_map . '</div>';
  $output .= drupal_render_children($form);
  return $output;
}