/** * Displays the list if available missing dependencies. * * @param core_plugin_manager $pluginman * @param array $dependencies * @return string */ protected function available_missing_dependencies_list(core_plugin_manager $pluginman, array $dependencies) { global $CFG; $table = new html_table(); $table->id = 'plugins-check-available-dependencies'; $table->head = array(get_string('displayname', 'core_plugin'), get_string('release', 'core_plugin'), get_string('version', 'core_plugin'), get_string('supportedmoodleversions', 'core_plugin'), get_string('info', 'core')); $table->colclasses = array('displayname', 'release', 'version', 'supportedmoodleversions', 'info'); $table->data = array(); foreach ($dependencies as $plugin) { $supportedmoodles = array(); foreach ($plugin->version->supportedmoodles as $moodle) { if ($CFG->branch == str_replace('.', '', $moodle->release)) { $supportedmoodles[] = html_writer::span($moodle->release, 'label label-success'); } else { $supportedmoodles[] = html_writer::span($moodle->release, 'label'); } } $requriedby = $pluginman->other_plugins_that_require($plugin->component); if ($requriedby) { foreach ($requriedby as $ix => $val) { $inf = $pluginman->get_plugin_info($val); if ($inf) { $requriedby[$ix] = $inf->displayname . ' (' . $inf->component . ')'; } } $info = html_writer::div(get_string('requiredby', 'core_plugin', implode(', ', $requriedby)), 'requiredby'); } else { $info = ''; } $info .= $this->output->container_start('actions'); $info .= html_writer::div(html_writer::link('https://moodle.org/plugins/view.php?plugin=' . $plugin->component, get_string('misdepinfoplugin', 'core_plugin')), 'misdepinfoplugin'); $info .= html_writer::div(html_writer::link('https://moodle.org/plugins/pluginversion.php?id=' . $plugin->version->id, get_string('misdepinfoversion', 'core_plugin')), 'misdepinfoversion'); $info .= html_writer::div(html_writer::link($plugin->version->downloadurl, get_string('download')), 'misdepdownload'); if ($pluginman->is_remote_plugin_installable($plugin->component, $plugin->version->version, $reason)) { $info .= $this->output->single_button(new moodle_url($this->page->url, array('installdep' => $plugin->component)), get_string('dependencyinstall', 'core_plugin'), 'post', array('class' => 'singlebutton dependencyinstall')); } else { $reasonhelp = $this->info_remote_plugin_not_installable($reason); if ($reasonhelp) { $info .= html_writer::div($reasonhelp, 'reasonhelp dependencyinstall'); } } $info .= $this->output->container_end(); // End of .actions container. $table->data[] = array(html_writer::div($plugin->name, 'name') . ' ' . html_writer::div($plugin->component, 'component'), $plugin->version->release, $plugin->version->version, implode($supportedmoodles, ' '), $info); } return html_writer::table($table); }
/** * 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(); if (!empty($plugin->versionrequires)) { if ($plugin->versionrequires <= $version) { $class = 'requires-ok'; } else { $class = 'requires-failed'; } $requires[] = html_writer::tag('li', get_string('moodleversion', 'core_plugin', $plugin->versionrequires), array('class' => $class)); } foreach ($plugin->get_other_required_plugins() as $component => $requiredversion) { $ok = true; $otherplugin = $pluginman->get_plugin_info($component); if (is_null($otherplugin)) { $ok = false; } else { if ($requiredversion != ANY_VERSION and $otherplugin->versiondisk < $requiredversion) { $ok = false; } } if ($ok) { $class = 'requires-ok'; } else { $class = 'requires-failed'; } if ($requiredversion != ANY_VERSION) { $str = 'otherpluginversion'; } else { $str = 'otherplugin'; } $componenturl = new moodle_url('https://moodle.org/plugins/view.php?plugin=' . $component); $componenturl = html_writer::tag('a', $component, array('href' => $componenturl->out())); $requires[] = html_writer::tag('li', get_string($str, 'core_plugin', array('component' => $componenturl, 'version' => $requiredversion)), array('class' => $class)); } if (!$requires) { return ''; } return html_writer::tag('ul', implode("\n", $requires)); }
/** * 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(); if (!empty($plugin->versionrequires)) { if ($plugin->versionrequires <= $version) { $class = 'requires-ok'; } else { $class = 'requires-failed'; } $requires[] = html_writer::tag('li', get_string('moodleversion', 'core_plugin', $plugin->versionrequires), array('class' => $class)); } foreach ($plugin->get_other_required_plugins() as $component => $requiredversion) { $otherplugin = $pluginman->get_plugin_info($component); $actions = array(); if (is_null($otherplugin)) { // The required plugin is not installed. $class = 'requires-failed requires-missing'; $installurl = new moodle_url('https://moodle.org/plugins/view.php', array('plugin' => $component)); $uploadurl = new moodle_url('/admin/tool/installaddon/'); $actions[] = html_writer::link($installurl, get_string('dependencyinstall', 'core_plugin')); $actions[] = html_writer::link($uploadurl, get_string('dependencyupload', 'core_plugin')); } else { if ($requiredversion != ANY_VERSION and $otherplugin->versiondisk < $requiredversion) { // The required plugin is installed but needs to be updated. $class = 'requires-failed requires-outdated'; if (!$otherplugin->is_standard()) { $updateurl = new moodle_url($this->page->url, array('sesskey' => sesskey(), 'fetchupdates' => 1)); $actions[] = html_writer::link($updateurl, get_string('checkforupdates', 'core_plugin')); } } else { // Already installed plugin with sufficient version. $class = 'requires-ok'; } } if ($requiredversion != ANY_VERSION) { $str = 'otherpluginversion'; } else { $str = 'otherplugin'; } $requires[] = html_writer::tag('li', html_writer::div(get_string($str, 'core_plugin', array('component' => $component, 'version' => $requiredversion)), 'component') . html_writer::div(implode(' | ', $actions), 'actions'), array('class' => $class)); } if (!$requires) { return ''; } return html_writer::tag('ul', implode("\n", $requires)); }
/** * Renders indicator manager * * @return string HTML */ public function display_indicator_list(core_plugin_manager $pluginman, $instances) { if (empty($instances)) { return ''; } $table = new html_table(); $table->id = 'plugins-control-panel'; $table->attributes['class'] = 'generaltable generalbox boxaligncenter boxwidthwide'; $table->head = array(get_string('displayname', 'core_plugin'), get_string('source', 'core_plugin'), get_string('version', 'core_plugin'), get_string('availability', 'core_plugin'), get_string('settings', 'core_plugin')); $table->colclasses = array('displayname', 'source', 'version', 'availability', 'settings'); foreach ($instances as $name => $path) { $plugin = $pluginman->get_plugin_info('engagementindicator_' . $name); $row = new html_table_row(); $row->attributes['class'] = 'type-' . $plugin->type . ' name-' . $plugin->type . '_' . $plugin->name; if ($this->page->theme->resolve_image_location('icon', $plugin->type . '_' . $plugin->name)) { $icon = $this->output->pix_icon('icon', '', $plugin->type . '_' . $plugin->name, array('class' => 'smallicon pluginicon')); } else { $icon = $this->output->pix_icon('spacer', '', 'moodle', array('class' => 'smallicon pluginicon noicon')); } if ($plugin->get_status() === core_plugin_manager::PLUGIN_STATUS_MISSING) { $msg = html_writer::tag('span', get_string('status_missing', 'core_plugin'), array('class' => 'notifyproblem')); $row->attributes['class'] .= ' missingfromdisk'; } else { $msg = ''; } $displayname = $icon . ' ' . $plugin->displayname . ' ' . $msg; $displayname = new html_table_cell($displayname); if (report_engagement_is_core_indicator($name)) { $row->attributes['class'] .= ' standard'; $source = new html_table_cell(get_string('sourcestd', 'core_plugin')); } else { $row->attributes['class'] .= ' extension'; $source = new html_table_cell(get_string('sourceext', 'core_plugin')); } $version = new html_table_cell($plugin->versiondb); $isenabled = $plugin->is_enabled(); if (is_null($isenabled)) { $availability = new html_table_cell(''); } else { if ($isenabled) { $row->attributes['class'] .= ' enabled'; $icon = $this->output->pix_icon('i/hide', get_string('pluginenabled', 'core_plugin')); $availability = new html_table_cell($icon . ' ' . get_string('pluginenabled', 'core_plugin')); } else { $row->attributes['class'] .= ' disabled'; $icon = $this->output->pix_icon('i/show', get_string('plugindisabled', 'core_plugin')); $availability = new html_table_cell($icon . ' ' . get_string('plugindisabled', 'core_plugin')); } } $settingsurl = $plugin->get_settings_url(); if (is_null($settingsurl)) { $settings = new html_table_cell(''); } else { $settings = html_writer::link($settingsurl, get_string('settings', 'core_plugin')); $settings = new html_table_cell($settings); } $row->cells = array($displayname, $source, $version, $availability, $settings); $table->data[] = $row; } return html_writer::table($table); }