]> git.wh0rd.org Git - tt-rss.git/commitdiff
use popup feedbrowser for main UI (incomplete)
authorAndrew Dolgov <fox@bah.spb.su>
Fri, 23 Jan 2009 18:54:57 +0000 (19:54 +0100)
committerAndrew Dolgov <fox@bah.spb.su>
Fri, 23 Jan 2009 18:54:57 +0000 (19:54 +0100)
modules/pref-feeds.php
prefs.js
tt-rss.js
tt-rss.php

index bc8171c6d215117959ed8a46fb5a9a9a4d0abf2e..0bdaf4e5535b3cb4d13e02af2b563c633d3efb9d 100644 (file)
                                return;
                        }
 
-                       print "<div id=\"infoBoxTitle\">".__('Other feeds: Top 25')."</div>";
+                       print "<div id=\"infoBoxTitle\">".__('Feed Browser')."</div>";
                        
                        print "<div class=\"infoBoxContents\">";
 
-                       print "<p>".__("Showing top 25 registered feeds, sorted by popularity:")."</p>";
 
-                       $owner_uid = $_SESSION["uid"];
-
-/*                     $result = db_query($link, "SELECT feed_url,COUNT(id) AS subscribers
-                               FROM ttrss_feeds WHERE (SELECT COUNT(id) = 0 FROM ttrss_feeds AS tf 
-                                       WHERE tf.feed_url = ttrss_feeds.feed_url 
-                                               AND owner_uid = '$owner_uid') GROUP BY feed_url 
-                                               ORDER BY subscribers DESC LIMIT 25"); */
-
-                       $result = db_query($link, "SELECT feed_url, subscribers FROM
-                               ttrss_feedbrowser_cache WHERE (SELECT COUNT(id) = 0 FROM ttrss_feeds AS tf
-                               WHERE tf.feed_url = ttrss_feedbrowser_cache.feed_url 
-                               AND owner_uid = '$owner_uid') ORDER BY subscribers DESC LIMIT 25");
-
-                       print "<ul class='browseFeedList' id='browseFeedList'>";
-
-                       $feedctr = 0;
-                       
-                       while ($line = db_fetch_assoc($result)) {
-                               $feed_url = $line["feed_url"];
-                               $subscribers = $line["subscribers"];
-
-                               $det_result = db_query($link, "SELECT site_url,title,id 
-                                       FROM ttrss_feeds WHERE feed_url = '$feed_url' LIMIT 1");
+                       $browser_search = db_escape_string($_GET["search"]);
 
-                               $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 class=\"tinyFeedIcon\"       src=\"" . ICONS_URL . 
-                                                       "/".$details["id"].".ico\">";
+                       if (array_key_exists("search", $_GET)) {
+                               $_SESSION["feed_browser_search"] = $browser_search;
                                } else {
-                                       $feed_icon = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\">";
-                               }
-
-                               $check_box = "<input onclick='toggleSelectListRow(this)' class='feedBrowseCB' 
-                                       type=\"checkbox\" id=\"FBCHK-" . $details["id"] . "\">";
-
-                               $class = ($feedctr % 2) ? "even" : "odd";
+                               $browser_search = $_SESSION["feed_browser_search"];
+                       }
 
-                               print "<li class='$class' id=\"FBROW-".$details["id"]."\">$check_box".
-                                       "$feed_icon " . $details["title"] . 
-                                       "&nbsp;<span class='subscribers'>($subscribers)</span></li>";
+                       //print "<p>".__("Showing top 25 registered feeds, sorted by popularity:")."</p>";
+                       print "<input id=\"feed_browser_search\" size=\"20\" type=\"search\"
+                               onfocus=\"javascript:disableHotkeys();\" 
+                               onblur=\"javascript:enableHotkeys();\"
+                               onchange=\"javascript:updateFeedBrowser()\" value=\"$browser_search\">
+                       <input type=\"submit\" class=\"button\" 
+                               onclick=\"javascript:updateFeedBrowser()\" value=\"".__('Search')."\">";
 
-                                       ++$feedctr;
-                       }
+                       print "<p>";
 
-                       if ($feedctr == 0) {
-                               print "<li style=\"text-align : center\"><p>".__('No feeds found.')."</p></li>";
-                               $subscribe_btn_disabled = "disabled";
-                       } else {
-                               $subscribe_btn_disabled = "";
-                       }
+                       $owner_uid = $_SESSION["uid"];
 
+                       print "<ul class='browseFeedList' id='browseFeedList'>";
+                       $subscribe_btn_disabled = print_feed_browser($link, $search, $limit) == 0 ? "disabled" : "";
                        print "</ul>";
 
                        print "<div align='center'>
                print "</p>";
 
        }
+
+       function print_feed_browser($link, $search, $limit) {
+
+                       $result = db_query($link, "SELECT feed_url, subscribers FROM
+                               ttrss_feedbrowser_cache WHERE (SELECT COUNT(id) = 0 FROM ttrss_feeds AS tf
+                               WHERE tf.feed_url = ttrss_feedbrowser_cache.feed_url 
+                               AND owner_uid = '$owner_uid') ORDER BY subscribers DESC LIMIT 25");
+
+                       $feedctr = 0;
+                       
+                       while ($line = db_fetch_assoc($result)) {
+                               $feed_url = $line["feed_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 class=\"tinyFeedIcon\"       src=\"" . ICONS_URL . 
+                                                       "/".$details["id"].".ico\">";
+                               } else {
+                                       $feed_icon = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\">";
+                               }
+
+                               $check_box = "<input onclick='toggleSelectListRow(this)' class='feedBrowseCB' 
+                                       type=\"checkbox\" id=\"FBCHK-" . $details["id"] . "\">";
+
+                               $class = ($feedctr % 2) ? "even" : "odd";
+
+                               print "<li class='$class' id=\"FBROW-".$details["id"]."\">$check_box".
+                                       "$feed_icon " . $details["title"] . 
+                                       "&nbsp;<span class='subscribers'>($subscribers)</span></li>";
+
+                                       ++$feedctr;
+                       }
+
+                       if ($feedctr == 0) {
+                               print "<li style=\"text-align : center\"><p>".__('No feeds found.')."</p></li>";
+                       }
+
+               return $feedctr;
+
+       }
 ?>
index 38dde4660b92c4462895ea5e931cbda0c619a130..611ea6c17c19697d78c0508e2ee97f037e2c8f5b 100644 (file)
--- a/prefs.js
+++ b/prefs.js
@@ -2256,3 +2256,8 @@ function batchFeedsToggleField(cb, elem, label) {
        }
 }
 
+function updateFeedBrowser() {
+       alert("FIXME");
+}
+
+
index 2b6f7f822bb3e0d0332dc84c0f9c896d4b4b1a41..ba7fbc64d1dd6c8865dcc6d0fdf4896d3d9d47fe 100644 (file)
--- a/tt-rss.js
+++ b/tt-rss.js
@@ -1422,3 +1422,31 @@ function addLabel() {
 function visitOfficialSite() {
        window.open("http://tt-rss.org/");
 }
+
+function browseFeeds(limit) {
+
+       try {
+
+               var query = "backend.php?op=pref-feeds&subop=browse";
+
+               notify_progress("Loading, please wait...", true);
+
+               new Ajax.Request(query, {
+                       onComplete: function(transport) { 
+                               infobox_callback2(transport);
+                       } });
+
+               return false;
+       } catch (e) {
+               exception_error("browseFeeds", e);
+       }
+}
+
+function updateFeedBrowser() {
+       alert("FIXME");
+}
+
+function feedBrowserSubscribe() {
+       alert("FIXME");
+
+}
index 5ab205e25ec312bfb0930c01a32d4d47f6c065c6..4ca51661571adc1a367e7aa00e781c72df6c4ed5 100644 (file)
@@ -140,7 +140,7 @@ window.onload = init;
                        href="javascript:toggleTags()"><?php echo __("tag cloud") ?></a>
                <?php if (!SINGLE_USER_MODE) { ?>
                <br/>
-               <a id="feedBrowserPrompt" href="prefs.php?tab=feedBrowser" 
+               <a id="feedBrowserPrompt" onclick="return browseFeeds()" href="#"
                        title="<?php echo __('More feeds...') ?>">+</a>
                <?php } ?>
        </div>