Permalink
Browse files

Robustness check from Marko Korhonen (bug 3751):

Don't print a warning if $rss->items is empty.
  • Loading branch information...
1 parent 9f02856 commit 73b60981afc9dbf31fd4c0e75f5743b85795bc9e defacer committed Jul 16, 2005
Showing with 26 additions and 24 deletions.
  1. +26 −24 blocks/rss_client/block_rss_client.php
@@ -198,30 +198,32 @@ function get_rss_by_id($rssid, $display_description, $shownumentries, $showtitle
$formatoptions->para = false;
- foreach ($rss->items as $item) {
- $item['title'] = stripslashes_safe(rss_unhtmlentities($item['title']));
- $item['description'] = stripslashes_safe(rss_unhtmlentities($item['description']));
- if ($item['title'] == '') {
- // no title present, use portion of description
- $item['title'] = substr(strip_tags($item['description']), 0, 20) . '...';
- } else {
- $item['title'] = break_up_long_words($item['title'], 30);
- }
-
- if ($item['link'] == '') {
- $item['link'] = $item['guid'];
- }
-
- $item['link'] = str_replace('&', '&', $item['link']);
-
- $returnstring .= '<div class="link"><a href="'. $item['link'] .'" target="_blank">'. $item['title'] . '</a></div>' ."\n";
-
-
- if ($display_description && !empty($item['description'])) {
- $item['description'] = break_up_long_words($item['description'], 30);
- $returnstring .= '<div class="description">'.
- format_text($item['description'], FORMAT_MOODLE, $formatoptions, $this->courseid) .
- '</div>' ."\n";
+ if(!empty($rss->items)) {
+ foreach ($rss->items as $item) {
+ $item['title'] = stripslashes_safe(rss_unhtmlentities($item['title']));
+ $item['description'] = stripslashes_safe(rss_unhtmlentities($item['description']));
+ if ($item['title'] == '') {
+ // no title present, use portion of description
+ $item['title'] = substr(strip_tags($item['description']), 0, 20) . '...';
+ } else {
+ $item['title'] = break_up_long_words($item['title'], 30);
+ }
+
+ if ($item['link'] == '') {
+ $item['link'] = $item['guid'];
+ }
+
+ $item['link'] = str_replace('&', '&amp;', $item['link']);
+
+ $returnstring .= '<div class="link"><a href="'. $item['link'] .'" target="_blank">'. $item['title'] . '</a></div>' ."\n";
+
+
+ if ($display_description && !empty($item['description'])) {
+ $item['description'] = break_up_long_words($item['description'], 30);
+ $returnstring .= '<div class="description">'.
+ format_text($item['description'], FORMAT_MOODLE, $formatoptions, $this->courseid) .
+ '</div>' ."\n";
+ }
}
}

0 comments on commit 73b6098

Please sign in to comment.