Permalink
Browse files

additional debug output when in debug mode

  • Loading branch information...
1 parent 2481037 commit 340f81987128bdbaf6cdfeafb0c00af0844fc155 dhawes committed Jun 28, 2005
Showing with 44 additions and 17 deletions.
  1. +19 −2 blocks/rss_client/block_rss_client.php
  2. +25 −15 blocks/rss_client/block_rss_client_action.php
View
21 blocks/rss_client/block_rss_client.php
@@ -1,5 +1,18 @@
<?php //$Id$
+/*******************************************************************
+* This file contains one class which...
+*
+* @author Daryl Hawes
+* @version $Id$
+* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
+* @package base
+******************************************************************/
+
+/**
+ * This class is for a block which....
+ */
+
// Developer's debug assistant - if true then the display string will not cache, only
// the magpie object's built in caching will be used
define('BLOCK_RSS_SECONDARY_CACHE_ENABLED', true);
@@ -36,7 +49,6 @@ function get_content() {
}
$this->content = new stdClass;
- $this->content->footer = '';
if (empty($this->instance)) {
// We're being asked for content without an associated instance
@@ -159,7 +171,6 @@ function get_rss_by_id($rssid, $display_description, $shownumentries, $showtitle
$rss_record = get_record('block_rss_client', 'id', $rssid);
if (isset($rss_record) && isset($rss_record->id)) {
-
// By capturing the output from fetch_rss this way
// error messages do not display and clutter up the moodle interface
// however, we do lose out on seeing helpful messages like "cache hit", etc.
@@ -198,6 +209,12 @@ function get_rss_by_id($rssid, $display_description, $shownumentries, $showtitle
$formatoptions->para = false;
+ // first we must verify that the rss feed is loaded
+ // by checking $rss and $rss->items exist before using them
+ if (empty($rss) || empty($rss->items)) {
+ return '';
+ }
+
foreach ($rss->items as $item) {
$item['title'] = stripslashes_safe(rss_unhtmlentities($item['title']));
$item['description'] = stripslashes_safe(rss_unhtmlentities($item['description']));
View
40 blocks/rss_client/block_rss_client_action.php
@@ -1,12 +1,21 @@
<?php //$Id$
+/*******************************************************************
+* This file contains one class which...
+*
+* @author Daryl Hawes
+* @version $Id$
+* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
+* @package base
+******************************************************************/
+
require_once('../../config.php');
require_once($CFG->libdir .'/rsslib.php');
require_once(MAGPIE_DIR .'rss_fetch.inc');
require_login();
global $USER;
-
+
//ensure that the logged in user is not using the guest account
if (isset($_SERVER['HTTP_REFERER'])) {
$referrer = $_SERVER['HTTP_REFERER'];
@@ -69,13 +78,16 @@
if (empty($url)) {
error( 'url not defined for rss feed' );
}
-
+
// By capturing the output from fetch_rss this way
// error messages do not display and clutter up the moodle interface
// however, we do lose out on seeing helpful messages like "cache hit", etc.
+ $message = '';
ob_start();
$rss = fetch_rss($url);
- $rsserror = ob_get_contents();
+ if ($CFG->debug) {
+ $message .= ob_get_contents();
+ }
ob_end_clean();
$dataobject->id = $rssid;
@@ -94,10 +106,9 @@
error('There was an error trying to update rss feed with id:'. $rssid);
}
- redirect($referrer, get_string('feedupdated', 'block_rss_client'));
-/* rss_display_feeds();
- rss_get_form($act, $dataobject->url, $rssid, $dataobject->preferredtitle);
-*/
+ $message .= '<br />'. get_string('feedupdated', 'block_rss_client');
+ redirect($referrer, $message);
+
} else if ($act == 'addfeed' ) {
if (empty($url)) {
@@ -117,13 +128,16 @@
// By capturing the output from fetch_rss this way
// error messages do not display and clutter up the moodle interface
// however, we do lose out on seeing helpful messages like "cache hit", etc.
+ $message = '';
ob_start();
$rss = fetch_rss($url);
- $rsserror = ob_get_contents();
+ if ($CFG->debug) {
+ $message .= ob_get_contents();
+ }
ob_end_clean();
if ($rss === false) {
- $message = 'There was an error loading this rss feed. You may want to verify the url you have specified before using it.'; //Daryl Hawes note: localize this line
+ $message .= '<br /><br />There was an error loading this rss feed. You may want to verify the url you have specified before using it.'; //Daryl Hawes note: localize this line
} else {
$dataobject->id = $rssid;
@@ -136,7 +150,7 @@
if (!update_record('block_rss_client', $dataobject)) {
error('There was an error trying to update rss feed with id:'. $rssid);
}
- $message = get_string('feedadded', 'block_rss_client');
+ $message .= '<br />'. get_string('feedadded', 'block_rss_client');
}
redirect($referrer, $message);
/*
@@ -168,9 +182,6 @@
redirect($referrer, get_string('feeddeleted', 'block_rss_client') );
-/* rss_display_feeds();
- rss_get_form($act, $url, $rssid, $preferredtitle);
-*/
} else if ($act == 'view') {
// echo $sql; //debug
// print_object($res); //debug
@@ -183,7 +194,6 @@
// however, we do lose out on seeing helpful messages like "cache hit", etc.
ob_start();
$rss = fetch_rss($rss_record->url);
- $rsserror = ob_get_contents();
ob_end_clean();
if (empty($rss_record->preferredtitle)) {
@@ -212,7 +222,7 @@
//Blog module is installed - provide "blog this" link
print '<td align="right">'."\n";
print '<img src="'. $CFG->pixpath .'/blog/blog.gif" alt="'. get_string('blogthis', 'blog').'" title="'. get_string('blogthis', 'blog') .'" border="0" align="middle" />'."\n";
- print '<a href="'. $CFG->wwwroot .'/blog/blogthis.php?blogid='. $blogid .'&act=use&item='. $y .'&rssid='. $rssid .'"><small><strong>'. get_string('blogthis', 'blog') .'</strong></small></a>'."\n";
+ print '<a href="'. $CFG->wwwroot .'/blog/blogthis.php?userid='. $userid .'&act=use&item='. $y .'&rssid='. $rssid .'"><small><strong>'. get_string('blogthis', 'blog') .'</strong></small></a>'."\n";
} else {
print '<td>&nbsp;';
}

0 comments on commit 340f819

Please sign in to comment.