]> git.wh0rd.org Git - tt-rss.git/commitdiff
split feedbrowser into a separate file
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Mon, 24 Dec 2012 11:58:29 +0000 (15:58 +0400)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Mon, 24 Dec 2012 11:58:29 +0000 (15:58 +0400)
classes/dlg.php
classes/rpc.php
include/feedbrowser.php [new file with mode: 0644]
include/functions.php

index 09f7cc387222c3d0824524d55fdb7be1e9d8880a..3a980ec8bb7de006c477c680190b818e8d209a4a 100644 (file)
@@ -338,6 +338,8 @@ class Dlg extends Handler_Protected {
 
                $owner_uid = $_SESSION["uid"];
 
+               require_once "feedbrowser.php";
+
                print "<ul class='browseFeedList' id='browseFeedList'>";
                print make_feed_browser($this->link, $search, 25);
                print "</ul>";
index 08efbcffc58d8749ba528bbf16eb210cf5c522e4..9ed05bae74225f587ecbd218fc77b8a94948ca0e 100644 (file)
@@ -457,6 +457,8 @@ class RPC extends Handler_Protected {
                $limit = db_escape_string($_REQUEST["limit"]);
                $mode = (int) db_escape_string($_REQUEST["mode"]);
 
+               require_once "feedbrowser.php";
+
                print json_encode(array("content" =>
                        make_feed_browser($this->link, $search, $limit, $mode),
                                "mode" => $mode));
diff --git a/include/feedbrowser.php b/include/feedbrowser.php
new file mode 100644 (file)
index 0000000..002e251
--- /dev/null
@@ -0,0 +1,112 @@
+<?
+       function make_feed_browser($link, $search, $limit, $mode = 1) {
+
+               $owner_uid = $_SESSION["uid"];
+               $rv = '';
+
+               if ($search) {
+                       $search_qpart = "AND (UPPER(feed_url) LIKE UPPER('%$search%') OR
+                                               UPPER(title) LIKE UPPER('%$search%'))";
+               } else {
+                       $search_qpart = "";
+               }
+
+               if ($mode == 1) {
+                       /* $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') $search_qpart
+                       ORDER BY subscribers DESC LIMIT $limit"); */
+
+                       $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, site_url, title ORDER BY subscribers DESC LIMIT $limit");
+
+               } else if ($mode == 2) {
+                       $result = db_query($link, "SELECT *,
+                                               (SELECT COUNT(*) FROM ttrss_user_entries WHERE
+                                                       orig_feed_id = ttrss_archived_feeds.id) AS articles_archived
+                                               FROM
+                                                       ttrss_archived_feeds
+                                               WHERE
+                                               (SELECT COUNT(*) FROM ttrss_feeds
+                                                       WHERE ttrss_feeds.feed_url = ttrss_archived_feeds.feed_url AND
+                                                               owner_uid = '$owner_uid') = 0   AND
+                                               owner_uid = '$owner_uid' $search_qpart
+                                               ORDER BY id DESC LIMIT $limit");
+               }
+
+               $feedctr = 0;
+
+               while ($line = db_fetch_assoc($result)) {
+
+                       if ($mode == 1) {
+
+                               $feed_url = htmlspecialchars($line["feed_url"]);
+                               $site_url = htmlspecialchars($line["site_url"]);
+                               $subscribers = $line["subscribers"];
+
+                               $check_box = "<input onclick='toggleSelectListRow2(this)'
+                                                       dojoType=\"dijit.form.CheckBox\"
+                                                       type=\"checkbox\" \">";
+
+                               $class = ($feedctr % 2) ? "even" : "odd";
+
+                               $site_url = "<a target=\"_blank\"
+                                                       href=\"$site_url\">
+                                                       <span class=\"fb_feedTitle\">".
+                               htmlspecialchars($line["title"])."</span></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>$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"]);
+
+                               $check_box = "<input onclick='toggleSelectListRow2(this)' dojoType=\"dijit.form.CheckBox\"
+                                                       type=\"checkbox\">";
+
+                               $class = ($feedctr % 2) ? "even" : "odd";
+
+                               if ($line['articles_archived'] > 0) {
+                                       $archived = sprintf(__("%d archived articles"), $line['articles_archived']);
+                                       $archived = "&nbsp;<span class='subscribers'>($archived)</span>";
+                               } else {
+                                       $archived = '';
+                               }
+
+                               $site_url = "<a target=\"_blank\"
+                                                       href=\"$site_url\">
+                                                       <span class=\"fb_feedTitle\">".
+                               htmlspecialchars($line["title"])."</span></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 id=\"FBROW-".$line["id"]."\">".
+                                                       "$check_box $feed_url $site_url $archived</li>";
+                       }
+
+                       ++$feedctr;
+               }
+
+               if ($feedctr == 0) {
+                       $rv .= "<li style=\"text-align : center\"><p>".__('No feeds found.')."</p></li>";
+               }
+
+               return $rv;
+       }
+?>
index bf38a453832fcef59ff2f53fc610604b1c54f87b..14b3af517848dc33702fa580345b3cfbadf2ea6d 100644 (file)
                }
        }
 
-       function make_feed_browser($link, $search, $limit, $mode = 1) {
-
-               $owner_uid = $_SESSION["uid"];
-               $rv = '';
-
-               if ($search) {
-                       $search_qpart = "AND (UPPER(feed_url) LIKE UPPER('%$search%') OR
-                                               UPPER(title) LIKE UPPER('%$search%'))";
-               } else {
-                       $search_qpart = "";
-               }
-
-               if ($mode == 1) {
-                       /* $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') $search_qpart
-                       ORDER BY subscribers DESC LIMIT $limit"); */
-
-                       $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, site_url, title ORDER BY subscribers DESC LIMIT $limit");
-
-               } else if ($mode == 2) {
-                       $result = db_query($link, "SELECT *,
-                                               (SELECT COUNT(*) FROM ttrss_user_entries WHERE
-                                                       orig_feed_id = ttrss_archived_feeds.id) AS articles_archived
-                                               FROM
-                                                       ttrss_archived_feeds
-                                               WHERE
-                                               (SELECT COUNT(*) FROM ttrss_feeds
-                                                       WHERE ttrss_feeds.feed_url = ttrss_archived_feeds.feed_url AND
-                                                               owner_uid = '$owner_uid') = 0   AND
-                                               owner_uid = '$owner_uid' $search_qpart
-                                               ORDER BY id DESC LIMIT $limit");
-               }
-
-               $feedctr = 0;
-
-               while ($line = db_fetch_assoc($result)) {
-
-                       if ($mode == 1) {
-
-                               $feed_url = htmlspecialchars($line["feed_url"]);
-                               $site_url = htmlspecialchars($line["site_url"]);
-                               $subscribers = $line["subscribers"];
-
-                               $check_box = "<input onclick='toggleSelectListRow2(this)'
-                                                       dojoType=\"dijit.form.CheckBox\"
-                                                       type=\"checkbox\" \">";
-
-                               $class = ($feedctr % 2) ? "even" : "odd";
-
-                               $site_url = "<a target=\"_blank\"
-                                                       href=\"$site_url\">
-                                                       <span class=\"fb_feedTitle\">".
-                               htmlspecialchars($line["title"])."</span></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>$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"]);
-
-                               $check_box = "<input onclick='toggleSelectListRow2(this)' dojoType=\"dijit.form.CheckBox\"
-                                                       type=\"checkbox\">";
-
-                               $class = ($feedctr % 2) ? "even" : "odd";
-
-                               if ($line['articles_archived'] > 0) {
-                                       $archived = sprintf(__("%d archived articles"), $line['articles_archived']);
-                                       $archived = "&nbsp;<span class='subscribers'>($archived)</span>";
-                               } else {
-                                       $archived = '';
-                               }
-
-                               $site_url = "<a target=\"_blank\"
-                                                       href=\"$site_url\">
-                                                       <span class=\"fb_feedTitle\">".
-                               htmlspecialchars($line["title"])."</span></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 id=\"FBROW-".$line["id"]."\">".
-                                                       "$check_box $feed_url $site_url $archived</li>";
-                       }
-
-                       ++$feedctr;
-               }
-
-               if ($feedctr == 0) {
-                       $rv .= "<li style=\"text-align : center\"><p>".__('No feeds found.')."</p></li>";
-               }
-
-               return $rv;
-       }
-
        if (!function_exists('gzdecode')) {
                function gzdecode($string) { // no support for 2nd argument
                        return file_get_contents('compress.zlib://data:who/cares;base64,'.