]> git.wh0rd.org Git - tt-rss.git/commitdiff
add persistent storage for toolbar view options, bump schema
authorAndrew Dolgov <fox@madoka.spb.ru>
Mon, 26 Mar 2007 05:23:15 +0000 (06:23 +0100)
committerAndrew Dolgov <fox@madoka.spb.ru>
Mon, 26 Mar 2007 05:23:15 +0000 (06:23 +0100)
12 files changed:
backend.php
feedlist.js
functions.js
functions.php
modules/pref-prefs.php
prefs.js
schema/ttrss_schema_mysql.sql
schema/ttrss_schema_pgsql.sql
schema/versions/mysql/15.sql [new file with mode: 0644]
schema/versions/pgsql/15.sql [new file with mode: 0644]
tt-rss.js
update.php

index b15101fddfab52498dcf9b6935e41743daa96600..45c9780234416d78fe1264d7017c3df3af855d7c 100644 (file)
@@ -12,7 +12,7 @@
        
        error_reporting(DEFAULT_ERROR_LEVEL); */
 
-       define('SCHEMA_VERSION', 14);
+       define('SCHEMA_VERSION', 15);
 
        require_once "sanity_check.php";
        require_once "config.php";
 
                if (!$offset) $offset = 0;
 
+               set_pref($link, "_DEFAULT_VIEW_MODE", $view_mode);
+               set_pref($link, "_DEFAULT_VIEW_LIMIT", $limit);
+
                if ($subop == "undefined") $subop = "";
 
                if ($subop == "CatchupSelected") {
index ddf12f2913cc057a90970265c2e8be07e3078026..9d6be547c7e506729cb95f606ed3186967aeb929 100644 (file)
@@ -57,12 +57,6 @@ function viewfeed(feed, subop, is_cat, subop_param, skip_history, offset) {
                        toolbar_form.query.value = "";
                }
 
-               storeInitParam("toolbar_limit", 
-                       toolbar_form.limit[toolbar_form.limit.selectedIndex].value);
-
-               storeInitParam("toolbar_view_mode", 
-                       toolbar_form.view_mode[toolbar_form.view_mode.selectedIndex].value); 
-
                var query = "backend.php?op=viewfeed&feed=" + feed + "&" +
                        toolbar_query + "&subop=" + param_escape(subop);
 
index 1172a49f71541e28e351949137079e36f54411b9..608284dc40973b3ed18e2873aecf18c85437cd33 100644 (file)
@@ -1502,71 +1502,13 @@ function debug(msg) {
 }
 
 function getInitParam(key) {
-       var c = getCookie("TTIP:" + key);
-       if (c) {
-               return c;
-       } else {
-               return getMainContext().init_params[key];
-       }
+       return init_params[key];
 }
 
 function storeInitParam(key, value) {
-       try {
-               init_params[key] = value;
-               debug("storeInitParam: " + key + " => " + value + 
-                       " (" + getInitParam("cookie_lifetime") + ")");
-               if (getInitParam("cookie_lifetime") > 0) {
-                       setCookie("TTIP:" + key, value, getInitParam("cookie_lifetime"));
-               } else {
-                       setCookie("TTIP:" + key, value);
-               }
-       } catch (e) {
-               exception_error("storeInitParam", e);
-       }
+       debug("<b>storeInitParam is OBSOLETE: " + key + " => " + value + "</b>");
 }
 
-
-/*
-function storeInitParam(key, value, is_client) {
-       try {
-               if (!is_client) {
-                       if (getMainContext().init_params[key] != value) {
-                               debug("storeInitParam: " + key + " => " + value);
-                               //new Ajax.Request("backend.php?op=rpc&subop=storeParam&key=" + 
-                               //      param_escape(key) + "&value=" + param_escape(value));   
-                               var f = getMainContext().document.getElementById("backReqBox");
-                               f.src = "backend.php?op=rpc&subop=storeParam&key=" + 
-                                       param_escape(key) + "&value=" + param_escape(value);
-                       }
-               }
-               getMainContext().init_params[key] = value;
-       } catch (e) {
-               exception_error("storeInitParam", e);
-       }
-} */
-
-/*
-function storeInitParams(params, is_client) {
-       try {
-               var s = "";
-
-               for (k in params) {
-                       if (getMainContext().init_params[k] != params[k]) {
-                               s += k + "=" + params[k] + ";";
-                               getMainContext().init_params[k] = params[k];
-                       }
-               } 
-
-               debug("storeInitParams: " + s);
-       
-               if (!is_client) {
-                       new Ajax.Request("backend.php?op=rpc&subop=storeParams&str=" + s);
-               }
-       } catch (e) {
-               exception_error("storeInitParams", e);
-       }
-}*/
-
 function fatalError(code, message) {
        try {   
 
index 05ac12dd304b044a3eaeff8f98246a647ed9750e..e98f36f698b0ac512316d6090ff98dbde93aea7e 100644 (file)
 
                print "<param key=\"cookie_lifetime\" value=\"" . SESSION_COOKIE_LIFETIME . "\"/>";
 
+               print "<param key=\"default_view_mode\" value=\"" . 
+                       get_pref($link, "_DEFAULT_VIEW_MODE") . "\"/>";
+
+               print "<param key=\"default_view_limit\" value=\"" . 
+                       sprintf("%d", get_pref($link, "_DEFAULT_VIEW_LIMIT")) . "\"/>";
+
                print "</init-params>";
        }
 
index e9ebc183fef4cde07487e01517c06990e5959026..37c6c9b5f68f38c586c443998f48acb78f8c39f8 100644 (file)
                                WHERE type_id = ttrss_prefs_types.id AND 
                                        section_id = ttrss_prefs_sections.id AND
                                        ttrss_user_prefs.pref_name = ttrss_prefs.pref_name AND
+                                       short_desc != '' AND
                                        owner_uid = ".$_SESSION["uid"]."
                                ORDER BY section_id,short_desc");
 
index a6e5d084c6198d87c9de44bb2f22d34a93d0f624..c8cb35589e79e283d5a17fb448e54f124da4e335 100644 (file)
--- a/prefs.js
+++ b/prefs.js
@@ -1219,10 +1219,6 @@ function selectTab(id, noupdate, subop) {
                        }
                }
        
-               if (active_tab != id) {
-                       storeInitParam("prefs_active_tab", id);
-               }
-       
                active_tab = id;
 
        } catch (e) {
index 1097a4e19d9cdee8358ee6c40d6323385ef5ba12..0afcac5d72f5c4ea79d664d1a7b5c9ecc57384d6 100644 (file)
@@ -188,7 +188,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 (14);
+insert into ttrss_version values (15);
 
 create table ttrss_prefs_types (id integer not null primary key, 
        type_name varchar(100) not null) TYPE=InnoDB;
@@ -267,6 +267,10 @@ 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('CDM_AUTO_CATCHUP', 1, 'false', 'Mark articles as read automatically',2,
 'This option enables marking articles as read automatically in combined mode while you scroll article list.');
 
+insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_DEFAULT_VIEW_MODE', 2, 'adaptive', '', 1);
+
+insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_DEFAULT_VIEW_LIMIT', 3, '30', '', 1);
+
 create table ttrss_user_prefs (
    owner_uid integer not null,
    pref_name varchar(250),
index 24436b3afe8f6bebdf72788e423eaf09b447dbe2..4501ef1c0d7cd1585e65f5fa0e2d11b185392483 100644 (file)
@@ -172,7 +172,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 (14);
+insert into ttrss_version values (15);
 
 create table ttrss_prefs_types (id integer not null primary key, 
        type_name varchar(100) not null);
@@ -247,6 +247,10 @@ 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('CDM_AUTO_CATCHUP', 1, 'false', 'Mark articles as read automatically',2,
 'This option enables marking articles as read automatically in combined mode while you scroll article list.');
 
+insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_DEFAULT_VIEW_MODE', 2, 'adaptive', '', 1);
+
+insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_DEFAULT_VIEW_LIMIT', 3, '30', '', 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/15.sql b/schema/versions/mysql/15.sql
new file mode 100644 (file)
index 0000000..9fa183a
--- /dev/null
@@ -0,0 +1,5 @@
+insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_DEFAULT_VIEW_MODE', 2, 'adaptive', '', 1);
+
+insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_DEFAULT_VIEW_LIMIT', 3, '30', '', 1);
+
+update ttrss_version set schema_version = 15;
diff --git a/schema/versions/pgsql/15.sql b/schema/versions/pgsql/15.sql
new file mode 100644 (file)
index 0000000..9fa183a
--- /dev/null
@@ -0,0 +1,5 @@
+insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_DEFAULT_VIEW_MODE', 2, 'adaptive', '', 1);
+
+insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_DEFAULT_VIEW_LIMIT', 3, '30', '', 1);
+
+update ttrss_version set schema_version = 15;
index bc5bc8205c06f36a7c9f87dd283849f35324084c..5f913f86f5837c460553a4b1e7a4ecf5ec55cd8d 100644 (file)
--- a/tt-rss.js
+++ b/tt-rss.js
@@ -386,10 +386,10 @@ function init_second_stage() {
        
                document.onkeydown = hotkey_handler;
 
-               var tb = parent.document.forms["main_toolbar_form"];
+               var toolbar = document.forms["main_toolbar_form"];
 
-               dropboxSelect(tb.view_mode, getInitParam("toolbar_view_mode"));
-               dropboxSelect(tb.limit, getInitParam("toolbar_limit"));
+               dropboxSelect(toolbar.view_mode, getInitParam("default_view_mode"));
+               dropboxSelect(toolbar.limit, getInitParam("default_view_limit"));
 
                daemon_enabled = getInitParam("daemon_enabled") == 1;
                daemon_refresh_only = getInitParam("daemon_refresh_only") == 1;
index 3851679ac6e081ebd0624aba2120dfba7b1a2a8d..bab0543df19f52ff06bd6404231bd562a675ca4b 100644 (file)
@@ -25,7 +25,7 @@
                exit;
        }
        
-       define('SCHEMA_VERSION', 14);
+       define('SCHEMA_VERSION', 15);
 
 ?>