weekly release 2.4.6+
[moodle.git] / admin / renderer.php
blob802cab3f251f51f4d4e143e98b2ff0ab7df871a7
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.
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/>.
17 /**
18 * Renderer for core_admin subsystem
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
26 defined('MOODLE_INTERNAL') || die();
28 require_once($CFG->libdir . '/pluginlib.php');
30 /**
31 * Standard HTML output renderer for core_admin subsystem
33 class core_admin_renderer extends plugin_renderer_base {
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.
40 public function install_licence_page() {
41 global $CFG;
42 $output = '';
44 $copyrightnotice = text_to_html(get_string('gpl3'));
45 $copyrightnotice = str_replace('target="_blank"', 'onclick="this.target=\'_blank\'"', $copyrightnotice); // extremely ugly validation hack
47 $continue = new single_button(new moodle_url('/admin/index.php', array('lang'=>$CFG->lang, 'agreelicense'=>1)), get_string('continue'), 'get');
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();
57 return $output;
60 /**
61 * Display page explaining proper upgrade process,
62 * there can not be any PHP file leftovers...
64 * @return string HTML to output.
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 .= format_text(get_string('upgradestalefilesinfo', 'admin', get_docs_url('Upgrading')), FORMAT_MARKDOWN);
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();
77 return $output;
80 /**
81 * Display the 'environment check' page that is displayed during install.
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
86 * @return string HTML to output.
88 public function install_environment_page($maturity, $envstatus, $environment_results, $release) {
89 global $CFG;
90 $output = '';
92 $output .= $this->header();
93 $output .= $this->maturity_warning($maturity);
94 $output .= $this->heading("Moodle $release");
95 $output .= $this->release_notes_link();
97 $output .= $this->environment_check_table($envstatus, $environment_results);
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)));
106 $output .= $this->footer();
107 return $output;
111 * Displays the list of plugins with unsatisfied dependencies
113 * @param double|string|int $version Moodle on-disk version
114 * @param array $failed list of plugins with unsatisfied dependecies
115 * @param moodle_url $reloadurl URL of the page to recheck the dependencies
116 * @return string HTML
118 public function unsatisfied_dependencies_page($version, array $failed, moodle_url $reloadurl) {
119 $output = '';
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);
128 $output .= $this->footer();
130 return $output;
134 * Display the 'You are about to upgrade Moodle' page. The first page
135 * during upgrade.
136 * @param string $strnewversion
137 * @param int $maturity
138 * @return string HTML to output.
140 public function upgrade_confirm_page($strnewversion, $maturity) {
141 $output = '';
143 $continueurl = new moodle_url('index.php', array('confirmupgrade' => 1));
144 $cancelurl = new moodle_url('index.php');
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();
151 return $output;
155 * Display the environment page during the upgrade process.
156 * @param string $release
157 * @param boolean $envstatus final result of env check (true/false)
158 * @param array $environment_results array of results gathered
159 * @return string HTML to output.
161 public function upgrade_environment_page($release, $envstatus, $environment_results) {
162 global $CFG;
163 $output = '';
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);
170 if (!$envstatus) {
171 $output .= $this->upgrade_reload(new moodle_url('/admin/index.php'), array('confirmupgrade' => 1));
173 } else {
174 $output .= $this->notification(get_string('environmentok', 'admin'), 'notifysuccess');
176 if (empty($CFG->skiplangupgrade) and current_language() !== 'en') {
177 $output .= $this->box(get_string('langpackwillbeupdated', 'admin'), 'generalbox', 'notice');
180 $output .= $this->continue_button(new moodle_url('/admin/index.php', array('confirmupgrade' => 1, 'confirmrelease' => 1)));
183 $output .= $this->footer();
185 return $output;
189 * Display the upgrade page that lists all the plugins that require attention.
190 * @param plugin_manager $pluginman provides information about the plugins.
191 * @param available_update_checker $checker provides information about available updates.
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
196 * @return string HTML to output.
198 public function upgrade_plugin_check_page(plugin_manager $pluginman, available_update_checker $checker,
199 $version, $showallplugins, $reloadurl, $continueurl) {
200 global $CFG;
202 $output = '';
204 $output .= $this->header();
205 $output .= $this->box_start('generalbox');
206 $output .= $this->container_start('generalbox', 'notice');
207 $output .= html_writer::tag('p', get_string('pluginchecknotice', 'core_plugin'));
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'))));
215 $output .= $this->container_end();
217 $output .= $this->container_end();
219 $output .= $this->plugins_check_table($pluginman, $version, array('full' => $showallplugins));
220 $output .= $this->box_end();
221 $output .= $this->upgrade_reload($reloadurl);
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();
229 $button = new single_button($continueurl, get_string('upgradestart', 'admin'), 'get');
230 $button->class = 'continuebutton';
231 $output .= $this->render($button);
232 $output .= $this->footer();
234 return $output;
238 * Prints a page with a summary of plugin deployment to be confirmed.
240 * @param available_update_deployer $deployer
241 * @param array $data deployer's data package as returned by {@link available_update_deployer::submitted_data()}
242 * @return string
244 public function upgrade_plugin_confirm_deploy_page(available_update_deployer $deployer, array $data) {
246 if (!$deployer->initialized()) {
247 throw new coding_exception('Unable to render a page for non-initialized deployer.');
250 if (empty($data['updateinfo'])) {
251 throw new coding_exception('Missing required data component.');
254 $updateinfo = $data['updateinfo'];
256 $output = '';
257 $output .= $this->header();
258 $output .= $this->container_start('generalbox updateplugin', 'notice');
260 $a = new stdClass();
261 if (get_string_manager()->string_exists('pluginname', $updateinfo->component)) {
262 $a->name = get_string('pluginname', $updateinfo->component);
263 } else {
264 $a->name = $updateinfo->component;
267 if (isset($updateinfo->release)) {
268 $a->version = $updateinfo->release . ' (' . $updateinfo->version . ')';
269 } else {
270 $a->version = $updateinfo->version;
272 $a->url = $updateinfo->download;
274 $output .= $this->output->heading(get_string('updatepluginconfirm', 'core_plugin'));
275 $output .= $this->output->container(format_text(get_string('updatepluginconfirminfo', 'core_plugin', $a)), 'updatepluginconfirminfo');
276 $output .= $this->output->container(get_string('updatepluginconfirmwarning', 'core_plugin', 'updatepluginconfirmwarning'));
278 if ($repotype = $deployer->plugin_external_source($data['updateinfo'])) {
279 $output .= $this->output->container(get_string('updatepluginconfirmexternal', 'core_plugin', $repotype), 'updatepluginconfirmexternal');
282 $widget = $deployer->make_execution_widget($data['updateinfo']);
283 $output .= $this->output->render($widget);
285 $output .= $this->output->single_button($data['returnurl'], get_string('cancel', 'core'), 'get');
287 $output .= $this->container_end();
288 $output .= $this->footer();
290 return $output;
294 * Display the admin notifications page.
295 * @param int $maturity
296 * @param bool $insecuredataroot warn dataroot is invalid
297 * @param bool $errorsdisplayed warn invalid dispaly error setting
298 * @param bool $cronoverdue warn cron not running
299 * @param bool $dbproblems warn db has problems
300 * @param bool $maintenancemode warn in maintenance mode
301 * @param bool $buggyiconvnomb warn iconv problems
302 * @param array|null $availableupdates array of available_update_info objects or null
303 * @param int|null $availableupdatesfetch timestamp of the most recent updates fetch or null (unknown)
305 * @return string HTML to output.
307 public function admin_notifications_page($maturity, $insecuredataroot, $errorsdisplayed,
308 $cronoverdue, $dbproblems, $maintenancemode, $availableupdates, $availableupdatesfetch,
309 $buggyiconvnomb, $registered) {
310 global $CFG;
311 $output = '';
313 $output .= $this->header();
314 $output .= $this->maturity_info($maturity);
315 $output .= empty($CFG->disableupdatenotifications) ? $this->available_updates($availableupdates, $availableupdatesfetch) : '';
316 $output .= $this->insecure_dataroot_warning($insecuredataroot);
317 $output .= $this->display_errors_warning($errorsdisplayed);
318 $output .= $this->buggy_iconv_warning($buggyiconvnomb);
319 $output .= $this->cron_overdue_warning($cronoverdue);
320 $output .= $this->db_problems($dbproblems);
321 $output .= $this->maintenance_mode_warning($maintenancemode);
322 $output .= $this->registration_warning($registered);
324 //////////////////////////////////////////////////////////////////////////////////////////////////
325 //// IT IS ILLEGAL AND A VIOLATION OF THE GPL TO HIDE, REMOVE OR MODIFY THIS COPYRIGHT NOTICE ///
326 $output .= $this->moodle_copyright();
327 //////////////////////////////////////////////////////////////////////////////////////////////////
329 $output .= $this->footer();
331 return $output;
335 * Display the plugin management page (admin/plugins.php).
337 * The filtering options array may contain following items:
338 * bool contribonly - show only contributed extensions
339 * bool updatesonly - show only plugins with an available update
341 * @param plugin_manager $pluginman
342 * @param available_update_checker $checker
343 * @param array $options filtering options
344 * @return string HTML to output.
346 public function plugin_management_page(plugin_manager $pluginman, available_update_checker $checker, array $options = array()) {
347 global $CFG;
349 $output = '';
351 $output .= $this->header();
352 $output .= $this->heading(get_string('pluginsoverview', 'core_admin'));
353 $output .= $this->plugins_overview_panel($pluginman, $options);
355 if (empty($CFG->disableupdatenotifications)) {
356 $output .= $this->container_start('checkforupdates');
357 $output .= $this->single_button(
358 new moodle_url($this->page->url, array_merge($options, array('fetchremote' => 1))),
359 get_string('checkforupdates', 'core_plugin')
361 if ($timefetched = $checker->get_last_timefetched()) {
362 $output .= $this->container(get_string('checkforupdateslast', 'core_plugin',
363 userdate($timefetched, get_string('strftimedatetime', 'core_langconfig'))));
365 $output .= $this->container_end();
368 $output .= $this->box($this->plugins_control_panel($pluginman, $options), 'generalbox');
369 $output .= $this->footer();
371 return $output;
375 * Display the plugin management page (admin/environment.php).
376 * @param array $versions
377 * @param string $version
378 * @param boolean $envstatus final result of env check (true/false)
379 * @param array $environment_results array of results gathered
380 * @return string HTML to output.
382 public function environment_check_page($versions, $version, $envstatus, $environment_results) {
383 $output = '';
384 $output .= $this->header();
386 // Print the component download link
387 $output .= html_writer::tag('div', html_writer::link(
388 new moodle_url('/admin/environment.php', array('action' => 'updatecomponent', 'sesskey' => sesskey())),
389 get_string('updatecomponent', 'admin')),
390 array('class' => 'reportlink'));
392 // Heading.
393 $output .= $this->heading(get_string('environment', 'admin'));
395 // Box with info and a menu to choose the version.
396 $output .= $this->box_start();
397 $output .= html_writer::tag('div', get_string('adminhelpenvironment'));
398 $select = new single_select(new moodle_url('/admin/environment.php'), 'version', $versions, $version, null);
399 $select->label = get_string('moodleversion');
400 $output .= $this->render($select);
401 $output .= $this->box_end();
403 // The results
404 $output .= $this->environment_check_table($envstatus, $environment_results);
406 $output .= $this->footer();
407 return $output;
411 * Output a warning message, of the type that appears on the admin notifications page.
412 * @param string $message the message to display.
413 * @param string $type type class
414 * @return string HTML to output.
416 protected function warning($message, $type = 'warning') {
417 return $this->box($message, 'generalbox admin' . $type);
421 * Render an appropriate message if dataroot is insecure.
422 * @param bool $insecuredataroot
423 * @return string HTML to output.
425 protected function insecure_dataroot_warning($insecuredataroot) {
426 global $CFG;
428 if ($insecuredataroot == INSECURE_DATAROOT_WARNING) {
429 return $this->warning(get_string('datarootsecuritywarning', 'admin', $CFG->dataroot));
431 } else if ($insecuredataroot == INSECURE_DATAROOT_ERROR) {
432 return $this->warning(get_string('datarootsecurityerror', 'admin', $CFG->dataroot), 'error');
434 } else {
435 return '';
440 * Render an appropriate message if dataroot is insecure.
441 * @param bool $errorsdisplayed
442 * @return string HTML to output.
444 protected function display_errors_warning($errorsdisplayed) {
445 if (!$errorsdisplayed) {
446 return '';
449 return $this->warning(get_string('displayerrorswarning', 'admin'));
453 * Render an appropriate message if iconv is buggy and mbstring missing.
454 * @param bool $buggyiconvnomb
455 * @return string HTML to output.
457 protected function buggy_iconv_warning($buggyiconvnomb) {
458 if (!$buggyiconvnomb) {
459 return '';
462 return $this->warning(get_string('warningiconvbuggy', 'admin'));
466 * Render an appropriate message if cron has not been run recently.
467 * @param bool $cronoverdue
468 * @return string HTML to output.
470 public function cron_overdue_warning($cronoverdue) {
471 if (!$cronoverdue) {
472 return '';
475 return $this->warning(get_string('cronwarning', 'admin') . '&nbsp;' .
476 $this->help_icon('cron', 'admin'));
480 * Render an appropriate message if there are any problems with the DB set-up.
481 * @param bool $dbproblems
482 * @return string HTML to output.
484 public function db_problems($dbproblems) {
485 if (!$dbproblems) {
486 return '';
489 return $this->warning($dbproblems);
493 * Render an appropriate message if the site in in maintenance mode.
494 * @param bool $maintenancemode
495 * @return string HTML to output.
497 public function maintenance_mode_warning($maintenancemode) {
498 if (!$maintenancemode) {
499 return '';
502 $url = new moodle_url('/admin/settings.php', array('section' => 'maintenancemode'));
503 $url = $url->out(); // get_string() does not support objects in params
505 return $this->warning(get_string('sitemaintenancewarning2', 'admin', $url));
509 * Display a warning about installing development code if necesary.
510 * @param int $maturity
511 * @return string HTML to output.
513 protected function maturity_warning($maturity) {
514 if ($maturity == MATURITY_STABLE) {
515 return ''; // No worries.
518 $maturitylevel = get_string('maturity' . $maturity, 'admin');
519 return $this->box(
520 $this->container(get_string('maturitycorewarning', 'admin', $maturitylevel)) .
521 $this->container($this->doc_link('admin/versions', get_string('morehelp'))),
522 'generalbox maturitywarning');
526 * Output the copyright notice.
527 * @return string HTML to output.
529 protected function moodle_copyright() {
530 global $CFG;
532 //////////////////////////////////////////////////////////////////////////////////////////////////
533 //// IT IS ILLEGAL AND A VIOLATION OF THE GPL TO HIDE, REMOVE OR MODIFY THIS COPYRIGHT NOTICE ///
534 $copyrighttext = '<a href="http://moodle.org/">Moodle</a> '.
535 '<a href="http://docs.moodle.org/dev/Releases" title="'.$CFG->version.'">'.$CFG->release.'</a><br />'.
536 'Copyright &copy; 1999 onwards, Martin Dougiamas<br />'.
537 'and <a href="http://moodle.org/dev">many other contributors</a>.<br />'.
538 '<a href="http://docs.moodle.org/dev/License">GNU Public License</a>';
539 //////////////////////////////////////////////////////////////////////////////////////////////////
541 return $this->box($copyrighttext, 'copyright');
545 * Display a warning about installing development code if necesary.
546 * @param int $maturity
547 * @return string HTML to output.
549 protected function maturity_info($maturity) {
550 if ($maturity == MATURITY_STABLE) {
551 return ''; // No worries.
554 $maturitylevel = get_string('maturity' . $maturity, 'admin');
555 return $this->box(
556 get_string('maturitycoreinfo', 'admin', $maturitylevel) . ' ' .
557 $this->doc_link('admin/versions', get_string('morehelp')),
558 'generalbox adminwarning maturityinfo maturity'.$maturity);
562 * Displays the info about available Moodle core and plugin updates
564 * The structure of the $updates param has changed since 2.4. It contains not only updates
565 * for the core itself, but also for all other installed plugins.
567 * @param array|null $updates array of (string)component => array of available_update_info objects or null
568 * @param int|null $fetch timestamp of the most recent updates fetch or null (unknown)
569 * @return string
571 protected function available_updates($updates, $fetch) {
573 $updateinfo = $this->box_start('generalbox adminwarning availableupdatesinfo');
574 $someupdateavailable = false;
575 if (is_array($updates)) {
576 if (is_array($updates['core'])) {
577 $someupdateavailable = true;
578 $updateinfo .= $this->heading(get_string('updateavailable', 'core_admin'), 3);
579 foreach ($updates['core'] as $update) {
580 $updateinfo .= $this->moodle_available_update_info($update);
583 unset($updates['core']);
584 // If something has left in the $updates array now, it is updates for plugins.
585 if (!empty($updates)) {
586 $someupdateavailable = true;
587 $updateinfo .= $this->heading(get_string('updateavailableforplugin', 'core_admin'), 3);
588 $pluginsoverviewurl = new moodle_url('/admin/plugins.php', array('updatesonly' => 1));
589 $updateinfo .= $this->container(get_string('pluginsoverviewsee', 'core_admin',
590 array('url' => $pluginsoverviewurl->out())));
594 if (!$someupdateavailable) {
595 $now = time();
596 if ($fetch and ($fetch <= $now) and ($now - $fetch < HOURSECS)) {
597 $updateinfo .= $this->heading(get_string('updateavailablenot', 'core_admin'), 3);
601 $updateinfo .= $this->container_start('checkforupdates');
602 $updateinfo .= $this->single_button(new moodle_url($this->page->url, array('fetchupdates' => 1)), get_string('checkforupdates', 'core_plugin'));
603 if ($fetch) {
604 $updateinfo .= $this->container(get_string('checkforupdateslast', 'core_plugin',
605 userdate($fetch, get_string('strftimedatetime', 'core_langconfig'))));
607 $updateinfo .= $this->container_end();
609 $updateinfo .= $this->box_end();
611 return $updateinfo;
615 * Display a warning about not being registered on Moodle.org if necesary.
617 * @param boolean $registered true if the site is registered on Moodle.org
618 * @return string HTML to output.
620 protected function registration_warning($registered) {
622 if (!$registered) {
624 $registerbutton = $this->single_button(new moodle_url('registration/register.php',
625 array('huburl' => HUB_MOODLEORGHUBURL, 'hubname' => 'Moodle.org')),
626 get_string('register', 'admin'));
628 return $this->warning( get_string('registrationwarning', 'admin')
629 . '&nbsp;' . $this->help_icon('registration', 'admin') . $registerbutton );
632 return '';
636 * Helper method to render the information about the available Moodle update
638 * @param available_update_info $updateinfo information about the available Moodle core update
640 protected function moodle_available_update_info(available_update_info $updateinfo) {
642 $boxclasses = 'moodleupdateinfo';
643 $info = array();
645 if (isset($updateinfo->release)) {
646 $info[] = html_writer::tag('span', get_string('updateavailable_release', 'core_admin', $updateinfo->release),
647 array('class' => 'info release'));
650 if (isset($updateinfo->version)) {
651 $info[] = html_writer::tag('span', get_string('updateavailable_version', 'core_admin', $updateinfo->version),
652 array('class' => 'info version'));
655 if (isset($updateinfo->maturity)) {
656 $info[] = html_writer::tag('span', get_string('maturity'.$updateinfo->maturity, 'core_admin'),
657 array('class' => 'info maturity'));
658 $boxclasses .= ' maturity'.$updateinfo->maturity;
661 if (isset($updateinfo->download)) {
662 $info[] = html_writer::link($updateinfo->download, get_string('download'), array('class' => 'info download'));
665 if (isset($updateinfo->url)) {
666 $info[] = html_writer::link($updateinfo->url, get_string('updateavailable_moreinfo', 'core_plugin'),
667 array('class' => 'info more'));
670 $box = $this->output->box_start($boxclasses);
671 $box .= $this->output->box(implode(html_writer::tag('span', ' ', array('class' => 'separator')), $info), '');
672 $box .= $this->output->box_end();
674 return $box;
678 * Display a link to the release notes.
679 * @return string HTML to output.
681 protected function release_notes_link() {
682 $releasenoteslink = get_string('releasenoteslink', 'admin', 'http://docs.moodle.org/dev/Releases');
683 $releasenoteslink = str_replace('target="_blank"', 'onclick="this.target=\'_blank\'"', $releasenoteslink); // extremely ugly validation hack
684 return $this->box($releasenoteslink, 'generalbox releasenoteslink');
688 * Display the reload link that appears on several upgrade/install pages.
689 * @return string HTML to output.
691 function upgrade_reload($url) {
692 return html_writer::empty_tag('br') .
693 html_writer::tag('div',
694 html_writer::link($url, $this->pix_icon('i/reload', '', '', array('class' => 'icon icon-pre')) .
695 get_string('reload'), array('title' => get_string('reload'))),
696 array('class' => 'continuebutton')) . html_writer::empty_tag('br');
700 * Displays all known plugins and information about their installation or upgrade
702 * This default implementation renders all plugins into one big table. The rendering
703 * options support:
704 * (bool)full = false: whether to display up-to-date plugins, too
705 * (bool)xdep = false: display the plugins with unsatisified dependecies only
707 * @param plugin_manager $pluginman provides information about the plugins.
708 * @param int $version the version of the Moodle code from version.php.
709 * @param array $options rendering options
710 * @return string HTML code
712 public function plugins_check_table(plugin_manager $pluginman, $version, array $options = array()) {
713 global $CFG;
715 $plugininfo = $pluginman->get_plugins();
717 if (empty($plugininfo)) {
718 return '';
721 $options['full'] = isset($options['full']) ? (bool)$options['full'] : false;
722 $options['xdep'] = isset($options['xdep']) ? (bool)$options['xdep'] : false;
724 $table = new html_table();
725 $table->id = 'plugins-check';
726 $table->head = array(
727 get_string('displayname', 'core_plugin'),
728 get_string('rootdir', 'core_plugin'),
729 get_string('source', 'core_plugin'),
730 get_string('versiondb', 'core_plugin'),
731 get_string('versiondisk', 'core_plugin'),
732 get_string('requires', 'core_plugin'),
733 get_string('status', 'core_plugin'),
735 $table->colclasses = array(
736 'displayname', 'rootdir', 'source', 'versiondb', 'versiondisk', 'requires', 'status',
738 $table->data = array();
740 $numofhighlighted = array(); // number of highlighted rows per this subsection
742 foreach ($plugininfo as $type => $plugins) {
744 $header = new html_table_cell($pluginman->plugintype_name_plural($type));
745 $header->header = true;
746 $header->colspan = count($table->head);
747 $header = new html_table_row(array($header));
748 $header->attributes['class'] = 'plugintypeheader type-' . $type;
750 $numofhighlighted[$type] = 0;
752 if (empty($plugins) and $options['full']) {
753 $msg = new html_table_cell(get_string('noneinstalled', 'core_plugin'));
754 $msg->colspan = count($table->head);
755 $row = new html_table_row(array($msg));
756 $row->attributes['class'] .= 'msg msg-noneinstalled';
757 $table->data[] = $header;
758 $table->data[] = $row;
759 continue;
762 $plugintyperows = array();
764 foreach ($plugins as $name => $plugin) {
765 $row = new html_table_row();
766 $row->attributes['class'] = 'type-' . $plugin->type . ' name-' . $plugin->type . '_' . $plugin->name;
768 if ($this->page->theme->resolve_image_location('icon', $plugin->type . '_' . $plugin->name, null)) {
769 $icon = $this->output->pix_icon('icon', '', $plugin->type . '_' . $plugin->name, array('class' => 'smallicon pluginicon'));
770 } else {
771 $icon = $this->output->pix_icon('spacer', '', 'moodle', array('class' => 'smallicon pluginicon noicon'));
773 $displayname = $icon . ' ' . $plugin->displayname;
774 $displayname = new html_table_cell($displayname);
776 $rootdir = new html_table_cell($plugin->get_dir());
778 if ($isstandard = $plugin->is_standard()) {
779 $row->attributes['class'] .= ' standard';
780 $source = new html_table_cell(get_string('sourcestd', 'core_plugin'));
781 } else {
782 $row->attributes['class'] .= ' extension';
783 $source = new html_table_cell(get_string('sourceext', 'core_plugin'));
786 $versiondb = new html_table_cell($plugin->versiondb);
787 $versiondisk = new html_table_cell($plugin->versiondisk);
789 $statuscode = $plugin->get_status();
790 $row->attributes['class'] .= ' status-' . $statuscode;
791 $status = get_string('status_' . $statuscode, 'core_plugin');
793 $availableupdates = $plugin->available_updates();
794 if (!empty($availableupdates) and empty($CFG->disableupdatenotifications)) {
795 foreach ($availableupdates as $availableupdate) {
796 $status .= $this->plugin_available_update_info($availableupdate);
800 $status = new html_table_cell($status);
802 $requires = new html_table_cell($this->required_column($plugin, $pluginman, $version));
804 $statusisboring = in_array($statuscode, array(
805 plugin_manager::PLUGIN_STATUS_NODB, plugin_manager::PLUGIN_STATUS_UPTODATE));
807 $coredependency = $plugin->is_core_dependency_satisfied($version);
808 $otherpluginsdependencies = $pluginman->are_dependencies_satisfied($plugin->get_other_required_plugins());
809 $dependenciesok = $coredependency && $otherpluginsdependencies;
811 if ($options['xdep']) {
812 // we want to see only plugins with failed dependencies
813 if ($dependenciesok) {
814 continue;
817 } else if ($isstandard and $statusisboring and $dependenciesok and empty($availableupdates)) {
818 // no change is going to happen to the plugin - display it only
819 // if the user wants to see the full list
820 if (empty($options['full'])) {
821 continue;
825 // ok, the plugin should be displayed
826 $numofhighlighted[$type]++;
828 $row->cells = array($displayname, $rootdir, $source,
829 $versiondb, $versiondisk, $requires, $status);
830 $plugintyperows[] = $row;
833 if (empty($numofhighlighted[$type]) and empty($options['full'])) {
834 continue;
837 $table->data[] = $header;
838 $table->data = array_merge($table->data, $plugintyperows);
841 $sumofhighlighted = array_sum($numofhighlighted);
843 if ($options['xdep']) {
844 // we do not want to display no heading and links in this mode
845 $out = '';
847 } else if ($sumofhighlighted == 0) {
848 $out = $this->output->container_start('nonehighlighted', 'plugins-check-info');
849 $out .= $this->output->heading(get_string('nonehighlighted', 'core_plugin'));
850 if (empty($options['full'])) {
851 $out .= html_writer::link(new moodle_url('/admin/index.php',
852 array('confirmupgrade' => 1, 'confirmrelease' => 1, 'showallplugins' => 1)),
853 get_string('nonehighlightedinfo', 'core_plugin'));
855 $out .= $this->output->container_end();
857 } else {
858 $out = $this->output->container_start('somehighlighted', 'plugins-check-info');
859 $out .= $this->output->heading(get_string('somehighlighted', 'core_plugin', $sumofhighlighted));
860 if (empty($options['full'])) {
861 $out .= html_writer::link(new moodle_url('/admin/index.php',
862 array('confirmupgrade' => 1, 'confirmrelease' => 1, 'showallplugins' => 1)),
863 get_string('somehighlightedinfo', 'core_plugin'));
864 } else {
865 $out .= html_writer::link(new moodle_url('/admin/index.php',
866 array('confirmupgrade' => 1, 'confirmrelease' => 1, 'showallplugins' => 0)),
867 get_string('somehighlightedonly', 'core_plugin'));
869 $out .= $this->output->container_end();
872 if ($sumofhighlighted > 0 or $options['full']) {
873 $out .= html_writer::table($table);
876 return $out;
880 * Formats the information that needs to go in the 'Requires' column.
881 * @param plugininfo_base $plugin the plugin we are rendering the row for.
882 * @param plugin_manager $pluginman provides data on all the plugins.
883 * @param string $version
884 * @return string HTML code
886 protected function required_column(plugininfo_base $plugin, plugin_manager $pluginman, $version) {
887 $requires = array();
889 if (!empty($plugin->versionrequires)) {
890 if ($plugin->versionrequires <= $version) {
891 $class = 'requires-ok';
892 } else {
893 $class = 'requires-failed';
895 $requires[] = html_writer::tag('li',
896 get_string('moodleversion', 'core_plugin', $plugin->versionrequires),
897 array('class' => $class));
900 foreach ($plugin->get_other_required_plugins() as $component => $requiredversion) {
901 $ok = true;
902 $otherplugin = $pluginman->get_plugin_info($component);
904 if (is_null($otherplugin)) {
905 $ok = false;
906 } else if ($requiredversion != ANY_VERSION and $otherplugin->versiondisk < $requiredversion) {
907 $ok = false;
910 if ($ok) {
911 $class = 'requires-ok';
912 } else {
913 $class = 'requires-failed';
916 if ($requiredversion != ANY_VERSION) {
917 $str = 'otherpluginversion';
918 } else {
919 $str = 'otherplugin';
921 $componenturl = new moodle_url('https://moodle.org/plugins/view.php?plugin='.$component);
922 $componenturl = html_writer::tag('a', $component, array('href' => $componenturl->out()));
923 $requires[] = html_writer::tag('li',
924 get_string($str, 'core_plugin',
925 array('component' => $componenturl, 'version' => $requiredversion)),
926 array('class' => $class));
929 if (!$requires) {
930 return '';
932 return html_writer::tag('ul', implode("\n", $requires));
936 * Prints an overview about the plugins - number of installed, number of extensions etc.
938 * @param plugin_manager $pluginman provides information about the plugins
939 * @param array $options filtering options
940 * @return string as usually
942 public function plugins_overview_panel(plugin_manager $pluginman, array $options = array()) {
943 global $CFG;
945 $plugininfo = $pluginman->get_plugins();
947 $numtotal = $numdisabled = $numextension = $numupdatable = 0;
949 foreach ($plugininfo as $type => $plugins) {
950 foreach ($plugins as $name => $plugin) {
951 if ($plugin->get_status() === plugin_manager::PLUGIN_STATUS_MISSING) {
952 continue;
954 $numtotal++;
955 if ($plugin->is_enabled() === false) {
956 $numdisabled++;
958 if (!$plugin->is_standard()) {
959 $numextension++;
961 if (empty($CFG->disableupdatenotifications) and $plugin->available_updates()) {
962 $numupdatable++;
967 $info = array();
968 $filter = array();
969 $somefilteractive = false;
970 $info[] = html_writer::tag('span', get_string('numtotal', 'core_plugin', $numtotal), array('class' => 'info total'));
971 $info[] = html_writer::tag('span', get_string('numdisabled', 'core_plugin', $numdisabled), array('class' => 'info disabled'));
972 $info[] = html_writer::tag('span', get_string('numextension', 'core_plugin', $numextension), array('class' => 'info extension'));
973 if ($numextension > 0) {
974 if (empty($options['contribonly'])) {
975 $filter[] = html_writer::link(
976 new moodle_url($this->page->url, array('contribonly' => 1)),
977 get_string('filtercontribonly', 'core_plugin'),
978 array('class' => 'filter-item show-contribonly')
980 } else {
981 $filter[] = html_writer::tag('span', get_string('filtercontribonlyactive', 'core_plugin'),
982 array('class' => 'filter-item active show-contribonly'));
983 $somefilteractive = true;
986 if ($numupdatable > 0) {
987 $info[] = html_writer::tag('span', get_string('numupdatable', 'core_plugin', $numupdatable), array('class' => 'info updatable'));
988 if (empty($options['updatesonly'])) {
989 $filter[] = html_writer::link(
990 new moodle_url($this->page->url, array('updatesonly' => 1)),
991 get_string('filterupdatesonly', 'core_plugin'),
992 array('class' => 'filter-item show-updatesonly')
994 } else {
995 $filter[] = html_writer::tag('span', get_string('filterupdatesonlyactive', 'core_plugin'),
996 array('class' => 'filter-item active show-updatesonly'));
997 $somefilteractive = true;
1000 if ($somefilteractive) {
1001 $filter[] = html_writer::link($this->page->url, get_string('filterall', 'core_plugin'), array('class' => 'filter-item show-all'));
1004 $output = $this->output->box(implode(html_writer::tag('span', ' ', array('class' => 'separator')), $info), '', 'plugins-overview-panel');
1006 if (!empty($filter)) {
1007 $output .= $this->output->box(implode(html_writer::tag('span', ' ', array('class' => 'separator')), $filter), '', 'plugins-overview-filter');
1010 return $output;
1014 * Displays all known plugins and links to manage them
1016 * This default implementation renders all plugins into one big table.
1018 * @param plugin_manager $pluginman provides information about the plugins.
1019 * @param array $options filtering options
1020 * @return string HTML code
1022 public function plugins_control_panel(plugin_manager $pluginman, array $options = array()) {
1023 global $CFG;
1025 $plugininfo = $pluginman->get_plugins();
1027 // Filter the list of plugins according the options.
1028 if (!empty($options['updatesonly'])) {
1029 $updateable = array();
1030 foreach ($plugininfo as $plugintype => $pluginnames) {
1031 foreach ($pluginnames as $pluginname => $pluginfo) {
1032 if (!empty($pluginfo->availableupdates)) {
1033 foreach ($pluginfo->availableupdates as $pluginavailableupdate) {
1034 if ($pluginavailableupdate->version > $pluginfo->versiondisk) {
1035 $updateable[$plugintype][$pluginname] = $pluginfo;
1041 $plugininfo = $updateable;
1044 if (!empty($options['contribonly'])) {
1045 $contribs = array();
1046 foreach ($plugininfo as $plugintype => $pluginnames) {
1047 foreach ($pluginnames as $pluginname => $pluginfo) {
1048 if (!$pluginfo->is_standard()) {
1049 $contribs[$plugintype][$pluginname] = $pluginfo;
1053 $plugininfo = $contribs;
1056 if (empty($plugininfo)) {
1057 return '';
1060 $table = new html_table();
1061 $table->id = 'plugins-control-panel';
1062 $table->head = array(
1063 get_string('displayname', 'core_plugin'),
1064 get_string('source', 'core_plugin'),
1065 get_string('version', 'core_plugin'),
1066 get_string('availability', 'core_plugin'),
1067 get_string('actions', 'core_plugin'),
1068 get_string('notes','core_plugin'),
1070 $table->colclasses = array(
1071 'pluginname', 'source', 'version', 'availability', 'actions', 'notes'
1074 foreach ($plugininfo as $type => $plugins) {
1076 $header = new html_table_cell($pluginman->plugintype_name_plural($type));
1077 $header->header = true;
1078 $header->colspan = count($table->head);
1079 $header = new html_table_row(array($header));
1080 $header->attributes['class'] = 'plugintypeheader type-' . $type;
1081 $table->data[] = $header;
1083 if (empty($plugins)) {
1084 $msg = new html_table_cell(get_string('noneinstalled', 'core_plugin'));
1085 $msg->colspan = count($table->head);
1086 $row = new html_table_row(array($msg));
1087 $row->attributes['class'] .= 'msg msg-noneinstalled';
1088 $table->data[] = $row;
1089 continue;
1092 foreach ($plugins as $name => $plugin) {
1093 $row = new html_table_row();
1094 $row->attributes['class'] = 'type-' . $plugin->type . ' name-' . $plugin->type . '_' . $plugin->name;
1096 if ($this->page->theme->resolve_image_location('icon', $plugin->type . '_' . $plugin->name)) {
1097 $icon = $this->output->pix_icon('icon', '', $plugin->type . '_' . $plugin->name, array('class' => 'icon pluginicon'));
1098 } else {
1099 $icon = $this->output->pix_icon('spacer', '', 'moodle', array('class' => 'icon pluginicon noicon'));
1101 if ($plugin->get_status() === plugin_manager::PLUGIN_STATUS_MISSING) {
1102 $msg = html_writer::tag('span', get_string('status_missing', 'core_plugin'), array('class' => 'notifyproblem'));
1103 $row->attributes['class'] .= ' missingfromdisk';
1104 } else {
1105 $msg = '';
1107 $pluginname = html_writer::tag('div', $icon . '' . $plugin->displayname . ' ' . $msg, array('class' => 'displayname')).
1108 html_writer::tag('div', $plugin->component, array('class' => 'componentname'));
1109 $pluginname = new html_table_cell($pluginname);
1111 if ($plugin->is_standard()) {
1112 $row->attributes['class'] .= ' standard';
1113 $source = new html_table_cell(get_string('sourcestd', 'core_plugin'));
1114 } else {
1115 $row->attributes['class'] .= ' extension';
1116 $source = new html_table_cell(get_string('sourceext', 'core_plugin'));
1119 $version = new html_table_cell($plugin->versiondb);
1121 $isenabled = $plugin->is_enabled();
1122 if (is_null($isenabled)) {
1123 $availability = new html_table_cell('');
1124 } else if ($isenabled) {
1125 $row->attributes['class'] .= ' enabled';
1126 $availability = new html_table_cell(get_string('pluginenabled', 'core_plugin'));
1127 } else {
1128 $row->attributes['class'] .= ' disabled';
1129 $availability = new html_table_cell(get_string('plugindisabled', 'core_plugin'));
1132 $actions = array();
1134 $settingsurl = $plugin->get_settings_url();
1135 if (!is_null($settingsurl)) {
1136 $actions[] = html_writer::link($settingsurl, get_string('settings', 'core_plugin'), array('class' => 'settings'));
1139 $uninstallurl = $plugin->get_uninstall_url();
1140 if (!is_null($uninstallurl)) {
1141 $actions[] = html_writer::link($uninstallurl, get_string('uninstall', 'core_plugin'), array('class' => 'uninstall'));
1144 $actions = new html_table_cell(implode(html_writer::tag('span', ' ', array('class' => 'separator')), $actions));
1146 $requriedby = $pluginman->other_plugins_that_require($plugin->component);
1147 if ($requriedby) {
1148 $requiredby = html_writer::tag('div', get_string('requiredby', 'core_plugin', implode(', ', $requriedby)),
1149 array('class' => 'requiredby'));
1150 } else {
1151 $requiredby = '';
1154 $updateinfo = '';
1155 if (empty($CFG->disableupdatenotifications) and is_array($plugin->available_updates())) {
1156 foreach ($plugin->available_updates() as $availableupdate) {
1157 $updateinfo .= $this->plugin_available_update_info($availableupdate);
1161 $notes = new html_table_cell($requiredby.$updateinfo);
1163 $row->cells = array(
1164 $pluginname, $source, $version, $availability, $actions, $notes
1166 $table->data[] = $row;
1170 return html_writer::table($table);
1174 * Helper method to render the information about the available plugin update
1176 * The passed objects always provides at least the 'version' property containing
1177 * the (higher) version of the plugin available.
1179 * @param available_update_info $updateinfo information about the available update for the plugin
1181 protected function plugin_available_update_info(available_update_info $updateinfo) {
1183 $boxclasses = 'pluginupdateinfo';
1184 $info = array();
1186 if (isset($updateinfo->release)) {
1187 $info[] = html_writer::tag('span', get_string('updateavailable_release', 'core_plugin', $updateinfo->release),
1188 array('class' => 'info release'));
1191 if (isset($updateinfo->maturity)) {
1192 $info[] = html_writer::tag('span', get_string('maturity'.$updateinfo->maturity, 'core_admin'),
1193 array('class' => 'info maturity'));
1194 $boxclasses .= ' maturity'.$updateinfo->maturity;
1197 if (isset($updateinfo->download)) {
1198 $info[] = html_writer::link($updateinfo->download, get_string('download'), array('class' => 'info download'));
1201 if (isset($updateinfo->url)) {
1202 $info[] = html_writer::link($updateinfo->url, get_string('updateavailable_moreinfo', 'core_plugin'),
1203 array('class' => 'info more'));
1206 $box = $this->output->box_start($boxclasses);
1207 $box .= html_writer::tag('div', get_string('updateavailable', 'core_plugin', $updateinfo->version), array('class' => 'version'));
1208 $box .= $this->output->box(implode(html_writer::tag('span', ' ', array('class' => 'separator')), $info), '');
1210 $deployer = available_update_deployer::instance();
1211 if ($deployer->initialized()) {
1212 $impediments = $deployer->deployment_impediments($updateinfo);
1213 if (empty($impediments)) {
1214 $widget = $deployer->make_confirm_widget($updateinfo);
1215 $box .= $this->output->render($widget);
1216 } else {
1217 if (isset($impediments['notwritable'])) {
1218 $box .= $this->output->help_icon('notwritable', 'core_plugin', get_string('notwritable', 'core_plugin'));
1220 if (isset($impediments['notdownloadable'])) {
1221 $box .= $this->output->help_icon('notdownloadable', 'core_plugin', get_string('notdownloadable', 'core_plugin'));
1226 $box .= $this->output->box_end();
1228 return $box;
1232 * This function will render one beautiful table with all the environmental
1233 * configuration and how it suits Moodle needs.
1235 * @param boolean $result final result of the check (true/false)
1236 * @param array $environment_results array of results gathered
1237 * @return string HTML to output.
1239 public function environment_check_table($result, $environment_results) {
1240 global $CFG;
1242 // Table headers
1243 $servertable = new html_table();//table for server checks
1244 $servertable->head = array(
1245 get_string('name'),
1246 get_string('info'),
1247 get_string('report'),
1248 get_string('status'),
1250 $servertable->align = array('center', 'center', 'left', 'center');
1251 $servertable->wrap = array('nowrap', '', '', 'nowrap');
1252 $servertable->size = array('10', 10, '100%', '10');
1253 $servertable->attributes['class'] = 'environmenttable generaltable';
1255 $serverdata = array('ok'=>array(), 'warn'=>array(), 'error'=>array());
1257 $othertable = new html_table();//table for custom checks
1258 $othertable->head = array(
1259 get_string('info'),
1260 get_string('report'),
1261 get_string('status'),
1263 $othertable->align = array('center', 'left', 'center');
1264 $othertable->wrap = array('', '', 'nowrap');
1265 $othertable->size = array(10, '100%', '10');
1266 $othertable->attributes['class'] = 'environmenttable generaltable';
1268 $otherdata = array('ok'=>array(), 'warn'=>array(), 'error'=>array());
1270 // Iterate over each environment_result
1271 $continue = true;
1272 foreach ($environment_results as $environment_result) {
1273 $errorline = false;
1274 $warningline = false;
1275 $stringtouse = '';
1276 if ($continue) {
1277 $type = $environment_result->getPart();
1278 $info = $environment_result->getInfo();
1279 $status = $environment_result->getStatus();
1280 $error_code = $environment_result->getErrorCode();
1281 // Process Report field
1282 $rec = new stdClass();
1283 // Something has gone wrong at parsing time
1284 if ($error_code) {
1285 $stringtouse = 'environmentxmlerror';
1286 $rec->error_code = $error_code;
1287 $status = get_string('error');
1288 $errorline = true;
1289 $continue = false;
1292 if ($continue) {
1293 if ($rec->needed = $environment_result->getNeededVersion()) {
1294 // We are comparing versions
1295 $rec->current = $environment_result->getCurrentVersion();
1296 if ($environment_result->getLevel() == 'required') {
1297 $stringtouse = 'environmentrequireversion';
1298 } else {
1299 $stringtouse = 'environmentrecommendversion';
1302 } else if ($environment_result->getPart() == 'custom_check') {
1303 // We are checking installed & enabled things
1304 if ($environment_result->getLevel() == 'required') {
1305 $stringtouse = 'environmentrequirecustomcheck';
1306 } else {
1307 $stringtouse = 'environmentrecommendcustomcheck';
1310 } else if ($environment_result->getPart() == 'php_setting') {
1311 if ($status) {
1312 $stringtouse = 'environmentsettingok';
1313 } else if ($environment_result->getLevel() == 'required') {
1314 $stringtouse = 'environmentmustfixsetting';
1315 } else {
1316 $stringtouse = 'environmentshouldfixsetting';
1319 } else {
1320 if ($environment_result->getLevel() == 'required') {
1321 $stringtouse = 'environmentrequireinstall';
1322 } else {
1323 $stringtouse = 'environmentrecommendinstall';
1327 // Calculate the status value
1328 if ($environment_result->getBypassStr() != '') { //Handle bypassed result (warning)
1329 $status = get_string('bypassed');
1330 $warningline = true;
1331 } else if ($environment_result->getRestrictStr() != '') { //Handle restricted result (error)
1332 $status = get_string('restricted');
1333 $errorline = true;
1334 } else {
1335 if ($status) { //Handle ok result (ok)
1336 $status = get_string('ok');
1337 } else {
1338 if ($environment_result->getLevel() == 'optional') {//Handle check result (warning)
1339 $status = get_string('check');
1340 $warningline = true;
1341 } else { //Handle error result (error)
1342 $status = get_string('check');
1343 $errorline = true;
1349 // Build the text
1350 $linkparts = array();
1351 $linkparts[] = 'admin/environment';
1352 $linkparts[] = $type;
1353 if (!empty($info)){
1354 $linkparts[] = $info;
1356 if (empty($CFG->docroot)) {
1357 $report = get_string($stringtouse, 'admin', $rec);
1358 } else {
1359 $report = $this->doc_link(join($linkparts, '/'), get_string($stringtouse, 'admin', $rec));
1362 // Format error or warning line
1363 if ($errorline || $warningline) {
1364 $messagetype = $errorline? 'error':'warn';
1365 } else {
1366 $messagetype = 'ok';
1368 $status = '<span class="'.$messagetype.'">'.$status.'</span>';
1369 // Here we'll store all the feedback found
1370 $feedbacktext = '';
1371 // Append the feedback if there is some
1372 $feedbacktext .= $environment_result->strToReport($environment_result->getFeedbackStr(), $messagetype);
1373 //Append the bypass if there is some
1374 $feedbacktext .= $environment_result->strToReport($environment_result->getBypassStr(), 'warn');
1375 //Append the restrict if there is some
1376 $feedbacktext .= $environment_result->strToReport($environment_result->getRestrictStr(), 'error');
1378 $report .= $feedbacktext;
1380 // Add the row to the table
1381 if ($environment_result->getPart() == 'custom_check'){
1382 $otherdata[$messagetype][] = array ($info, $report, $status);
1383 } else {
1384 $serverdata[$messagetype][] = array ($type, $info, $report, $status);
1389 //put errors first in
1390 $servertable->data = array_merge($serverdata['error'], $serverdata['warn'], $serverdata['ok']);
1391 $othertable->data = array_merge($otherdata['error'], $otherdata['warn'], $otherdata['ok']);
1393 // Print table
1394 $output = '';
1395 $output .= $this->heading(get_string('serverchecks', 'admin'));
1396 $output .= html_writer::table($servertable);
1397 if (count($othertable->data)){
1398 $output .= $this->heading(get_string('customcheck', 'admin'));
1399 $output .= html_writer::table($othertable);
1402 // Finally, if any error has happened, print the summary box
1403 if (!$result) {
1404 $output .= $this->box(get_string('environmenterrortodo', 'admin'), 'environmentbox errorbox');
1407 return $output;