mirror of
https://git.tt-rss.org/git/tt-rss.git
synced 2025-12-13 11:55:56 +00:00
sorta-kinda fix the feedlist
This commit is contained in:
@@ -7,49 +7,6 @@ class Feeds extends Protected_Handler {
|
||||
return array_search($method, $csrf_ignored) !== false;
|
||||
}
|
||||
|
||||
private function feedlist_init_cat($cat_id, $hidden = false) {
|
||||
$obj = array();
|
||||
$cat_id = (int) $cat_id;
|
||||
|
||||
if ($cat_id > 0) {
|
||||
$cat_unread = ccache_find($this->link, $cat_id, $_SESSION["uid"], true);
|
||||
} else if ($cat_id == 0 || $cat_id == -2) {
|
||||
$cat_unread = getCategoryUnread($this->link, $cat_id);
|
||||
}
|
||||
|
||||
$obj['id'] = 'CAT:' . $cat_id;
|
||||
$obj['items'] = array();
|
||||
$obj['name'] = getCategoryTitle($this->link, $cat_id);
|
||||
$obj['type'] = 'feed';
|
||||
$obj['unread'] = (int) $cat_unread;
|
||||
$obj['hidden'] = $hidden;
|
||||
$obj['bare_id'] = $cat_id;
|
||||
|
||||
return $obj;
|
||||
}
|
||||
|
||||
private function feedlist_init_feed($feed_id, $title = false, $unread = false, $error = '', $updated = '') {
|
||||
$obj = array();
|
||||
$feed_id = (int) $feed_id;
|
||||
|
||||
if (!$title)
|
||||
$title = getFeedTitle($this->link, $feed_id, false);
|
||||
|
||||
if ($unread === false)
|
||||
$unread = getFeedUnread($this->link, $feed_id, false);
|
||||
|
||||
$obj['id'] = 'FEED:' . $feed_id;
|
||||
$obj['name'] = $title;
|
||||
$obj['unread'] = (int) $unread;
|
||||
$obj['type'] = 'feed';
|
||||
$obj['error'] = $error;
|
||||
$obj['updated'] = $updated;
|
||||
$obj['icon'] = getFeedIcon($feed_id);
|
||||
$obj['bare_id'] = $feed_id;
|
||||
|
||||
return $obj;
|
||||
}
|
||||
|
||||
private function format_headline_subtoolbar($feed_site_url, $feed_title,
|
||||
$feed_id, $is_cat, $search, $match_on,
|
||||
$search_mode, $view_mode, $error) {
|
||||
@@ -776,289 +733,6 @@ class Feeds extends Protected_Handler {
|
||||
$vgroup_last_feed, $reply);
|
||||
}
|
||||
|
||||
private function outputFeedList($special = true) {
|
||||
|
||||
$feedlist = array();
|
||||
|
||||
$enable_cats = get_pref($this->link, 'ENABLE_FEED_CATS');
|
||||
|
||||
$feedlist['identifier'] = 'id';
|
||||
$feedlist['label'] = 'name';
|
||||
$feedlist['items'] = array();
|
||||
|
||||
$owner_uid = $_SESSION["uid"];
|
||||
|
||||
/* virtual feeds */
|
||||
|
||||
if ($special) {
|
||||
|
||||
if ($enable_cats) {
|
||||
$cat_hidden = get_pref($this->link, "_COLLAPSED_SPECIAL");
|
||||
$cat = $this->feedlist_init_cat(-1, $cat_hidden);
|
||||
} else {
|
||||
$cat['items'] = array();
|
||||
}
|
||||
|
||||
foreach (array(-4, -3, -1, -2, 0) as $i) {
|
||||
array_push($cat['items'], $this->feedlist_init_feed($i));
|
||||
}
|
||||
|
||||
if ($enable_cats) {
|
||||
array_push($feedlist['items'], $cat);
|
||||
} else {
|
||||
$feedlist['items'] = array_merge($feedlist['items'], $cat['items']);
|
||||
}
|
||||
|
||||
$result = db_query($this->link, "SELECT * FROM
|
||||
ttrss_labels2 WHERE owner_uid = '$owner_uid' ORDER by caption");
|
||||
|
||||
if (db_num_rows($result) > 0) {
|
||||
|
||||
if (get_pref($this->link, 'ENABLE_FEED_CATS')) {
|
||||
$cat_hidden = get_pref($this->link, "_COLLAPSED_LABELS");
|
||||
$cat = $this->feedlist_init_cat(-2, $cat_hidden);
|
||||
} else {
|
||||
$cat['items'] = array();
|
||||
}
|
||||
|
||||
while ($line = db_fetch_assoc($result)) {
|
||||
|
||||
$label_id = -$line['id'] - 11;
|
||||
$count = getFeedUnread($this->link, $label_id);
|
||||
|
||||
$feed = $this->feedlist_init_feed($label_id, false, $count);
|
||||
|
||||
$feed['fg_color'] = $line['fg_color'];
|
||||
$feed['bg_color'] = $line['bg_color'];
|
||||
|
||||
array_push($cat['items'], $feed);
|
||||
}
|
||||
|
||||
if ($enable_cats) {
|
||||
array_push($feedlist['items'], $cat);
|
||||
} else {
|
||||
$feedlist['items'] = array_merge($feedlist['items'], $cat['items']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->feedlist_process_category('root', &$feedlist);
|
||||
|
||||
/* if (get_pref($this->link, 'ENABLE_FEED_CATS')) {
|
||||
if (get_pref($this->link, "FEEDS_SORT_BY_UNREAD")) {
|
||||
$order_by_qpart = "order_id,category,unread DESC,title";
|
||||
} else {
|
||||
$order_by_qpart = "order_id,category,title";
|
||||
}
|
||||
} else {
|
||||
if (get_pref($this->link, "FEEDS_SORT_BY_UNREAD")) {
|
||||
$order_by_qpart = "unread DESC,title";
|
||||
} else {
|
||||
$order_by_qpart = "title";
|
||||
}
|
||||
} */
|
||||
|
||||
/* real feeds */
|
||||
|
||||
/* if ($enable_cats)
|
||||
$order_by_qpart = "ttrss_feed_categories.order_id,category,
|
||||
ttrss_feeds.order_id,title";
|
||||
else
|
||||
$order_by_qpart = "title";
|
||||
|
||||
$query = "SELECT ttrss_feeds.id, ttrss_feeds.title,
|
||||
".SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated_noms,
|
||||
cat_id,last_error,
|
||||
COALESCE(ttrss_feed_categories.title, '".__('Uncategorized')."') AS category,
|
||||
ttrss_feed_categories.collapsed,
|
||||
value AS unread
|
||||
FROM ttrss_feeds LEFT JOIN ttrss_feed_categories
|
||||
ON (ttrss_feed_categories.id = cat_id)
|
||||
LEFT JOIN ttrss_counters_cache
|
||||
ON
|
||||
(ttrss_feeds.id = feed_id)
|
||||
WHERE
|
||||
ttrss_feeds.owner_uid = '$owner_uid' AND parent_cat IS NULL
|
||||
ORDER BY $order_by_qpart";
|
||||
|
||||
$result = db_query($this->link, $query);
|
||||
|
||||
$actid = $_REQUEST["actid"];
|
||||
|
||||
if (db_num_rows($result) > 0) {
|
||||
|
||||
$category = "";
|
||||
|
||||
if (!$enable_cats)
|
||||
$cat['items'] = array();
|
||||
else
|
||||
$cat = false;
|
||||
|
||||
while ($line = db_fetch_assoc($result)) {
|
||||
|
||||
$feed = htmlspecialchars(trim($line["title"]));
|
||||
|
||||
if (!$feed) $feed = "[Untitled]";
|
||||
|
||||
$feed_id = $line["id"];
|
||||
$unread = $line["unread"];
|
||||
|
||||
$cat_id = $line["cat_id"];
|
||||
$tmp_category = $line["category"];
|
||||
|
||||
if ($category != $tmp_category && $enable_cats) {
|
||||
|
||||
$category = $tmp_category;
|
||||
|
||||
$collapsed = sql_bool_to_bool($line["collapsed"]);
|
||||
|
||||
// workaround for NULL category
|
||||
if ($category == __("Uncategorized")) {
|
||||
$collapsed = get_pref($this->link, "_COLLAPSED_UNCAT");
|
||||
}
|
||||
|
||||
if ($cat) array_push($feedlist['items'], $cat);
|
||||
|
||||
$cat = $this->feedlist_init_cat($cat_id, $collapsed);
|
||||
}
|
||||
|
||||
$updated = make_local_datetime($this->link, $line["updated_noms"], false);
|
||||
|
||||
array_push($cat['items'], $this->feedlist_init_feed($feed_id,
|
||||
$feed, $unread, $line['last_error'], $updated));
|
||||
}
|
||||
|
||||
if ($enable_cats) {
|
||||
array_push($feedlist['items'], $cat);
|
||||
} else {
|
||||
$feedlist['items'] = array_merge($feedlist['items'], $cat['items']);
|
||||
}
|
||||
|
||||
} */
|
||||
|
||||
return $feedlist;
|
||||
}
|
||||
|
||||
private function feedlist_process_category($cat_id, &$feedlist) {
|
||||
$owner_uid = $_SESSION['uid'];
|
||||
$enable_cats = get_pref($this->link, 'ENABLE_FEED_CATS');
|
||||
|
||||
if (get_pref($this->link, 'ENABLE_FEED_CATS')) {
|
||||
if (get_pref($this->link, "FEEDS_SORT_BY_UNREAD")) {
|
||||
$order_by_qpart = "order_id,category,unread DESC,title";
|
||||
} else {
|
||||
$order_by_qpart = "order_id,category,title";
|
||||
}
|
||||
} else {
|
||||
if (get_pref($this->link, "FEEDS_SORT_BY_UNREAD")) {
|
||||
$order_by_qpart = "unread DESC,title";
|
||||
} else {
|
||||
$order_by_qpart = "title";
|
||||
}
|
||||
}
|
||||
|
||||
if ($enable_cats)
|
||||
$order_by_qpart = "ttrss_feed_categories.order_id,category,
|
||||
ttrss_feeds.order_id,title";
|
||||
else
|
||||
$order_by_qpart = "title";
|
||||
|
||||
/* real feeds */
|
||||
|
||||
if ($enable_cats)
|
||||
$order_by_qpart = "ttrss_feed_categories.order_id,category,
|
||||
ttrss_feeds.order_id,title";
|
||||
else
|
||||
$order_by_qpart = "title";
|
||||
|
||||
if (!$enable_cats) {
|
||||
$parent_qpart = "true";
|
||||
} else if ($cat_id == 'root') {
|
||||
$parent_qpart = 'parent_cat IS NULL';
|
||||
} else {
|
||||
$parent_qpart = 'parent_cat = '.db_escape_string($cat_id);
|
||||
}
|
||||
|
||||
$query = "SELECT ttrss_feeds.id, ttrss_feeds.title,
|
||||
".SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated_noms,
|
||||
cat_id,last_error,
|
||||
COALESCE(ttrss_feed_categories.title, '".__('Uncategorized')."') AS category,
|
||||
ttrss_feed_categories.collapsed,
|
||||
value AS unread
|
||||
FROM ttrss_feeds LEFT JOIN ttrss_feed_categories
|
||||
ON (ttrss_feed_categories.id = cat_id)
|
||||
LEFT JOIN ttrss_counters_cache
|
||||
ON
|
||||
(ttrss_feeds.id = feed_id)
|
||||
WHERE
|
||||
ttrss_feeds.owner_uid = '$owner_uid' AND $parent_qpart
|
||||
ORDER BY $order_by_qpart";
|
||||
|
||||
$result = db_query($this->link, $query);
|
||||
|
||||
$actid = $_REQUEST["actid"];
|
||||
|
||||
if (db_num_rows($result) > 0) {
|
||||
|
||||
$category = "";
|
||||
|
||||
if (!$enable_cats)
|
||||
$cat['items'] = array();
|
||||
else
|
||||
$cat = false;
|
||||
|
||||
while ($line = db_fetch_assoc($result)) {
|
||||
|
||||
$feed = htmlspecialchars(trim($line["title"]));
|
||||
|
||||
if (!$feed) $feed = "[Untitled]";
|
||||
|
||||
$feed_id = $line["id"];
|
||||
$unread = $line["unread"];
|
||||
|
||||
$cat_id = $line["cat_id"];
|
||||
$tmp_category = $line["category"];
|
||||
|
||||
if ($category != $tmp_category && $enable_cats) {
|
||||
|
||||
$category = $tmp_category;
|
||||
|
||||
$collapsed = sql_bool_to_bool($line["collapsed"]);
|
||||
|
||||
// workaround for NULL category
|
||||
if ($category == __("Uncategorized")) {
|
||||
$collapsed = get_pref($this->link, "_COLLAPSED_UNCAT");
|
||||
}
|
||||
|
||||
if ($cat) array_push($feedlist['items'], $cat);
|
||||
|
||||
$cat = $this->feedlist_init_cat($cat_id, $collapsed);
|
||||
|
||||
if ($cat_id) {
|
||||
$cat_items = $this->feedlist_process_category($cat_id, &$feedlist);
|
||||
if (count($cat_items) > 0) {
|
||||
array_push($cat['items'], $cat_items);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$updated = make_local_datetime($this->link, $line["updated_noms"], false);
|
||||
|
||||
array_push($cat['items'], $this->feedlist_init_feed($feed_id,
|
||||
$feed, $unread, $line['last_error'], $updated));
|
||||
}
|
||||
|
||||
if ($enable_cats) {
|
||||
array_push($feedlist['items'], $cat);
|
||||
} else {
|
||||
$feedlist['items'] = array_merge($feedlist['items'], $cat['items']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function catchupAll() {
|
||||
db_query($this->link, "UPDATE ttrss_user_entries SET
|
||||
last_read = NOW(),unread = false WHERE owner_uid = " . $_SESSION["uid"]);
|
||||
|
||||
Reference in New Issue
Block a user