X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=plugins%2FPtitUrl%2FPtitUrlPlugin.php;h=cac5baf8b72e81fa339a19de656e82a1ba69254f;hb=1c05ed08453ab4f39687957ec61be61f3b978cf4;hp=ef453e96d84e388903efa480b7eb923e030777f3;hpb=a42e128c1532c45fd930d98c985f9a8d98ff6868;p=quix0rs-gnu-social.git diff --git a/plugins/PtitUrl/PtitUrlPlugin.php b/plugins/PtitUrl/PtitUrlPlugin.php index ef453e96d8..cac5baf8b7 100644 --- a/plugins/PtitUrl/PtitUrlPlugin.php +++ b/plugins/PtitUrl/PtitUrlPlugin.php @@ -22,7 +22,7 @@ * @category Plugin * @package StatusNet * @author Craig Andrews - * @copyright 2009 Craig Andrews http://candrews.integralblue.com + * @copyright 2009 Free Software Foundation, Inc http://www.fsf.org * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ */ @@ -30,7 +30,6 @@ if (!defined('STATUSNET')) { exit(1); } -require_once INSTALLDIR.'/plugins/UrlShortener/UrlShortenerPlugin.php'; class PtitUrlPlugin extends UrlShortenerPlugin { @@ -39,7 +38,8 @@ class PtitUrlPlugin extends UrlShortenerPlugin function onInitializePlugin(){ parent::onInitializePlugin(); if(!isset($this->serviceUrl)){ - throw new Exception("must specify a serviceUrl"); + // TRANS: Exception thrown when URL shortening plugin was configured incorrectly. + throw new Exception(_m('You must specify a serviceUrl for ptit URL shortening.')); } } @@ -47,11 +47,27 @@ class PtitUrlPlugin extends UrlShortenerPlugin { $response = $this->http_get(sprintf($this->serviceUrl,urlencode($url))); if (!$response) return; - $response = $this->tidy($response); - $y = @simplexml_load_string($response); + $dom = new DOMDocument(); + @$dom->loadHTML($response); + $y = @simplexml_import_dom($dom); if (!isset($y->body)) return; $xml = $y->body->center->table->tr->td->pre->a->attributes(); - if (isset($xml['href'])) return $xml['href']; + if (isset($xml['href'])) { + return strval($xml['href']); + } } -} + function onPluginVersion(&$versions) + { + $versions[] = array('name' => sprintf('PtitUrl (%s)', $this->shortenerName), + 'version' => STATUSNET_VERSION, + 'author' => 'Craig Andrews', + 'homepage' => 'http://status.net/wiki/Plugin:PtitUrl', + 'rawdescription' => + // TRANS: Plugin description. %1$s is the URL shortening service base URL (for example "bit.ly"). + sprintf(_m('Uses %1$s URL-shortener service.'), + $this->shortenerName)); + + return true; + } +}