Changeset 275
- Timestamp:
- 08/01/08 18:11:54 (4 months ago)
- Files:
-
- trunk/Phergie/Plugin/Abstract/Base.php (modified) (1 diff)
- trunk/Phergie/Plugin/Abstract/Cron.php (modified) (2 diffs)
- trunk/Phergie/Plugin/FeedTicker.php (modified) (2 diffs)
- trunk/Phergie/Plugin/Php.php (modified) (2 diffs)
- trunk/Phergie/Plugin/UrbanDictionary.php (modified) (3 diffs)
- trunk/Phergie/Plugin/Url.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/Phergie/Plugin/Abstract/Base.php
r273 r275 211 211 { 212 212 $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 convert219 * @return string220 */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' => $url232 ))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;243 213 } 244 214 trunk/Phergie/Plugin/Abstract/Cron.php
r217 r275 8 8 * delayed. 9 9 */ 10 abstract class Phergie_Plugin_Abstract_Cron extends Phergie_Plugin_Abstract_ Base10 abstract class Phergie_Plugin_Abstract_Cron extends Phergie_Plugin_Abstract_Command 11 11 { 12 12 /** … … 54 54 if (time() > $this->nextCall) { 55 55 $this->run(); 56 $this->nextCall = time() + $this->delay;56 $this->nextCall = time() + $this->delay; 57 57 } 58 58 } trunk/Phergie/Plugin/FeedTicker.php
r273 r275 153 153 public static function checkDependencies(Phergie_Driver_Abstract $client, array $plugins) 154 154 { 155 $errors = array(); 156 155 157 if (!extension_loaded('SimpleXML')) { 156 return'SimpleXML php extension is required';158 $errors[] = 'SimpleXML php extension is required'; 157 159 } 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; 160 165 } 161 166 … … 278 283 $article[0] = $this->decode($article[0], 40); 279 284 // Convert link with TinyURL if required 280 $article[1] = $this->tinyUrl($article[1]);285 $article[1] = Phergie_Plugin_TinyUrl::get($article[1]); 281 286 // Decode and trim feed title 282 287 $article[3] = $this->decode($article[3], 20); trunk/Phergie/Plugin/Php.php
r245 r275 24 24 */ 25 25 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 } 26 44 27 45 /** … … 63 81 $tmp = file_get_contents('http://php.net/manual/en/function.' . $name . '.php'); 64 82 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) . ' ] '; 66 84 if (preg_match('/<div class="methodsynopsis dc-description">(.*?)<\/div>/mis', $tmp, $m)) { 67 85 $contents .= $this->decode($m[1]); trunk/Phergie/Plugin/UrbanDictionary.php
r217 r275 7 7 class Phergie_Plugin_UrbanDictionary extends Phergie_Plugin_Abstract_Command 8 8 { 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 9 27 /** 10 28 * Handles Urban Dictionary definition requests. … … 22 40 23 41 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); 25 43 $this->doNotice($target, $term . ' is not defined yet [ ' . $url . ' ]'); 26 44 } else { … … 34 52 $contents = $term . ': ' . trim(preg_replace('/[\r\n\t ]+/', ' ', $contents)); 35 53 36 $url = ' [ ' . $this->tinyUrl($url) . ' ]';54 $url = ' [ ' . Phergie_Plugin_TinyUrl::get($url) . ' ]'; 37 55 38 56 /** trunk/Phergie/Plugin/Url.php
r274 r275 126 126 127 127 /** 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 /** 128 146 * Obtains configuration settings 129 147 * … … 232 250 233 251 // Convert url 234 $tinyUrl = $this->tinyUrl($url);252 $tinyUrl = Phergie_Plugin_TinyUrl::get($url); 235 253 236 254 // Prevent spamfest