MDL-37455 mod_folder can display content inline. Coding style corrections
[moodle.git] / admin / renderer.php
blobb39976d2220774a7bd58ade77e96a320b815a686
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 $requires[] = html_writer::tag('li',
922 get_string($str, 'core_plugin',
923 array('component' => $component, 'version' => $requiredversion)),
924 array('class' => $class));
927 if (!$requires) {
928 return '';
930 return html_writer::tag('ul', implode("\n", $requires));
934 * Prints an overview about the plugins - number of installed, number of extensions etc.
936 * @param plugin_manager $pluginman provides information about the plugins
937 * @param array $options filtering options
938 * @return string as usually
940 public function plugins_overview_panel(plugin_manager $pluginman, array $options = array()) {
941 global $CFG;
943 $plugininfo = $pluginman->get_plugins();
945 $numtotal = $numdisabled = $numextension = $numupdatable = 0;
947 foreach ($plugininfo as $type => $plugins) {
948 foreach ($plugins as $name => $plugin) {
949 if ($plugin->get_status() === plugin_manager::PLUGIN_STATUS_MISSING) {
950 continue;
952 $numtotal++;
953 if ($plugin->is_enabled() === false) {
954 $numdisabled++;
956 if (!$plugin->is_standard()) {
957 $numextension++;
959 if (empty($CFG->disableupdatenotifications) and $plugin->available_updates()) {
960 $numupdatable++;
965 $info = array();
966 $filter = array();
967 $somefilteractive = false;
968 $info[] = html_writer::tag('span', get_string('numtotal', 'core_plugin', $numtotal), array('class' => 'info total'));
969 $info[] = html_writer::tag('span', get_string('numdisabled', 'core_plugin', $numdisabled), array('class' => 'info disabled'));
970 $info[] = html_writer::tag('span', get_string('numextension', 'core_plugin', $numextension), array('class' => 'info extension'));
971 if ($numextension > 0) {
972 if (empty($options['contribonly'])) {
973 $filter[] = html_writer::link(
974 new moodle_url($this->page->url, array('contribonly' => 1)),
975 get_string('filtercontribonly', 'core_plugin'),
976 array('class' => 'filter-item show-contribonly')
978 } else {
979 $filter[] = html_writer::tag('span', get_string('filtercontribonlyactive', 'core_plugin'),
980 array('class' => 'filter-item active show-contribonly'));
981 $somefilteractive = true;
984 if ($numupdatable > 0) {
985 $info[] = html_writer::tag('span', get_string('numupdatable', 'core_plugin', $numupdatable), array('class' => 'info updatable'));
986 if (empty($options['updatesonly'])) {
987 $filter[] = html_writer::link(
988 new moodle_url($this->page->url, array('updatesonly' => 1)),
989 get_string('filterupdatesonly', 'core_plugin'),
990 array('class' => 'filter-item show-updatesonly')
992 } else {
993 $filter[] = html_writer::tag('span', get_string('filterupdatesonlyactive', 'core_plugin'),
994 array('class' => 'filter-item active show-updatesonly'));
995 $somefilteractive = true;
998 if ($somefilteractive) {
999 $filter[] = html_writer::link($this->page->url, get_string('filterall', 'core_plugin'), array('class' => 'filter-item show-all'));
1002 $output = $this->output->box(implode(html_writer::tag('span', ' ', array('class' => 'separator')), $info), '', 'plugins-overview-panel');
1004 if (!empty($filter)) {
1005 $output .= $this->output->box(implode(html_writer::tag('span', ' ', array('class' => 'separator')), $filter), '', 'plugins-overview-filter');
1008 return $output;
1012 * Displays all known plugins and links to manage them
1014 * This default implementation renders all plugins into one big table.
1016 * @param plugin_manager $pluginman provides information about the plugins.
1017 * @param array $options filtering options
1018 * @return string HTML code
1020 public function plugins_control_panel(plugin_manager $pluginman, array $options = array()) {
1021 global $CFG;
1023 $plugininfo = $pluginman->get_plugins();
1025 // Filter the list of plugins according the options.
1026 if (!empty($options['updatesonly'])) {
1027 $updateable = array();
1028 foreach ($plugininfo as $plugintype => $pluginnames) {
1029 foreach ($pluginnames as $pluginname => $pluginfo) {
1030 if (!empty($pluginfo->availableupdates)) {
1031 foreach ($pluginfo->availableupdates as $pluginavailableupdate) {
1032 if ($pluginavailableupdate->version > $pluginfo->versiondisk) {
1033 $updateable[$plugintype][$pluginname] = $pluginfo;
1039 $plugininfo = $updateable;
1042 if (!empty($options['contribonly'])) {
1043 $contribs = array();
1044 foreach ($plugininfo as $plugintype => $pluginnames) {
1045 foreach ($pluginnames as $pluginname => $pluginfo) {
1046 if (!$pluginfo->is_standard()) {
1047 $contribs[$plugintype][$pluginname] = $pluginfo;
1051 $plugininfo = $contribs;
1054 if (empty($plugininfo)) {
1055 return '';
1058 $table = new html_table();
1059 $table->id = 'plugins-control-panel';
1060 $table->head = array(
1061 get_string('displayname', 'core_plugin'),
1062 get_string('source', 'core_plugin'),
1063 get_string('version', 'core_plugin'),
1064 get_string('availability', 'core_plugin'),
1065 get_string('actions', 'core_plugin'),
1066 get_string('notes','core_plugin'),
1068 $table->colclasses = array(
1069 'pluginname', 'source', 'version', 'availability', 'actions', 'notes'
1072 foreach ($plugininfo as $type => $plugins) {
1074 $header = new html_table_cell($pluginman->plugintype_name_plural($type));
1075 $header->header = true;
1076 $header->colspan = count($table->head);
1077 $header = new html_table_row(array($header));
1078 $header->attributes['class'] = 'plugintypeheader type-' . $type;
1079 $table->data[] = $header;
1081 if (empty($plugins)) {
1082 $msg = new html_table_cell(get_string('noneinstalled', 'core_plugin'));
1083 $msg->colspan = count($table->head);
1084 $row = new html_table_row(array($msg));
1085 $row->attributes['class'] .= 'msg msg-noneinstalled';
1086 $table->data[] = $row;
1087 continue;
1090 foreach ($plugins as $name => $plugin) {
1091 $row = new html_table_row();
1092 $row->attributes['class'] = 'type-' . $plugin->type . ' name-' . $plugin->type . '_' . $plugin->name;
1094 if ($this->page->theme->resolve_image_location('icon', $plugin->type . '_' . $plugin->name)) {
1095 $icon = $this->output->pix_icon('icon', '', $plugin->type . '_' . $plugin->name, array('class' => 'icon pluginicon'));
1096 } else {
1097 $icon = $this->output->pix_icon('spacer', '', 'moodle', array('class' => 'icon pluginicon noicon'));
1099 if ($plugin->get_status() === plugin_manager::PLUGIN_STATUS_MISSING) {
1100 $msg = html_writer::tag('span', get_string('status_missing', 'core_plugin'), array('class' => 'notifyproblem'));
1101 $row->attributes['class'] .= ' missingfromdisk';
1102 } else {
1103 $msg = '';
1105 $pluginname = html_writer::tag('div', $icon . '' . $plugin->displayname . ' ' . $msg, array('class' => 'displayname')).
1106 html_writer::tag('div', $plugin->component, array('class' => 'componentname'));
1107 $pluginname = new html_table_cell($pluginname);
1109 if ($plugin->is_standard()) {
1110 $row->attributes['class'] .= ' standard';
1111 $source = new html_table_cell(get_string('sourcestd', 'core_plugin'));
1112 } else {
1113 $row->attributes['class'] .= ' extension';
1114 $source = new html_table_cell(get_string('sourceext', 'core_plugin'));
1117 $version = new html_table_cell($plugin->versiondb);
1119 $isenabled = $plugin->is_enabled();
1120 if (is_null($isenabled)) {
1121 $availability = new html_table_cell('');
1122 } else if ($isenabled) {
1123 $row->attributes['class'] .= ' enabled';
1124 $availability = new html_table_cell(get_string('pluginenabled', 'core_plugin'));
1125 } else {
1126 $row->attributes['class'] .= ' disabled';
1127 $availability = new html_table_cell(get_string('plugindisabled', 'core_plugin'));
1130 $actions = array();
1132 $settingsurl = $plugin->get_settings_url();
1133 if (!is_null($settingsurl)) {
1134 $actions[] = html_writer::link($settingsurl, get_string('settings', 'core_plugin'), array('class' => 'settings'));
1137 $uninstallurl = $plugin->get_uninstall_url();
1138 if (!is_null($uninstallurl)) {
1139 $actions[] = html_writer::link($uninstallurl, get_string('uninstall', 'core_plugin'), array('class' => 'uninstall'));
1142 $actions = new html_table_cell(implode(html_writer::tag('span', ' ', array('class' => 'separator')), $actions));
1144 $requriedby = $pluginman->other_plugins_that_require($plugin->component);
1145 if ($requriedby) {
1146 $requiredby = html_writer::tag('div', get_string('requiredby', 'core_plugin', implode(', ', $requriedby)),
1147 array('class' => 'requiredby'));
1148 } else {
1149 $requiredby = '';
1152 $updateinfo = '';
1153 if (empty($CFG->disableupdatenotifications) and is_array($plugin->available_updates())) {
1154 foreach ($plugin->available_updates() as $availableupdate) {
1155 $updateinfo .= $this->plugin_available_update_info($availableupdate);
1159 $notes = new html_table_cell($requiredby.$updateinfo);
1161 $row->cells = array(
1162 $pluginname, $source, $version, $availability, $actions, $notes
1164 $table->data[] = $row;
1168 return html_writer::table($table);
1172 * Helper method to render the information about the available plugin update
1174 * The passed objects always provides at least the 'version' property containing
1175 * the (higher) version of the plugin available.
1177 * @param available_update_info $updateinfo information about the available update for the plugin
1179 protected function plugin_available_update_info(available_update_info $updateinfo) {
1181 $boxclasses = 'pluginupdateinfo';
1182 $info = array();
1184 if (isset($updateinfo->release)) {
1185 $info[] = html_writer::tag('span', get_string('updateavailable_release', 'core_plugin', $updateinfo->release),
1186 array('class' => 'info release'));
1189 if (isset($updateinfo->maturity)) {
1190 $info[] = html_writer::tag('span', get_string('maturity'.$updateinfo->maturity, 'core_admin'),
1191 array('class' => 'info maturity'));
1192 $boxclasses .= ' maturity'.$updateinfo->maturity;
1195 if (isset($updateinfo->download)) {
1196 $info[] = html_writer::link($updateinfo->download, get_string('download'), array('class' => 'info download'));
1199 if (isset($updateinfo->url)) {
1200 $info[] = html_writer::link($updateinfo->url, get_string('updateavailable_moreinfo', 'core_plugin'),
1201 array('class' => 'info more'));
1204 $box = $this->output->box_start($boxclasses);
1205 $box .= html_writer::tag('div', get_string('updateavailable', 'core_plugin', $updateinfo->version), array('class' => 'version'));
1206 $box .= $this->output->box(implode(html_writer::tag('span', ' ', array('class' => 'separator')), $info), '');
1208 $deployer = available_update_deployer::instance();
1209 if ($deployer->initialized()) {
1210 $impediments = $deployer->deployment_impediments($updateinfo);
1211 if (empty($impediments)) {
1212 $widget = $deployer->make_confirm_widget($updateinfo);
1213 $box .= $this->output->render($widget);
1214 } else {
1215 if (isset($impediments['notwritable'])) {
1216 $box .= $this->output->help_icon('notwritable', 'core_plugin', get_string('notwritable', 'core_plugin'));
1218 if (isset($impediments['notdownloadable'])) {
1219 $box .= $this->output->help_icon('notdownloadable', 'core_plugin', get_string('notdownloadable', 'core_plugin'));
1224 $box .= $this->output->box_end();
1226 return $box;
1230 * This function will render one beautiful table with all the environmental
1231 * configuration and how it suits Moodle needs.
1233 * @param boolean $result final result of the check (true/false)
1234 * @param array $environment_results array of results gathered
1235 * @return string HTML to output.
1237 public function environment_check_table($result, $environment_results) {
1238 global $CFG;
1240 // Table headers
1241 $servertable = new html_table();//table for server checks
1242 $servertable->head = array(
1243 get_string('name'),
1244 get_string('info'),
1245 get_string('report'),
1246 get_string('status'),
1248 $servertable->colclasses = array('centeralign name', 'centeralign status', 'leftalign report', 'centeralign info');
1249 $servertable->attributes['class'] = 'admintable environmenttable generaltable';
1250 $servertable->id = 'serverstatus';
1252 $serverdata = array('ok'=>array(), 'warn'=>array(), 'error'=>array());
1254 $othertable = new html_table();//table for custom checks
1255 $othertable->head = array(
1256 get_string('info'),
1257 get_string('report'),
1258 get_string('status'),
1260 $othertable->colclasses = array('aligncenter info', 'alignleft report', 'aligncenter status');
1261 $othertable->attributes['class'] = 'admintable environmenttable generaltable';
1262 $othertable->id = 'otherserverstatus';
1264 $otherdata = array('ok'=>array(), 'warn'=>array(), 'error'=>array());
1266 // Iterate over each environment_result
1267 $continue = true;
1268 foreach ($environment_results as $environment_result) {
1269 $errorline = false;
1270 $warningline = false;
1271 $stringtouse = '';
1272 if ($continue) {
1273 $type = $environment_result->getPart();
1274 $info = $environment_result->getInfo();
1275 $status = $environment_result->getStatus();
1276 $error_code = $environment_result->getErrorCode();
1277 // Process Report field
1278 $rec = new stdClass();
1279 // Something has gone wrong at parsing time
1280 if ($error_code) {
1281 $stringtouse = 'environmentxmlerror';
1282 $rec->error_code = $error_code;
1283 $status = get_string('error');
1284 $errorline = true;
1285 $continue = false;
1288 if ($continue) {
1289 if ($rec->needed = $environment_result->getNeededVersion()) {
1290 // We are comparing versions
1291 $rec->current = $environment_result->getCurrentVersion();
1292 if ($environment_result->getLevel() == 'required') {
1293 $stringtouse = 'environmentrequireversion';
1294 } else {
1295 $stringtouse = 'environmentrecommendversion';
1298 } else if ($environment_result->getPart() == 'custom_check') {
1299 // We are checking installed & enabled things
1300 if ($environment_result->getLevel() == 'required') {
1301 $stringtouse = 'environmentrequirecustomcheck';
1302 } else {
1303 $stringtouse = 'environmentrecommendcustomcheck';
1306 } else if ($environment_result->getPart() == 'php_setting') {
1307 if ($status) {
1308 $stringtouse = 'environmentsettingok';
1309 } else if ($environment_result->getLevel() == 'required') {
1310 $stringtouse = 'environmentmustfixsetting';
1311 } else {
1312 $stringtouse = 'environmentshouldfixsetting';
1315 } else {
1316 if ($environment_result->getLevel() == 'required') {
1317 $stringtouse = 'environmentrequireinstall';
1318 } else {
1319 $stringtouse = 'environmentrecommendinstall';
1323 // Calculate the status value
1324 if ($environment_result->getBypassStr() != '') { //Handle bypassed result (warning)
1325 $status = get_string('bypassed');
1326 $warningline = true;
1327 } else if ($environment_result->getRestrictStr() != '') { //Handle restricted result (error)
1328 $status = get_string('restricted');
1329 $errorline = true;
1330 } else {
1331 if ($status) { //Handle ok result (ok)
1332 $status = get_string('ok');
1333 } else {
1334 if ($environment_result->getLevel() == 'optional') {//Handle check result (warning)
1335 $status = get_string('check');
1336 $warningline = true;
1337 } else { //Handle error result (error)
1338 $status = get_string('check');
1339 $errorline = true;
1345 // Build the text
1346 $linkparts = array();
1347 $linkparts[] = 'admin/environment';
1348 $linkparts[] = $type;
1349 if (!empty($info)){
1350 $linkparts[] = $info;
1352 if (empty($CFG->docroot)) {
1353 $report = get_string($stringtouse, 'admin', $rec);
1354 } else {
1355 $report = $this->doc_link(join($linkparts, '/'), get_string($stringtouse, 'admin', $rec));
1358 // Format error or warning line
1359 if ($errorline || $warningline) {
1360 $messagetype = $errorline? 'error':'warn';
1361 } else {
1362 $messagetype = 'ok';
1364 $status = '<span class="'.$messagetype.'">'.$status.'</span>';
1365 // Here we'll store all the feedback found
1366 $feedbacktext = '';
1367 // Append the feedback if there is some
1368 $feedbacktext .= $environment_result->strToReport($environment_result->getFeedbackStr(), $messagetype);
1369 //Append the bypass if there is some
1370 $feedbacktext .= $environment_result->strToReport($environment_result->getBypassStr(), 'warn');
1371 //Append the restrict if there is some
1372 $feedbacktext .= $environment_result->strToReport($environment_result->getRestrictStr(), 'error');
1374 $report .= $feedbacktext;
1376 // Add the row to the table
1377 if ($environment_result->getPart() == 'custom_check'){
1378 $otherdata[$messagetype][] = array ($info, $report, $status);
1379 } else {
1380 $serverdata[$messagetype][] = array ($type, $info, $report, $status);
1385 //put errors first in
1386 $servertable->data = array_merge($serverdata['error'], $serverdata['warn'], $serverdata['ok']);
1387 $othertable->data = array_merge($otherdata['error'], $otherdata['warn'], $otherdata['ok']);
1389 // Print table
1390 $output = '';
1391 $output .= $this->heading(get_string('serverchecks', 'admin'));
1392 $output .= html_writer::table($servertable);
1393 if (count($othertable->data)){
1394 $output .= $this->heading(get_string('customcheck', 'admin'));
1395 $output .= html_writer::table($othertable);
1398 // Finally, if any error has happened, print the summary box
1399 if (!$result) {
1400 $output .= $this->box(get_string('environmenterrortodo', 'admin'), 'environmentbox errorbox');
1403 return $output;