diff options
author | Andrew Dolgov <[email protected]> | 2017-02-14 15:27:57 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2017-02-14 15:27:57 +0300 |
commit | d93f0e4be9ebf1c161ac258b7a179d9ab71a8b98 (patch) | |
tree | 7f68bcb79ebb9c57aeb76d6da9fece676f0f1c2a |
initial
-rwxr-xr-x | init.php | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/init.php b/init.php new file mode 100755 index 0000000..e62e353 --- /dev/null +++ b/init.php @@ -0,0 +1,54 @@ +<?php +class Af_GoodShowSir extends Plugin { + private $host; + + function about() { + return array(1.0, + "Fix image url in goodshowsir.co.uk RSS feed", + "fox"); + } + + function init($host) { + $this->host = $host; + + $host->add_hook($host::HOOK_ARTICLE_FILTER, $this); + } + + function hook_article_filter($article) { + + $doc = new DOMDocument(); + + $found = false; + + if (@$doc->loadHTML($article["content"])) { + + $xpath = new DOMXpath($doc); + $images = $xpath->query('(//img[contains(@src, \'goodshowsir.co.uk\')])'); + + foreach ($images as $img) { + $src = $img->getAttribute("src"); + + if (strpos($src, " ") !== FALSE) { + $img->setAttribute("src", trim($src)); + + $found = true; + + } + } + } + + if ($found) { + $article["content"] = $doc->saveXML(); + } + + return $article; + + } + + + function api_version() { + return 2; + } + +} +?> |