2 // This file is part of Moodle - http://moodle.org/
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.
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/>.
18 * Renderer for core_admin subsystem
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();
30 * Standard HTML output renderer for core_admin subsystem
32 class core_admin_renderer
extends plugin_renderer_base
{
35 * Display the 'Do you acknowledge the terms of the GPL' page. The first page
37 * @return string HTML to output.
39 public function install_licence_page() {
43 $copyrightnotice = text_to_html(get_string('gpl3'));
44 $copyrightnotice = str_replace('target="_blank"', 'onclick="this.target=\'_blank\'"', $copyrightnotice); // extremely ugly validation hack
46 $continue = new single_button(new moodle_url('/admin/index.php', array('lang'=>$CFG->lang
, 'agreelicense'=>1)), get_string('continue'), 'get');
48 $output .= $this->header();
49 $output .= $this->heading('<a href="http://moodle.org">Moodle</a> - Modular Object-Oriented Dynamic Learning Environment');
50 $output .= $this->heading(get_string('copyrightnotice'));
51 $output .= $this->box($copyrightnotice, 'copyrightnotice');
52 $output .= html_writer
::empty_tag('br');
53 $output .= $this->confirm(get_string('doyouagree'), $continue, "http://docs.moodle.org/dev/License");
54 $output .= $this->footer();
60 * Display page explaining proper upgrade process,
61 * there can not be any PHP file leftovers...
63 * @return string HTML to output.
65 public function upgrade_stale_php_files_page() {
67 $output .= $this->header();
68 $output .= $this->heading(get_string('upgradestalefiles', 'admin'));
69 $output .= $this->box_start('generalbox', 'notice');
70 $output .= format_text(get_string('upgradestalefilesinfo', 'admin', get_docs_url('Upgrading')), FORMAT_MARKDOWN
);
71 $output .= html_writer
::empty_tag('br');
72 $output .= html_writer
::tag('div', $this->single_button($this->page
->url
, get_string('reload'), 'get'), array('class' => 'buttons'));
73 $output .= $this->box_end();
74 $output .= $this->footer();
80 * Display the 'environment check' page that is displayed during install.
81 * @param int $maturity
82 * @param boolean $envstatus final result of the check (true/false)
83 * @param array $environment_results array of results gathered
84 * @param string $release moodle release
85 * @return string HTML to output.
87 public function install_environment_page($maturity, $envstatus, $environment_results, $release) {
91 $output .= $this->header();
92 $output .= $this->maturity_warning($maturity);
93 $output .= $this->heading("Moodle $release");
94 $output .= $this->release_notes_link();
96 $output .= $this->environment_check_table($envstatus, $environment_results);
99 $output .= $this->upgrade_reload(new moodle_url('/admin/index.php', array('agreelicense' => 1, 'lang' => $CFG->lang
)));
101 $output .= $this->notification(get_string('environmentok', 'admin'), 'notifysuccess');
102 $output .= $this->continue_button(new moodle_url('/admin/index.php', array('agreelicense'=>1, 'confirmrelease'=>1, 'lang'=>$CFG->lang
)));
105 $output .= $this->footer();
110 * Displays the list of plugins with unsatisfied dependencies
112 * @param double|string|int $version Moodle on-disk version
113 * @param array $failed list of plugins with unsatisfied dependecies
114 * @param moodle_url $reloadurl URL of the page to recheck the dependencies
115 * @return string HTML
117 public function unsatisfied_dependencies_page($version, array $failed, moodle_url
$reloadurl) {
120 $output .= $this->header();
121 $output .= $this->heading(get_string('pluginscheck', 'admin'));
122 $output .= $this->warning(get_string('pluginscheckfailed', 'admin', array('pluginslist' => implode(', ', array_unique($failed)))));
123 $output .= $this->plugins_check_table(core_plugin_manager
::instance(), $version, array('xdep' => true));
124 $output .= $this->warning(get_string('pluginschecktodo', 'admin'));
125 $output .= $this->continue_button($reloadurl);
127 $output .= $this->footer();
133 * Display the 'You are about to upgrade Moodle' page. The first page
135 * @param string $strnewversion
136 * @param int $maturity
137 * @param string $testsite
138 * @return string HTML to output.
140 public function upgrade_confirm_page($strnewversion, $maturity, $testsite) {
143 $continueurl = new moodle_url('/admin/index.php', array('confirmupgrade' => 1, 'cache' => 0));
144 $continue = new single_button($continueurl, get_string('continue'), 'get');
145 $cancelurl = new moodle_url('/admin/index.php');
147 $output .= $this->header();
148 $output .= $this->maturity_warning($maturity);
149 $output .= $this->test_site_warning($testsite);
150 $output .= $this->confirm(get_string('upgradesure', 'admin', $strnewversion), $continue, $cancelurl);
151 $output .= $this->footer();
157 * Display the environment page during the upgrade process.
158 * @param string $release
159 * @param boolean $envstatus final result of env check (true/false)
160 * @param array $environment_results array of results gathered
161 * @return string HTML to output.
163 public function upgrade_environment_page($release, $envstatus, $environment_results) {
167 $output .= $this->header();
168 $output .= $this->heading("Moodle $release");
169 $output .= $this->release_notes_link();
170 $output .= $this->environment_check_table($envstatus, $environment_results);
173 $output .= $this->upgrade_reload(new moodle_url('/admin/index.php'), array('confirmupgrade' => 1, 'cache' => 0));
176 $output .= $this->notification(get_string('environmentok', 'admin'), 'notifysuccess');
178 if (empty($CFG->skiplangupgrade
) and current_language() !== 'en') {
179 $output .= $this->box(get_string('langpackwillbeupdated', 'admin'), 'generalbox', 'notice');
182 $output .= $this->continue_button(new moodle_url('/admin/index.php', array('confirmupgrade' => 1, 'confirmrelease' => 1, 'cache' => 0)));
185 $output .= $this->footer();
191 * Display the upgrade page that lists all the plugins that require attention.
192 * @param core_plugin_manager $pluginman provides information about the plugins.
193 * @param \core\update\checker $checker provides information about available updates.
194 * @param int $version the version of the Moodle code from version.php.
195 * @param bool $showallplugins
196 * @param moodle_url $reloadurl
197 * @param moodle_url $continueurl
198 * @return string HTML to output.
200 public function upgrade_plugin_check_page(core_plugin_manager
$pluginman, \core\update\checker
$checker,
201 $version, $showallplugins, $reloadurl, $continueurl) {
206 $output .= $this->header();
207 $output .= $this->box_start('generalbox');
208 $output .= $this->container_start('generalbox', 'notice');
209 $output .= html_writer
::tag('p', get_string('pluginchecknotice', 'core_plugin'));
210 if (empty($CFG->disableupdatenotifications
)) {
211 $output .= $this->container_start('checkforupdates');
212 $output .= $this->single_button(new moodle_url($reloadurl, array('fetchupdates' => 1)), get_string('checkforupdates', 'core_plugin'));
213 if ($timefetched = $checker->get_last_timefetched()) {
214 $output .= $this->container(get_string('checkforupdateslast', 'core_plugin',
215 userdate($timefetched, get_string('strftimedatetime', 'core_langconfig'))));
217 $output .= $this->container_end();
219 $output .= $this->container_end();
221 $output .= $this->plugins_check_table($pluginman, $version, array('full' => $showallplugins));
222 $output .= $this->box_end();
223 $output .= $this->upgrade_reload($reloadurl);
225 if ($pluginman->some_plugins_updatable()) {
226 $output .= $this->container_start('upgradepluginsinfo');
227 $output .= $this->help_icon('upgradepluginsinfo', 'core_admin', get_string('upgradepluginsfirst', 'core_admin'));
228 $output .= $this->container_end();
231 $button = new single_button($continueurl, get_string('upgradestart', 'admin'), 'get');
232 $button->class = 'continuebutton';
233 $output .= $this->render($button);
234 $output .= $this->footer();
240 * Prints a page with a summary of plugin deployment to be confirmed.
242 * @param \core\update\deployer $deployer
243 * @param array $data deployer's data package as returned by {@link \core\update\deployer::submitted_data()}
246 public function upgrade_plugin_confirm_deploy_page(\core\update\deployer
$deployer, array $data) {
248 if (!$deployer->initialized()) {
249 throw new coding_exception('Unable to render a page for non-initialized deployer.');
252 if (empty($data['updateinfo'])) {
253 throw new coding_exception('Missing required data component.');
256 $updateinfo = $data['updateinfo'];
259 $output .= $this->header();
260 $output .= $this->container_start('generalbox updateplugin', 'notice');
263 if (get_string_manager()->string_exists('pluginname', $updateinfo->component
)) {
264 $a->name
= get_string('pluginname', $updateinfo->component
);
266 $a->name
= $updateinfo->component
;
269 if (isset($updateinfo->release
)) {
270 $a->version
= $updateinfo->release
. ' (' . $updateinfo->version
. ')';
272 $a->version
= $updateinfo->version
;
274 $a->url
= $updateinfo->download
;
276 $output .= $this->output
->heading(get_string('updatepluginconfirm', 'core_plugin'));
277 $output .= $this->output
->container(format_text(get_string('updatepluginconfirminfo', 'core_plugin', $a)), 'updatepluginconfirminfo');
278 $output .= $this->output
->container(get_string('updatepluginconfirmwarning', 'core_plugin', 'updatepluginconfirmwarning'));
280 if ($repotype = $deployer->plugin_external_source($data['updateinfo'])) {
281 $output .= $this->output
->container(get_string('updatepluginconfirmexternal', 'core_plugin', $repotype), 'updatepluginconfirmexternal');
284 $widget = $deployer->make_execution_widget($data['updateinfo'], $data['returnurl']);
285 $output .= $this->output
->render($widget);
287 $output .= $this->output
->single_button($data['callerurl'], get_string('cancel', 'core'), 'get');
289 $output .= $this->container_end();
290 $output .= $this->footer();
296 * Display the admin notifications page.
297 * @param int $maturity
298 * @param bool $insecuredataroot warn dataroot is invalid
299 * @param bool $errorsdisplayed warn invalid dispaly error setting
300 * @param bool $cronoverdue warn cron not running
301 * @param bool $dbproblems warn db has problems
302 * @param bool $maintenancemode warn in maintenance mode
303 * @param bool $buggyiconvnomb warn iconv problems
304 * @param array|null $availableupdates array of \core\update\info objects or null
305 * @param int|null $availableupdatesfetch timestamp of the most recent updates fetch or null (unknown)
306 * @param string[] $cachewarnings An array containing warnings from the Cache API.
308 * @return string HTML to output.
310 public function admin_notifications_page($maturity, $insecuredataroot, $errorsdisplayed,
311 $cronoverdue, $dbproblems, $maintenancemode, $availableupdates, $availableupdatesfetch,
312 $buggyiconvnomb, $registered, array $cachewarnings = array()) {
316 $output .= $this->header();
317 $output .= $this->maturity_info($maturity);
318 $output .= empty($CFG->disableupdatenotifications
) ?
$this->available_updates($availableupdates, $availableupdatesfetch) : '';
319 $output .= $this->insecure_dataroot_warning($insecuredataroot);
320 $output .= $this->display_errors_warning($errorsdisplayed);
321 $output .= $this->buggy_iconv_warning($buggyiconvnomb);
322 $output .= $this->cron_overdue_warning($cronoverdue);
323 $output .= $this->db_problems($dbproblems);
324 $output .= $this->maintenance_mode_warning($maintenancemode);
325 $output .= $this->cache_warnings($cachewarnings);
326 $output .= $this->registration_warning($registered);
328 //////////////////////////////////////////////////////////////////////////////////////////////////
329 //// IT IS ILLEGAL AND A VIOLATION OF THE GPL TO HIDE, REMOVE OR MODIFY THIS COPYRIGHT NOTICE ///
330 $output .= $this->moodle_copyright();
331 //////////////////////////////////////////////////////////////////////////////////////////////////
333 $output .= $this->footer();
339 * Display the plugin management page (admin/plugins.php).
341 * The filtering options array may contain following items:
342 * bool contribonly - show only contributed extensions
343 * bool updatesonly - show only plugins with an available update
345 * @param core_plugin_manager $pluginman
346 * @param \core\update\checker $checker
347 * @param array $options filtering options
348 * @return string HTML to output.
350 public function plugin_management_page(core_plugin_manager
$pluginman, \core\update\checker
$checker, array $options = array()) {
355 $output .= $this->header();
356 $output .= $this->heading(get_string('pluginsoverview', 'core_admin'));
357 $output .= $this->plugins_overview_panel($pluginman, $options);
359 if (empty($CFG->disableupdatenotifications
)) {
360 $output .= $this->container_start('checkforupdates');
361 $output .= $this->single_button(
362 new moodle_url($this->page
->url
, array_merge($options, array('fetchremote' => 1))),
363 get_string('checkforupdates', 'core_plugin')
365 if ($timefetched = $checker->get_last_timefetched()) {
366 $output .= $this->container(get_string('checkforupdateslast', 'core_plugin',
367 userdate($timefetched, get_string('strftimedatetime', 'core_langconfig'))));
369 $output .= $this->container_end();
372 $output .= $this->box($this->plugins_control_panel($pluginman, $options), 'generalbox');
373 $output .= $this->footer();
379 * Display a page to confirm the plugin uninstallation.
381 * @param core_plugin_manager $pluginman
382 * @param \core\plugininfo\base $pluginfo
383 * @param moodle_url $continueurl URL to continue after confirmation
384 * @param moodle_url $cancelurl URL to to go if cancelled
387 public function plugin_uninstall_confirm_page(core_plugin_manager
$pluginman, \core\plugininfo\base
$pluginfo, moodle_url
$continueurl, moodle_url
$cancelurl) {
390 $pluginname = $pluginman->plugin_name($pluginfo->component
);
392 $confirm = '<p>' . get_string('uninstallconfirm', 'core_plugin', array('name' => $pluginname)) . '</p>';
393 if ($extraconfirm = $pluginfo->get_uninstall_extra_warning()) {
394 $confirm .= $extraconfirm;
397 $output .= $this->output
->header();
398 $output .= $this->output
->heading(get_string('uninstalling', 'core_plugin', array('name' => $pluginname)));
399 $output .= $this->output
->confirm($confirm, $continueurl, $cancelurl);
400 $output .= $this->output
->footer();
406 * Display a page with results of plugin uninstallation and offer removal of plugin files.
408 * @param core_plugin_manager $pluginman
409 * @param \core\plugininfo\base $pluginfo
410 * @param progress_trace_buffer $progress
411 * @param moodle_url $continueurl URL to continue to remove the plugin folder
414 public function plugin_uninstall_results_removable_page(core_plugin_manager
$pluginman, \core\plugininfo\base
$pluginfo,
415 progress_trace_buffer
$progress, moodle_url
$continueurl) {
418 $pluginname = $pluginman->plugin_name($pluginfo->component
);
420 // Do not show navigation here, they must click one of the buttons.
421 $this->page
->set_pagelayout('maintenance');
422 $this->page
->set_cacheable(false);
424 $output .= $this->output
->header();
425 $output .= $this->output
->heading(get_string('uninstalling', 'core_plugin', array('name' => $pluginname)));
427 $output .= $this->output
->box($progress->get_buffer(), 'generalbox uninstallresultmessage');
429 $confirm = $this->output
->container(get_string('uninstalldeleteconfirm', 'core_plugin',
430 array('name' => $pluginname, 'rootdir' => $pluginfo->rootdir
)), 'uninstalldeleteconfirm');
432 if ($repotype = $pluginman->plugin_external_source($pluginfo->component
)) {
433 $confirm .= $this->output
->container(get_string('uninstalldeleteconfirmexternal', 'core_plugin', $repotype),
434 'uninstalldeleteconfirmexternal');
437 // After any uninstall we must execute full upgrade to finish the cleanup!
438 $output .= $this->output
->confirm($confirm, $continueurl, new moodle_url('/admin/index.php'));
439 $output .= $this->output
->footer();
445 * Display a page with results of plugin uninstallation and inform about the need to remove plugin files manually.
447 * @param core_plugin_manager $pluginman
448 * @param \core\plugininfo\base $pluginfo
449 * @param progress_trace_buffer $progress
452 public function plugin_uninstall_results_page(core_plugin_manager
$pluginman, \core\plugininfo\base
$pluginfo, progress_trace_buffer
$progress) {
455 $pluginname = $pluginfo->component
;
457 $output .= $this->output
->header();
458 $output .= $this->output
->heading(get_string('uninstalling', 'core_plugin', array('name' => $pluginname)));
460 $output .= $this->output
->box($progress->get_buffer(), 'generalbox uninstallresultmessage');
462 $output .= $this->output
->box(get_string('uninstalldelete', 'core_plugin',
463 array('name' => $pluginname, 'rootdir' => $pluginfo->rootdir
)), 'generalbox uninstalldelete');
464 $output .= $this->output
->continue_button(new moodle_url('/admin/index.php'));
465 $output .= $this->output
->footer();
471 * Display the plugin management page (admin/environment.php).
472 * @param array $versions
473 * @param string $version
474 * @param boolean $envstatus final result of env check (true/false)
475 * @param array $environment_results array of results gathered
476 * @return string HTML to output.
478 public function environment_check_page($versions, $version, $envstatus, $environment_results) {
480 $output .= $this->header();
482 // Print the component download link
483 $output .= html_writer
::tag('div', html_writer
::link(
484 new moodle_url('/admin/environment.php', array('action' => 'updatecomponent', 'sesskey' => sesskey())),
485 get_string('updatecomponent', 'admin')),
486 array('class' => 'reportlink'));
489 $output .= $this->heading(get_string('environment', 'admin'));
491 // Box with info and a menu to choose the version.
492 $output .= $this->box_start();
493 $output .= html_writer
::tag('div', get_string('adminhelpenvironment'));
494 $select = new single_select(new moodle_url('/admin/environment.php'), 'version', $versions, $version, null);
495 $select->label
= get_string('moodleversion');
496 $output .= $this->render($select);
497 $output .= $this->box_end();
500 $output .= $this->environment_check_table($envstatus, $environment_results);
502 $output .= $this->footer();
507 * Output a warning message, of the type that appears on the admin notifications page.
508 * @param string $message the message to display.
509 * @param string $type type class
510 * @return string HTML to output.
512 protected function warning($message, $type = 'warning') {
513 return $this->box($message, 'generalbox admin' . $type);
517 * Render an appropriate message if dataroot is insecure.
518 * @param bool $insecuredataroot
519 * @return string HTML to output.
521 protected function insecure_dataroot_warning($insecuredataroot) {
524 if ($insecuredataroot == INSECURE_DATAROOT_WARNING
) {
525 return $this->warning(get_string('datarootsecuritywarning', 'admin', $CFG->dataroot
));
527 } else if ($insecuredataroot == INSECURE_DATAROOT_ERROR
) {
528 return $this->warning(get_string('datarootsecurityerror', 'admin', $CFG->dataroot
), 'error');
536 * Render an appropriate message if dataroot is insecure.
537 * @param bool $errorsdisplayed
538 * @return string HTML to output.
540 protected function display_errors_warning($errorsdisplayed) {
541 if (!$errorsdisplayed) {
545 return $this->warning(get_string('displayerrorswarning', 'admin'));
549 * Render an appropriate message if iconv is buggy and mbstring missing.
550 * @param bool $buggyiconvnomb
551 * @return string HTML to output.
553 protected function buggy_iconv_warning($buggyiconvnomb) {
554 if (!$buggyiconvnomb) {
558 return $this->warning(get_string('warningiconvbuggy', 'admin'));
562 * Render an appropriate message if cron has not been run recently.
563 * @param bool $cronoverdue
564 * @return string HTML to output.
566 public function cron_overdue_warning($cronoverdue) {
572 if (empty($CFG->cronclionly
)) {
573 $url = new moodle_url('/admin/cron.php');
574 if (!empty($CFG->cronremotepassword
)) {
575 $url = new moodle_url('/admin/cron.php', array('password' => $CFG->cronremotepassword
));
578 return $this->warning(get_string('cronwarning', 'admin', $url->out()) . ' ' .
579 $this->help_icon('cron', 'admin'));
582 // $CFG->cronclionly is not empty: cron can run only from CLI.
583 return $this->warning(get_string('cronwarningcli', 'admin') . ' ' .
584 $this->help_icon('cron', 'admin'));
588 * Render an appropriate message if there are any problems with the DB set-up.
589 * @param bool $dbproblems
590 * @return string HTML to output.
592 public function db_problems($dbproblems) {
597 return $this->warning($dbproblems);
601 * Renders cache warnings if there are any.
603 * @param string[] $cachewarnings
606 public function cache_warnings(array $cachewarnings) {
607 if (!count($cachewarnings)) {
610 return join("\n", array_map(array($this, 'warning'), $cachewarnings));
614 * Render an appropriate message if the site in in maintenance mode.
615 * @param bool $maintenancemode
616 * @return string HTML to output.
618 public function maintenance_mode_warning($maintenancemode) {
619 if (!$maintenancemode) {
623 $url = new moodle_url('/admin/settings.php', array('section' => 'maintenancemode'));
624 $url = $url->out(); // get_string() does not support objects in params
626 return $this->warning(get_string('sitemaintenancewarning2', 'admin', $url));
630 * Display a warning about installing development code if necesary.
631 * @param int $maturity
632 * @return string HTML to output.
634 protected function maturity_warning($maturity) {
635 if ($maturity == MATURITY_STABLE
) {
636 return ''; // No worries.
639 $maturitylevel = get_string('maturity' . $maturity, 'admin');
640 return $this->warning(
641 $this->container(get_string('maturitycorewarning', 'admin', $maturitylevel)) .
642 $this->container($this->doc_link('admin/versions', get_string('morehelp'))),
647 * If necessary, displays a warning about upgrading a test site.
649 * @param string $testsite
650 * @return string HTML
652 protected function test_site_warning($testsite) {
658 $warning = (get_string('testsiteupgradewarning', 'admin', $testsite));
659 return $this->warning($warning, 'error');
663 * Output the copyright notice.
664 * @return string HTML to output.
666 protected function moodle_copyright() {
669 //////////////////////////////////////////////////////////////////////////////////////////////////
670 //// IT IS ILLEGAL AND A VIOLATION OF THE GPL TO HIDE, REMOVE OR MODIFY THIS COPYRIGHT NOTICE ///
671 $copyrighttext = '<a href="http://moodle.org/">Moodle</a> '.
672 '<a href="http://docs.moodle.org/dev/Releases" title="'.$CFG->version
.'">'.$CFG->release
.'</a><br />'.
673 'Copyright © 1999 onwards, Martin Dougiamas<br />'.
674 'and <a href="http://moodle.org/dev">many other contributors</a>.<br />'.
675 '<a href="http://docs.moodle.org/dev/License">GNU Public License</a>';
676 //////////////////////////////////////////////////////////////////////////////////////////////////
678 return $this->box($copyrighttext, 'copyright');
682 * Display a warning about installing development code if necesary.
683 * @param int $maturity
684 * @return string HTML to output.
686 protected function maturity_info($maturity) {
687 if ($maturity == MATURITY_STABLE
) {
688 return ''; // No worries.
693 if ($maturity == MATURITY_ALPHA
) {
697 $maturitylevel = get_string('maturity' . $maturity, 'admin');
698 $warningtext = get_string('maturitycoreinfo', 'admin', $maturitylevel);
699 $warningtext .= ' ' . $this->doc_link('admin/versions', get_string('morehelp'));
700 return $this->warning($warningtext, $level);
704 * Displays the info about available Moodle core and plugin updates
706 * The structure of the $updates param has changed since 2.4. It contains not only updates
707 * for the core itself, but also for all other installed plugins.
709 * @param array|null $updates array of (string)component => array of \core\update\info objects or null
710 * @param int|null $fetch timestamp of the most recent updates fetch or null (unknown)
713 protected function available_updates($updates, $fetch) {
716 $someupdateavailable = false;
717 if (is_array($updates)) {
718 if (is_array($updates['core'])) {
719 $someupdateavailable = true;
720 $updateinfo .= $this->heading(get_string('updateavailable', 'core_admin'), 3);
721 foreach ($updates['core'] as $update) {
722 $updateinfo .= $this->moodle_available_update_info($update);
724 $updateinfo .= html_writer
::tag('p', get_string('updateavailablerecommendation', 'core_admin'),
725 array('class' => 'updateavailablerecommendation'));
727 unset($updates['core']);
728 // If something has left in the $updates array now, it is updates for plugins.
729 if (!empty($updates)) {
730 $someupdateavailable = true;
731 $updateinfo .= $this->heading(get_string('updateavailableforplugin', 'core_admin'), 3);
732 $pluginsoverviewurl = new moodle_url('/admin/plugins.php', array('updatesonly' => 1));
733 $updateinfo .= $this->container(get_string('pluginsoverviewsee', 'core_admin',
734 array('url' => $pluginsoverviewurl->out())));
738 if (!$someupdateavailable) {
740 if ($fetch and ($fetch <= $now) and ($now - $fetch < HOURSECS
)) {
741 $updateinfo .= $this->heading(get_string('updateavailablenot', 'core_admin'), 3);
745 $updateinfo .= $this->container_start('checkforupdates');
746 $fetchurl = new moodle_url('/admin/index.php', array('fetchupdates' => 1, 'sesskey' => sesskey(), 'cache' => 0));
747 $updateinfo .= $this->single_button($fetchurl, get_string('checkforupdates', 'core_plugin'));
749 $updateinfo .= $this->container(get_string('checkforupdateslast', 'core_plugin',
750 userdate($fetch, get_string('strftimedatetime', 'core_langconfig'))));
752 $updateinfo .= $this->container_end();
754 return $this->warning($updateinfo);
758 * Display a warning about not being registered on Moodle.org if necesary.
760 * @param boolean $registered true if the site is registered on Moodle.org
761 * @return string HTML to output.
763 protected function registration_warning($registered) {
767 $registerbutton = $this->single_button(new moodle_url('/admin/registration/register.php',
768 array('huburl' => HUB_MOODLEORGHUBURL
, 'hubname' => 'Moodle.org')),
769 get_string('register', 'admin'));
771 return $this->warning( get_string('registrationwarning', 'admin')
772 . ' ' . $this->help_icon('registration', 'admin') . $registerbutton );
779 * Helper method to render the information about the available Moodle update
781 * @param \core\update\info $updateinfo information about the available Moodle core update
783 protected function moodle_available_update_info(\core\update\info
$updateinfo) {
785 $boxclasses = 'moodleupdateinfo';
788 if (isset($updateinfo->release
)) {
789 $info[] = html_writer
::tag('span', get_string('updateavailable_release', 'core_admin', $updateinfo->release
),
790 array('class' => 'info release'));
793 if (isset($updateinfo->version
)) {
794 $info[] = html_writer
::tag('span', get_string('updateavailable_version', 'core_admin', $updateinfo->version
),
795 array('class' => 'info version'));
798 if (isset($updateinfo->maturity
)) {
799 $info[] = html_writer
::tag('span', get_string('maturity'.$updateinfo->maturity
, 'core_admin'),
800 array('class' => 'info maturity'));
801 $boxclasses .= ' maturity'.$updateinfo->maturity
;
804 if (isset($updateinfo->download
)) {
805 $info[] = html_writer
::link($updateinfo->download
, get_string('download'), array('class' => 'info download'));
808 if (isset($updateinfo->url
)) {
809 $info[] = html_writer
::link($updateinfo->url
, get_string('updateavailable_moreinfo', 'core_plugin'),
810 array('class' => 'info more'));
813 $box = $this->output
->box_start($boxclasses);
814 $box .= $this->output
->box(implode(html_writer
::tag('span', ' ', array('class' => 'separator')), $info), '');
815 $box .= $this->output
->box_end();
821 * Display a link to the release notes.
822 * @return string HTML to output.
824 protected function release_notes_link() {
825 $releasenoteslink = get_string('releasenoteslink', 'admin', 'http://docs.moodle.org/dev/Releases');
826 $releasenoteslink = str_replace('target="_blank"', 'onclick="this.target=\'_blank\'"', $releasenoteslink); // extremely ugly validation hack
827 return $this->box($releasenoteslink, 'generalbox releasenoteslink');
831 * Display the reload link that appears on several upgrade/install pages.
832 * @return string HTML to output.
834 function upgrade_reload($url) {
835 return html_writer
::empty_tag('br') .
836 html_writer
::tag('div',
837 html_writer
::link($url, $this->pix_icon('i/reload', '', '', array('class' => 'icon icon-pre')) .
838 get_string('reload'), array('title' => get_string('reload'))),
839 array('class' => 'continuebutton')) . html_writer
::empty_tag('br');
843 * Displays all known plugins and information about their installation or upgrade
845 * This default implementation renders all plugins into one big table. The rendering
847 * (bool)full = false: whether to display up-to-date plugins, too
848 * (bool)xdep = false: display the plugins with unsatisified dependecies only
850 * @param core_plugin_manager $pluginman provides information about the plugins.
851 * @param int $version the version of the Moodle code from version.php.
852 * @param array $options rendering options
853 * @return string HTML code
855 public function plugins_check_table(core_plugin_manager
$pluginman, $version, array $options = array()) {
858 $plugininfo = $pluginman->get_plugins();
860 if (empty($plugininfo)) {
864 $options['full'] = isset($options['full']) ?
(bool)$options['full'] : false;
865 $options['xdep'] = isset($options['xdep']) ?
(bool)$options['xdep'] : false;
867 $table = new html_table();
868 $table->id
= 'plugins-check';
869 $table->head
= array(
870 get_string('displayname', 'core_plugin'),
871 get_string('rootdir', 'core_plugin'),
872 get_string('source', 'core_plugin'),
873 get_string('versiondb', 'core_plugin'),
874 get_string('versiondisk', 'core_plugin'),
875 get_string('requires', 'core_plugin'),
876 get_string('status', 'core_plugin'),
878 $table->colclasses
= array(
879 'displayname', 'rootdir', 'source', 'versiondb', 'versiondisk', 'requires', 'status',
881 $table->data
= array();
883 $numofhighlighted = array(); // number of highlighted rows per this subsection
885 foreach ($plugininfo as $type => $plugins) {
887 $header = new html_table_cell($pluginman->plugintype_name_plural($type));
888 $header->header
= true;
889 $header->colspan
= count($table->head
);
890 $header = new html_table_row(array($header));
891 $header->attributes
['class'] = 'plugintypeheader type-' . $type;
893 $numofhighlighted[$type] = 0;
895 if (empty($plugins) and $options['full']) {
896 $msg = new html_table_cell(get_string('noneinstalled', 'core_plugin'));
897 $msg->colspan
= count($table->head
);
898 $row = new html_table_row(array($msg));
899 $row->attributes
['class'] .= 'msg msg-noneinstalled';
900 $table->data
[] = $header;
901 $table->data
[] = $row;
905 $plugintyperows = array();
907 foreach ($plugins as $name => $plugin) {
908 $row = new html_table_row();
909 $row->attributes
['class'] = 'type-' . $plugin->type
. ' name-' . $plugin->type
. '_' . $plugin->name
;
911 if ($this->page
->theme
->resolve_image_location('icon', $plugin->type
. '_' . $plugin->name
, null)) {
912 $icon = $this->output
->pix_icon('icon', '', $plugin->type
. '_' . $plugin->name
, array('class' => 'smallicon pluginicon'));
914 $icon = $this->output
->pix_icon('spacer', '', 'moodle', array('class' => 'smallicon pluginicon noicon'));
916 $displayname = $icon . ' ' . $plugin->displayname
;
917 $displayname = new html_table_cell($displayname);
919 $rootdir = new html_table_cell($plugin->get_dir());
921 if ($isstandard = $plugin->is_standard()) {
922 $row->attributes
['class'] .= ' standard';
923 $source = new html_table_cell(get_string('sourcestd', 'core_plugin'));
925 $row->attributes
['class'] .= ' extension';
926 $source = new html_table_cell(get_string('sourceext', 'core_plugin'));
929 $versiondb = new html_table_cell($plugin->versiondb
);
930 $versiondisk = new html_table_cell($plugin->versiondisk
);
932 $statuscode = $plugin->get_status();
933 $row->attributes
['class'] .= ' status-' . $statuscode;
934 $status = get_string('status_' . $statuscode, 'core_plugin');
936 $availableupdates = $plugin->available_updates();
937 if (!empty($availableupdates) and empty($CFG->disableupdatenotifications
)) {
938 foreach ($availableupdates as $availableupdate) {
939 $status .= $this->plugin_available_update_info($availableupdate);
943 $status = new html_table_cell($status);
945 $requires = new html_table_cell($this->required_column($plugin, $pluginman, $version));
947 $statusisboring = in_array($statuscode, array(
948 core_plugin_manager
::PLUGIN_STATUS_NODB
, core_plugin_manager
::PLUGIN_STATUS_UPTODATE
));
950 $coredependency = $plugin->is_core_dependency_satisfied($version);
951 $otherpluginsdependencies = $pluginman->are_dependencies_satisfied($plugin->get_other_required_plugins());
952 $dependenciesok = $coredependency && $otherpluginsdependencies;
954 if ($options['xdep']) {
955 // we want to see only plugins with failed dependencies
956 if ($dependenciesok) {
960 } else if ($statusisboring and $dependenciesok and empty($availableupdates)) {
961 // no change is going to happen to the plugin - display it only
962 // if the user wants to see the full list
963 if (empty($options['full'])) {
968 // ok, the plugin should be displayed
969 $numofhighlighted[$type]++
;
971 $row->cells
= array($displayname, $rootdir, $source,
972 $versiondb, $versiondisk, $requires, $status);
973 $plugintyperows[] = $row;
976 if (empty($numofhighlighted[$type]) and empty($options['full'])) {
980 $table->data
[] = $header;
981 $table->data
= array_merge($table->data
, $plugintyperows);
984 $sumofhighlighted = array_sum($numofhighlighted);
986 if ($options['xdep']) {
987 // we do not want to display no heading and links in this mode
990 } else if ($sumofhighlighted == 0) {
991 $out = $this->output
->container_start('nonehighlighted', 'plugins-check-info');
992 $out .= $this->output
->heading(get_string('nonehighlighted', 'core_plugin'));
993 if (empty($options['full'])) {
994 $out .= html_writer
::link(new moodle_url('/admin/index.php',
995 array('confirmupgrade' => 1, 'confirmrelease' => 1, 'showallplugins' => 1, 'cache' => 0)),
996 get_string('nonehighlightedinfo', 'core_plugin'));
998 $out .= $this->output
->container_end();
1001 $out = $this->output
->container_start('somehighlighted', 'plugins-check-info');
1002 $out .= $this->output
->heading(get_string('somehighlighted', 'core_plugin', $sumofhighlighted));
1003 if (empty($options['full'])) {
1004 $out .= html_writer
::link(new moodle_url('/admin/index.php',
1005 array('confirmupgrade' => 1, 'confirmrelease' => 1, 'showallplugins' => 1, 'cache' => 0)),
1006 get_string('somehighlightedinfo', 'core_plugin'));
1008 $out .= html_writer
::link(new moodle_url('/admin/index.php',
1009 array('confirmupgrade' => 1, 'confirmrelease' => 1, 'showallplugins' => 0, 'cache' => 0)),
1010 get_string('somehighlightedonly', 'core_plugin'));
1012 $out .= $this->output
->container_end();
1015 if ($sumofhighlighted > 0 or $options['full']) {
1016 $out .= html_writer
::table($table);
1023 * Formats the information that needs to go in the 'Requires' column.
1024 * @param \core\plugininfo\base $plugin the plugin we are rendering the row for.
1025 * @param core_plugin_manager $pluginman provides data on all the plugins.
1026 * @param string $version
1027 * @return string HTML code
1029 protected function required_column(\core\plugininfo\base
$plugin, core_plugin_manager
$pluginman, $version) {
1030 $requires = array();
1032 if (!empty($plugin->versionrequires
)) {
1033 if ($plugin->versionrequires
<= $version) {
1034 $class = 'requires-ok';
1036 $class = 'requires-failed';
1038 $requires[] = html_writer
::tag('li',
1039 get_string('moodleversion', 'core_plugin', $plugin->versionrequires
),
1040 array('class' => $class));
1043 foreach ($plugin->get_other_required_plugins() as $component => $requiredversion) {
1044 $otherplugin = $pluginman->get_plugin_info($component);
1047 if (is_null($otherplugin)) {
1048 // The required plugin is not installed.
1049 $class = 'requires-failed requires-missing';
1050 $installurl = new moodle_url('https://moodle.org/plugins/view.php', array('plugin' => $component));
1051 $uploadurl = new moodle_url('/admin/tool/installaddon/');
1052 $actions[] = html_writer
::link($installurl, get_string('dependencyinstall', 'core_plugin'));
1053 $actions[] = html_writer
::link($uploadurl, get_string('dependencyupload', 'core_plugin'));
1055 } else if ($requiredversion != ANY_VERSION
and $otherplugin->versiondisk
< $requiredversion) {
1056 // The required plugin is installed but needs to be updated.
1057 $class = 'requires-failed requires-outdated';
1058 if (!$otherplugin->is_standard()) {
1059 $updateurl = new moodle_url($this->page
->url
, array('sesskey' => sesskey(), 'fetchupdates' => 1));
1060 $actions[] = html_writer
::link($updateurl, get_string('checkforupdates', 'core_plugin'));
1064 // Already installed plugin with sufficient version.
1065 $class = 'requires-ok';
1068 if ($requiredversion != ANY_VERSION
) {
1069 $str = 'otherpluginversion';
1071 $str = 'otherplugin';
1074 $requires[] = html_writer
::tag('li',
1075 html_writer
::div(get_string($str, 'core_plugin',
1076 array('component' => $component, 'version' => $requiredversion)), 'component').
1077 html_writer
::div(implode(' | ', $actions), 'actions'),
1078 array('class' => $class));
1084 return html_writer
::tag('ul', implode("\n", $requires));
1088 * Prints an overview about the plugins - number of installed, number of extensions etc.
1090 * @param core_plugin_manager $pluginman provides information about the plugins
1091 * @param array $options filtering options
1092 * @return string as usually
1094 public function plugins_overview_panel(core_plugin_manager
$pluginman, array $options = array()) {
1097 $plugininfo = $pluginman->get_plugins();
1099 $numtotal = $numdisabled = $numextension = $numupdatable = 0;
1101 foreach ($plugininfo as $type => $plugins) {
1102 foreach ($plugins as $name => $plugin) {
1103 if ($plugin->get_status() === core_plugin_manager
::PLUGIN_STATUS_MISSING
) {
1107 if ($plugin->is_enabled() === false) {
1110 if (!$plugin->is_standard()) {
1113 if (empty($CFG->disableupdatenotifications
) and $plugin->available_updates()) {
1121 $somefilteractive = false;
1122 $info[] = html_writer
::tag('span', get_string('numtotal', 'core_plugin', $numtotal), array('class' => 'info total'));
1123 $info[] = html_writer
::tag('span', get_string('numdisabled', 'core_plugin', $numdisabled), array('class' => 'info disabled'));
1124 $info[] = html_writer
::tag('span', get_string('numextension', 'core_plugin', $numextension), array('class' => 'info extension'));
1125 if ($numextension > 0) {
1126 if (empty($options['contribonly'])) {
1127 $filter[] = html_writer
::link(
1128 new moodle_url($this->page
->url
, array('contribonly' => 1)),
1129 get_string('filtercontribonly', 'core_plugin'),
1130 array('class' => 'filter-item show-contribonly')
1133 $filter[] = html_writer
::tag('span', get_string('filtercontribonlyactive', 'core_plugin'),
1134 array('class' => 'filter-item active show-contribonly'));
1135 $somefilteractive = true;
1138 if ($numupdatable > 0) {
1139 $info[] = html_writer
::tag('span', get_string('numupdatable', 'core_plugin', $numupdatable), array('class' => 'info updatable'));
1140 if (empty($options['updatesonly'])) {
1141 $filter[] = html_writer
::link(
1142 new moodle_url($this->page
->url
, array('updatesonly' => 1)),
1143 get_string('filterupdatesonly', 'core_plugin'),
1144 array('class' => 'filter-item show-updatesonly')
1147 $filter[] = html_writer
::tag('span', get_string('filterupdatesonlyactive', 'core_plugin'),
1148 array('class' => 'filter-item active show-updatesonly'));
1149 $somefilteractive = true;
1152 if ($somefilteractive) {
1153 $filter[] = html_writer
::link($this->page
->url
, get_string('filterall', 'core_plugin'), array('class' => 'filter-item show-all'));
1156 $output = $this->output
->box(implode(html_writer
::tag('span', ' ', array('class' => 'separator')), $info), '', 'plugins-overview-panel');
1158 if (!empty($filter)) {
1159 $output .= $this->output
->box(implode(html_writer
::tag('span', ' ', array('class' => 'separator')), $filter), '', 'plugins-overview-filter');
1166 * Displays all known plugins and links to manage them
1168 * This default implementation renders all plugins into one big table.
1170 * @param core_plugin_manager $pluginman provides information about the plugins.
1171 * @param array $options filtering options
1172 * @return string HTML code
1174 public function plugins_control_panel(core_plugin_manager
$pluginman, array $options = array()) {
1177 $plugininfo = $pluginman->get_plugins();
1179 // Filter the list of plugins according the options.
1180 if (!empty($options['updatesonly'])) {
1181 $updateable = array();
1182 foreach ($plugininfo as $plugintype => $pluginnames) {
1183 foreach ($pluginnames as $pluginname => $pluginfo) {
1184 if (!empty($pluginfo->availableupdates
)) {
1185 foreach ($pluginfo->availableupdates
as $pluginavailableupdate) {
1186 if ($pluginavailableupdate->version
> $pluginfo->versiondisk
) {
1187 $updateable[$plugintype][$pluginname] = $pluginfo;
1193 $plugininfo = $updateable;
1196 if (!empty($options['contribonly'])) {
1197 $contribs = array();
1198 foreach ($plugininfo as $plugintype => $pluginnames) {
1199 foreach ($pluginnames as $pluginname => $pluginfo) {
1200 if (!$pluginfo->is_standard()) {
1201 $contribs[$plugintype][$pluginname] = $pluginfo;
1205 $plugininfo = $contribs;
1208 if (empty($plugininfo)) {
1212 $table = new html_table();
1213 $table->id
= 'plugins-control-panel';
1214 $table->head
= array(
1215 get_string('displayname', 'core_plugin'),
1216 get_string('source', 'core_plugin'),
1217 get_string('version', 'core_plugin'),
1218 get_string('release', 'core_plugin'),
1219 get_string('availability', 'core_plugin'),
1220 get_string('actions', 'core_plugin'),
1221 get_string('notes','core_plugin'),
1223 $table->headspan
= array(1, 1, 1, 1, 1, 2, 1);
1224 $table->colclasses
= array(
1225 'pluginname', 'source', 'version', 'release', 'availability', 'settings', 'uninstall', 'notes'
1228 foreach ($plugininfo as $type => $plugins) {
1229 $heading = $pluginman->plugintype_name_plural($type);
1230 $pluginclass = core_plugin_manager
::resolve_plugininfo_class($type);
1231 if ($manageurl = $pluginclass::get_manage_url()) {
1232 $heading = html_writer
::link($manageurl, $heading);
1234 $header = new html_table_cell(html_writer
::tag('span', $heading, array('id'=>'plugin_type_cell_'.$type)));
1235 $header->header
= true;
1236 $header->colspan
= array_sum($table->headspan
);
1237 $header = new html_table_row(array($header));
1238 $header->attributes
['class'] = 'plugintypeheader type-' . $type;
1239 $table->data
[] = $header;
1241 if (empty($plugins)) {
1242 $msg = new html_table_cell(get_string('noneinstalled', 'core_plugin'));
1243 $msg->colspan
= array_sum($table->headspan
);
1244 $row = new html_table_row(array($msg));
1245 $row->attributes
['class'] .= 'msg msg-noneinstalled';
1246 $table->data
[] = $row;
1250 foreach ($plugins as $name => $plugin) {
1251 $row = new html_table_row();
1252 $row->attributes
['class'] = 'type-' . $plugin->type
. ' name-' . $plugin->type
. '_' . $plugin->name
;
1254 if ($this->page
->theme
->resolve_image_location('icon', $plugin->type
. '_' . $plugin->name
)) {
1255 $icon = $this->output
->pix_icon('icon', '', $plugin->type
. '_' . $plugin->name
, array('class' => 'icon pluginicon'));
1257 $icon = $this->output
->pix_icon('spacer', '', 'moodle', array('class' => 'icon pluginicon noicon'));
1259 $status = $plugin->get_status();
1260 $row->attributes
['class'] .= ' status-'.$status;
1261 if ($status === core_plugin_manager
::PLUGIN_STATUS_MISSING
) {
1262 $msg = html_writer
::tag('span', get_string('status_missing', 'core_plugin'), array('class' => 'statusmsg'));
1263 } else if ($status === core_plugin_manager
::PLUGIN_STATUS_NEW
) {
1264 $msg = html_writer
::tag('span', get_string('status_new', 'core_plugin'), array('class' => 'statusmsg'));
1268 $pluginname = html_writer
::tag('div', $icon . '' . $plugin->displayname
. ' ' . $msg, array('class' => 'displayname')).
1269 html_writer
::tag('div', $plugin->component
, array('class' => 'componentname'));
1270 $pluginname = new html_table_cell($pluginname);
1272 if ($plugin->is_standard()) {
1273 $row->attributes
['class'] .= ' standard';
1274 $source = new html_table_cell(get_string('sourcestd', 'core_plugin'));
1276 $row->attributes
['class'] .= ' extension';
1277 $source = new html_table_cell(get_string('sourceext', 'core_plugin'));
1280 $version = new html_table_cell($plugin->versiondb
);
1281 $release = new html_table_cell($plugin->release
);
1283 $isenabled = $plugin->is_enabled();
1284 if (is_null($isenabled)) {
1285 $availability = new html_table_cell('');
1286 } else if ($isenabled) {
1287 $row->attributes
['class'] .= ' enabled';
1288 $availability = new html_table_cell(get_string('pluginenabled', 'core_plugin'));
1290 $row->attributes
['class'] .= ' disabled';
1291 $availability = new html_table_cell(get_string('plugindisabled', 'core_plugin'));
1294 $settingsurl = $plugin->get_settings_url();
1295 if (!is_null($settingsurl)) {
1296 $settings = html_writer
::link($settingsurl, get_string('settings', 'core_plugin'), array('class' => 'settings'));
1300 $settings = new html_table_cell($settings);
1302 if ($uninstallurl = $pluginman->get_uninstall_url($plugin->component
, 'overview')) {
1303 $uninstall = html_writer
::link($uninstallurl, get_string('uninstall', 'core_plugin'));
1307 $uninstall = new html_table_cell($uninstall);
1309 $requriedby = $pluginman->other_plugins_that_require($plugin->component
);
1311 $requiredby = html_writer
::tag('div', get_string('requiredby', 'core_plugin', implode(', ', $requriedby)),
1312 array('class' => 'requiredby'));
1318 if (empty($CFG->disableupdatenotifications
) and is_array($plugin->available_updates())) {
1319 foreach ($plugin->available_updates() as $availableupdate) {
1320 $updateinfo .= $this->plugin_available_update_info($availableupdate);
1324 $notes = new html_table_cell($requiredby.$updateinfo);
1326 $row->cells
= array(
1327 $pluginname, $source, $version, $release, $availability, $settings, $uninstall, $notes
1329 $table->data
[] = $row;
1333 return html_writer
::table($table);
1337 * Helper method to render the information about the available plugin update
1339 * The passed objects always provides at least the 'version' property containing
1340 * the (higher) version of the plugin available.
1342 * @param \core\update\info $updateinfo information about the available update for the plugin
1344 protected function plugin_available_update_info(\core\update\info
$updateinfo) {
1346 $boxclasses = 'pluginupdateinfo';
1349 if (isset($updateinfo->release
)) {
1350 $info[] = html_writer
::tag('span', get_string('updateavailable_release', 'core_plugin', $updateinfo->release
),
1351 array('class' => 'info release'));
1354 if (isset($updateinfo->maturity
)) {
1355 $info[] = html_writer
::tag('span', get_string('maturity'.$updateinfo->maturity
, 'core_admin'),
1356 array('class' => 'info maturity'));
1357 $boxclasses .= ' maturity'.$updateinfo->maturity
;
1360 if (isset($updateinfo->download
)) {
1361 $info[] = html_writer
::link($updateinfo->download
, get_string('download'), array('class' => 'info download'));
1364 if (isset($updateinfo->url
)) {
1365 $info[] = html_writer
::link($updateinfo->url
, get_string('updateavailable_moreinfo', 'core_plugin'),
1366 array('class' => 'info more'));
1369 $box = $this->output
->box_start($boxclasses);
1370 $box .= html_writer
::tag('div', get_string('updateavailable', 'core_plugin', $updateinfo->version
), array('class' => 'version'));
1371 $box .= $this->output
->box(implode(html_writer
::tag('span', ' ', array('class' => 'separator')), $info), '');
1373 $deployer = \core\update\deployer
::instance();
1374 if ($deployer->initialized()) {
1375 $impediments = $deployer->deployment_impediments($updateinfo);
1376 if (empty($impediments)) {
1377 $widget = $deployer->make_confirm_widget($updateinfo);
1378 $box .= $this->output
->render($widget);
1380 if (isset($impediments['notwritable'])) {
1381 $box .= $this->output
->help_icon('notwritable', 'core_plugin', get_string('notwritable', 'core_plugin'));
1383 if (isset($impediments['notdownloadable'])) {
1384 $box .= $this->output
->help_icon('notdownloadable', 'core_plugin', get_string('notdownloadable', 'core_plugin'));
1389 $box .= $this->output
->box_end();
1395 * This function will render one beautiful table with all the environmental
1396 * configuration and how it suits Moodle needs.
1398 * @param boolean $result final result of the check (true/false)
1399 * @param environment_results[] $environment_results array of results gathered
1400 * @return string HTML to output.
1402 public function environment_check_table($result, $environment_results) {
1406 $servertable = new html_table();//table for server checks
1407 $servertable->head
= array(
1410 get_string('report'),
1411 get_string('plugin'),
1412 get_string('status'),
1414 $servertable->colclasses
= array('centeralign name', 'centeralign info', 'leftalign report', 'leftalign plugin', 'centeralign status');
1415 $servertable->attributes
['class'] = 'admintable environmenttable generaltable';
1416 $servertable->id
= 'serverstatus';
1418 $serverdata = array('ok'=>array(), 'warn'=>array(), 'error'=>array());
1420 $othertable = new html_table();//table for custom checks
1421 $othertable->head
= array(
1423 get_string('report'),
1424 get_string('plugin'),
1425 get_string('status'),
1427 $othertable->colclasses
= array('aligncenter info', 'alignleft report', 'alignleft plugin', 'aligncenter status');
1428 $othertable->attributes
['class'] = 'admintable environmenttable generaltable';
1429 $othertable->id
= 'otherserverstatus';
1431 $otherdata = array('ok'=>array(), 'warn'=>array(), 'error'=>array());
1433 // Iterate over each environment_result
1435 foreach ($environment_results as $environment_result) {
1437 $warningline = false;
1440 $type = $environment_result->getPart();
1441 $info = $environment_result->getInfo();
1442 $status = $environment_result->getStatus();
1443 $plugin = $environment_result->getPluginName();
1444 $error_code = $environment_result->getErrorCode();
1445 // Process Report field
1446 $rec = new stdClass();
1447 // Something has gone wrong at parsing time
1449 $stringtouse = 'environmentxmlerror';
1450 $rec->error_code
= $error_code;
1451 $status = get_string('error');
1457 if ($rec->needed
= $environment_result->getNeededVersion()) {
1458 // We are comparing versions
1459 $rec->current
= $environment_result->getCurrentVersion();
1460 if ($environment_result->getLevel() == 'required') {
1461 $stringtouse = 'environmentrequireversion';
1463 $stringtouse = 'environmentrecommendversion';
1466 } else if ($environment_result->getPart() == 'custom_check') {
1467 // We are checking installed & enabled things
1468 if ($environment_result->getLevel() == 'required') {
1469 $stringtouse = 'environmentrequirecustomcheck';
1471 $stringtouse = 'environmentrecommendcustomcheck';
1474 } else if ($environment_result->getPart() == 'php_setting') {
1476 $stringtouse = 'environmentsettingok';
1477 } else if ($environment_result->getLevel() == 'required') {
1478 $stringtouse = 'environmentmustfixsetting';
1480 $stringtouse = 'environmentshouldfixsetting';
1484 if ($environment_result->getLevel() == 'required') {
1485 $stringtouse = 'environmentrequireinstall';
1487 $stringtouse = 'environmentrecommendinstall';
1491 // Calculate the status value
1492 if ($environment_result->getBypassStr() != '') { //Handle bypassed result (warning)
1493 $status = get_string('bypassed');
1494 $warningline = true;
1495 } else if ($environment_result->getRestrictStr() != '') { //Handle restricted result (error)
1496 $status = get_string('restricted');
1499 if ($status) { //Handle ok result (ok)
1500 $status = get_string('ok');
1502 if ($environment_result->getLevel() == 'optional') {//Handle check result (warning)
1503 $status = get_string('check');
1504 $warningline = true;
1505 } else { //Handle error result (error)
1506 $status = get_string('check');
1514 $linkparts = array();
1515 $linkparts[] = 'admin/environment';
1516 $linkparts[] = $type;
1518 $linkparts[] = $info;
1520 // Plugin environments do not have docs pages yet.
1521 if (empty($CFG->docroot
) or $environment_result->plugin
) {
1522 $report = get_string($stringtouse, 'admin', $rec);
1524 $report = $this->doc_link(join($linkparts, '/'), get_string($stringtouse, 'admin', $rec));
1527 // Format error or warning line
1528 if ($errorline ||
$warningline) {
1529 $messagetype = $errorline?
'error':'warn';
1531 $messagetype = 'ok';
1533 $status = '<span class="'.$messagetype.'">'.$status.'</span>';
1534 // Here we'll store all the feedback found
1536 // Append the feedback if there is some
1537 $feedbacktext .= $environment_result->strToReport($environment_result->getFeedbackStr(), $messagetype);
1538 //Append the bypass if there is some
1539 $feedbacktext .= $environment_result->strToReport($environment_result->getBypassStr(), 'warn');
1540 //Append the restrict if there is some
1541 $feedbacktext .= $environment_result->strToReport($environment_result->getRestrictStr(), 'error');
1543 $report .= $feedbacktext;
1545 // Add the row to the table
1546 if ($environment_result->getPart() == 'custom_check'){
1547 $otherdata[$messagetype][] = array ($info, $report, $plugin, $status);
1549 $serverdata[$messagetype][] = array ($type, $info, $report, $plugin, $status);
1554 //put errors first in
1555 $servertable->data
= array_merge($serverdata['error'], $serverdata['warn'], $serverdata['ok']);
1556 $othertable->data
= array_merge($otherdata['error'], $otherdata['warn'], $otherdata['ok']);
1560 $output .= $this->heading(get_string('serverchecks', 'admin'));
1561 $output .= html_writer
::table($servertable);
1562 if (count($othertable->data
)){
1563 $output .= $this->heading(get_string('customcheck', 'admin'));
1564 $output .= html_writer
::table($othertable);
1567 // Finally, if any error has happened, print the summary box
1569 $output .= $this->box(get_string('environmenterrortodo', 'admin'), 'environmentbox errorbox');