]> git.wh0rd.org Git - tt-rss.git/commitdiff
main toolbar: add dropbox to select headlines sort mode
authorAndrew Dolgov <fox@madoka.spb.ru>
Tue, 9 Sep 2008 03:30:12 +0000 (04:30 +0100)
committerAndrew Dolgov <fox@madoka.spb.ru>
Tue, 9 Sep 2008 03:30:12 +0000 (04:30 +0100)
backend.php
functions.php
sanity_check.php
schema/ttrss_schema_mysql.sql
schema/ttrss_schema_pgsql.sql
schema/versions/mysql/42.sql [new file with mode: 0644]
schema/versions/pgsql/42.sql [new file with mode: 0644]
tt-rss.js
tt-rss.php

index a632fafad7da724d721bb0895719c2648dde45e0..d5f9741a257bb06e98e28d3525bca6da45afa77e 100644 (file)
                        $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()
                                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];
index 701d3ec57f59140aa0182a47d9e4b78915925806..34778e37508717eed582d0c1c5b6ebc698622d24 100644 (file)
                print "<param key=\"default_view_limit\" value=\"" . 
                        (int) get_pref($link, "_DEFAULT_VIEW_LIMIT") . "\"/>";
 
+               print "<param key=\"default_view_order_by\" value=\"" . 
+                       get_pref($link, "_DEFAULT_VIEW_ORDER_BY") . "\"/>";
+
                print "<param key=\"prefs_active_tab\" value=\"" . 
                        get_pref($link, "_PREFS_ACTIVE_TAB") . "\"/>";
 
 
                        $view_query_part = "";
        
-                       if ($view_mode == "adaptive") {
+                       if ($view_mode == "adaptive" || $view_query_part == "noscores") {
                                if ($search) {
                                        $view_query_part = " ";
                                } else if ($feed != -1) {
                                $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;
        }
 
        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;
 
                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);
 
index 814a673c27be8c257d7092d175914d4203dbe351..82605fd67242849da1ac5fbc59b0dea66bd5753c 100644 (file)
@@ -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 __("<b>Fatal Error</b>: You forgot to copy 
index 6b003439f8585e553151e310b95fd2aec477a151..f8c919e558badca707f238f421f0f7d858d8a636 100644 (file)
@@ -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),
index 5ba024d034dfec0416dced35339dcf46f3902b9b..8801b69573ea6da3bacaa0a0467c17f2ac1ee0cf 100644 (file)
@@ -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 (file)
index 0000000..3ae211d
--- /dev/null
@@ -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 (file)
index 0000000..3ae211d
--- /dev/null
@@ -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;
index a63ccacb59e91ddacac07d156e49dd29220b9f78..9a52354976f27bd8b91b129e4f93d1464b0e67bb 100644 (file)
--- 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;
index dd6edef996d68032c0cb08024150e3c1987aa1b6..6bbec6784b4d30d36d460ce46d76644a7b49d18c 100644 (file)
@@ -184,14 +184,24 @@ window.onload = init;
 
                <?php } ?>
 
-               <?php echo __('View:') ?>
                <select name="view_mode" onchange="viewModeChanged()">
                        <option selected value="adaptive"><?php echo __('Adaptive') ?></option>
                        <option value="all_articles"><?php echo __('All Articles') ?></option>
                        <option value="marked"><?php echo __('Starred') ?></option>
                        <option value="unread"><?php echo __('Unread') ?></option>
+                       <!-- <option value="noscores"><?php echo __('Ignore Scoring') ?></option> -->
                </select>
-               
+
+               <?php echo __('Order by:') ?>
+
+               <select name="order_by" onchange="viewModeChanged()">
+                       <option selected value="default"><?php echo __('Default') ?></option>
+                       <option value="date"><?php echo __('Date') ?></option>
+                       <option value="title"><?php echo __('Title') ?></option>
+                       <option value="score"><?php echo __('Score') ?></option>
+               </select>
+
+
                <?php echo __('Limit:') ?>
                <?php
                $limits = array(15 => 15, 30 => 30, 60 => 60, 0 => "All");