restore init params from DB in offline mode
This commit is contained in:
parent
80b1c23867
commit
3034277ab5
|
@ -576,22 +576,25 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = db_query($link,
|
$result = db_query($link,
|
||||||
"SELECT DISTINCT id,title,guid,link,
|
"SELECT DISTINCT id,title,guid,link,comments,
|
||||||
feed_id,content,updated,unread,marked FROM
|
feed_id,content,updated,unread,marked FROM
|
||||||
ttrss_user_entries,ttrss_entries
|
ttrss_user_entries,ttrss_entries
|
||||||
WHERE $unread_qpart $cid_qpart $date_qpart
|
WHERE $unread_qpart $cid_qpart $date_qpart
|
||||||
ref_id = id AND owner_uid = ".$_SESSION["uid"]."
|
ref_id = id AND owner_uid = ".$_SESSION["uid"]."
|
||||||
ORDER BY updated DESC LIMIT $limit OFFSET $skip");
|
ORDER BY updated DESC LIMIT $limit OFFSET $skip");
|
||||||
|
|
||||||
while ($line = db_fetch_assoc($result)) {
|
if (function_exists('json_encode')) {
|
||||||
print "<article><![CDATA[";
|
|
||||||
|
|
||||||
$line["marked"] = (int)sql_bool_to_bool($line["marked"]);
|
while ($line = db_fetch_assoc($result)) {
|
||||||
$line["unread"] = (int)sql_bool_to_bool($line["unread"]);
|
print "<article><![CDATA[";
|
||||||
$line["tags"] = format_tags_string(get_article_tags($link, $id), $id);
|
|
||||||
|
|
||||||
print json_encode($line);
|
$line["marked"] = (int)sql_bool_to_bool($line["marked"]);
|
||||||
print "]]></article>";
|
$line["unread"] = (int)sql_bool_to_bool($line["unread"]);
|
||||||
|
$line["tags"] = format_tags_string(get_article_tags($link, $id), $id);
|
||||||
|
|
||||||
|
print json_encode($line);
|
||||||
|
print "]]></article>";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
25
offline.js
25
offline.js
|
@ -1,4 +1,4 @@
|
||||||
var SCHEMA_VERSION = 2;
|
var SCHEMA_VERSION = 3;
|
||||||
|
|
||||||
var offline_mode = false;
|
var offline_mode = false;
|
||||||
var store = false;
|
var store = false;
|
||||||
|
@ -353,7 +353,14 @@ function init_offline() {
|
||||||
|
|
||||||
Element.hide(tb_form.update);
|
Element.hide(tb_form.update);
|
||||||
|
|
||||||
init_params["theme"] = "";
|
var rs = db.execute("SELECT key, value FROM init_params");
|
||||||
|
|
||||||
|
while (rs.isValidRow()) {
|
||||||
|
init_params[rs.field(0)] = rs.field(1);
|
||||||
|
rs.next();
|
||||||
|
}
|
||||||
|
|
||||||
|
rs.close();
|
||||||
|
|
||||||
render_offline_feedlist();
|
render_offline_feedlist();
|
||||||
remove_splash();
|
remove_splash();
|
||||||
|
@ -402,10 +409,11 @@ function offline_download_parse(stage, transport) {
|
||||||
db.execute("DELETE FROM articles WHERE id = ?", [a.id]);
|
db.execute("DELETE FROM articles WHERE id = ?", [a.id]);
|
||||||
db.execute("INSERT INTO articles "+
|
db.execute("INSERT INTO articles "+
|
||||||
"(id, feed_id, title, link, guid, updated, content, "+
|
"(id, feed_id, title, link, guid, updated, content, "+
|
||||||
"unread, marked, tags, added) "+
|
"unread, marked, tags, added, comments) "+
|
||||||
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
||||||
[a.id, a.feed_id, a.title, a.link, a.guid, a.updated,
|
[a.id, a.feed_id, a.title, a.link, a.guid, a.updated,
|
||||||
a.content, a.unread, a.marked, a.tags, ts]);
|
a.content, a.unread, a.marked, a.tags, ts,
|
||||||
|
a.comments]);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -577,14 +585,21 @@ function init_gears() {
|
||||||
version = rs.field(0);
|
version = rs.field(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rs.close();
|
||||||
|
|
||||||
if (version != SCHEMA_VERSION) {
|
if (version != SCHEMA_VERSION) {
|
||||||
|
db.execute("DROP TABLE IF EXISTS init_params");
|
||||||
db.execute("DROP TABLE IF EXISTS cache");
|
db.execute("DROP TABLE IF EXISTS cache");
|
||||||
db.execute("DROP TABLE IF EXISTS feeds");
|
db.execute("DROP TABLE IF EXISTS feeds");
|
||||||
db.execute("DROP TABLE IF EXISTS articles");
|
db.execute("DROP TABLE IF EXISTS articles");
|
||||||
|
db.execute("DROP TABLE IF EXISTS version");
|
||||||
|
db.execute("CREATE TABLE IF NOT EXISTS version (schema_version text)");
|
||||||
db.execute("INSERT INTO version (schema_version) VALUES (?)",
|
db.execute("INSERT INTO version (schema_version) VALUES (?)",
|
||||||
[SCHEMA_VERSION]);
|
[SCHEMA_VERSION]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
db.execute("CREATE TABLE IF NOT EXISTS init_params (key text, value text)");
|
||||||
|
|
||||||
db.execute("CREATE TABLE IF NOT EXISTS cache (id text, article text, param text, added text)");
|
db.execute("CREATE TABLE IF NOT EXISTS cache (id text, article text, param text, added text)");
|
||||||
db.execute("CREATE TABLE IF NOT EXISTS feeds (id integer, title text, has_icon integer)");
|
db.execute("CREATE TABLE IF NOT EXISTS feeds (id integer, title text, has_icon integer)");
|
||||||
db.execute("CREATE TABLE IF NOT EXISTS articles (id integer, feed_id integer, title text, link text, guid text, updated text, content text, tags text, unread text, marked text, added text, comments text)");
|
db.execute("CREATE TABLE IF NOT EXISTS articles (id integer, feed_id integer, title text, link text, guid text, updated text, content text, tags text, unread text, marked text, added text, comments text)");
|
||||||
|
|
|
@ -170,6 +170,13 @@ function backend_sanity_check_callback(transport) {
|
||||||
var v = param.getAttribute("value");
|
var v = param.getAttribute("value");
|
||||||
debug(k + " => " + v);
|
debug(k + " => " + v);
|
||||||
init_params[k] = v;
|
init_params[k] = v;
|
||||||
|
|
||||||
|
if (db) {
|
||||||
|
db.execute("DELETE FROM init_params WHERE key = ?", [k]);
|
||||||
|
db.execute("INSERT INTO init_params (key,value) VALUES (?, ?)",
|
||||||
|
[k, v]);
|
||||||
|
}
|
||||||
|
|
||||||
param = param.nextSibling;
|
param = param.nextSibling;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue