Differences Between: [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 mod_data\output; 18 19 use mod_data\manager; 20 use moodle_url; 21 use templatable; 22 use renderable; 23 24 /** 25 * Renderable class for the action bar elements in the zero state (no fields created) pages in the database activity. 26 * 27 * @package mod_data 28 * @copyright 2022 Amaia Anabitarte <amaia@moodle.com> 29 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 30 */ 31 class zero_state_action_bar implements templatable, renderable { 32 33 /** @var manager The manager instance. */ 34 protected $manager; 35 36 /** 37 * The class constructor. 38 * 39 * @param manager $manager The manager instance. 40 */ 41 public function __construct(manager $manager) { 42 $this->manager = $manager; 43 } 44 45 /** 46 * Export the data for the mustache template. 47 * 48 * @param \renderer_base $output The renderer to be used to render the action bar elements. 49 * @return array 50 */ 51 public function export_for_template(\renderer_base $output): array { 52 global $PAGE; 53 54 $data = []; 55 if ($this->manager->can_manage_templates()) { 56 $cm = $this->manager->get_coursemodule(); 57 $instance = $this->manager->get_instance(); 58 $params = ['id' => $cm->id, 'backto' => $PAGE->url->out(false)]; 59 60 $usepresetlink = new moodle_url('/mod/data/preset.php', $params); 61 $usepresetbutton = new \single_button($usepresetlink, 62 get_string('usestandard', 'mod_data'), 'get', \single_button::BUTTON_PRIMARY); 63 $data['usepresetbutton'] = $usepresetbutton->export_for_template($output); 64 65 $actionbar = new \mod_data\output\action_bar($instance->id, $PAGE->url); 66 $createfieldbutton = $actionbar->get_create_fields(); 67 $data['createfieldbutton'] = $createfieldbutton->export_for_template($output); 68 69 $importpresetlink = new moodle_url('/mod/data/preset.php', $params); 70 $importpresetbutton = new \single_button($importpresetlink, 71 get_string('importapreset', 'mod_data'), 'get', \single_button::BUTTON_SECONDARY, [ 72 'data-action' => 'importpresets', 73 'data-dataid' => $cm->id, 74 ]); 75 $data['importpresetbutton'] = $importpresetbutton->export_for_template($output); 76 } 77 78 return $data; 79 } 80 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body