summaryrefslogtreecommitdiffstats
path: root/src/usr/local/www/head.inc
diff options
context:
space:
mode:
authorRenato Botelho <renato@netgate.com>2016-03-02 12:24:28 -0300
committerRenato Botelho <renato@netgate.com>2016-03-02 12:24:28 -0300
commit909a195421db3611f7818ebd448ebc7eb98b7784 (patch)
treea6beeff34f367e09cf97103963d9c82207387786 /src/usr/local/www/head.inc
parenta6121be4fa5893ca9c8bd4a38a180588d27b5447 (diff)
downloadpfsense-909a195421db3611f7818ebd448ebc7eb98b7784.zip
pfsense-909a195421db3611f7818ebd448ebc7eb98b7784.tar.gz
Read xml files from /usr/local/share/pfSense/menu and load menu entries
Diffstat (limited to 'src/usr/local/www/head.inc')
-rw-r--r--src/usr/local/www/head.inc74
1 files changed, 55 insertions, 19 deletions
diff --git a/src/usr/local/www/head.inc b/src/usr/local/www/head.inc
index 114ce81..dba85bc 100644
--- a/src/usr/local/www/head.inc
+++ b/src/usr/local/www/head.inc
@@ -138,41 +138,75 @@ if (($pagename == "pkg.php") || ($pagename == "pkg_edit.php") || ($pagename == "
// Build the full help URL.
$helpurl .= "{$g['help_base_url']}?page={$pagename}";
+/*
+ * Read files from $g['ext_menu_path']/*.xml and fill an array with menu info
+ */
+function read_ext_menu_path_data() {
+ global $g;
+
+ $result = array();
+
+ if (!is_dir($g['ext_menu_path'])) {
+ return $result;
+ }
+
+ foreach (glob("{$g['ext_menu_path']}/*.xml") as $menu_xml) {
+ $xml_data = parse_xml_config_pkg($menu_xml, "packagegui");
+ if (empty($xml_data['menu'])) {
+ continue;
+ }
+ foreach ($xml_data['menu'] as $menu) {
+ $result[] = $menu;
+ }
+ }
+
+ return $result;
+}
+
// Create a menu entry of any installed packages in the specified category
// (Now reads the menu information from $config['installedpackages']['menu'] only)
function return_ext_menu($section) {
- global $config;
+ global $config, $ext_menu_path_data;
$htmltext = "";
$extarray = array();
+ $ext_menu_entries = array();
if ((!empty($config['installedpackages']['package'])) && (!empty($config['installedpackages']['menu']))) {
foreach ($config['installedpackages']['menu'] as $menu) {
// print('Name: ' . $menu['name'] . ', Pkg category: ' . $menu['category'] . ', Section: ' . $section . '<br />');
- if ($menu['section'] != $section) {
- continue;
+ if ($menu['section'] == $section) {
+ $ext_menu_entries[] = $menu;
}
+ }
+ }
+
+ foreach ($ext_menu_path_data as $menu) {
+ if ($menu['section'] == $section) {
+ $ext_menu_entries[] = $menu;
+ }
+ }
- if ($menu['url'] != "") {
- $test_url = $menu['url'];
- $addresswithport = getenv("HTTP_HOST");
- $colonpos = strpos($addresswithport, ":");
+ foreach ($ext_menu_entries as $menu) {
+ if ($menu['url'] != "") {
+ $test_url = $menu['url'];
+ $addresswithport = getenv("HTTP_HOST");
+ $colonpos = strpos($addresswithport, ":");
- if ($colonpos !== false) {
- //my url is actually just the IP address of the pfsense box
- $myurl = substr($addresswithport, 0, $colonpos);
- } else {
- $myurl = $addresswithport;
- }
- $description = str_replace('$myurl', $myurl, $menu['url']);
+ if ($colonpos !== false) {
+ //my url is actually just the IP address of the pfsense box
+ $myurl = substr($addresswithport, 0, $colonpos);
} else {
- $description = '/pkg.php?xml=' . $menu['configfile'];
- $test_url=$description;
+ $myurl = $addresswithport;
}
+ $description = str_replace('$myurl', $myurl, $menu['url']);
+ } else {
+ $description = '/pkg.php?xml=' . $menu['configfile'];
+ $test_url=$description;
+ }
- if (isAllowedPage($test_url)) {
- $extarray[] = array($menu['name'], $description);
- }
+ if (isAllowedPage($test_url)) {
+ $extarray[] = array($menu['name'], $description);
}
}
@@ -200,6 +234,8 @@ function output_menu($arrayitem, $target = null, $section = "") {
}
}
+$ext_menu_path_data = read_ext_menu_path_data();
+
// System
$system_menu = array();
$system_menu[] = array(gettext("Logout"), "/index.php?logout");
OpenPOWER on IntegriCloud