]> git.wh0rd.org Git - tt-rss.git/commitdiff
add action to reset category order
authorAndrew Dolgov <fox@madoka.spb.ru>
Fri, 29 Aug 2008 08:01:53 +0000 (09:01 +0100)
committerAndrew Dolgov <fox@madoka.spb.ru>
Fri, 29 Aug 2008 08:01:53 +0000 (09:01 +0100)
backend.php
feedlist.js
functions.php
localized_js.php
tt-rss.js
tt-rss.php

index 350511f28e3f114e91d42828f2c7cea33b84751e..116b04b5435471aaa95886e23934c71242ac81a9 100644 (file)
                                                $_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);
index 1f14810431f0181b408305de91beaba0bda25840..7620dab52ddfb905e9a8b6c8e0e7f0d635b1e90d 100644 (file)
@@ -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);
index 2401947310c69c4f9f0306b858b431b52c47ca40..f097e19103d8165bf5618a737ee368b68037e257 100644 (file)
 
                        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")) {
index 5f2a2ea609a7b88a41ab82d9658db673450dca97..c97f9d107eb8333a8616bd8100cb6e7a4985e93f 100644 (file)
@@ -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(
index 495b488812a6622562ccb54222b1678f1860e42a..2bbe782cbf943d4df87de8b89682d8f7cc03f6f0 100644 (file)
--- 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);
        }
index 38e0ac59c074aad5cb98d121b1d88069d9354d75..dd6edef996d68032c0cb08024150e3c1987aa1b6 100644 (file)
@@ -157,6 +157,7 @@ window.onload = init;
                                        <option style="color : #5050aa" disabled><?php echo __('Other actions:') ?></option>                            
                                        <option value="qmcAddFilter"><?php echo __('&nbsp;&nbsp;Create filter') ?></option>
                                        <option value="qmcResetUI"><?php echo __('&nbsp;&nbsp;Reset UI layout') ?></option>
+                                       <option value="qmcResetCats"><?php echo __('&nbsp;&nbsp;Reset category order') ?></option>
 
                                        <option value="qmcHKhelp"><?php echo __('&nbsp;&nbsp;Keyboard shortcuts') ?></option>
                        </select>