You are here

function theme_getlocations_search_form in Get Locations 7

Same name and namespace in other branches
  1. 7.2 modules/getlocations_search/getlocations_search.module \theme_getlocations_search_form()

Themes the search form and results.

Parameters

array $variables:

Return value

Returns $output

File

modules/getlocations_search/getlocations_search.module, line 730
getlocations_search.module @author Bob Hutchinson http://drupal.org/user/52366 @copyright GNU GPL

Code

function theme_getlocations_search_form($variables) {
  $form = $variables['form'];
  $which = $form['which']['#value'];
  unset($form['which']);
  $mapid = $form['mapid']['#value'];
  unset($form['mapid']);
  $display_latlon = $form['display_latlon']['#value'];
  unset($form['display_latlon']);
  $display_accuracy = $form['display_accuracy']['#value'];
  unset($form['display_accuracy']);
  $display_geo_microformat = $form['display_geo_microformat']['#value'];
  unset($form['display_geo_microformat']);
  $output = '';
  $form['getlocations_search_' . $mapid]['#prefix'] = '<div id="getlocations_search_wrapper">';
  $form['getlocations_search_submit']['#suffix'] = '</div>';

  // if the units dropdown is not exposed show the units after the distance box
  if ($form['getlocations_search_units_' . $mapid]['#type'] == 'hidden' && $form['getlocations_search_distance_' . $mapid]['#type'] !== 'hidden') {
    $form['getlocations_search_distance_' . $mapid]['#field_suffix'] = getlocations_get_unit_names($form['getlocations_search_units_' . $mapid]['#value'], 'plurals');
  }
  if (getlocations_is_mobile() && isset($form['getlocations_search_geolocation_button_' . $mapid])) {
    $geolocation_button = '<div id="getlocations_search_geolocation_button_wrapper_' . $mapid . '"><p>';
    $geolocation_button .= '<input type="button" value="' . t('Find current Location') . '" title="' . t('Get the latitude and longitude for this location from the browser') . '" id="getlocations_search_geolocation_button_' . $mapid . '" class="form-submit" />&nbsp;';
    $geolocation_button .= '<span id="getlocations_search_geolocation_status_ok_' . $mapid . '" class="js-hide" ><img src="' . base_path() . GETLOCATIONS_PATH . '/images/ok.png' . '" title="' . t('Geolocation OK') . '" /></span>';
    $geolocation_button .= '<span id="getlocations_search_geolocation_status_err_' . $mapid . '" class="js-hide" ><img src="' . base_path() . GETLOCATIONS_PATH . '/images/error.png' . '" title="' . t('Geolocation failed') . '" /></span>';
    $geolocation_button .= '<span id="getlocations_search_geolocation_status_load_' . $mapid . '" class="js-hide" ><img src="' . base_path() . GETLOCATIONS_PATH . '/images/loading_small.gif' . '" title="' . t('Geolocation loading') . '" /></span>';
    $geolocation_button .= '</p>';
    $geolocation_button .= '<p>' . t('Use the browser to find your current location') . '</p></div>';
    $form['getlocations_search_geolocation_button_' . $mapid]['#markup'] = $geolocation_button;
  }
  if (isset($form['getlocations_search_country_' . $mapid]['#markup'])) {
    $restrict_country = '<p>' . t('Restrict the search to %c', array(
      '%c' => getlocations_get_country_name($form['getlocations_search_country_' . $mapid]['#markup']),
    )) . '</p>';
    $form['getlocations_search_country_' . $mapid]['#markup'] = $restrict_country;
  }

  // geocode button
  if (isset($form['getlocations_search_geocode_button_' . $mapid]['#markup'])) {
    $geocode_button = '<div id="getlocations_search_geocode_button_wrapper_' . $mapid . '">';
    $geocode_button .= '<input type="button" value="' . t('Geocode') . '" title="' . t('Geocode this address') . '" id="getlocations_search_geocode_button_' . $mapid . '" class="form-submit" />';
    $geocode_button .= '</div>';
    $form['getlocations_search_geocode_button_' . $mapid]['#markup'] = $geocode_button;
  }

  // reset button
  if (isset($form['getlocations_search_reset_button_' . $mapid]['#markup'])) {
    $reset_button = '<div id="getlocations_search_reset_button_wrapper_' . $mapid . '">';
    $reset_button .= '<input type="button" value="' . t('Reset') . '" title="' . t('Reset this form') . '" id="getlocations_search_reset_button_' . $mapid . '" class="form-submit" />';
    $reset_button .= '</div>';
    $form['getlocations_search_reset_button_' . $mapid]['#markup'] = $reset_button;
  }
  $output .= drupal_render_children($form);

  // $which can be page or block so we can change things accordingly
  $output .= "<!-- {$which} -->";
  $output .= '<div id="getlocations_search' . ($which == 'block' ? '_block' : '') . '_result">';
  $output .= '<h4>' . t('Results') . '</h4>';
  $output .= '<div id="getlocations_search_address_' . $mapid . '"></div>';
  $output .= '<div id="getlocations_search_distance_' . $mapid . '"></div>';
  $output .= '<div id="getlocations_search_count_' . $mapid . '"></div>';
  $output .= '<div id="getlocations_search_type_' . $mapid . '"></div>';
  if ($display_accuracy) {
    $output .= '<div id="getlocations_search_accuracy_' . $mapid . '"></div>';
  }
  if ($display_latlon) {
    $output .= '<div id="getlocations_search' . ($which == 'block' ? '_block' : '') . '_latlon_wrapper">';
    if ($display_geo_microformat) {
      $output .= '<div id="getlocations_search_latlon_' . $mapid . '" class="getlocations_search' . ($which == 'block' ? '_block' : '') . '_latlon"></div>';
    }
    else {
      $output .= '<div id="getlocations_search_lat_' . $mapid . '" class="getlocations_search' . ($which == 'block' ? '_block' : '') . '_lat"></div>';
      $output .= '<div id="getlocations_search_lon_' . $mapid . '" class="getlocations_search' . ($which == 'block' ? '_block' : '') . '_lon"></div>';
    }
    $output .= '</div>';
  }
  $output .= '</div>';

  // hidden
  $output .= '<div id="getlocations_search_data_' . $mapid . '" class="js-hide">';
  $output .= '<div id="getlocations_search_slat_' . $mapid . '"></div>';
  $output .= '<div id="getlocations_search_slon_' . $mapid . '"></div>';
  $output .= '<div id="getlocations_search_sunit_' . $mapid . '"></div>';
  $output .= '<div id="getlocations_search_markerdata_' . $mapid . '"></div>';
  $output .= '</div>';
  return $output;
}