Text Compare
Produced: 28-07-2015 10:49:55
   
Mode:  Differences, With Context  
Left file: F:\Documents and Settings\Administrator\Skrivebord\MIDLERTIDIG\SAMMENLIGN\6.x-3.x-dev\google.inc  
Right file: F:\Documents and Settings\Administrator\Skrivebord\MIDLERTIDIG\SAMMENLIGN\6.x-3.4\google.inc  
/** = /**
* @file   * @file
* Google geocoder.   * Google geocoder.
*/   */
     
/**   /**
  -+ * Returns an XML document containing the list of countries supported by the
    * Google geocoder.
    * A cached version is stored in the Drupal cache in case Google is unreachable.
    */
    function google_geocode_country_list_xml() {
      // Get the google data from the feed.
      $source = drupal_http_request('http://spreadsheets.google.com/feeds/list/p9pdwsai2hDMsLkXsoM05KQ/default/public/values');
     
      if (!$source->data) {
        // Use the cache.
        $data = cache_get('location_google');
        if (!defined('LIBXML_VERSION') || (version_compare(phpversion(), '5.1.0', '<'))) {
          $xml = simplexml_load_string($data->data, NULL);
        }
        else {
          $xml = simplexml_load_string($data->data, NULL, LIBXML_NOERROR | LIBXML_NOWARNING);
        }
      }
      else {
        if (!defined('LIBXML_VERSION') || (version_compare(phpversion(), '5.1.0', '<'))) {
          $xml = simplexml_load_string($source->data, NULL);
          // Stores the XML in the cache to eventually use it later.
          cache_set('location_google', $xml->asXML());
        }
        else {
          $xml = simplexml_load_string($source->data, NULL, LIBXML_NOERROR | LIBXML_NOWARNING);
          // Store the XML in the cache to eventually use it later.
          cache_set('location_google', $xml->asXML());
        }
      }
     
      return $xml;
    }
     
    /**
* Return the list of ISO3166 codes supported by this geocoder. = * Return the list of ISO3166 codes supported by this geocoder.
* <>  
* Google now supports geocoding for all countries:    
* https://developers.google.com/maps/coverage   * Coverage list: http://gmaps-samples.googlecode.com/svn/trunk/mapcoverage_filtered.html
    * Coverage list feed: http://spreadsheets.google.com/feeds/list/p9pdwsai2hDMsLkXsoM05KQ/default/public/values
*/ = */
function google_geocode_country_list() {   function google_geocode_country_list() {
  <>   // Get the google data from the feed.
      $xml = google_geocode_country_list_xml();
     
      // Loop through google data and find all valid entries.
      $regionclean = array();
      foreach($xml->entry as $region) {
        $pos = strpos($region->content, 'geocoding:') + 11;
        $geocoding = substr($region->content, $pos, strpos($region->content, ',', $pos) - $pos);
        if (strpos($geocoding, "Yes") !== FALSE) {
         $regionclean[] = t(htmlentities($region->title));
        }
      }
     
      // Get the countries list and clean it up so that names will match to google.
      // The regex removes parenthetical items so that both of the "Congo" entries
      // and the "Coco Islands" work.
      // The $countriesfixes overwrites values in the Drupal API countries list
      // with values that will match to google's entries.
      // "Sao Tome and Principe" are non-accented in the Drupal API so the entry
      // here is to match the htmlentities() fix in the foreach loop below.
      // Note: it may be neccessary to adjust/add to the fixes list in the future
      // if google adds countries that don't match the Drupal API list for whatever
      // reason.
  $countries = location_get_iso3166_list();     $countries = location_get_iso3166_list();
      $regex = "#[ (].*[)]#e";
      $cntryclean = preg_replace($regex, "", $countries);
      $countriesfixes = array_merge($cntryclean, array(
        "hk" => t("China"),
        "mo" => t("China"),
        "pn" => t("Pitcairn Islands"),
        "wf" => t("Wallis Futuna"),
        "st" => t("S&Atilde;&pound;o Tom&Atilde;&copy; and Pr&Atilde;&shy;ncipe"),
      ));
     
      // Compare new google data found to fixed country name values and return
      // matches with abbreviations as keys.
      $googlematched = array_intersect($countriesfixes, $regionclean);
     
      // Compare new keys to original Drupal API and return the array with the
      // original name values.
      $fixedkeys = array_intersect_key($countries, $googlematched);
  return array_keys($countries);     return array_keys($fixedkeys);
}   }
  =  
/**   /**
* Return general information about this geocoder.   * Return general information about this geocoder.
*/   */
function google_geocode_info() {   function google_geocode_info() {
  return array(     return array(