From c2726c9615edd3eeb9b484525aff34d634472047 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 6 Feb 2009 11:47:25 +0300 Subject: [PATCH] offline: store article labels --- modules/backend-rpc.php | 7 ++++ offline.js | 89 ++++++++++++++++++++++++++++++++++++----- 2 files changed, 85 insertions(+), 11 deletions(-) diff --git a/modules/backend-rpc.php b/modules/backend-rpc.php index af8a94e3..2e9915f5 100644 --- a/modules/backend-rpc.php +++ b/modules/backend-rpc.php @@ -560,6 +560,11 @@ print __("Special"); print "]]>"; + print ""; + while ($line = db_fetch_assoc($result)) { print " 0) { + for (var j = 0; j < a.labels.length; j++) { + label_local_add_article(a.id, a.labels[j][0]); + } + } + } } @@ -1014,3 +1040,44 @@ function printCategoryHeader(cat_id, hidden, can_browse) { } } +function is_local_cat_collapsed(id) { + try { + + var rs = db.execute("SELECT collapsed FROM categories WHERE id = ?", [id]); + var cat_hidden = 0; + + if (rs.isValidRow()) { + cat_hidden = rs.field(0); + } + + rs.close(); + + return cat_hidden == "1"; + + } catch (e) { + exception_error("is_local_cat_collapsed", e); + } +} + +function label_local_add_article(id, label_id) { + try { + debug("label_local_add_article " + id + " => " + label_id); + + var rs = db.execute("SELECT COUNT(id) FROM article_labels WHERE "+ + "id = ? AND label_id = ?", [id, label_id]); + var check = rs.field(0); + + if (rs.isValidRow()) { + var check = rs.field(0); + } + rs.close(); + + if (check == 0) { + db.execute("INSERT INTO article_labels (id, label_id) VALUES "+ + "(?,?)", [id, label_id]); + } + + } catch (e) { + exception_error("label_local_add_article", e); + } +} -- 2.39.5