]> git.wh0rd.org - tt-rss.git/blobdiff - modules/pref-feeds.php
prefs: enable selecting all feeds in a category
[tt-rss.git] / modules / pref-feeds.php
index 238ca0a857bc73edce6151375e8f7730a93ccbc1..7da4598c1499cb771d1491b2bc08661be761a78b 100644 (file)
@@ -57,6 +57,7 @@
                                        $cat['bare_id'] = $feed_id;
                                        $cat['name'] = $line['title'];
                                        $cat['items'] = array();
+                                       $cat['checkbox'] = false;
                                        $cat['type'] = 'category';
 
                                        $feed_result = db_query($link, "SELECT id, title, last_error,
                                                array_push($cat['items'], $feed);
                                        }
 
+                                       $cat['param'] = T_sprintf('(%d feeds)', count($cat['items']));
+
                                        if (count($cat['items']) > 0)
                                                array_push($root['items'], $cat);
+
+                                       $root['param'] += count($cat['items']);
                                }
 
                                /* Uncategorized is a special case */
                                        array_push($cat['items'], $feed);
                                }
 
+                               $cat['param'] = T_sprintf('(%d feeds)', count($cat['items']));
+
                                if (count($cat['items']) > 0)
                                        array_push($root['items'], $cat);
 
+                               $root['param'] += count($cat['items']);
+                               $root['param'] = T_sprintf('(%d feeds)', $root['param']);
+
                        } else {
                                $feed_result = db_query($link, "SELECT id, title, last_error,
                                        ".SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated
 
                                        array_push($root['items'], $feed);
                                }
+
+                               $root['param'] = T_sprintf('(%d feeds)', count($root['items']));
+
                        }
 
                        $fl = array();
 
                        $purge_interval = db_fetch_result($result, 0, "purge_interval");
 
-                       if (FORCE_ARTICLE_PURGE == 0) {
 
                                /* Purge intl */
 
-                               print "<hr/>";
-
-                               print __('Article purging:') . " ";
-
-                               print_select_hash("purge_interval", $purge_interval, $purge_intervals,
-                                       'dojoType="dijit.form.Select"');
-
-                       } else {
-                               print "<input style=\"display : none\" name='purge_interval'
-                                       dojoType=\"dijit.form.TextBox\" value='$purge_interval'>";
+                       print "<hr/>";
+                       print __('Article purging:') . " ";
 
-                       }
+                       print_select_hash("purge_interval", $purge_interval, $purge_intervals,
+                               'dojoType="dijit.form.Select" ' .
+                                       ((FORCE_ARTICLE_PURGE == 0) ? "" : 'disabled="1"'));
 
                        print "</div>";
                        print "<div class=\"dlgSec\">".__("Authentication")."</div>";
                                <button dojoType=\"dijit.form.Button\" onclick='return unsubscribeFeed($feed_id, \"$title\")'>".
                                        __('Unsubscribe')."</button>";
 
-                       $pubsub_state = db_fetch_result($result, 0, "pubsub_state");
-
-                       $pubsub_btn_disabled = ($pubsub_state == 2) ? "" : "disabled=\"1\"";
+                       if (PUBSUBHUBBUB_ENABLED) {
+                               $pubsub_state = db_fetch_result($result, 0, "pubsub_state");
+                               $pubsub_btn_disabled = ($pubsub_state == 2) ? "" : "disabled=\"1\"";
 
-                       print "<button dojoType=\"dijit.form.Button\" id=\"pubsubReset_Btn\" $pubsub_btn_disabled
-                                       onclick='return resetPubSub($feed_id, \"$title\")'>".__('Resubscribe to push updates').
-                                       "</button>";
+                               print "<button dojoType=\"dijit.form.Button\" id=\"pubsubReset_Btn\" $pubsub_btn_disabled
+                                               onclick='return resetPubSub($feed_id, \"$title\")'>".__('Resubscribe to push updates').
+                                               "</button>";
+                       }
 
                        print "</div>";
 
                        case 2:
                                print_error(T_sprintf("Could not subscribe to <b>%s</b>.", $feed_url));
                                break;
+                       case 3:
+                               print_error(T_sprintf("No feeds found in <b>%s</b>.", $feed_url));
+                               break;
                        case 0:
                                print_warning(T_sprintf("Already subscribed to <b>%s</b>.", $feed_url));
                                break;
 
                print "<div style='float : right; padding-right : 4px;'>
                        <input dojoType=\"dijit.form.TextBox\" id=\"feed_search\" size=\"20\" type=\"search\"
-                               onchange=\"updateFeedList()\" value=\"$feed_search\">
+                               value=\"$feed_search\">
                        <button dojoType=\"dijit.form.Button\" onclick=\"updateFeedList()\">".
                                __('Search')."</button>
                        </div>";
 
                print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__('OPML')."\">";
 
-               print "<p>" . __("Using OPML you can export and import your feeds and Tiny Tiny RSS settings.");
+               print "<p>" . __("Using OPML you can export and import your feeds and Tiny Tiny RSS settings.") . " ";
 
-               print "<div class=\"insensitive\">" . __("Note: Only main settings profile can be migrated using OPML.") . "</div>";
+               print "<span class=\"insensitive\">" . __("Note: Only main settings profile can be migrated using OPML.") . "</span>";
 
                print "</p>";
 
-               print "<iframe id=\"upload_iframe\"
+               print "<h3>" . __("Import") . "</h3>";
+
+               print "<br/><iframe id=\"upload_iframe\"
                        name=\"upload_iframe\" onload=\"opmlImportComplete(this)\"
                        style=\"width: 400px; height: 100px; display: none;\"></iframe>";
 
-               print "<form style='display : block' target=\"upload_iframe\"
+               print "<form  name=\"opml_form\" style='display : block' target=\"upload_iframe\"
                        enctype=\"multipart/form-data\" method=\"POST\"
                                action=\"backend.php\">
                        <input id=\"opml_file\" name=\"opml_file\" type=\"file\">&nbsp;
                        <input type=\"hidden\" name=\"op\" value=\"dlg\">
                        <input type=\"hidden\" name=\"id\" value=\"importOpml\">
-                       <button dojoType=\"dijit.form.Button\" onclick=\"return opmlImport();\"
-                               type=\"submit\">".__('Import')."</button>
-                       <button dojoType=\"dijit.form.Button\" onclick=\"gotoExportOpml()\">".__('Export OPML')."</button>
-                       </form>";
+                       <button dojoType=\"dijit.form.Button\" onclick=\"return opmlImport();\" type=\"submit\">" .
+                       __('Import') . "</button>";
+
+               print "<h3>" . __("Export") . "</h3>";
+
+               print "<p>" . __('Filename:') .
+            " <input type=\"text\" id=\"filename\" value=\"TinyTinyRSS.opml\" />&nbsp;" .
+            __('Include settings') . "<input type=\"checkbox\" id=\"settings\" CHECKED />" .
+
+                       "<button dojoType=\"dijit.form.Button\"
+                       onclick=\"gotoExportOpml(document.opml_form.filename.value, document.opml_form.settings.checked)\" >" .
+              __('Export') . "</button></p></form>";
 
-               print "<p>".__('Your OPML can be published publicly and can be subscribed by anyone who knows the URL below.');
+               print "<h3>" . __("Publish") . "</h3>";
 
-               print "<div class=\"insensitive\">" . __("Note: Published OPML does not include your Tiny Tiny RSS settings, feeds that require authentication or feeds hidden from Popular feeds.") .                  "</div>" . "</p>";
+               print "<p>".__('Your OPML can be published publicly and can be subscribed by anyone who knows the URL below.') . " ";
+
+               print "<span class=\"insensitive\">" . __("Note: Published OPML does not include your Tiny Tiny RSS settings, feeds that require authentication or feeds hidden from Popular feeds.") .                         "</span>" . "</p>";
 
                print "<button dojoType=\"dijit.form.Button\" onclick=\"return displayDlg('pubOPMLUrl')\">".
                        __('Display URL')."</button> ";
 
                print "</div>"; #pane
 
-               print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Published articles and generated feeds')."\">";
+               print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Published & shared articles and generated feeds')."\">";
+
+               print "<h3>" . __("Published articles and generated feeds") . "</h3>";
 
                print "<p>".__('Published articles are exported as a public RSS feed and can be subscribed by anyone who knows the URL specified below.')."</p>";
 
                print "<button dojoType=\"dijit.form.Button\" onclick=\"return clearFeedAccessKeys()\">".
                        __('Clear all generated URLs')."</button> ";
 
+               print "<h3>" . __("Articles shared by URL") . "</h3>";
+
+               print "<p>" . __("You can disable all articles shared by unique URLs here.") . "</p>";
+
+               print "<button dojoType=\"dijit.form.Button\" onclick=\"return clearArticleAccessKeys()\">".
+                       __('Unshare all articles')."</button> ";
+
                print "</div>"; #pane
 
                if (defined('CONSUMER_KEY') && CONSUMER_KEY != '') {
                                        AND owner_uid = '$owner_uid') $search_qpart
                                        ORDER BY subscribers DESC LIMIT $limit"); */
 
-                               $result = db_query($link, "SELECT feed_url, title, SUM(subscribers) AS subscribers FROM
-                                       (SELECT feed_url, title, subscribers FROM ttrss_feedbrowser_cache UNION ALL
-                                               SELECT feed_url, title, subscribers FROM ttrss_linked_feeds) AS qqq
+                               $result = db_query($link, "SELECT feed_url, site_url, title, SUM(subscribers) AS subscribers FROM
+                                       (SELECT feed_url, site_url, title, subscribers FROM ttrss_feedbrowser_cache UNION ALL
+                                               SELECT feed_url, site_url, title, subscribers FROM ttrss_linked_feeds) AS qqq
                                        WHERE
                                                (SELECT COUNT(id) = 0 FROM ttrss_feeds AS tf
                                                        WHERE tf.feed_url = qqq.feed_url
                                                                AND owner_uid = '$owner_uid') $search_qpart
-                                       GROUP BY feed_url, title ORDER BY subscribers DESC LIMIT $limit");
+                                       GROUP BY feed_url, site_url, title ORDER BY subscribers DESC LIMIT $limit");
 
                        } else if ($mode == 2) {
                                $result = db_query($link, "SELECT *,
 
                                if ($mode == 1) {
 
-                                       $feed_url = $line["feed_url"];
+                                       $feed_url = htmlspecialchars($line["feed_url"]);
+                                       $site_url = htmlspecialchars($line["site_url"]);
                                        $subscribers = $line["subscribers"];
 
-                                       $det_result = db_query($link, "SELECT site_url,title,id
-                                               FROM ttrss_feeds WHERE feed_url = '$feed_url' LIMIT 1");
-
-                                       $details = db_fetch_assoc($det_result);
-
-                                       $icon_file = ICONS_DIR . "/" . $details["id"] . ".ico";
-
-                                       if (file_exists($icon_file) && filesize($icon_file) > 0) {
-                                                       $feed_icon = "<img style=\"vertical-align : middle\" class=\"tinyFeedIcon\"     src=\"" . ICONS_URL .
-                                                               "/".$details["id"].".ico\">";
-                                       } else {
-                                               $feed_icon = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\">";
-                                       }
-
                                        $check_box = "<input onclick='toggleSelectListRow2(this)'
                                                dojoType=\"dijit.form.CheckBox\"
                                                type=\"checkbox\" \">";
 
                                        $class = ($feedctr % 2) ? "even" : "odd";
 
-                                       $feed_url = htmlspecialchars($line["feed_url"]);
-
-                                       if ($details["site_url"]) {
-                                               $site_url = "<a target=\"_blank\" href=\"".
-                                                       htmlspecialchars($details["site_url"])."\">
-                                                       <img style='border-width : 0px' src='images/www.png' alt='www'></a>";
-                                       } else {
-                                               $site_url = "";
-                                       }
+                                       $site_url = "<a target=\"_blank\"
+                                               href=\"$site_url\">
+                                               <span class=\"fb_feedTitle\">".
+                                               htmlspecialchars($line["title"])."</span></a>";
 
-                                       $feed_url = "<a target=\"_blank\" href=\"$feed_url\"><img
-                                               style='border-width : 0px; vertical-align : middle'
-                                               src='images/feed-icon-12x12.png'></a>";
+                                       $feed_url = "<a target=\"_blank\" class=\"fb_feedUrl\"
+                                               href=\"$feed_url\"><img src='images/feed-icon-12x12.png'
+                                               style='vertical-align : middle'></a>";
 
-                                       $rv .= "<li title=\"".htmlspecialchars($details["site_url"])."\"
-                                               id=\"FBROW-".$details["id"]."\">$check_box".
-                                               "$feed_icon $feed_url " . htmlspecialchars($details["title"]) .
-                                               "&nbsp;<span class='subscribers'>($subscribers)</span>
-                                               $site_url</li>";
+                                       $rv .= "<li>$check_box $feed_url $site_url".
+                                               "&nbsp;<span class='subscribers'>($subscribers)</span></li>";
 
                                } else if ($mode == 2) {
                                        $feed_url = htmlspecialchars($line["feed_url"]);
                                        $site_url = htmlspecialchars($line["site_url"]);
                                        $title = htmlspecialchars($line["title"]);
 
-                                       $icon_file = ICONS_DIR . "/" . $line["id"] . ".ico";
-
-                                       if (file_exists($icon_file) && filesize($icon_file) > 0) {
-                                                       $feed_icon = "<img class=\"tinyFeedIcon\"       src=\"" . ICONS_URL .
-                                                               "/".$line["id"].".ico\">";
-                                       } else {
-                                               $feed_icon = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\">";
-                                       }
-
                                        $check_box = "<input onclick='toggleSelectListRow2(this)' dojoType=\"dijit.form.CheckBox\"
                                                type=\"checkbox\">";
 
                                                $archived = '';
                                        }
 
-                                       if ($line["site_url"]) {
-                                               $site_url = "<a target=\"_blank\" href=\"$site_url\">
-                                                       <img style='border-width : 0px' src='images/www.png' alt='www'></a>";
-                                       } else {
-                                               $site_url = "";
-                                       }
-
-                                       $feed_url = "<a target=\"_blank\" href=\"$feed_url\"><img
-                                               style='border-width : 0px; vertical-align : middle'
-                                               src='images/feed-icon-12x12.png'></a>";
+                                       $site_url = "<a target=\"_blank\"
+                                               href=\"$site_url\">
+                                               <span class=\"fb_feedTitle\">".
+                                               htmlspecialchars($line["title"])."</span></a>";
 
-                                       $rv .= "<li title='".$line['site_url']."' class='$class'
-                                               id=\"FBROW-".$line["id"]."\">".
-                                               $check_box . "$feed_icon $feed_url " . $title .
-                                               $archived . $site_url . "</li>";
+                                       $feed_url = "<a target=\"_blank\" class=\"fb_feedUrl\"
+                                               href=\"$feed_url\"><img src='images/feed-icon-12x12.png'
+                                               style='vertical-align : middle'></a>";
 
 
+                                       $rv .= "<li id=\"FBROW-".$line["id"]."\">".
+                                               "$check_box $feed_url $site_url $archived</li>";
                                }
 
                                ++$feedctr;