init.php 1.7 KB

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