芝麻web文件管理V1.00
编辑当前文件:/home2/sdektunc/public_html/cepali/course/format/topics/renderer.php
. /** * Renderer for outputting the topics course format. * * @package format_topics * @copyright 2012 Dan Poltawski * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @since Moodle 2.3 */ defined('MOODLE_INTERNAL') || die(); require_once($CFG->dirroot.'/course/format/renderer.php'); /** * Basic renderer for topics format. * * @copyright 2012 Dan Poltawski * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class format_topics_renderer extends format_section_renderer_base { /** * Constructor method, calls the parent constructor * * @param moodle_page $page * @param string $target one of rendering target constants */ public function __construct(moodle_page $page, $target) { parent::__construct($page, $target); // Since format_topics_renderer::section_edit_controls() only displays the 'Set current section' control when editing mode is on // we need to be sure that the link 'Turn editing mode on' is available for a user who does not have any other managing capability. $page->set_other_editing_capability('moodle/course:setcurrentsection'); } /** * Generate the starting container html for a list of sections * @return string HTML to output. */ protected function start_section_list() { return html_writer::start_tag('ul', array('class' => 'topics')); } /** * Generate the closing container html for a list of sections * @return string HTML to output. */ protected function end_section_list() { return html_writer::end_tag('ul'); } /** * Generate the title for this section page * @return string the page title */ protected function page_title() { return get_string('topicoutline'); } /** * Generate the section title, wraps it in a link to the section page if page is to be displayed on a separate page * * @param stdClass $section The course_section entry from DB * @param stdClass $course The course entry from DB * @return string HTML to output. */ public function section_title($section, $course) { return $this->render(course_get_format($course)->inplace_editable_render_section_name($section)); } /** * Generate the section title to be displayed on the section page, without a link * * @param stdClass $section The course_section entry from DB * @param stdClass $course The course entry from DB * @return string HTML to output. */ public function section_title_without_link($section, $course) { return $this->render(course_get_format($course)->inplace_editable_render_section_name($section, false)); } /** * Generate the edit control items 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 edit control items */ protected function section_edit_control_items($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 ($section->section && has_capability('moodle/course:setcurrentsection', $coursecontext)) { if ($course->marker == $section->section) { // Show the "light globe" on/off. $url->param('marker', 0); $highlightoff = get_string('highlightoff'); $controls['highlight'] = array('url' => $url, "icon" => 'i/marked', 'name' => $highlightoff, 'pixattr' => array('class' => ''), 'attr' => array('class' => 'editing_highlight', 'data-action' => 'removemarker')); } else { $url->param('marker', $section->section); $highlight = get_string('highlight'); $controls['highlight'] = array('url' => $url, "icon" => 'i/marker', 'name' => $highlight, 'pixattr' => array('class' => ''), 'attr' => array('class' => 'editing_highlight', 'data-action' => 'setmarker')); } } $parentcontrols = parent::section_edit_control_items($course, $section, $onsectionpage); // If the edit key exists, we are going to insert our controls after it. if (array_key_exists("edit", $parentcontrols)) { $merged = array(); // We can't use splice because we are using associative arrays. // Step through the array and merge the arrays. foreach ($parentcontrols as $key => $action) { $merged[$key] = $action; if ($key == "edit") { // If we have come to the edit key, merge these controls here. $merged = array_merge($merged, $controls); } } return $merged; } else { return array_merge($controls, $parentcontrols); } } }