Remove lingering horde/Core reference in horde/Nls
authorMichael M Slusarz <slusarz@curecanti.org>
Wed, 14 Jul 2010 21:49:58 +0000 (15:49 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Wed, 14 Jul 2010 21:49:58 +0000 (15:49 -0600)
framework/Nls/lib/Horde/Nls.php
framework/Nls/lib/Horde/Nls/Geoip.php
framework/Ui/lib/Horde/Ui/FlagImage.php

index ec721c8..b025205 100644 (file)
@@ -112,14 +112,16 @@ class Horde_Nls
     /**
      * Get country information from a hostname or IP address.
      *
-     * @param string $host  The hostname or IP address.
+     * @param string $host      The hostname or IP address.
+     * @param string $datafile  The datafile for the GeoIP lookup. If not set,
+     *                          will skip this lookup.
      *
      * @return mixed  On success, return an array with the following entries:
      *                'code'  =>  Country Code
      *                'name'  =>  Country Name
      *                On failure, return false.
      */
-    static public function getCountryByHost($host)
+    static public function getCountryByHost($host, $datafile = null)
     {
         /* List of generic domains that we know is not in the country TLD
            list. See: http://www.iana.org/gtld/gtld.htm */
@@ -162,8 +164,7 @@ class Horde_Nls
         }
 
         /* Try GeoIP lookup next. */
-        $geoip = Horde_Nls_Geoip::singleton(!empty($GLOBALS['conf']['geoip']['datafile']) ? $GLOBALS['conf']['geoip']['datafile'] : null);
-
+        $geoip = new Horde_Nls_Geoip($datafile);
         return $geoip->getCountryInfo($checkHost);
     }
 
index 77df03e..156b6d8 100644 (file)
@@ -19,8 +19,9 @@
  * See the enclosed file COPYING for license information (LGPL). If you
  * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
  *
- * @author  Michael Slusarz <slusarz@horde.org>
- * @package Horde_NLS
+ * @author   Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @package  Nls
  */
 class Horde_Nls_Geoip
 {
@@ -30,13 +31,6 @@ class Horde_Nls_Geoip
     const STANDARD_RECORD_LENGTH = 3;
 
     /**
-     * The singleton instance.
-     *
-     * @var Horde_Nls_Geoip
-     */
-    static protected $_instance;
-
-    /**
      * Country list.
      *
      * @var array
@@ -82,26 +76,6 @@ class Horde_Nls_Geoip
     protected $_fh;
 
     /**
-     * Returns a reference to the global Horde_Nls_GeoIP object, only creating
-     * it if it doesn't already exist.
-     *
-     * This method must be invoked as:
-     *   $geoip = Horde_Nls_Geoip::singleton($datafile);
-     *
-     * @param string $datafile  The location of the GeoIP database.
-     *
-     * @return object Horde_Nls_Geoip  The object instance.
-     */
-    static public function singleton($datafile)
-    {
-        if (!isset(self::$_instance)) {
-            self::$_instance = new self($datafile);
-        }
-
-        return self::$_instance;
-    }
-
-    /**
      * Constructor.
      *
      * @param string $datafile  The location of the GeoIP database.
index ab1cf4a..aeb41bc 100644 (file)
@@ -25,7 +25,8 @@ class Horde_Ui_FlagImage
      */
     static public function generateFlagImageByHost($host)
     {
-        $data = Horde_Nls::getCountryByHost($host);
+        $data = Horde_Nls::getCountryByHost($host, empty($GLOBALS['conf']['geoip']['datafile']) ? null : $GLOBALS['conf']['geoip']['datafile']);
+    );
         if ($data === false) {
             return '';
         }