]> 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 f5cb6e64983866840c312934d0dbedd889fd1135..257c1f9c38a9cabf9d32361116dc0f844bbfc122 100644 (file)
@@ -2,7 +2,8 @@
 class Pref_Feeds extends Protected_Handler {
 
        function csrf_ignore($method) {
-               $csrf_ignored = array("index", "getfeedtree", "add", "editcats", "editfeed");
+               $csrf_ignored = array("index", "getfeedtree", "add", "editcats", "editfeed",
+                       "savefeedorder", "uploadicon");
 
                return array_search($method, $csrf_ignored) !== false;
        }
@@ -44,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");
@@ -79,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']);
@@ -117,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']);
@@ -169,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);
 
@@ -798,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":
@@ -991,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\"
@@ -1019,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;
@@ -1163,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");
@@ -1188,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>";
 
@@ -1316,6 +1338,8 @@ class Pref_Feeds extends Protected_Handler {
                        dojoType=\"dijit.MenuItem\">".__('Edit selected feeds')."</div>";
                print "<div onclick=\"resetFeedOrder()\"
                        dojoType=\"dijit.MenuItem\">".__('Reset sort order')."</div>";
+               print "<div onclick=\"batchSubscribe()\"
+                       dojoType=\"dijit.MenuItem\">".__('Batch subscribe')."</div>";
                print "</div></div>";
 
                if (get_pref($this->link, 'ENABLE_FEED_CATS')) {
@@ -1324,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>";
@@ -1400,9 +1426,7 @@ class Pref_Feeds extends Protected_Handler {
 
                print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Import and export')."\">";
 
-               print "<h2>" . __("OPML") . "</h2>";
-
-               print "<h3>" . __("Import") . "</h3>";
+               print "<h3>" . __("OPML") . "</h3>";
 
                print "<p>" . __("Using OPML you can export and import your feeds, filters, labels and Tiny Tiny RSS settings.") . " ";
 
@@ -1419,44 +1443,42 @@ class Pref_Feeds extends Protected_Handler {
                        <input type=\"hidden\" name=\"op\" value=\"dlg\">
                        <input type=\"hidden\" name=\"method\" value=\"importOpml\">
                        <button dojoType=\"dijit.form.Button\" onclick=\"return opmlImport();\" type=\"submit\">" .
-                       __('Import') . "</button>";
+                       __('Import my OPML') . "</button>";
 
-               print "<h3>" . __("Export") . "</h3>";
+               print "<hr>";
 
                print "<p>" . __('Filename:') .
             " <input type=\"text\" id=\"filename\" value=\"TinyTinyRSS.opml\" />&nbsp;" .
-            __('Include settings') . "<input type=\"checkbox\" id=\"settings\" CHECKED />" .
+                               __('Include settings') . "<input type=\"checkbox\" id=\"settings\" checked=\"1\"/>";
 
-                       "<button dojoType=\"dijit.form.Button\"
+               print "</p><button dojoType=\"dijit.form.Button\"
                        onclick=\"gotoExportOpml(document.opml_form.filename.value, document.opml_form.settings.checked)\" >" .
-              __('Export') . "</button></p></form>";
+              __('Export OPML') . "</button></p></form>";
 
-               print "<h3>" . __("Publish") . "</h3>";
+               print "<hr>";
 
                print "<p>".__('Your OPML can be published publicly and can be subscribed by anyone who knows the URL below.') . " ";
 
                print __("Published OPML does not include your Tiny Tiny RSS settings, feeds that require authentication or feeds hidden from Popular feeds.") . "</p>";
 
                print "<button dojoType=\"dijit.form.Button\" onclick=\"return displayDlg('pubOPMLUrl')\">".
-                       __('Display URL')."</button> ";
-
+                       __('Display published OPML URL')."</button> ";
 
-               print "<h2>" . __("Article archive") . "</h2>";
 
-               print "<p>" . __("You can export your Starred and Archived articles using neutral storage format. Please note that import and export of such data is only supported between same tt-rss versions.") . "</p>";
+               print "<h3>" . __("Article archive") . "</h3>";
 
-               print "<h3>" . __("Export") . "</h3>";
+               print "<p>" . __("You can export and import your Starred and Archived articles for safekeeping or when migrating between tt-rss instances.") . "</p>";
 
                print "<button dojoType=\"dijit.form.Button\" onclick=\"return exportData()\">".
                        __('Export my data')."</button> ";
 
-               print "<h3>" . __("Import") . "</h3>";
+               print "<hr>";
 
                print "<iframe id=\"data_upload_iframe\"
                        name=\"data_upload_iframe\" onload=\"dataImportComplete(this)\"
                        style=\"width: 400px; height: 100px; display: none;\"></iframe>";
 
-               print "<form  name=\"opml_form\" style='display : block' target=\"data_upload_iframe\"
+               print "<form name=\"import_form\" style='display : block' target=\"data_upload_iframe\"
                        enctype=\"multipart/form-data\" method=\"POST\"
                        action=\"backend.php\">
                        <input id=\"export_file\" name=\"export_file\" type=\"file\">&nbsp;
@@ -1493,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}");
 
@@ -1501,7 +1523,7 @@ class Pref_Feeds extends Protected_Handler {
 
                print "</div>"; #pane
 
-               print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Published & shared articles and generated feeds')."\">";
+               print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Published & shared articles / Generated feeds')."\">";
 
                print "<h3>" . __("Published articles and generated feeds") . "</h3>";