[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * Renderer for outputting the topics course format. 19 * 20 * @package format_topics 21 * @copyright 2012 Dan Poltawski 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 * @since Moodle 2.3 24 */ 25 26 27 defined('MOODLE_INTERNAL') || die(); 28 require_once($CFG->dirroot.'/course/format/renderer.php'); 29 30 /** 31 * Basic renderer for topics format. 32 * 33 * @copyright 2012 Dan Poltawski 34 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 35 */ 36 class format_topics_renderer extends format_section_renderer_base { 37 38 /** 39 * Constructor method, calls the parent constructor 40 * 41 * @param moodle_page $page 42 * @param string $target one of rendering target constants 43 */ 44 public function __construct(moodle_page $page, $target) { 45 parent::__construct($page, $target); 46 47 // Since format_topics_renderer::section_edit_controls() only displays the 'Set current section' control when editing mode is on 48 // 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. 49 $page->set_other_editing_capability('moodle/course:setcurrentsection'); 50 } 51 52 /** 53 * Generate the starting container html for a list of sections 54 * @return string HTML to output. 55 */ 56 protected function start_section_list() { 57 return html_writer::start_tag('ul', array('class' => 'topics')); 58 } 59 60 /** 61 * Generate the closing container html for a list of sections 62 * @return string HTML to output. 63 */ 64 protected function end_section_list() { 65 return html_writer::end_tag('ul'); 66 } 67 68 /** 69 * Generate the title for this section page 70 * @return string the page title 71 */ 72 protected function page_title() { 73 return get_string('topicoutline'); 74 } 75 76 /** 77 * Generate the section title, wraps it in a link to the section page if page is to be displayed on a separate page 78 * 79 * @param stdClass $section The course_section entry from DB 80 * @param stdClass $course The course entry from DB 81 * @return string HTML to output. 82 */ 83 public function section_title($section, $course) { 84 return $this->render(course_get_format($course)->inplace_editable_render_section_name($section)); 85 } 86 87 /** 88 * Generate the section title to be displayed on the section page, without a link 89 * 90 * @param stdClass $section The course_section entry from DB 91 * @param stdClass $course The course entry from DB 92 * @return string HTML to output. 93 */ 94 public function section_title_without_link($section, $course) { 95 return $this->render(course_get_format($course)->inplace_editable_render_section_name($section, false)); 96 } 97 98 /** 99 * Generate the edit control items of a section 100 * 101 * @param stdClass $course The course entry from DB 102 * @param stdClass $section The course_section entry from DB 103 * @param bool $onsectionpage true if being printed on a section page 104 * @return array of edit control items 105 */ 106 protected function section_edit_control_items($course, $section, $onsectionpage = false) { 107 global $PAGE; 108 109 if (!$PAGE->user_is_editing()) { 110 return array(); 111 } 112 113 $coursecontext = context_course::instance($course->id); 114 115 if ($onsectionpage) { 116 $url = course_get_url($course, $section->section); 117 } else { 118 $url = course_get_url($course); 119 } 120 $url->param('sesskey', sesskey()); 121 122 $isstealth = $section->section > $course->numsections; 123 $controls = array(); 124 if (!$isstealth && $section->section && has_capability('moodle/course:setcurrentsection', $coursecontext)) { 125 if ($course->marker == $section->section) { // Show the "light globe" on/off. 126 $url->param('marker', 0); 127 $markedthistopic = get_string('markedthistopic'); 128 $highlightoff = get_string('highlightoff'); 129 $controls['highlight'] = array('url' => $url, "icon" => 'i/marked', 130 'name' => $highlightoff, 131 'pixattr' => array('class' => '', 'alt' => $markedthistopic), 132 'attr' => array('class' => 'editing_highlight', 'title' => $markedthistopic)); 133 } else { 134 $url->param('marker', $section->section); 135 $markthistopic = get_string('markthistopic'); 136 $highlight = get_string('highlight'); 137 $controls['highlight'] = array('url' => $url, "icon" => 'i/marker', 138 'name' => $highlight, 139 'pixattr' => array('class' => '', 'alt' => $markthistopic), 140 'attr' => array('class' => 'editing_highlight', 'title' => $markthistopic)); 141 } 142 } 143 144 $parentcontrols = parent::section_edit_control_items($course, $section, $onsectionpage); 145 146 // If the edit key exists, we are going to insert our controls after it. 147 if (array_key_exists("edit", $parentcontrols)) { 148 $merged = array(); 149 // We can't use splice because we are using associative arrays. 150 // Step through the array and merge the arrays. 151 foreach ($parentcontrols as $key => $action) { 152 $merged[$key] = $action; 153 if ($key == "edit") { 154 // If we have come to the edit key, merge these controls here. 155 $merged = array_merge($merged, $controls); 156 } 157 } 158 159 return $merged; 160 } else { 161 return array_merge($controls, $parentcontrols); 162 } 163 } 164 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |