-
Notifications
You must be signed in to change notification settings - Fork 23
/
renderer.php
135 lines (122 loc) · 4.7 KB
/
renderer.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* @package mod_pdfannotator
* @copyright 2018 RWTH Aachen (see README.md)
* @author Rabea de Groot and Anna Heynkes
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*
*/
defined('MOODLE_INTERNAL') || die();
class mod_pdfannotator_renderer extends plugin_renderer_base {
/**
*
* @param type $index
* @return type
*/
public function render_index($index) {
return $this->render_from_template('pdfannotator/index', $index->export_for_template($this));
}
/**
*
* @param \templatable $statistic
* @return type
*/
public function render_statistic(\templatable $statistic) {
$data = $statistic->export_for_template($this);
return $this->render_from_template('mod_pdfannotator/statistic', $data);
}
/**
* renders dropdown-actionmenu. Currently used on overview in the categories "answers" and "reports".
* @param \templatable $dropdownmenu
* @return type
*/
public function render_dropdownmenu(\templatable $dropdownmenu) {
$data = $dropdownmenu->export_for_template($this);
return $this->render_from_template('mod_pdfannotator/dropdownmenu', $data);
}
/**
* Render a table containing information about a comment the user wants to report
*
* @param pdfannotator_comment_info $info a renderable
* @return string
*/
public function render_pdfannotator_comment_info(pdfannotator_comment_info $info) {
$o = '';
$o .= $this->output->container_start('appointmentinfotable');
$o .= $this->output->box_start('boxaligncenter appointmentinfotable');
$t = new html_table();
$row = new html_table_row();
$cell1 = new html_table_cell(get_string('slotdatetimelabel', 'pdfannotator'));
$cell2 = $info->datetime;
$row->cells = array($cell1, $cell2);
$t->data[] = $row;
$row = new html_table_row();
$cell1 = new html_table_cell(get_string('author', 'pdfannotator'));
$cell2 = new html_table_cell($info->author);
$row->cells = array($cell1, $cell2);
$t->data[] = $row;
$row = new html_table_row();
$cell1 = new html_table_cell(get_string('comment', 'pdfannotator'));
$cell2 = new html_table_cell($info->content);
$row->cells = array($cell1, $cell2);
$t->data[] = $row;
$o .= html_writer::table($t);
$o .= $this->output->box_end();
$o .= $this->output->container_end();
return $o;
}
/**
* Construct a tab header.
*
* @param moodle_url $baseurl
* @param string $what
* @param string $namekey
* @param string $subpage
* @param string $nameargs
* @return tabobject
*/
private function pdfannotator_create_tab(moodle_url $baseurl, $action, $namekey = null, $pdfannotatorname = null,
$nameargs = null) {
$taburl = new moodle_url($baseurl, array('action' => $action));
$tabname = get_string($namekey, 'pdfannotator', $nameargs);
if ($pdfannotatorname) {
strlen($pdfannotatorname) > 20 ? $tabname = substr($pdfannotatorname, 0, 21) . "..." : $tabname = $pdfannotatorname;
}
$id = $action;
$tab = new tabobject($id, $taburl, $tabname);
return $tab;
}
/**
* Render the tab header hierarchy.
*
* @param moodle_url $baseurl
* @param type $pdfannotatorname
* @param type $context
* @param type $selected
* @param type $inactive
* @return type
*/
public function pdfannotator_render_tabs(moodle_url $baseurl, $pdfannotatorname, $context, $selected = null, $inactive = null) {
$overviewtab = $this->pdfannotator_create_tab($baseurl, 'overview', 'overview');
$level1 = array(
$overviewtab,
$this->pdfannotator_create_tab($baseurl, 'view', 'document', $pdfannotatorname),
$this->pdfannotator_create_tab($baseurl, 'statistic', 'statistic'),
);
return $this->tabtree($level1, $selected, $inactive);
}
}