From adccd201687825e49a863548172df36dcfba6ef6 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 28 Nov 2005 14:19:54 +0100 Subject: [PATCH] headlines: xml output mode (omode=xml) --- backend.php | 211 +++++++++++++++++++++++++++++++--------------------- error.php | 2 + 2 files changed, 130 insertions(+), 83 deletions(-) diff --git a/backend.php b/backend.php index 53e4698a..2df6fc55 100644 --- a/backend.php +++ b/backend.php @@ -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,44 +981,54 @@ } if (!$result) { - print "
- Could not display feed (query failed). Please check match syntax or local configuration.
"; - return; - } + if ($omode != "xml") { + print "
+ Could not display feed (query failed). Please check label match syntax or local configuration.
"; + return; + } else { + print ""; + } + } + if (db_num_rows($result) > 0) { - print ""; - - print ""; - - print "
- Select: - All, - Unread, - None -    - Toggle: Unread, - Starred"; - - print ""; - - if ($feed_site_url) { - print "$feed_title"; + if ($omode != "xml") { + + print ""; + + print ""; + + print ""; + print "
+ Select: + All, + Unread, + None +    + Toggle: Unread, + Starred"; + + print ""; + + if ($feed_site_url) { + print "$feed_title"; + } else { + print $feed_title; + } + + print "
"; + + print ""; + } else { - print $feed_title; + print ""; } - - print ""; - print "
"; - - - print ""; $lnum = 0; @@ -1022,7 +1037,7 @@ $num_unread = 0; while ($line = db_fetch_assoc($result)) { - + $class = ($lnum % 2) ? "even" : "odd"; $id = $line["id"]; @@ -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") { @@ -1053,72 +1071,99 @@ $content_link = "" . $line["title"] . ""; - - print ""; - // onclick=\"javascript:view($id,$feed_id)\"> - - print ""; - - print ""; - - print ""; - - if ($line["feed_title"]) { - print ""; - print ""; - } else { - print ""; - } - + 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 ""; + // onclick=\"javascript:view($id,$feed_id)\"> + + print ""; + + print ""; + + print ""; + + if ($line["feed_title"]) { + print ""; + print ""; + } else { + print ""; + } + + print ""; + + print ""; + + } else { + + print ""; + print "<![CDATA[" . $line["title"] . "]]>"; + print "" . $line["link"] . ""; + print "$updated_fmt"; + if ($content_preview) { + print ""; + } + + if ($line["feed_title"]) { + print ""; + } + print ""; + + } - print ""; - - print ""; ++$lnum; } - - print "
$update_pic - - $marked_pic$content_link - ".$line["feed_title"].""; - - print "" . - $line["title"]; - - if (get_pref($link, 'SHOW_CONTENT_PREVIEW')) { - - $content_preview = truncate_string(strip_tags($line["content_preview"]), - 101); - - if ($content_preview) { - print " - $content_preview"; - } - } - - print ""; - print "
$update_pic + + $marked_pic$content_link + ".$line["feed_title"].""; + + print "" . + $line["title"]; + + if (get_pref($link, 'SHOW_CONTENT_PREVIEW')) { + + if ($content_preview) { + print " - $content_preview"; + } + } + + print ""; + print "$updated_fmt 
$updated_fmt 
"; + + if ($omode != "xml") { + print "
"; + } else { + print ""; + } } else { print "
No articles found.
"; } - print ""; + if ($omode != "xml") { - if ($addheader) { - print ""; + print ""; + + if ($addheader) { + print ""; + } } - } if ($op == "pref-rpc") { diff --git a/error.php b/error.php index 4d5e06e2..2dd8e133 100644 --- a/error.php +++ b/error.php @@ -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."; + ?> -- 2.39.5