Skip to content
Browse files

New rss_geterrorxmlfile() function added

and some optional data checked.
  • Loading branch information...
1 parent 53eddb7 commit 9fba045d1a051fca0bbc48075c01149f0fd73cd4 stronk7 committed Dec 1, 2004
Showing with 36 additions and 3 deletions.
  1. +36 −3 rss/rsslib.php
View
39 rss/rsslib.php
@@ -167,11 +167,15 @@ function rss_standard_header($title = NULL, $link = NULL, $description = NULL) {
$result .= rss_full_tag("title",2,false,$title);
$result .= rss_full_tag("link",2,false,$link);
$result .= rss_full_tag("description",2,false,$description);
- $result .= rss_full_tag("language",2,false,substr($USER->lang,0,2));
+ if (!empty($USER->lang)) {
+ $result .= rss_full_tag("language",2,false,substr($USER->lang,0,2));
+ }
$today = getdate();
$result .= rss_full_tag("copyright",2,false,"© ".$today['year']." ".$site->fullname);
- $result .= rss_full_tag("managingEditor",2,false,$USER->email);
- $result .= rss_full_tag("webMaster",2,false,$USER->email);
+ if (!empty($USER->email)) {
+ $result .= rss_full_tag("managingEditor",2,false,$USER->email);
+ $result .= rss_full_tag("webMaster",2,false,$USER->email);
+ }
//write image info
//Calculate the origin
@@ -249,6 +253,35 @@ function rss_standard_footer($title = NULL, $link = NULL, $description = NULL) {
return $result;
}
+//This function return an error xml file (string)
+//to be sent when a rss is required (file.php)
+//and something goes wrong
+function rss_geterrorxmlfile() {
+
+ global $CFG;
+
+ $return = '';
+
+ //XML Header
+ $return = rss_standard_header();
+
+ //XML item
+ if ($return) {
+ $item->title = "RSS Error";
+ $item->link = $CFG->wwwroot;
+ $item->pubdate = time();
+ $item->description = get_string("rsserror");
+ $return .= rss_add_items(array($item));
+ }
+
+ //XML Footer
+ if ($return) {
+ $return .= rss_standard_footer();
+ }
+
+ return $return;
+}
+
// ===== This function are used to write XML tags =========
// [stronk7]: They are similar to the glossary export and backup generation
// but I've replicated them here because they have some minor

0 comments on commit 9fba045

Please sign in to comment.
Something went wrong with that request. Please try again.