]> git.wh0rd.org - tt-rss.git/commitdiff
properly handle multiple feed extraction in external subscription dialog
authorAndrew Dolgov <fox@fakecake.org>
Tue, 18 Jan 2011 13:58:26 +0000 (16:58 +0300)
committerAndrew Dolgov <fox@fakecake.org>
Tue, 18 Jan 2011 13:58:26 +0000 (16:58 +0300)
modules/pref-feeds.php

index 7f1b029a1953d70e9691ece60574625f774e4d81..36957b236d019592cb0b4bdf3f7adc91f3797e38 100644 (file)
                        case 0:
                                print_warning(T_sprintf("Already subscribed to <b>%s</b>.", $feed_url));
                                break;
+                       case 4:
+                               print_notice("Multiple feed URLs found.");
+
+                               $feed_urls = get_feeds_from_html($feed_url);
+                               break;
                        case 5:
                                print_error(T_sprintf("Could not subscribe to <b>%s</b>.<br>Can't download the Feed URL.", $feed_url));
                                break;
                        }
 
                        if ($p_from != 'tt-rss') {
-                               if (!isset($_SERVER['HTTPS'])) $_SERVER['HTTPS'] = 'off';
-                               $tt_uri = ($_SERVER['HTTPS'] != "on" ? 'http://' : 'https://') . $_SERVER['HTTP_HOST'] . preg_replace('/backend\.php.*$/', 'tt-rss.php', $_SERVER["REQUEST_URI"]);
 
+                               if ($feed_urls) {
+
+                                       print "<form action=\"backend.php\">";
+                                       print "<input type=\"hidden\" name=\"op\" value=\"pref-feeds\">";
+                                       print "<input type=\"hidden\" name=\"quiet\" value=\"1\">";
+                                       print "<input type=\"hidden\" name=\"subop\" value=\"add\">";
+                                       
+                                       print "<select name=\"feed_url\">";
+
+                                       foreach ($feed_urls as $url => $name) {
+                                               $url = htmlspecialchars($url);
+                                               $name = htmlspecialchars($name);
+
+                                               print "<option value=\"$url\">$name</option>";
+                                       }
+
+                                       print "<input type=\"submit\" value=\"".__("Subscribe to selected feed").
+                                               "\">";
+
+                                       print "</form>";
+                               }
 
-                               $tp_uri = ($_SERVER['HTTPS'] != "on" ? 'http://' : 'https://') . $_SERVER['HTTP_HOST'] . preg_replace('/backend\.php.*$/', 'prefs.php', $_SERVER["REQUEST_URI"]);
+                               $tp_uri = get_self_url_prefix() . "/prefs.php";
+                               $tt_uri = get_self_url_prefix();
 
                                if ($rc <= 2){
                                        $result = db_query($link, "SELECT id FROM ttrss_feeds WHERE