]>
Commit | Line | Data |
---|---|---|
de0d8d10 AD |
1 | <?php |
2 | class Af_Comics extends Plugin { | |
3 | ||
4 | private $host; | |
901dd67a | 5 | private $filters = array(); |
de0d8d10 AD |
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); | |
de0d8d10 | 18 | |
901dd67a | 19 | require_once __DIR__ . "/filter_base.php"; |
de0d8d10 | 20 | |
901dd67a | 21 | $filters = glob(__DIR__ . "/filters/*.php"); |
de0d8d10 | 22 | |
901dd67a AD |
23 | foreach ($filters as $file) { |
24 | require_once $file; | |
25 | $filter_name = preg_replace("/\..*$/", "", basename($file)); | |
de0d8d10 | 26 | |
901dd67a | 27 | $filter = new $filter_name(); |
de0d8d10 | 28 | |
901dd67a AD |
29 | if (is_subclass_of($filter, "Af_ComicFilter")) { |
30 | array_push($this->filters, $filter); | |
52265e19 AD |
31 | } |
32 | } | |
33 | ||
901dd67a | 34 | } |
de0d8d10 | 35 | |
901dd67a AD |
36 | function hook_prefs_tab($args) { |
37 | if ($args != "prefPrefs") return; | |
de0d8d10 | 38 | |
901dd67a | 39 | print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Feeds supported by af_comics')."\">"; |
de0d8d10 | 40 | |
901dd67a | 41 | print "<p>" . __("The following comics are currently supported:") . "</p>"; |
de0d8d10 | 42 | |
901dd67a | 43 | $comics = array(); |
de0d8d10 | 44 | |
901dd67a AD |
45 | foreach ($this->filters as $f) { |
46 | foreach ($f->supported() as $comic) { | |
47 | array_push($comics, $comic); | |
de0d8d10 AD |
48 | } |
49 | } | |
50 | ||
901dd67a | 51 | asort($comics); |
3df1a8b8 | 52 | |
901dd67a AD |
53 | print "<ul class=\"browseFeedList\" style=\"border-width : 1px\">"; |
54 | foreach ($comics as $comic) { | |
55 | print "<li>$comic</li>"; | |
de0d8d10 | 56 | } |
901dd67a | 57 | print "</ul>"; |
de0d8d10 | 58 | |
901dd67a AD |
59 | print "</div>"; |
60 | } | |
de0d8d10 | 61 | |
901dd67a AD |
62 | function hook_article_filter($article) { |
63 | $owner_uid = $article["owner_uid"]; | |
de0d8d10 | 64 | |
901dd67a AD |
65 | foreach ($this->filters as $f) { |
66 | if ($f->process($article)) | |
67 | break; | |
de0d8d10 AD |
68 | } |
69 | ||
70 | return $article; | |
901dd67a | 71 | |
de0d8d10 AD |
72 | } |
73 | ||
74 | function api_version() { | |
75 | return 2; | |
76 | } | |
77 | ||
78 | } | |
79 | ?> |