diff --git a/backend.php b/backend.php
index 634d5ae34..b04b2619b 100644
--- a/backend.php
+++ b/backend.php
@@ -43,7 +43,8 @@
$print_exec_time = false;
- if ((!$op || $op == "rpc" || $op == "rss" || $op == "view" || $op == "digestSend" ||
+ if ((!$op || $op == "rpc" || $op == "rss" || $op == "view" ||
+ $op == "digestSend" || $op == "viewfeed" ||
$op == "globalUpdateFeeds") && !$_REQUEST["noxml"]) {
header("Content-Type: application/xml; charset=utf-8");
} else {
@@ -141,160 +142,6 @@
}
- function outputArticleXML($link, $id, $feed_id, $mark_as_read = true) {
-
- print "";
- } else {
- $feed_icon = " ";
- }
-
-/* if ($line["comments"] && $line["link"] != $line["comments"]) {
- $entry_comments = "(Comments)";
- } else {
- $entry_comments = "";
- } */
-
- $num_comments = $line["num_comments"];
- $entry_comments = "";
-
- if ($num_comments > 0) {
- if ($line["comments"]) {
- $comments_url = $line["comments"];
- } else {
- $comments_url = $line["link"];
- }
- $entry_comments = "$num_comments comments";
- } else {
- if ($line["comments"] && $line["link"] != $line["comments"]) {
- $entry_comments = "comments";
- }
- }
-
- print "";
-
- print "";
-
- print "
" . $feed_icon . "
";
- print "
";
-
- if (db_num_rows($tmp_result) > 0) {
- print "
".__('Tags:')."$f_tags_str
";
- }
-
- if (get_pref($link, 'OPEN_LINKS_IN_NEW_WINDOW')) {
- $line["content"] = preg_replace("/href=/i", "target=\"_new\" href=", $line["content"]);
- }
-
- $line["content"] = sanitize_rss($line["content"]);
-
- print $line["content"] . "
";
-
- print "
";
-
- }
-
- print "]]>";
-
- }
-
if ($op == "view") {
$id = db_escape_string($_GET["id"]);
@@ -329,6 +176,10 @@
if ($op == "viewfeed") {
+ print "";
+
+ $omode = db_escape_string($_GET["omode"]);
+
$feed = db_escape_string($_GET["feed"]);
$subop = db_escape_string($_GET["subop"]);
$view_mode = db_escape_string($_GET["view_mode"]);
@@ -337,312 +188,21 @@
$next_unread_feed = db_escape_string($_GET["nuf"]);
$offset = db_escape_string($_GET["skip"]);
- if (!$offset) $offset = 0;
-
set_pref($link, "_DEFAULT_VIEW_MODE", $view_mode);
set_pref($link, "_DEFAULT_VIEW_LIMIT", $limit);
- if ($subop == "undefined") $subop = "";
+ print "";
- if ($subop == "ForceUpdate" && sprintf("%d", $feed) > 0) {
- update_generic_feed($link, $feed, $cat_view);
- }
+ print "";
+ getAllCounters($link, $omode);
+ print "";
- if ($subop == "MarkAllRead") {
- catchup_feed($link, $feed, $cat_view);
-
- if (get_pref($link, 'ON_CATCHUP_SHOW_NEXT_FEED')) {
- if ($next_unread_feed) {
- $feed = $next_unread_feed;
- }
- }
- }
-
- if ($feed_id > 0) {
- $result = db_query($link,
- "SELECT id FROM ttrss_feeds WHERE id = '$feed' LIMIT 1");
-
- if (db_num_rows($result) == 0) {
- print "".__('Feed not found.')."
";
- return;
- }
- }
-
- if (preg_match("/^-?[0-9][0-9]*$/", $feed) != false) {
-
- $result = db_query($link, "SELECT rtl_content FROM ttrss_feeds
- WHERE id = '$feed' AND owner_uid = " . $_SESSION["uid"]);
-
- if (db_num_rows($result) == 1) {
- $rtl_content = sql_bool_to_bool(db_fetch_result($result, 0, "rtl_content"));
- } else {
- $rtl_content = false;
- }
-
- if ($rtl_content) {
- $rtl_tag = "dir=\"RTL\"";
- } else {
- $rtl_tag = "";
- }
- } else {
- $rtl_tag = "";
- $rtl_content = false;
- }
-
- $script_dt_add = get_script_dt_add();
-
-/* print "
-
-
-
-
-
- "; */
-
- /// START /////////////////////////////////////////////////////////////////////////////////
-
- $search = db_escape_string($_GET["query"]);
- $search_mode = db_escape_string($_GET["search_mode"]);
- $match_on = db_escape_string($_GET["match_on"]);
-
- if (!$match_on) {
- $match_on = "both";
- }
-
- $real_offset = $offset * $limit;
-
- $qfh_ret = queryFeedHeadlines($link, $feed, $limit, $view_mode, $cat_view,
- $search, $search_mode, $match_on, false, $real_offset);
-
- $result = $qfh_ret[0];
- $feed_title = $qfh_ret[1];
- $feed_site_url = $qfh_ret[2];
- $last_error = $qfh_ret[3];
-
- /// STOP //////////////////////////////////////////////////////////////////////////////////
-
- print "";
-
- if (!$result) {
- print "
".__("Could not display feed (query failed). Please check label match syntax or local configuration.")."
";
- return;
- }
-
- print_headline_subtoolbar($link, $feed_site_url, $feed_title, false,
- $rtl_content, $feed, $cat_view, $search, $match_on, $search_mode,
- $offset, $limit);
-
- print "
";
-
- if (db_num_rows($result) > 0) {
-
-# print "\{$offset}";
-
- if (!get_pref($link, 'COMBINED_DISPLAY_MODE')) {
- print "
";
- }
-
- $lnum = 0;
-
- error_reporting (DEFAULT_ERROR_LEVEL);
-
- $num_unread = 0;
-
- while ($line = db_fetch_assoc($result)) {
-
- $class = ($lnum % 2) ? "even" : "odd";
-
- $id = $line["id"];
- $feed_id = $line["feed_id"];
-
- if ($line["last_read"] == "" &&
- ($line["unread"] != "t" && $line["unread"] != "1")) {
-
- $update_pic = "";
- } else {
- $update_pic = "";
- }
-
- if ($line["unread"] == "t" || $line["unread"] == "1") {
- $class .= "Unread";
- ++$num_unread;
- $is_unread = true;
- } else {
- $is_unread = false;
- }
-
- if ($line["marked"] == "t" || $line["marked"] == "1") {
- $marked_pic = "";
- } else {
- $marked_pic = "";
- }
-
-# $content_link = "" .
-# $line["title"] . "";
-
- $content_link = "" .
- $line["title"] . "";
-
-# $content_link = "" .
-# $line["title"] . "";
-
- if (get_pref($link, 'HEADLINES_SMART_DATE')) {
- $updated_fmt = smart_date_time(strtotime($line["updated"]));
- } else {
- $short_date = get_pref($link, 'SHORT_DATE_FORMAT');
- $updated_fmt = date($short_date, strtotime($line["updated"]));
- }
-
- if (get_pref($link, 'SHOW_CONTENT_PREVIEW')) {
- $content_preview = truncate_string(strip_tags($line["content_preview"]),
- 100);
- }
-
- $entry_author = $line["author"];
-
- if ($entry_author) {
- $entry_author = " - by $entry_author";
- }
-
- if (!get_pref($link, 'COMBINED_DISPLAY_MODE')) {
-
- print "";
-
- print "$update_pic | ";
-
- print "
-
- | ";
-
- print "$marked_pic | ";
-
- if ($line["feed_title"]) {
- print "$content_link | ";
- print "
- ".
- $line["feed_title"]." | ";
- } else {
- print "";
-
- print "" .
- $line["title"];
-
- if (get_pref($link, 'SHOW_CONTENT_PREVIEW')) {
- if ($content_preview) {
- print " - $content_preview";
- }
- }
-
- print "";
- print " | ";
- }
-
- print "$updated_fmt | ";
-
- print "
";
-
- } else {
-
- if ($is_unread) {
- $add_class = "Unread";
- } else {
- $add_class = "";
- }
-
- print "";
-
- print "";
-
- print "
" . $line["content_preview"] . "
";
-
- print "";
-
-# print "
";
-
- print "
";
-
- }
-
- ++$lnum;
- }
-
- if (!get_pref($link, 'COMBINED_DISPLAY_MODE')) {
- print "
";
- }
-
-// print_headline_subtoolbar($link,
-// "javascript:catchupPage()", "Mark page as read", true, $rtl_content);
-
-
- } else {
- print "
".__('No articles found.')."
";
- }
-
- print "
";
-
- print "
";
+ print "";
}
if ($op == "pref-feeds") {
diff --git a/feedlist.js b/feedlist.js
index f5a675772..740020e63 100644
--- a/feedlist.js
+++ b/feedlist.js
@@ -130,6 +130,14 @@ function viewfeed(feed, subop, is_cat, subop_param, skip_history, offset) {
container.innerHTML = "
" +
"Loading, please wait...
"; */
+ // for piggybacked counters
+
+ if (tagsAreDisplayed()) {
+ query = query + "&omode=lt";
+ } else {
+ query = query + "&omode=flc";
+ }
+
notify_progress("Loading, please wait...", true);
// xmlhttp.abort();
diff --git a/functions.php b/functions.php
index 6188e38d9..1f8d86383 100644
--- a/functions.php
+++ b/functions.php
@@ -2406,7 +2406,11 @@
WHERE id = '$label_id'");
$query_strategy_part = db_fetch_result($tmp_result, 0, "sql_exp");
-
+
+ if (!$query_strategy_part) {
+ return false;
+ }
+
$vfeed_query_part = "ttrss_feeds.title AS feed_title,";
} else {
$query_strategy_part = "id > 0"; // dumb
@@ -3352,4 +3356,451 @@
return vsprintf(__(array_shift($args)), $args);
}
+ function outputArticleXML($link, $id, $feed_id, $mark_as_read = true) {
+
+ print "";
+ } else {
+ $feed_icon = " ";
+ }
+
+/* if ($line["comments"] && $line["link"] != $line["comments"]) {
+ $entry_comments = "(Comments)";
+ } else {
+ $entry_comments = "";
+ } */
+
+ $num_comments = $line["num_comments"];
+ $entry_comments = "";
+
+ if ($num_comments > 0) {
+ if ($line["comments"]) {
+ $comments_url = $line["comments"];
+ } else {
+ $comments_url = $line["link"];
+ }
+ $entry_comments = "$num_comments comments";
+ } else {
+ if ($line["comments"] && $line["link"] != $line["comments"]) {
+ $entry_comments = "comments";
+ }
+ }
+
+ print "";
+
+ print "";
+
+ print "
" . $feed_icon . "
";
+ print "
";
+
+ if (db_num_rows($tmp_result) > 0) {
+ print "
".__('Tags:')."$f_tags_str
";
+ }
+
+ if (get_pref($link, 'OPEN_LINKS_IN_NEW_WINDOW')) {
+ $line["content"] = preg_replace("/href=/i", "target=\"_new\" href=", $line["content"]);
+ }
+
+ $line["content"] = sanitize_rss($line["content"]);
+
+ print $line["content"] . "
";
+
+ print "
";
+
+ }
+
+ print "]]>";
+
+ }
+
+ function outputHeadlinesList($link, $feed, $subop, $view_mode, $limit, $cat_view,
+ $next_unread_feed, $offset) {
+
+ if (!$offset) $offset = 0;
+
+ if ($subop == "undefined") $subop = "";
+
+ if ($subop == "CatchupSelected") {
+ $ids = split(",", db_escape_string($_GET["ids"]));
+ $cmode = sprintf("%d", $_GET["cmode"]);
+
+ catchupArticlesById($link, $ids, $cmode);
+ }
+
+ if ($subop == "ForceUpdate" && sprintf("%d", $feed) > 0) {
+ update_generic_feed($link, $feed, $cat_view);
+ }
+
+ if ($subop == "MarkAllRead") {
+ catchup_feed($link, $feed, $cat_view);
+
+ if (get_pref($link, 'ON_CATCHUP_SHOW_NEXT_FEED')) {
+ if ($next_unread_feed) {
+ $feed = $next_unread_feed;
+ }
+ }
+ }
+
+ if ($feed_id > 0) {
+ $result = db_query($link,
+ "SELECT id FROM ttrss_feeds WHERE id = '$feed' LIMIT 1");
+
+ if (db_num_rows($result) == 0) {
+ print "".__('Feed not found.')."
";
+ return;
+ }
+ }
+
+ if (preg_match("/^-?[0-9][0-9]*$/", $feed) != false) {
+
+ $result = db_query($link, "SELECT rtl_content FROM ttrss_feeds
+ WHERE id = '$feed' AND owner_uid = " . $_SESSION["uid"]);
+
+ if (db_num_rows($result) == 1) {
+ $rtl_content = sql_bool_to_bool(db_fetch_result($result, 0, "rtl_content"));
+ } else {
+ $rtl_content = false;
+ }
+
+ if ($rtl_content) {
+ $rtl_tag = "dir=\"RTL\"";
+ } else {
+ $rtl_tag = "";
+ }
+ } else {
+ $rtl_tag = "";
+ $rtl_content = false;
+ }
+
+ $script_dt_add = get_script_dt_add();
+
+ /// START /////////////////////////////////////////////////////////////////////////////////
+
+ $search = db_escape_string($_GET["query"]);
+ $search_mode = db_escape_string($_GET["search_mode"]);
+ $match_on = db_escape_string($_GET["match_on"]);
+
+ if (!$match_on) {
+ $match_on = "both";
+ }
+
+ $real_offset = $offset * $limit;
+
+ $qfh_ret = queryFeedHeadlines($link, $feed, $limit, $view_mode, $cat_view,
+ $search, $search_mode, $match_on, false, $real_offset);
+
+ $result = $qfh_ret[0];
+ $feed_title = $qfh_ret[1];
+ $feed_site_url = $qfh_ret[2];
+ $last_error = $qfh_ret[3];
+
+ /// STOP //////////////////////////////////////////////////////////////////////////////////
+
+ print "";
+
+ if (!$result) {
+ print "
".__("Could not display feed (query failed). Please check label match syntax or local configuration.")."
";
+ return;
+ }
+
+ print_headline_subtoolbar($link, $feed_site_url, $feed_title, false,
+ $rtl_content, $feed, $cat_view, $search, $match_on, $search_mode,
+ $offset, $limit);
+
+ print "
";
+
+ if (db_num_rows($result) > 0) {
+
+# print "\{$offset}";
+
+ if (!get_pref($link, 'COMBINED_DISPLAY_MODE')) {
+ print "
";
+ }
+
+ $lnum = 0;
+
+ error_reporting (DEFAULT_ERROR_LEVEL);
+
+ $num_unread = 0;
+
+ while ($line = db_fetch_assoc($result)) {
+
+ $class = ($lnum % 2) ? "even" : "odd";
+
+ $id = $line["id"];
+ $feed_id = $line["feed_id"];
+
+ if ($line["last_read"] == "" &&
+ ($line["unread"] != "t" && $line["unread"] != "1")) {
+
+ $update_pic = "";
+ } else {
+ $update_pic = "";
+ }
+
+ if ($line["unread"] == "t" || $line["unread"] == "1") {
+ $class .= "Unread";
+ ++$num_unread;
+ $is_unread = true;
+ } else {
+ $is_unread = false;
+ }
+
+ if ($line["marked"] == "t" || $line["marked"] == "1") {
+ $marked_pic = "";
+ } else {
+ $marked_pic = "";
+ }
+
+# $content_link = "" .
+# $line["title"] . "";
+
+ $content_link = "" .
+ $line["title"] . "";
+
+# $content_link = "" .
+# $line["title"] . "";
+
+ if (get_pref($link, 'HEADLINES_SMART_DATE')) {
+ $updated_fmt = smart_date_time(strtotime($line["updated"]));
+ } else {
+ $short_date = get_pref($link, 'SHORT_DATE_FORMAT');
+ $updated_fmt = date($short_date, strtotime($line["updated"]));
+ }
+
+ if (get_pref($link, 'SHOW_CONTENT_PREVIEW')) {
+ $content_preview = truncate_string(strip_tags($line["content_preview"]),
+ 100);
+ }
+
+ $entry_author = $line["author"];
+
+ if ($entry_author) {
+ $entry_author = " - by $entry_author";
+ }
+
+ if (!get_pref($link, 'COMBINED_DISPLAY_MODE')) {
+
+ print "";
+
+ print "$update_pic | ";
+
+ print "
+
+ | ";
+
+ print "$marked_pic | ";
+
+ if ($line["feed_title"]) {
+ print "$content_link | ";
+ print "
+ ".
+ $line["feed_title"]." | ";
+ } else {
+ print "";
+
+ print "" .
+ $line["title"];
+
+ if (get_pref($link, 'SHOW_CONTENT_PREVIEW')) {
+ if ($content_preview) {
+ print " - $content_preview";
+ }
+ }
+
+ print "";
+ print " | ";
+ }
+
+ print "$updated_fmt | ";
+
+ print "
";
+
+ } else {
+
+ if ($is_unread) {
+ $add_class = "Unread";
+ } else {
+ $add_class = "";
+ }
+
+ print "";
+
+ print "";
+
+ print "
" . $line["content_preview"] . "
";
+
+ print "";
+
+# print "
";
+
+ print "
";
+
+ }
+
+ ++$lnum;
+ }
+
+ if (!get_pref($link, 'COMBINED_DISPLAY_MODE')) {
+ print "
";
+ }
+
+// print_headline_subtoolbar($link,
+// "javascript:catchupPage()", "Mark page as read", true, $rtl_content);
+
+
+ } else {
+ print "
".__('No articles found.')."
";
+ }
+
+ print "
";
+
+ print "
";
+
+
+ }
?>
diff --git a/viewfeed.js b/viewfeed.js
index 88448f318..7435db076 100644
--- a/viewfeed.js
+++ b/viewfeed.js
@@ -40,8 +40,23 @@ function headlines_callback() {
try {
f.scrollTop = 0;
} catch (e) { };
- f.innerHTML = xmlhttp.responseText;
- update_all_counters();
+
+ if (xmlhttp.responseXML) {
+ var headlines = xmlhttp.responseXML.getElementsByTagName("headlines")[0];
+ var counters = xmlhttp.responseXML.getElementsByTagName("counters")[0];
+
+ f.innerHTML = headlines.firstChild.nodeValue;
+
+ if (counters) {
+ debug("parsing piggybacked counters: " + counters);
+ parse_counters(counters, false);
+ }
+ } else {
+ debug("headlines_callback: returned no XML object");
+ f.innerHTML = xmlhttp.responseText;
+ update_all_counters();
+ }
+
if (typeof correctPNG != 'undefined') {
correctPNG();
}