diff --git a/classes/dlg.php b/classes/dlg.php index 09f7cc38..3a980ec8 100644 --- a/classes/dlg.php +++ b/classes/dlg.php @@ -338,6 +338,8 @@ class Dlg extends Handler_Protected { $owner_uid = $_SESSION["uid"]; + require_once "feedbrowser.php"; + print ""; diff --git a/classes/rpc.php b/classes/rpc.php index 08efbcff..9ed05bae 100644 --- a/classes/rpc.php +++ b/classes/rpc.php @@ -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 index 00000000..002e2511 --- /dev/null +++ b/include/feedbrowser.php @@ -0,0 +1,112 @@ +"; + + $class = ($feedctr % 2) ? "even" : "odd"; + + $site_url = " + ". + htmlspecialchars($line["title"]).""; + + $feed_url = ""; + + $rv .= "
  • $check_box $feed_url $site_url". + " ($subscribers)
  • "; + + } else if ($mode == 2) { + $feed_url = htmlspecialchars($line["feed_url"]); + $site_url = htmlspecialchars($line["site_url"]); + $title = htmlspecialchars($line["title"]); + + $check_box = ""; + + $class = ($feedctr % 2) ? "even" : "odd"; + + if ($line['articles_archived'] > 0) { + $archived = sprintf(__("%d archived articles"), $line['articles_archived']); + $archived = " ($archived)"; + } else { + $archived = ''; + } + + $site_url = " + ". + htmlspecialchars($line["title"]).""; + + $feed_url = ""; + + + $rv .= "
  • ". + "$check_box $feed_url $site_url $archived
  • "; + } + + ++$feedctr; + } + + if ($feedctr == 0) { + $rv .= "
  • ".__('No feeds found.')."

  • "; + } + + return $rv; + } +?> diff --git a/include/functions.php b/include/functions.php index bf38a453..14b3af51 100644 --- a/include/functions.php +++ b/include/functions.php @@ -4798,117 +4798,6 @@ } } - 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 = ""; - - $class = ($feedctr % 2) ? "even" : "odd"; - - $site_url = " - ". - htmlspecialchars($line["title"]).""; - - $feed_url = ""; - - $rv .= "
  • $check_box $feed_url $site_url". - " ($subscribers)
  • "; - - } else if ($mode == 2) { - $feed_url = htmlspecialchars($line["feed_url"]); - $site_url = htmlspecialchars($line["site_url"]); - $title = htmlspecialchars($line["title"]); - - $check_box = ""; - - $class = ($feedctr % 2) ? "even" : "odd"; - - if ($line['articles_archived'] > 0) { - $archived = sprintf(__("%d archived articles"), $line['articles_archived']); - $archived = " ($archived)"; - } else { - $archived = ''; - } - - $site_url = " - ". - htmlspecialchars($line["title"]).""; - - $feed_url = ""; - - - $rv .= "
  • ". - "$check_box $feed_url $site_url $archived
  • "; - } - - ++$feedctr; - } - - if ($feedctr == 0) { - $rv .= "
  • ".__('No feeds found.')."

  • "; - } - - return $rv; - } - if (!function_exists('gzdecode')) { function gzdecode($string) { // no support for 2nd argument return file_get_contents('compress.zlib://data:who/cares;base64,'.