diff --git a/admin/renderer.php b/admin/renderer.php index fa3b23717b336..8477bd060e41b 100644 --- a/admin/renderer.php +++ b/admin/renderer.php @@ -236,6 +236,7 @@ public function plugin_management_page(plugin_manager $pluginman) { $output .= $this->header(); $output .= $this->heading(get_string('pluginsoverview', 'core_admin')); + $output .= $this->plugins_overview_panel($pluginman); $output .= $this->box_start('generalbox'); $output .= $this->plugins_control_panel($pluginman); $output .= $this->box_end(); @@ -646,6 +647,46 @@ protected function required_column(plugininfo_base $plugin, plugin_manager $plug return html_writer::tag('ul', implode("\n", $requires)); } + /** + * Prints an overview about the plugins - number of installed, number of extensions etc. + * + * @param plugin_manager $pluginman provides information about the plugins + * @return string as usually + */ + public function plugins_overview_panel(plugin_manager $pluginman) { + $plugininfo = $pluginman->get_plugins(); + + $numtotal = $numdisabled = $numextension = $numupdatable = 0; + + foreach ($plugininfo as $type => $plugins) { + foreach ($plugins as $name => $plugin) { + if ($plugin->get_status() === plugin_manager::PLUGIN_STATUS_MISSING) { + continue; + } + $numtotal++; + if ($plugin->is_enabled() === false) { + $numdisabled++; + } + if (!$plugin->is_standard()) { + $numextension++; + } + if ($plugin->available_update()) { + $numupdatable++; + } + } + } + + $info = array(); + $info[] = html_writer::tag('span', get_string('numtotal', 'core_plugin', $numtotal), array('class' => 'info total')); + $info[] = html_writer::tag('span', get_string('numdisabled', 'core_plugin', $numdisabled), array('class' => 'info disabled')); + $info[] = html_writer::tag('span', get_string('numextension', 'core_plugin', $numextension), array('class' => 'info extension')); + if ($numupdatable > 0) { + $info[] = html_writer::tag('span', get_string('numupdatable', 'core_plugin', $numupdatable), array('class' => 'info updatable')); + } + + return $this->output->box(implode(html_writer::tag('span', ' ', array('class' => 'separator')), $info), '', 'plugins-overview-panel'); + } + /** * Displays all known plugins and links to manage them * diff --git a/lang/en/plugin.php b/lang/en/plugin.php index 6b062117a61c7..fbb72a1c13ea6 100644 --- a/lang/en/plugin.php +++ b/lang/en/plugin.php @@ -31,6 +31,10 @@ $string['nonehighlighted'] = 'No plugins require your attention during this upgrade'; $string['nonehighlightedinfo'] = 'Display the list of all installed plugins anyway'; $string['noneinstalled'] = 'No plugins of this type are installed'; +$string['numtotal'] = '{$a} installed'; +$string['numdisabled'] = '{$a} disabled'; +$string['numextension'] = '{$a} extensions'; +$string['numupdatable'] = '{$a} updates available'; $string['otherplugin'] = '{$a->component}'; $string['otherpluginversion'] = '{$a->component} ({$a->version})'; $string['showall'] = 'Reload and show all plugins'; diff --git a/lib/pluginlib.php b/lib/pluginlib.php index f52842bb2e79f..f69c881e8c129 100644 --- a/lib/pluginlib.php +++ b/lib/pluginlib.php @@ -786,6 +786,19 @@ public function is_enabled() { return null; } + /** + * If there is an update of this plugin available, returns the data about it. + * + * Returns object with various properties about the available update, if such + * an update is available. Returns false if there is no update available for + * this plugin. Returns null if the update availabitlity is unknown. + * + * @return stdClass|false|null + */ + public function available_update() { + return null; + } + /** * Returns the URL of the plugin settings screen * diff --git a/theme/base/style/admin.css b/theme/base/style/admin.css index 64017d4360e43..4e0336a6eef43 100644 --- a/theme/base/style/admin.css +++ b/theme/base/style/admin.css @@ -206,6 +206,10 @@ #page-admin-plugins #plugins-control-panel .extension .source {background-color:#f3f2aa;} #page-admin-plugins #plugins-control-panel .msg td {text-align:center;} #page-admin-plugins #plugins-control-panel .requiredby {font-size:0.7em;color:#999;} +#page-admin-plugins #plugins-overview-panel {margin:1em auto;text-align:center;} +#page-admin-plugins #plugins-overview-panel .info {padding:5px 10px;} +#page-admin-plugins #plugins-overview-panel .separator {border-left:1px dotted #999;} +#page-admin-plugins #plugins-overview-panel .info.updatable {margin-left:10px;background-color:#d2ebff;font-weight:bold;-moz-border-radius: 10px;-webkit-border-radius: 10px;border-radius: 10px;} /** MNet networking */ #page-admin-mnet-peers .box.deletedhosts {margin-bottom:1em;font-size:80%;}