]> git.wh0rd.org - tt-rss.git/blobdiff - plugins/af_comics/init.php
Updated af_comics GoComics handling to support comics with numbers and use the main...
[tt-rss.git] / plugins / af_comics / init.php
index 31994176e748ecbf2720476f440963f165037d15..54054399ef63271af6a76c2466b1f80daa64f882 100644 (file)
@@ -19,23 +19,31 @@ class Af_Comics extends Plugin {
 
                require_once __DIR__ . "/filter_base.php";
 
-               $filters = glob(__DIR__ . "/filters/*.php");
+               $filters = array_merge(glob(__DIR__ . "/filters.local/*.php"), glob(__DIR__ . "/filters/*.php"));
+               $names = [];
 
                foreach ($filters as $file) {
-                       require_once $file;
                        $filter_name = preg_replace("/\..*$/", "", basename($file));
 
-                       $filter = new $filter_name();
+                       if (array_search($filter_name, $names) === FALSE) {
+                               if (!class_exists($filter_name)) {
+                                       require_once $file;
+                               }
+
+                               array_push($names, $filter_name);
 
-                       if (is_subclass_of($filter, "Af_ComicFilter")) {
-                               array_push($this->filters, $filter);
+                               $filter = new $filter_name();
+
+                               if (is_subclass_of($filter, "Af_ComicFilter")) {
+                                       array_push($this->filters, $filter);
+                                       array_push($names, $filter_name);
+                               }
                        }
                }
-
        }
 
        function hook_prefs_tab($args) {
-               if ($args != "prefPrefs") return;
+               if ($args != "prefFeeds") return;
 
                print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Feeds supported by af_comics')."\">";
 
@@ -57,29 +65,31 @@ class Af_Comics extends Plugin {
                }
                print "</ul>";
 
-               print "<p>".__('GoComics requires a specific URL to workaround their lack of feed support: <code>http://feeds.feedburner.com/uclick/<em>comic_name</em></code> (e.g. <code>http://www.gocomics.com/garfield</code> uses <code>http://feeds.feedburner.com/uclick/garfield</code>).')."</p>";
+               print "<p>".__("To subscribe to GoComics use the comic's regular web page as the feed URL (e.g. for the <em>Garfield</em> comic use <code>http://www.gocomics.com/garfield</code>).")."</p>";
+
+               print "<p>".__('Drop any updated filters into <code>filters.local</code> in plugin directory.')."</p>";
 
                print "</div>";
        }
 
        function hook_article_filter($article) {
-               $owner_uid = $article["owner_uid"];
-
                foreach ($this->filters as $f) {
                        if ($f->process($article))
                                break;
                }
 
                return $article;
-
        }
 
        // GoComics dropped feed support so it needs to be handled when fetching the feed.
+       /**
+        * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+        */
        function hook_fetch_feed($feed_data, $fetch_url, $owner_uid, $feed, $last_article_timestamp, $auth_login, $auth_pass) {
                if ($auth_login || $auth_pass)
                        return $feed_data;
 
-               if (preg_match('#^https?://feeds.feedburner.com/uclick/([-a-z]+)#', $fetch_url, $comic)) {
+               if (preg_match('#^https?://(?:feeds\.feedburner\.com/uclick|www\.gocomics\.com)/([-a-z0-9]+)$#i', $fetch_url, $comic)) {
                        $site_url = 'http://www.gocomics.com/' . $comic[1];
 
                        $article_link = $site_url . date('/Y/m/d');
@@ -117,7 +127,7 @@ class Af_Comics extends Plugin {
                                                $tpl->setVariable('ARTICLE_LINK', $article_link, true);
                                                $tpl->setVariable('ARTICLE_TITLE', date('l, F d, Y'), true);
                                                $tpl->setVariable('ARTICLE_EXCERPT', '', true);
-                                               $tpl->setVariable('ARTICLE_CONTENT', $doc->saveXML($node), true);
+                                               $tpl->setVariable('ARTICLE_CONTENT', $doc->saveHTML($node), true);
 
                                                $tpl->setVariable('ARTICLE_AUTHOR', '', true);
                                                $tpl->setVariable('ARTICLE_SOURCE_LINK', $site_url, true);
@@ -144,4 +154,3 @@ class Af_Comics extends Plugin {
        }
 
 }
-?>