Starred vfolder

master
Andrew Dolgov 19 years ago
parent 3fa371a071
commit 254e0e4b82

@ -25,6 +25,18 @@
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"> <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">
</head><body>"; </head><body>";
print "<ul class=\"feedList\" id=\"feedList\">";
/* 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 "<li><hr></li>";
$result = db_query($link, "SELECT *, $result = db_query($link, "SELECT *,
(SELECT count(id) FROM ttrss_entries (SELECT count(id) FROM ttrss_entries
WHERE feed_id = ttrss_feeds.id) AS total, WHERE feed_id = ttrss_feeds.id) AS total,
@ -34,9 +46,7 @@
$actid = $_GET["actid"]; $actid = $_GET["actid"];
// print "<table width=\"100%\" class=\"feedsList\" id=\"feedsList\">"; /* real feeds */
print "<ul class=\"feedList\" id=\"feedList\">";
$lnum = 0; $lnum = 0;
@ -64,52 +74,7 @@
$total_unread += $unread; $total_unread += $unread;
// print "<tr class=\"$class\" id=\"FEEDR-$feed_id\">"; printFeedEntry($feed_id, $class, $feed, $unread, "icons/$feed_id.ico");
$icon_file = ICONS_DIR . "/$feed_id.ico";
if ($subop != "piggie") {
if (file_exists($icon_file) && filesize($icon_file) > 0) {
$feed_icon = "<img src=\"" . ICONS_URL . "/$feed_id.ico\">";
} else {
$feed_icon = "<img src=\"images/blank_icon.gif\">";
}
} else {
$feed_icon = "<img width=\"16\" height=\"16\"
src=\"http://madoka.spb.ru/stuff/fox/tiny_piggie.png\">";
}
$feed = "<a href=\"javascript:viewfeed($feed_id, 0);\">$feed</a>";
/* if (ENABLE_FEED_ICONS) {
print "<td>$feed_icon</td>";
}
print "<td id=\"FEEDN-$feed_id\">$feed</td>";
print "<td>";
print "<span id=\"FEEDU-$feed_id\">$unread</span>&nbsp;/&nbsp;";
print "<span id=\"FEEDT-$feed_id\">$total</span>";
print "</td>";
print "</tr>"; */
print "<li id=\"FEEDR-$feed_id\" class=\"$class\">";
if (ENABLE_FEED_ICONS) {
print "$feed_icon";
}
print "<span id=\"FEEDN-$feed_id\">$feed</span>";
if ($unread != 0) {
$fctr_class = "";
} else {
$fctr_class = "class=\"invisible\"";
}
print "<span $fctr_class id=\"FEEDCTR-$feed_id\">
(<span id=\"FEEDU-$feed_id\">$unread</span>)</span>";
print "</li>";
++$lnum; ++$lnum;
} }
@ -117,7 +82,6 @@
print "</table>"; print "</table>";
print "<div class=\"invisible\" id=\"FEEDTU\">$total_unread</div>"; print "<div class=\"invisible\" id=\"FEEDTU\">$total_unread</div>";
// print "<div class=\"invisible\" id=\"ACTFEEDID\">$actid</div>";
} }
@ -284,6 +248,8 @@
</head><body>"; </head><body>";
} }
if ($feed >= 0) {
$result = db_query($link, $result = db_query($link,
"SELECT *,SUBSTRING(last_updated,1,16) as last_updated_s "SELECT *,SUBSTRING(last_updated,1,16) as last_updated_s
FROM ttrss_feeds WHERE id = '$feed'"); FROM ttrss_feeds WHERE id = '$feed'");
@ -300,11 +266,10 @@
WHERE feed_id = '$feed'"); WHERE feed_id = '$feed'");
} }
} }
}
print "<table class=\"headlinesList\" id=\"headlinesList\" width=\"100%\">"; print "<table class=\"headlinesList\" id=\"headlinesList\" width=\"100%\">";
$feed_last_updated = "Updated: " . $line["last_updated"];
$search = $_GET["search"]; $search = $_GET["search"];
if ($search) { if ($search) {
@ -324,12 +289,12 @@
$view_query_part = " unread = true AND "; $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 FROM ttrss_entries WHERE
$search_query_part $search_query_part
feed_id = '$feed'"); 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 /* $result = db_query("SELECT count(id) AS unread_entries
FROM ttrss_entries WHERE FROM ttrss_entries WHERE
@ -343,16 +308,29 @@
$limit_query_part = "LIMIT " . $limit; $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 $result = db_query($link, "SELECT
id,title,updated,unread,feed_id,marked,link,last_read, id,title,updated,unread,feed_id,marked,link,last_read,
SUBSTRING(last_read,1,19) as last_read_noms, SUBSTRING(last_read,1,19) as last_read_noms,
$vfeed_query_part
SUBSTRING(updated,1,19) as updated_noms SUBSTRING(updated,1,19) as updated_noms
FROM FROM
ttrss_entries ttrss_entries
WHERE WHERE
$search_query_part $search_query_part
$view_query_part $view_query_part
feed_id = '$feed' ORDER BY updated DESC $query_strategy_part ORDER BY updated DESC
$limit_query_part"); $limit_query_part");
$lnum = 0; $lnum = 0;
@ -408,7 +386,13 @@
print "<td width='25%'> print "<td width='25%'>
<a href=\"javascript:view($id,$feed_id);\">".$line["updated"]."</a></td>"; <a href=\"javascript:view($id,$feed_id);\">".$line["updated"]."</a></td>";
if ($line["feed_title"]) {
print "<td width='50%'>$content_link</td>";
print "<td width='20%'>".$line["feed_title"]."</td>";
} else {
print "<td width='70%'>$content_link</td>"; print "<td width='70%'>$content_link</td>";
}
print "</tr>"; print "</tr>";
@ -419,20 +403,26 @@
print "<tr><td align='center'>No entries found.</td></tr>"; print "<tr><td align='center'>No entries found.</td></tr>";
} }
while ($lnum < HEADLINES_PER_PAGE) { /* while ($lnum < HEADLINES_PER_PAGE) {
++$lnum; ++$lnum;
print "<tr><td>&nbsp;</td></tr>"; print "<tr><td>&nbsp;</td></tr>";
} } */
print "</table>"; print "</table>";
$result = db_query($link, "SELECT id, (SELECT count(id) FROM ttrss_entries if ($feed >= 0) {
WHERE feed_id = ttrss_feeds.id) AS total,
(SELECT count(id) FROM ttrss_entries $result = db_query($link, "SELECT count(id) as unread FROM ttrss_entries
WHERE feed_id = ttrss_feeds.id AND unread = true) as unread WHERE feed_id = ttrss_feeds.id AND $query_strategy_part
FROM ttrss_feeds WHERE id = '$feed'"); 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<br>";
}
$total = db_fetch_result($result, 0, "total");
$unread = db_fetch_result($result, 0, "unread"); $unread = db_fetch_result($result, 0, "unread");
// update unread/total counters and status for active feed in the feedlist // update unread/total counters and status for active feed in the feedlist
@ -452,7 +442,7 @@
var feedctr = p_document.getElementById(\"FEEDCTR-\" + $feed); 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\"; feedr.className = feedr.className + \"Unread\";
feedctr.className = ''; feedctr.className = '';
} else if ($unread <= 0) { } else if ($unread <= 0) {

@ -320,4 +320,34 @@
return false; return false;
} }
function printFeedEntry($feed_id, $class, $feed_title, $unread, $icon_file) {
if (file_exists($icon_file) && filesize($icon_file) > 0) {
$feed_icon = "<img src=\"$icon_file\">";
} else {
$feed_icon = "<img src=\"images/blank_icon.gif\">";
}
$feed = "<a href=\"javascript:viewfeed($feed_id, 0);\">$feed_title</a>";
print "<li id=\"FEEDR-$feed_id\" class=\"$class\">";
if (ENABLE_FEED_ICONS) {
print "$feed_icon";
}
print "<span id=\"FEEDN-$feed_id\">$feed</span>";
if ($unread != 0) {
$fctr_class = "";
} else {
$fctr_class = "class=\"invisible\"";
}
print "<span $fctr_class id=\"FEEDCTR-$feed_id\">
(<span id=\"FEEDU-$feed_id\">$unread</span>)</span>";
print "</li>";
}
?> ?>

@ -94,16 +94,36 @@ function toggleMark(id, toggle) {
var query = "backend.php?op=rpc&id=" + id + "&subop=mark"; 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) { if (toggle == true) {
mark_img.src = "images/mark_set.png"; mark_img.src = "images/mark_set.png";
mark_img.alt = "Reset mark"; mark_img.alt = "Reset mark";
mark_img.setAttribute('onclick', 'javascript:toggleMark('+id+', false)'); mark_img.setAttribute('onclick', 'javascript:toggleMark('+id+', false)');
query = query + "&mark=1"; query = query + "&mark=1";
if (vfeedu) vfeedu.innerHTML = (+vfeedu.innerHTML) + 1;
} else { } else {
mark_img.src = "images/mark_unset.png"; mark_img.src = "images/mark_unset.png";
mark_img.alt = "Set mark"; mark_img.alt = "Set mark";
mark_img.setAttribute('onclick', 'javascript:toggleMark('+id+', true)'); mark_img.setAttribute('onclick', 'javascript:toggleMark('+id+', true)');
query = query + "&mark=0"; 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); xmlhttp_rpc.open("GET", query, true);

Loading…
Cancel
Save