2014-01-09 10:08:39 +00:00
|
|
|
<?php
|
|
|
|
class Af_Comics extends Plugin {
|
|
|
|
|
|
|
|
private $host;
|
2014-02-17 09:00:25 +00:00
|
|
|
private $filters = array();
|
2014-01-09 10:08:39 +00:00
|
|
|
|
|
|
|
function about() {
|
|
|
|
return array(1.0,
|
|
|
|
"Fixes RSS feeds of assorted comic strips",
|
|
|
|
"fox");
|
|
|
|
}
|
|
|
|
|
|
|
|
function init($host) {
|
|
|
|
$this->host = $host;
|
|
|
|
|
|
|
|
$host->add_hook($host::HOOK_ARTICLE_FILTER, $this);
|
|
|
|
$host->add_hook($host::HOOK_PREFS_TAB, $this);
|
|
|
|
|
2014-02-17 09:00:25 +00:00
|
|
|
require_once __DIR__ . "/filter_base.php";
|
2014-01-09 10:08:39 +00:00
|
|
|
|
2014-02-17 09:00:25 +00:00
|
|
|
$filters = glob(__DIR__ . "/filters/*.php");
|
2014-01-09 10:08:39 +00:00
|
|
|
|
2014-02-17 09:00:25 +00:00
|
|
|
foreach ($filters as $file) {
|
|
|
|
require_once $file;
|
|
|
|
$filter_name = preg_replace("/\..*$/", "", basename($file));
|
2014-01-09 10:08:39 +00:00
|
|
|
|
2014-02-17 09:00:25 +00:00
|
|
|
$filter = new $filter_name();
|
2014-01-09 10:08:39 +00:00
|
|
|
|
2014-02-17 09:00:25 +00:00
|
|
|
if (is_subclass_of($filter, "Af_ComicFilter")) {
|
|
|
|
array_push($this->filters, $filter);
|
2014-02-17 08:26:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-17 09:00:25 +00:00
|
|
|
}
|
2014-01-09 10:08:39 +00:00
|
|
|
|
2014-02-17 09:00:25 +00:00
|
|
|
function hook_prefs_tab($args) {
|
|
|
|
if ($args != "prefPrefs") return;
|
2014-01-09 10:08:39 +00:00
|
|
|
|
2014-02-17 09:00:25 +00:00
|
|
|
print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Feeds supported by af_comics')."\">";
|
2014-01-09 10:08:39 +00:00
|
|
|
|
2014-02-17 09:00:25 +00:00
|
|
|
print "<p>" . __("The following comics are currently supported:") . "</p>";
|
2014-01-09 10:08:39 +00:00
|
|
|
|
2014-02-17 09:00:25 +00:00
|
|
|
$comics = array();
|
2014-01-09 10:08:39 +00:00
|
|
|
|
2014-02-17 09:00:25 +00:00
|
|
|
foreach ($this->filters as $f) {
|
|
|
|
foreach ($f->supported() as $comic) {
|
|
|
|
array_push($comics, $comic);
|
2014-01-09 10:08:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-17 09:00:25 +00:00
|
|
|
asort($comics);
|
2014-02-14 12:44:39 +00:00
|
|
|
|
2014-02-17 09:00:25 +00:00
|
|
|
print "<ul class=\"browseFeedList\" style=\"border-width : 1px\">";
|
|
|
|
foreach ($comics as $comic) {
|
|
|
|
print "<li>$comic</li>";
|
2014-01-09 10:08:39 +00:00
|
|
|
}
|
2014-02-17 09:00:25 +00:00
|
|
|
print "</ul>";
|
2014-01-09 10:08:39 +00:00
|
|
|
|
2014-02-17 09:00:25 +00:00
|
|
|
print "</div>";
|
|
|
|
}
|
2014-01-09 10:08:39 +00:00
|
|
|
|
2014-02-17 09:00:25 +00:00
|
|
|
function hook_article_filter($article) {
|
|
|
|
$owner_uid = $article["owner_uid"];
|
2014-01-09 10:08:39 +00:00
|
|
|
|
2014-02-17 09:00:25 +00:00
|
|
|
foreach ($this->filters as $f) {
|
|
|
|
if ($f->process($article))
|
|
|
|
break;
|
2014-01-09 10:08:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return $article;
|
2014-02-17 09:00:25 +00:00
|
|
|
|
2014-01-09 10:08:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function api_version() {
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
?>
|