init.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. class Af_Comics extends Plugin {
  3. private $host;
  4. private $filters = array();
  5. function about() {
  6. return array(1.0,
  7. "Fixes RSS feeds of assorted comic strips",
  8. "fox");
  9. }
  10. function init($host) {
  11. $this->host = $host;
  12. $host->add_hook($host::HOOK_ARTICLE_FILTER, $this);
  13. $host->add_hook($host::HOOK_PREFS_TAB, $this);
  14. require_once __DIR__ . "/filter_base.php";
  15. $filters = glob(__DIR__ . "/filters/*.php");
  16. foreach ($filters as $file) {
  17. require_once $file;
  18. $filter_name = preg_replace("/\..*$/", "", basename($file));
  19. $filter = new $filter_name();
  20. if (is_subclass_of($filter, "Af_ComicFilter")) {
  21. array_push($this->filters, $filter);
  22. }
  23. }
  24. }
  25. function hook_prefs_tab($args) {
  26. if ($args != "prefPrefs") return;
  27. print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Feeds supported by af_comics')."\">";
  28. print "<p>" . __("The following comics are currently supported:") . "</p>";
  29. $comics = array();
  30. foreach ($this->filters as $f) {
  31. foreach ($f->supported() as $comic) {
  32. array_push($comics, $comic);
  33. }
  34. }
  35. asort($comics);
  36. print "<ul class=\"browseFeedList\" style=\"border-width : 1px\">";
  37. foreach ($comics as $comic) {
  38. print "<li>$comic</li>";
  39. }
  40. print "</ul>";
  41. print "</div>";
  42. }
  43. function hook_article_filter($article) {
  44. $owner_uid = $article["owner_uid"];
  45. foreach ($this->filters as $f) {
  46. if ($f->process($article))
  47. break;
  48. }
  49. return $article;
  50. }
  51. function api_version() {
  52. return 2;
  53. }
  54. }
  55. ?>