summaryrefslogtreecommitdiff
path: root/classes/feeds.php
diff options
context:
space:
mode:
Diffstat (limited to 'classes/feeds.php')
-rwxr-xr-xclasses/feeds.php74
1 files changed, 45 insertions, 29 deletions
diff --git a/classes/feeds.php b/classes/feeds.php
index ba2719f48..b1b19500f 100755
--- a/classes/feeds.php
+++ b/classes/feeds.php
@@ -108,7 +108,7 @@ class Feeds extends Handler_Protected {
$this->_mark_timestamp("db query");
- $vfeed_group_enabled = get_pref("VFEED_GROUP_BY_FEED") &&
+ $vfeed_group_enabled = get_pref(Prefs::VFEED_GROUP_BY_FEED) &&
!(in_array($feed, self::NEVER_GROUP_FEEDS) && !$cat_view);
$result = $qfh_ret[0]; // this could be either a PDO query result or a -1 if first id changed
@@ -167,7 +167,7 @@ class Feeds extends Handler_Protected {
++$headlines_count;
- if (!get_pref('SHOW_CONTENT_PREVIEW')) {
+ if (!get_pref(Prefs::SHOW_CONTENT_PREVIEW)) {
$line["content_preview"] = "";
} else {
$line["content_preview"] = "— " . truncate_string(strip_tags($line["content"]), 250);
@@ -208,15 +208,19 @@ class Feeds extends Handler_Protected {
if ($label_cache) {
if ($label_cache["no-labels"] ?? false == 1)
- $labels = array();
+ $labels = [];
else
$labels = $label_cache;
}
+
+ $line["labels"] = $labels;
+ } else {
+ $line["labels"] = [];
}
- if (!is_array($labels)) $labels = Article::_get_labels($id);
+ /*if (!is_array($labels)) $labels = Article::_get_labels($id);
- $line["labels"] = Article::_get_labels($id);
+ $line["labels"] = Article::_get_labels($id);*/
if (count($topmost_article_ids) < 3) {
array_push($topmost_article_ids, $id);
@@ -262,22 +266,26 @@ class Feeds extends Handler_Protected {
$this->_mark_timestamp(" note");
- if (!get_pref("CDM_EXPANDED")) {
+ if (!get_pref(Prefs::CDM_EXPANDED)) {
$line["cdm_excerpt"] = "<span class='collapse'>
<i class='material-icons' onclick='return Article.cdmUnsetActive(event)'
title=\"" . __("Collapse article") . "\">remove_circle</i></span>";
- if (get_pref('SHOW_CONTENT_PREVIEW')) {
+ if (get_pref(Prefs::SHOW_CONTENT_PREVIEW)) {
$line["cdm_excerpt"] .= "<span class='excerpt'>" . $line["content_preview"] . "</span>";
}
}
$this->_mark_timestamp(" pre-enclosures");
- $line["enclosures"] = Article::_format_enclosures($id,
- $line["always_display_enclosures"],
- $line["content"],
- $line["hide_images"]);
+ if ($line["num_enclosures"] > 0) {
+ $line["enclosures"] = Article::_format_enclosures($id,
+ $line["always_display_enclosures"],
+ $line["content"],
+ $line["hide_images"]);
+ } else {
+ $line["enclosures"] = [ 'formatted' => '', 'entries' => [] ];
+ }
$this->_mark_timestamp(" enclosures");
@@ -292,9 +300,11 @@ class Feeds extends Handler_Protected {
if ($line["tag_cache"])
$tags = explode(",", $line["tag_cache"]);
else
- $tags = false;
+ $tags = [];
- $line["tags"] = Article::_get_tags($line["id"], false, $line["tag_cache"]);
+ $line["tags"] = $tags;
+
+ //$line["tags"] = Article::_get_tags($line["id"], false, $line["tag_cache"]);
$this->_mark_timestamp(" tags");
@@ -324,7 +334,7 @@ class Feeds extends Handler_Protected {
/* we don't need those */
foreach (["date_entered", "guid", "last_published", "last_marked", "tag_cache", "favicon_avg_color",
- "uuid", "label_cache", "yyiw"] as $k)
+ "uuid", "label_cache", "yyiw", "num_enclosures"] as $k)
unset($line[$k]);
array_push($reply['content'], $line);
@@ -413,7 +423,7 @@ class Feeds extends Handler_Protected {
$feed = $_REQUEST["feed"];
$method = $_REQUEST["m"] ?? "";
- $view_mode = $_REQUEST["view_mode"];
+ $view_mode = $_REQUEST["view_mode"] ?? "";
$limit = 30;
$cat_view = $_REQUEST["cat"] == "true";
$next_unread_feed = $_REQUEST["nuf"] ?? 0;
@@ -459,8 +469,8 @@ class Feeds extends Handler_Protected {
return;
}
- set_pref("_DEFAULT_VIEW_MODE", $view_mode);
- set_pref("_DEFAULT_VIEW_ORDER_BY", $order_by);
+ set_pref(Prefs::_DEFAULT_VIEW_MODE, $view_mode);
+ set_pref(Prefs::_DEFAULT_VIEW_ORDER_BY, $order_by);
/* bump login timestamp if needed */
if (time() - $_SESSION["last_login_update"] > 3600) {
@@ -499,7 +509,7 @@ class Feeds extends Handler_Protected {
"disable_cache" => (bool) $disable_cache];
// this is parsed by handleRpcJson() on first viewfeed() to set cdm expanded, etc
- $reply['runtime-info'] = RPC::make_runtime_info();
+ $reply['runtime-info'] = RPC::_make_runtime_info();
print json_encode($reply);
}
@@ -573,7 +583,7 @@ class Feeds extends Handler_Protected {
"show_language" => Config::get(Config::DB_TYPE) == "pgsql",
"show_syntax_help" => count(PluginHost::getInstance()->get_hooks(PluginHost::HOOK_SEARCH)) == 0,
"all_languages" => Pref_Feeds::get_ts_languages(),
- "default_language" => get_pref('DEFAULT_SEARCH_LANGUAGE')
+ "default_language" => get_pref(Prefs::DEFAULT_SEARCH_LANGUAGE)
]);
}
@@ -799,7 +809,7 @@ class Feeds extends Handler_Protected {
if ($feed == -3) {
- $intl = (int) get_pref("FRESH_ARTICLE_MAX_AGE");
+ $intl = (int) get_pref(Prefs::FRESH_ARTICLE_MAX_AGE);
if (Config::get(Config::DB_TYPE) == "pgsql") {
$match_part = "date_entered > NOW() - INTERVAL '$intl hour' ";
@@ -892,7 +902,7 @@ class Feeds extends Handler_Protected {
} else if ($n_feed == -3) {
$match_part = "unread = true AND score >= 0";
- $intl = (int) get_pref("FRESH_ARTICLE_MAX_AGE", $owner_uid);
+ $intl = (int) get_pref(Prefs::FRESH_ARTICLE_MAX_AGE, $owner_uid);
if (Config::get(Config::DB_TYPE) == "pgsql") {
$match_part .= " AND date_entered > NOW() - INTERVAL '$intl hour' ";
@@ -1478,7 +1488,7 @@ class Feeds extends Handler_Protected {
} else if ($feed == -3) { // fresh virtual feed
$query_strategy_part = "unread = true AND score >= 0";
- $intl = (int) get_pref("FRESH_ARTICLE_MAX_AGE", $owner_uid);
+ $intl = (int) get_pref(Prefs::FRESH_ARTICLE_MAX_AGE, $owner_uid);
if (Config::get(Config::DB_TYPE) == "pgsql") {
$query_strategy_part .= " AND date_entered > NOW() - INTERVAL '$intl hour' ";
@@ -1566,7 +1576,7 @@ class Feeds extends Handler_Protected {
if (is_numeric($feed)) {
// proper override_order applied above
- if ($vfeed_query_part && !$ignore_vfeed_group && get_pref('VFEED_GROUP_BY_FEED', $owner_uid)) {
+ if ($vfeed_query_part && !$ignore_vfeed_group && get_pref(Prefs::VFEED_GROUP_BY_FEED, $owner_uid)) {
if (!(in_array($feed, self::NEVER_GROUP_BY_DATE) && !$cat_view)) {
$yyiw_desc = $order_by == "date_reverse" ? "" : "desc";
@@ -1583,7 +1593,7 @@ class Feeds extends Handler_Protected {
}
if (!$allow_archived) {
- $from_qpart = "${ext_tables_part}ttrss_entries LEFT JOIN ttrss_user_entries ON (ref_id = ttrss_entries.id),ttrss_feeds";
+ $from_qpart = "${ext_tables_part}ttrss_entries LEFT JOIN ttrss_user_entries ON (ref_id = ttrss_entries.id), ttrss_feeds";
$feed_check_qpart = "ttrss_user_entries.feed_id = ttrss_feeds.id AND";
} else {
@@ -1611,6 +1621,11 @@ class Feeds extends Handler_Protected {
$distinct_qpart = "DISTINCT"; //fallback
}
+ // except for Labels category
+ if (get_pref(Prefs::HEADLINES_NO_DISTINCT) && !($feed == -2 && $cat_view)) {
+ $distinct_qpart = "";
+ }
+
if (!$search && !$skip_first_id_check) {
// if previous topmost article id changed that means our current pagination is no longer valid
$query = "SELECT
@@ -1675,7 +1690,8 @@ class Feeds extends Handler_Protected {
last_marked, last_published,
$vfeed_query_part
$content_query_part
- author,score
+ author,score,
+ (SELECT count(id) FROM ttrss_enclosures WHERE post_id = ttrss_entries.id) AS num_enclosures
FROM
$from_qpart
WHERE
@@ -1975,7 +1991,7 @@ class Feeds extends Handler_Protected {
$purge_unread = true;
$purge_interval = Config::get(Config::FORCE_ARTICLE_PURGE);
} else {
- $purge_unread = get_pref("PURGE_UNREAD_ARTICLES", $owner_uid, false);
+ $purge_unread = get_pref(Prefs::PURGE_UNREAD_ARTICLES, $owner_uid);
}
$purge_interval = (int) $purge_interval;
@@ -2038,7 +2054,7 @@ class Feeds extends Handler_Protected {
$owner_uid = $row["owner_uid"];
if ($purge_interval == 0)
- $purge_interval = get_pref('PURGE_OLD_DAYS', $owner_uid, false);
+ $purge_interval = get_pref(Prefs::PURGE_OLD_DAYS, $owner_uid);
return $purge_interval;
} else {
@@ -2058,7 +2074,7 @@ class Feeds extends Handler_Protected {
if ($search_language)
$search_language = $pdo->quote(mb_strtolower($search_language));
else
- $search_language = $pdo->quote(mb_strtolower(get_pref('DEFAULT_SEARCH_LANGUAGE', $owner_uid)));
+ $search_language = $pdo->quote(mb_strtolower(get_pref(Prefs::DEFAULT_SEARCH_LANGUAGE, $owner_uid)));
foreach ($keywords as $k) {
if (strpos($k, "-") === 0) {
@@ -2166,7 +2182,7 @@ class Feeds extends Handler_Protected {
default:
if (strpos($k, "@") === 0) {
- $user_tz_string = get_pref('USER_TIMEZONE', $_SESSION['uid']);
+ $user_tz_string = get_pref(Prefs::USER_TIMEZONE, $_SESSION['uid']);
$orig_ts = strtotime(substr($k, 1));
$k = date("Y-m-d", TimeHelper::convert_timestamp($orig_ts, $user_tz_string, 'UTC'));