From 79ac52d54a51acdbd469f2d48890eb11e04ac991 Mon Sep 17 00:00:00 2001
From: Pim van den Berg
Date: Fri, 28 Dec 2012 20:25:29 +0100
Subject: remove arguments overview_plugins and other_plugins from plugins_list
function
Those can be gathered within the function.
---
detail.php | 10 ++--------
host.php | 9 ++-------
inc/html.inc.php | 35 ++++++++++++++++++++++++-----------
3 files changed, 28 insertions(+), 26 deletions(-)
diff --git a/detail.php b/detail.php
index b824d1d..fdeb777 100644
--- a/detail.php
+++ b/detail.php
@@ -21,12 +21,7 @@ $width = GET('x');
$heigth = GET('y');
$seconds = GET('s');
-if (!$plugin) {
- $selected_plugins = $CONFIG['overview'];
-}
-else {
- $selected_plugins = array($plugin);
-}
+$selected_plugins = !$plugin ? $CONFIG['overview'] : array($plugin);
html_start();
@@ -39,8 +34,7 @@ if(!$plugins) {
return false;
}
-plugins_list($host, $CONFIG['overview'], $plugins, $selected_plugins);
-
+plugins_list($host, $selected_plugins);
echo '
';
plugin_header($host, $plugin);
diff --git a/host.php b/host.php
index 42121ea..71d786a 100644
--- a/host.php
+++ b/host.php
@@ -7,12 +7,7 @@ require_once 'inc/collectd.inc.php';
$host = validate_get(GET('h'), 'host');
$plugin = validate_get(GET('p'), 'plugin');
-if (!$plugin) {
- $selected_plugins = $CONFIG['overview'];
-}
-else {
- $selected_plugins = array($plugin);
-}
+$selected_plugins = !$plugin ? $CONFIG['overview'] : array($plugin);
html_start();
@@ -25,7 +20,7 @@ if(!$plugins) {
return false;
}
-plugins_list($host, $CONFIG['overview'], $plugins, $selected_plugins);
+plugins_list($host, $selected_plugins);
echo '
';
foreach ($selected_plugins as $selected_plugin) {
diff --git a/inc/html.inc.php b/inc/html.inc.php
index fd32b38..a9e6a94 100644
--- a/inc/html.inc.php
+++ b/inc/html.inc.php
@@ -63,29 +63,42 @@ function plugin_header($host, $plugin) {
return printf("
\n", $CONFIG['weburl'], $host, $plugin, $plugin);
}
-function plugins_list($host, $overview_plugins, $other_plugins, $selected_plugins = array()) {
+function plugins_list($host, $selected_plugins = array()) {
global $CONFIG;
+ $plugins = collectd_plugins($host);
+
echo '
';
echo '
Plugins
';
echo '
';
- $selected = selected_overview($selected_plugins);
- printf("- %s
\n", $selected, $CONFIG['weburl'], $host, 'overview');
+ printf("- overview
\n",
+ selected_overview($selected_plugins),
+ $CONFIG['weburl'],
+ $host
+ );
# first the ones defined as ordered
- foreach($overview_plugins as $plugin) {
- if (in_array($plugin, $other_plugins)) {
- $selected = selected_plugin($plugin, $selected_plugins);
- printf("- %s
\n", $selected, $CONFIG['weburl'], $host, $plugin, $plugin);
+ foreach($CONFIG['overview'] as $plugin) {
+ if (in_array($plugin, $plugins)) {
+ printf("- %4\$s
\n",
+ selected_plugin($plugin, $selected_plugins),
+ $CONFIG['weburl'],
+ $host,
+ $plugin
+ );
}
}
# other plugins
- foreach($other_plugins as $plugin) {
- if (!in_array($plugin, $overview_plugins)) {
- $selected = selected_plugin($plugin, $selected_plugins);
- printf("- %s
\n", $selected, $CONFIG['weburl'], $host, $plugin, $plugin);
+ foreach($plugins as $plugin) {
+ if (!in_array($plugin, $CONFIG['overview'])) {
+ printf("- %4\$s
\n",
+ selected_plugin($plugin, $selected_plugins),
+ $CONFIG['weburl'],
+ $host,
+ $plugin
+ );
}
}
--
cgit v1.1