Assembla home | Assembla project page
 

Changeset 228

Show
Ignore:
Timestamp:
04/13/08 21:03:27 (7 months ago)
Author:
Slynderdale
Message:

URL now updates the TLD as needed instead of just on init() and changed TLD to allow for the tld command like "tld com" and "tld.com" as well as just ".com"

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Phergie/Plugin/Tld.php

    r223 r228  
    186186 
    187187        $target = $this->event->getNick(); 
    188         if (preg_match('#^(?:'.preg_quote($this->getIni('nick')).'\s*[:,>]?\s+)?\.([a-z]{2,10})$#i', $this->event->getArgument(1), $m) && 
    189             $description = self::getTld($m[1])) { 
     188        $prefix = preg_quote(trim($this->getIni('command_prefix'))); 
     189        if (preg_match('#^(?:' . preg_quote($this->getIni('nick')) . '\s*[:,>]?\s+)?(?:' . $prefix . 'tld\s+\.?([a-z]{2,10})|\.([a-z]{2,10}))$#i', $this->event->getArgument(1), $m) && 
     190            $description = self::getTld((!empty($m[1]) ? $m[1] : $m[2]))) { 
    190191            $this->doPrivmsg($this->event->getSource(), 
    191             $target . ': ' . $m[0] . ' -> ' . ($description ? ucfirst($description) : 'Unknown TLD')); 
     192            $target . ': .' . (!empty($m[1]) ? $m[1] : $m[2]) . ' -> ' . ($description ? ucfirst($description) : 'Unknown TLD')); 
    192193        } 
    193194    } 
  • trunk/Phergie/Plugin/Url.php

    r227 r228  
    116116     * @var array 
    117117     */ 
    118     protected $tldList; 
    119  
    120     /** 
    121      * Initializes settings 
    122      * 
    123      * @return void 
    124      */ 
    125     public function init() 
    126     { 
    127         // Get a list of valid TLDs 
    128         $this->tldList = array(); 
    129         if ($this->pluginLoaded('Tld')) { 
    130             $this->tldList = Phergie_Plugin_Tld::getTlds(); 
    131             if (is_array($this->tldList)) { 
    132                 $this->tldList = array_keys($this->tldList); 
    133             } 
    134         } 
    135         unset($plugins); 
    136         if (!is_array($this->tldList) || count($this->tldList) <= 0) { 
    137             $this->tldList = array('com', 'org', 'net'); 
    138         } 
    139         rsort($this->tldList); 
    140     } 
     118    protected $tldList = array(); 
    141119 
    142120    /** 
     
    164142            $this->updateSetting('title_length', 'titleLength', true); 
    165143            $this->updateSetting('show_errors', 'showErrors'); 
     144            // Update the valid TLD list 
     145            $this->updateTldList(); 
    166146 
    167147            $responses = array(); 
     
    564544    } 
    565545 
     546    /** 
     547     * Updates the list of TLDs from the TLD plugin 
     548     * 
     549     * @return void 
     550     */ 
     551    protected function updateTldList() 
     552    { 
     553        // Get a list of valid TLDs 
     554        if (!is_array($this->tldList) || count($this->tldList) <= 6) { 
     555            if ($this->pluginLoaded('Tld')) { 
     556                $this->tldList = Phergie_Plugin_Tld::getTlds(); 
     557                if (is_array($this->tldList)) { 
     558                    $this->tldList = array_keys($this->tldList); 
     559                } 
     560            } 
     561            if (!is_array($this->tldList) || count($this->tldList) <= 0) { 
     562                $this->tldList = array('com', 'org', 'net', 'gov', 'us', 'uk'); 
     563            } 
     564            rsort($this->tldList); 
     565        } 
     566    } 
     567 
    566568    /* 
    567     * Updates the given variable with the setting 
    568     */ 
     569     * Updates the given variable with the setting 
     570     * 
     571     * @return void 
     572     */ 
    569573    protected function updateSetting($setting, $var, $integer = false) 
    570574    {