]> git.wh0rd.org - tt-rss.git/blame - plugins/af_sciam/init.php
plugins: remove obsolete plugin_data/stored stuff
[tt-rss.git] / plugins / af_sciam / init.php
CommitLineData
c309f41d
AD
1<?php
2class Af_SciAm extends Plugin {
3
4 private $host;
5
6 function about() {
7 return array(1.0,
8 "Fetch content of Scientific American feeds",
9 "fox");
10 }
11
12 function init($host) {
13 $this->host = $host;
14
15 $host->add_hook($host::HOOK_ARTICLE_FILTER, $this);
16 }
17
18 function hook_article_filter($article) {
19 $owner_uid = $article["owner_uid"];
20
54af7f84 21 if (strpos($article["link"], "scientificamerican.com") !== FALSE || strpos($article["link"], "rss.sciam.com") !== FALSE) {
c309f41d
AD
22
23 $doc = new DOMDocument();
24 @$doc->loadHTML(fetch_file_contents($article["link"]));
25
26 $basenode = false;
27
28 if ($doc) {
54af7f84
AD
29 $xpath = new DOMXpath($doc);
30
31 $basenode = $xpath->query("//*[@id='singleBlogPost' or @id='articleContent']")->item(0);
c309f41d
AD
32
33 if ($basenode) {
34 $article["content"] = $doc->saveXML($basenode);
c309f41d
AD
35 }
36 }
c309f41d
AD
37 }
38
39 return $article;
40 }
41
42 function api_version() {
43 return 2;
44 }
45}
46?>