Ejemplo n.º 1
0
 /**
  * Course-specific information to be output immediately above content on any course page
  *
  * See {@link format_base::course_header()} for usage
  *
  * @return null|renderable null for no output or object with data for plugin renderer
  */
 public function course_content_header()
 {
     global $PAGE;
     // if we are on course view page for particular section, return 'back to parent' control
     if ($this->get_viewed_section()) {
         $section = $this->get_section($this->get_viewed_section());
         if ($section->parent) {
             $sr = $this->find_collapsed_parent($section->parent);
             $text = new lang_string('backtosection', 'format_flexsections', $this->get_section_name($section->parent));
         } else {
             $sr = 0;
             $text = new lang_string('backtocourse', 'format_flexsections', $this->get_course()->fullname);
         }
         $url = $this->get_view_url($section->section, array('sr' => $sr));
         return new format_flexsections_edit_control('backto', $url, strip_tags($text));
     }
     // if we are on module view page, return 'back to section' control
     if ($PAGE->context && $PAGE->context->contextlevel == CONTEXT_MODULE && $PAGE->cm) {
         $sectionnum = $PAGE->cm->sectionnum;
         if ($sectionnum) {
             $text = new lang_string('backtosection', 'format_flexsections', $this->get_section_name($sectionnum));
         } else {
             $text = new lang_string('backtocourse', 'format_flexsections', $this->get_course()->fullname);
         }
         return new format_flexsections_edit_control('backto', $this->get_view_url($sectionnum), strip_tags($text));
     }
     return parent::course_content_header();
 }