diff options
author | Evan Prodromou <evan@status.net> | 2009-11-14 17:14:35 +0100 |
---|---|---|
committer | Evan Prodromou <evan@status.net> | 2009-11-14 17:14:35 +0100 |
commit | 959d278c347fdf90e0227adc57c0215f5d82404a (patch) | |
tree | 16eb3b0155b446ada520566e187b4c47b0b9e76b /plugins/PtitUrl/PtitUrlPlugin.php | |
parent | 093857c582a68b39e0d65523d27f25ede7b7fed6 (diff) | |
parent | 2147ac510f5489c860a4bebf3ab48a069b89ecfb (diff) |
Merge branch '0.9.x' of git@gitorious.org:statusnet/mainline into 0.9.x
Diffstat (limited to 'plugins/PtitUrl/PtitUrlPlugin.php')
-rw-r--r-- | plugins/PtitUrl/PtitUrlPlugin.php | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/plugins/PtitUrl/PtitUrlPlugin.php b/plugins/PtitUrl/PtitUrlPlugin.php index f00d3e2f2..ef453e96d 100644 --- a/plugins/PtitUrl/PtitUrlPlugin.php +++ b/plugins/PtitUrl/PtitUrlPlugin.php @@ -30,33 +30,28 @@ if (!defined('STATUSNET')) { exit(1); } +require_once INSTALLDIR.'/plugins/UrlShortener/UrlShortenerPlugin.php'; -class PtitUrlPlugin extends Plugin +class PtitUrlPlugin extends UrlShortenerPlugin { - function __construct() - { - parent::__construct(); - } + public $serviceUrl; function onInitializePlugin(){ - $this->registerUrlShortener( - 'ptiturl.com', - array(), - array('PtitUrl',array('http://ptiturl.com/?creer=oui&action=Reduire&url=')) - ); + parent::onInitializePlugin(); + if(!isset($this->serviceUrl)){ + throw new Exception("must specify a serviceUrl"); + } } -} -class PtitUrl extends ShortUrlApi -{ - protected function shorten_imp($url) { - $response = $this->http_get($url); - if (!$response) return $url; + protected function shorten($url) + { + $response = $this->http_get(sprintf($this->serviceUrl,urlencode($url))); + if (!$response) return; $response = $this->tidy($response); $y = @simplexml_load_string($response); - if (!isset($y->body)) return $url; + if (!isset($y->body)) return; $xml = $y->body->center->table->tr->td->pre->a->attributes(); if (isset($xml['href'])) return $xml['href']; - return $url; } } + |