]> git.wh0rd.org Git - tt-rss.git/commitdiff
Add 'HOOK_FEED_BASIC_INFO' to enable plugins to provide basic feed info.
authorwn_ <invalid@email.com>
Mon, 25 Sep 2017 00:37:49 +0000 (19:37 -0500)
committerwn_ <invalid@email.com>
Mon, 25 Sep 2017 00:37:49 +0000 (19:37 -0500)
It's expected the plugin will return content parsable by FeedParser, which
will act as an interface to the basic feed info.  In the case of a plugin
that also uses 'HOOK_FETCH_FEED', both might return the same content.

The hook signature was made somewhat similar to 'HOOK_FETCH_FEED'.

classes/pluginhost.php
classes/rssutils.php

index afe4da49ef6a652fa1097dacd00b7a41731c3bd1..571c30fb6c30a80a938956f87a5f85644be96d25 100644 (file)
@@ -54,6 +54,7 @@ class PluginHost {
        const HOOK_ENCLOSURE_ENTRY = 33;
        const HOOK_FORMAT_ARTICLE = 34;
        const HOOK_FORMAT_ARTICLE_CDM = 35;
+       const HOOK_FEED_BASIC_INFO = 36;
 
        const KIND_ALL = 1;
        const KIND_SYSTEM = 2;
@@ -436,4 +437,4 @@ class PluginHost {
        function get_filter_actions() {
                return $this->plugin_actions;
        }
-}
\ No newline at end of file
+}
index 460709f05170df7aec8f765e79e7a4f4ecd19c6c..a656de27325633f0c2b7026cfb69db4da9ab844d 100644 (file)
@@ -205,9 +205,11 @@ class RSSUtils {
 
                $feed = db_escape_string($feed);
 
-               $result = db_query("SELECT feed_url,auth_pass,auth_login,auth_pass_encrypted
+               $result = db_query("SELECT owner_uid,feed_url,auth_pass,auth_login,auth_pass_encrypted
                                        FROM ttrss_feeds WHERE id = '$feed'");
 
+               $owner_uid = db_fetch_result($result, 0, "owner_uid");
+
                $auth_pass_encrypted = sql_bool_to_bool(db_fetch_result($result,
                        0, "auth_pass_encrypted"));
 
@@ -221,17 +223,35 @@ class RSSUtils {
 
                $fetch_url = db_fetch_result($result, 0, "feed_url");
 
-               $feed_data = fetch_file_contents($fetch_url, false,
-                       $auth_login, $auth_pass, false,
-                       FEED_FETCH_TIMEOUT,
-                       0);
+               $feed_data = '';
+               
+               $pluginhost = new PluginHost();
+               $user_plugins = get_pref("_ENABLED_PLUGINS", $owner_uid);
 
-               global $fetch_curl_used;
+               $pluginhost->load(PLUGINS, PluginHost::KIND_ALL);
+               $pluginhost->load($user_plugins, PluginHost::KIND_USER, $owner_uid);
+               $pluginhost->load_data();
 
-               if (!$fetch_curl_used) {
-                       $tmp = @gzdecode($feed_data);
+               foreach ($pluginhost->get_hooks(PluginHost::HOOK_FEED_BASIC_INFO) as $plugin) {
+                       $feed_data = $plugin->hook_feed_basic_info($fetch_url, $owner_uid, $feed, $auth_login, $auth_pass);
+                       if ($feed_data) {
+                               break;
+                       }
+        }
 
-                       if ($tmp) $feed_data = $tmp;
+               if (!$feed_data) {
+                       $feed_data = fetch_file_contents($fetch_url, false,
+                               $auth_login, $auth_pass, false,
+                               FEED_FETCH_TIMEOUT,
+                               0);
+
+                       global $fetch_curl_used;
+
+                       if (!$fetch_curl_used) {
+                               $tmp = @gzdecode($feed_data);
+
+                               if ($tmp) $feed_data = $tmp;
+                       }
                }
 
                $feed_data = trim($feed_data);
@@ -1520,4 +1540,4 @@ class RSSUtils {
 
 
 
-}
\ No newline at end of file
+}