Assembla home | Assembla project page
 

Changeset 273

Show
Ignore:
Timestamp:
08/01/08 09:58:43 (4 months ago)
Author:
Seldaek
Message:

* Plugins that can't load now return error messages to say why
fixes #35

Files:

Legend:

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

    r267 r273  
    223223         *       $class::checkDependencies($client, $plugins); 
    224224         */ 
    225         if (call_user_func(array($class, 'checkDependencies'), $client, $plugins)) { 
     225        $result = call_user_func(array($class, 'checkDependencies'), $client, $plugins); 
     226        if ($result === true) { 
    226227            $instance = new $class($client); 
    227228            $client->addPlugin($instance); 
    228229            $client->debug('Loaded ' . $plugin); 
    229230        } else { 
    230             $client->debug('Unable to load ' . $plugin); 
     231            // handle bc 
     232            if ($plugin === false) { 
     233                $client->debug('Unable to load ' . $plugin); 
     234            } else { 
     235                    $client->debug('Unable to load ' . $plugin . ":\r\n  " . implode("\r\n  ", (array) $result)); 
     236            } 
    231237        } 
    232238    } 
  • trunk/Phergie/Plugin/Abstract/Base.php

    r249 r273  
    465465            $plugins = array_map('strtolower', $plugins); 
    466466            if (in_array(strtolower($plugin), $plugins) && class_exists('Phergie_Plugin_' . $plugin) && 
    467                 call_user_func(array('Phergie_Plugin_' . $plugin, 'checkDependencies'), $client, $plugins)) { 
     467                call_user_func(array('Phergie_Plugin_' . $plugin, 'checkDependencies'), $client, $plugins) === true) { 
    468468                return true; 
    469469            } 
     
    487487            $plugins = array_map('strtolower', $plugins); 
    488488            if (in_array(strtolower($plugin), $plugins) && class_exists('Phergie_Plugin_' . $plugin) && 
    489                 call_user_func(array('Phergie_Plugin_' . $plugin, 'checkDependencies'), $client, $plugins)) { 
     489                call_user_func(array('Phergie_Plugin_' . $plugin, 'checkDependencies'), $client, $plugins) === true) { 
    490490                return true; 
    491491            } 
     
    546546     * @return bool TRUE if dependencies are met, FALSE otherwise 
    547547     */ 
    548     public static function checkDependencies(Phergie_Driver_Abstract $client, array$plugins) 
     548    public static function checkDependencies(Phergie_Driver_Abstract $client, array $plugins) 
    549549    { 
    550550        return true; 
  • trunk/Phergie/Plugin/Autojoin.php

    r247 r273  
    6060     * @return bool TRUE if dependencies are met, FALSE otherwise 
    6161     */ 
    62     public static function checkDependencies(Phergie_Driver_Abstract $client, array$plugins) 
     62    public static function checkDependencies(Phergie_Driver_Abstract $client, array $plugins) 
    6363    { 
    6464        $channels = $client->getIni('autojoin.channels'); 
     65 
    6566        if (empty($channels)) { 
    66             return false
     67            return 'Ini setting autojoin.channels must be filled-in'
    6768        } 
    6869 
  • trunk/Phergie/Plugin/ChuckNorris.php

    r232 r273  
    114114     * @return bool TRUE if dependencies are met, FALSE otherwise 
    115115     */ 
    116     public static function checkDependencies(Phergie_Driver_Abstract $client, array$plugins) 
    117     { 
    118         if (!extension_loaded('PDO') || !extension_loaded('pdo_sqlite')) { 
    119             return false; 
    120         } 
    121  
    122         return true; 
     116    public static function checkDependencies(Phergie_Driver_Abstract $client, array $plugins) 
     117    { 
     118        $errors = array(); 
     119 
     120        if (!extension_loaded('PDO')) { 
     121            $errors[] = 'PDO php extension is required'; 
     122        } 
     123        if (!extension_loaded('pdo_sqlite')) { 
     124            $errors[] = 'pdo_sqlite php extension is required'; 
     125        } 
     126 
     127        return empty($errors) ? true : $errors; 
    123128    } 
    124129 
  • trunk/Phergie/Plugin/Convert.php

    r266 r273  
    1616     * @return bool TRUE if dependencies are met, FALSE otherwise 
    1717     */ 
    18     public static function checkDependencies(Phergie_Driver_Abstract $client, array$plugins) 
     18    public static function checkDependencies(Phergie_Driver_Abstract $client, array $plugins) 
    1919    { 
    2020        if (!extension_loaded('Dom')) { 
    21             return false
     21            return 'Dom php extension is required'
    2222        } 
    2323 
  • trunk/Phergie/Plugin/Drink.php

    r252 r273  
    207207     * @return bool TRUE if dependencies are met, FALSE otherwise 
    208208     */ 
    209     public static function checkDependencies(Phergie_Driver_Abstract $client, array$plugins) 
    210     { 
    211         if (!extension_loaded('PDO') || !extension_loaded('pdo_sqlite')) { 
    212             return false; 
    213         } 
    214  
    215         return true; 
     209    public static function checkDependencies(Phergie_Driver_Abstract $client, array $plugins) 
     210    { 
     211        $errors = array(); 
     212 
     213        if (!extension_loaded('PDO')) { 
     214            $errors[] = 'PDO php extension is required'; 
     215        } 
     216        if (!extension_loaded('pdo_sqlite')) { 
     217            $errors[] = 'pdo_sqlite php extension is required'; 
     218        } 
     219 
     220        return empty($errors) ? true : $errors; 
    216221    } 
    217222 
  • trunk/Phergie/Plugin/FeedTicker.php

    r270 r273  
    151151     * @return bool TRUE if dependencies are met, FALSE otherwise 
    152152     */ 
    153     public static function checkDependencies(Phergie_Driver_Abstract $client, array$plugins) 
    154     { 
    155         if (!extension_loaded('SimpleXML')) { 
    156             return false
    157        
     153    public static function checkDependencies(Phergie_Driver_Abstract $client, array $plugins) 
     154    { 
     155       if (!extension_loaded('SimpleXML')) { 
     156            return 'SimpleXML php extension is required'
     157       
    158158 
    159159        return true; 
  • trunk/Phergie/Plugin/Karma.php

    r265 r273  
    202202     * @return bool TRUE if dependencies are met, FALSE otherwise 
    203203     */ 
    204     public static function checkDependencies(Phergie_Driver_Abstract $client, array$plugins) 
    205     { 
    206         if (!extension_loaded('PDO') || !extension_loaded('pdo_sqlite')) { 
    207             return false; 
    208         } 
    209  
    210         return true; 
     204    public static function checkDependencies(Phergie_Driver_Abstract $client, array $plugins) 
     205    { 
     206        $errors = array(); 
     207 
     208        if (!extension_loaded('PDO')) { 
     209            $errors[] = 'PDO php extension is required'; 
     210        } 
     211        if (!extension_loaded('pdo_sqlite')) { 
     212            $errors[] = 'pdo_sqlite php extension is required'; 
     213        } 
     214 
     215        return empty($errors) ? true : $errors; 
    211216    } 
    212217 
  • trunk/Phergie/Plugin/Lart.php

    r253 r273  
    147147     * @return bool TRUE if dependencies are met, FALSE otherwise 
    148148     */ 
    149     public static function checkDependencies(Phergie_Driver_Abstract $client, array$plugins) 
    150     { 
    151         if (!extension_loaded('PDO') || !extension_loaded('pdo_sqlite')) { 
    152             return false; 
    153         } 
    154  
    155         return true; 
     149    public static function checkDependencies(Phergie_Driver_Abstract $client, array $plugins) 
     150    { 
     151        $errors = array(); 
     152 
     153        if (!extension_loaded('PDO')) { 
     154            $errors[] = 'PDO php extension is required'; 
     155        } 
     156        if (!extension_loaded('pdo_sqlite')) { 
     157            $errors[] = 'pdo_sqlite php extension is required'; 
     158        } 
     159 
     160        return empty($errors) ? true : $errors; 
    156161    } 
    157162 
  • trunk/Phergie/Plugin/Sed.php

    r230 r273  
    5555     * @return bool TRUE if dependencies are met, FALSE otherwise 
    5656     */ 
    57     public static function checkDependencies(Phergie_Driver_Abstract $client, array$plugins) 
     57    public static function checkDependencies(Phergie_Driver_Abstract $client, array $plugins) 
    5858    { 
    5959        if (self::staticPluginLoaded('Logging', $client, $plugins)) { 
    60             return false
     60            return 'Logging plugin must be enabled'
    6161        } 
    6262        return true; 
  • trunk/Phergie/Plugin/Seen.php

    r264 r273  
    136136     * @return bool TRUE if dependencies are met, FALSE otherwise 
    137137     */ 
    138     public static function checkDependencies(Phergie_Driver_Abstract $client, array$plugins) 
     138    public static function checkDependencies(Phergie_Driver_Abstract $client, array $plugins) 
    139139    { 
    140140        if (self::staticPluginLoaded('Logging', $client, $plugins)) { 
    141             return false
     141            return 'Logging plugin must be enabled'
    142142        } 
    143143        return true; 
  • trunk/Phergie/Plugin/Spellcheck.php

    r258 r273  
    5757     * @return bool TRUE if dependencies are met, FALSE otherwise 
    5858     */ 
    59     static public function checkDependencies(Phergie_Driver_Abstract $client, array$plugins) 
    60     { 
    61         if (!extension_loaded('pspell') || !$client->getIni('spellcheck.lang')) { 
    62             return false; 
    63         } 
    64  
    65         return true; 
     59    static public function checkDependencies(Phergie_Driver_Abstract $client, array $plugins) 
     60    { 
     61        $errors = array(); 
     62 
     63        if (!extension_loaded('pspell')) { 
     64            $errors[] = 'pspell php extension is required'; 
     65        } 
     66        if (!$client->getIni('spellcheck.lang')) { 
     67            $errors[] = 'Ini setting spellcheck.lang must be filled-in'; 
     68        } 
     69 
     70        return empty($errors) ? true : $errors; 
    6671    } 
    6772 
  • trunk/Phergie/Plugin/Tld.php

    r237 r273  
    164164     * @return bool TRUE if dependencies are met, FALSE otherwise 
    165165     */ 
    166     public static function checkDependencies(Phergie_Driver_Abstract $client, array$plugins) 
    167     { 
    168         if (!extension_loaded('PDO') || !extension_loaded('pdo_sqlite')) { 
    169             return false; 
    170         } 
    171  
    172         return true; 
     166    public static function checkDependencies(Phergie_Driver_Abstract $client, array $plugins) 
     167    { 
     168        $errors = array(); 
     169 
     170        if (!extension_loaded('PDO')) { 
     171            $errors[] = 'PDO php extension is required'; 
     172        } 
     173        if (!extension_loaded('pdo_sqlite')) { 
     174            $errors[] = 'pdo_sqlite php extension is required'; 
     175        } 
     176 
     177        return empty($errors) ? true : $errors; 
    173178    } 
    174179 
  • trunk/Phergie/Plugin/Toggle.php

    r232 r273  
    170170                if (in_array($plugin, $plugins)) { 
    171171                    $class = 'Phergie_Plugin_' . $plugin; 
    172                     if (call_user_func(array($class, 'checkDependencies'), $this->client, $plugins)) { 
     172                    $result = call_user_func(array($class, 'checkDependencies'), $this->client, $plugins); 
     173                    if ($result === true) { 
    173174                        $instance = new $class($this->client); 
    174175                        $this->client->addPlugin($instance); 
     
    176177                        $this->doNotice($user, 'Plugin ' . $plugin . ' loaded.'); 
    177178                    } else { 
    178                         $this->doNotice($user, 'Plugin ' . $plugin . ' can not be loaded, missing dependencies.'); 
     179                        if ($plugin === false) { 
     180                            $this->doNotice($user, 'Plugin ' . $plugin . ' can not be loaded, missing dependencies.'); 
     181                        } else { 
     182                            $this->doNotice($user, 'Plugin ' . $plugin . ' can not be loaded : '. implode(', ', (array) $plugin)); 
     183                        } 
    179184                    } 
    180185                // Plugin file not found 
  • trunk/Phergie/Plugin/Weather.php

    r256 r273  
    4646     * @return bool TRUE if dependencies are met, FALSE otherwise 
    4747     */ 
    48     public static function checkDependencies(Phergie_Driver_Abstract $client, array$plugins) 
     48    public static function checkDependencies(Phergie_Driver_Abstract $client, array $plugins) 
    4949    { 
    5050        $partnerId = $client->getIni('weather.partner_id'); 
    5151        $licenseKey = $client->getIni('weather.license_key'); 
    5252 
    53         if (!$partnerId || !$licenseKey) { 
    54             return false; 
     53        $errors = array(); 
     54 
     55        if (!$licenseKey) { 
     56            $errors[] = 'Ini setting weather.license_key must be filled-in'; 
     57        } 
     58        if (!$partnerId) { 
     59            $errors[] = 'Ini setting weather.partner_id must be filled-in'; 
    5560        } 
    5661 
    57         return true
     62        return empty($errors) ? true : $errors
    5863    } 
    5964