summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2017-02-14 15:27:57 +0300
committerAndrew Dolgov <[email protected]>2017-02-14 15:27:57 +0300
commitd93f0e4be9ebf1c161ac258b7a179d9ab71a8b98 (patch)
tree7f68bcb79ebb9c57aeb76d6da9fece676f0f1c2a
initial
-rwxr-xr-xinit.php54
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;
+ }
+
+}
+?>