? location_microformat_vcard.patch ? new_ubuntu.patch Index: location.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/location/location.inc,v retrieving revision 1.34.2.8 diff -u -F^f -r1.34.2.8 location.inc --- location.inc 20 Oct 2006 21:41:59 -0000 1.34.2.8 +++ location.inc 22 Nov 2006 19:47:25 -0000 @@ -62,7 +62,7 @@ function location_get_postalcode_data($l $location['country'] = isset($location['country']) ? trim($location['country']) : NULL; $location['postal_code'] = isset($location['postal_code']) ? trim($location['postal_code']) : NULL; if (is_null($location['postal_code']) || is_null($location['country']) || empty($location['country']) || empty($location['postal_code']) || $location['postal_code'] == 'xx') { - return NULL; + return NULL; } $country_specific_function = 'location_get_postalcode_data_'. $location['country']; if (function_exists($country_specific_function)) { @@ -105,55 +105,58 @@ function theme_location($location = arra if (_location_nothing_to_show($location, $hide)) { return ''; } + $output = ''; $country_specific_function = 'theme_location_'. (isset($location['country']) ? $location['country'] : ''); if (function_exists($country_specific_function)) { - $output .= $country_specific_function($location); + $output .= $country_specific_function($location, $hide); } elseif (count($location)) { $output .= "\n"; - $output .= '
'."\n"; + $output .= '
'."\n"; if (!empty($location['name']) && !in_array('name', $hide)) { - $output .= '
'. $location['name'] .'
'; + $output .= '
'. $location['name'] .'
'; } if (!empty($location['street']) && !in_array('street', $hide)) { - $output .= '
'. $location['street'] .'
'; + $output .= '
'. $location['street']; + if (!empty($location['additional']) && !in_array('street', $hide)) { + $output .= ' ' . $location['additional']; + } + $output .='
'; } - - if (!empty($location['additional']) && !in_array('street', $hide)) { - $output .= '
' . $location['additional'] . '
'; - } - - if ((!empty($location['city']) && !in_array('city', $hide)) || - (!empty($location['province']) && !in_array('province', $hide)) || - (!empty($location['postal_code']) && !in_array('postal_code', $hide))) { - $output .= '
'; - + + if (!empty($location['city']) && !in_array('city', $hide)) { + $city_province_postal[] = $location['city']; + } + + if ((!empty($location['city']) && !in_array('city', $hide)) || + (!empty($location['province']) && !in_array('province', $hide)) || + (!empty($location['postal_codet']) && !in_array('postal_code', $hide))) { + $city_province_postal = array(); + if (!empty($location['city']) && !in_array('city', $hide)) { - $city_province_postal[] = $location['city']; + $city_province_postal[] = '' . $location['city'] . ''; } - + if (!empty($location['province']) && !in_array('province', $hide)) { - $city_province_postal[] = $location['province']; + $city_province_postal[] = '' . $location['province'] . ''; } if (!empty($location['postal_code']) && !in_array('postal_code', $hide)) { - $city_province_postal[] = $location['postal_code']; + $city_province_postal[] = '' . $location['postal_code'] . ''; } - + $output .= implode(', ', $city_province_postal); - - $output .= '
'; } - + if (!empty($location['country']) && !in_array('country', $hide)) { $countries = _location_get_iso3166_list(); - $output .= '
'. $countries[$location['country']] . '
'; + $output .= '
'. t($countries[$location['country']]) . '
'; } - - $output .= '
'; + + $output .= ''; } $output .= location_map_link($location); @@ -174,7 +177,7 @@ function _location_nothing_to_show($loca * Given two points in lat/lon form, returns the distance between them. * * @param $latlonA - * An associative array where + * An associative array where * 'lon' => is a floating point of the longitude coordinate for the point given by latlonA * 'lat' => is a floating point of the latitude coordinate for the point given by latlonB * @@ -188,7 +191,7 @@ function _location_nothing_to_show($loca * @return * NULL if sense can't be made of the parameters. * An associative array where - * 'scalar' => Is the distance between the two lat/lon parameter points + * 'scalar' => Is the distance between the two lat/lon parameter points * 'distance_unit' => Is the unit of distance being represented by 'scalar'. * This will be 'km' unless 'mile' is passed for the $distance_unit param */ @@ -196,15 +199,15 @@ function location_distance_between($latl if (!isset($latlonA['lon']) || !isset($latlonA['lat']) || !isset($latlonB['lon']) || !isset($latlonB['lat'])) { return NULL; } - + if ($distance_unit != 'km' && $distance_unit != 'mile') { return NULL; } - + // $conversion_factor = number to divide by to convert meters to $distance_unit // At this point, $distance_unit == 'km' or 'mile' and nothing else //$conversion_factor = ($distance_unit == 'km') ? 1000.0 : 1609.347; - + $meters = earth_distance($latlonA['lon'], $latlonA['lat'], $latlonB['lon'], $latlonB['lat']); return array('scalar' => round($meters/(($distance_unit == 'km') ? 1000.0 : 1609.347), 1), 'distance_unit' => $distance_unit); } @@ -226,7 +229,7 @@ function location_distance_between($latl * @param $required_fields * An array of values that are required. Each string can be one of 'street', 'city', 'postal_code', 'province', or 'country'. * The presence of values in this array determines which fields will be marked as 'required'. Validation (i.e., making sure - * a required value is actually filled in is the responsibility of the caller) + * a required value is actually filled in is the responsibility of the caller) * * @param $suppressed_values * An array of values that are to be automatically filled and hidden from user view. These will be indicated in this @@ -240,20 +243,20 @@ function location_distance_between($latl * * @param $form_name * An additional parameter to help prevent HTML input name collisions. If the caller is using this - * function to generate more than 1 location form on a page, then the generated name for each HTML input's - * "name" attribute will go by the value supplied for $form_name. This parameter is defaulted to 'location' - * For example, if $form_name == 'xyz' and there is a 'street' field in the form to be served, + * function to generate more than 1 location form on a page, then the generated name for each HTML input's + * "name" attribute will go by the value supplied for $form_name. This parameter is defaulted to 'location' + * For example, if $form_name == 'xyz' and there is a 'street' field in the form to be served, * the "name" attribute for the HTML will be "edit[xyz][street]" * * @param $function * A string that tells location_form() which location API function will be using the location submitted via the * generated form. For example, if $function == 'latlon_rough', then the returned location_form (if it includes * a country field) will only generate a list of countries in the HTML select for which function location_latlon_rough() - * is supported. To figure out which countries these are, we check to see which of the configured countries have existing + * is supported. To figure out which countries these are, we check to see which of the configured countries have existing * functions to support the call. In this case, we would check to see if there existed a function called "location_latlon_rough_us()" * before listing the United States in the HTML SELECT for the generated location form. $function is defaulted to NULL. * If $function is NULL, the HTML SELECT that is generated will list all countries. - * + * * @return * An location form based on the parameters specified. If the $fields array is empty, then the * function returns a form in which all possible fields are served as optional form items. @@ -263,7 +266,7 @@ function location_distance_between($latl * * -> The following call returns a form that only contains fields for a postal_code and country where * the postal_code is required: - * --- + * --- * $form = location_form(array('postal_code', 'country'), array(), array('postal_code', 'country'), 'Permanent location') * --- * The form returned by this call is generated with calls to Drupal's 'form_' functions: @@ -404,7 +407,7 @@ function location_form($fields = array() $form['country']['#suffix'] = "\n"; } } - + return $form; } @@ -416,7 +419,7 @@ function location_latlon_form($descripti if ($usegmap) { $form['map'] = array(); //reserve spot at top of form for map } - + $form['latitude'] = array( '#prefix' => '
', '#type' => 'textfield', @@ -434,12 +437,12 @@ function location_latlon_form($descripti '#description' => $description, '#suffix' => '
' ); - + if ($usegmap) { $map_macro = variable_get('gmap_user_map', '[gmap|id=usermap|center=0,30|zoom=16|width=100%|height=400px]'); $form['map']['gmap']['#value'] = gmap_set_location($map_macro, $form, array('latitude'=>'latitude','longitude'=>'longitude')); } - + return $form; } @@ -510,29 +513,29 @@ function location_api2form($location = a /** * This function generates a form for doing proximity searches within a certain distance - * of a specified point. + * of a specified point. * * Depending on the context within which this function is called, the search-point can either - * be user-supplied via the location form that is passed (if one is available) or done within - * a search-point extracted from a contact table or some other location source specified by + * be user-supplied via the location form that is passed (if one is available) or done within + * a search-point extracted from a contact table or some other location source specified by * the programmer calling this function. * * @param $prefilled_values - * An associative array for prefilled values for the proximity search parameters, where + * An associative array for prefilled values for the proximity search parameters, where * 'distance' => is the prefilled int value to be selected for the distance scalar * 'distance_unit' => is 'km' or 'mile' - * + * * @param $suppressed_values * An associative array for values you wish to force the selection of rather than pre-fill as a default. * The value will be passed as a hidden form input. The passed values will be taken in as an associative - * array where + * array where * 'distance' => a preselected positive integer for the distance * 'distance_unit' => a preselected unit for the distance, one of either 'km' or 'mile' * * @return * An HTML form (generated by Drupal form functions) that lets users specify proximity search parameters that include distance, * the unit of distance, and a search-point if the optional $location_form parameter is passed. If one is not passed, - * the caller of this function will be assumed to already have one. + * the caller of this function will be assumed to already have one. * */ function location_proximity_form($prefilled_values = array(), $suppressed_values = array(), $form_name = 'location') { @@ -555,7 +558,7 @@ function location_proximity_form($prefil '#description' => '' ); } - + if (in_array('distance_unit', array_keys($suppressed_values))) { $form['distance_unit'] = array( '#type' => 'hidden', @@ -572,7 +575,7 @@ function location_proximity_form($prefil '#suffix' => t(' of:') ); } - + return $form; } @@ -591,29 +594,29 @@ function _location_is_full($location = a if (!isset($location['street']) && trim($location['street']) != '') { return FALSE; } - + if (!isset($location['city']) && trim($location['city']) != '') { return FALSE; } - + if (!isset($location['province']) && trim($location['province']) != '') { return FALSE; } - + if (!isset($location['postal_code']) && trim($location['postal_code']) != '') { return FALSE; } - + if (!isset($location['country']) && trim($location['country']) != '') { return FALSE; } - + return TRUE; } /** - * Takes two locationes and tries to return a deep-link to driving directions. + * Takes two locationes and tries to return a deep-link to driving directions. * * Parameters: * @param $locationA @@ -624,7 +627,7 @@ function _location_is_full($location = a * 'province' => the province, state, or territory * 'country' => lower-cased two-letter ISO code (REQUIRED) * 'postal_code' => the postal code - * + * * @param $locationB * An associative array that represents an location in the same way that * parameter $locationA does. @@ -632,7 +635,7 @@ function _location_is_full($location = a * @param $link_text * The text of the HTML link that is to be generated. * - * @return + * @return * A deep-link to driving directions on Yahoo! or some other mapping service, if enough fields are filled in the parameters. * A deep-link to a form for driving directions with information pre-filled if not enough, but some fields are filled in the parameters. * The empty string if no information is provided (or if so little information is provided that there is no function to which to delegate @@ -640,7 +643,7 @@ function _location_is_full($location = a * * We dispatch the call to a country-specific function. The country-specific function, in this case, * will be the one reflected by the country parameter of the first function. We require that - * both locationes supplied have a country field at the minimum. + * both locationes supplied have a country field at the minimum. * * The country-specific functions will ultimately decide, with the parameters given, whether to * to link to a form for driving directions is provided, where this form will be @@ -651,15 +654,15 @@ function location_driving_directions_lin if (!isset($locationA['country']) || !isset($locationB['country'])) { return ''; } - + // For now, return empty string if starting-point and destinations are in different countries //if ($locationA['country'] != $locationB['country']) { // return ''; //} // Lines above commented out because I want to let the country-specific function of the departure point decide - // what it will do with driving destination locationes from other countries. As an example, Yahoo! Maps supports driving - // direction queries for locationes between the U.S. and Canada. - + // what it will do with driving destination locationes from other countries. As an example, Yahoo! Maps supports driving + // direction queries for locationes between the U.S. and Canada. + $driving_direction_function = 'location_driving_directions_link_'. $locationA['country']; if (function_exists($driving_direction_function)) { $http_link = $driving_direction_function($locationA, $locationB); @@ -670,7 +673,7 @@ function location_driving_directions_lin return ''; } } - + return ''; } @@ -678,7 +681,7 @@ function location_driving_directions_lin * Takes an location and a distance and returns an array of all postal-codes (from all countries that are supported) * within the specified distance of the specified location. * - * @param $location + * @param $location * An associative array where * 'street' => the street location * 'additional' => extra street location or building name or hall or something like that.\ @@ -689,24 +692,24 @@ function location_driving_directions_lin * * @param $distance * The number portion of the distance; it is forced to an integer ceiling - * - * @param $distance_unit + * + * @param $distance_unit * The unit of distance being used for the distance being submitted. * Valid arguments for $distance_unit are 'mile' and 'km'. If something other than one of * these unit types is submitted for this argument, it is forced to 'km'. * - * @return - * An array where + * @return + * An array where * -> the keys are a postive integer ranking of the search result's closeness to the parameter $postal_code * with 1 being assigned to the nearest postal code - * -> the values are an associative array where + * -> the values are an associative array where * 'postal_code' => A postal code that fell within the search-radius given by $distance and $distance_unit. * 'country' => The two-letter ISO code for the home-country of this particular postal_code search result. * 'city' => The city to which this postal code belongs. * 'province' => The province to which this postal code belongs. * 'lon' => The longitude coordinate of the approximate center of the area covered by 'postal_code' * 'lat' => The latitude coordinate of the approximate center of the area covered by 'postal_code' - * 'distance' => The number of 'km's or 'mile's that are between the approximate center of the area of + * 'distance' => The number of 'km's or 'mile's that are between the approximate center of the area of * the $postal_code parameter and that of the 'postal_code' in this subarray * 'distance_unit' => The unit of distance specified by 'scalar' */ @@ -715,12 +718,12 @@ function location_nearby_postalcodes_byl //$start_time = microtime(); $latlon = location_latlon_rough($location); - + // If we could not get lat/lon coordinates for the given location, return an empty search result set. if (!isset($latlon['lat']) || !isset($latlon['lon'])) { return array(); } - + // If the distance parameters did not make sense, return an empty search result set. if (!($distance_float = _location_convert_distance_to_meters($distance, $distance_unit))) { return array(); @@ -730,46 +733,46 @@ function location_nearby_postalcodes_byl //DEBUG: commented code is for testing/debugging //$format_start_time = microtime(); - + _location_format_search_result_distances($search_results, $distance_unit); - + //$format_end_time = microtime(); //print 'Time for FORMATTING to complete: '. _location_time_difference($format_end_time, $format_start_time) ."
\n"; - + // DEBUG: commented code is for testing/debugging purposes //$end_time = microtime(); //print 'Time for this search to complete: '. _location_time_difference($end_time, $start_time) ."
\n"; - + return $search_results; } /** - * Takes a latitude, longitude, and a distance, and returns all postal_codes within + * Takes a latitude, longitude, and a distance, and returns all postal_codes within * * @param $lon * A floating point of the longitude coordinate of the search point - * + * * @param $lat * A floating point of the latitude coordinate of the search point * - * @param $distance - * The number portion of the distance; it is forced to an integer ceiling + * @param $distance + * The number portion of the distance; it is forced to an integer ceiling * * @param $distance_unit * The unit of distance being used for the distance being submitted. * Valid arguments for $distance_unit are 'mile' and 'km'. If something other than one of * these unit types is submitted for this argument, it is forced to 'km'. * - * @return - * An array where - * -> the keys are a contatenation of the country's ISO code and the postal code. For example, if + * @return + * An array where + * -> the keys are a contatenation of the country's ISO code and the postal code. For example, if * one of the search results is for postal code "94803" in the United States, the key is then "us94803" - * -> the values are an associative array where + * -> the values are an associative array where * 'postal_code' => A postal code that fell within the search-radius given by $distance and $distance_unit. * 'country' => The two-letter ISO code for the home-country of this particular postal_code search result. * 'lon' => The longitude coordinate of the approximate center of the area covered by 'postal_code' * 'lat' => The latitude coordinate of the approximate center of the area covered by 'postal_code' - * 'distance' => The number of 'km's or 'mile's that are between the approximate center of the area of the + * 'distance' => The number of 'km's or 'mile's that are between the approximate center of the area of the * $postal_code parameter and that of the 'postal_code' in this array * 'distance_unit' => The unit of distance specified by 'distance' */ @@ -781,16 +784,16 @@ function location_nearby_postalcodes_byl if (!is_numeric($lon) || !is_numeric($lat)) { return array(); } - + // If the distance parameters did not make sense, return an empty search result set. $distance_float = _location_convert_distance_to_meters($distance, $distance_unit); if (is_null($distance_float)) { return array(); } - + $search_results = _location_nearby_postalcodes($lon, $lat, $distance_float); _location_format_search_result_distances($search_results, $distance_unit); - + // DEBUG: commented code is for testing/debugging purposes //$end_time = microtime(); //print 'Time for this search to complete: '. _location_time_difference($end_time, $start_time)."
\n"; @@ -809,12 +812,12 @@ function _location_time_difference($end_ /** * @param $distance - * A number in either miles or km. + * A number in either miles or km. * - * @param $distance_unit + * @param $distance_unit * Either 'km' or 'mile' * - * @return + * @return * A floating point number where the number in meters after the initially passed scalar has been ceil()'d * This is done after the $distance_unit parmeter is forced to be 'km' or 'mile' */ @@ -822,22 +825,22 @@ function _location_convert_distance_to_m if (!is_numeric($distance)) { return NULL; } - + // Force an integer version of distance, just in case anyone wants to add a caching mechanism // for postal code proximity searches. - + if (is_float($distance)) { $distance = intval(ceil($distance)); } - + if ($distance < 1) { return NULL; } - + if ($distance_unit != 'km' && $distance_unit != 'mile') { $distance_unit = 'km'; } - + // Convert distance to meters //$distance_float = floatval($distance) * (($distance_unit == 'km') ? 1000.0 : 1609.347); //return round($distance_float, 2); @@ -868,7 +871,7 @@ function location_latlon_rough($location if (!isset($location['country']) || !isset($location['postal_code'])) { return NULL; } - + $latlon_function = 'location_latlon_rough_'. $location['country']; if (function_exists($latlon_function)) { return $latlon_function($location); @@ -877,9 +880,9 @@ function location_latlon_rough($location return NULL; } } - - + + /** * This is the main logic-level function for performing proximity postal-code searches. * It calls a number of helper functions for finding postal_code results in each country, @@ -888,20 +891,20 @@ function location_latlon_rough($location * of a previous search's results on the same search-point. * * @param $lon - * A floating point of the longitude coordinate about which the search is being executed + * A floating point of the longitude coordinate about which the search is being executed * * @param $lat * A floating point of the latitude coordinate about which the search is being executed * - * @param $distance + * @param $distance * A floating point of the distance in meters; it is forced to an integer ceiling, but * kept as a float * * @return - * An array where + * An array where * -> the keys are a concatenation of the lower-case two-letter ISO country code and the postal code * For example, 94063 in the United States would be 'us94063' - * -> the values are an associative array where + * -> the values are an associative array where * 'postal_code' => A postal code that fell within the search-radius given by $distance and $distance_unit. * 'country' => The two-letter ISO code for the home-country of this particular postal_code search result. * 'lon' => The longitude coordinate of the approximate center of the area covered by 'postal_code' @@ -912,7 +915,7 @@ function location_latlon_rough($location */ function _location_nearby_postalcodes($lon, $lat, $distance) { $search_results = _location_search_results_from_cache($lon, $lat, $distance); - + // If there were usable cached search_results then return those and go no further... awwwww yeah. if (count($search_results)) { return $search_results; @@ -927,31 +930,31 @@ function _location_nearby_postalcodes($l // The value of the cached item will be a serialize($result_array) // // The cache will be cleared of proximity searches when there is a change in countries that have - // been configured into the system. + // been configured into the system. //------------------------------------------------------------------------------------------ - + $search_results = array(); - + $latrange = earth_latitude_range($lon, $lat, $distance); - $lonrange = earth_longitude_range($lon, $lat, $distance); + $lonrange = earth_longitude_range($lon, $lat, $distance); //$query_start_time = microtime(); - + $result = db_query('SELECT zip, city, state, country, '. earth_distance_sql($lon, $lat) .' as distance FROM {zipcodes} WHERE latitude > %f AND latitude < %f AND longitude > %f AND longitude < %f AND '. earth_distance_sql($lon, $lat) .' < %f ORDER by distance', $latrange[0], $latrange[1], $lonrange[0], $lonrange[1], $distance); - + while ($result_row = db_fetch_object($result)) { $search_results[$result_row->country . $result_row->zip] = array('city' => $result_row->city, 'province' => $result_row->state, 'distance' => $result_row->distance); } - + //DEBUG: commented code for testing/debugging purposes //$query_end_time = microtime(); - + //print 'TOTAL TIME FOR _location_nearby_postalcodes() '. _location_time_difference($query_end_time, $query_start_time) ."
\n"; //-------------------------------------------------------------------------------------------- // This is the spot where search results are cached - + cache_set('location_prox_search:'. round($lon, 3) .':'. round($lat, 3) .':'. $distance, serialize($search_results)); - + // DEBUG: commented code is for testing/debugging purposes //print 'POSTAL CODE SEARCH CACHING: Wrote new search results to cache'."
\n"; //-------------------------------------------------------------------------------------------- @@ -962,11 +965,11 @@ function _location_nearby_postalcodes($l * Helper function: this function is intended ONLY for use by _location_nearby_postalcodes(). * It checks the cache for search-results on a given point and returns the appropriate subset * if one exists. - * + * * @param $lon * A floating point of the longitude coordinate of the search point * - * @param $lat + * @param $lat * A floating point of the latitude coordinate of the search point * * @param $distance @@ -982,26 +985,26 @@ function _location_nearby_postalcodes($l */ function _location_search_results_from_cache($lon, $lat, $distance) { $cache_id_prefix = 'location_prox_search:'. round($lon, 3) .':'. round($lat, 3) .':'; - + $result = db_query("SELECT cid FROM {cache} WHERE cid LIKE '%s%%'", $cache_id_prefix); - + if ($result_row = db_fetch_object($result)) { // A previous search has been done on the same search point, possibily with the an equal or different // search radius. $cached_key_fields = explode(':', $result_row->cid); $previous_search_radius = $cached_key_fields[3]; - + // If the search-radius is less than or equal to the previous search-radius, then just use // the appropriate subset of the previous search result. // This is very convenient since previous search results are sorted in ascending order - // by their distance from the search point. + // by their distance from the search point. if ($distance <= $previous_search_radius) { $cached_search_results = cache_get($result_row->cid); $cached_search_results = unserialize($cached_search_results->data); // If the cached-search had the exact same search-radius, just return the entire search result's // array from before, - // otherwise, go through the distance-sorted search results and pick them out until the distances + // otherwise, go through the distance-sorted search results and pick them out until the distances // of each search result start being something greater than the current search-radius if ($distance == $previous_search_radius) { // DEBUG: commented code is for testing/debugging purposes @@ -1028,13 +1031,13 @@ function _location_search_results_from_c // then delete the previous search from the cache to make way in the cache for the results of // the current, more comprehensive search being done on the same point, but on a larger radius. // Return an empty array to let the calling function know that it will have to do a new search. - + // DEBUG: commented code is for testing/debugging purposes //print 'POSTAL CODE SEARCH CACHING: Throwing out old search on a point because new search uses larger search-radius'."
\n"; cache_clear_all($result_row->cid); return array(); } - + } else { // This else-clause ties back to the first if-clause in this function. @@ -1050,7 +1053,7 @@ function _location_search_results_from_c * _location_sort_proximity_search_results() * * @param $results_array - * An array of proximity search results where + * An array of proximity search results where * -> the keys are integer rankings starting from 1 for the closest postal_code search result * -> the values are associative arrays where * 'postal_code' => is the postal code of the search result @@ -1067,36 +1070,36 @@ function _location_search_results_from_c * * @return * Returns nothing. - * Modifies parameter $results_array so that 'distance' (mentioned above) now points to a string representation + * Modifies parameter $results_array so that 'distance' (mentioned above) now points to a string representation * of distance that goes to 1 decimal place, AFTER it has been converted * from the original meters to the distance unit specified by $distance_unit. * Also adds a key 'distance_unit' => 'mile' or 'km' which reflects the $distance_unit parameter. - * + * */ function _location_format_search_result_distances(&$results_array, $distance_unit = 'km') { if ($distance_unit != 'km' && $distance_unit != 'mile') { $distance_unit = 'km'; } - + // $conversion_factor = number to divide by to convert meters to $distance_unit // At this point, $distance_unit == 'km' or 'mile' and nothing else $conversion_factor = ($distance_unit == 'km') ? 1000.0 : 1609.347; - + foreach ($results_array as $index => $single_result) { $results_array[$index]['distance'] = round($single_result['distance']/$conversion_factor, 1); } } /** - * Currently, this is not a priority until there is an implementable use for exact longitude, + * Currently, this is not a priority until there is an implementable use for exact longitude, * latitude coordinates for an location. The idea is that this call will eventually retrieve * information through a web-service. Whereas location_latlon_rough() returns an approximate * lat/lon pair based strictly on the postal code where this lat/lon pair is pulled from a - * database table, this function is intended to send the entire location to a web-service and + * database table, this function is intended to send the entire location to a web-service and * to retrieve exact lat/lon coordinates. * * @param $location - * An array where + * An array where * -> the key values are 'street', 'additional', 'province', 'country', 'postal_code' * -> the values are: * 'street' => the string representing the street location (REQUIRED) @@ -1129,7 +1132,7 @@ function location_latlon_exact($location /** * @param $location - * An array where + * An array where * -> the key values are 'street', 'additional', 'province', 'country', 'postal_code' * -> the values are: * 'street' => the string representing the street location @@ -1174,25 +1177,25 @@ function location_geocode_meta_tags($loc * The array is sorted by the values. * * Please note the difference between "supported" countries and "configured" - * countries: A country being "supported" means that there is an include file - * to support the country while "configured" implies that the site admin has - * configured the site to actually use that country's include file. + * countries: A country being "supported" means that there is an include file + * to support the country while "configured" implies that the site admin has + * configured the site to actually use that country's include file. */ function location_configured_countries() { static $configured_countries_associative; if (!count($configured_countries)) { $configured_countries = variable_get('location_configured_countries', array('us' => 'us')); // => - - $configured_countries = is_array($configured_countries) ? $configured_countries : array(); + + $configured_countries = is_array($configured_countries) ? $configured_countries : array(); $supported_countries = _location_supported_countries(); // => - + $configured_countries_associative = array(); foreach ($configured_countries as $country_code) { if (array_key_exists($country_code, $supported_countries)) { $configured_countries_associative[$country_code] = $supported_countries[$country_code]; } } - + asort($configured_countries_associative); } return $configured_countries_associative; @@ -1207,9 +1210,9 @@ function location_configured_countries() * The array is sorted the index (i.e., by the short English name of the country). * * Please note the different between "supported" countries and "configured" - * countries: A country being "supported" means that there is an include file - * to support the country while "configure" implies that the site admin has - * configured the site to actually use that country. + * countries: A country being "supported" means that there is an include file + * to support the country while "configure" implies that the site admin has + * configured the site to actually use that country. */ function _location_supported_countries() { // '' => '' @@ -1227,9 +1230,9 @@ function _location_supported_countries() } } } - + $supported_countries = array_flip($supported_countries); - // In the foreach, here, $index is just an integer that we want to + // In the foreach, here, $index is just an integer that we want to // replace with the name of the country, where the key pointing to it // is the two-letter ISO code for the country foreach ($supported_countries as $code => $index) { @@ -1254,7 +1257,7 @@ function _location_supported_countries() * The HTML "name" attribute assigned to the generated form element. Defaults to 'location' if none is specified * * @return - * A form_select where the labels are the English names of the countries and the corresponding value + * A form_select where the labels are the English names of the countries and the corresponding value * attributes for the options are the two-letter ISO code for the countries. * If 'location' is passed as the $form_name, then the HTML "name" attribute for the generated form element * will be "edit[location][country]". @@ -1289,7 +1292,7 @@ function _location_country_select_option * The array that is returned is a complete list of state/provinces * that belong to the countries enabled by the site's location system. * - * @param $value + * @param $value * A preselected value for the HTML select form item that is returned. * * @param $required @@ -1307,8 +1310,8 @@ function _location_country_select_option * * @return * An associative array where - * -> the keys are a contatenation of the countrycode and a three - * digit positive integer unique to each province within a + * -> the keys are a contatenation of the countrycode and a three + * digit positive integer unique to each province within a * country's provinces * -> the values are the full name of the province * @@ -1392,34 +1395,34 @@ function location_address2singleline($lo if (!empty($location['street'])) { $address .= $location['street']; } - + if (!empty($location['city'])) { if (!empty($location['street'])) { $address .= ', '; } - + $address .= $location['city']; } - + if (!empty($location['province'])) { if (!empty($location['street']) || !empty($location['city'])) { $address .= ', '; } - + $address .= $location['province']; } - + if (!empty($location['postal_code'])) { if (!empty($address)) { $address .= ' '; } $address .= $location['postal_code']; } - + if (!empty($location['country'])) { $address .= ', '. $location['country']; } - + return $address; } @@ -1675,6 +1678,3 @@ function _location_get_iso3166_list() { 'zw' => 'Zimbabwe' ); } - - -?> Index: location.install =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/location/location.install,v retrieving revision 1.2.2.1 diff -u -F^f -r1.2.2.1 location.install --- location.install 15 Sep 2006 23:09:15 -0000 1.2.2.1 +++ location.install 22 Nov 2006 19:47:25 -0000 @@ -1,5 +1,4 @@ drupal_get_path('module', 'location') . '/database'))); Index: location.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/location/location.module,v retrieving revision 1.62.2.8 diff -u -F^f -r1.62.2.8 location.module --- location.module 20 Oct 2006 21:41:59 -0000 1.62.2.8 +++ location.module 22 Nov 2006 19:47:28 -0000 @@ -1138,4 +1138,13 @@ function _location_floats_are_equal($x, return (abs(max($x, $y) - min($x, $y)) < pow(10, -6)); } - +function location_footer($main = 0) { + $path = drupal_get_normal_path($_GET['q']); + list($node, $nid) = array_values(explode('/', $path)); + if ($node == 'node') { + $node = node_load($nid); + if (count($node->location)) { + drupal_set_html_head(location_geocode_meta_tags($node->location)); + } + } +} Index: supported/location.de.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/location/supported/location.de.inc,v retrieving revision 1.8 diff -u -F^f -r1.8 location.de.inc --- supported/location.de.inc 18 Sep 2005 17:27:56 -0000 1.8 +++ supported/location.de.inc 22 Nov 2006 19:47:28 -0000 @@ -122,37 +122,45 @@ function _location_driving_directions_li } } -function theme_location_de($location = array()) { +function theme_location_de($location = array(), $hide = array()) { $output = ''; if (count($location)) { $output .= "\n"; - $output .= '
'."\n"; - - if (isset($location['street'])) { - $output .= '
'. $location['street'] .'
'; + $output .= '
'."\n"; + if (!empty($location['name']) && !in_array('name', $hide)) { + $output .= '
'. $location['name'] .'
'; } - - if (isset($location['additional'])) { - $output .= '
' . $location['additional'] . '
'; - } - - $postal_isset = (isset($location['postal_code']) && strlen($location['postal_code'])); - $city_isset = (isset($location['city']) && strlen($location['postal_code'])); - if ($postal_isset || $city_isset) { - $output .= '
'; - if ($postal_isset) { - $output .= $location['postal_code']; + + if (!empty($location['street']) && !in_array('street', $hide)) { + $output .= '
'. $location['street']; + if (!empty($location['additional']) && !in_array('street', $hide)) { + $output .= ' ' . $location['additional']; } - if ($postal_isset && $city_isset) { - $output .= ' '; + $output .='
'; + } + + 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[] = '' . $location['postal_code'] . ''; } - if ($city_isset) { - $output .= $location['city']; + + if (!empty($location['city']) && !in_array('city', $hide)) { + $city_postal[] = '' . $location['city'] . ''; } - $output .= "
\n"; + + $output .= '
'. implode(' ', $city_postal) .'
'; + } + + if (!in_array('country', $hide)) { + $output .= '
'. t('Germany') . '
'; } - - $output .= '
'. t('Germany') ."
\n"; + + $output .= '
'; + } return $output; } @@ -211,5 +219,4 @@ function location_province_list_de() { 'ST' => 'Sachsen-Anhalt', 'TH' => 'Thüringen' ); -} -?> +}