Commit 67076c20 authored by Camille Tardy's avatar Camille Tardy
Browse files

fix deprecated coursecat calls. & Do not try to get categID form course...

fix deprecated coursecat calls. & Do not try to get categID form course catalogue homepage, there is none.
parent 91c2a9b1
......@@ -5,7 +5,7 @@ namespace theme_unige\output\core;
defined('MOODLE_INTERNAL') || die();
use moodle_url;
use coursecat;
use core_course_category;
use coursecat_helper;
use html_writer;
use single_select;
......@@ -59,8 +59,8 @@ class course_renderer extends \core_course_renderer {
*/
public function course_category($category) {
global $CFG;
require_once($CFG->libdir. '/coursecatlib.php');
$coursecat = coursecat::get(is_object($category) ? $category->id : $category);
// require_once($CFG->libdir. '/coursecatlib.php');
$coursecat = core_course_category::get(is_object($category) ? $category->id : $category);
$site = get_site();
$output = '';
......@@ -117,9 +117,9 @@ class course_renderer extends \core_course_renderer {
$output .= $this->course_search_form();
if (!$coursecat->id) {
if (coursecat::count_all() == 1) {
if (core_course_category::is_simple_site() == 1) {
// There exists only one category in the system, do not display link to it
$coursecat = coursecat::get_default();
$coursecat = core_course_category::get_default();
$strfulllistofcourses = get_string('fulllistofcourses');
$this->page->set_title("$site->shortname: $strfulllistofcourses");
} else {
......@@ -128,16 +128,16 @@ class course_renderer extends \core_course_renderer {
}
} else {
$title = $site->shortname;
if (coursecat::count_all() > 1) {
if (core_course_category::is_simple_site() > 1) {
$title .= ": ". $coursecat->get_formatted_name();
}
$this->page->set_title($title);
// Print the category selector
if (coursecat::count_all() > 1) {
if (core_course_category::is_simple_site() > 1) {
$output .= html_writer::start_tag('div', array('class' => 'categorypicker'));
$select = new single_select(new moodle_url('/course/index.php'), 'categoryid',
coursecat::make_categories_list(), $coursecat->id, null, 'switchcategory');
core_course_category::make_categories_list(), $coursecat->id, null, 'switchcategory');
$select->set_label(get_string('categories').':');
$output .= $this->render($select);
$output .= html_writer::end_tag('div'); // .categorypicker
......@@ -213,7 +213,9 @@ class course_renderer extends \core_course_renderer {
if ($this->page->pagetype == "course-index") {
$id_category = $coursecat->id;
} elseif ($this->page->pagetype == "course-index-category") {
$id_category = $_GET['categoryid'];
if(isset($_GET['categoryid'])){ //if catalogue home page no category_id in GET.
$id_category = $_GET['categoryid'];
}
}
// category name
......@@ -382,7 +384,7 @@ class course_renderer extends \core_course_renderer {
* please use {@link core_course_renderer::course_info_box()}
*
* @param coursecat_helper $chelper various display options
* @param course_in_list|stdClass $course
* @param core_course_list_element|stdClass $course
* @param string $additionalclasses additional classes to add to the main <div> tag (usually
* depend on the course position in list - first/last/even/odd)
* @return string
......@@ -396,8 +398,8 @@ class course_renderer extends \core_course_renderer {
return '';
}
if ($course instanceof stdClass) {
require_once($CFG->libdir. '/coursecatlib.php');
$course = new course_in_list($course);
// require_once($CFG->libdir. '/coursecatlib.php');
$course = new core_course_list_element($course);
}
$content = '';
$classes = trim('coursebox clearfix '. $additionalclasses);
......
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