See Release Notes
Long Term Support Release
Differences Between: [Versions 401 and 402] [Versions 401 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 namespace core_badges\output; 18 19 use moodle_page; 20 use moodle_url; 21 use renderer_base; 22 use single_button; 23 24 /** 25 * Class standard_action_bar - Display the action bar 26 * 27 * @package core_badges 28 * @copyright 2021 Peter Dias 29 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 30 */ 31 class standard_action_bar extends base_action_bar { 32 /** @var bool $showmanage Whether or not to show the manage badges button. */ 33 protected $showmanage; 34 35 /** @var bool $showaddbadge Whether or not to show the add badges button. */ 36 protected $showaddbadge; 37 38 /** @var moodle_url $backurl BackURL to be used when the back button is required. */ 39 protected $backurl; 40 41 /** 42 * standard_action_bar constructor 43 * 44 * @param moodle_page $page The page object 45 * @param int $type The type of badge we are operating with 46 * @param bool $showmanage Whether or not to show the manage badges button 47 * @param bool $showaddbadge Whether or not to show the add badges button 48 * @param moodle_url|null $backurl The backurl to be used 49 */ 50 public function __construct(moodle_page $page, int $type, bool $showmanage = true, 51 $showaddbadge = true, ?moodle_url $backurl = null) { 52 parent::__construct($page, $type); 53 54 $this->showmanage = $showmanage; 55 $this->showaddbadge = $showaddbadge; 56 $this->backurl = $backurl; 57 } 58 59 /** 60 * The template that this tertiary nav should use. 61 * 62 * @return string 63 */ 64 public function get_template(): string { 65 return 'core_badges/manage_badges'; 66 } 67 68 /** 69 * Export the action bar 70 * 71 * @param renderer_base $output 72 * @return array The buttons to be rendered 73 */ 74 public function export_for_template(renderer_base $output): array { 75 $buttons = []; 76 if ($this->backurl) { 77 $buttons[] = new single_button($this->backurl, get_string('back'), 'get'); 78 } 79 80 $params = ['type' => $this->type]; 81 if ($this->page->context->contextlevel == CONTEXT_COURSE) { 82 $params['id'] = $this->page->context->instanceid; 83 } 84 85 if ($this->showmanage) { 86 $buttons[] = new single_button(new moodle_url('/badges/index.php', $params), 87 get_string('managebadges', 'core_badges'), 'get'); 88 } 89 90 if ($this->showaddbadge && has_capability('moodle/badges:createbadge', $this->page->context)) { 91 $buttons[] = new single_button(new moodle_url('/badges/newbadge.php', $params), 92 get_string('newbadge', 'core_badges'), 'post', true); 93 } 94 95 foreach ($buttons as $key => $button) { 96 $buttons[$key] = $button->export_for_template($output); 97 } 98 99 $data = ['buttons' => $buttons]; 100 $additional = $this->get_third_party_nav_action($output); 101 $data += $additional ?: []; 102 103 return $data; 104 } 105 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body