]> git.wh0rd.org Git - tt-rss.git/blob - plugins/af_elreg/init.php
a652d25d153d59364da8891dcd3a4df30f5d9c25
[tt-rss.git] / plugins / af_elreg / init.php
1 <?php
2 class Af_ElReg extends Plugin {
3
4         private $host;
5
6         function about() {
7                 return array(1.0,
8                         "Fetch content of The Register 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                 if (strpos($article["link"], "theregister.co.uk") !== FALSE) {
20
21                                 $doc = new DOMDocument();
22                                 @$doc->loadHTML(fetch_file_contents($article["link"]));
23
24                                 $basenode = false;
25
26                                 if ($doc) {
27                                         $basenode = $doc->getElementById("body");
28
29                                         if ($basenode) {
30                                                 $article["content"] = $doc->saveXML($basenode);
31                                         }
32                                 }
33                 }
34
35                 return $article;
36         }
37
38         function api_version() {
39                 return 2;
40         }
41 }
42 ?>