Merge branch 'MD-31803' of git://github.com/mouneyrac/moodle
[moodle.git] / admin / renderer.php
CommitLineData
b9934a17
DM
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 core_admin subsystem
19 *
20 * @package core
21 * @subpackage admin
22 * @copyright 2011 David Mudrak <david@moodle.com>
23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24 */
25
26defined('MOODLE_INTERNAL') || die();
27
28require_once($CFG->libdir . '/pluginlib.php');
29
30/**
31 * Standard HTML output renderer for core_admin subsystem
32 */
33class core_admin_renderer extends plugin_renderer_base {
34
cc359566
TH
35 /**
36 * Display the 'Do you acknowledge the terms of the GPL' page. The first page
37 * during install.
38 * @return string HTML to output.
39 */
40 public function install_licence_page() {
41 global $CFG;
42 $output = '';
43
44 $copyrightnotice = text_to_html(get_string('gpl3'));
45 $copyrightnotice = str_replace('target="_blank"', 'onclick="this.target=\'_blank\'"', $copyrightnotice); // extremely ugly validation hack
46
47 $continue = new single_button(new moodle_url('/admin/index.php', array('lang'=>$CFG->lang, 'agreelicense'=>1)), get_string('continue'), 'get');
48
49 $output .= $this->header();
50 $output .= $this->heading('<a href="http://moodle.org">Moodle</a> - Modular Object-Oriented Dynamic Learning Environment');
51 $output .= $this->heading(get_string('copyrightnotice'));
52 $output .= $this->box($copyrightnotice, 'copyrightnotice');
53 $output .= html_writer::empty_tag('br');
54 $output .= $this->confirm(get_string('doyouagree'), $continue, "http://docs.moodle.org/dev/License");
55 $output .= $this->footer();
56
57 return $output;
58 }
59
9008ec16
PS
60 /**
61 * Display page explaining proper upgrade process,
62 * there can not be any PHP file leftovers...
63 *
64 * @return string HTML to output.
65 */
66 public function upgrade_stale_php_files_page() {
67 $output = '';
68 $output .= $this->header();
69 $output .= $this->heading(get_string('upgradestalefiles', 'admin'));
70 $output .= $this->box_start('generalbox', 'notice');
71 $output .= get_string('upgradestalefilesinfo', 'admin', get_docs_url('Upgrading'));
72 $output .= html_writer::empty_tag('br');
73 $output .= html_writer::tag('div', $this->single_button($this->page->url, get_string('reload'), 'get'), array('class' => 'buttons'));
74 $output .= $this->box_end();
75 $output .= $this->footer();
cc359566
TH
76
77 return $output;
78 }
79
80 /**
81 * Display the 'environment check' page that is displayed during install.
8d1da748
PS
82 * @param int $maturity
83 * @param boolean $envstatus final result of the check (true/false)
84 * @param array $environment_results array of results gathered
85 * @param string $release moodle release
cc359566
TH
86 * @return string HTML to output.
87 */
8d1da748 88 public function install_environment_page($maturity, $envstatus, $environment_results, $release) {
cc359566
TH
89 global $CFG;
90 $output = '';
91
92 $output .= $this->header();
93 $output .= $this->maturity_warning($maturity);
94 $output .= $this->heading("Moodle $release");
95 $output .= $this->release_notes_link();
96
97 $output .= $this->environment_check_table($envstatus, $environment_results);
98
99 if (!$envstatus) {
100 $output .= $this->upgrade_reload(new moodle_url('/admin/index.php', array('agreelicense' => 1, 'lang' => $CFG->lang)));
101 } else {
102 $output .= $this->notification(get_string('environmentok', 'admin'), 'notifysuccess');
103 $output .= $this->continue_button(new moodle_url('/admin/index.php', array('agreelicense'=>1, 'confirmrelease'=>1, 'lang'=>$CFG->lang)));
104 }
105
106 $output .= $this->footer();
107 return $output;
108 }
109
39f15cc7
DM
110 /**
111 * Displays the list of plugins with unsatisfied dependencies
112 *
113 * @param double|string|int $version Moodle on-disk version
114 * @param array $failed list of plugins with unsatisfied dependecies
e937c545 115 * @param moodle_url $reloadurl URL of the page to recheck the dependencies
39f15cc7
DM
116 * @return string HTML
117 */
118 public function unsatisfied_dependencies_page($version, array $failed, moodle_url $reloadurl) {
119 $output = '';
120
121 $output .= $this->header();
122 $output .= $this->heading(get_string('pluginscheck', 'admin'));
123 $output .= $this->warning(get_string('pluginscheckfailed', 'admin', array('pluginslist' => implode(', ', array_unique($failed)))));
124 $output .= $this->plugins_check_table(plugin_manager::instance(), $version, array('xdep' => true));
125 $output .= $this->warning(get_string('pluginschecktodo', 'admin'));
126 $output .= $this->continue_button($reloadurl);
127
128 $output .= $this->footer();
129
130 return $output;
131 }
132
cc359566
TH
133 /**
134 * Display the 'You are about to upgrade Moodle' page. The first page
135 * during upgrade.
8d1da748
PS
136 * @param string $strnewversion
137 * @param int $maturity
cc359566
TH
138 * @return string HTML to output.
139 */
140 public function upgrade_confirm_page($strnewversion, $maturity) {
141 $output = '';
142
143 $continueurl = new moodle_url('index.php', array('confirmupgrade' => 1));
144 $cancelurl = new moodle_url('index.php');
145
146 $output .= $this->header();
147 $output .= $this->maturity_warning($maturity);
148 $output .= $this->confirm(get_string('upgradesure', 'admin', $strnewversion), $continueurl, $cancelurl);
149 $output .= $this->footer();
150
151 return $output;
152 }
153
154 /**
155 * Display the environment page during the upgrade process.
8d1da748
PS
156 * @param string $release
157 * @param boolean $envstatus final result of env check (true/false)
158 * @param array $environment_results array of results gathered
cc359566
TH
159 * @return string HTML to output.
160 */
161 public function upgrade_environment_page($release, $envstatus, $environment_results) {
162 global $CFG;
163 $output = '';
164
165 $output .= $this->header();
166 $output .= $this->heading("Moodle $release");
167 $output .= $this->release_notes_link();
168 $output .= $this->environment_check_table($envstatus, $environment_results);
169
170 if (!$envstatus) {
171 $output .= $this->upgrade_reload(new moodle_url('/admin/index.php'), array('confirmupgrade' => 1));
172
173 } else {
faadd326 174 $output .= $this->notification(get_string('environmentok', 'admin'), 'notifysuccess');
cc359566
TH
175
176 if (empty($CFG->skiplangupgrade) and current_language() !== 'en') {
177 $output .= $this->box(get_string('langpackwillbeupdated', 'admin'), 'generalbox', 'notice');
178 }
179
180 $output .= $this->continue_button(new moodle_url('/admin/index.php', array('confirmupgrade' => 1, 'confirmrelease' => 1)));
181 }
182
183 $output .= $this->footer();
184
185 return $output;
186 }
187
188 /**
189 * Display the upgrade page that lists all the plugins that require attention.
8d1da748 190 * @param plugin_manager $pluginman provides information about the plugins.
96dd9237 191 * @param available_update_checker $checker provides information about available updates.
8d1da748
PS
192 * @param int $version the version of the Moodle code from version.php.
193 * @param bool $showallplugins
194 * @param moodle_url $reloadurl
195 * @param moodle_url $continueurl
cc359566
TH
196 * @return string HTML to output.
197 */
96dd9237
DM
198 public function upgrade_plugin_check_page(plugin_manager $pluginman, available_update_checker $checker,
199 $version, $showallplugins, $reloadurl, $continueurl) {
fa1d403f 200 global $CFG;
96dd9237 201
cc359566
TH
202 $output = '';
203
204 $output .= $this->header();
205 $output .= $this->box_start('generalbox');
96dd9237
DM
206 $output .= $this->container_start('generalbox', 'notice');
207 $output .= html_writer::tag('p', get_string('pluginchecknotice', 'core_plugin'));
fa1d403f
DM
208 if (empty($CFG->disableupdatenotifications)) {
209 $output .= $this->container_start('checkforupdates');
210 $output .= $this->single_button(new moodle_url($reloadurl, array('fetchupdates' => 1)), get_string('checkforupdates', 'core_plugin'));
211 if ($timefetched = $checker->get_last_timefetched()) {
212 $output .= $this->container(get_string('checkforupdateslast', 'core_plugin',
213 userdate($timefetched, get_string('strftimedatetime', 'core_langconfig'))));
214 }
215 $output .= $this->container_end();
96dd9237
DM
216 }
217 $output .= $this->container_end();
96dd9237 218
faadd326 219 $output .= $this->plugins_check_table($pluginman, $version, array('full' => $showallplugins));
cc359566
TH
220 $output .= $this->box_end();
221 $output .= $this->upgrade_reload($reloadurl);
222
ead8ba3b
DM
223 if ($pluginman->some_plugins_updatable()) {
224 $output .= $this->container_start('upgradepluginsinfo');
225 $output .= $this->help_icon('upgradepluginsinfo', 'core_admin', get_string('upgradepluginsfirst', 'core_admin'));
226 $output .= $this->container_end();
faadd326 227 }
cc359566 228
ead8ba3b
DM
229 $button = new single_button($continueurl, get_string('upgradestart', 'admin'), 'get');
230 $button->class = 'continuebutton';
231 $output .= $this->render($button);
cc359566
TH
232 $output .= $this->footer();
233
234 return $output;
235 }
236
237 /**
238 * Display the admin notifications page.
8d1da748
PS
239 * @param int $maturity
240 * @param bool $insecuredataroot warn dataroot is invalid
241 * @param bool $errorsdisplayed warn invalid dispaly error setting
242 * @param bool $cronoverdue warn cron not running
243 * @param bool $dbproblems warn db has problems
244 * @param bool $maintenancemode warn in maintenance mode
0aff15c2 245 * @param bool $buggyiconvnomb warn iconv problems
55585f3a
DM
246 * @param array|null $availableupdates array of available_update_info objects or null
247 * @param int|null $availableupdatesfetch timestamp of the most recent updates fetch or null (unknown)
248 *
cc359566
TH
249 * @return string HTML to output.
250 */
251 public function admin_notifications_page($maturity, $insecuredataroot, $errorsdisplayed,
b3245b75
DP
252 $cronoverdue, $dbproblems, $maintenancemode, $availableupdates, $availableupdatesfetch,
253 $buggyiconvnomb, $registered) {
4db58f5f 254 global $CFG;
cc359566
TH
255 $output = '';
256
257 $output .= $this->header();
258 $output .= $this->maturity_info($maturity);
4db58f5f 259 $output .= empty($CFG->disableupdatenotifications) ? $this->available_updates($availableupdates, $availableupdatesfetch) : '';
cc359566
TH
260 $output .= $this->insecure_dataroot_warning($insecuredataroot);
261 $output .= $this->display_errors_warning($errorsdisplayed);
0aff15c2 262 $output .= $this->buggy_iconv_warning($buggyiconvnomb);
e3258164 263 $output .= $this->cron_overdue_warning($cronoverdue);
cc359566
TH
264 $output .= $this->db_problems($dbproblems);
265 $output .= $this->maintenance_mode_warning($maintenancemode);
b3245b75 266 $output .= $this->registration_warning($registered);
cc359566
TH
267
268 //////////////////////////////////////////////////////////////////////////////////////////////////
269 //// IT IS ILLEGAL AND A VIOLATION OF THE GPL TO HIDE, REMOVE OR MODIFY THIS COPYRIGHT NOTICE ///
270 $output .= $this->moodle_copyright();
271 //////////////////////////////////////////////////////////////////////////////////////////////////
272
273 $output .= $this->footer();
274
275 return $output;
276 }
277
8342171b
DM
278 /**
279 * Display the plugin management page (admin/plugins.php).
280 *
281 * @param plugin_manager $pluginman
282 * @param available_update_checker $checker
283 * @return string HTML to output.
284 */
285 public function plugin_management_page(plugin_manager $pluginman, available_update_checker $checker) {
7716057f
DM
286 global $CFG;
287
8342171b
DM
288 $output = '';
289
290 $output .= $this->header();
291 $output .= $this->heading(get_string('pluginsoverview', 'core_admin'));
292 $output .= $this->plugins_overview_panel($pluginman);
293
7716057f
DM
294 if (empty($CFG->disableupdatenotifications)) {
295 $output .= $this->container_start('checkforupdates');
296 $output .= $this->single_button(new moodle_url($this->page->url, array('fetchremote' => 1)), get_string('checkforupdates', 'core_plugin'));
297 if ($timefetched = $checker->get_last_timefetched()) {
298 $output .= $this->container(get_string('checkforupdateslast', 'core_plugin',
299 userdate($timefetched, get_string('strftimedatetime', 'core_langconfig'))));
300 }
301 $output .= $this->container_end();
8342171b 302 }
8342171b
DM
303
304 $output .= $this->box($this->plugins_control_panel($pluginman), 'generalbox');
305 $output .= $this->footer();
306
307 return $output;
308 }
309
cc359566
TH
310 /**
311 * Display the plugin management page (admin/environment.php).
8d1da748
PS
312 * @param array $versions
313 * @param string $version
314 * @param boolean $envstatus final result of env check (true/false)
315 * @param array $environment_results array of results gathered
cc359566
TH
316 * @return string HTML to output.
317 */
318 public function environment_check_page($versions, $version, $envstatus, $environment_results) {
319 $output = '';
320 $output .= $this->header();
321
322 // Print the component download link
323 $output .= html_writer::tag('div', html_writer::link(
324 new moodle_url('/admin/environment.php', array('action' => 'updatecomponent', 'sesskey' => sesskey())),
325 get_string('updatecomponent', 'admin')),
326 array('class' => 'reportlink'));
327
328 // Heading.
329 $output .= $this->heading(get_string('environment', 'admin'));
330
331 // Box with info and a menu to choose the version.
332 $output .= $this->box_start();
333 $output .= html_writer::tag('div', get_string('adminhelpenvironment'));
334 $select = new single_select(new moodle_url('/admin/environment.php'), 'version', $versions, $version, null);
335 $select->label = get_string('moodleversion');
336 $output .= $this->render($select);
337 $output .= $this->box_end();
338
339 // The results
340 $output .= $this->environment_check_table($envstatus, $environment_results);
341
342 $output .= $this->footer();
343 return $output;
344 }
345
346 /**
347 * Output a warning message, of the type that appears on the admin notifications page.
348 * @param string $message the message to display.
8d1da748 349 * @param string $type type class
cc359566
TH
350 * @return string HTML to output.
351 */
352 protected function warning($message, $type = 'warning') {
353 return $this->box($message, 'generalbox admin' . $type);
354 }
355
356 /**
357 * Render an appropriate message if dataroot is insecure.
8d1da748 358 * @param bool $insecuredataroot
cc359566
TH
359 * @return string HTML to output.
360 */
361 protected function insecure_dataroot_warning($insecuredataroot) {
362 global $CFG;
363
364 if ($insecuredataroot == INSECURE_DATAROOT_WARNING) {
365 return $this->warning(get_string('datarootsecuritywarning', 'admin', $CFG->dataroot));
366
367 } else if ($insecuredataroot == INSECURE_DATAROOT_ERROR) {
368 return $this->warning(get_string('datarootsecurityerror', 'admin', $CFG->dataroot), 'error');
369
370 } else {
371 return '';
372 }
373 }
374
375 /**
376 * Render an appropriate message if dataroot is insecure.
8d1da748 377 * @param bool $errorsdisplayed
cc359566
TH
378 * @return string HTML to output.
379 */
380 protected function display_errors_warning($errorsdisplayed) {
381 if (!$errorsdisplayed) {
382 return '';
383 }
384
385 return $this->warning(get_string('displayerrorswarning', 'admin'));
386 }
387
0aff15c2
PS
388 /**
389 * Render an appropriate message if iconv is buggy and mbstring missing.
390 * @param bool $buggyiconvnomb
391 * @return string HTML to output.
392 */
393 protected function buggy_iconv_warning($buggyiconvnomb) {
394 if (!$buggyiconvnomb) {
395 return '';
396 }
397
398 return $this->warning(get_string('warningiconvbuggy', 'admin'));
399 }
400
cc359566
TH
401 /**
402 * Render an appropriate message if cron has not been run recently.
8d1da748 403 * @param bool $cronoverdue
cc359566
TH
404 * @return string HTML to output.
405 */
406 public function cron_overdue_warning($cronoverdue) {
407 if (!$cronoverdue) {
408 return '';
409 }
410
411 return $this->warning(get_string('cronwarning', 'admin') . '&nbsp;' .
412 $this->help_icon('cron', 'admin'));
413 }
414
415 /**
416 * Render an appropriate message if there are any problems with the DB set-up.
8d1da748 417 * @param bool $dbproblems
cc359566
TH
418 * @return string HTML to output.
419 */
420 public function db_problems($dbproblems) {
421 if (!$dbproblems) {
422 return '';
423 }
424
425 return $this->warning($dbproblems);
426 }
427
428 /**
429 * Render an appropriate message if the site in in maintenance mode.
8d1da748 430 * @param bool $maintenancemode
cc359566
TH
431 * @return string HTML to output.
432 */
433 public function maintenance_mode_warning($maintenancemode) {
434 if (!$maintenancemode) {
435 return '';
436 }
437
ecc2897c
PS
438 $url = new moodle_url('/admin/settings.php', array('section' => 'maintenancemode'));
439 $url = $url->out(); // get_string() does not support objects in params
440
441 return $this->warning(get_string('sitemaintenancewarning2', 'admin', $url));
cc359566
TH
442 }
443
444 /**
445 * Display a warning about installing development code if necesary.
8d1da748 446 * @param int $maturity
cc359566
TH
447 * @return string HTML to output.
448 */
449 protected function maturity_warning($maturity) {
450 if ($maturity == MATURITY_STABLE) {
451 return ''; // No worries.
452 }
453
454 $maturitylevel = get_string('maturity' . $maturity, 'admin');
455 return $this->box(
456 $this->container(get_string('maturitycorewarning', 'admin', $maturitylevel)) .
457 $this->container($this->doc_link('admin/versions', get_string('morehelp'))),
458 'generalbox maturitywarning');
459 }
460
461 /**
462 * Output the copyright notice.
463 * @return string HTML to output.
464 */
465 protected function moodle_copyright() {
466 global $CFG;
467
468 //////////////////////////////////////////////////////////////////////////////////////////////////
469 //// IT IS ILLEGAL AND A VIOLATION OF THE GPL TO HIDE, REMOVE OR MODIFY THIS COPYRIGHT NOTICE ///
470 $copyrighttext = '<a href="http://moodle.org/">Moodle</a> '.
471 '<a href="http://docs.moodle.org/dev/Releases" title="'.$CFG->version.'">'.$CFG->release.'</a><br />'.
472 'Copyright &copy; 1999 onwards, Martin Dougiamas<br />'.
473 'and <a href="http://docs.moodle.org/dev/Credits">many other contributors</a>.<br />'.
474 '<a href="http://docs.moodle.org/dev/License">GNU Public License</a>';
475 //////////////////////////////////////////////////////////////////////////////////////////////////
476
477 return $this->box($copyrighttext, 'copyright');
478 }
479
480 /**
481 * Display a warning about installing development code if necesary.
8d1da748
PS
482 * @param int $maturity
483 * @return string HTML to output.
cc359566
TH
484 */
485 protected function maturity_info($maturity) {
486 if ($maturity == MATURITY_STABLE) {
487 return ''; // No worries.
488 }
489
490 $maturitylevel = get_string('maturity' . $maturity, 'admin');
491 return $this->box(
492 get_string('maturitycoreinfo', 'admin', $maturitylevel) . ' ' .
493 $this->doc_link('admin/versions', get_string('morehelp')),
37f75ad4 494 'generalbox adminwarning maturityinfo maturity'.$maturity);
cc359566
TH
495 }
496
55585f3a
DM
497 /**
498 * Displays the info about available Moodle updates
499 *
500 * @param array|null $updates array of available_update_info objects or null
501 * @param int|null $fetch timestamp of the most recent updates fetch or null (unknown)
502 * @return string
503 */
504 protected function available_updates($updates, $fetch) {
505
506 $updateinfo = $this->box_start('generalbox adminwarning availableupdatesinfo');
507 if (is_array($updates)) {
508 $updateinfo .= $this->heading(get_string('updateavailable', 'core_admin'), 3);
509 foreach ($updates as $update) {
510 $updateinfo .= $this->moodle_available_update_info($update);
511 }
512 } else {
cb1c3291
DM
513 $now = time();
514 if ($fetch and ($fetch <= $now) and ($now - $fetch < HOURSECS)) {
515 $updateinfo .= $this->heading(get_string('updateavailablenot', 'core_admin'), 3);
516 }
55585f3a
DM
517 }
518
519 $updateinfo .= $this->container_start('checkforupdates');
520 $updateinfo .= $this->single_button(new moodle_url($this->page->url, array('fetchupdates' => 1)), get_string('checkforupdates', 'core_plugin'));
521 if ($fetch) {
522 $updateinfo .= $this->container(get_string('checkforupdateslast', 'core_plugin',
523 userdate($fetch, get_string('strftimedatetime', 'core_langconfig'))));
524 }
525 $updateinfo .= $this->container_end();
526
527 $updateinfo .= $this->box_end();
528
529 return $updateinfo;
530 }
531
b3245b75
DP
532 /**
533 * Display a warning about not being registered on Moodle.org if necesary.
534 *
535 * @param boolean $registered true if the site is registered on Moodle.org
536 * @return string HTML to output.
537 */
538 protected function registration_warning($registered) {
539
540 if (!$registered) {
541
542 $registerbutton = $this->single_button(new moodle_url('registration/register.php',
543 array('huburl' => HUB_MOODLEORGHUBURL, 'hubname' => 'Moodle.org')),
544 get_string('register', 'admin'));
545
546 return $this->warning( get_string('registrationwarning', 'admin')
547 . '&nbsp;' . $this->help_icon('registration', 'admin') . $registerbutton );
548 }
549
550 return '';
551 }
552
55585f3a
DM
553 /**
554 * Helper method to render the information about the available Moodle update
555 *
556 * @param available_update_info $updateinfo information about the available Moodle core update
557 */
558 protected function moodle_available_update_info(available_update_info $updateinfo) {
559
560 $boxclasses = 'moodleupdateinfo';
561 $info = array();
562
563 if (isset($updateinfo->release)) {
564 $info[] = html_writer::tag('span', get_string('updateavailable_release', 'core_admin', $updateinfo->release),
565 array('class' => 'info release'));
566 }
567
568 if (isset($updateinfo->version)) {
569 $info[] = html_writer::tag('span', get_string('updateavailable_version', 'core_admin', $updateinfo->version),
570 array('class' => 'info version'));
571 }
572
573 if (isset($updateinfo->maturity)) {
574 $info[] = html_writer::tag('span', get_string('maturity'.$updateinfo->maturity, 'core_admin'),
575 array('class' => 'info maturity'));
576 $boxclasses .= ' maturity'.$updateinfo->maturity;
577 }
578
579 if (isset($updateinfo->download)) {
580 $info[] = html_writer::link($updateinfo->download, get_string('download'), array('class' => 'info download'));
581 }
582
583 if (isset($updateinfo->url)) {
584 $info[] = html_writer::link($updateinfo->url, get_string('updateavailable_moreinfo', 'core_plugin'),
585 array('class' => 'info more'));
586 }
587
588 $box = $this->output->box_start($boxclasses);
589 $box .= $this->output->box(implode(html_writer::tag('span', ' ', array('class' => 'separator')), $info), '');
590 $box .= $this->output->box_end();
591
592 return $box;
593 }
594
cc359566
TH
595 /**
596 * Display a link to the release notes.
8d1da748 597 * @return string HTML to output.
cc359566
TH
598 */
599 protected function release_notes_link() {
600 $releasenoteslink = get_string('releasenoteslink', 'admin', 'http://docs.moodle.org/dev/Releases');
601 $releasenoteslink = str_replace('target="_blank"', 'onclick="this.target=\'_blank\'"', $releasenoteslink); // extremely ugly validation hack
602 return $this->box($releasenoteslink, 'generalbox releasenoteslink');
603 }
604
605 /**
606 * Display the reload link that appears on several upgrade/install pages.
8d1da748 607 * @return string HTML to output.
cc359566
TH
608 */
609 function upgrade_reload($url) {
610 return html_writer::empty_tag('br') .
611 html_writer::tag('div',
612 html_writer::link($url, $this->pix_icon('i/reload', '') .
613 get_string('reload'), array('title' => get_string('reload'))),
614 array('class' => 'continuebutton')) . html_writer::empty_tag('br');
615 }
616
b9934a17
DM
617 /**
618 * Displays all known plugins and information about their installation or upgrade
619 *
620 * This default implementation renders all plugins into one big table. The rendering
621 * options support:
622 * (bool)full = false: whether to display up-to-date plugins, too
39f15cc7 623 * (bool)xdep = false: display the plugins with unsatisified dependecies only
b9934a17 624 *
36ca62ca 625 * @param plugin_manager $pluginman provides information about the plugins.
faadd326 626 * @param int $version the version of the Moodle code from version.php.
b9934a17
DM
627 * @param array $options rendering options
628 * @return string HTML code
629 */
39f15cc7 630 public function plugins_check_table(plugin_manager $pluginman, $version, array $options = array()) {
fa1d403f
DM
631 global $CFG;
632
36ca62ca 633 $plugininfo = $pluginman->get_plugins();
b9934a17
DM
634
635 if (empty($plugininfo)) {
636 return '';
637 }
638
39f15cc7
DM
639 $options['full'] = isset($options['full']) ? (bool)$options['full'] : false;
640 $options['xdep'] = isset($options['xdep']) ? (bool)$options['xdep'] : false;
b9934a17 641
b9934a17
DM
642 $table = new html_table();
643 $table->id = 'plugins-check';
644 $table->head = array(
645 get_string('displayname', 'core_plugin'),
646 get_string('rootdir', 'core_plugin'),
647 get_string('source', 'core_plugin'),
648 get_string('versiondb', 'core_plugin'),
649 get_string('versiondisk', 'core_plugin'),
36ca62ca 650 get_string('requires', 'core_plugin'),
b9934a17
DM
651 get_string('status', 'core_plugin'),
652 );
653 $table->colclasses = array(
36ca62ca 654 'displayname', 'rootdir', 'source', 'versiondb', 'versiondisk', 'requires', 'status',
b9934a17
DM
655 );
656 $table->data = array();
657
658 $numofhighlighted = array(); // number of highlighted rows per this subsection
659
660 foreach ($plugininfo as $type => $plugins) {
661
662 $header = new html_table_cell($pluginman->plugintype_name_plural($type));
663 $header->header = true;
664 $header->colspan = count($table->head);
665 $header = new html_table_row(array($header));
666 $header->attributes['class'] = 'plugintypeheader type-' . $type;
667
668 $numofhighlighted[$type] = 0;
669
670 if (empty($plugins) and $options['full']) {
671 $msg = new html_table_cell(get_string('noneinstalled', 'core_plugin'));
672 $msg->colspan = count($table->head);
673 $row = new html_table_row(array($msg));
674 $row->attributes['class'] .= 'msg msg-noneinstalled';
675 $table->data[] = $header;
676 $table->data[] = $row;
677 continue;
678 }
679
680 $plugintyperows = array();
681
682 foreach ($plugins as $name => $plugin) {
683 $row = new html_table_row();
684 $row->attributes['class'] = 'type-' . $plugin->type . ' name-' . $plugin->type . '_' . $plugin->name;
685
686 if ($this->page->theme->resolve_image_location('icon', $plugin->type . '_' . $plugin->name)) {
687 $icon = $this->output->pix_icon('icon', '', $plugin->type . '_' . $plugin->name, array('class' => 'smallicon pluginicon'));
688 } else {
689 $icon = $this->output->pix_icon('spacer', '', 'moodle', array('class' => 'smallicon pluginicon noicon'));
690 }
691 $displayname = $icon . ' ' . $plugin->displayname;
692 $displayname = new html_table_cell($displayname);
693
694 $rootdir = new html_table_cell($plugin->get_dir());
695
696 if ($isstandard = $plugin->is_standard()) {
697 $row->attributes['class'] .= ' standard';
698 $source = new html_table_cell(get_string('sourcestd', 'core_plugin'));
699 } else {
700 $row->attributes['class'] .= ' extension';
701 $source = new html_table_cell(get_string('sourceext', 'core_plugin'));
702 }
703
704 $versiondb = new html_table_cell($plugin->versiondb);
705 $versiondisk = new html_table_cell($plugin->versiondisk);
706
707 $statuscode = $plugin->get_status();
708 $row->attributes['class'] .= ' status-' . $statuscode;
96dd9237
DM
709 $status = get_string('status_' . $statuscode, 'core_plugin');
710
711 $availableupdates = $plugin->available_updates();
fa1d403f 712 if (!empty($availableupdates) and empty($CFG->disableupdatenotifications)) {
96dd9237
DM
713 foreach ($availableupdates as $availableupdate) {
714 $status .= $this->plugin_available_update_info($availableupdate);
715 }
716 }
b9934a17 717
96dd9237 718 $status = new html_table_cell($status);
b9934a17 719
faadd326 720 $requires = new html_table_cell($this->required_column($plugin, $pluginman, $version));
36ca62ca
TH
721
722 $statusisboring = in_array($statuscode, array(
723 plugin_manager::PLUGIN_STATUS_NODB, plugin_manager::PLUGIN_STATUS_UPTODATE));
e937c545
DM
724
725 $coredependency = $plugin->is_core_dependency_satisfied($version);
726 $otherpluginsdependencies = $pluginman->are_dependencies_satisfied($plugin->get_other_required_plugins());
727 $dependenciesok = $coredependency && $otherpluginsdependencies;
39f15cc7
DM
728
729 if ($options['xdep']) {
730 // we want to see only plugins with failed dependencies
731 if ($dependenciesok) {
732 continue;
733 }
734
735 } else if ($isstandard and $statusisboring and $dependenciesok and empty($availableupdates)) {
736 // no change is going to happen to the plugin - display it only
737 // if the user wants to see the full list
b9934a17
DM
738 if (empty($options['full'])) {
739 continue;
740 }
b9934a17
DM
741 }
742
39f15cc7
DM
743 // ok, the plugin should be displayed
744 $numofhighlighted[$type]++;
745
36ca62ca
TH
746 $row->cells = array($displayname, $rootdir, $source,
747 $versiondb, $versiondisk, $requires, $status);
b9934a17
DM
748 $plugintyperows[] = $row;
749 }
750
751 if (empty($numofhighlighted[$type]) and empty($options['full'])) {
752 continue;
753 }
754
755 $table->data[] = $header;
756 $table->data = array_merge($table->data, $plugintyperows);
757 }
758
759 $sumofhighlighted = array_sum($numofhighlighted);
760
39f15cc7
DM
761 if ($options['xdep']) {
762 // we do not want to display no heading and links in this mode
763 $out = '';
764
765 } else if ($sumofhighlighted == 0) {
b9934a17
DM
766 $out = $this->output->container_start('nonehighlighted', 'plugins-check-info');
767 $out .= $this->output->heading(get_string('nonehighlighted', 'core_plugin'));
768 if (empty($options['full'])) {
769 $out .= html_writer::link(new moodle_url('/admin/index.php',
770 array('confirmupgrade' => 1, 'confirmrelease' => 1, 'showallplugins' => 1)),
771 get_string('nonehighlightedinfo', 'core_plugin'));
772 }
773 $out .= $this->output->container_end();
774
775 } else {
776 $out = $this->output->container_start('somehighlighted', 'plugins-check-info');
777 $out .= $this->output->heading(get_string('somehighlighted', 'core_plugin', $sumofhighlighted));
778 if (empty($options['full'])) {
779 $out .= html_writer::link(new moodle_url('/admin/index.php',
780 array('confirmupgrade' => 1, 'confirmrelease' => 1, 'showallplugins' => 1)),
781 get_string('somehighlightedinfo', 'core_plugin'));
a687fcac
DM
782 } else {
783 $out .= html_writer::link(new moodle_url('/admin/index.php',
784 array('confirmupgrade' => 1, 'confirmrelease' => 1, 'showallplugins' => 0)),
785 get_string('somehighlightedonly', 'core_plugin'));
b9934a17
DM
786 }
787 $out .= $this->output->container_end();
788 }
789
790 if ($sumofhighlighted > 0 or $options['full']) {
791 $out .= html_writer::table($table);
792 }
793
794 return $out;
795 }
796
36ca62ca
TH
797 /**
798 * Formats the information that needs to go in the 'Requires' column.
b6ad8594 799 * @param plugininfo_base $plugin the plugin we are rendering the row for.
36ca62ca 800 * @param plugin_manager $pluginman provides data on all the plugins.
8d1da748
PS
801 * @param string $version
802 * @return string HTML code
36ca62ca 803 */
b6ad8594 804 protected function required_column(plugininfo_base $plugin, plugin_manager $pluginman, $version) {
36ca62ca
TH
805 $requires = array();
806
807 if (!empty($plugin->versionrequires)) {
faadd326 808 if ($plugin->versionrequires <= $version) {
36ca62ca
TH
809 $class = 'requires-ok';
810 } else {
811 $class = 'requires-failed';
812 }
813 $requires[] = html_writer::tag('li',
814 get_string('moodleversion', 'core_plugin', $plugin->versionrequires),
815 array('class' => $class));
816 }
817
818 foreach ($plugin->get_other_required_plugins() as $component => $requiredversion) {
819 $ok = true;
820 $otherplugin = $pluginman->get_plugin_info($component);
821
822 if (is_null($otherplugin)) {
823 $ok = false;
499ff0a9 824 } else if ($requiredversion != ANY_VERSION and $otherplugin->versiondisk < $requiredversion) {
36ca62ca
TH
825 $ok = false;
826 }
827
828 if ($ok) {
829 $class = 'requires-ok';
830 } else {
831 $class = 'requires-failed';
832 }
833
834 if ($requiredversion != ANY_VERSION) {
835 $str = 'otherpluginversion';
836 } else {
837 $str = 'otherplugin';
838 }
839 $requires[] = html_writer::tag('li',
840 get_string($str, 'core_plugin',
841 array('component' => $component, 'version' => $requiredversion)),
842 array('class' => $class));
843 }
844
845 if (!$requires) {
846 return '';
847 }
848 return html_writer::tag('ul', implode("\n", $requires));
849 }
850
d26f3ddd
DM
851 /**
852 * Prints an overview about the plugins - number of installed, number of extensions etc.
853 *
854 * @param plugin_manager $pluginman provides information about the plugins
855 * @return string as usually
856 */
857 public function plugins_overview_panel(plugin_manager $pluginman) {
7716057f
DM
858 global $CFG;
859
d26f3ddd
DM
860 $plugininfo = $pluginman->get_plugins();
861
862 $numtotal = $numdisabled = $numextension = $numupdatable = 0;
863
864 foreach ($plugininfo as $type => $plugins) {
865 foreach ($plugins as $name => $plugin) {
866 if ($plugin->get_status() === plugin_manager::PLUGIN_STATUS_MISSING) {
867 continue;
868 }
869 $numtotal++;
870 if ($plugin->is_enabled() === false) {
871 $numdisabled++;
872 }
873 if (!$plugin->is_standard()) {
874 $numextension++;
875 }
7716057f 876 if (empty($CFG->disableupdatenotifications) and $plugin->available_updates()) {
d26f3ddd
DM
877 $numupdatable++;
878 }
879 }
880 }
881
882 $info = array();
883 $info[] = html_writer::tag('span', get_string('numtotal', 'core_plugin', $numtotal), array('class' => 'info total'));
884 $info[] = html_writer::tag('span', get_string('numdisabled', 'core_plugin', $numdisabled), array('class' => 'info disabled'));
885 $info[] = html_writer::tag('span', get_string('numextension', 'core_plugin', $numextension), array('class' => 'info extension'));
886 if ($numupdatable > 0) {
887 $info[] = html_writer::tag('span', get_string('numupdatable', 'core_plugin', $numupdatable), array('class' => 'info updatable'));
888 }
889
890 return $this->output->box(implode(html_writer::tag('span', ' ', array('class' => 'separator')), $info), '', 'plugins-overview-panel');
891 }
892
b9934a17
DM
893 /**
894 * Displays all known plugins and links to manage them
895 *
896 * This default implementation renders all plugins into one big table.
897 *
36ca62ca 898 * @param plugin_manager $pluginman provides information about the plugins.
b9934a17
DM
899 * @return string HTML code
900 */
36ca62ca 901 public function plugins_control_panel(plugin_manager $pluginman) {
7716057f
DM
902 global $CFG;
903
36ca62ca 904 $plugininfo = $pluginman->get_plugins();
b9934a17
DM
905
906 if (empty($plugininfo)) {
907 return '';
908 }
909
b9934a17
DM
910 $table = new html_table();
911 $table->id = 'plugins-control-panel';
912 $table->head = array(
913 get_string('displayname', 'core_plugin'),
b9934a17
DM
914 get_string('source', 'core_plugin'),
915 get_string('version', 'core_plugin'),
916 get_string('availability', 'core_plugin'),
2b135b05
DM
917 get_string('actions', 'core_plugin'),
918 get_string('notes','core_plugin'),
b9934a17
DM
919 );
920 $table->colclasses = array(
2b135b05 921 'pluginname', 'source', 'version', 'availability', 'actions', 'notes'
b9934a17
DM
922 );
923
924 foreach ($plugininfo as $type => $plugins) {
925
926 $header = new html_table_cell($pluginman->plugintype_name_plural($type));
927 $header->header = true;
928 $header->colspan = count($table->head);
929 $header = new html_table_row(array($header));
930 $header->attributes['class'] = 'plugintypeheader type-' . $type;
931 $table->data[] = $header;
932
933 if (empty($plugins)) {
934 $msg = new html_table_cell(get_string('noneinstalled', 'core_plugin'));
935 $msg->colspan = count($table->head);
936 $row = new html_table_row(array($msg));
937 $row->attributes['class'] .= 'msg msg-noneinstalled';
938 $table->data[] = $row;
939 continue;
940 }
941
942 foreach ($plugins as $name => $plugin) {
943 $row = new html_table_row();
944 $row->attributes['class'] = 'type-' . $plugin->type . ' name-' . $plugin->type . '_' . $plugin->name;
945
946 if ($this->page->theme->resolve_image_location('icon', $plugin->type . '_' . $plugin->name)) {
947 $icon = $this->output->pix_icon('icon', '', $plugin->type . '_' . $plugin->name, array('class' => 'smallicon pluginicon'));
948 } else {
949 $icon = $this->output->pix_icon('spacer', '', 'moodle', array('class' => 'smallicon pluginicon noicon'));
950 }
951 if ($plugin->get_status() === plugin_manager::PLUGIN_STATUS_MISSING) {
952 $msg = html_writer::tag('span', get_string('status_missing', 'core_plugin'), array('class' => 'notifyproblem'));
953 $row->attributes['class'] .= ' missingfromdisk';
954 } else {
955 $msg = '';
956 }
2b135b05
DM
957 $pluginname = html_writer::tag('div', $icon . ' ' . $plugin->displayname . ' ' . $msg, array('class' => 'displayname')).
958 html_writer::tag('div', $plugin->component, array('class' => 'componentname'));
959 $pluginname = new html_table_cell($pluginname);
b9934a17
DM
960
961 if ($plugin->is_standard()) {
962 $row->attributes['class'] .= ' standard';
963 $source = new html_table_cell(get_string('sourcestd', 'core_plugin'));
964 } else {
965 $row->attributes['class'] .= ' extension';
966 $source = new html_table_cell(get_string('sourceext', 'core_plugin'));
967 }
968
969 $version = new html_table_cell($plugin->versiondb);
970
971 $isenabled = $plugin->is_enabled();
972 if (is_null($isenabled)) {
973 $availability = new html_table_cell('');
974 } else if ($isenabled) {
975 $row->attributes['class'] .= ' enabled';
976 $icon = $this->output->pix_icon('i/hide', get_string('pluginenabled', 'core_plugin'));
977 $availability = new html_table_cell($icon . ' ' . get_string('pluginenabled', 'core_plugin'));
978 } else {
979 $row->attributes['class'] .= ' disabled';
980 $icon = $this->output->pix_icon('i/show', get_string('plugindisabled', 'core_plugin'));
981 $availability = new html_table_cell($icon . ' ' . get_string('plugindisabled', 'core_plugin'));
982 }
983
2b135b05
DM
984 $actions = array();
985
b9934a17 986 $settingsurl = $plugin->get_settings_url();
2b135b05
DM
987 if (!is_null($settingsurl)) {
988 $actions[] = html_writer::link($settingsurl, get_string('settings', 'core_plugin'), array('class' => 'settings'));
b9934a17
DM
989 }
990
991 $uninstallurl = $plugin->get_uninstall_url();
2b135b05
DM
992 if (!is_null($uninstallurl)) {
993 $actions[] = html_writer::link($uninstallurl, get_string('uninstall', 'core_plugin'), array('class' => 'uninstall'));
994 }
995
996 $actions = new html_table_cell(implode(html_writer::tag('span', ' ', array('class' => 'separator')), $actions));
997
828788f0 998 $requriedby = $pluginman->other_plugins_that_require($plugin->component);
2b135b05
DM
999 if ($requriedby) {
1000 $requiredby = html_writer::tag('div', get_string('requiredby', 'core_plugin', implode(', ', $requriedby)),
1001 array('class' => 'requiredby'));
b9934a17 1002 } else {
2b135b05 1003 $requiredby = '';
b9934a17
DM
1004 }
1005
7d8de6d8 1006 $updateinfo = '';
7716057f 1007 if (empty($CFG->disableupdatenotifications) and is_array($plugin->available_updates())) {
7d8de6d8
DM
1008 foreach ($plugin->available_updates() as $availableupdate) {
1009 $updateinfo .= $this->plugin_available_update_info($availableupdate);
1010 }
3204daea
DM
1011 }
1012
1013 $notes = new html_table_cell($requiredby.$updateinfo);
2b135b05 1014
b9934a17 1015 $row->cells = array(
2b135b05 1016 $pluginname, $source, $version, $availability, $actions, $notes
b9934a17
DM
1017 );
1018 $table->data[] = $row;
1019 }
1020 }
1021
1022 return html_writer::table($table);
1023 }
da2fdc3f 1024
3204daea 1025 /**
e7611389 1026 * Helper method to render the information about the available plugin update
3204daea
DM
1027 *
1028 * The passed objects always provides at least the 'version' property containing
7d8de6d8 1029 * the (higher) version of the plugin available.
3204daea 1030 *
7d8de6d8 1031 * @param available_update_info $updateinfo information about the available update for the plugin
3204daea 1032 */
7d8de6d8 1033 protected function plugin_available_update_info(available_update_info $updateinfo) {
3204daea 1034
e7611389 1035 $boxclasses = 'pluginupdateinfo';
3204daea
DM
1036 $info = array();
1037
1038 if (isset($updateinfo->release)) {
1039 $info[] = html_writer::tag('span', get_string('updateavailable_release', 'core_plugin', $updateinfo->release),
1040 array('class' => 'info release'));
1041 }
1042
1043 if (isset($updateinfo->maturity)) {
1044 $info[] = html_writer::tag('span', get_string('maturity'.$updateinfo->maturity, 'core_admin'),
1045 array('class' => 'info maturity'));
e7611389 1046 $boxclasses .= ' maturity'.$updateinfo->maturity;
3204daea
DM
1047 }
1048
1049 if (isset($updateinfo->download)) {
1050 $info[] = html_writer::link($updateinfo->download, get_string('download'), array('class' => 'info download'));
1051 }
1052
1053 if (isset($updateinfo->url)) {
1054 $info[] = html_writer::link($updateinfo->url, get_string('updateavailable_moreinfo', 'core_plugin'),
1055 array('class' => 'info more'));
1056 }
1057
e7611389
DM
1058 $box = $this->output->box_start($boxclasses);
1059 $box .= html_writer::tag('div', get_string('updateavailable', 'core_plugin', $updateinfo->version), array('class' => 'version'));
1060 $box .= $this->output->box(implode(html_writer::tag('span', ' ', array('class' => 'separator')), $info), '');
3204daea
DM
1061 $box .= $this->output->box_end();
1062
1063 return $box;
1064 }
1065
da2fdc3f 1066 /**
cc359566
TH
1067 * This function will render one beautiful table with all the environmental
1068 * configuration and how it suits Moodle needs.
1069 *
1070 * @param boolean $result final result of the check (true/false)
1071 * @param array $environment_results array of results gathered
1072 * @return string HTML to output.
da2fdc3f 1073 */
cc359566
TH
1074 public function environment_check_table($result, $environment_results) {
1075 global $CFG;
1076
1077 // Table headers
1078 $servertable = new html_table();//table for server checks
1079 $servertable->head = array(
1080 get_string('name'),
1081 get_string('info'),
1082 get_string('report'),
1083 get_string('status'),
1084 );
1085 $servertable->align = array('center', 'center', 'left', 'center');
1086 $servertable->wrap = array('nowrap', '', '', 'nowrap');
1087 $servertable->size = array('10', 10, '100%', '10');
1088 $servertable->attributes['class'] = 'environmenttable generaltable';
1089
1090 $serverdata = array('ok'=>array(), 'warn'=>array(), 'error'=>array());
1091
1092 $othertable = new html_table();//table for custom checks
1093 $othertable->head = array(
1094 get_string('info'),
1095 get_string('report'),
1096 get_string('status'),
1097 );
1098 $othertable->align = array('center', 'left', 'center');
1099 $othertable->wrap = array('', '', 'nowrap');
1100 $othertable->size = array(10, '100%', '10');
1101 $othertable->attributes['class'] = 'environmenttable generaltable';
1102
1103 $otherdata = array('ok'=>array(), 'warn'=>array(), 'error'=>array());
1104
1105 // Iterate over each environment_result
1106 $continue = true;
1107 foreach ($environment_results as $environment_result) {
1108 $errorline = false;
1109 $warningline = false;
1110 $stringtouse = '';
1111 if ($continue) {
1112 $type = $environment_result->getPart();
1113 $info = $environment_result->getInfo();
1114 $status = $environment_result->getStatus();
1115 $error_code = $environment_result->getErrorCode();
1116 // Process Report field
1117 $rec = new stdClass();
1118 // Something has gone wrong at parsing time
1119 if ($error_code) {
1120 $stringtouse = 'environmentxmlerror';
1121 $rec->error_code = $error_code;
1122 $status = get_string('error');
1123 $errorline = true;
1124 $continue = false;
1125 }
1126
1127 if ($continue) {
1128 if ($rec->needed = $environment_result->getNeededVersion()) {
1129 // We are comparing versions
1130 $rec->current = $environment_result->getCurrentVersion();
1131 if ($environment_result->getLevel() == 'required') {
1132 $stringtouse = 'environmentrequireversion';
1133 } else {
1134 $stringtouse = 'environmentrecommendversion';
1135 }
1136
1137 } else if ($environment_result->getPart() == 'custom_check') {
1138 // We are checking installed & enabled things
1139 if ($environment_result->getLevel() == 'required') {
1140 $stringtouse = 'environmentrequirecustomcheck';
1141 } else {
1142 $stringtouse = 'environmentrecommendcustomcheck';
1143 }
1144
1145 } else if ($environment_result->getPart() == 'php_setting') {
1146 if ($status) {
1147 $stringtouse = 'environmentsettingok';
1148 } else if ($environment_result->getLevel() == 'required') {
1149 $stringtouse = 'environmentmustfixsetting';
1150 } else {
1151 $stringtouse = 'environmentshouldfixsetting';
1152 }
1153
1154 } else {
1155 if ($environment_result->getLevel() == 'required') {
1156 $stringtouse = 'environmentrequireinstall';
1157 } else {
1158 $stringtouse = 'environmentrecommendinstall';
1159 }
1160 }
1161
1162 // Calculate the status value
1163 if ($environment_result->getBypassStr() != '') { //Handle bypassed result (warning)
1164 $status = get_string('bypassed');
1165 $warningline = true;
1166 } else if ($environment_result->getRestrictStr() != '') { //Handle restricted result (error)
1167 $status = get_string('restricted');
1168 $errorline = true;
1169 } else {
1170 if ($status) { //Handle ok result (ok)
1171 $status = get_string('ok');
1172 } else {
1173 if ($environment_result->getLevel() == 'optional') {//Handle check result (warning)
1174 $status = get_string('check');
1175 $warningline = true;
1176 } else { //Handle error result (error)
1177 $status = get_string('check');
1178 $errorline = true;
1179 }
1180 }
1181 }
1182 }
1183
1184 // Build the text
1185 $linkparts = array();
1186 $linkparts[] = 'admin/environment';
1187 $linkparts[] = $type;
1188 if (!empty($info)){
1189 $linkparts[] = $info;
1190 }
1191 if (empty($CFG->docroot)) {
1192 $report = get_string($stringtouse, 'admin', $rec);
1193 } else {
1194 $report = $this->doc_link(join($linkparts, '/'), get_string($stringtouse, 'admin', $rec));
1195 }
1196
1197 // Format error or warning line
1198 if ($errorline || $warningline) {
1199 $messagetype = $errorline? 'error':'warn';
1200 } else {
1201 $messagetype = 'ok';
1202 }
1203 $status = '<span class="'.$messagetype.'">'.$status.'</span>';
1204 // Here we'll store all the feedback found
1205 $feedbacktext = '';
1206 // Append the feedback if there is some
1207 $feedbacktext .= $environment_result->strToReport($environment_result->getFeedbackStr(), $messagetype);
1208 //Append the bypass if there is some
1209 $feedbacktext .= $environment_result->strToReport($environment_result->getBypassStr(), 'warn');
1210 //Append the restrict if there is some
1211 $feedbacktext .= $environment_result->strToReport($environment_result->getRestrictStr(), 'error');
1212
1213 $report .= $feedbacktext;
1214
1215 // Add the row to the table
1216 if ($environment_result->getPart() == 'custom_check'){
1217 $otherdata[$messagetype][] = array ($info, $report, $status);
1218 } else {
1219 $serverdata[$messagetype][] = array ($type, $info, $report, $status);
1220 }
1221 }
1222 }
1223
1224 //put errors first in
1225 $servertable->data = array_merge($serverdata['error'], $serverdata['warn'], $serverdata['ok']);
1226 $othertable->data = array_merge($otherdata['error'], $otherdata['warn'], $otherdata['ok']);
1227
1228 // Print table
1229 $output = '';
1230 $output .= $this->heading(get_string('serverchecks', 'admin'));
1231 $output .= html_writer::table($servertable);
1232 if (count($othertable->data)){
1233 $output .= $this->heading(get_string('customcheck', 'admin'));
1234 $output .= html_writer::table($othertable);
1235 }
1236
1237 // Finally, if any error has happened, print the summary box
1238 if (!$result) {
1239 $output .= $this->box(get_string('environmenterrortodo', 'admin'), 'environmentbox errorbox');
1240 }
1241
1242 return $output;
da2fdc3f 1243 }
b9934a17 1244}