From 9d393c84da965ebdcdaba26491ad0649c273af18 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 29 Aug 2008 09:01:53 +0100 Subject: [PATCH] add action to reset category order --- backend.php | 25 +++++++++++++++++++++++++ feedlist.js | 30 +++++++++++++++++++++++++++++- functions.php | 4 ++-- localized_js.php | 2 +- tt-rss.js | 15 +++++++++++++++ tt-rss.php | 1 + 6 files changed, 73 insertions(+), 4 deletions(-) diff --git a/backend.php b/backend.php index 350511f28..116b04b54 100644 --- a/backend.php +++ b/backend.php @@ -180,6 +180,31 @@ $_SESSION["uid"]); return; break; + + case "catsortreset": + db_query($link, "UPDATE ttrss_feed_categories + SET order_id = 0 WHERE owner_uid = " . $_SESSION["uid"]); + return; + break; + + case "catsort": + $corder = db_escape_string($_GET["corder"]); + + $cats = split(",", $corder); + + for ($i = 0; $i < count($cats); $i++) { + $cat_id = $cats[$i]; + + if ($cat_id > 0) { + db_query($link, "UPDATE ttrss_feed_categories + SET order_id = '$i' WHERE id = '$cat_id' AND + owner_uid = " . $_SESSION["uid"]); + } + } + + return; + break; + } outputFeedList($link, $tags); diff --git a/feedlist.js b/feedlist.js index 1f1481043..7620dab52 100644 --- a/feedlist.js +++ b/feedlist.js @@ -316,6 +316,34 @@ function toggleCollapseCat(cat) { } } +function feedlist_dragsorted(ctr) { + try { + var elem = document.getElementById("feedList"); + + var cats = elem.getElementsByTagName("LI"); + var ordered_cats = new Array(); + + for (var i = 0; i < cats.length; i++) { + if (cats[i].id && cats[i].id.match("FCAT-")) { + ordered_cats.push(cats[i].id.replace("FCAT-", "")); + } + } + + if (ordered_cats.length > 0) { + + var query = "backend.php?op=feeds&subop=catsort&corder=" + + param_escape(ordered_cats.toString()); + + debug(query); + + new Ajax.Request(query); + } + + } catch (e) { + exception_error("feedlist_init", e); + } +} + function feedlist_init() { try { // if (arguments.callee.done) return; @@ -354,7 +382,7 @@ function feedlist_init() { init_collapsable_feedlist(getInitParam("theme")); - Sortable.create('feedList'); + Sortable.create('feedList', {onChange: feedlist_dragsorted}); } catch (e) { exception_error("feedlist/init", e); diff --git a/functions.php b/functions.php index 240194731..f097e1910 100644 --- a/functions.php +++ b/functions.php @@ -4234,9 +4234,9 @@ if (get_pref($link, 'ENABLE_FEED_CATS')) { if (get_pref($link, "FEEDS_SORT_BY_UNREAD")) { - $order_by_qpart = "category,unread DESC,title"; + $order_by_qpart = "order_id,category,unread DESC,title"; } else { - $order_by_qpart = "category,title"; + $order_by_qpart = "order_id,category,title"; } } else { if (get_pref($link, "FEEDS_SORT_BY_UNREAD")) { diff --git a/localized_js.php b/localized_js.php index 5f2a2ea60..c97f9d107 100644 --- a/localized_js.php +++ b/localized_js.php @@ -138,7 +138,7 @@ print T_js_decl("Rescoring feeds..."); print T_js_decl("You can't rescore this kind of feed."); print T_js_decl("Rescore articles in %s?"); print T_js_decl("Rescoring articles..."); -#print T_js_decl( +print T_js_decl("Reset category order?"); #print T_js_decl( #print T_js_decl( #print T_js_decl( diff --git a/tt-rss.js b/tt-rss.js index 495b48881..2bbe782cb 100644 --- a/tt-rss.js +++ b/tt-rss.js @@ -601,6 +601,21 @@ function quickMenuGo(opid) { resize_headlines(); } + if (opid == "qmcResetCats") { + + if (confirm(__("Reset category order?"))) { + + var query = "backend.php?op=feeds&subop=catsortreset"; + + notify_progress("Loading, please wait...", true); + + new Ajax.Request(query, { + onComplete: function(transport) { + window.setTimeout('updateFeedList(false, false)', 50); + } }); + } + } + } catch (e) { exception_error("quickMenuGo", e); } diff --git a/tt-rss.php b/tt-rss.php index 38e0ac59c..dd6edef99 100644 --- a/tt-rss.php +++ b/tt-rss.php @@ -157,6 +157,7 @@ window.onload = init; +