Merge branch 'bugfix/published-feed-title' into 'master'
Fix getting the title for syndicated feeds. See merge request tt-rss/tt-rss!182
This commit is contained in:
@@ -175,7 +175,7 @@ class API extends Handler {
|
||||
if ($unread || !$unread_only) {
|
||||
array_push($cats, [
|
||||
'id' => $cat_id,
|
||||
'title' => Feeds::_get_cat_title($cat_id),
|
||||
'title' => Feeds::_get_cat_title($cat_id, $_SESSION['uid']),
|
||||
'unread' => (int) $unread,
|
||||
]);
|
||||
}
|
||||
@@ -574,7 +574,7 @@ class API extends Handler {
|
||||
$unread = Feeds::_get_counters($i, false, true);
|
||||
|
||||
if ($unread || !$unread_only) {
|
||||
$title = Feeds::_get_title($i);
|
||||
$title = Feeds::_get_title($i, $_SESSION['uid']);
|
||||
|
||||
$row = [
|
||||
'id' => $i,
|
||||
|
||||
@@ -677,7 +677,7 @@ class Feeds extends Handler_Protected {
|
||||
</script>
|
||||
|
||||
<div class="container">
|
||||
<h1>Feed Debugger: <?= "$feed_id: " . $this->_get_title($feed_id) ?></h1>
|
||||
<h1>Feed Debugger: <?= "$feed_id: " . $this->_get_title($feed_id, $_SESSION['uid']) ?></h1>
|
||||
<div class="content">
|
||||
<form method="post" action="" dojoType="dijit.form.Form">
|
||||
<?= \Controls\hidden_tag("op", "Feeds") ?>
|
||||
@@ -1178,11 +1178,9 @@ class Feeds extends Handler_Protected {
|
||||
}
|
||||
}
|
||||
|
||||
static function _get_title(int|string $id, bool $cat = false): string {
|
||||
$pdo = Db::pdo();
|
||||
|
||||
static function _get_title(int|string $id, int $owner_uid, bool $cat = false): string {
|
||||
if ($cat) {
|
||||
return self::_get_cat_title($id);
|
||||
return self::_get_cat_title($id, $owner_uid);
|
||||
} else if ($id == Feeds::FEED_STARRED) {
|
||||
return __("Starred articles");
|
||||
} else if ($id == Feeds::FEED_PUBLISHED) {
|
||||
@@ -1201,7 +1199,7 @@ class Feeds extends Handler_Protected {
|
||||
|
||||
$label = ORM::for_table('ttrss_labels2')
|
||||
->select('caption')
|
||||
->where('owner_uid', $_SESSION['uid'])
|
||||
->where('owner_uid', $owner_uid)
|
||||
->find_one($label_id);
|
||||
|
||||
return $label ? $label->caption : "Unknown label ($label_id)";
|
||||
@@ -1210,7 +1208,7 @@ class Feeds extends Handler_Protected {
|
||||
|
||||
$feed = ORM::for_table('ttrss_feeds')
|
||||
->select('title')
|
||||
->where('owner_uid', $_SESSION['uid'])
|
||||
->where('owner_uid', $owner_uid)
|
||||
->find_one($id);
|
||||
|
||||
return $feed ? $feed->title : "Unknown feed ($id)";
|
||||
@@ -1345,7 +1343,7 @@ class Feeds extends Handler_Protected {
|
||||
return $row["count"] ?? 0;
|
||||
}
|
||||
|
||||
static function _get_cat_title(int $cat_id): string {
|
||||
static function _get_cat_title(int $cat_id, int $owner_uid): string {
|
||||
switch ($cat_id) {
|
||||
case Feeds::CATEGORY_UNCATEGORIZED:
|
||||
return __("Uncategorized");
|
||||
@@ -1355,7 +1353,7 @@ class Feeds extends Handler_Protected {
|
||||
return __("Labels");
|
||||
default:
|
||||
$cat = ORM::for_table('ttrss_feed_categories')
|
||||
->where('owner_uid', $_SESSION['uid'])
|
||||
->where('owner_uid', $owner_uid)
|
||||
->find_one($cat_id);
|
||||
|
||||
if ($cat) {
|
||||
@@ -1627,7 +1625,7 @@ class Feeds extends Handler_Protected {
|
||||
$feed_title = T_sprintf("Search results: %s", $search);
|
||||
} else {
|
||||
if ($cat_view) {
|
||||
$feed_title = self::_get_cat_title($feed);
|
||||
$feed_title = self::_get_cat_title($feed, $owner_uid);
|
||||
} else {
|
||||
if (is_numeric($feed) && $feed > 0) {
|
||||
$ssth = $pdo->prepare("SELECT title,site_url,last_error,last_updated
|
||||
@@ -1640,7 +1638,7 @@ class Feeds extends Handler_Protected {
|
||||
$last_error = $row["last_error"];
|
||||
$last_updated = $row["last_updated"];
|
||||
} else {
|
||||
$feed_title = self::_get_title($feed);
|
||||
$feed_title = self::_get_title($feed, $owner_uid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,6 +182,7 @@ class OPML extends Handler_Protected {
|
||||
if ($cat_filter && $tmp_line["cat_id"] || $tmp_line["feed_id"]) {
|
||||
$tmp_line["feed"] = Feeds::_get_title(
|
||||
$cat_filter ? $tmp_line["cat_id"] : $tmp_line["feed_id"],
|
||||
$_SESSION['uid'],
|
||||
$cat_filter);
|
||||
} else {
|
||||
$tmp_line["feed"] = "";
|
||||
@@ -193,13 +194,13 @@ class OPML extends Handler_Protected {
|
||||
if (str_starts_with($feed_id, "CAT:")) {
|
||||
$feed_id = (int)substr($feed_id, 4);
|
||||
if ($feed_id) {
|
||||
array_push($match, [Feeds::_get_cat_title($feed_id), true, false]);
|
||||
array_push($match, [Feeds::_get_cat_title($feed_id, $owner_uid), true, false]);
|
||||
} else {
|
||||
array_push($match, [0, true, true]);
|
||||
}
|
||||
} else {
|
||||
if ($feed_id) {
|
||||
array_push($match, [Feeds::_get_title((int)$feed_id), false, false]);
|
||||
array_push($match, [Feeds::_get_title((int)$feed_id, $owner_uid), false, false]);
|
||||
} else {
|
||||
array_push($match, [0, false, true]);
|
||||
}
|
||||
|
||||
@@ -1103,7 +1103,7 @@ class Pref_Feeds extends Handler_Protected {
|
||||
return [
|
||||
'id' => 'CAT:' . $cat_id,
|
||||
'items' => array(),
|
||||
'name' => Feeds::_get_cat_title($cat_id),
|
||||
'name' => Feeds::_get_cat_title($cat_id, $_SESSION['uid']),
|
||||
'type' => 'category',
|
||||
'unread' => -1, //(int) Feeds::_get_cat_unread($cat_id);
|
||||
'bare_id' => $cat_id,
|
||||
@@ -1115,7 +1115,7 @@ class Pref_Feeds extends Handler_Protected {
|
||||
*/
|
||||
private function feedlist_init_feed(int $feed_id, ?string $title = null, bool $unread = false, string $error = '', string $updated = ''): array {
|
||||
if (!$title)
|
||||
$title = Feeds::_get_title($feed_id, false);
|
||||
$title = Feeds::_get_title($feed_id, $_SESSION['uid']);
|
||||
|
||||
if ($unread === false)
|
||||
$unread = Feeds::_get_counters($feed_id, false, true);
|
||||
@@ -1284,7 +1284,7 @@ class Pref_Feeds extends Handler_Protected {
|
||||
]);
|
||||
|
||||
print json_encode([
|
||||
"title" => Feeds::_get_title($feed_id, $is_cat),
|
||||
"title" => Feeds::_get_title($feed_id, $_SESSION['uid'], $is_cat),
|
||||
"link" => $link
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -261,10 +261,10 @@ class Pref_Filters extends Handler_Protected {
|
||||
|
||||
if (str_starts_with($feed_id, "CAT:")) {
|
||||
$feed_id = (int)substr($feed_id, 4);
|
||||
array_push($feeds_fmt, Feeds::_get_cat_title($feed_id));
|
||||
array_push($feeds_fmt, Feeds::_get_cat_title($feed_id, $_SESSION['uid']));
|
||||
} else {
|
||||
if ($feed_id)
|
||||
array_push($feeds_fmt, Feeds::_get_title((int)$feed_id));
|
||||
array_push($feeds_fmt, Feeds::_get_title((int)$feed_id, $_SESSION['uid']));
|
||||
else
|
||||
array_push($feeds_fmt, __("All feeds"));
|
||||
}
|
||||
@@ -274,9 +274,9 @@ class Pref_Filters extends Handler_Protected {
|
||||
|
||||
} else {
|
||||
$where = $rule->cat_filter ?
|
||||
Feeds::_get_cat_title($rule->cat_id ?? 0) :
|
||||
Feeds::_get_cat_title($rule->cat_id ?? 0, $_SESSION['uid']) :
|
||||
($rule->feed_id ?
|
||||
Feeds::_get_title($rule->feed_id) : __("All feeds"));
|
||||
Feeds::_get_title($rule->feed_id, $_SESSION['uid']) : __("All feeds"));
|
||||
}
|
||||
|
||||
$inverse_class = $rule->inverse ? "inverse" : "";
|
||||
@@ -460,10 +460,10 @@ class Pref_Filters extends Handler_Protected {
|
||||
|
||||
if (str_starts_with($feed_id, "CAT:")) {
|
||||
$feed_id = (int)substr($feed_id, 4);
|
||||
array_push($feeds_fmt, Feeds::_get_cat_title($feed_id));
|
||||
array_push($feeds_fmt, Feeds::_get_cat_title($feed_id, $_SESSION['uid']));
|
||||
} else {
|
||||
if ($feed_id)
|
||||
array_push($feeds_fmt, Feeds::_get_title((int)$feed_id));
|
||||
array_push($feeds_fmt, Feeds::_get_title((int)$feed_id, $_SESSION['uid']));
|
||||
else
|
||||
array_push($feeds_fmt, __("All feeds"));
|
||||
}
|
||||
|
||||
@@ -210,7 +210,7 @@ class Af_Psql_Trgm extends Plugin {
|
||||
<li>
|
||||
<i class='material-icons'>rss_feed</i>
|
||||
<a href='#' onclick="CommonDialogs.editFeed(<?= $f ?>)">
|
||||
<?= Feeds::_get_title($f) ?>
|
||||
<?= Feeds::_get_title($f, $_SESSION['uid']) ?>
|
||||
</a>
|
||||
</li>
|
||||
<?php } ?>
|
||||
|
||||
Reference in New Issue
Block a user