]> git.wh0rd.org Git - tt-rss.git/blob - plugins/af_comics/init.php
Merge pull request #1 from gothfox/master
[tt-rss.git] / plugins / af_comics / init.php
1 <?php
2 class Af_Comics extends Plugin {
3
4         private $host;
5         private $filters = array();
6
7         function about() {
8                 return array(1.0,
9                         "Fixes RSS feeds of assorted comic strips",
10                         "fox");
11         }
12
13         function init($host) {
14                 $this->host = $host;
15
16                 $host->add_hook($host::HOOK_ARTICLE_FILTER, $this);
17                 $host->add_hook($host::HOOK_PREFS_TAB, $this);
18
19                 require_once __DIR__ . "/filter_base.php";
20
21                 $filters = glob(__DIR__ . "/filters/*.php");
22
23                 foreach ($filters as $file) {
24                         require_once $file;
25                         $filter_name = preg_replace("/\..*$/", "", basename($file));
26
27                         $filter = new $filter_name();
28
29                         if (is_subclass_of($filter, "Af_ComicFilter")) {
30                                 array_push($this->filters, $filter);
31                         }
32                 }
33
34         }
35
36         function hook_prefs_tab($args) {
37                 if ($args != "prefPrefs") return;
38
39                 print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Feeds supported by af_comics')."\">";
40
41                 print "<p>" . __("The following comics are currently supported:") . "</p>";
42
43                 $comics = array();
44
45                 foreach ($this->filters as $f) {
46                         foreach ($f->supported() as $comic) {
47                                 array_push($comics, $comic);
48                         }
49                 }
50
51                 asort($comics);
52
53                 print "<ul class=\"browseFeedList\" style=\"border-width : 1px\">";
54                 foreach ($comics as $comic) {
55                         print "<li>$comic</li>";
56                 }
57                 print "</ul>";
58
59                 print "</div>";
60         }
61
62         function hook_article_filter($article) {
63                 $owner_uid = $article["owner_uid"];
64
65                 foreach ($this->filters as $f) {
66                         if ($f->process($article))
67                                 break;
68                 }
69
70                 return $article;
71
72         }
73
74         function api_version() {
75                 return 2;
76         }
77
78 }
79 ?>