Moved a function directly into block. Changed some echo statements to print. Now supports new preferredtitle field for custom feed channel titles.

This commit is contained in:
dhawes 2005-01-27 22:45:50 +00:00
parent 011df35452
commit 48005861f6

View file

@ -30,7 +30,7 @@ function rss_get_link($courseid, $userid, $modulename, $id, $tooltiptext='') {
//This function prints the icon (from theme) with the link to rss/file.php //This function prints the icon (from theme) with the link to rss/file.php
function rss_print_link($courseid, $userid, $modulename, $id, $tooltiptext='') { function rss_print_link($courseid, $userid, $modulename, $id, $tooltiptext='') {
echo rss_get_link($courseid, $userid, $modulename, $id, $tooltiptext); print rss_get_link($courseid, $userid, $modulename, $id, $tooltiptext);
} }
//This function iterates over each module in the server to see if //This function iterates over each module in the server to see if
@ -153,33 +153,33 @@ function rss_standard_header($title = NULL, $link = NULL, $description = NULL) {
$result .= "<rss version=\"2.0\">\n"; $result .= "<rss version=\"2.0\">\n";
//open the channel //open the channel
$result .= rss_start_tag("channel",1,true); $result .= rss_start_tag('channel', 1, true);
//write channel info //write channel info
$result .= rss_full_tag("title",2,false,$title); $result .= rss_full_tag('title', 2, false, $title);
$result .= rss_full_tag("link",2,false,$link); $result .= rss_full_tag('link', 2, false, $link);
$result .= rss_full_tag("description",2,false,$description); $result .= rss_full_tag('description', 2, false, $description);
if (!empty($USER->lang)) { if (!empty($USER->lang)) {
$result .= rss_full_tag("language",2,false,substr($USER->lang,0,2)); $result .= rss_full_tag('language', 2, false, substr($USER->lang,0,2));
} }
$today = getdate(); $today = getdate();
$result .= rss_full_tag("copyright",2,false,"&copy; ".$today['year']." ".$site->fullname); $result .= rss_full_tag('copyright', 2, false, '&copy; '. $today['year'] .' '. $site->fullname);
if (!empty($USER->email)) { if (!empty($USER->email)) {
$result .= rss_full_tag("managingEditor",2,false,$USER->email); $result .= rss_full_tag('managingEditor', 2, false, $USER->email);
$result .= rss_full_tag("webMaster",2,false,$USER->email); $result .= rss_full_tag('webMaster', 2, false, $USER->email);
} }
//write image info //write image info
$rsspix = $CFG->pixpath."/i/rsssitelogo.gif"; $rsspix = $CFG->pixpath."/i/rsssitelogo.gif";
//write the info //write the info
$result .= rss_start_tag("image",2,true); $result .= rss_start_tag('image', 2, true);
$result .= rss_full_tag("url",3,false,$rsspix); $result .= rss_full_tag('url', 3, false, $rsspix);
$result .= rss_full_tag("title",3,false,"moodle"); $result .= rss_full_tag('title', 3, false, 'moodle');
$result .= rss_full_tag("link",3,false,$CFG->wwwroot); $result .= rss_full_tag('link', 3, false, $CFG->wwwroot);
$result .= rss_full_tag("width",3,false,"140"); $result .= rss_full_tag('width', 3, false, '140');
$result .= rss_full_tag("height",3,false,"35"); $result .= rss_full_tag('height', 3, false, '35');
$result .= rss_end_tag("image",2,true); $result .= rss_end_tag('image', 2, true);
} }
if (!$status) { if (!$status) {
@ -230,9 +230,9 @@ function rss_standard_footer($title = NULL, $link = NULL, $description = NULL) {
$result = ""; $result = "";
//Close the chanel //Close the chanel
$result .= rss_end_tag("channel",1,true); $result .= rss_end_tag('channel', 1, true);
////Close the rss tag ////Close the rss tag
$result .= "</rss>"; $result .= '</rss>';
return $result; return $result;
} }
@ -374,78 +374,26 @@ function rss_display_feeds($rssid='none') {
$deleteString .= '<img src="'. $CFG->pixpath .'/t/delete.gif" alt="'. get_string('delete'); $deleteString .= '<img src="'. $CFG->pixpath .'/t/delete.gif" alt="'. get_string('delete');
$deleteString .= '" title="'. get_string('delete') .'" align="absmiddle" border="0" /></a>'; $deleteString .= '" title="'. get_string('delete') .'" align="absmiddle" border="0" /></a>';
} }
echo '<tr class="forumpostmessage"><td><strong><a href="'. $CFG->wwwroot .'/blocks/rss_client/block_rss_client_action.php?act=view&rssid='; if (!empty($feed->preferredtitle)) {
echo $feed->id .'&blogid='. $blogid .'">'. $feed->title .'</a></strong><br />' ."\n"; $feedtitle = stripslashes_safe($feed->preferredtitle);
echo '<a href="'. $feed->url .'">'. $feed->url .'</a><br />'."\n"; } else {
echo $feed->description .'<br />' ."\n"; $feedtitle = stripslashes_safe($feed->title);
echo '</td>'; }
echo '<td align="center">'. $editString .'</td>' ."\n"; print '<tr class="forumpostmessage"><td><strong><a href="'. $CFG->wwwroot .'/blocks/rss_client/block_rss_client_action.php?act=view&rssid=';
echo '<td align="center">'. $deleteString .'</td>' ."\n"; print $feed->id .'&blogid='. $blogid .'">'. $feedtitle .'</a></strong><br />' ."\n";
echo '</tr>'."\n"; print '<a href="'. $feed->url .'">'. $feed->url .'</a><br />'."\n";
print $feed->description .'<br />' ."\n";
print '</td>';
print '<td align="center">'. $editString .'</td>' ."\n";
print '<td align="center">'. $deleteString .'</td>' ."\n";
print '</tr>'."\n";
} }
} }
if ($closeTable){ if ($closeTable){
echo '</table>'."\n"; print '</table>'."\n";
} }
} }
/**
* @param string $act .
* @param string $url .
* @param int $rssid .
* @param bool $printnow True if the generated form should be printed out, false if the string should be returned from this function quietly
*/
function rss_get_form($act, $url, $rssid, $printnow=true) {
global $USER, $CFG, $_SERVER, $blockid, $blockaction;
global $blogid; //hackish, but if there is a blogid it would be good to preserve it
$stredit = get_string('edit');
$stradd = get_string('add');
$strupdatefeed = get_string('block_rss_update_feed', 'block_rss_client');
$straddfeed = get_string('block_rss_add_feed', 'block_rss_client');
$returnstring = '<table align="center"><tbody><tr><td>'."\n";
$returnstring .= '<form action="'. $_SERVER['PHP_SELF'] .'" method="POST" name="block_rss">'."\n";
if ($act == 'rss_edit') {
$returnstring .= $strupdatefeed;
} else {
$returnstring .= $straddfeed;
}
$returnstring .= '<br /><input type="text" size="60" maxlength="256" name="url" value="';
if ($act == 'rss_edit') {
$returnstring .= $url;
}
$returnstring .= '" />'."\n";
$returnstring .= '<input type="hidden" name="act" value="';
if ($act == 'rss_edit') {
$returnstring .= 'updfeed';
} else {
$returnstring .= 'addfeed';
}
$returnstring .= '" />'."\n";
if ($act == 'rss_edit') {
$returnstring .= '<input type="hidden" name="rssid" value="'. $rssid .'" />'. "\n";
}
$returnstring .= '<input type="hidden" name="blogid" value="'. $blogid .'" />'."\n";
$returnstring .= '<input type="hidden" name="user" value="'. $USER->id .'" />'."\n";
$returnstring .= '<br /><input type="submit" value="';
$validatestring = "<a href=\"#\" onClick=\"window.open('http://feedvalidator.org/check.cgi?url='+document.block_rss.elements['url'].value,'validate','width=640,height=480,scrollbars=yes,status=yes,resizable=yes');return true;\">Validate</a>";
if ($act == 'rss_edit') {
$returnstring .= $stredit;
} else {
$returnstring .= $stradd;
}
$returnstring .= '" />&nbsp;'. $validatestring .'</form>'."\n";
$returnstring .= '</td></tr></tbody></table>'."\n";
if ($printnow){
print $returnstring;
}
return $returnstring;
}
/** /**
* translates HTML special characters back to ASCII * translates HTML special characters back to ASCII
* RSS feeds may have encoded html commands which we want to translate properly * RSS feeds may have encoded html commands which we want to translate properly