From b9a06a0e39739b1d810bbb78bc1eef05f7d095cf Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 28 Mar 2013 20:44:43 +0400 Subject: [PATCH] retire frankly ridiculous sorting by score/title/date/default keep defaul and oldest first instead of REVERSE_HEADLINES --- classes/feeds.php | 24 ++---------------------- classes/pref/prefs.php | 2 +- classes/rpc.php | 3 +-- include/functions.php | 35 +++++++++-------------------------- index.php | 4 +--- js/feedlist.js | 14 +------------- js/tt-rss.js | 18 ++++++++++++++++-- 7 files changed, 31 insertions(+), 69 deletions(-) diff --git a/classes/feeds.php b/classes/feeds.php index 1086dc49..6aca206a 100644 --- a/classes/feeds.php +++ b/classes/feeds.php @@ -869,28 +869,8 @@ class Feeds extends Handler_Protected { } switch ($order_by) { - case "date": - if (get_pref($this->link, 'REVERSE_HEADLINES', $owner_uid)) { - $override_order = "$date_sort_field, updated"; - } else { - $override_order = "$date_sort_field DESC, updated DESC"; - } - break; - - case "title": - if (get_pref($this->link, 'REVERSE_HEADLINES', $owner_uid)) { - $override_order = "title DESC, $date_sort_field, updated"; - } else { - $override_order = "title, $date_sort_field DESC, updated DESC"; - } - break; - - case "score": - if (get_pref($this->link, 'REVERSE_HEADLINES', $owner_uid)) { - $override_order = "score, $date_sort_field, updated"; - } else { - $override_order = "score DESC, $date_sort_field DESC, updated DESC"; - } + case "date_reverse": + $override_order = "$date_sort_field, updated"; break; } diff --git a/classes/pref/prefs.php b/classes/pref/prefs.php index 3226ccde..be8b9444 100644 --- a/classes/pref/prefs.php +++ b/classes/pref/prefs.php @@ -121,7 +121,7 @@ class Pref_Prefs extends Handler_Protected { global $access_level_names; - $prefs_blacklist = array("STRIP_UNSAFE_TAGS"); + $prefs_blacklist = array("STRIP_UNSAFE_TAGS", "REVERSE_HEADLINES"); /* "FEEDS_SORT_BY_UNREAD", "HIDE_READ_FEEDS", "REVERSE_HEADLINES" */ diff --git a/classes/rpc.php b/classes/rpc.php index 72028759..66bdb86b 100644 --- a/classes/rpc.php +++ b/classes/rpc.php @@ -544,9 +544,8 @@ class RPC extends Handler_Protected { function catchupFeed() { $feed_id = db_escape_string($this->link, $_REQUEST['feed_id']); $is_cat = db_escape_string($this->link, $_REQUEST['is_cat']) == "true"; - $max_id = (int) db_escape_string($this->link, $_REQUEST['max_id']); - catchup_feed($this->link, $feed_id, $is_cat, false, $max_id); + catchup_feed($this->link, $feed_id, $is_cat, false); print json_encode(array("message" => "UPDATE_COUNTERS")); } diff --git a/include/functions.php b/include/functions.php index be90b15b..4f8eb057 100644 --- a/include/functions.php +++ b/include/functions.php @@ -996,9 +996,6 @@ //if (preg_match("/^-?[0-9][0-9]*$/", $feed) != false) { - $ref_check_qpart = ($max_id && - !get_pref($link, 'REVERSE_HEADLINES')) ? "ref_id <= '$max_id'" : "true"; - if (is_numeric($feed)) { if ($cat_view) { @@ -1018,7 +1015,7 @@ db_query($link, "UPDATE ttrss_user_entries SET unread = false,last_read = NOW() WHERE feed_id IN (SELECT id FROM ttrss_feeds WHERE $cat_qpart) - AND $ref_check_qpart AND unread = true + AND unread = true AND owner_uid = $owner_uid"); } else if ($feed == -2) { @@ -1026,7 +1023,6 @@ db_query($link, "UPDATE ttrss_user_entries SET unread = false,last_read = NOW() WHERE (SELECT COUNT(*) FROM ttrss_user_labels2 WHERE article_id = ref_id) > 0 - AND $ref_check_qpart AND unread = true AND owner_uid = $owner_uid"); } @@ -1035,7 +1031,7 @@ db_query($link, "UPDATE ttrss_user_entries SET unread = false,last_read = NOW() WHERE feed_id = '$feed' - AND $ref_check_qpart AND unread = true + AND unread = true AND owner_uid = $owner_uid"); } else if ($feed < 0 && $feed > LABEL_BASE_INDEX) { // special, like starred @@ -1044,7 +1040,7 @@ db_query($link, "UPDATE ttrss_user_entries SET unread = false,last_read = NOW() WHERE marked = true - AND $ref_check_qpart AND unread = true + AND unread = true AND owner_uid = $owner_uid"); } @@ -1052,7 +1048,7 @@ db_query($link, "UPDATE ttrss_user_entries SET unread = false,last_read = NOW() WHERE published = true - AND $ref_check_qpart AND unread = true + AND unread = true AND owner_uid = $owner_uid"); } @@ -1085,7 +1081,7 @@ if ($feed == -4) { db_query($link, "UPDATE ttrss_user_entries SET unread = false,last_read = NOW() - WHERE $ref_check_qpart AND unread = true AND + WHERE unread = true AND owner_uid = $owner_uid"); } @@ -1096,7 +1092,6 @@ db_query($link, "UPDATE ttrss_user_entries, ttrss_user_labels2 SET unread = false, last_read = NOW() WHERE label_id = '$label_id' AND unread = true - AND $ref_check_qpart AND owner_uid = '$owner_uid' AND ref_id = article_id"); } @@ -1114,7 +1109,7 @@ while ($line = db_fetch_assoc($result)) { db_query($link, "UPDATE ttrss_user_entries SET unread = false, last_read = NOW() - WHERE $ref_check_qpart AND unread = true + WHERE unread = true AND int_id = " . $line["post_int_id"]); } db_query($link, "COMMIT"); @@ -2361,11 +2356,7 @@ $allow_archived = true; if (!$override_order) { - if (get_pref($link, 'REVERSE_HEADLINES', $owner_uid)) { - $override_order = "date_entered, updated"; - } else { - $override_order = "last_marked DESC, date_entered DESC, updated DESC"; - } + $override_order = "last_marked DESC, date_entered DESC, updated DESC"; } } else if ($feed == -2) { // published virtual feed OR labels category @@ -2376,11 +2367,7 @@ $allow_archived = true; if (!$override_order) { - if (get_pref($link, 'REVERSE_HEADLINES', $owner_uid)) { - $override_order = "date_entered, updated"; - } else { - $override_order = "last_published DESC, date_entered DESC, updated DESC"; - } + $override_order = "last_published DESC, date_entered DESC, updated DESC"; } } else { @@ -2434,11 +2421,7 @@ $date_sort_field = "date_entered"; } - if (get_pref($link, 'REVERSE_HEADLINES', $owner_uid)) { - $order_by = "$date_sort_field, updated"; - } else { - $order_by = "$date_sort_field DESC, updated DESC"; - } + $order_by = "$date_sort_field DESC, updated DESC"; if ($view_mode != "noscores") { $order_by = "score DESC, $order_by"; diff --git a/index.php b/index.php index 2aa4891e..963e5940 100644 --- a/index.php +++ b/index.php @@ -177,9 +177,7 @@ onchange="viewModeChanged()" dojoType="dijit.form.Select" name="order_by"> - - - + diff --git a/js/feedlist.js b/js/feedlist.js index ec3b09da..28fadc0b 100644 --- a/js/feedlist.js +++ b/js/feedlist.js @@ -413,20 +413,8 @@ function catchupFeed(feed, is_cat) { return; } - var max_id = 0; - - if (feed == getActiveFeedId() && is_cat == activeFeedIsCat()) { - $$("#headlines-frame > div[id*=RROW]").each( - function(child) { - var id = parseInt(child.id.replace("RROW-", "")); - - if (id > max_id) max_id = id; - } - ); - } - var catchup_query = "?op=rpc&method=catchupFeed&feed_id=" + - feed + "&is_cat=" + is_cat + "&max_id=" + max_id; + feed + "&is_cat=" + is_cat; console.log(catchup_query); diff --git a/js/tt-rss.js b/js/tt-rss.js index ae5815b6..d38b203c 100644 --- a/js/tt-rss.js +++ b/js/tt-rss.js @@ -854,13 +854,27 @@ function inPreferences() { function reverseHeadlineOrder() { try { - var query_str = "?op=rpc&method=togglepref&key=REVERSE_HEADLINES"; + /* var query_str = "?op=rpc&method=togglepref&key=REVERSE_HEADLINES"; new Ajax.Request("backend.php", { parameters: query_str, onComplete: function(transport) { viewCurrentFeed(); - } }); + } }); */ + + var toolbar = document.forms["main_toolbar_form"]; + var order_by = dijit.getEnclosingWidget(toolbar.order_by); + + var value = order_by.attr('value'); + + if (value == "date_reverse") + value = "default"; + else + value = "date_reverse"; + + order_by.attr('value', value); + + viewCurrentFeed(); } catch (e) { exception_error("reverseHeadlineOrder", e);