]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/Irc/extlib/phergie/Phergie/Plugin/Tld.php
Revert "Merged in Phergie changes"
[quix0rs-gnu-social.git] / plugins / Irc / extlib / phergie / Phergie / Plugin / Tld.php
index 5efc265c6403b2b479764092e89ea6ac4d863faa..21993f73c58fbde3efdb18ff5fc99d64ec24d0ca 100644 (file)
@@ -29,7 +29,6 @@
  * @author   Phergie Development Team <team@phergie.org>
  * @license  http://phergie.org/license New BSD License
  * @link     http://pear.phergie.org/package/Phergie_Plugin_Tld
- * @uses     Phergie_Plugin_Http pear.phergie.org
  * @uses     extension PDO
  * @uses     extension pdo_sqlite
  *
@@ -42,11 +41,6 @@ class Phergie_Plugin_Tld extends Phergie_Plugin_Abstract
      * @var PDO
      */
     protected $db;
-    /**
-     * Some fixed TLD values, keys must be lowercase
-     * @var array
-     */
-    protected static $fixedTlds;
 
     /**
      * Prepared statement for selecting a single tld
@@ -67,19 +61,13 @@ class Phergie_Plugin_Tld extends Phergie_Plugin_Abstract
      */
     public function onLoad()
     {
+        if (!extension_loaded('PDO') || !extension_loaded('pdo_sqlite')) {
+            $this->fail('PDO and pdo_sqlite extensions must be installed');
+        }
+
         $help = $this->getPluginHandler()->getPlugin('Help');
         $help->register($this);
 
-        if (!is_array(self::$fixedTlds)) {
-            self::$fixedTlds = array(
-                'phergie' => 'You can find Phergie at http://www.phergie.org',
-                'spoon'   => 'Don\'t you know? There is no spoon!',
-                'poo'     => 'Do you really think that\'s funny?',
-                'root'    => 'Diagnostic marker to indicate '
-                . 'a root zone load was not truncated.'
-            );
-        }
-
         $dbFile = dirname(__FILE__) . '/Tld/tld.db';
         try {
             $this->db = new PDO('sqlite:' . $dbFile);
@@ -124,19 +112,15 @@ class Phergie_Plugin_Tld extends Phergie_Plugin_Abstract
      *
      * @param string $tld TLD to search for
      *
-     * @return string Definition of the given TLD
+     * @return mixed Definition of the given TLD as a string or false if unknown
      */
     public function getTld($tld)
     {
         $tld = trim(strtolower($tld));
-        if (isset(self::$fixedTlds[$tld])) {
-            return self::$fixedTlds[$tld];
-        } else {
-            if ($this->select->execute(array('tld' => $tld))) {
-                $tlds = $this->select->fetch();
-                if (is_array($tlds)) {
-                    return '(' . $tlds['type'] . ') ' . $tlds['description'];
-                }
+        if ($this->select->execute(array('tld' => $tld))) {
+            $tlds = $this->select->fetch();
+            if (is_array($tlds)) {
+                return '(' . $tlds['type'] . ') ' . $tlds['description'];
             }
         }
         return false;
@@ -145,7 +129,8 @@ class Phergie_Plugin_Tld extends Phergie_Plugin_Abstract
     /**
      * Retrieves a list of all the TLDs and their definitions
      *
-     * @return array Array of all the TLDs and their definitions
+     * @return mixed Array of all the TLDs and their definitions or FALSE on
+      *        failure
      */
     public function getTlds()
     {
@@ -159,7 +144,6 @@ class Phergie_Plugin_Tld extends Phergie_Plugin_Abstract
                         . $tld['description'];
                     }
                 }
-                unset($tlds);
                 return $tldinfo;
             }
         }