See Release Notes
Long Term Support Release
Differences Between: [Versions 39 and 311] [Versions 39 and 400] [Versions 39 and 401] [Versions 39 and 402] [Versions 39 and 403]
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 * File containing the class activity navigation renderable. 19 * 20 * @package core_course 21 * @copyright 2017 Mark Nelson <markn@moodle.com> 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 namespace core_course\output; 25 26 defined('MOODLE_INTERNAL') || die(); 27 28 use renderable; 29 use templatable; 30 use url_select; 31 32 /** 33 * The class activity navigation renderable. 34 * 35 * @package core_course 36 * @copyright 2017 Mark Nelson <markn@moodle.com> 37 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 38 */ 39 class activity_navigation implements renderable, templatable { 40 41 /** 42 * @var \action_link The action link object for the prev link. 43 */ 44 public $prevlink = null; 45 46 /** 47 * @var \action_link The action link object for the next link. 48 */ 49 public $nextlink = null; 50 51 /** 52 * @var url_select The url select object for the activity selector menu. 53 */ 54 public $activitylist = null; 55 56 /** 57 * Constructor. 58 * 59 * @param \cm_info|null $prevmod The previous module to display, null if none. 60 * @param \cm_info|null $nextmod The next module to display, null if none. 61 * @param array $activitylist The list of activity URLs (as key) and names (as value) for the activity dropdown menu. 62 */ 63 public function __construct($prevmod, $nextmod, $activitylist = array()) { 64 global $OUTPUT; 65 66 // Check if there is a previous module to display. 67 if ($prevmod) { 68 $linkurl = new \moodle_url($prevmod->url, array('forceview' => 1)); 69 $linkname = $prevmod->get_formatted_name(); 70 if (!$prevmod->visible) { 71 $linkname .= ' ' . get_string('hiddenwithbrackets'); 72 } 73 74 $attributes = [ 75 'class' => 'btn btn-link', 76 'id' => 'prev-activity-link', 77 'title' => $linkname, 78 ]; 79 $this->prevlink = new \action_link($linkurl, $OUTPUT->larrow() . ' ' . $linkname, null, $attributes); 80 } 81 82 // Check if there is a next module to display. 83 if ($nextmod) { 84 $linkurl = new \moodle_url($nextmod->url, array('forceview' => 1)); 85 $linkname = $nextmod->get_formatted_name(); 86 if (!$nextmod->visible) { 87 $linkname .= ' ' . get_string('hiddenwithbrackets'); 88 } 89 90 $attributes = [ 91 'class' => 'btn btn-link', 92 'id' => 'next-activity-link', 93 'title' => $linkname, 94 ]; 95 $this->nextlink = new \action_link($linkurl, $linkname . ' ' . $OUTPUT->rarrow(), null, $attributes); 96 } 97 98 // Render the activity list dropdown menu if available. 99 if (!empty($activitylist)) { 100 $select = new url_select($activitylist, '', array('' => get_string('jumpto'))); 101 $select->set_label(get_string('jumpto'), array('class' => 'sr-only')); 102 $select->attributes = array('id' => 'jump-to-activity'); 103 $this->activitylist = $select; 104 } 105 } 106 107 /** 108 * Export this data so it can be used as the context for a mustache template. 109 * 110 * @param \renderer_base $output Renderer base. 111 * @return \stdClass 112 */ 113 public function export_for_template(\renderer_base $output) { 114 $data = new \stdClass(); 115 if ($this->prevlink) { 116 $data->prevlink = $this->prevlink->export_for_template($output); 117 } 118 119 if ($this->nextlink) { 120 $data->nextlink = $this->nextlink->export_for_template($output); 121 } 122 123 if ($this->activitylist) { 124 $data->activitylist = $this->activitylist->export_for_template($output); 125 } 126 127 return $data; 128 } 129 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body