/** * Formats the information that needs to go in the 'Requires' column. * @param \core\plugininfo\base $plugin the plugin we are rendering the row for. * @param core_plugin_manager $pluginman provides data on all the plugins. * @param string $version * @return string HTML code */ protected function required_column(\core\plugininfo\base $plugin, core_plugin_manager $pluginman, $version) { $requires = array(); $displayuploadlink = false; $displayupdateslink = false; foreach ($pluginman->resolve_requirements($plugin, $version) as $reqname => $reqinfo) { if ($reqname === 'core') { if ($reqinfo->status == $pluginman::REQUIREMENT_STATUS_OK) { $class = 'requires-ok'; $label = ''; } else { $class = 'requires-failed'; $label = html_writer::span(get_string('dependencyfails', 'core_plugin'), 'label label-important'); } $requires[] = html_writer::tag('li', html_writer::span(get_string('moodleversion', 'core_plugin', $plugin->versionrequires), 'dep dep-core') . ' ' . $label, array('class' => $class)); } else { $actions = array(); if ($reqinfo->status == $pluginman::REQUIREMENT_STATUS_OK) { $label = ''; $class = 'requires-ok'; } else { if ($reqinfo->status == $pluginman::REQUIREMENT_STATUS_MISSING) { if ($reqinfo->availability == $pluginman::REQUIREMENT_AVAILABLE) { $label = html_writer::span(get_string('dependencymissing', 'core_plugin'), 'label label-warning'); $label .= ' ' . html_writer::span(get_string('dependencyavailable', 'core_plugin'), 'label label-warning'); $class = 'requires-failed requires-missing requires-available'; $actions[] = html_writer::link(new moodle_url('https://moodle.org/plugins/view.php', array('plugin' => $reqname)), get_string('misdepinfoplugin', 'core_plugin')); } else { $label = html_writer::span(get_string('dependencymissing', 'core_plugin'), 'label label-important'); $label .= ' ' . html_writer::span(get_string('dependencyunavailable', 'core_plugin'), 'label label-important'); $class = 'requires-failed requires-missing requires-unavailable'; } $displayuploadlink = true; } else { if ($reqinfo->status == $pluginman::REQUIREMENT_STATUS_OUTDATED) { if ($reqinfo->availability == $pluginman::REQUIREMENT_AVAILABLE) { $label = html_writer::span(get_string('dependencyfails', 'core_plugin'), 'label label-warning'); $label .= ' ' . html_writer::span(get_string('dependencyavailable', 'core_plugin'), 'label label-warning'); $class = 'requires-failed requires-outdated requires-available'; $displayupdateslink = true; } else { $label = html_writer::span(get_string('dependencyfails', 'core_plugin'), 'label label-important'); $label .= ' ' . html_writer::span(get_string('dependencyunavailable', 'core_plugin'), 'label label-important'); $class = 'requires-failed requires-outdated requires-unavailable'; } $displayuploadlink = true; } } } if ($reqinfo->reqver != ANY_VERSION) { $str = 'otherpluginversion'; } else { $str = 'otherplugin'; } $requires[] = html_writer::tag('li', html_writer::span(get_string($str, 'core_plugin', array('component' => $reqname, 'version' => $reqinfo->reqver)), 'dep dep-plugin') . ' ' . $label . ' ' . html_writer::span(implode(' | ', $actions), 'actions'), array('class' => $class)); } } if (!$requires) { return ''; } $out = html_writer::tag('ul', implode("\n", $requires)); if ($displayuploadlink) { $out .= html_writer::div(html_writer::link(new moodle_url('/admin/tool/installaddon/'), get_string('dependencyuploadmissing', 'core_plugin')), 'dependencyuploadmissing'); } if ($displayupdateslink) { $out .= html_writer::div(html_writer::link(new moodle_url($this->page->url, array('sesskey' => sesskey(), 'fetchupdates' => 1)), get_string('checkforupdates', 'core_plugin')), 'checkforupdates'); } return $out; }