]>
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_notice("This plugin can be easily extended by adding filters to <code>plugins/af_comics/filters</code>."); |
de0d8d10 | 42 | |
901dd67a | 43 | print "<p>" . __("The following comics are currently supported:") . "</p>"; |
de0d8d10 | 44 | |
901dd67a | 45 | $comics = array(); |
de0d8d10 | 46 | |
901dd67a AD |
47 | foreach ($this->filters as $f) { |
48 | foreach ($f->supported() as $comic) { | |
49 | array_push($comics, $comic); | |
de0d8d10 AD |
50 | } |
51 | } | |
52 | ||
901dd67a | 53 | asort($comics); |
3df1a8b8 | 54 | |
901dd67a AD |
55 | print "<ul class=\"browseFeedList\" style=\"border-width : 1px\">"; |
56 | foreach ($comics as $comic) { | |
57 | print "<li>$comic</li>"; | |
de0d8d10 | 58 | } |
901dd67a | 59 | print "</ul>"; |
de0d8d10 | 60 | |
901dd67a AD |
61 | print "</div>"; |
62 | } | |
de0d8d10 | 63 | |
901dd67a AD |
64 | function hook_article_filter($article) { |
65 | $owner_uid = $article["owner_uid"]; | |
de0d8d10 | 66 | |
901dd67a AD |
67 | foreach ($this->filters as $f) { |
68 | if ($f->process($article)) | |
69 | break; | |
de0d8d10 AD |
70 | } |
71 | ||
72 | return $article; | |
901dd67a | 73 | |
de0d8d10 AD |
74 | } |
75 | ||
76 | function api_version() { | |
77 | return 2; | |
78 | } | |
79 | ||
80 | } | |
81 | ?> |