diff --git a/classes/api.php b/classes/api.php index 7863a213e..2416dd7c9 100755 --- a/classes/api.php +++ b/classes/api.php @@ -544,6 +544,28 @@ class API extends Handler { /* Virtual feeds */ + $vfeeds = PluginHost::getInstance()->get_feeds(-1); + + if (is_array($vfeeds)) { + foreach ($vfeeds as $feed) { + if (!implements_interface($feed['sender'], 'IVirtualFeed')) + continue; + + $unread = $feed['sender']->get_unread($feed['id']); + + if ($unread || !$unread_only) { + $row = [ + 'id' => PluginHost::pfeed_to_feed_id($feed['id']), + 'title' => $feed['title'], + 'unread' => $unread, + 'cat_id' => -1, + ]; + + array_push($feeds, $row); + } + } + } + if ($cat_id == -4 || $cat_id == -1) { foreach ([-1, -2, -3, -4, -6, 0] as $i) { $unread = Feeds::_get_counters($i, false, true); @@ -675,7 +697,47 @@ class API extends Handler { "skip_first_id_check" => $skip_first_id_check ); - $qfh_ret = Feeds::_get_headlines($params); + if (!$is_cat && is_numeric($feed_id) && $feed_id < PLUGIN_FEED_BASE_INDEX && $feed_id > LABEL_BASE_INDEX) { + /** @var IVirtualFeed|false $handler */ + $pfeed_id = PluginHost::feed_to_pfeed_id($feed_id); + $handler = PluginHost::getInstance()->get_feed_handler($pfeed_id); + + if ($handler) { + $params = array( + "feed" => $feed_id, + "limit" => $limit, + "view_mode" => $view_mode, + "cat_view" => $is_cat, + "search" => $search, + "override_order" => $order, + "offset" => $offset, + "since_id" => 0, + "include_children" => $include_nested, + "check_first_id" => $check_first_id, + "skip_first_id_check" => $skip_first_id_check + ); + + $qfh_ret = $handler->get_headlines($pfeed_id, $params); + } + + } else { + + $params = array( + "feed" => $feed_id, + "limit" => $limit, + "view_mode" => $view_mode, + "cat_view" => $is_cat, + "search" => $search, + "override_order" => $order, + "offset" => $offset, + "since_id" => $since_id, + "include_children" => $include_nested, + "check_first_id" => $check_first_id, + "skip_first_id_check" => $skip_first_id_check + ); + + $qfh_ret = Feeds::_get_headlines($params); + } $result = $qfh_ret[0]; $feed_title = $qfh_ret[1]; diff --git a/classes/feeds.php b/classes/feeds.php index afcc97d81..3801f1511 100755 --- a/classes/feeds.php +++ b/classes/feeds.php @@ -965,6 +965,14 @@ class Feeds extends Handler_Protected { if ($is_cat) { return self::_get_cat_unread($n_feed, $owner_uid); + } else if(is_numeric($feed) && $feed < PLUGIN_FEED_BASE_INDEX && $feed > LABEL_BASE_INDEX) { // virtual Feed + $feed_id = PluginHost::feed_to_pfeed_id($feed); + $handler = PluginHost::getInstance()->get_feed_handler($feed_id); + if (implements_interface($handler, 'IVirtualFeed')) { + return $handler->get_unread($feed_id); + } else { + return 0; + } } else if ($n_feed == -6) { return 0; // tags