$search_mode = $method;
}
// error_log("search_mode: " . $search_mode);
- $qfh_ret = queryFeedHeadlines($this->link, $feed, $limit, $view_mode, $cat_view,
- $search, $search_mode, $override_order, $offset, 0,
- false, 0, $include_children);
+
+ if (!$cat_view && is_numeric($feed) && $feed < PLUGIN_FEED_BASE_INDEX) {
+ global $pluginhost;
+
+ $handler = $pluginhost->get_feed_handler(
+ PluginHost::feed_to_pfeed_id($feed));
+
+ // function queryFeedHeadlines($link, $feed, $limit, $view_mode, $cat_view, $search, $search_mode, $override_order = false, $offset = 0, $owner_uid = 0, $filter = false, $since_id = 0, $include_children = false, $ignore_vfeed_group = false) {
+
+ if ($handler) {
+ $options = array(
+ "limit" => $limit,
+ "view_mode" => $view_mode,
+ "cat_view" => $cat_view,
+ "search" => $search,
+ "search_mode" => $search_mode,
+ "override_order" => $override_order,
+ "offset" => $offset,
+ "owner_uid" => $_SESSION["uid"],
+ "filter" => false,
+ "since_id" => 0,
+ "include_children" => $include_children);
+
+ $qfh_ret = $handler->get_headlines(PluginHost::feed_to_pfeed_id($feed),
+ $options);
+ }
+
+ } else {
+ $qfh_ret = queryFeedHeadlines($this->link, $feed, $limit, $view_mode, $cat_view,
+ $search, $search_mode, $override_order, $offset, 0,
+ false, 0, $include_children);
+ }
if ($_REQUEST["debug"]) $timing_info = print_checkpoint("H1", $timing_info);
private $handlers = array();
private $commands = array();
private $storage = array();
+ private $feeds = array();
private $owner_uid;
private $debug;
function get_debug() {
return $this->debug;
}
+
+ // Plugin feed functions are *EXPERIMENTAL*!
+
+ // cat_id: only -1 is supported (Special)
+ function add_feed($cat_id, $title, $icon, $sender) {
+ if (!$this->feeds[$cat_id]) $this->feeds[$cat_id] = array();
+
+ $id = count($this->feeds[$cat_id]);
+
+ array_push($this->feeds[$cat_id],
+ array('id' => $id, 'title' => $title, 'sender' => $sender, 'icon' => $icon));
+
+ return $id;
+ }
+
+ function get_feeds($cat_id) {
+ return $this->feeds[$cat_id];
+ }
+
+ // convert feed_id (e.g. -129) to pfeed_id first
+ function get_feed_handler($pfeed_id) {
+ foreach ($this->feeds as $cat) {
+ foreach ($cat as $feed) {
+ if ($feed['id'] == $pfeed_id) {
+ return $feed['sender'];
+ }
+ }
+ }
+ }
+
+ static function pfeed_to_feed_id($label) {
+ return PLUGIN_FEED_BASE_INDEX - 1 - abs($label);
+ }
+
+ static function feed_to_pfeed_id($feed) {
+ return PLUGIN_FEED_BASE_INDEX - 1 + abs($feed);
+ }
+
}
?>
array_push($cat['items'], $this->feedlist_init_feed($i));
}
+ /* Plugin feeds for -1 */
+
+ global $pluginhost;
+
+ $feeds = $pluginhost->get_feeds(-1);
+
+ if ($feeds) {
+ foreach ($feeds as $feed) {
+ $feed_id = PluginHost::pfeed_to_feed_id($feed['id']);
+
+ $item = array();
+ $item['id'] = 'FEED:' . $feed_id;
+ $item['bare_id'] = (int)$feed_id;
+ $item['name'] = $feed['title'];
+ $item['checkbox'] = false;
+ $item['error'] = '';
+ $item['icon'] = $feed['icon'];
+
+ $item['param'] = '';
+ $item['unread'] = 0; //$feed['sender']->get_unread($feed['id']);
+ $item['type'] = 'feed';
+
+ array_push($cat['items'], $item);
+ }
+ }
+
if ($enable_cats) {
array_push($root['items'], $cat);
} else {
define('SCHEMA_VERSION', 109);
define('LABEL_BASE_INDEX', -1024);
+ define('PLUGIN_FEED_BASE_INDEX', -128);
$fetch_last_error = false;
$pluginhost = false;
array_push($ret_arr, $cv);
}
+ global $pluginhost;
+
+ if ($pluginhost) {
+ $feeds = $pluginhost->get_feeds(-1);
+
+ foreach ($feeds as $feed) {
+ $cv = array("id" => PluginHost::pfeed_to_feed_id($feed['id']),
+ "counter" => $feed['sender']->get_unread($feed['id']));
+
+ array_push($ret_arr, $cv);
+ }
+
+ }
+
return $ret_arr;
}
--- /dev/null
+<?php
+class Example_VFeed extends Plugin {
+
+ // Demonstrates how to create a dummy special feed and chain
+ // headline generation to queryFeedHeadlines();
+
+ // Not implemented yet: stuff for 3 panel mode
+
+ private $link;
+ private $host;
+ private $dummy_id;
+
+ function about() {
+ return array(1.0,
+ "Example vfeed plugin",
+ "fox",
+ false);
+ }
+
+ function init($host) {
+ $this->link = $host->get_link();
+ $this->host = $host;
+
+ $this->dummy_id = $host->add_feed(-1, 'Dummy feed', 'images/pub_set.svg', $this);
+ }
+
+ function get_unread($feed_id) {
+ return 1234;
+ }
+
+ function get_headlines($feed_id, $options) {
+ $qfh_ret = queryFeedHeadlines($this->link, -4,
+ $options['limit'],
+ $options['view_mode'], $options['cat_view'],
+ $options['search'],
+ $options['search_mode'],
+ $options['override_order'],
+ $options['offset'],
+ $options['owner_uid'],
+ $options['filter'],
+ $options['since_id'],
+ $options['include_children']);
+
+ $qfh_ret[1] = 'Dummy feed';
+
+ return $qfh_ret;
+ }
+}
+?>