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