Commit b6665125 authored by Daniel Neis Araujo's avatar Daniel Neis Araujo

fix for 3.4

parent 6014a613
......@@ -24,6 +24,9 @@
defined('MOODLE_INTERNAL') || die();
require_once($CFG->libdir. '/coursecatlib.php');
require_once($CFG->dirroot. '/course/renderer.php');
class block_featuredcourses extends block_base {
public function init() {
......@@ -48,60 +51,51 @@ class block_featuredcourses extends block_base {
$this->content->footer = '';
$this->content->text = '';
// The user/index.php expect course context, so get one if page has module context.
$currentcontext = $this->page->context->get_course_context(false);
if (empty($currentcontext)) {
return $this->content;
}
if ($this->page->course->id == SITEID) {
$courses = self::get_featured_courses();
require_once($CFG->libdir. '/coursecatlib.php');
$chelper = new coursecat_helper();
foreach ($courses as $course) {
$courses = self::get_featured_courses();
$chelper = new coursecat_helper();
foreach ($courses as $course) {
$course = new course_in_list($course);
$course = new course_in_list($course);
$this->content->text .= '<div class="container-fluid coursebox">';
$this->content->text .= '<div class="container-fluid coursebox">';
$content = '';
$content = '';
$coursename = $chelper->get_course_formatted_name($course);
$coursenamelink = html_writer::link(new moodle_url('/course/view.php', array('id' => $course->id)),
$coursename, array('class' => $course->visible ? '' : 'dimmed'));
$content .= html_writer::tag('div', $coursenamelink, array('class' => 'coursename'));
$coursename = $chelper->get_course_formatted_name($course);
$coursenamelink = html_writer::link(new moodle_url('/course/view.php', array('id' => $course->id)),
$coursename, array('class' => $course->visible ? '' : 'dimmed'));
$content .= html_writer::tag('div', $coursenamelink, array('class' => 'coursename'));
if ($course->has_summary()) {
$content .= html_writer::start_tag('div', array('class' => 'summary'));
$content .= $chelper->get_course_formatted_summary($course,
array('overflowdiv' => true, 'noclean' => true, 'para' => false));
$content .= html_writer::end_tag('div');
}
if ($course->has_summary()) {
$content .= html_writer::start_tag('div', array('class' => 'summary'));
$content .= $chelper->get_course_formatted_summary($course,
array('overflowdiv' => true, 'noclean' => true, 'para' => false));
$content .= html_writer::end_tag('div');
}
// Display course overview files.
$contentimages = $contentfiles = '';
foreach ($course->get_course_overviewfiles() as $file) {
$isimage = $file->is_valid_image();
$url = file_encode_url("{$CFG->wwwroot}/pluginfile.php",
'/'. $file->get_contextid(). '/'. $file->get_component(). '/'.
$file->get_filearea(). $file->get_filepath(). $file->get_filename(), !$isimage);
if ($isimage) {
$contentimages .= html_writer::tag('div',
html_writer::empty_tag('img', array('src' => $url, 'style' => 'max-height: 150px')),
array('class' => 'courseimage'));
} else {
$image = $this->output->pix_icon(file_file_icon($file, 24), $file->get_filename(), 'moodle');
$filename = html_writer::tag('span', $image, array('class' => 'fp-icon')).
html_writer::tag('span', $file->get_filename(), array('class' => 'fp-filename'));
$contentfiles .= html_writer::tag('span',
html_writer::link($url, $filename),
array('class' => 'coursefile fp-filename-icon'));
}
// Display course overview files.
$contentimages = $contentfiles = '';
foreach ($course->get_course_overviewfiles() as $file) {
$isimage = $file->is_valid_image();
$url = file_encode_url("{$CFG->wwwroot}/pluginfile.php",
'/'. $file->get_contextid(). '/'. $file->get_component(). '/'.
$file->get_filearea(). $file->get_filepath(). $file->get_filename(), !$isimage);
if ($isimage) {
$contentimages .= html_writer::tag('div',
html_writer::empty_tag('img', array('src' => $url, 'style' => 'max-height: 150px')),
array('class' => 'courseimage'));
} else {
$image = $this->output->pix_icon(file_file_icon($file, 24), $file->get_filename(), 'moodle');
$filename = html_writer::tag('span', $image, array('class' => 'fp-icon')).
html_writer::tag('span', $file->get_filename(), array('class' => 'fp-filename'));
$contentfiles .= html_writer::tag('span',
html_writer::link($url, $filename),
array('class' => 'coursefile fp-filename-icon'));
}
$content .= $contentimages. $contentfiles;
$this->content->text .= $content. '</div>';
}
$content .= $contentimages. $contentfiles;
$this->content->text .= $content. '</div>';
}
return $this->content;
......
......@@ -18,14 +18,14 @@
* Version details
*
* @package block_featuredcourses
* @copyright Daniel Neis <danielneis@gmail.com>
* @copyright Daniel Neis Araujo <danielneis@gmail.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
$plugin->version = 2015042701; // The current plugin version (Date: YYYYMMDDXX)
$plugin->requires = 2014110400; // Requires this Moodle version
$plugin->release = 2;
$plugin->version = 2015042701; // The current plugin version (Date: YYYYMMDDXX).
$plugin->requires = 2017111300; // Requires this Moodle version.
$plugin->release = 3;
$plugin->maturity = MATURITY_STABLE;
$plugin->component = 'block_featuredcourses'; // Full name of the plugin (used for diagnostics)
$plugin->component = 'block_featuredcourses'; // Full name of the plugin (used for diagnostics).
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment