[ Index ] |
PHP Cross Reference of moodle-2.8 |
[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 edit controls of a section 78 * 79 * @param stdClass $course The course entry from DB 80 * @param stdClass $section The course_section entry from DB 81 * @param bool $onsectionpage true if being printed on a section page 82 * @return array of links with edit controls 83 */ 84 protected function section_edit_controls($course, $section, $onsectionpage = false) { 85 global $PAGE; 86 87 if (!$PAGE->user_is_editing()) { 88 return array(); 89 } 90 91 $coursecontext = context_course::instance($course->id); 92 93 if ($onsectionpage) { 94 $url = course_get_url($course, $section->section); 95 } else { 96 $url = course_get_url($course); 97 } 98 $url->param('sesskey', sesskey()); 99 100 $controls = array(); 101 if (has_capability('moodle/course:setcurrentsection', $coursecontext)) { 102 if ($course->marker == $section->section) { // Show the "light globe" on/off. 103 $url->param('marker', 0); 104 $controls[] = html_writer::link($url, 105 html_writer::empty_tag('img', array('src' => $this->output->pix_url('i/marked'), 106 'class' => 'icon ', 'alt' => get_string('markedthistopic'))), 107 array('title' => get_string('markedthistopic'), 'class' => 'editing_highlight')); 108 } else { 109 $url->param('marker', $section->section); 110 $controls[] = html_writer::link($url, 111 html_writer::empty_tag('img', array('src' => $this->output->pix_url('i/marker'), 112 'class' => 'icon', 'alt' => get_string('markthistopic'))), 113 array('title' => get_string('markthistopic'), 'class' => 'editing_highlight')); 114 } 115 } 116 117 return array_merge($controls, parent::section_edit_controls($course, $section, $onsectionpage)); 118 } 119 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:29:05 2014 | Cross-referenced by PHPXref 0.7.1 |