From a64fbc87b6808d8a31a20c240415e89eccea25f7 Mon Sep 17 00:00:00 2001 From: Frederic Massart Date: Fri, 29 Jun 2012 13:43:02 +0800 Subject: [PATCH] MDL-33767 Course: General section displays its title when required --- course/format/renderer.php | 10 ++++++++-- course/lib.php | 16 ++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/course/format/renderer.php b/course/format/renderer.php index 1fec7b2389d..1309025b909 100644 --- a/course/format/renderer.php +++ b/course/format/renderer.php @@ -151,7 +151,13 @@ abstract class format_section_renderer_base extends plugin_renderer_base { $o.= html_writer::tag('div', $rightcontent, array('class' => 'right side')); $o.= html_writer::start_tag('div', array('class' => 'content')); - if (!$onsectionpage) { + // When not on a section page, we display the section titles except the general section if null + $hasnamenotsecpg = (!$onsectionpage && ($section->section != 0 || !is_null($section->name))); + + // When on a section page, we only display the general section title, if title is not the default one + $hasnamesecpg = ($onsectionpage && ($section->section == 0 && !is_null($section->name))); + + if ($hasnamenotsecpg || $hasnamesecpg) { $o.= $this->output->heading($this->section_title($section, $course), 3, 'sectionname'); } @@ -642,7 +648,7 @@ abstract class format_section_renderer_base extends plugin_renderer_base { $thissection = $sections[0]; unset($sections[0]); if ($thissection->summary or $thissection->sequence or $PAGE->user_is_editing()) { - echo $this->section_header($thissection, $course, true); + echo $this->section_header($thissection, $course, false); print_section($course, $thissection, $mods, $modnamesused, true); if ($PAGE->user_is_editing()) { print_section_add_menus($course, 0, $modnames); diff --git a/course/lib.php b/course/lib.php index 3a2e3ad282f..63df417fe53 100644 --- a/course/lib.php +++ b/course/lib.php @@ -1376,7 +1376,16 @@ function get_print_section_cm_text(cm_info $cm, $course) { /** * Prints a section full of activity modules + * + * @param stdClass $course The course + * @param stdClass $section The section + * @param array $mods The modules in the section + * @param array $modnamesused An array containing the list of modules and their names + * @param bool $absolute All links are absolute + * @param string $width Width of the container + * @param bool $hidecompletion Hide completion status * @param int $sectionreturn The section to return to + * @return void */ function print_section($course, $section, $mods, $modnamesused, $absolute=false, $width="100%", $hidecompletion=false, $sectionreturn=0) { global $CFG, $USER, $DB, $PAGE, $OUTPUT; @@ -1757,7 +1766,14 @@ function print_section($course, $section, $mods, $modnamesused, $absolute=false, /** * Prints the menus to add activities and resources. + * + * @param stdClass $course The course + * @param stdClass $section The section + * @param array $modnames An array containing the list of modules and their names + * @param bool $vertical Vertical orientation + * @param bool $return Return the menus or send them to output * @param int $sectionreturn The section to link back to + * @return void|string depending on $return */ function print_section_add_menus($course, $section, $modnames, $vertical=false, $return=false, $sectionreturn=0) { global $CFG, $OUTPUT;