You are here

function _location_driving_directions_link_ca_yahoo in Location 7.4

Same name and namespace in other branches
  1. 5.3 supported/location.ca.inc \_location_driving_directions_link_ca_yahoo()
  2. 5 supported/location.ca.inc \_location_driving_directions_link_ca_yahoo()
  3. 6.3 supported/location.ca.inc \_location_driving_directions_link_ca_yahoo()
  4. 7.5 supported/location.ca.inc \_location_driving_directions_link_ca_yahoo()
  5. 7.3 supported/location.ca.inc \_location_driving_directions_link_ca_yahoo()

Parameters: Function that is called by location_driving_directions_link_ca() under assumption that it is the chosen function

Returns: a URL with HTTP GET variables Depending on how full the locationes are, the URL will either point to the driving directions on Yahoo! or, if only partial locationes are provided, a URL that points to the *form* for Yahoo! driving directions where the form is filled with whatever fields have been provided for the partial location(es).

1 call to _location_driving_directions_link_ca_yahoo()
location_driving_directions_link_ca in supported/location.ca.inc
Parameters: -> $location_a is an associative array that represents a full location where 'street' => the street portions of the location 'supplemental' => additional street portion of the…

File

supported/location.ca.inc, line 218

Code

function _location_driving_directions_link_ca_yahoo($location_a, $location_b) {
  if (trim($location_b['country']) != 'ca' && trim($location_b['country']) != 'us') {
    return '';
  }

  // These are the fields that need to be in each location if we are to provide a direct
  // link to yahoo directions.  If all of these fields don't have values, then we generate
  // a link to the *form* for Yahoo! driving directions rather than directly to the driving
  // directions themselves.
  foreach ($location_a as $field => $value) {
    $location_a[$field] = trim($value);
  }
  foreach ($location_b as $field => $value) {
    $location_b[$field] = trim($value);
  }
  if (_location_ca_enough_fields_for_yahoo($location_a) && _location_ca_enough_fields_for_yahoo($location_b)) {
    $yahoo_maps_path = 'dd_result';
  }
  else {
    $yahoo_maps_path = 'dd';
  }
  $get_query = '?';
  $get_query .= 'addr=' . urlencode($location_a['street']) . '&';
  $get_query .= 'csz=' . _location_ca_yahoo_csz_get_field($location_a) . '&';
  $get_query .= 'country=' . urlencode($location_a['country']) . '&';
  $get_query .= 'taddr=' . urlencode($location_b['street']) . '&';
  $get_query .= 'tcsz=' . _location_ca_yahoo_csz_get_field($location_b) . '&';
  $get_query .= 'tcountry=' . urlencode($location_b['country']);
  $get_query .= '&getrte=' . urlencode('Get Directions');
  return 'http://ca.maps.yahoo.com/' . $yahoo_maps_path . $get_query;
}