Assembla home | Assembla project page
 

Changeset 275

Show
Ignore:
Timestamp:
08/01/08 18:11:54 (4 months ago)
Author:
Seldaek
Message:

fixes #45

Files:

Legend:

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

    r273 r275  
    211211    { 
    212212        $this->client->debug('<' . strtolower($this->name) . '> ' . $message, $displayDebug); 
    213     } 
    214  
    215     /** 
    216      * Returns a TinyURL version of a given URL. 
    217      * 
    218      * @param string $url URL to convert 
    219      * @return string 
    220      */ 
    221     public function tinyUrl($url) 
    222     { 
    223         $tiny = $url; 
    224         if (strlen($url) > 30) { 
    225             $opts = array( 
    226                 'http' => array( 
    227                     'timeout' => 4, 
    228                     'method' => 'POST', 
    229                     'header' => 'Content-type: application/x-www-form-urlencoded', 
    230                     'content' => http_build_query(array( 
    231                         'url' => $url 
    232                     )) 
    233                 ) 
    234             ); 
    235             $context = stream_context_create($opts); 
    236             $tiny = @file_get_contents('http://tinyurl.com/api-create.php', false, $context); 
    237             if (empty($tiny)) { 
    238                 $tiny = $url; 
    239             } 
    240         } 
    241  
    242         return $tiny; 
    243213    } 
    244214 
  • trunk/Phergie/Plugin/Abstract/Cron.php

    r217 r275  
    88 * delayed. 
    99 */ 
    10 abstract class Phergie_Plugin_Abstract_Cron extends Phergie_Plugin_Abstract_Base 
     10abstract class Phergie_Plugin_Abstract_Cron extends Phergie_Plugin_Abstract_Command 
    1111{ 
    1212    /** 
     
    5454        if (time() > $this->nextCall) { 
    5555            $this->run(); 
    56             $this->nextCall = time() +$this->delay; 
     56            $this->nextCall = time() + $this->delay; 
    5757        } 
    5858    } 
  • trunk/Phergie/Plugin/FeedTicker.php

    r273 r275  
    153153    public static function checkDependencies(Phergie_Driver_Abstract $client, array $plugins) 
    154154    { 
     155        $errors = array(); 
     156 
    155157        if (!extension_loaded('SimpleXML')) { 
    156             return 'SimpleXML php extension is required'; 
     158            $errors[] = 'SimpleXML php extension is required'; 
    157159        } 
    158  
    159         return true; 
     160        if (self::staticPluginLoaded('TinyUrl', $client, $plugins)) { 
     161            $errors[] = 'TinyUrl plugin must be enabled'; 
     162        } 
     163 
     164        return empty($errors) ? true : $errors; 
    160165    } 
    161166 
     
    278283                    $article[0] = $this->decode($article[0], 40); 
    279284                    // Convert link with TinyURL if required 
    280                     $article[1] = $this->tinyUrl($article[1]); 
     285                    $article[1] = Phergie_Plugin_TinyUrl::get($article[1]); 
    281286                    // Decode and trim feed title 
    282287                    $article[3] = $this->decode($article[3], 20); 
  • trunk/Phergie/Plugin/Php.php

    r245 r275  
    2424     */ 
    2525    protected $errorStatus = false; 
     26 
     27    /** 
     28     * Returns whether or not the plugin's dependencies are met. 
     29     * 
     30     * @param Phergie_Driver_Abstract $client Client instance 
     31     * @param array $plugins List of short names for plugins that the 
     32     *                       bootstrap file intends to instantiate 
     33     * @see Phergie_Plugin_Abstract_Base::checkDependencies() 
     34     * @return bool TRUE if dependencies are met, FALSE otherwise 
     35     */ 
     36    public static function checkDependencies(Phergie_Driver_Abstract $client, array $plugins) 
     37    { 
     38        if (self::staticPluginLoaded('TinyUrl', $client, $plugins)) { 
     39            return 'TinyUrl plugin must be enabled'; 
     40        } 
     41 
     42        return true; 
     43    } 
    2644 
    2745    /** 
     
    6381            $tmp = file_get_contents('http://php.net/manual/en/function.' . $name . '.php'); 
    6482            if (!$this->errorStatus && strpos($tmp, '<p class="refpurpose dc-title">') !== false) { 
    65                $contents = '[ ' . $this->tinyUrl('http://php.net/' . $name) . ' ] '; 
     83               $contents = '[ ' . Phergie_Plugin_TinyUrl::get('http://php.net/' . $name) . ' ] '; 
    6684               if (preg_match('/<div class="methodsynopsis dc-description">(.*?)<\/div>/mis', $tmp, $m)) { 
    6785                  $contents .= $this->decode($m[1]); 
  • trunk/Phergie/Plugin/UrbanDictionary.php

    r217 r275  
    77class Phergie_Plugin_UrbanDictionary extends Phergie_Plugin_Abstract_Command 
    88{ 
     9    /** 
     10     * Returns whether or not the plugin's dependencies are met. 
     11     * 
     12     * @param Phergie_Driver_Abstract $client Client instance 
     13     * @param array $plugins List of short names for plugins that the 
     14     *                       bootstrap file intends to instantiate 
     15     * @see Phergie_Plugin_Abstract_Base::checkDependencies() 
     16     * @return bool TRUE if dependencies are met, FALSE otherwise 
     17     */ 
     18    public static function checkDependencies(Phergie_Driver_Abstract $client, array $plugins) 
     19    { 
     20        if (self::staticPluginLoaded('TinyUrl', $client, $plugins)) { 
     21            return 'TinyUrl plugin must be enabled'; 
     22        } 
     23 
     24        return true; 
     25    } 
     26 
    927    /** 
    1028     * Handles Urban Dictionary definition requests. 
     
    2240 
    2341        if (strpos($contents, '<i>' . $term . '</i> isn\'t defined') !== false) { 
    24             $url = $this->tinyUrl('http://urbandictionary.com/insert.php?word=' . $term); 
     42            $url = Phergie_Plugin_TinyUrl::get('http://urbandictionary.com/insert.php?word=' . $term); 
    2543            $this->doNotice($target, $term . ' is not defined yet [ ' . $url . ' ]'); 
    2644        } else { 
     
    3452            $contents = $term . ': ' . trim(preg_replace('/[\r\n\t ]+/', ' ', $contents)); 
    3553 
    36             $url = ' [ ' . $this->tinyUrl($url) . ' ]'; 
     54            $url = ' [ ' . Phergie_Plugin_TinyUrl::get($url) . ' ]'; 
    3755 
    3856            /** 
  • trunk/Phergie/Plugin/Url.php

    r274 r275  
    126126 
    127127    /** 
     128     * Returns whether or not the plugin's dependencies are met. 
     129     * 
     130     * @param Phergie_Driver_Abstract $client Client instance 
     131     * @param array $plugins List of short names for plugins that the 
     132     *                       bootstrap file intends to instantiate 
     133     * @see Phergie_Plugin_Abstract_Base::checkDependencies() 
     134     * @return bool TRUE if dependencies are met, FALSE otherwise 
     135     */ 
     136    public static function checkDependencies(Phergie_Driver_Abstract $client, array $plugins) 
     137    { 
     138        if (self::staticPluginLoaded('TinyUrl', $client, $plugins)) { 
     139            return 'TinyUrl plugin must be enabled'; 
     140        } 
     141 
     142        return true; 
     143    } 
     144 
     145    /** 
    128146     * Obtains configuration settings 
    129147     * 
     
    232250 
    233251                // Convert url 
    234                 $tinyUrl = $this->tinyUrl($url); 
     252                $tinyUrl = Phergie_Plugin_TinyUrl::get($url); 
    235253 
    236254                // Prevent spamfest