1 |
efrain |
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 'tool_licensemanager' component.
|
|
|
19 |
*
|
|
|
20 |
* @package tool_licensemanager
|
|
|
21 |
* @copyright Tom Dickman <tomdickman@catalyst-au.net>
|
|
|
22 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
23 |
*/
|
|
|
24 |
|
|
|
25 |
namespace tool_licensemanager\output;
|
|
|
26 |
|
|
|
27 |
defined('MOODLE_INTERNAL') || die();
|
|
|
28 |
|
|
|
29 |
use license_manager;
|
|
|
30 |
use plugin_renderer_base;
|
|
|
31 |
use tool_licensemanager\helper;
|
|
|
32 |
|
|
|
33 |
/**
|
|
|
34 |
* Renderer class for 'tool_licensemanager' component.
|
|
|
35 |
*
|
|
|
36 |
* @package tool_licensemanager
|
|
|
37 |
* @copyright 2019 Tom Dickman <tomdickman@catalyst-au.net>
|
|
|
38 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
39 |
*/
|
|
|
40 |
class renderer extends plugin_renderer_base {
|
|
|
41 |
|
|
|
42 |
/**
|
|
|
43 |
* Render the headers for create license form.
|
|
|
44 |
*
|
|
|
45 |
* @return string html fragment for display.
|
|
|
46 |
*/
|
|
|
47 |
public function render_create_licence_headers(): string {
|
|
|
48 |
|
|
|
49 |
$this->page->navbar->add(get_string('createlicense', 'tool_licensemanager'),
|
|
|
50 |
helper::get_create_license_url());
|
|
|
51 |
|
|
|
52 |
$return = $this->header();
|
|
|
53 |
$return .= $this->heading(get_string('createlicense', 'tool_licensemanager'));
|
|
|
54 |
|
|
|
55 |
return $return;
|
|
|
56 |
}
|
|
|
57 |
|
|
|
58 |
/**
|
|
|
59 |
* Render the headers for edit license form.
|
|
|
60 |
*
|
|
|
61 |
* @param string $licenseshortname the shortname of license to edit.
|
|
|
62 |
*
|
|
|
63 |
* @return string html fragment for display.
|
|
|
64 |
*/
|
|
|
65 |
public function render_edit_licence_headers(string $licenseshortname): string {
|
|
|
66 |
|
|
|
67 |
$this->page->navbar->add(get_string('editlicense', 'tool_licensemanager'),
|
|
|
68 |
helper::get_update_license_url($licenseshortname));
|
|
|
69 |
|
|
|
70 |
$return = $this->header();
|
|
|
71 |
$return .= $this->heading(get_string('editlicense', 'tool_licensemanager'));
|
|
|
72 |
|
|
|
73 |
return $return;
|
|
|
74 |
}
|
|
|
75 |
|
|
|
76 |
/**
|
|
|
77 |
* Render the license manager table.
|
|
|
78 |
*
|
|
|
79 |
* @param \renderable $table the renderable.
|
|
|
80 |
*
|
|
|
81 |
* @return string HTML.
|
|
|
82 |
*/
|
|
|
83 |
public function render_table(\renderable $table) {
|
|
|
84 |
$licenses = license_manager::get_licenses();
|
|
|
85 |
|
|
|
86 |
// Add the create license button.
|
|
|
87 |
$html = $table->create_license_link();
|
|
|
88 |
|
|
|
89 |
// Add the table containing licenses for management.
|
|
|
90 |
$html .= $this->box_start('generalbox editorsui');
|
|
|
91 |
$html .= $table->create_license_manager_table($licenses, $this);
|
|
|
92 |
$html .= $this->box_end();
|
|
|
93 |
|
|
|
94 |
return $html;
|
|
|
95 |
}
|
|
|
96 |
}
|