2012-12-26 22:16:18 +01:00
|
|
|
<?php
|
2013-04-17 16:34:18 +02:00
|
|
|
function make_feed_browser($search, $limit, $mode = 1) {
|
2012-12-24 12:58:29 +01:00
|
|
|
|
2015-05-22 05:53:14 +02:00
|
|
|
if (defined('_DISABLE_FEED_BROWSER') && _DISABLE_FEED_BROWSER) return;
|
|
|
|
|
2012-12-24 12:58:29 +01:00
|
|
|
$rv = '';
|
|
|
|
|
2017-12-01 12:56:27 +01:00
|
|
|
$pdo = Db::pdo();
|
|
|
|
|
2012-12-24 12:58:29 +01:00
|
|
|
if ($search) {
|
2017-12-01 12:56:27 +01:00
|
|
|
$search = $pdo->quote($search);
|
|
|
|
|
|
|
|
$search_qpart = "AND (UPPER(feed_url) LIKE UPPER('%$search%') OR
|
2012-12-24 12:58:29 +01:00
|
|
|
UPPER(title) LIKE UPPER('%$search%'))";
|
|
|
|
} else {
|
|
|
|
$search_qpart = "";
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($mode == 1) {
|
2017-12-01 12:56:27 +01:00
|
|
|
$sth = $pdo->prepare("SELECT feed_url, site_url, title, SUM(subscribers) AS subscribers FROM
|
2012-12-24 12:58:29 +01:00
|
|
|
(SELECT feed_url, site_url, title, subscribers FROM ttrss_feedbrowser_cache UNION ALL
|
|
|
|
SELECT feed_url, site_url, title, subscribers FROM ttrss_linked_feeds) AS qqq
|
|
|
|
WHERE
|
|
|
|
(SELECT COUNT(id) = 0 FROM ttrss_feeds AS tf
|
|
|
|
WHERE tf.feed_url = qqq.feed_url
|
2017-12-01 12:56:27 +01:00
|
|
|
AND owner_uid = ?) $search_qpart
|
2018-06-18 22:50:32 +02:00
|
|
|
GROUP BY feed_url, site_url, title ORDER BY subscribers DESC LIMIT " . (int)$limit);
|
|
|
|
$sth->execute([$_SESSION['uid']]);
|
2012-12-24 12:58:29 +01:00
|
|
|
|
|
|
|
} else if ($mode == 2) {
|
2017-12-01 12:56:27 +01:00
|
|
|
$sth = $pdo->prepare("SELECT *,
|
2012-12-24 12:58:29 +01:00
|
|
|
(SELECT COUNT(*) FROM ttrss_user_entries WHERE
|
|
|
|
orig_feed_id = ttrss_archived_feeds.id) AS articles_archived
|
|
|
|
FROM
|
|
|
|
ttrss_archived_feeds
|
|
|
|
WHERE
|
|
|
|
(SELECT COUNT(*) FROM ttrss_feeds
|
|
|
|
WHERE ttrss_feeds.feed_url = ttrss_archived_feeds.feed_url AND
|
2017-12-01 12:56:27 +01:00
|
|
|
owner_uid = :uid) = 0 AND
|
|
|
|
owner_uid = :uid $search_qpart
|
2018-06-18 22:50:32 +02:00
|
|
|
ORDER BY id DESC LIMIT " . (int)$limit);
|
2017-12-01 12:56:27 +01:00
|
|
|
|
2018-06-18 22:50:32 +02:00
|
|
|
$sth->execute([":uid" => $_SESSION['uid']]);
|
2012-12-24 12:58:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$feedctr = 0;
|
|
|
|
|
2017-12-01 12:56:27 +01:00
|
|
|
while ($line = $sth->fetch()) {
|
2012-12-24 12:58:29 +01:00
|
|
|
|
|
|
|
if ($mode == 1) {
|
|
|
|
|
|
|
|
$feed_url = htmlspecialchars($line["feed_url"]);
|
|
|
|
$site_url = htmlspecialchars($line["site_url"]);
|
|
|
|
$subscribers = $line["subscribers"];
|
|
|
|
|
|
|
|
$check_box = "<input onclick='toggleSelectListRow2(this)'
|
|
|
|
dojoType=\"dijit.form.CheckBox\"
|
|
|
|
type=\"checkbox\" \">";
|
|
|
|
|
|
|
|
$class = ($feedctr % 2) ? "even" : "odd";
|
|
|
|
|
2017-02-12 11:01:36 +01:00
|
|
|
$site_url = "<a target=\"_blank\" rel=\"noopener noreferrer\"
|
2012-12-24 12:58:29 +01:00
|
|
|
href=\"$site_url\">
|
|
|
|
<span class=\"fb_feedTitle\">".
|
|
|
|
htmlspecialchars($line["title"])."</span></a>";
|
|
|
|
|
2017-02-12 11:01:36 +01:00
|
|
|
$feed_url = "<a target=\"_blank\" rel=\"noopener noreferrer\" class=\"fb_feedUrl\"
|
2014-02-19 12:42:52 +01:00
|
|
|
href=\"$feed_url\"><img src='images/pub_set.png'
|
2012-12-24 12:58:29 +01:00
|
|
|
style='vertical-align : middle'></a>";
|
|
|
|
|
|
|
|
$rv .= "<li>$check_box $feed_url $site_url".
|
|
|
|
" <span class='subscribers'>($subscribers)</span></li>";
|
|
|
|
|
|
|
|
} else if ($mode == 2) {
|
|
|
|
$feed_url = htmlspecialchars($line["feed_url"]);
|
|
|
|
$site_url = htmlspecialchars($line["site_url"]);
|
|
|
|
|
|
|
|
$check_box = "<input onclick='toggleSelectListRow2(this)' dojoType=\"dijit.form.CheckBox\"
|
|
|
|
type=\"checkbox\">";
|
|
|
|
|
|
|
|
$class = ($feedctr % 2) ? "even" : "odd";
|
|
|
|
|
|
|
|
if ($line['articles_archived'] > 0) {
|
2017-01-22 08:18:43 +01:00
|
|
|
$archived = sprintf(_ngettext("%d archived article", "%d archived articles", (int) $line['articles_archived']), $line['articles_archived']);
|
2012-12-24 12:58:29 +01:00
|
|
|
$archived = " <span class='subscribers'>($archived)</span>";
|
|
|
|
} else {
|
|
|
|
$archived = '';
|
|
|
|
}
|
|
|
|
|
2017-02-12 11:01:36 +01:00
|
|
|
$site_url = "<a target=\"_blank\" rel=\"noopener noreferrer\"
|
2012-12-24 12:58:29 +01:00
|
|
|
href=\"$site_url\">
|
|
|
|
<span class=\"fb_feedTitle\">".
|
|
|
|
htmlspecialchars($line["title"])."</span></a>";
|
|
|
|
|
2017-02-12 11:01:36 +01:00
|
|
|
$feed_url = "<a target=\"_blank\" rel=\"noopener noreferrer\" class=\"fb_feedUrl\"
|
2014-02-19 12:42:52 +01:00
|
|
|
href=\"$feed_url\"><img src='images/pub_set.png'
|
2012-12-24 12:58:29 +01:00
|
|
|
style='vertical-align : middle'></a>";
|
|
|
|
|
|
|
|
|
|
|
|
$rv .= "<li id=\"FBROW-".$line["id"]."\">".
|
|
|
|
"$check_box $feed_url $site_url $archived</li>";
|
|
|
|
}
|
|
|
|
|
|
|
|
++$feedctr;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($feedctr == 0) {
|
|
|
|
$rv .= "<li style=\"text-align : center\"><p>".__('No feeds found.')."</p></li>";
|
|
|
|
}
|
|
|
|
|
|
|
|
return $rv;
|
|
|
|
}
|