-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrenderer.php
167 lines (146 loc) · 5.74 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
<?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/>.
/**
* Defines the renderer for the odisseagtafsync tool.
*
* It uses the standard core Moodle formslib. For more info about them, please
* visit: http://docs.moodle.org/en/Development:lib/formslib.php
*
* @package tool
* @subpackage odisseagtafsync
* @copyright 2013 Departament d'Ensenyament de la Generalitat de Catalunya
* @author Sara Arjona Téllez <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
class tool_odisseagtafsync_renderer extends plugin_renderer_base
{
public function sync_page($run, $results, $errors) {
$output = '';
$output .= $this->header();
$output .= $this->heading(get_string('pluginname', 'tool_odisseagtafsync'));
if (!empty($errors)) {
$strerror = implode('<br/><br/>', $errors);
$output .= '<br/>';
$output .= $this->notification($strerror);
}
if (!empty($results)) {
foreach ($results as $result) {
if (!empty($result)) {
$output .= $this->box($result);
}
}
} else {
if ($run == 1) { // Synchronize
$output .= '<p><br/>';
$output .= get_string('nosyncfiles', 'tool_odisseagtafsync');
$output .= '</p>';
}
}
$output .= $this->back_to_index($run);
$output .= $this->footer();
return $output;
}
public function process_csv_page($file, $response, $params) {
extract($params);
$output = '';
$output .= $this->heading($file);
if (!empty($response)) {
$output .= '<br/>' . $this->container($response[1]);
}
$output .= $this->box_start('boxwidthnormal boxaligncenter generalbox', 'uploadresults');
$output .= '<p>';
if ($optype != UU_USER_UPDATE) {
$output .= get_string('userscreated', 'tool_uploaduser') . ': ' . $usersnew . '<br />';
}
if ($optype == UU_USER_UPDATE or $optype == UU_USER_ADD_UPDATE) {
$output .= get_string('usersupdated', 'tool_uploaduser') . ': ' . $usersupdated . '<br />';
}
if ($allowdeletes) {
$output .= get_string('usersdeleted', 'tool_uploaduser') . ': ' . $deletes . '<br />';
$output .= get_string('deleteerrors', 'tool_uploaduser') . ': ' . $deleteerrors . '<br />';
}
if ($allowrenames) {
$output .= get_string('usersrenamed', 'tool_uploaduser') . ': ' . $renames . '<br />';
$output .= get_string('renameerrors', 'tool_uploaduser') . ': ' . $renameerrors . '<br />';
}
if ($usersskipped) {
$output .= get_string('usersskipped', 'tool_uploaduser') . ': ' . $usersskipped . '<br />';
}
$output .= get_string('usersweakpassword', 'tool_uploaduser') . ': ' . $weakpasswords . '<br />';
$output .= get_string('errors', 'tool_uploaduser') . ': ' . $userserrors;
$output .= '</p>';
$output .= $this->box_end();
return $output;
}
public function prepare_enrolments_page($params) {
extract($params);
$output = '';
$output .= $this->heading($file);
$output .= '<p><br/>';
$output .= get_string('preparedenrolmentsok', 'tool_odisseagtafsync', $flatfilelocation);
$output .= '</p>';
return $output;
}
public function process_restore_file_page($file) {
$output = '';
$output .= $this->heading($file);
$output .= '<p><br/>';
$output .= get_string('processrestorefileok', 'tool_odisseagtafsync');
$output .= '<br/><br/></p>';
return $output;
}
public function process_delete_file_page($file) {
$output = '';
$output .= $this->heading($file);
$output .= '<p><br/>';
$output .= get_string('processdeletefileok', 'tool_odisseagtafsync');
$output .= '<br/><br/></p>';
return $output;
}
/**
* Render a link in a div, such as the 'Back to plugin main page' link.
*
* @param $url the link URL.
* @param $text the link text.
* @return string html to output.
*/
public function end_of_page_link($url, $text) {
return html_writer::tag('div', html_writer::link($url, $text), ['class' => 'mdl-align']);
}
/**
* Output a link back to the plugin index page.
*
* @param $run
* @return string html to output.
* @throws coding_exception
* @throws moodle_exception
*/
public function back_to_index($run) {
global $CFG;
if ($run == 1) {
return $this->end_of_page_link(
new moodle_url('/' . $CFG->admin . '/tool/odisseagtafsync/index.php'),
get_string('backtoindex', 'tool_odisseagtafsync')
);
} else {
return $this->end_of_page_link(
new moodle_url('/' . $CFG->admin . '/tool/odisseagtafsync/move.php'),
get_string('backtoindex', 'tool_odisseagtafsync')
);
}
}
}