host = $host; $searches = explode("\n", $this->host->get($this, "searches", "")); foreach ($searches as $line) { list ($caption, $query) = explode(",", $line, 2); if ($caption && $query) array_push($this->feeds, [$host->add_feed(-1, $caption, 'search', $this), $query] ); } $host->add_hook($host::HOOK_PREFS_TAB, $this); } function get_unread($feed_id) { return 0; } function get_total($feed_id) { return 0; } function get_headlines($feed_id, $options) { $search = array_reduce($this->feeds, function ($carry, $feed) use ($feed_id) { if ($feed_id == $feed[0]) return $feed[1]; else return $carry; } ); $params = array( "feed" => -4, "limit" => $options["limit"], "view_mode" => $this->get_unread(-1) > 0 ? "adaptive" : "all_articles", "override_order" => $options['override_order'], "offset" => $options["offset"], "filter" => $options["filter"], "since_id" => $options["since_id"], "include_children" => $options["include_children"], "search" => $search, "override_vfeed" => "ttrss_feeds.title AS feed_title," ); $qfh_ret = Feeds::queryFeedHeadlines($params); $qfh_ret[1] = "Search results: $search"; return $qfh_ret; } function hook_prefs_tab($args) { if ($args != "prefFeeds") return; $searches = $this->host->get($this, "searches", ""); print "
search Show searches as feeds (vf_search)\">"; print "
"; print ""; print \Controls\pluginhandler_tags($this, "save"); print_notice("One line per generated feed. Use the following format for each line: feed title,search query"); print "
"; print ""; print "
"; print \Controls\submit_tag("Save"); print "
"; print "
"; } function save() { $searches = ($_POST["searches"] ?? ""); $this->host->set($this, "searches", $searches); echo "Data saved"; } function api_version() { return 2; } }