Moving to GitHub.
[platal.git] / classes / gmapsgeocoder.php
index 2e44a01..e009080 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2011 Polytechnique.org                              *
+ *  Copyright (C) 2003-2014 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -32,13 +32,16 @@ class GMapsGeocoder extends Geocoder {
 
     static public function buildStaticMapURL($latitude, $longitude, $color, $separator = '&')
     {
+        if (!$latitude || !$longitude) {
+            return null;
+        }
+
         $parameters = array(
             'size'    => '300x100',
             'markers' => 'color:' . $color . '|' . $latitude . ',' . $longitude,
             'zoom'    => '12',
             'sensor'  => 'false'
         );
-        global $globals;
 
         return Platal::globals()->maps->static_map . '?' . http_build_query($parameters, '', $separator);
     }
@@ -238,6 +241,9 @@ class GMapsGeocoder extends Geocoder {
         }
         $textLines  = explode("\n", $text);
         $countLines = count($textLines);
+        if ($countLines < 2) {
+            return $text;
+        }
         $needle     = strtoupper(trim($textLines[$countLines - 2]));
         $isPseudoCountry = false;
         if ($needle) {
@@ -256,5 +262,5 @@ class GMapsGeocoder extends Geocoder {
     }
 }
 
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker fenc=utf-8:
 ?>