]> git.wh0rd.org Git - tt-rss.git/commitdiff
offline: store labels
authorAndrew Dolgov <fox@bah.org.ru>
Fri, 6 Feb 2009 08:08:56 +0000 (11:08 +0300)
committerAndrew Dolgov <fox@bah.org.ru>
Fri, 6 Feb 2009 08:08:56 +0000 (11:08 +0300)
modules/backend-rpc.php
offline.js

index 711455de061d457d6473c678f15d4501bb3779d2..af8a94e356287932460aa3ad123f33b0c89786c7 100644 (file)
 
                                print "</feed-categories>";
 
+                               print "<labels>";
+
+                               $result = db_query($link, "SELECT * FROM
+                                       ttrss_labels2 WHERE owner_uid = ".$_SESSION["uid"]);
+
+                               while ($line = db_fetch_assoc($result)) {
+                                       print "<label
+                                               id=\"".$line["id"]."\"
+                                               fg_color=\"".$line["fg_color"]."\"
+                                               bg_color=\"".$line["bg_color"]."\"
+                                               ><![CDATA[";
+                                       print $line["caption"];
+                                       print "]]></label>";
+                               }
+
+
+                               print "</labels>";
 
                        }
 
index 7e3d260ad86a02f770f2a0312d580627d0131065..584cf8cee9b54b828320aca13f5c93a3e19d007f 100644 (file)
@@ -1,4 +1,4 @@
-var SCHEMA_VERSION = 5;
+var SCHEMA_VERSION = 6;
 
 var offline_mode = false;
 var store = false;
@@ -606,6 +606,23 @@ function offline_download_parse(stage, transport) {
                                                [id, title, collapsed]);
                                }
 
+                               var labels = transport.responseXML.getElementsByTagName("label");
+
+                               if (labels.length > 0) {
+                                       db.execute("DELETE FROM labels");
+                               }
+
+                               for (var i = 0; i < labels.length; i++) {
+                                       var id = labels[i].getAttribute("id");
+                                       var fg_color = labels[i].getAttribute("fg_color");
+                                       var bg_color = labels[i].getAttribute("bg_color");
+                                       var caption = labels[i].firstChild.nodeValue;
+
+                                       db.execute("INSERT INTO labels (id,caption,fg_color,bg_color)"+
+                                               "VALUES (?,?,?,?)",
+                                               [id, caption, fg_color, bg_color]);
+                               }
+
                                window.setTimeout("update_offline_data("+(stage+1)+")", 10*1000);
                        } else {
 
@@ -855,6 +872,8 @@ function init_gears() {
                                db.execute("DROP TABLE IF EXISTS cache");
                                db.execute("DROP TABLE IF EXISTS feeds");
                                db.execute("DROP TABLE IF EXISTS categories");
+                               db.execute("DROP TABLE IF EXISTS labels");
+                               db.execute("DROP TABLE IF EXISTS article_labels");
                                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)");
@@ -867,6 +886,8 @@ function init_gears() {
                        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, cat_id integer)");
                        db.execute("CREATE TABLE IF NOT EXISTS categories (id integer, title text, collapsed integer)");
+                       db.execute("CREATE TABLE IF NOT EXISTS labels (id integer, caption text, fg_color text, bg_color text)");
+                       db.execute("CREATE TABLE IF NOT EXISTS article_labels (id integer, label_id 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("DELETE FROM cache WHERE id LIKE 'F:%' OR id LIKE 'C:%'");