diff --git a/backend.php b/backend.php
index e9be94504..57fd24a4f 100644
--- a/backend.php
+++ b/backend.php
@@ -24,7 +24,19 @@
";
-
+
+ print "";
+
+ /* virtual feeds */
+
+ $result = db_query($link, "SELECT count(id) as num_starred
+ FROM ttrss_entries WHERE marked = true");
+ $num_starred = db_fetch_result($result, 0, "num_starred");
+
+ printFeedEntry(-1, "odd", "Starred items", $num_starred, "images/mark_set.png");
+
+ print "
";
+
$result = db_query($link, "SELECT *,
(SELECT count(id) FROM ttrss_entries
WHERE feed_id = ttrss_feeds.id) AS total,
@@ -34,9 +46,7 @@
$actid = $_GET["actid"];
-// print "";
print "$total_unread
";
-// print "$actid
";
}
@@ -284,27 +248,28 @@
";
}
- $result = db_query($link,
- "SELECT *,SUBSTRING(last_updated,1,16) as last_updated_s
- FROM ttrss_feeds WHERE id = '$feed'");
+ if ($feed >= 0) {
+
+ $result = db_query($link,
+ "SELECT *,SUBSTRING(last_updated,1,16) as last_updated_s
+ FROM ttrss_feeds WHERE id = '$feed'");
+
+ if ($result) {
- if ($result) {
-
- $line = db_fetch_assoc($result);
-
- update_rss_feed($link, $line["feed_url"], $feed);
-
- if ($subop == "MarkAllRead") {
-
- db_query($link, "UPDATE ttrss_entries SET unread = false,last_read = NOW()
- WHERE feed_id = '$feed'");
+ $line = db_fetch_assoc($result);
+
+ update_rss_feed($link, $line["feed_url"], $feed);
+
+ if ($subop == "MarkAllRead") {
+
+ db_query($link, "UPDATE ttrss_entries SET unread = false,last_read = NOW()
+ WHERE feed_id = '$feed'");
+ }
}
}
print "";
- $feed_last_updated = "Updated: " . $line["last_updated"];
-
$search = $_GET["search"];
if ($search) {
@@ -324,12 +289,12 @@
$view_query_part = " unread = true AND ";
}
- $result = db_query($link, "SELECT count(id) AS total_entries
+/* $result = db_query($link, "SELECT count(id) AS total_entries
FROM ttrss_entries WHERE
$search_query_part
feed_id = '$feed'");
- $total_entries = db_fetch_result($result, 0, "total_entries");
+ $total_entries = db_fetch_result($result, 0, "total_entries"); */
/* $result = db_query("SELECT count(id) AS unread_entries
FROM ttrss_entries WHERE
@@ -343,16 +308,29 @@
$limit_query_part = "LIMIT " . $limit;
}
+ $vfeed_query_part = "";
+
+ if ($feed >= 0) {
+ $query_strategy_part = "feed_id = '$feed'";
+ } else if ($feed == -1) {
+ $query_strategy_part = "marked = true";
+ $vfeed_query_part = "(SELECT title FROM ttrss_feeds WHERE
+ id = feed_id) as feed_title,";
+ } else {
+ $query_strategy_part = "id => 0"; // dumb
+ }
+
$result = db_query($link, "SELECT
id,title,updated,unread,feed_id,marked,link,last_read,
SUBSTRING(last_read,1,19) as last_read_noms,
+ $vfeed_query_part
SUBSTRING(updated,1,19) as updated_noms
FROM
ttrss_entries
WHERE
$search_query_part
$view_query_part
- feed_id = '$feed' ORDER BY updated DESC
+ $query_strategy_part ORDER BY updated DESC
$limit_query_part");
$lnum = 0;
@@ -408,7 +386,13 @@
print "
".$line["updated"]." | ";
- print "$content_link | ";
+
+ if ($line["feed_title"]) {
+ print "$content_link | ";
+ print "".$line["feed_title"]." | ";
+ } else {
+ print "$content_link | ";
+ }
print "";
@@ -419,20 +403,26 @@
print "No entries found. |
";
}
- while ($lnum < HEADLINES_PER_PAGE) {
+/* while ($lnum < HEADLINES_PER_PAGE) {
++$lnum;
print " |
";
- }
+ } */
print "
";
- $result = db_query($link, "SELECT id, (SELECT count(id) FROM ttrss_entries
- WHERE feed_id = ttrss_feeds.id) AS total,
- (SELECT count(id) FROM ttrss_entries
- WHERE feed_id = ttrss_feeds.id AND unread = true) as unread
- FROM ttrss_feeds WHERE id = '$feed'");
+ if ($feed >= 0) {
+
+ $result = db_query($link, "SELECT count(id) as unread FROM ttrss_entries
+ WHERE feed_id = ttrss_feeds.id AND $query_strategy_part
+ AND unread = true");
+ } else if ($feed == -1) {
+ $result = db_query($link, "SELECT count(id) as unread FROM ttrss_entries
+ WHERE $query_strategy_part");
+
+ } else {
+ print "[viewfeed] feed type not implemented
";
+ }
- $total = db_fetch_result($result, 0, "total");
$unread = db_fetch_result($result, 0, "unread");
// update unread/total counters and status for active feed in the feedlist
@@ -452,7 +442,7 @@
var feedctr = p_document.getElementById(\"FEEDCTR-\" + $feed);
- if ($unread > 0 && !feedr.className.match(\"Unread\")) {
+ if ($unread > 0 && $feed != -1 && !feedr.className.match(\"Unread\")) {
feedr.className = feedr.className + \"Unread\";
feedctr.className = '';
} else if ($unread <= 0) {
diff --git a/functions.php b/functions.php
index 5736c016e..c032364d7 100644
--- a/functions.php
+++ b/functions.php
@@ -320,4 +320,34 @@
return false;
}
+ function printFeedEntry($feed_id, $class, $feed_title, $unread, $icon_file) {
+
+ if (file_exists($icon_file) && filesize($icon_file) > 0) {
+ $feed_icon = "";
+ } else {
+ $feed_icon = "";
+ }
+
+ $feed = "$feed_title";
+
+ print "- ";
+ if (ENABLE_FEED_ICONS) {
+ print "$feed_icon";
+ }
+
+ print "$feed";
+
+ if ($unread != 0) {
+ $fctr_class = "";
+ } else {
+ $fctr_class = "class=\"invisible\"";
+ }
+
+ print "
+ ($unread)";
+
+ print "
";
+
+ }
+
?>
diff --git a/viewfeed.js b/viewfeed.js
index 35bef67b7..5bcb38124 100644
--- a/viewfeed.js
+++ b/viewfeed.js
@@ -94,16 +94,36 @@ function toggleMark(id, toggle) {
var query = "backend.php?op=rpc&id=" + id + "&subop=mark";
+ var f_doc = parent.frames["feeds-frame"].document;
+
+ var vfeedu = f_doc.getElementById("FEEDU--1");
+
if (toggle == true) {
mark_img.src = "images/mark_set.png";
mark_img.alt = "Reset mark";
mark_img.setAttribute('onclick', 'javascript:toggleMark('+id+', false)');
query = query + "&mark=1";
+
+ if (vfeedu) vfeedu.innerHTML = (+vfeedu.innerHTML) + 1;
+
} else {
mark_img.src = "images/mark_unset.png";
mark_img.alt = "Set mark";
mark_img.setAttribute('onclick', 'javascript:toggleMark('+id+', true)');
query = query + "&mark=0";
+
+ if (vfeedu) vfeedu.innerHTML = (+vfeedu.innerHTML) - 1;
+
+ }
+
+ var vfeedctr = f_doc.getElementById("FEEDCTR--1");
+
+ if (vfeedu && vfeedctr) {
+ if ((+vfeedu.innerHTML) > 0) {
+ vfeedctr.className = "odd";
+ } else {
+ vfeedctr.className = "invisible";
+ }
}
xmlhttp_rpc.open("GET", query, true);