Ticket 1870: drop unnecessary Tidy module installation requirement.
Tidy was only being used by a couple of non-default URL shortener plugins, PtitUrl and TightUrl. Both were easily changed to load the tag-soup HTML via DOMDocument (using the default DOM module which is already used by other dependencies). Added xml, dom, and simplexml modules to the requirements check in install.php, as they were being used but not checked for. Also cleaned up LilUrl, PtitUrl, and TightUrl to return URL as a string instead of as a SimpleXML node object.
This commit is contained in:
parent
a2e4ac2fe8
commit
10f40661a2
2
README
2
README
|
@ -98,7 +98,6 @@ released Aug 26 2009. Notable changes this version:
|
||||||
- Better error handling in Twitter posting.
|
- Better error handling in Twitter posting.
|
||||||
- Show oEmbed data for XHTML files as well as plain HTML.
|
- Show oEmbed data for XHTML files as well as plain HTML.
|
||||||
- Updated bug database link in README.
|
- Updated bug database link in README.
|
||||||
- require HTML tidy extension.
|
|
||||||
- add support for HTTP Basic Auth in PHP CGI or FastCGI (e.g. GoDaddy).
|
- add support for HTTP Basic Auth in PHP CGI or FastCGI (e.g. GoDaddy).
|
||||||
- autofocus input to selected entry elements depending on page.
|
- autofocus input to selected entry elements depending on page.
|
||||||
- updated layout for filter-by-tag form.
|
- updated layout for filter-by-tag form.
|
||||||
|
@ -179,7 +178,6 @@ Your PHP installation must include the following PHP extensions:
|
||||||
- GD. For scaling down avatar images.
|
- GD. For scaling down avatar images.
|
||||||
- mbstring. For handling Unicode (UTF-8) encoded strings.
|
- mbstring. For handling Unicode (UTF-8) encoded strings.
|
||||||
- gettext. For multiple languages. Default on many PHP installs.
|
- gettext. For multiple languages. Default on many PHP installs.
|
||||||
- tidy. Used to clean up HTML/URLs for the URL shortener to consume.
|
|
||||||
|
|
||||||
For some functionality, you will also need the following extensions:
|
For some functionality, you will also need the following extensions:
|
||||||
|
|
||||||
|
|
|
@ -301,7 +301,7 @@ function checkPrereqs()
|
||||||
}
|
}
|
||||||
|
|
||||||
$reqs = array('gd', 'curl',
|
$reqs = array('gd', 'curl',
|
||||||
'xmlwriter', 'mbstring','tidy');
|
'xmlwriter', 'mbstring', 'xml', 'dom', 'simplexml');
|
||||||
|
|
||||||
foreach ($reqs as $req) {
|
foreach ($reqs as $req) {
|
||||||
if (!checkExtension($req)) {
|
if (!checkExtension($req)) {
|
||||||
|
|
|
@ -54,7 +54,7 @@ class LilUrlPlugin extends UrlShortenerPlugin
|
||||||
if (!isset($y->body)) return;
|
if (!isset($y->body)) return;
|
||||||
$x = $y->body->p[0]->a->attributes();
|
$x = $y->body->p[0]->a->attributes();
|
||||||
if (isset($x['href'])) {
|
if (isset($x['href'])) {
|
||||||
return $x['href'];
|
return strval($x['href']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,11 +47,14 @@ class PtitUrlPlugin extends UrlShortenerPlugin
|
||||||
{
|
{
|
||||||
$response = $this->http_get(sprintf($this->serviceUrl,urlencode($url)));
|
$response = $this->http_get(sprintf($this->serviceUrl,urlencode($url)));
|
||||||
if (!$response) return;
|
if (!$response) return;
|
||||||
$response = $this->tidy($response);
|
$dom = new DOMDocument();
|
||||||
$y = @simplexml_load_string($response);
|
@$dom->loadHTML($response);
|
||||||
|
$y = @simplexml_import_dom($dom);
|
||||||
if (!isset($y->body)) return;
|
if (!isset($y->body)) return;
|
||||||
$xml = $y->body->center->table->tr->td->pre->a->attributes();
|
$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']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,10 +48,13 @@ class TightUrlPlugin extends UrlShortenerPlugin
|
||||||
{
|
{
|
||||||
$response = $this->http_get(sprintf($this->serviceUrl,urlencode($url)));
|
$response = $this->http_get(sprintf($this->serviceUrl,urlencode($url)));
|
||||||
if (!$response) return;
|
if (!$response) return;
|
||||||
$response = $this->tidy($response);
|
$dom = new DOMDocument();
|
||||||
$y = @simplexml_load_string($response);
|
@$dom->loadHTML($response);
|
||||||
|
$y = @simplexml_import_dom($dom);
|
||||||
if (!isset($y->body)) return;
|
if (!isset($y->body)) return;
|
||||||
$xml = $y->body->p[0]->code[0]->a->attributes();
|
$xml = $y->body->p[0]->code[0]->a->attributes();
|
||||||
if (isset($xml['href'])) return $xml['href'];
|
if (isset($xml['href'])) {
|
||||||
|
return strval($xml['href']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,14 +68,6 @@ abstract class UrlShortenerPlugin extends Plugin
|
||||||
return $response->getBody();
|
return $response->getBody();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function tidy($response) {
|
|
||||||
$response = str_replace(' ', ' ', $response);
|
|
||||||
$config = array('output-xhtml' => true);
|
|
||||||
$tidy = new tidy;
|
|
||||||
$tidy->parseString($response, $config, 'utf8');
|
|
||||||
$tidy->cleanRepair();
|
|
||||||
return (string)$tidy;
|
|
||||||
}
|
|
||||||
//------------Below are the methods that connect StatusNet to the implementing Url Shortener plugin------------\\
|
//------------Below are the methods that connect StatusNet to the implementing Url Shortener plugin------------\\
|
||||||
|
|
||||||
function onInitializePlugin(){
|
function onInitializePlugin(){
|
||||||
|
|
Loading…
Reference in New Issue
Block a user