]> git.wh0rd.org - tt-rss.git/blobdiff - classes/pref_feeds.php
add select all/none functionality to several edit dialogs
[tt-rss.git] / classes / pref_feeds.php
index 442eaba3ce09d819628e53e6085b6a47f60506c0..257c1f9c38a9cabf9d32361116dc0f844bbfc122 100644 (file)
@@ -3,7 +3,7 @@ class Pref_Feeds extends Protected_Handler {
 
        function csrf_ignore($method) {
                $csrf_ignored = array("index", "getfeedtree", "add", "editcats", "editfeed",
-                       "savefeedorder");
+                       "savefeedorder", "uploadicon");
 
                return array_search($method, $csrf_ignored) !== false;
        }
@@ -45,6 +45,7 @@ class Pref_Feeds extends Protected_Handler {
                $root['type'] = 'category';
 
                if (get_pref($this->link, 'ENABLE_FEED_CATS')) {
+                       $show_empty_cats = get_pref($this->link, '_PREFS_SHOW_EMPTY_CATS');
 
                        $result = db_query($this->link, "SELECT id, title FROM ttrss_feed_categories
                                WHERE owner_uid = " . $_SESSION["uid"] . " ORDER BY order_id, title");
@@ -80,7 +81,7 @@ class Pref_Feeds extends Protected_Handler {
 
                                $cat['param'] = T_sprintf('(%d feeds)', count($cat['items']));
 
-                               if (count($cat['items']) > 0)
+                               if (count($cat['items']) > 0 || $show_empty_cats)
                                        array_push($root['items'], $cat);
 
                                $root['param'] += count($cat['items']);
@@ -118,7 +119,7 @@ class Pref_Feeds extends Protected_Handler {
 
                        $cat['param'] = T_sprintf('(%d feeds)', count($cat['items']));
 
-                       if (count($cat['items']) > 0)
+                       if (count($cat['items']) > 0 || $show_empty_cats)
                                array_push($root['items'], $cat);
 
                        $root['param'] += count($cat['items']);
@@ -170,6 +171,11 @@ class Pref_Feeds extends Protected_Handler {
                return;
        }
 
+       function togglehiddenfeedcats() {
+               set_pref($this->link, '_PREFS_SHOW_EMPTY_CATS',
+                       (get_pref($this->link, '_PREFS_SHOW_EMPTY_CATS') ? 'false' : 'true'));
+       }
+
        function savefeedorder() {
                $data = json_decode($_POST['payload'], true);
 
@@ -799,31 +805,31 @@ class Pref_Feeds extends Protected_Handler {
                                                break;
 
                                        case "private":
-                                               $qpart = "private = '$private'";
+                                               $qpart = "private = $private";
                                                break;
 
                                        case "include_in_digest":
-                                               $qpart = "include_in_digest = '$include_in_digest'";
+                                               $qpart = "include_in_digest = $include_in_digest";
                                                break;
 
                                        case "always_display_enclosures":
-                                               $qpart = "always_display_enclosures = '$always_display_enclosures'";
+                                               $qpart = "always_display_enclosures = $always_display_enclosures";
                                                break;
 
                                        case "mark_unread_on_update":
-                                               $qpart = "mark_unread_on_update = '$mark_unread_on_update'";
+                                               $qpart = "mark_unread_on_update = $mark_unread_on_update";
                                                break;
 
                                        case "update_on_checksum_change":
-                                               $qpart = "update_on_checksum_change = '$update_on_checksum_change'";
+                                               $qpart = "update_on_checksum_change = $update_on_checksum_change";
                                                break;
 
                                        case "cache_images":
-                                               $qpart = "cache_images = '$cache_images'";
+                                               $qpart = "cache_images = $cache_images";
                                                break;
 
                                        case "rtl_content":
-                                               $qpart = "rtl_content = '$rtl_content'";
+                                               $qpart = "rtl_content = $rtl_content";
                                                break;
 
                                        case "update_method":
@@ -992,11 +998,12 @@ class Pref_Feeds extends Protected_Handler {
                $auth_pass = db_escape_string(trim($_POST["auth_pass"]));
 
                if ($p_from != 'tt-rss') {
-                       header("Content-Type: text/html");
+                       header('Content-Type: text/html; charset=utf-8');
                        print "<html>
                                <head>
                                        <title>Tiny Tiny RSS</title>
                                        <link rel=\"stylesheet\" type=\"text/css\" href=\"utility.css\">
+                                       <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>
                                </head>
                                <body>
                                <img class=\"floatingLogo\" src=\"images/ttrss_logo.png\"
@@ -1020,7 +1027,7 @@ class Pref_Feeds extends Protected_Handler {
                        print_warning(T_sprintf("Already subscribed to <b>%s</b>.", $feed_url));
                        break;
                case 4:
-                       print_notice("Multiple feed URLs found.");
+                       print_notice(__("Multiple feed URLs found."));
 
                        $feed_urls = get_feeds_from_html($feed_url);
                        break;
@@ -1164,11 +1171,25 @@ class Pref_Feeds extends Protected_Handler {
                        }
                }
 
-               print "<div dojoType=\"dijit.Toolbar\">
-                       <input dojoType=\"dijit.form.ValidationTextBox\" required=\"1\" name=\"newcat\">
+               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 title,id FROM ttrss_feed_categories
                        WHERE owner_uid = ".$_SESSION["uid"]."
                        ORDER BY title");
@@ -1189,11 +1210,11 @@ class Pref_Feeds extends Protected_Handler {
                                $cat_id = $line["id"];
                                $this_row_id = "id=\"FCATR-$cat_id\"";
 
-                               print "<tr class=\"\" $this_row_id>";
+                               print "<tr class=\"placeholder\" $this_row_id>";
 
                                $edit_title = htmlspecialchars($line["title"]);
 
-                               print "<td width='5%' align='center'><input
+                               print "<td width='5%' align='center'><input id=\"FCATC-$cat_id\"
                                        onclick='toggleSelectRow2(this);' dojoType=\"dijit.form.CheckBox\"
                                        type=\"checkbox\"></td>";
 
@@ -1327,6 +1348,8 @@ class Pref_Feeds extends Protected_Handler {
                        print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
                        print "<div onclick=\"editFeedCats()\"
                                dojoType=\"dijit.MenuItem\">".__('Edit categories')."</div>";
+                       print "<div onclick=\"toggleHiddenFeedCats()\"
+                               dojoType=\"dijit.MenuItem\">".__('(Un)hide empty categories')."</div>";
                        print "<div onclick=\"resetCatOrder()\"
                                dojoType=\"dijit.MenuItem\">".__('Reset sort order')."</div>";
                        print "</div></div>";
@@ -1492,7 +1515,7 @@ class Pref_Feeds extends Protected_Handler {
 
                $bm_subscribe_url = str_replace('%s', '', add_feed_url());
 
-               $confirm_str = __('Subscribe to %s in Tiny Tiny RSS?');
+               $confirm_str = str_replace("'", "\'", __('Subscribe to %s in Tiny Tiny RSS?'));
 
                $bm_url = htmlspecialchars("javascript:{if(confirm('$confirm_str'.replace('%s',window.location.href)))window.location.href='$bm_subscribe_url'+window.location.href}");