summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjim-p <jimp@pfsense.org>2012-08-15 22:18:53 -0400
committerjim-p <jimp@pfsense.org>2012-08-15 22:18:53 -0400
commit391abfcfe42a1156d252e30d049fbafc47dcf790 (patch)
tree8cba703b3084e44eefe3a079fc85490919168e21
parent7468a29fa001983f0e4cc5656c4d6af294894edc (diff)
downloadpfsense-391abfcfe42a1156d252e30d049fbafc47dcf790.zip
pfsense-391abfcfe42a1156d252e30d049fbafc47dcf790.tar.gz
Extend the shortcuts code and link back from Status > Services also.
-rwxr-xr-xusr/local/www/fbegin.inc16
-rw-r--r--usr/local/www/shortcuts.inc67
-rwxr-xr-xusr/local/www/status_services.php11
3 files changed, 80 insertions, 14 deletions
diff --git a/usr/local/www/fbegin.inc b/usr/local/www/fbegin.inc
index aa2151c..6766dd6 100755
--- a/usr/local/www/fbegin.inc
+++ b/usr/local/www/fbegin.inc
@@ -406,19 +406,13 @@ if (!$hide_service_status && !empty($shortcuts[$shortcut_section]['service'])) {
echo get_service_status_icon($ssvc, false);
echo get_service_control_links($ssvc, true);
}
-} ?>
-<?php if(!empty($shortcut_section) && !empty($shortcuts[$shortcut_section]['main']) && ($_SERVER['SCRIPT_NAME'] != "/" . $shortcuts[$shortcut_section]['main'])): ?>
-
-<a href="<?php echo $shortcuts[$shortcut_section]['main']; ?>" title="<?php echo gettext("Main page for this section"); ?>"><img style="vertical-align:middle" src="/themes/<?php echo $g['theme']; ?>/images/icons/icon_plus.gif" border="0"></a>
-<?php endif; ?>
-<?php if(!empty($shortcut_section) && !empty($shortcuts[$shortcut_section]['status'])): ?>
+}
-<a href="<?php echo $shortcuts[$shortcut_section]['status']; ?>" title="<?php echo gettext("Status of items on this page"); ?>"><img style="vertical-align:middle" src="/themes/<?php echo $g['theme']; ?>/images/icons/icon_service_status.gif" border="0"></a>
-<?php endif; ?>
-<?php if(!empty($shortcut_section) && !empty($shortcuts[$shortcut_section]['log'])): ?>
+echo get_shortcut_main_link($shortcut_section, true);
+echo get_shortcut_status_link($shortcut_section, true);
+echo get_shortcut_log_link($shortcut_section, true);
-<a href="<?php echo $shortcuts[$shortcut_section]['log']; ?>" title="<?php echo gettext("Log entries for items on this page"); ?>"><img style="vertical-align:middle" src="/themes/<?php echo $g['theme']; ?>/images/icons/icon_logs.gif" border="0"></a>
-<?php endif; ?>
+?>
<?php if(! $g['disablehelpicon']): ?>
<a href="<?php echo $helpurl; ?>" title="<?php echo gettext("Help for items on this page"); ?>"><img style="vertical-align:middle" src="/themes/<?php echo $g['theme']; ?>/images/icons/icon_help.gif" border="0"></a>
diff --git a/usr/local/www/shortcuts.inc b/usr/local/www/shortcuts.inc
index 112ac44..ca42593 100644
--- a/usr/local/www/shortcuts.inc
+++ b/usr/local/www/shortcuts.inc
@@ -61,6 +61,73 @@ function get_shortcut_files($directory) {
return $dir_array;
}
+function get_shortcut_by_service_name($servicename) {
+ global $shortcuts;
+ foreach ($shortcuts as $name => $shortcut) {
+ if (!empty($shortcut['service']) && ($shortcut['service'] == $servicename))
+ return $name;
+ }
+ return null;
+}
+
+function get_shortcut_main_link($shortcut_section, $addspace = true, $service = array()) {
+ global $g, $shortcuts;
+ if(empty($shortcut_section))
+ return "";
+ $space = ($addspace) ? "&nbsp;" : "" ;
+ switch ($shortcut_section) {
+ case "openvpn":
+ if (!empty($service['mode']) && is_numeric($service['id']))
+ $link = "vpn_openvpn_{$service['mode']}.php?act=edit&id={$service['id']}";
+ else
+ $link = $shortcuts[$shortcut_section]['main'];
+ break;
+ case "captiveportal":
+ if (!empty($service['zone']))
+ $link = "services_captiveportal.php?zone={$service['zone']}";
+ else
+ $link = $shortcuts[$shortcut_section]['main'];
+ break;
+ default:
+ $link = $shortcuts[$shortcut_section]['main'];
+ break;
+ }
+ if(!empty($link) && ($_SERVER['SCRIPT_NAME'] != "/{$link}"))
+ return "{$space}<a href=\"{$link}\" title=\"" . gettext("Main page for this section") . "\"><img style=\"vertical-align:middle\" src=\"/themes/{$g['theme']}/images/icons/icon_plus.gif\" border=\"0\"></a>";
+}
+
+function get_shortcut_status_link($shortcut_section, $addspace = true, $service = array()) {
+ global $g, $shortcuts, $cpzone;
+ if(empty($shortcut_section))
+ return "";
+ $space = ($addspace) ? "&nbsp;" : "" ;
+ if (!empty($cpzone))
+ $zone = $cpzone;
+ elseif (!empty($service['zone']))
+ $zone = $service['zone'];
+ switch ($shortcut_section) {
+ case "captiveportal":
+ if (!empty($zone))
+ $link = "status_captiveportal.php?zone={$zone}";
+ else
+ $link = $shortcuts[$shortcut_section]['status'];
+ break;
+ default:
+ $link = $shortcuts[$shortcut_section]['status'];
+ break;
+ }
+ if(!empty($link))
+ return "{$space}<a href=\"{$link}\" title=\"" . gettext("Status of items on this page") . "\"><img style=\"vertical-align:middle\" src=\"/themes/{$g['theme']}/images/icons/icon_service_status.gif\" border=\"0\"></a>";
+}
+
+function get_shortcut_log_link($shortcut_section, $addspace = true) {
+ global $g, $shortcuts;
+ $space = ($addspace) ? "&nbsp;" : "" ;
+ if(!empty($shortcut_section) && !empty($shortcuts[$shortcut_section]['log'])) {
+ return "{$space}<a href=\"{$shortcuts[$shortcut_section]['log']}\" title=\"" . gettext("Log entries for items on this page") . "\"><img style=\"vertical-align:middle\" src=\"/themes/{$g['theme']}/images/icons/icon_logs.gif\" border=\"0\"></a>";
+ }
+}
+
// Load shortcuts
$dir_array = get_shortcut_files("/usr/local/www/shortcuts");
foreach ($dir_array as $file)
diff --git a/usr/local/www/status_services.php b/usr/local/www/status_services.php
index 84c1e4e..0bcb45f 100755
--- a/usr/local/www/status_services.php
+++ b/usr/local/www/status_services.php
@@ -247,7 +247,6 @@ include("fbegin.inc");
$services = get_services();
-
if (count($services) > 0) {
uasort($services, "service_name_compare");
foreach($services as $service) {
@@ -255,11 +254,17 @@ if (count($services) > 0) {
continue;
if (empty($service['description']))
$service['description'] = get_pkg_descr($service['name']);
- echo '<tr><td class="listlr">' . $service['name'] . '</td>' . "\n";
- echo '<td class="listr">' . $service['description'] . '</td>' . "\n";
+ echo '<tr><td class="listlr" width="20%">' . $service['name'] . '</td>' . "\n";
+ echo '<td class="listr" width="55%">' . $service['description'] . '</td>' . "\n";
echo get_service_status_icon($service, true, true);
echo '<td valign="middle" class="list" nowrap>';
echo get_service_control_links($service);
+ $scut = get_shortcut_by_service_name($service['name']);
+ if (!empty($scut)) {
+ echo get_shortcut_main_link($scut, true, $service);
+ echo get_shortcut_status_link($scut, true, $service);
+ echo get_shortcut_log_link($scut, true);
+ }
echo "</td></tr>\n";
}
} else {
OpenPOWER on IntegriCloud