]> git.wh0rd.org - tt-rss.git/blobdiff - classes/pref_feeds.php
remove old category editor
[tt-rss.git] / classes / pref_feeds.php
index d292319cbf11814ff6c5baf0a616fe663507d708..bddf321852f268a641ee1f782ebb5ae87d4ab3b5 100644 (file)
@@ -33,6 +33,8 @@ class Pref_Feeds extends Protected_Handler {
        }
 
        private function get_category_items($cat_id) {
+               $show_empty_cats = $_REQUEST['mode'] != 2 &&
+                       get_pref($this->link, '_PREFS_SHOW_EMPTY_CATS');
 
                $items = array();
 
@@ -1288,164 +1290,6 @@ class Pref_Feeds extends Protected_Handler {
                db_query($this->link, "COMMIT");
        }
 
-       function editCats() {
-
-               $action = $_REQUEST["action"];
-
-               if ($action == "save") {
-
-                       $cat_title = db_escape_string(trim($_REQUEST["value"]));
-                       $cat_id = db_escape_string($_REQUEST["cid"]);
-
-                       db_query($this->link, "BEGIN");
-
-                       $result = db_query($this->link, "SELECT title FROM ttrss_feed_categories
-                               WHERE id = '$cat_id' AND owner_uid = ".$_SESSION["uid"]);
-
-                       if (db_num_rows($result) == 1) {
-
-                               $old_title = db_fetch_result($result, 0, "title");
-
-                               if ($cat_title != "") {
-                                       $result = db_query($this->link, "UPDATE ttrss_feed_categories SET
-                                               title = '$cat_title' WHERE id = '$cat_id' AND
-                                               owner_uid = ".$_SESSION["uid"]);
-
-                                       print $cat_title;
-                               } else {
-                                       print $old_title;
-                               }
-                       } else {
-                               print $_REQUEST["value"];
-                       }
-
-                       db_query($this->link, "COMMIT");
-
-                       return;
-
-               }
-
-               if ($action == "add") {
-
-                       $feed_cat = db_escape_string(trim($_REQUEST["cat"]));
-
-                       if (!add_feed_category($this->link, $feed_cat))
-                               print_warning(T_sprintf("Category <b>$%s</b> already exists in the database.", $feed_cat));
-
-               }
-
-               if ($action == "remove") {
-
-                       $ids = split(",", db_escape_string($_REQUEST["ids"]));
-
-                       foreach ($ids as $id) {
-                               remove_feed_category($this->link, $id, $_SESSION["uid"]);
-                       }
-               }
-
-               print "<div dojoType=\"dijit.Toolbar\">";
-
-               print "<div dojoType=\"dijit.form.DropDownButton\">".
-                               "<span>" . __('Select')."</span>";
-               print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
-               print "<div onclick=\"selectTableRows('prefFeedCatList', 'all')\"
-                       dojoType=\"dijit.MenuItem\">".__('All')."</div>";
-               print "<div onclick=\"selectTableRows('prefFeedCatList', 'none')\"
-                       dojoType=\"dijit.MenuItem\">".__('None')."</div>";
-               print "</div></div>";
-
-               print "<div style='float : right'>";
-
-               print "<input dojoType=\"dijit.form.ValidationTextBox\" required=\"1\" name=\"newcat\">
-                               <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('feedCatEditDlg').addCategory()\">".
-                                       __('Create category')."</button></div>";
-
-               print "</div>";
-
-               $result = db_query($this->link, "SELECT c.title, c.id,COUNT(f.id) AS count
-                       FROM ttrss_feed_categories AS c LEFT JOIN ttrss_feeds AS f ON
-                               (f.cat_id = c.id)
-                       WHERE c.owner_uid = ".$_SESSION["uid"]."
-                       GROUP BY c.title, c.id ORDER BY title");
-
-               if (db_num_rows($result) != 0) {
-
-                       print "<div class=\"prefFeedCatHolder\">";
-
-                       print "<table width=\"100%\" class=\"prefFeedCatList\"
-                               cellspacing=\"0\" id=\"prefFeedCatList\">";
-
-                       $lnum = 0;
-
-                       while ($line = db_fetch_assoc($result)) {
-
-                               $class = ($lnum % 2) ? "even" : "odd";
-
-                               $cat_id = $line["id"];
-                               $this_row_id = "id=\"FCATR-$cat_id\"";
-
-                               print "<tr class=\"placeholder\" $this_row_id>";
-
-                               $edit_title = htmlspecialchars($line["title"]);
-
-                               print "<td width='5%' align='center'><input id=\"FCATC-$cat_id\"
-                                       onclick='toggleSelectRow2(this);' dojoType=\"dijit.form.CheckBox\"
-                                       type=\"checkbox\"></td>";
-
-                               print "<td>";
-
-                               if ($line['count'] == 0) print '<em>';
-
-                               print "<span dojoType=\"dijit.InlineEditBox\"
-                                       width=\"300px\" autoSave=\"false\"
-                                       cat-id=\"$cat_id\">" . $edit_title .
-                                       "<script type=\"dojo/method\" event=\"onChange\" args=\"item\">
-                                               var elem = this;
-                                               dojo.xhrPost({
-                                                       url: 'backend.php',
-                                                       content: {op: 'pref-feeds', method: 'editCats',
-                                                               action: 'save',
-                                                               value: this.value,
-                                                               cid: this.srcNodeRef.getAttribute('cat-id')},
-                                                               load: function(response) {
-                                                                       elem.attr('value', response);
-                                                                       updateFeedList();
-                                                       }
-                                               });
-                                       </script>
-                               </span>";
-
-                               if ($line['count'] == 0) print '</em>';
-
-                               print "</td>";
-
-                               print "<td align='right' class='insensitive'>";
-                               echo T_sprintf("%d feeds", $line['count']);
-                               print "</td></tr>";
-
-                               ++$lnum;
-                       }
-
-                       print "</table>";
-                       print "</div>";
-
-               } else {
-                       print "<p>".__('No feed categories defined.')."</p>";
-               }
-
-               print "<div class='dlgButtons'>
-                       <div style='float : left'>
-                       <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('feedCatEditDlg').removeSelected()\">".
-                       __('Remove selected categories')."</button>
-                       </div>";
-
-               print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('feedCatEditDlg').hide()\">".
-                       __('Close this window')."</button></div>";
-
-               return;
-
-       }
-
        function index() {
 
                print "<div dojoType=\"dijit.layout.AccordionContainer\" region=\"center\">";
@@ -1528,8 +1372,8 @@ class Pref_Feeds extends Protected_Handler {
                        print "<div dojoType=\"dijit.form.DropDownButton\">".
                                        "<span>" . __('Categories')."</span>";
                        print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
-                       print "<div onclick=\"editFeedCats()\"
-                               dojoType=\"dijit.MenuItem\">".__('Edit categories')."</div>";
+                       print "<div onclick=\"createCategory()\"
+                               dojoType=\"dijit.MenuItem\">".__('Add category')."</div>";
                        print "<div onclick=\"toggleHiddenFeedCats()\"
                                dojoType=\"dijit.MenuItem\">".__('(Un)hide empty categories')."</div>";
                        print "<div onclick=\"resetCatOrder()\"