headlines: xml output mode (omode=xml)

This commit is contained in:
Andrew Dolgov 2005-11-28 14:19:54 +01:00
parent e5a99b885f
commit adccd20168
2 changed files with 130 additions and 83 deletions

View File

@ -683,6 +683,11 @@
$view_mode = $_GET["view"]; $view_mode = $_GET["view"];
$addheader = $_GET["addheader"]; $addheader = $_GET["addheader"];
$limit = $_GET["limit"]; $limit = $_GET["limit"];
$omode = $_GET["omode"];
if ($omode == "xml") {
header("Content-Type: application/xml");
}
if (!$feed) { if (!$feed) {
return; return;
@ -976,44 +981,54 @@
} }
if (!$result) { if (!$result) {
print "<div align='center'> if ($omode != "xml") {
Could not display feed (query failed). Please check match syntax or local configuration.</div>"; print "<div align='center'>
return; Could not display feed (query failed). Please check label match syntax or local configuration.</div>";
} return;
} else {
print "<error error-code=\"8\"/>";
}
}
if (db_num_rows($result) > 0) { if (db_num_rows($result) > 0) {
print "<table class=\"headlinesSubToolbar\" if ($omode != "xml") {
width=\"100%\" cellspacing=\"0\" cellpadding=\"0\"><tr>";
print "<table class=\"headlinesSubToolbar\"
print "<td class=\"headlineActions\"> width=\"100%\" cellspacing=\"0\" cellpadding=\"0\"><tr>";
Select:
<a href=\"javascript:selectTableRowsByIdPrefix('headlinesList', print "<td class=\"headlineActions\">
'RROW-', 'RCHK-', true)\">All</a>, Select:
<a href=\"javascript:selectTableRowsByIdPrefix('headlinesList', <a href=\"javascript:selectTableRowsByIdPrefix('headlinesList',
'RROW-', 'RCHK-', true, 'Unread')\">Unread</a>, 'RROW-', 'RCHK-', true)\">All</a>,
<a href=\"javascript:selectTableRowsByIdPrefix('headlinesList', <a href=\"javascript:selectTableRowsByIdPrefix('headlinesList',
'RROW-', 'RCHK-', false)\">None</a> 'RROW-', 'RCHK-', true, 'Unread')\">Unread</a>,
&nbsp;&nbsp; <a href=\"javascript:selectTableRowsByIdPrefix('headlinesList',
Toggle: <a href=\"javascript:toggleUnread()\">Unread</a>, 'RROW-', 'RCHK-', false)\">None</a>
<a href=\"javascript:toggleStarred()\">Starred</a>"; &nbsp;&nbsp;
Toggle: <a href=\"javascript:toggleUnread()\">Unread</a>,
print "</td>"; <a href=\"javascript:toggleStarred()\">Starred</a>";
print "<td class=\"headlineTitle\">"; print "</td>";
if ($feed_site_url) { print "<td class=\"headlineTitle\">";
print "<a target=\"_blank\" href=\"$feed_site_url\">$feed_title</a>";
if ($feed_site_url) {
print "<a target=\"_blank\" href=\"$feed_site_url\">$feed_title</a>";
} else {
print $feed_title;
}
print "</td>";
print "</tr></table>";
print "<table class=\"headlinesList\" id=\"headlinesList\"
cellspacing=\"0\" width=\"100%\">";
} else { } else {
print $feed_title; print "<headlines feed=\"$feed\" title=\"$feed_title\" site_url=\"$feed_site_url\">";
} }
print "</td>";
print "</tr></table>";
print "<table class=\"headlinesList\" id=\"headlinesList\"
cellspacing=\"0\" width=\"100%\">";
$lnum = 0; $lnum = 0;
@ -1022,7 +1037,7 @@
$num_unread = 0; $num_unread = 0;
while ($line = db_fetch_assoc($result)) { while ($line = db_fetch_assoc($result)) {
$class = ($lnum % 2) ? "even" : "odd"; $class = ($lnum % 2) ? "even" : "odd";
$id = $line["id"]; $id = $line["id"];
@ -1041,6 +1056,9 @@
if ($line["unread"] == "t" || $line["unread"] == "1") { if ($line["unread"] == "t" || $line["unread"] == "1") {
$class .= "Unread"; $class .= "Unread";
++$num_unread; ++$num_unread;
$is_unread = 'true';
} else {
$is_unread = 'false';
} }
if ($line["marked"] == "t" || $line["marked"] == "1") { if ($line["marked"] == "t" || $line["marked"] == "1") {
@ -1053,72 +1071,99 @@
$content_link = "<a id=\"FTITLE-$id\" href=\"javascript:view($id,$feed_id);\">" . $content_link = "<a id=\"FTITLE-$id\" href=\"javascript:view($id,$feed_id);\">" .
$line["title"] . "</a>"; $line["title"] . "</a>";
print "<tr class='$class' id='RROW-$id'>";
// onclick=\"javascript:view($id,$feed_id)\">
print "<td class='hlUpdatePic'>$update_pic</td>";
print "<td class='hlSelectRow'>
<input type=\"checkbox\" onclick=\"toggleSelectRow(this)\"
class=\"feedCheckBox\" id=\"RCHK-$id\">
</td>";
print "<td class='hlMarkedPic'>$marked_pic</td>";
if ($line["feed_title"]) {
print "<td class='hlContent'>$content_link</td>";
print "<td class='hlFeed'>
<a href='javascript:viewfeed($feed_id)'>".$line["feed_title"]."</a></td>";
} else {
print "<td class='hlContent'>";
print "<a id=\"FTITLE-$id\" href=\"javascript:view($id,$feed_id);\">" .
$line["title"];
if (get_pref($link, 'SHOW_CONTENT_PREVIEW')) {
$content_preview = truncate_string(strip_tags($line["content_preview"]),
101);
if ($content_preview) {
print "<span class=\"contentPreview\"> - $content_preview</span>";
}
}
print "</a>";
print "</td>";
}
if (get_pref($link, 'HEADLINES_SMART_DATE')) { if (get_pref($link, 'HEADLINES_SMART_DATE')) {
$updated_fmt = smart_date_time(strtotime($line["updated"])); $updated_fmt = smart_date_time(strtotime($line["updated"]));
} else { } else {
$short_date = get_pref($link, 'SHORT_DATE_FORMAT'); $short_date = get_pref($link, 'SHORT_DATE_FORMAT');
$updated_fmt = date($short_date, strtotime($line["updated"])); $updated_fmt = date($short_date, strtotime($line["updated"]));
} }
if (get_pref($link, 'SHOW_CONTENT_PREVIEW')) {
$content_preview = truncate_string(strip_tags($line["content_preview"]), 101);
}
if ($omode != "xml") {
print "<tr class='$class' id='RROW-$id'>";
// onclick=\"javascript:view($id,$feed_id)\">
print "<td class='hlUpdatePic'>$update_pic</td>";
print "<td class='hlSelectRow'>
<input type=\"checkbox\" onclick=\"toggleSelectRow(this)\"
class=\"feedCheckBox\" id=\"RCHK-$id\">
</td>";
print "<td class='hlMarkedPic'>$marked_pic</td>";
if ($line["feed_title"]) {
print "<td class='hlContent'>$content_link</td>";
print "<td class='hlFeed'>
<a href='javascript:viewfeed($feed_id)'>".$line["feed_title"]."</a></td>";
} else {
print "<td class='hlContent'>";
print "<a id=\"FTITLE-$id\" href=\"javascript:view($id,$feed_id);\">" .
$line["title"];
if (get_pref($link, 'SHOW_CONTENT_PREVIEW')) {
if ($content_preview) {
print "<span class=\"contentPreview\"> - $content_preview</span>";
}
}
print "</a>";
print "</td>";
}
print "<td class=\"hlUpdated\"><nobr>$updated_fmt&nbsp;</nobr></td>";
print "</tr>";
} else {
print "<entry unread='$is_unread' id='$id'>";
print "<title><![CDATA[" . $line["title"] . "]]></title>";
print "<link>" . $line["link"] . "</link>";
print "<updated>$updated_fmt</updated>";
if ($content_preview) {
print "<preview><![CDATA[ $content_preview ]]></preview>";
}
if ($line["feed_title"]) {
print "<feed id='$feed_id'><![CDATA[" . $line["feed_title"] . "]]></feed>";
}
print "</entry>";
}
print "<td class=\"hlUpdated\"><nobr>$updated_fmt&nbsp;</nobr></td>";
print "</tr>";
++$lnum; ++$lnum;
} }
print "</table>"; if ($omode != "xml") {
print "</table>";
} else {
print "</headlines>";
}
} else { } else {
print "<div width='100%' align='center'>No articles found.</div>"; print "<div width='100%' align='center'>No articles found.</div>";
} }
print "<script type=\"text/javascript\"> if ($omode != "xml") {
document.onkeydown = hotkey_handler;
update_all_counters('$feed');
</script>";
if ($addheader) { print "<script type=\"text/javascript\">
print "</body></html>"; document.onkeydown = hotkey_handler;
update_all_counters('$feed');
</script>";
if ($addheader) {
print "</body></html>";
}
} }
} }
if ($op == "pref-rpc") { if ($op == "pref-rpc") {

View File

@ -26,6 +26,8 @@
$ERRORS[7] = "No operation to perform."; $ERRORS[7] = "No operation to perform.";
$ERRORS[8] = "Could not display feed: query failed. Please check label match syntax or local configuration.";
?> ?>
<html> <html>