From fa7791a69bdc05d92f1e22a78e05ad9a9871ebd2 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 15 Jan 2021 08:37:52 +0300 Subject: initial --- README.md | 1 + init.php | 120 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 121 insertions(+) create mode 100644 README.md create mode 100644 init.php diff --git a/README.md b/README.md new file mode 100644 index 0000000..ec12090 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +git checkout to ``(plugins.local)/vf_search`` diff --git a/init.php b/init.php new file mode 100644 index 0000000..d457be7 --- /dev/null +++ b/init.php @@ -0,0 +1,120 @@ +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_hidden("op", "pluginhandler"); + print_hidden("method", "save"); + print_hidden("plugin", "vf_search"); + + print_notice("One line per generated feed. Use the following format for each line: feed title,search query"); + + print "
"; + print ""; + print "
"; + + print_button("submit", "Save", "class='alt-primary'"); + + print "
"; + + print "
"; + } + + function save() { + $searches = $_POST["searches"]; + + $this->host->set($this, "searches", $searches); + + echo "Data saved"; + } + + function api_version() { + return 2; + } + +} -- cgit v1.2.3