]> git.wh0rd.org - tt-rss.git/commitdiff
infobox-based feed category editor
authorAndrew Dolgov <fox@madoka.spb.ru>
Wed, 4 Oct 2006 05:40:00 +0000 (06:40 +0100)
committerAndrew Dolgov <fox@madoka.spb.ru>
Wed, 4 Oct 2006 05:40:00 +0000 (06:40 +0100)
functions.js
modules/pref-feeds.php
prefs.js
themes/compat/theme.css
themes/graycube/theme.css
tt-rss.css

index 652e2316f486ceb4d5b4692dbb6d17b7f19f28f9..db1351510ac7417b5132a9f9b7a69290674bb4d5 100644 (file)
@@ -1215,6 +1215,7 @@ function infobox_callback() {
                                box.style.display = "block";                            
                        }
                }
+               notify("");
        }
 }
 
index c460572747b9415adce9f5bf6246a18253275005..46b03e8913593466c712bcbc6e542433929d6cc8 100644 (file)
                        }
                }
 
-               if ($subop == "saveCat") {
+/*             if ($subop == "saveCat") {
                        $cat_title = db_escape_string(trim($_GET["title"]));
                        $cat_id = db_escape_string($_GET["id"]);
 
                        $result = db_query($link, "UPDATE ttrss_feed_categories SET
                                title = '$cat_title' WHERE id = '$cat_id' AND owner_uid = ".$_SESSION["uid"]);
 
-               }
+} */
 
                if ($subop == "remove") {
 
                        }
                }
 
-               if ($subop == "addCat") {
+/*             if ($subop == "addCat") {
 
                        if (!WEB_DEMO_MODE) {
 
 
 
                        }
-               }
+               } 
 
                if ($subop == "removeCats") {
 
                                        db_query($link, "COMMIT");
                                }
                        }
-               }
+               } */
 
                if ($subop == "categorize") {
 
 
                }
 
+               if ($subop == "editCats") {
+
+                       print "<div id=\"infoBoxTitle\">Category editor</div>";
+                       
+                       print "<div class=\"infoBoxContents\">";
+
+                       $action = $_REQUEST["action"];
+
+                       if ($action == "save") {
+
+                               $cat_title = db_escape_string(trim($_GET["title"]));
+                               $cat_id = db_escape_string($_GET["id"]);
+       
+                               $result = db_query($link, "UPDATE ttrss_feed_categories SET
+                                       title = '$cat_title' WHERE id = '$cat_id' AND owner_uid = ".$_SESSION["uid"]);
+       
+                       }
+
+                       if ($action == "add") {
+
+                               if (!WEB_DEMO_MODE) {
+       
+                                       $feed_cat = db_escape_string(trim($_GET["cat"]));
+       
+                                       $result = db_query($link,
+                                               "SELECT id FROM ttrss_feed_categories
+                                               WHERE title = '$feed_cat' AND owner_uid = ".$_SESSION["uid"]);
+       
+                                       if (db_num_rows($result) == 0) {
+                                               
+                                               $result = db_query($link,
+                                                       "INSERT INTO ttrss_feed_categories (owner_uid,title) 
+                                                       VALUES ('".$_SESSION["uid"]."', '$feed_cat')");
+       
+                                       } else {
+       
+                                               print "<div class=\"warning\">
+                                                       Category <b>$feed_cat</b> already exists in the database.
+                                               </div>";
+                                       }
+
+                               }
+                       }
+
+                       if ($action == "remove") {
+       
+                               if (!WEB_DEMO_MODE) {
+       
+                                       $ids = split(",", db_escape_string($_GET["ids"]));
+       
+                                       foreach ($ids as $id) {
+       
+                                               db_query($link, "BEGIN");
+       
+                                               $result = db_query($link, 
+                                                       "SELECT count(id) as num_feeds FROM ttrss_feeds 
+                                                               WHERE cat_id = '$id'");
+       
+                                               $num_feeds = db_fetch_result($result, 0, "num_feeds");
+       
+                                               if ($num_feeds == 0) {
+                                                       db_query($link, "DELETE FROM ttrss_feed_categories
+                                                               WHERE id = '$id' AND owner_uid = " . $_SESSION["uid"]);
+                                               } else {
+       
+                                                       print "<div class=\"warning\">
+                                                               Unable to delete non empty feed categories.</div>";
+                                                               
+                                               }
+       
+                                               db_query($link, "COMMIT");
+                                       }
+                               }
+                       }
+
+                       print "<div class=\"prefGenericAddBox\">
+                               <input id=\"fadd_cat\" 
+                                       onkeyup=\"toggleSubmitNotEmpty(this, 'catadd_submit_btn')\"
+                                       size=\"40\">&nbsp;
+                               <input 
+                                       type=\"submit\" class=\"button\" disabled=\"true\" id=\"catadd_submit_btn\"
+                                       onclick=\"javascript:addFeedCat()\" value=\"Create category\"></div>";
+       
+                       $result = db_query($link, "SELECT title,id FROM ttrss_feed_categories
+                               WHERE owner_uid = ".$_SESSION["uid"]."
+                               ORDER BY title");
+
+                       print "<p>";
+
+                       if (db_num_rows($result) != 0) {
+
+                               print "<table width=\"100%\" class=\"prefFeedCatList\" 
+                                       cellspacing=\"0\">";
+
+                               print "<tr><td class=\"selectPrompt\" colspan=\"8\">
+                               Select: 
+                                       <a href=\"javascript:selectPrefRows('fcat', true)\">All</a>,
+                                       <a href=\"javascript:selectPrefRows('fcat', false)\">None</a>
+                                       </td></tr>";
+
+                               print "</table>";
+
+                               print "<div class=\"prefFeedCatHolder\">";
+
+                               print "<form id=\"feed_cat_edit_form\">";
+
+                               print "<table width=\"100%\" class=\"prefFeedCatList\" 
+                                       cellspacing=\"0\" id=\"prefFeedCatList\">";
+
+/*                             print "<tr class=\"title\">
+                                                       <td width=\"5%\">&nbsp;</td><td width=\"80%\">Title</td>
+                                                       </tr>"; */
+                                               
+                               $lnum = 0;
+                               
+                               while ($line = db_fetch_assoc($result)) {
+               
+                                       $class = ($lnum % 2) ? "even" : "odd";
+               
+                                       $cat_id = $line["id"];
+               
+                                       $edit_cat_id = $_GET["id"];
+               
+                                       if ($action == "edit" && $cat_id != $edit_cat_id) {
+                                                       $class .= "Grayed";
+                                                       $this_row_id = "";
+                                       } else {
+                                               $this_row_id = "id=\"FCATR-$cat_id\"";
+                                       }
+               
+                                       print "<tr class=\"$class\" $this_row_id>";
+               
+                                       $edit_title = htmlspecialchars(db_unescape_string($line["title"]));
+               
+                                       if (!$edit_cat_id || $action != "edit") {
+               
+                                               print "<td width='5%' align='center'><input onclick='toggleSelectPrefRow(this, \"fcat\");' 
+                                                       type=\"checkbox\" id=\"FCCHK-".$line["id"]."\"></td>";
+               
+                                               print "<td><a href=\"javascript:editFeedCat($cat_id);\">" . 
+                                                       $edit_title . "</a></td>";              
+               
+                                       } else if ($cat_id != $edit_cat_id) {
+               
+                                               print "<td width='5%' align='center'><input disabled=\"true\" type=\"checkbox\" 
+                                                       id=\"FRCHK-".$line["id"]."\"></td>";
+               
+                                               print "<td>$edit_title</td>";           
+               
+                                       } else {
+               
+                                               print "<td width='5%' align='center'><input disabled=\"true\" type=\"checkbox\" checked>";
+                                               
+                                               print "<input type=\"hidden\" name=\"id\" value=\"$cat_id\">";
+                                               print "<input type=\"hidden\" name=\"op\" value=\"pref-feeds\">";
+                                               print "<input type=\"hidden\" name=\"subop\" value=\"editCats\">";
+                                               print "<input type=\"hidden\" name=\"action\" value=\"save\">";
+                               
+                                               print "</td>";
+               
+                                               print "<td><input onkeypress=\"return filterCR(event)\"
+                                                       name=\"title\" size=\"40\" value=\"$edit_title\"></td>";
+                                               
+                                       }
+                                       
+                                       print "</tr>";
+               
+                                       ++$lnum;
+                               }
+       
+                               print "</table>";
+
+                               print "</form>";
+
+                               print "</div>";
+
+                               print "<div style='float : right'>
+                                       <input type='submit' class='button'                     
+                                       onclick=\"closeInfoBox()\" value=\"Close this window\"></div>";
+
+                               print "<div id=\"catOpToolbar\">";
+       
+                               if ($action == "edit") {
+                                       print "<input type=\"submit\" class=\"button\"
+                                                       onclick=\"return feedCatEditSave()\" value=\"Save\">
+                                               <input type=\"submit\" class=\"button\"
+                                                       onclick=\"return feedCatEditCancel()\" value=\"Cancel\">";
+                                       } else {
+
+                                       print "
+                                       <input type=\"submit\" class=\"button\" disabled=\"true\"
+                                               onclick=\"return editSelectedFeedCat()\" value=\"Edit\">
+                                       <input type=\"submit\" class=\"button\" disabled=\"true\"
+                                               onclick=\"return removeSelectedFeedCats()\" value=\"Remove\">";
+       
+                                       }
+
+                               print "</div>";
+       
+                       } else {
+                               print "<p>No feed categories defined.</p>";
+                       }
+
+                       print "</div>";
+
+                       return;
+
+               }
+
                if ($quiet) return;
 
 //             print "<h3>Edit Feeds</h3>";
 
                                }
                                
-                               print "</span>
-                                       &nbsp;All feeds: <input type=\"submit\" 
+                               print "</span>";
+
+                               if (get_pref($link, 'ENABLE_FEED_CATS')) {
+
+                                       print " <input type=\"submit\" class=\"button\"
+                                               onclick=\"javascript:editFeedCats()\" value=\"Edit categories\">";
+
+                                       print "&nbsp;|&nbsp;";                          
+
+                               }
+
+                               print "All feeds: <input type=\"submit\" 
                                                        class=\"button\" onclick=\"gotoExportOpml()\" 
                                                        value=\"Export OPML\">";                        
                                }
 
                }
 
-               if (get_pref($link, 'ENABLE_FEED_CATS')) {
+
+/*             if (get_pref($link, 'ENABLE_FEED_CATS')) {
 
                        print "<h3>Edit Categories</h3>";
 
                        } else {
                                print "<p>No feed categories defined.</p>";
                        }
-               }
+               } */
 
                print "<h3>Import OPML</h3>
                <form   enctype=\"multipart/form-data\" method=\"POST\" action=\"opml.php\">
index da8a4c3e287ffcf8914392cdc244d60c12c08224..d9c10d692bf43608f0dc044d0511d9b20ec7290a 100644 (file)
--- a/prefs.js
+++ b/prefs.js
@@ -245,9 +245,9 @@ function addFeedCat() {
        } else {
                notify("Adding feed category...");
 
-               xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=addCat&cat=" +
+               xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=add&cat=" +
                        param_escape(cat.value), true);
-               xmlhttp.onreadystatechange=feedlist_callback;
+               xmlhttp.onreadystatechange=infobox_callback;
                xmlhttp.send(null);
 
                link.value = "";
@@ -365,9 +365,9 @@ function editFeedCat(cat) {
 
        active_feed_cat = cat;
 
-       xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCat&id=" +
+       xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=edit&id=" +
                param_escape(cat), true);
-       xmlhttp.onreadystatechange=feedlist_callback;
+       xmlhttp.onreadystatechange=infobox_callback;
        xmlhttp.send(null);
 
 }
@@ -549,9 +549,9 @@ function removeSelectedFeedCats() {
                if (ok) {
                        notify("Removing selected categories...");
        
-                       xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=removeCats&ids="+
+                       xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=remove&ids="+
                                param_escape(sel_rows.toString()), true);
-                       xmlhttp.onreadystatechange=feedlist_callback;
+                       xmlhttp.onreadystatechange=infobox_callback;
                        xmlhttp.send(null);
                }
 
@@ -589,8 +589,8 @@ function feedCatEditCancel() {
 
 //     notify("Operation cancelled.");
 
-       xmlhttp.open("GET", "backend.php?op=pref-feeds", true);
-       xmlhttp.onreadystatechange=feedlist_callback;
+       xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCats", true);
+       xmlhttp.onreadystatechange=infobox_callback;
        xmlhttp.send(null);
 
        return false;
@@ -637,7 +637,7 @@ function feedCatEditSave() {
        var query = Form.serialize("feed_cat_edit_form");
 
        xmlhttp.open("GET", "backend.php?" + query, true);
-       xmlhttp.onreadystatechange=feedlist_callback;
+       xmlhttp.onreadystatechange=infobox_callback;
        xmlhttp.send(null);
 
        active_feed_cat = false;
@@ -1435,7 +1435,7 @@ function selectPrefRows(kind, select) {
                } else if (kind == "fcat") {
                        opbarid = "catOpToolbar";
                        nrow = "FCATR-";
-                       nchk = "FCHK-";
+                       nchk = "FCCHK-";
                        lname = "prefFeedCatList";
                } else if (kind == "filter") {
                        opbarid = "filterOpToolbar";
@@ -1542,3 +1542,14 @@ function userSwitch() {
        var user = chooser[chooser.selectedIndex].value;
        window.location = "prefs.php?swu=" + user;
 }
+
+function editFeedCats() {
+       if (!xmlhttp_ready(xmlhttp)) {
+               printLockingError();
+               return
+       }
+
+       xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCats", true);
+       xmlhttp.onreadystatechange=infobox_callback;
+       xmlhttp.send(null);
+}
index 7fcf0fad2a12f8bc37e64beb88a1b1dac3f229e8..94bade828990bba4d122c29c87fe71f7e6bd081f 100644 (file)
@@ -315,6 +315,10 @@ tr.title td a:hover {
        color : #5050aa;
 }
 
+div.prefFeedCatHolder {
+       border : 1px solid #c0c0c0;
+}
+
 table.prefFeedList td.feedEditCat {
        font-size : large;
        border-color : #c0c0c0;
index 71bacfa96965fb6b948bd5e21cba4c69b299a5ba..a22f7010e8f15f767f3c7812c693ac95ff68de06 100644 (file)
@@ -125,15 +125,16 @@ div.postReply > div.postHeader {
 }
 
 .evenGrayed, .evenGrayed td {
-       background-color : white;
-       color : #909090;
-                 border-width : 1px 0px 1px 0px;
-                 border-style : solid;
-                 border-color : #ebebeb;
+       background-color : #f9f9f9;
+       color : gray;
+       border-width : 1px 0px 1px 0px;
+       border-style : solid;
+       border-color : #ebebeb;
 }
 
 .oddGrayed {
-       color : #909090;
+       color : gray;
+       background-color : #f9f9f9;
 }
 
 .even, .even td {
@@ -218,6 +219,10 @@ li.tagUnreadSelected a {
        color : gray;
 }
 
+div.prefFeedCatHolder {
+       border : 1px solid #999999;
+}
+
 table.prefFeedList td.feedEditCat {
        font-weight : bold;
        border-width : 0px 0px 1px 0px;
index b74aa487bbf25fb1bf3283113b13b650fc70f81f..a24a7968caaff2877417b8e976db5dc28b079f80 100644 (file)
@@ -412,6 +412,13 @@ table.prefFeedList td.feedSelect {
        text-align : center;
 }
 
+div.prefFeedCatHolder {
+       height : 250px;
+       overflow : auto;
+       border : 1px solid #88b0f0;
+       margin : 5px 0px 5px 0px;
+}
+
 a.helpLink {
        color : #808080;
 }
@@ -465,8 +472,9 @@ div.helpResponse {
 }
 
 div.infoBoxContents {
-       padding : 5px;
+       padding : 10px;
        margin-bottom : 5px;
+       font-size : small;
 }
 
 div.infoBoxContents td {