add HOOK_FETCH_FEED

This commit is contained in:
Andrew Dolgov 2013-05-20 15:26:53 +04:00
parent 0ad2013bd2
commit ee65bef405
2 changed files with 13 additions and 9 deletions

View File

@ -36,6 +36,7 @@ class PluginHost {
const HOOK_ARTICLE_LEFT_BUTTON = 19;
const HOOK_PREFS_EDIT_FEED = 20;
const HOOK_PREFS_SAVE_FEED = 21;
const HOOK_FETCH_FEED = 22;
const KIND_ALL = 1;
const KIND_SYSTEM = 2;

View File

@ -242,9 +242,16 @@
$cache_filename = CACHE_DIR . "/simplepie/" . sha1($fetch_url) . ".xml";
$pluginhost = new PluginHost();
$pluginhost->set_debug($debug_enabled);
$user_plugins = get_pref("_ENABLED_PLUGINS", $owner_uid);
$pluginhost->load(PLUGINS, PluginHost::KIND_ALL);
$pluginhost->load($user_plugins, PluginHost::KIND_USER, $owner_uid);
$pluginhost->load_data();
$rss = false;
$rss_hash = false;
$cache_timestamp = file_exists($cache_filename) ? filemtime($cache_filename) : 0;
$force_refetch = isset($_REQUEST["force_refetch"]);
@ -267,6 +274,10 @@
if (!$rss) {
foreach ($pluginhost->get_hooks(PluginHost::HOOK_FETCH_FEED) as $plugin) {
$feed_data = $plugin->hook_fetch_feed($feed_data, $fetch_url, $owner_uid);
}
if (!$feed_data) {
_debug("fetching [$fetch_url]...", $debug_enabled);
_debug("If-Modified-Since: ".gmdate('D, d M Y H:i:s \G\M\T', $last_article_timestamp), $debug_enabled);
@ -330,14 +341,6 @@
}
}
$pluginhost = new PluginHost();
$pluginhost->set_debug($debug_enabled);
$user_plugins = get_pref("_ENABLED_PLUGINS", $owner_uid);
$pluginhost->load(PLUGINS, PluginHost::KIND_ALL);
$pluginhost->load($user_plugins, PluginHost::KIND_USER, $owner_uid);
$pluginhost->load_data();
foreach ($pluginhost->get_hooks(PluginHost::HOOK_FEED_FETCHED) as $plugin) {
$feed_data = $plugin->hook_feed_fetched($feed_data, $fetch_url, $owner_uid);
}