-
Notifications
You must be signed in to change notification settings - Fork 12
/
renderer.php
223 lines (209 loc) · 11.4 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
<?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/>.
/**
* Moodle renderer used to display special elements of the lesson module.
*
* @package tinymce_recordrtc
* @author Jesus Federico (jesus [at] blindsidenetworks [dt] com)
* @author Jacob Prud'homme (jacob [dt] prudhomme [at] blindsidenetworks [dt] com)
* @copyright 2016 onwards, Blindside Networks Inc.
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die;
/**
* This class defines the custom renderer for this plugin.
* @copyright 2017 onwards, Blindside Networks Inc.
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class tinymce_recordrtc_renderer extends plugin_renderer_base {
/**
* Renders the HTML for the plugin, for the alerts section.
* @param boolean $oldermoodle True if Moodle >= 3.2, else False.
* @return string
*/
public function render_alerts($oldermoodle) {
if ($oldermoodle) {
$output = html_writer::start_tag('div', array('class' => 'row-fluid hide'));
$output .= html_writer::start_tag('div', array('class' => 'span12'));
$output .= html_writer::start_tag('div', array('id' => 'alert-warning', 'class' => 'alert'));
} else {
$output = html_writer::start_tag('div', array('class' => 'row hide'));
$output .= html_writer::start_tag('div', array('class' => 'col-xs-12'));
$output .= html_writer::start_tag('div', array('id' => 'alert-warning', 'class' => 'alert alert-warning'));
}
$output .= html_writer::start_tag('strong');
$output .= get_string('browseralert_title', 'tinymce_recordrtc');
$output .= html_writer::end_tag('strong');
$output .= ' ';
$output .= get_string('browseralert', 'tinymce_recordrtc');
$output .= html_writer::end_tag('div');
$output .= html_writer::end_tag('div');
$output .= html_writer::end_tag('div');
if ($oldermoodle) {
$output .= html_writer::start_tag('div', array('class' => 'row-fluid hide'));
$output .= html_writer::start_tag('div', array('class' => 'span12'));
$output .= html_writer::start_tag('div', array('id' => 'alert-danger', 'class' => 'alert alert-error'));
} else {
$output .= html_writer::start_tag('div', array('class' => 'row hide'));
$output .= html_writer::start_tag('div', array('class' => 'col-xs-12'));
$output .= html_writer::start_tag('div', array('id' => 'alert-danger', 'class' => 'alert alert-danger'));
}
$output .= html_writer::start_tag('strong');
$output .= get_string('insecurealert_title', 'tinymce_recordrtc');
$output .= html_writer::end_tag('strong');
$output .= ' ';
$output .= get_string('insecurealert', 'tinymce_recordrtc');
$output .= html_writer::end_tag('div');
$output .= html_writer::end_tag('div');
$output .= html_writer::end_tag('div');
return $output;
}
/**
* Renders the HTML for the plugin, for the audio/video player section.
* @param boolean $oldermoodle True if Moodle >= 3.2, else False.
* @param string $type Either 'audio' or 'video', depending on where it's being rendered.
* @return string
*/
public function render_player($oldermoodle, $type) {
if ($oldermoodle && $type === 'audio') {
$output = html_writer::start_tag('div', array('class' => 'row-fluid hide'));
$output .= html_writer::start_tag('div', array('class' => 'span1')).html_writer::end_tag('div');
$output .= html_writer::start_tag('div', array('class' => 'span10'));
$output .= html_writer::start_tag('audio', array('id' => 'player'));
$output .= html_writer::end_tag('audio');
$output .= html_writer::end_tag('div');
$output .= html_writer::start_tag('div', array('class' => 'span1')).html_writer::end_tag('div');
} else if ($oldermoodle && $type === 'video') {
$output = html_writer::start_tag('div', array('class' => 'row-fluid hide'));
$output .= html_writer::start_tag('div', array('class' => 'span12'));
$output .= html_writer::start_tag('video', array('id' => 'player'));
$output .= html_writer::end_tag('video');
$output .= html_writer::end_tag('div');
} else if ($type === 'audio') {
$output = html_writer::start_tag('div', array('class' => 'row hide'));
$output .= html_writer::start_tag('div', array('class' => 'col-xs-1')).html_writer::end_tag('div');
$output .= html_writer::start_tag('div', array('class' => 'col-xs-10'));
$output .= html_writer::start_tag('audio', array('id' => 'player'));
$output .= html_writer::end_tag('audio');
$output .= html_writer::end_tag('div');
$output .= html_writer::start_tag('div', array('class' => 'col-xs-1')).html_writer::end_tag('div');
} else {
$output = html_writer::start_tag('div', array('class' => 'row hide'));
$output .= html_writer::start_tag('div', array('class' => 'col-xs-12'));
$output .= html_writer::start_tag('video', array('id' => 'player'));
$output .= html_writer::end_tag('video');
$output .= html_writer::end_tag('div');
}
$output .= html_writer::end_tag('div');
return $output;
}
/**
* Renders the HTML for the plugin, for the start/stop and upload buttons section.
* @param boolean $oldermoodle True if Moodle >= 3.2, else False.
* @return string
*/
public function render_buttons($oldermoodle) {
if ($oldermoodle) {
$output = html_writer::start_tag('div', array('class' => 'row-fluid'));
$output .= html_writer::start_tag('div', array('class' => 'span1')).html_writer::end_tag('div');
$output .= html_writer::start_tag('div', array('class' => 'span10'));
$output .= html_writer::start_tag('button', array(
'id' => 'start-stop',
'class' => 'btn btn-large btn-danger btn-block'
));
$output .= get_string('startrecording', 'tinymce_recordrtc');
$output .= html_writer::end_tag('button');
$output .= html_writer::end_tag('div');
$output .= html_writer::start_tag('div', array('class' => 'span1')).html_writer::end_tag('div');
$output .= html_writer::end_tag('div');
$output .= html_writer::start_tag('div', array('class' => 'row-fluid hide'));
$output .= html_writer::start_tag('div', array('class' => 'span3')).html_writer::end_tag('div');
$output .= html_writer::start_tag('div', array('class' => 'span6'));
$output .= html_writer::start_tag('button', array('id' => 'upload', 'class' => 'btn btn-primary btn-block'));
$output .= get_string('attachrecording', 'tinymce_recordrtc');
$output .= html_writer::end_tag('button');
$output .= html_writer::end_tag('div');
$output .= html_writer::start_tag('div', array('class' => 'span3')).html_writer::end_tag('div');
$output .= html_writer::end_tag('div');
} else {
$output = html_writer::start_tag('div', array('class' => 'row'));
$output .= html_writer::start_tag('div', array('class' => 'col-xs-1')).html_writer::end_tag('div');
$output .= html_writer::start_tag('div', array('class' => 'col-xs-10'));
$output .= html_writer::start_tag('button', array(
'id' => 'start-stop',
'class' => 'btn btn-lg btn-outline-danger btn-block'
));
$output .= get_string('startrecording', 'tinymce_recordrtc');
$output .= html_writer::end_tag('button');
$output .= html_writer::end_tag('div');
$output .= html_writer::start_tag('div', array('class' => 'col-xs-1')).html_writer::end_tag('div');
$output .= html_writer::end_tag('div');
$output .= html_writer::start_tag('div', array('class' => 'row hide'));
$output .= html_writer::start_tag('div', array('class' => 'col-xs-3')).html_writer::end_tag('div');
$output .= html_writer::start_tag('div', array('class' => 'col-xs-6'));
$output .= html_writer::start_tag('button', array('id' => 'upload', 'class' => 'btn btn-primary btn-block'));
$output .= get_string('attachrecording', 'tinymce_recordrtc');
$output .= html_writer::end_tag('button');
$output .= html_writer::end_tag('div');
$output .= html_writer::start_tag('div', array('class' => 'col-xs-3')).html_writer::end_tag('div');
$output .= html_writer::end_tag('div');
}
return $output;
}
/**
* Renders the HTML for the plugin, for audio recording.
* @param boolean $oldermoodle True if Moodle >= 3.2, else False.
* @return string
*/
public function render_audiortc_index($oldermoodle) {
$output = html_writer::start_tag('div', array('class' => 'container-fluid'));
$output .= self::render_alerts($oldermoodle);
$output .= self::render_player($oldermoodle, 'audio');
$output .= self::render_buttons($oldermoodle);
$output .= html_writer::end_tag('div');
return $output;
}
/**
* Renders the HTML for the plugin, for video recording.
* @param boolean $oldermoodle True if Moodle >= 3.2, else False.
* @return string
*/
public function render_videortc_index($oldermoodle) {
$output = html_writer::start_tag('div', array('class' => 'container-fluid'));
$output .= self::render_alerts($oldermoodle);
$output .= self::render_player($oldermoodle, 'video');
$output .= self::render_buttons($oldermoodle);
$output .= html_writer::end_tag('div');
return $output;
}
/**
* Renders the HTML to include the necessary scripts.
* @return string
*/
public function render_scripts() {
$output = html_writer::start_tag('script', array('type' => 'text/javascript'));
$output .= 'var editor_tinymce_include = function(path) {'."\n";
$output .= 'document.write(\'<script type="text/javascript" src="\' + parent.tinyMCE.baseURL + \'/\' +
path + \'"></\' + \'script>\');'."\n";
$output .= '};'."\n";
$output .= 'editor_tinymce_include(\'tiny_mce_popup.js\');'."\n";
$output .= 'editor_tinymce_include(\'utils/validate.js\');'."\n";
$output .= 'editor_tinymce_include(\'utils/form_utils.js\');'."\n";
$output .= 'editor_tinymce_include(\'utils/editable_selects.js\');'."\n";
$output .= html_writer::end_tag('script');
return $output;
}
}