summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2020-03-25 20:16:39 +0300
committerAndrew Dolgov <[email protected]>2020-03-25 20:16:39 +0300
commitc352fbddde13273defe5a4fff6332f43ff427902 (patch)
treed01b02bdc2d16263c1552fae7ede4f51cb6d2bad
initial
-rw-r--r--init.php41
1 files changed, 41 insertions, 0 deletions
diff --git a/init.php b/init.php
new file mode 100644
index 0000000..560facc
--- /dev/null
+++ b/init.php
@@ -0,0 +1,41 @@
+<?php
+
+class Af_Fontanka extends Plugin {
+
+ function about() {
+ return array(1.0,
+ "Gets full text content from fontanka.ru RSS feed",
+ "fox");
+ }
+
+ function init($host) {
+ $host->add_hook($host::HOOK_ARTICLE_FILTER, $this);
+ }
+
+ function hook_article_filter($article) {
+ if (strpos($article["link"], ".fontanka.ru") !== FALSE) {
+ $tmp = fetch_file_contents(["url" => $article["link"]]);
+
+ if ($tmp) {
+ $doc = new DOMDocument("1.0", "UTF-8");
+
+ if (!@$doc->loadHTML($tmp))
+ return false;
+
+ $xpath = new DOMXPath($doc);
+ $base_node = $xpath->query("//article")->item(0);
+
+ if ($base_node) {
+ $article["content"] = $doc->saveHTML($base_node);
+ }
+ }
+ }
+
+ return $article;
+ }
+
+ function api_version() {
+ return 2;
+ }
+
+}