View source
<?php
function location_map_link_de($location = array(), $hide = array()) {
$map_links = array();
if ($link = _location_map_link_de_tinfo($location)) {
$map_links['T-info'] = $link;
}
return $map_links;
}
function _location_map_link_de_tinfo($location = array()) {
$get_query = '?';
$get_query .= 'map_input.country=2';
if (isset($location['street'])) {
$get_query .= '&' . 'map_input.street=' . urlencode($location['street']);
}
if ($location['postal_code'] != '') {
$get_query .= '&' . 'map_input.zip=' . urlencode($location['postal_code']);
}
if ($location['city'] != '') {
$get_query .= '&' . 'map_input.city_manual=' . urlencode($location['city']);
}
return 'http://www.t-info.de/map/jumppage/map.jsp' . $get_query;
}
function location_map_link_de_providers() {
return array(
'tinfo' => array(
'name' => 'T-Info',
'url' => 'http://www.t-info.de/map/index.jsp',
'tos' => 'http://www.t-info.de/map/application?origin=note.jsp&event=bea.portal.framework.internal.refresh&pageid=TermsOfUse&portal.content_id=30600',
),
);
}
function location_map_link_de_default_providers() {
return array();
}
function location_driving_directions_link_de($locationA, $locationB) {
return _location_driving_directions_link_de_tinfo($locationA, $locationB);
}
function _location_driving_directions_link_de_tinfo($locationA, $locationB) {
foreach ($locationA as $field => $value) {
$locationA[$field] = trim($value);
}
foreach ($locationB as $field => $value) {
$locationB[$field] = trim($value);
}
if ($locationA['country'] == 'de' && $locationB['country'] == 'de') {
$get_query = '?';
$get_query .= 'route_input.start_country=2';
if (isset($location['street'])) {
$get_query .= '&' . 'route_input.start_street=' . urlencode($location['street']);
}
if ($location['postal_code'] != '') {
$get_query .= '&' . 'route_input.start_zip=' . urlencode($location['postal_code']);
}
if ($location['city'] != '') {
$get_query .= '&' . 'route_input.start_city_manual=' . urlencode($location['city']);
}
$get_query .= 'route_input.target_country=2';
if (isset($location['street'])) {
$get_query .= '&' . 'route_input.target_street=' . urlencode($location['street']);
}
if ($location['postal_code'] != '') {
$get_query .= '&' . 'route_input.target_zip=' . urlencode($location['postal_code']);
}
if ($location['city'] != '') {
$get_query .= '&' . 'route_input.target_city_manual=' . urlencode($location['city']);
}
return 'http://www.t-info.de/map/jumppage/route_stations.jsp' . $get_query;
}
}
function theme_location_de($location = array(), $hide = array()) {
$output = '';
if (count($location)) {
$output .= "\n";
$output .= '<div class="location vcard"><div class="adr">' . "\n";
if (!empty($location['name']) && !in_array('name', $hide)) {
$output .= '<div class="fn">' . $location['name'] . '</div>';
}
if (!empty($location['street']) && !in_array('street', $hide)) {
$output .= '<div class="street-address">' . $location['street'];
if (!empty($location['additional']) && !in_array('street', $hide)) {
$output .= ' ' . $location['additional'];
}
$output .= '</div>';
}
if (!empty($location['city']) && !in_array('city', $hide) || !empty($location['postal_codet']) && !in_array('postal_code', $hide)) {
$city_postal = array();
if (!empty($location['postal_code']) && !in_array('postal_code', $hide)) {
$city_postal[] = '<span class="postal-code">' . $location['postal_code'] . '</span>';
}
if (!empty($location['city']) && !in_array('city', $hide)) {
$city_postal[] = '<span class="locality">' . $location['city'] . '</span>';
}
$output .= '<div>' . implode(' ', $city_postal) . '</div>';
}
if (!in_array('country', $hide)) {
$output .= '<div class="country-name">' . t('Germany') . '</div>';
}
if (isset($location['latitude']) && isset($location['longitude'])) {
$output .= '<div class="geo"><abbr class="latitude" title="' . $location['latitude'] . '" /><abbr class="longitude" title="' . $location['latitude'] . '" /></div>';
}
$output .= '</div></div>';
}
return $output;
}
function location_get_postalcode_data_de($location = array()) {
$dash_index == strpos($location['postal_code'], '-');
if ($dash_index === FALSE) {
$location['postal_code'] = substr($location['postal_code'], 0, $dash_index);
}
$res = db_query("SELECT * FROM {zipcodes} where country = '%s' AND zip = '%s'", $location['country'], str_pad($location['postal_code'], 5, "0", STR_PAD_LEFT));
if ($row = db_fetch_object($res)) {
return array(
'lat' => $row->latitude,
'lon' => $row->longitude,
'city' => $row->city,
'province' => $row->state,
'country' => $row->country,
);
}
else {
return NULL;
}
}
function location_province_list_de() {
return array(
'BB' => 'Brandenburg',
'BE' => 'Berlin',
'BW' => 'Baden-Württemberg',
'BY' => 'Bayern',
'HB' => 'Bremen',
'HE' => 'Hessen',
'HH' => 'Hamburg',
'MV' => 'Mecklenburg-Vorpommern',
'NI' => 'Niedersachsen',
'NW' => 'Nordrhein-Westfalen',
'RP' => 'Rheinland-Pfalz',
'SH' => 'Schleswig-Holstein',
'SL' => 'Saarland',
'SN' => 'Sachsen',
'ST' => 'Sachsen-Anhalt',
'TH' => 'Thüringen',
);
}