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"];
$addheader = $_GET["addheader"];
$limit = $_GET["limit"];
$omode = $_GET["omode"];
if ($omode == "xml") {
header("Content-Type: application/xml");
}
if (!$feed) {
return;
@ -976,13 +981,20 @@
}
if (!$result) {
if ($omode != "xml") {
print "<div align='center'>
Could not display feed (query failed). Please check match syntax or local configuration.</div>";
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 ($omode != "xml") {
print "<table class=\"headlinesSubToolbar\"
width=\"100%\" cellspacing=\"0\" cellpadding=\"0\"><tr>";
@ -1011,10 +1023,13 @@
print "</td>";
print "</tr></table>";
print "<table class=\"headlinesList\" id=\"headlinesList\"
cellspacing=\"0\" width=\"100%\">";
} else {
print "<headlines feed=\"$feed\" title=\"$feed_title\" site_url=\"$feed_site_url\">";
}
$lnum = 0;
error_reporting (DEFAULT_ERROR_LEVEL);
@ -1041,6 +1056,9 @@
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") {
@ -1054,6 +1072,19 @@
$content_link = "<a id=\"FTITLE-$id\" href=\"javascript:view($id,$feed_id);\">" .
$line["title"] . "</a>";
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"]), 101);
}
if ($omode != "xml") {
print "<tr class='$class' id='RROW-$id'>";
// onclick=\"javascript:view($id,$feed_id)\">
@ -1078,9 +1109,6 @@
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>";
}
@ -1090,26 +1118,43 @@
print "</td>";
}
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"]));
}
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>";
}
++$lnum;
}
if ($omode != "xml") {
print "</table>";
} else {
print "</headlines>";
}
} else {
print "<div width='100%' align='center'>No articles found.</div>";
}
if ($omode != "xml") {
print "<script type=\"text/javascript\">
document.onkeydown = hotkey_handler;
update_all_counters('$feed');
@ -1118,7 +1163,7 @@
if ($addheader) {
print "</body></html>";
}
}
}
if ($op == "pref-rpc") {

View File

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