]> git.wh0rd.org Git - tt-rss.git/blob - plugins/af_habr/init.php
plugins: remove obsolete plugin_data/stored stuff
[tt-rss.git] / plugins / af_habr / init.php
1 <?php
2 class Af_Habr extends Plugin {
3
4         function about() {
5                 return array(1.0,
6                         "Fetch content of Habrahabr feeds",
7                         "fox");
8         }
9
10         function init($host) {
11                 $this->host = $host;
12
13                 $host->add_hook($host::HOOK_ARTICLE_FILTER, $this);
14         }
15
16         function hook_article_filter($article) {
17                 $owner_uid = $article["owner_uid"];
18
19                 if (strpos($article["link"], "habrahabr.ru") !== FALSE) {
20
21                                 $doc = new DOMDocument();
22                                 @$doc->loadHTML(fetch_file_contents($article["link"]));
23
24                                 $basenode = false;
25
26                                 if ($doc) {
27                                         $xpath = new DOMXPath($doc);
28
29                                         $basenode = $xpath->query("//div[contains(@class,'content') and contains(@class, 'html_format')]")->item(0);
30
31                                         if ($basenode) {
32                                                 $article["content"] = $doc->saveXML($basenode);
33                                         }
34                                 }
35                 }
36
37                 return $article;
38         }
39
40         function api_version() {
41                 return 2;
42         }
43 }
44 ?>