]> git.wh0rd.org Git - tt-rss.git/commitdiff
implement category browsing
authorAndrew Dolgov <fox@bah.spb.su>
Sat, 4 Mar 2006 07:09:13 +0000 (08:09 +0100)
committerAndrew Dolgov <fox@bah.spb.su>
Sat, 4 Mar 2006 07:09:13 +0000 (08:09 +0100)
backend.php
feedlist.js

index a88e9af4a075d967cf222245d50ab4f8f2da462b..2beffdb26e669d703a4096f794497ed40836d428 100644 (file)
                                        $cat_id = sprintf("%d", $cat_id);
                                        
                                        print "<li class=\"feedCat\" id=\"FCAT-$cat_id\">
-                                               <a href=\"javascript:toggleCollapseCat($cat_id)\">$tmp_category
+                                               <a href=\"javascript:toggleCollapseCat($cat_id)\">$tmp_category</a>
+                                                       <a href=\"javascript:viewCategory($cat_id)\">
                                                        <span id=\"FCATCTR-$cat_id\" 
-                                                       class=\"$catctr_class\">($cat_unread unread)$ellipsis</span></a></li>";
+                                                       class=\"$catctr_class\">($cat_unread unread)$ellipsis</span></a>
+                                                       <!-- <div style=\"float : right\">
+                                                               <a href=\"javascript:viewCategory($cat_id)\">[view]</a>
+                                                       </div> -->
+                                               </li>";
 
                                        // !!! NO SPACE before <ul...feedCatList - breaks firstChild DOM function
                                        // -> keyboard navigation, etc.
                $subop = $_GET["subop"];
                $view_mode = $_GET["view"];
                $limit = $_GET["limit"];
+               $cat_view = $_GET["cat"];
 
                if (!$feed) {
                        return;
                                // fixme update_rss_feed...
                        } */
 
-                       $tmp_result = db_query($link, "SELECT feed_url FROM ttrss_feeds
-                               WHERE id = '$feed'");
-                       $feed_url = db_fetch_result($tmp_result, 0, "feed_url");                                
-                       update_rss_feed($link, $feed_url, $feed, ENABLE_UPDATE_DAEMON);
+                       if ($cat_view) {
+                               $tmp_result = db_query($link, "SELECT feed_url FROM ttrss_feeds
+                                       WHERE cat_id = '$feed' AND owner_uid = " . $_SESSION["uid"]);
+
+                               while ($tmp_line = db_fetch_assoc($tmp_result)) {                                       
+                                       $feed_url = $tmp_line["feed_url"];
+                                       update_rss_feed($link, $feed_url, $feed, ENABLE_UPDATE_DAEMON);
+                               }
+
+                       } else {
+                               $tmp_result = db_query($link, "SELECT feed_url FROM ttrss_feeds
+                                       WHERE id = '$feed'");
+                               $feed_url = db_fetch_result($tmp_result, 0, "feed_url");                                
+                               update_rss_feed($link, $feed_url, $feed, ENABLE_UPDATE_DAEMON);
+                       }
                }
 
                if ($subop == "MarkAllRead")  {
 
                        if (sprintf("%d", $feed) != 0) {
                        
-                               if ($feed > 0) {
+                               if ($cat_view) {
+
+                                       $tmp_result = db_query($link, "SELECT id 
+                                               FROM ttrss_feeds WHERE cat_id = '$feed' AND owner_uid = " . 
+                                               $_SESSION["uid"]);
+
+                                       while ($tmp_line = db_fetch_assoc($tmp_result)) {
+
+                                               $tmp_feed = $tmp_line["id"];
+
+                                               db_query($link, "UPDATE ttrss_user_entries 
+                                                       SET unread = false,last_read = NOW() 
+                                                       WHERE feed_id = '$tmp_feed' AND owner_uid = " . $_SESSION["uid"]);
+                                       }
+
+                               } else if ($feed > 0) {
 
                                        $tmp_result = db_query($link, "SELECT id 
                                                FROM ttrss_feeds WHERE parent_feed = '$feed'
                        } else {
                                $query_strategy_part = "ttrss_entries.id > 0";
                        }
-
+                       
                } else if ($feed >= 0) {
-               
-                       $tmp_result = db_query($link, "SELECT id 
-                               FROM ttrss_feeds WHERE parent_feed = '$feed'
-                               ORDER BY cat_id,title");
 
-                       $parent_ids = array();
-
-                       if (db_num_rows($tmp_result) > 0) {
-                               while ($p = db_fetch_assoc($tmp_result)) {
-                                       array_push($parent_ids, "feed_id = " . $p["id"]);
-                               }
-
-                               $query_strategy_part = sprintf("(feed_id = %d OR %s)", 
-                                       $feed, implode(" OR ", $parent_ids));
+                       if ($cat_view) {
 
+                               $query_strategy_part = "cat_id = $feed";
                                $vfeed_query_part = "ttrss_feeds.title AS feed_title,";
-                       } else {
-                               $query_strategy_part = "feed_id = '$feed'";
+
+                       } else {                
+                               $tmp_result = db_query($link, "SELECT id 
+                                       FROM ttrss_feeds WHERE parent_feed = '$feed'
+                                       ORDER BY cat_id,title");
+       
+                               $parent_ids = array();
+       
+                               if (db_num_rows($tmp_result) > 0) {
+                                       while ($p = db_fetch_assoc($tmp_result)) {
+                                               array_push($parent_ids, "feed_id = " . $p["id"]);
+                                       }
+       
+                                       $query_strategy_part = sprintf("(feed_id = %d OR %s)", 
+                                               $feed, implode(" OR ", $parent_ids));
+       
+                                       $vfeed_query_part = "ttrss_feeds.title AS feed_title,";
+                               } else {
+                                       $query_strategy_part = "feed_id = '$feed'";
+                               }
                        }
                } else if ($feed == -1) { // starred virtual feed
                        $query_strategy_part = "marked = true";
                } else if ($search && sprintf("%d", $feed) == 0) {
                        $feed_title = "Feed search results ($search, $feed)";
                } else if ($feed > 0) {
-                       $result = db_query($link, "SELECT title,site_url,last_error FROM ttrss_feeds 
-                               WHERE id = '$feed'");
 
-                       $feed_title = db_fetch_result($result, 0, "title");
-                       $feed_site_url = db_fetch_result($result, 0, "site_url");
-                       $last_error = db_fetch_result($result, 0, "last_error");
+                       if ($cat_view) {
+                       
+                               $result = db_query($link, "SELECT title FROM ttrss_feed_categories
+                                       WHERE id = '$feed' AND owner_uid = " . $_SESSION["uid"]);
+
+                               $feed_title = db_fetch_result($result, 0, "title");
+
+                       } else {
+                               
+                               $result = db_query($link, "SELECT title,site_url,last_error FROM ttrss_feeds 
+                                       WHERE id = '$feed' AND owner_uid = " . $_SESSION["uid"]);
+       
+                               $feed_title = db_fetch_result($result, 0, "title");
+                               $feed_site_url = db_fetch_result($result, 0, "site_url");
+                               $last_error = db_fetch_result($result, 0, "last_error");
+
+                       }
 
                } else if ($feed == -1) {
                        $feed_title = "Starred articles";
index 5610c29088bb5285df26b2aaeec6ef723b963393..370296b6b6724333bc4032665387dc2058888c92 100644 (file)
@@ -1,5 +1,7 @@
 var xmlhttp = false;
 
+var cat_view_mode = false;
+
 /*@cc_on @*/
 /*@if (@_jscript_version >= 5)
 // JScript gives us Conditional compilation, we can cope with old IE versions.
@@ -22,7 +24,11 @@ if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
        xmlhttp_rpc = new XMLHttpRequest();
 }
 
-function viewfeed(feed, skip, subop, doc) {
+function viewCategory(cat) {
+       viewfeed(cat, 0, '', false, true);
+}
+
+function viewfeed(feed, skip, subop, doc, is_cat) {
        try {
 
                if (!doc) doc = parent.document;
@@ -74,17 +80,24 @@ function viewfeed(feed, skip, subop, doc) {
        
        //      document.getElementById("ACTFEEDID").innerHTML = feed;
        
+               if (getActiveFeedId() != feed) {
+                       cat_view_mode = is_cat;
+               }
+
                setActiveFeedId(feed);
        
                if (subop == "MarkAllRead") {
        
                        var feedr = document.getElementById("FEEDR-" + feed);
                        var feedctr = document.getElementById("FEEDCTR-" + feed);
+
+                       if (feedr && feedctr) {
                
-                       feedctr.className = "invisible";
+                               feedctr.className = "invisible";
        
-                       if (feedr.className.match("Unread")) {
-                               feedr.className = feedr.className.replace("Unread", "");
+                               if (feedr.className.match("Unread")) {
+                                       feedr.className = feedr.className.replace("Unread", "");
+                               }
                        }
                }
        
@@ -97,6 +110,10 @@ function viewfeed(feed, skip, subop, doc) {
                        query = query + "&search=" + param_escape(search_query);
                        searchbox.value = "";
                }
+
+               if (cat_view_mode) {
+                       query = query + "&cat=1";
+               }
                
                var headlines_frame = parent.frames["headlines-frame"];