You are here

function getlocations_get_unit_names in Get Locations 7

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

Function

Return value

Returns

5 calls to getlocations_get_unit_names()
getlocations_element_distance_unit in ./getlocations.module
getlocations_fields_handler_filter_distance::exposed_form in modules/getlocations_fields/handlers/getlocations_fields_handler_filter_distance.inc
Render our chunk of the exposed filter form when selecting.
template_preprocess_getlocations_fields_distance in modules/getlocations_fields/getlocations_fields.module
Theme preprocess function for getlocations_fields_distance.
theme_getlocations_adinfo in ./getlocations.module
Returns HTML of a location's vcard, requested by ajax.
theme_getlocations_search_form in modules/getlocations_search/getlocations_search.module
Themes the search form and results.

File

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

Code

function getlocations_get_unit_names($unit = '', $type = 'plural') {
  $units_plural = array(
    'km' => t('Kilometers'),
    'm' => t('Meters'),
    'mi' => t('Miles'),
    'yd' => t('Yards'),
    'nmi' => t('Nautical miles'),
  );
  $units_plurals = array(
    'km' => t('Kilometer(s)'),
    'm' => t('Meter(s)'),
    'mi' => t('Mile(s)'),
    'yd' => t('Yard(s)'),
    'nmi' => t('Nautical mile(s)'),
  );
  $units = array(
    'km' => t('Kilometer'),
    'm' => t('Meter'),
    'mi' => t('Mile'),
    'yd' => t('Yard'),
    'nmi' => t('Nautical mile'),
  );

  // for dropdown
  $return = FALSE;
  if (empty($unit)) {
    if ($type == 'plural') {
      $return = $units_plural;
    }
    elseif ($type == 'plurals') {
      $return = $units_plurals;
    }
    else {
      $return = $units;
    }
  }
  else {

    // if $unit is supplied, return display name
    if (!in_array($unit, array_keys($units))) {
      $unit = 'km';
    }
    if ($type == 'plural') {
      $return = $units_plural[$unit];
    }
    elseif ($type == 'plurals') {
      $return = $units_plurals[$unit];
    }
    else {
      $return = $units[$unit];
    }
  }
  return $return;
}