Uses some profile informations (pormotions) to retrieve a login.
[platal.git] / include / geocoding.inc.php
index cb27635..a828366 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2009 Polytechnique.org                              *
+ *  Copyright (C) 2003-2010 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -47,9 +47,10 @@ abstract class Geocoder {
                                 WHERE  name = {?}",
                               $address[$area . 'Name']);
             if ($res->numRows() == 0) {
-                $address[$area . 'Id'] = XDB::execute("INSERT INTO  " . $databases[$area] . " (name, country)
-                                                            VALUES  ({?}, {?})",
-                                                      $address[$area . 'Name'], $address['countryId']);
+                XDB::execute('INSERT INTO  ' . $databases[$area] . ' (name, country)
+                                   VALUES  ({?}, {?})',
+                             $address[$area . 'Name'], $address['countryId']);
+                $address[$area . 'Id'] = XDB::insertId();
             } else {
                 $address[$area . 'Id'] = $res->fetchOneCell();
             }
@@ -337,7 +338,12 @@ class GMapsGeocoder extends Geocoder {
             $address['text'] = $address['geoloc'];
             $address['postalText'] = $address['geocodedPostalText'];
             unset($address['geoloc'], $address['geocodedPostalText']);
+        } else {
+            $address['geoloc'] = str_replace("\n", "\r\n", $address['geoloc']);
+            $address['geocodedPostalText'] = str_replace("\n", "\r\n", $address['geocodedPostalText']);
         }
+        $address['text'] = str_replace("\n", "\r\n", $address['text']);
+        $address['postalText'] = str_replace("\n", "\r\n", $address['postalText']);
     }
  
     // Returns the address formated for postal use.
@@ -409,9 +415,9 @@ class GMapsGeocoder extends Geocoder {
         }
 
         if ($isPseudoCountry) {
-            return $address['text'];
+            return implode("\n", array_slice($textLines, 0, -1));
         }
-        return implode("\n", array_slice($textLines, 0, -1));
+        return $address['text'];
     }
 
     // Search for the lign from the given address that is the closest to the geocoded thoroughfareName