Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/blocks/rss_client/viewfeed.php
Go to the documentation of this file.
00001 <?php
00002 
00003 // This file is part of Moodle - http://moodle.org/
00004 //
00005 // Moodle is free software: you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation, either version 3 of the License, or
00008 // (at your option) any later version.
00009 //
00010 // Moodle is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
00017 
00026 require_once(dirname(__FILE__) . '/../../config.php');
00027 require_once($CFG->libdir .'/simplepie/moodle_simplepie.php');
00028 
00029 require_login();
00030 if (isguestuser()) {
00031     print_error('guestsarenotallowed');
00032 }
00033 
00034 $returnurl = optional_param('returnurl', '', PARAM_LOCALURL);
00035 $courseid = optional_param('courseid', 0, PARAM_INTEGER);
00036 $rssid = required_param('rssid', PARAM_INTEGER);
00037 
00038 if ($courseid = SITEID) {
00039     $courseid = 0;
00040 }
00041 if ($courseid) {
00042     $course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST);
00043     $PAGE->set_course($course);
00044     $context = $PAGE->context;
00045 } else {
00046     $context = get_context_instance(CONTEXT_SYSTEM);
00047     $PAGE->set_context($context);
00048 }
00049 
00050 $urlparams = array('rssid' => $rssid);
00051 if ($courseid) {
00052     $urlparams['courseid'] = $courseid;
00053 }
00054 if ($returnurl) {
00055     $urlparams['returnurl'] = $returnurl;
00056 }
00057 $PAGE->set_url('/blocks/rss_client/viewfeed.php', $urlparams);
00058 $PAGE->set_pagelayout('popup');
00059 
00060 $rssrecord = $DB->get_record('block_rss_client', array('id' => $rssid), '*', MUST_EXIST);
00061 
00062 $rss = new moodle_simplepie($rssrecord->url);
00063 
00064 if ($rss->error()) {
00065     debugging($rss->error());
00066     print_error('errorfetchingrssfeed');
00067 }
00068 
00069 $strviewfeed = get_string('viewfeed', 'block_rss_client');
00070 
00071 $PAGE->set_title($strviewfeed);
00072 $PAGE->set_heading($strviewfeed);
00073 
00074 $settingsurl = new moodle_url('/admin/settings.php?section=blocksettingrss_client');
00075 $managefeeds = new moodle_url('/blocks/rss_client/managefeeds.php', $urlparams);
00076 $PAGE->navbar->add(get_string('blocks'));
00077 $PAGE->navbar->add(get_string('feedstitle', 'block_rss_client'), $settingsurl);
00078 $PAGE->navbar->add(get_string('managefeeds', 'block_rss_client'));
00079 $PAGE->navbar->add($strviewfeed);
00080 echo $OUTPUT->header();
00081 
00082 if (!empty($rssrecord->preferredtitle)) {
00083     $feedtitle = $rssrecord->preferredtitle;
00084 } else {
00085     $feedtitle =  $rss->get_title();
00086 }
00087 echo '<table align="center" width="50%" cellspacing="1">'."\n";
00088 echo '<tr><td colspan="2"><strong>'. $feedtitle .'</strong></td></tr>'."\n";
00089 foreach ($rss->get_items() as $item) {
00090     echo '<tr><td valign="middle">'."\n";
00091     echo '<a href="'. $item->get_link() .'" target="_blank"><strong>'. $item->get_title();
00092     echo '</strong></a>'."\n";
00093     echo '</td>'."\n";
00094     echo '</tr>'."\n";
00095     echo '<tr><td colspan="2"><small>';
00096     echo $item->get_description() .'</small></td></tr>'."\n";
00097 }
00098 echo '</table>'."\n";
00099 
00100 echo $OUTPUT->footer();
 All Data Structures Namespaces Files Functions Variables Enumerations