Skip to content

Commit

Permalink
MDL-20438 New plugins overview panel displaying some stats
Browse files Browse the repository at this point in the history
  • Loading branch information
mudrd8mz committed Mar 30, 2012
1 parent b6ad859 commit d26f3dd
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 0 deletions.
41 changes: 41 additions & 0 deletions admin/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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
*
Expand Down
4 changes: 4 additions & 0 deletions lang/en/plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
13 changes: 13 additions & 0 deletions lib/pluginlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down
4 changes: 4 additions & 0 deletions theme/base/style/admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -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%;}
Expand Down

0 comments on commit d26f3dd

Please sign in to comment.