]> git.wh0rd.org - tt-rss.git/blame - plugins/vf_shared/init.php
php: remove trailing whitespaces
[tt-rss.git] / plugins / vf_shared / init.php
CommitLineData
a6a61a8c
AD
1<?php
2class VF_Shared extends Plugin {
3
2eda9d9b 4 /* @var PluginHost $host */
a6a61a8c
AD
5 private $host;
6
7 function about() {
8 return array(1.0,
9 "Feed for all articles actively shared by URL",
10 "fox",
11 false);
12 }
13
14 function init($host) {
15 $this->host = $host;
16
17 $host->add_feed(-1, __("Shared articles"), 'plugins/vf_shared/share.png', $this);
18 }
19
20 function api_version() {
21 return 2;
22 }
23
21ce7d9e
AD
24 /**
25 * @SuppressWarnings(PHPMD.UnusedFormalParameter)
26 */
a6a61a8c 27 function get_unread($feed_id) {
3a029230 28 $sth = $this->pdo->prepare("select count(int_id) AS count
2eda9d9b
AD
29 from ttrss_user_entries where owner_uid = ? and unread = true and uuid != ''");
30 $sth->execute([$_SESSION['uid']]);
a6a61a8c 31
2eda9d9b
AD
32 if ($row = $sth->fetch()) {
33 return $row['count'];
34 }
35
36 return 0;
a6a61a8c
AD
37 }
38
21ce7d9e
AD
39 /**
40 * @SuppressWarnings(PHPMD.UnusedFormalParameter)
41 */
a6a61a8c 42 function get_total($feed_id) {
3a029230 43 $sth = $this->pdo->prepare("select count(int_id) AS count
2eda9d9b
AD
44 from ttrss_user_entries where owner_uid = ? and uuid != ''");
45 $sth->execute([$_SESSION['uid']]);
46
47 if ($row = $sth->fetch()) {
48 return $row['count'];
49 }
a6a61a8c 50
2eda9d9b 51 return 0;
a6a61a8c
AD
52 }
53
21ce7d9e
AD
54 /**
55 * @SuppressWarnings(PHPMD.UnusedFormalParameter)
56 */
a6a61a8c 57 function get_headlines($feed_id, $options) {
f5a0fb8b
AD
58 $params = array(
59 "feed" => -4,
60 "limit" => $options["limit"],
61 "view_mode" => $this->get_unread(-1) > 0 ? "adaptive" : "all_articles",
62 "search" => $options['search'],
63 "override_order" => $options['override_order'],
64 "offset" => $options["offset"],
65 "filter" => $options["filter"],
66 "since_id" => $options["since_id"],
67 "include_children" => $options["include_children"],
68 "override_strategy" => "uuid != ''",
69 "override_vfeed" => "ttrss_feeds.title AS feed_title,"
70 );
71
aeb1abed 72 $qfh_ret = Feeds::queryFeedHeadlines($params);
a6a61a8c
AD
73 $qfh_ret[1] = __("Shared articles");
74
75 return $qfh_ret;
76 }
77
21ce7d9e 78}