]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/TightUrl/TightUrlPlugin.php
Merge branch '0.9.x' of git@gitorious.org:statusnet/mainline into 0.9.x
[quix0rs-gnu-social.git] / plugins / TightUrl / TightUrlPlugin.php
index 56414c8c8d121fe45ea23668e79a0bdf750c8df7..e2d494a7bda4c4ebf2c7714c7a31259b8e7ee18b 100644 (file)
@@ -48,10 +48,25 @@ class TightUrlPlugin 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->p[0]->code[0]->a->attributes();
-        if (isset($xml['href'])) return $xml['href'];
+        if (isset($xml['href'])) {
+            return strval($xml['href']);
+        }
+    }
+
+    function onPluginVersion(&$versions)
+    {
+        $versions[] = array('name' => sprintf('TightUrl (%s)', $this->shortenerName),
+                            'version' => STATUSNET_VERSION,
+                            'author' => 'Craig Andrews',
+                            'homepage' => 'http://status.net/wiki/Plugin:TightUrl',
+                            'rawdescription' =>
+                            sprintf(_m('Uses <a href="http://%1$s/">%1$s</a> URL-shortener service.'),
+                                    $this->shortenerName));
+        return true;
     }
 }