New rss_geterrorxmlfile() function added

and some optional data checked.

Merged from MOODLE_14_STABLE
This commit is contained in:
stronk7 2004-12-01 19:51:45 +00:00
parent 690f358b62
commit ec6dc3f6d7

View File

@ -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