navigation MDL-22044 Course format can now choose the string that is used for section 0, defaults to general

This commit is contained in:
Sam Hemelryk 2010-04-22 01:26:45 +00:00
parent de631d3c2e
commit dc07683108
5 changed files with 9 additions and 34 deletions

View File

@ -25,3 +25,4 @@
$string['sectionname'] = 'topic';
$string['pluginname'] = 'Topics format';
$string['section0name'] = 'General';

View File

@ -34,21 +34,7 @@
* @return bool Returns true
*/
function callback_topics_load_content(&$navigation, $course, $coursenode) {
return $navigation->load_generic_course_sections($course, $coursenode, get_string('topic'), 'topic');
}
/**
* Used to display the course structure for a course where format=topic
*
* This is called automatically by {@link load_course()} if the current course
* format = weeks and the navigation was requested via AJAX
*
* @param array $path An array of keys to the course node in the navigation
* @param stdClass $modinfo The mod info object for the current course
* @return bool Returns true
*/
function callback_topics_load_limited_section(&$navigation, $keys, $course, $section) {
$navigation->limited_load_section_generic($keys, $course, $section, get_string('topic'), 'topic');
return $navigation->load_generic_course_sections($course, $coursenode, get_string('topic'), 'topic', get_string('section0name', 'format_topics'));
}
/**

View File

@ -25,3 +25,4 @@
$string['sectionname'] = 'week';
$string['pluginname'] = 'Weekly format';
$string['section0name'] = 'General';

View File

@ -34,22 +34,7 @@
* @param stdClass $course The course we are loading the section for
*/
function callback_weeks_load_content(&$navigation, $course, $coursenode) {
return $navigation->load_generic_course_sections($course, $coursenode, get_string('week'), 'week');
}
/**
* Used to display the course structure for a course where format=weeks
*
* This is called automatically by {@link load_course()} if the current course
* format = weeks and the navigation was requested via AJAX
*
* @param navigation_node $navigation The course node
* @param array $path An array of keys to the course node
* @param stdClass $course The course we are loading the section for
* @param stdClass $section The section to load
*/
function callback_weeks_load_limited_section(&$navigation, $keys, $course, $section) {
$navigation->limited_load_section_generic($keys, $course, $section, get_string('week'), 'week');
return $navigation->load_generic_course_sections($course, $coursenode, get_string('week'), 'week', get_string('section0name', 'format_weeks'));
}
/**

View File

@ -1042,12 +1042,14 @@ class global_navigation extends navigation_node {
* @param string $activeparam The url used to identify the active section
* @return array An array of course section nodes
*/
public function load_generic_course_sections(stdClass $course, navigation_node $coursenode, $name, $activeparam) {
public function load_generic_course_sections(stdClass $course, navigation_node $coursenode, $name, $activeparam, $section0name=null) {
$modinfo = get_fast_modinfo($course);
$sections = array_slice(get_all_sections($course->id), 0, $course->numsections+1, true);
$viewhiddensections = has_capability('moodle/course:viewhiddensections', $this->page->context);
$strgeneral = get_string('general');
if ($section0name === null) {
$section0name = get_string('general');
}
foreach ($sections as &$section) {
if ($course->id == SITEID) {
$this->load_section_activities($coursenode, $section->section, $modinfo);
@ -1056,7 +1058,7 @@ class global_navigation extends navigation_node {
continue;
}
if ($section->section == 0) {
$sectionname = $strgeneral;
$sectionname = $section0name;
} else {
$sectionname = $name.' '.$section->section;
}