. namespace mod_data\output; use mod_data\manager; use moodle_url; use templatable; use renderable; /** * Renderable class for the action bar elements for an empty database activity. * * @package mod_data * @copyright 2022 Amaia Anabitarte * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class empty_database_action_bar implements templatable, renderable { /** @var manager The manager instance. */ protected $manager; /** * The class constructor. * * @param int $id The database module id. */ public function __construct(manager $manager) { $this->manager = $manager; } /** * Export the data for the mustache template. * * @param \renderer_base $output The renderer to be used to render the action bar elements. * @return array */ public function export_for_template(\renderer_base $output): array { global $PAGE; $instance = $this->manager->get_instance(); $addentrybutton = new add_entries_action($instance->id); $data = ['addentrybutton' => $addentrybutton->export_for_template($output)]; if (has_capability('mod/data:manageentries', $PAGE->context)) { $params = ['d' => $instance->id, 'backto' => $PAGE->url->out(false)]; $importentrieslink = new moodle_url('/mod/data/import.php', $params); $importentriesbutton = new \single_button($importentrieslink, get_string('importentries', 'mod_data'), 'get'); $data['importentriesbutton'] = $importentriesbutton->export_for_template($output); } return $data; } }