/** * Generate the edit controls of a section * * @param stdClass $course The course entry from DB * @param stdClass $section The course_section entry from DB * @param bool $onsectionpage true if being printed on a section page * @return array of links with edit controls */ protected function section_edit_controls($course, $section, $onsectionpage = false) { if (!$this->userisediting) { return array(); } $coursecontext = context_course::instance($course->id); if ($onsectionpage) { $url = course_get_url($course, $section->section); } else { $url = course_get_url($course); } $url->param('sesskey', sesskey()); if (empty($this->tcsettings)) { $this->tcsettings = $this->courseformat->get_settings(); } $controls = array(); if (($this->tcsettings['layoutstructure'] == 1 || $this->tcsettings['layoutstructure'] == 4) && has_capability('moodle/course:setcurrentsection', $coursecontext)) { if ($course->marker == $section->section) { // Show the "light globe" on/off. $strmarkedthissection = get_string('markedthissection', 'format_topcoll'); $url->param('marker', 0); $controls[] = html_writer::link($url, html_writer::empty_tag('img', array('src' => $this->output->pix_url('i/marked'), 'class' => 'icon ', 'alt' => $strmarkedthissection)), array('title' => $strmarkedthissection, 'class' => 'editing_highlight')); } else { $strmarkthissection = get_string('markthissection', 'format_topcoll'); $url->param('marker', $section->section); $controls[] = html_writer::link($url, html_writer::empty_tag('img', array('src' => $this->output->pix_url('i/marker'), 'class' => 'icon', 'alt' => $strmarkthissection)), array('title' => $strmarkthissection, 'class' => 'editing_highlight')); } } return array_merge($controls, parent::section_edit_controls($course, $section, $onsectionpage)); }
/** * Generate the edit controls of a section * * @param stdClass $course The course entry from DB * @param stdClass $section The course_section entry from DB * @param bool $onsectionpage true if being printed on a section page * @return array of links with edit controls */ protected function section_edit_controls($course, $section, $onsectionpage = false) { global $PAGE; if (!$PAGE->user_is_editing()) { return array(); } $coursecontext = context_course::instance($course->id); if ($onsectionpage) { $url = course_get_url($course, $section->section); } else { $url = course_get_url($course); } $url->param('sesskey', sesskey()); $controls = array(); if (has_capability('moodle/course:setcurrentsection', $coursecontext)) { if ($course->marker == $section->section) { // Show the "light globe" on/off. $url->param('marker', 0); $controls[] = html_writer::link($url, html_writer::empty_tag('img', array('src' => $this->output->pix_url('i/marked'), 'class' => 'icon ', 'alt' => get_string('markedthistopic'))), array('title' => get_string('markedthistopic'), 'class' => 'editing_highlight')); } else { $url->param('marker', $section->section); $controls[] = html_writer::link($url, html_writer::empty_tag('img', array('src' => $this->output->pix_url('i/marker'), 'class' => 'icon', 'alt' => get_string('markthistopic'))), array('title' => get_string('markthistopic'), 'class' => 'editing_highlight')); } } return array_merge($controls, parent::section_edit_controls($course, $section, $onsectionpage)); }