mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 04:22:07 +02:00
MDL-38682 Allow configuring blocks for courses lists pages
Also fixed block configuration form error when pagetype string does not exist (for course- pages)
This commit is contained in:
parent
cb52eeab28
commit
9dd85edf02
@ -35,16 +35,5 @@ function admin_page_type_list($pagetype, $parentcontext, $currentcontext) {
|
||||
'admin-*' => get_string('page-admin-x', 'pagetype'),
|
||||
$pagetype => get_string('page-admin-current', 'pagetype')
|
||||
);
|
||||
// Add the missing * (any page) option for them. MDL-30340
|
||||
// TODO: These pages are really 'pagetype-varying' - MDL-30564 -
|
||||
// and some day we should stop behaving that way, so proper pagetypes
|
||||
// can be specified for it (like course-category-* or so).
|
||||
// Luckly... the option we are introducing '*' is independent
|
||||
// of that varying behavior, so will work.
|
||||
if ($pagetype == 'admin-course-category') {
|
||||
$array += array(
|
||||
'*' => get_string('page-x', 'pagetype')
|
||||
);
|
||||
}
|
||||
return $array;
|
||||
}
|
||||
|
@ -33,6 +33,7 @@ $site = get_site();
|
||||
if ($categoryid) {
|
||||
$PAGE->set_category_by_id($categoryid);
|
||||
$PAGE->set_url(new moodle_url('/course/index.php', array('categoryid' => $categoryid)));
|
||||
$PAGE->set_pagetype('course-index-category');
|
||||
// And the object has been loaded for us no need for another DB call
|
||||
$category = $PAGE->category;
|
||||
} else {
|
||||
|
@ -2825,22 +2825,31 @@ class course_request {
|
||||
/**
|
||||
* Return a list of page types
|
||||
* @param string $pagetype current page type
|
||||
* @param stdClass $parentcontext Block's parent context
|
||||
* @param stdClass $currentcontext Current context of block
|
||||
* @param context $parentcontext Block's parent context
|
||||
* @param context $currentcontext Current context of block
|
||||
* @return array array of page types
|
||||
*/
|
||||
function course_page_type_list($pagetype, $parentcontext, $currentcontext) {
|
||||
// $currentcontext could be null, get_context_info_array() will throw an error if this is the case.
|
||||
if (isset($currentcontext)) {
|
||||
// if above course context ,display all course fomats
|
||||
list($currentcontext, $course, $cm) = get_context_info_array($currentcontext->id);
|
||||
if ($course->id == SITEID) {
|
||||
return array('*'=>get_string('page-x', 'pagetype'));
|
||||
}
|
||||
if ($pagetype === 'course-index' || $pagetype === 'course-index-category') {
|
||||
// For courses and categories browsing pages (/course/index.php) add option to show on ANY category page
|
||||
$pagetypes = array('*' => get_string('page-x', 'pagetype'),
|
||||
'course-index-*' => get_string('page-course-index-x', 'pagetype'),
|
||||
);
|
||||
} else if ($currentcontext && (!($coursecontext = $currentcontext->get_course_context(false)) || $coursecontext->instanceid == SITEID)) {
|
||||
// We know for sure that despite pagetype starts with 'course-' this is not a page in course context (i.e. /course/search.php, etc.)
|
||||
$pagetypes = array('*' => get_string('page-x', 'pagetype'));
|
||||
} else {
|
||||
// Otherwise consider it a page inside a course even if $currentcontext is null
|
||||
$pagetypes = array('*' => get_string('page-x', 'pagetype'),
|
||||
'course-*' => get_string('page-course-x', 'pagetype'),
|
||||
'course-view-*' => get_string('page-course-view-x', 'pagetype')
|
||||
);
|
||||
}
|
||||
return array('*'=>get_string('page-x', 'pagetype'),
|
||||
'course-*'=>get_string('page-course-x', 'pagetype'),
|
||||
'course-view-*'=>get_string('page-course-view-x', 'pagetype')
|
||||
);
|
||||
// If the string definition for current page is missing, add generic name so the form does not get broken
|
||||
if (!get_string_manager()->string_exists('page-'. $pagetype, 'pagetype')) {
|
||||
$pagetypes[$pagetype] = $pagetype;
|
||||
}
|
||||
return $pagetypes;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -26,6 +26,10 @@
|
||||
$string['page-admin-current'] = 'The current site administration page';
|
||||
$string['page-admin-x'] = 'Any site administration page';
|
||||
$string['page-course-view-x'] = 'Any type of course main page';
|
||||
$string['page-course-index'] = 'Top category view page';
|
||||
$string['page-course-index-category'] = 'The current category view page';
|
||||
$string['page-course-index-x'] = 'Any category view page';
|
||||
$string['page-course-search'] = 'Courses search page';
|
||||
$string['page-course-x'] = 'Any course page';
|
||||
$string['page-course-report-x'] = 'Any course report';
|
||||
$string['page-mod-x'] = 'Any activity module page';
|
||||
|
Loading…
x
Reference in New Issue
Block a user