From 7b4d02a8345139fe86f291b15f89b3db335e2bd1 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 9 Sep 2008 04:30:12 +0100 Subject: [PATCH] main toolbar: add dropbox to select headlines sort mode --- backend.php | 24 +++++++++++++++++++++++- functions.php | 14 ++++++++++---- sanity_check.php | 2 +- schema/ttrss_schema_mysql.sql | 4 +++- schema/ttrss_schema_pgsql.sql | 4 +++- schema/versions/mysql/42.sql | 3 +++ schema/versions/pgsql/42.sql | 3 +++ tt-rss.js | 1 + tt-rss.php | 14 ++++++++++++-- 9 files changed, 59 insertions(+), 10 deletions(-) create mode 100644 schema/versions/mysql/42.sql create mode 100644 schema/versions/pgsql/42.sql diff --git a/backend.php b/backend.php index a632fafad..d5f9741a2 100644 --- a/backend.php +++ b/backend.php @@ -271,9 +271,11 @@ $offset = db_escape_string($_GET["skip"]); $vgroup_last_feed = db_escape_string($_GET["vgrlf"]); $csync = $_GET["csync"]; + $order_by = db_escape_string($_GET["order_by"]); set_pref($link, "_DEFAULT_VIEW_MODE", $view_mode); set_pref($link, "_DEFAULT_VIEW_LIMIT", $limit); + set_pref($link, "_DEFAULT_VIEW_ORDER_BY", $order_by); if (!$cat_view && preg_match("/^[0-9][0-9]*$/", $feed)) { db_query($link, "UPDATE ttrss_feeds SET last_viewed = NOW() @@ -287,10 +289,30 @@ generate_dashboard_feed($link); } else { + + $override_order = false; + + switch ($order_by) { + case "date": + if (get_pref($link, 'REVERSE_HEADLINES', $owner_uid)) { + $override_order = "updated"; + } else { + $override_order = "updated DESC"; + } + break; + + case "title": + $override_order = "updated DESC"; + break; + + case "score": + $override_order = "score DESC"; + break; + } $ret = outputHeadlinesList($link, $feed, $subop, $view_mode, $limit, $cat_view, $next_unread_feed, $offset, - $vgroup_last_feed); + $vgroup_last_feed, $override_order); $topmost_article_ids = $ret[0]; $headlines_count = $ret[1]; diff --git a/functions.php b/functions.php index 701d3ec57..34778e375 100644 --- a/functions.php +++ b/functions.php @@ -3003,6 +3003,9 @@ print ""; + print ""; + print ""; @@ -3127,7 +3130,7 @@ $view_query_part = ""; - if ($view_mode == "adaptive") { + if ($view_mode == "adaptive" || $view_query_part == "noscores") { if ($search) { $view_query_part = " "; } else if ($feed != -1) { @@ -3262,7 +3265,9 @@ $order_by = "updated DESC"; } - $order_by = "score DESC, $order_by"; + if ($view_mode != "noscores") { + $order_by = "score DESC, $order_by"; + } if ($override_order) { $order_by = $override_order; @@ -4789,7 +4794,8 @@ } function outputHeadlinesList($link, $feed, $subop, $view_mode, $limit, $cat_view, - $next_unread_feed, $offset, $vgr_last_feed = false) { + $next_unread_feed, $offset, $vgr_last_feed = false, + $override_order = false) { $disable_cache = false; @@ -4884,7 +4890,7 @@ if ($_GET["debug"]) $timing_info = print_checkpoint("H0", $timing_info); $qfh_ret = queryFeedHeadlines($link, $feed, $limit, $view_mode, $cat_view, - $search, $search_mode, $match_on, false, $real_offset); + $search, $search_mode, $match_on, $override_order, $real_offset); if ($_GET["debug"]) $timing_info = print_checkpoint("H1", $timing_info); diff --git a/sanity_check.php b/sanity_check.php index 814a673c2..82605fd67 100644 --- a/sanity_check.php +++ b/sanity_check.php @@ -2,7 +2,7 @@ require_once "functions.php"; define('EXPECTED_CONFIG_VERSION', 17); - define('SCHEMA_VERSION', 41); + define('SCHEMA_VERSION', 42); if (!file_exists("config.php")) { print __("Fatal Error: You forgot to copy diff --git a/schema/ttrss_schema_mysql.sql b/schema/ttrss_schema_mysql.sql index 6b003439f..f8c919e55 100644 --- a/schema/ttrss_schema_mysql.sql +++ b/schema/ttrss_schema_mysql.sql @@ -210,7 +210,7 @@ create table ttrss_tags (id integer primary key auto_increment, create table ttrss_version (schema_version int not null) TYPE=InnoDB; -insert into ttrss_version values (41); +insert into ttrss_version values (42); create table ttrss_enclosures (id serial not null primary key, content_url text not null, @@ -339,6 +339,8 @@ insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) valu insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_text) values('ENABLE_FLASH_PLAYER', 1, 'true', 'Enable inline MP3 player', 3, 'Enable the Flash-based XSPF Player to play MP3-format podcast enclosures.'); +insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_DEFAULT_VIEW_ORDER_BY', 2, 'default', '', 1); + create table ttrss_user_prefs ( owner_uid integer not null, pref_name varchar(250), diff --git a/schema/ttrss_schema_pgsql.sql b/schema/ttrss_schema_pgsql.sql index 5ba024d03..8801b6957 100644 --- a/schema/ttrss_schema_pgsql.sql +++ b/schema/ttrss_schema_pgsql.sql @@ -190,7 +190,7 @@ create index ttrss_tags_owner_uid_index on ttrss_tags(owner_uid); create table ttrss_version (schema_version int not null); -insert into ttrss_version values (41); +insert into ttrss_version values (42); create table ttrss_enclosures (id serial not null primary key, content_url text not null, @@ -313,6 +313,8 @@ insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) valu insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_text) values('ENABLE_FLASH_PLAYER', 1, 'true', 'Enable inline MP3 player', 3, 'Enable the Flash-based XSPF Player to play MP3-format podcast enclosures.'); +insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_DEFAULT_VIEW_ORDER_BY', 2, 'default', '', 1); + create table ttrss_user_prefs ( owner_uid integer not null references ttrss_users(id) ON DELETE CASCADE, pref_name varchar(250) not null references ttrss_prefs(pref_name) ON DELETE CASCADE, diff --git a/schema/versions/mysql/42.sql b/schema/versions/mysql/42.sql new file mode 100644 index 000000000..3ae211d07 --- /dev/null +++ b/schema/versions/mysql/42.sql @@ -0,0 +1,3 @@ +insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_DEFAULT_VIEW_ORDER_BY', 2, 'default', '', 1); + +update ttrss_version set schema_version = 42; diff --git a/schema/versions/pgsql/42.sql b/schema/versions/pgsql/42.sql new file mode 100644 index 000000000..3ae211d07 --- /dev/null +++ b/schema/versions/pgsql/42.sql @@ -0,0 +1,3 @@ +insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_DEFAULT_VIEW_ORDER_BY', 2, 'default', '', 1); + +update ttrss_version set schema_version = 42; diff --git a/tt-rss.js b/tt-rss.js index a63ccacb5..9a5235497 100644 --- a/tt-rss.js +++ b/tt-rss.js @@ -464,6 +464,7 @@ function init_second_stage() { dropboxSelect(toolbar.view_mode, getInitParam("default_view_mode")); dropboxSelect(toolbar.limit, getInitParam("default_view_limit")); + dropboxSelect(toolbar.order_by, getInitParam("default_view_order_by")); daemon_enabled = getInitParam("daemon_enabled") == 1; daemon_refresh_only = getInitParam("daemon_refresh_only") == 1; diff --git a/tt-rss.php b/tt-rss.php index dd6edef99..6bbec6784 100644 --- a/tt-rss.php +++ b/tt-rss.php @@ -184,14 +184,24 @@ window.onload = init; - - + + + + + + 15, 30 => 30, 60 => 60, 0 => "All");