/** * need to split these tables or something, mark the headers as thead? */ public function plugins_check_table(plugin_manager $pluginman, $version, array $options = array()) { global $CFG; $plugininfo = $pluginman->get_plugins(); if (empty($plugininfo)) { return ''; } $options['full'] = isset($options['full']) ? (bool) $options['full'] : false; $options['xdep'] = isset($options['xdep']) ? (bool) $options['xdep'] : false; $table = new html_table(); $table->id = 'plugins-check'; $table->attributes['class'] = 'table table-striped table-hover'; $table->head = array(get_string('displayname', 'core_plugin'), get_string('rootdir', 'core_plugin'), get_string('source', 'core_plugin'), get_string('versiondb', 'core_plugin'), get_string('versiondisk', 'core_plugin'), get_string('requires', 'core_plugin'), get_string('status', 'core_plugin')); $table->data = array(); $numofhighlighted = array(); // number of highlighted rows per this subsection foreach ($plugininfo as $type => $plugins) { $header = new html_table_cell($pluginman->plugintype_name_plural($type)); $header->header = true; $header->colspan = count($table->head); $header = new html_table_row(array($header)); $header->attributes['class'] = 'plugintypeheader type-' . $type; $numofhighlighted[$type] = 0; if (empty($plugins) and $options['full']) { $msg = new html_table_cell(get_string('noneinstalled', 'core_plugin')); $msg->colspan = count($table->head); $row = new html_table_row(array($msg)); $row->attributes['class'] .= 'warning msg-noneinstalled'; $table->data[] = $header; $table->data[] = $row; continue; } $plugintyperows = array(); foreach ($plugins as $name => $plugin) { $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 = bootstrap::icon_spacer(); } $displayname = $icon . ' ' . $plugin->displayname; $displayname = new html_table_cell($displayname); $rootdir = new html_table_cell($plugin->get_dir()); if ($isstandard = $plugin->is_standard()) { $source = new html_table_cell(get_string('sourcestd', 'core_plugin')); } else { $source = new html_table_cell(label::warning(get_string('sourceext', 'core_plugin'))); } $versiondb = new html_table_cell($plugin->versiondb); $versiondisk = new html_table_cell($plugin->versiondisk); $statuscode = $plugin->get_status(); $status = get_string('status_' . $statuscode, 'core_plugin'); if ($statuscode === 'upgrade') { $status = label::info($status); } else { if ($statuscode === 'new') { $status = label::success($status); } } $availableupdates = $plugin->available_updates(); if (!empty($availableupdates) and empty($CFG->disableupdatenotifications)) { foreach ($availableupdates as $availableupdate) { $status .= $this->plugin_available_update_info($availableupdate); } } $status = new html_table_cell($status); $requires = new html_table_cell($this->required_column($plugin, $pluginman, $version)); $statusisboring = in_array($statuscode, array(plugin_manager::PLUGIN_STATUS_NODB, plugin_manager::PLUGIN_STATUS_UPTODATE)); $coredependency = $plugin->is_core_dependency_satisfied($version); $otherpluginsdependencies = $pluginman->are_dependencies_satisfied($plugin->get_other_required_plugins()); $dependenciesok = $coredependency && $otherpluginsdependencies; if ($options['xdep']) { // we want to see only plugins with failed dependencies if ($dependenciesok) { continue; } } else { if ($isstandard and $statusisboring and $dependenciesok and empty($availableupdates)) { // no change is going to happen to the plugin - display it only // if the user wants to see the full list if (empty($options['full'])) { continue; } } } // ok, the plugin should be displayed $numofhighlighted[$type]++; $row->cells = array($displayname, $rootdir, $source, $versiondb, $versiondisk, $requires, $status); $plugintyperows[] = $row; } if (empty($numofhighlighted[$type]) and empty($options['full'])) { continue; } $table->data[] = $header; $table->data = array_merge($table->data, $plugintyperows); } $sumofhighlighted = array_sum($numofhighlighted); if ($options['xdep']) { // we do not want to display no heading and links in this mode $out = ''; } else { if ($sumofhighlighted == 0) { $out = $this->output->container_start('nonehighlighted', 'plugins-check-info'); $out .= $this->output->heading(get_string('nonehighlighted', 'core_plugin')); if (empty($options['full'])) { $out .= html_writer::link(new moodle_url('/admin/index.php', array('confirmupgrade' => 1, 'confirmrelease' => 1, 'showallplugins' => 1)), get_string('nonehighlightedinfo', 'core_plugin')); } $out .= $this->output->container_end(); } else { $out = $this->output->container_start('somehighlighted', 'plugins-check-info'); $out .= $this->output->heading(get_string('somehighlighted', 'core_plugin', $sumofhighlighted)); if (empty($options['full'])) { $out .= html_writer::link(new moodle_url('/admin/index.php', array('confirmupgrade' => 1, 'confirmrelease' => 1, 'showallplugins' => 1)), get_string('somehighlightedinfo', 'core_plugin')); } else { $out .= html_writer::link(new moodle_url('/admin/index.php', array('confirmupgrade' => 1, 'confirmrelease' => 1, 'showallplugins' => 0)), get_string('somehighlightedonly', 'core_plugin')); } $out .= $this->output->container_end(); } } if ($sumofhighlighted > 0 or $options['full']) { $out .= html_writer::table($table); } return $out; }