Commit 17dad5a7 authored by Ad Schellevis's avatar Ad Schellevis

(menu, cleanup) move interface items to model, remove duplicate code

parent 3c854168
...@@ -203,23 +203,6 @@ class ControllerBase extends ControllerRoot ...@@ -203,23 +203,6 @@ class ControllerBase extends ControllerRoot
// set translator // set translator
$this->view->setVar('lang', $this->getTranslator($cnf)); $this->view->setVar('lang', $this->getTranslator($cnf));
$ifarr = array();
foreach ($cnf->object()->interfaces->children() as $key => $node) {
$ifarr[$key] = !empty($node->descr) ? $node->descr->__toString() : strtoupper($key);
}
natcasesort($ifarr);
$ordid = 0;
foreach ($ifarr as $key => $descr) {
$menu->appendItem('Interfaces', $key, array(
'url' => '/interfaces.php?if='. $key,
'visiblename' => '[' . $descr . ']',
'cssclass' => 'fa fa-sitemap',
'order' => $ordid++,
));
}
unset($ifarr);
$this->view->menuSystem = $menu->getItems("/ui".$this->router->getRewriteUri()); $this->view->menuSystem = $menu->getItems("/ui".$this->router->getRewriteUri());
// set theme in ui_theme template var, let template handle its defaults (if there is no theme). // set theme in ui_theme template var, let template handle its defaults (if there is no theme).
......
...@@ -33,7 +33,6 @@ namespace OPNsense\Core\Api; ...@@ -33,7 +33,6 @@ namespace OPNsense\Core\Api;
use OPNsense\Base\ApiControllerBase; use OPNsense\Base\ApiControllerBase;
use OPNsense\Base\Menu; use OPNsense\Base\Menu;
use OPNsense\Core\ACL; use OPNsense\Core\ACL;
use OPNsense\Core\Config;
/** /**
* Class MenuController * Class MenuController
...@@ -125,25 +124,6 @@ class MenuController extends ApiControllerBase ...@@ -125,25 +124,6 @@ class MenuController extends ApiControllerBase
$this->username = $this->session->get("Username"); $this->username = $this->session->get("Username");
} }
// add interfaces to "Interfaces" menu tab... kind of a hack, may need some improvement.
$cnf = Config::getInstance();
$ifarr = array();
foreach ($cnf->object()->interfaces->children() as $key => $node) {
$ifarr[$key] = !empty($node->descr) ? $node->descr->__toString() : strtoupper($key);
}
natcasesort($ifarr);
$ordid = 0;
foreach ($ifarr as $key => $descr) {
$menu->appendItem('Interfaces', $key, array(
'url' => '/interfaces.php?if='. $key,
'visiblename' => '[' . $descr . ']',
'cssclass' => 'fa fa-sitemap',
'order' => $ordid++,
));
}
unset($ifarr);
// fetch menu items and apply acl // fetch menu items and apply acl
$menu_items = $menu->getItems($selected_uri); $menu_items = $menu->getItems($selected_uri);
$this->applyACL($menu_items, $acl); $this->applyACL($menu_items, $acl);
......
...@@ -29,6 +29,8 @@ ...@@ -29,6 +29,8 @@
*/ */
namespace OPNsense\Base\Menu; namespace OPNsense\Base\Menu;
use OPNsense\Core\Config;
/** /**
* Class MenuSystem * Class MenuSystem
* @package OPNsense\Base\Menu * @package OPNsense\Base\Menu
...@@ -101,6 +103,23 @@ class MenuSystem ...@@ -101,6 +103,23 @@ class MenuSystem
} }
} }
} }
// add interfaces to "Interfaces" menu tab... kind of a hack, may need some improvement.
$ifarr = array();
foreach (Config::getInstance()->object()->interfaces->children() as $key => $node) {
$ifarr[$key] = !empty($node->descr) ? $node->descr->__toString() : strtoupper($key);
}
natcasesort($ifarr);
$ordid = 0;
foreach ($ifarr as $key => $descr) {
$this->appendItem('Interfaces', $key, array(
'url' => '/interfaces.php?if='. $key,
'visiblename' => '[' . $descr . ']',
'cssclass' => 'fa fa-sitemap',
'order' => $ordid++,
));
}
unset($ifarr);
} }
/** /**
......
...@@ -15,24 +15,6 @@ function system_get_language_code() { ...@@ -15,24 +15,6 @@ function system_get_language_code() {
// link menu system // link menu system
$menu = new OPNsense\Base\Menu\MenuSystem(); $menu = new OPNsense\Base\Menu\MenuSystem();
// add interfaces to "Interfaces" menu tab... kind of a hack, may need some improvement.
$cnf = OPNsense\Core\Config::getInstance();
$ifarr = array();
foreach ($cnf->object()->interfaces->children() as $key => $node) {
$ifarr[$key] = !empty($node->descr) ? $node->descr->__toString() : strtoupper($key);
}
natcasesort($ifarr);
$ordid = 0;
foreach ($ifarr as $key => $descr) {
$menu->appendItem('Interfaces', $key, array(
'url' => '/interfaces.php?if=' . $key,
'visiblename' => '[' . $descr . ']',
'cssclass' => 'fa fa-sitemap',
'order' => $ordid++,
));
}
unset($ifarr);
$menuSystem = $menu->getItems($_SERVER['REQUEST_URI']); $menuSystem = $menu->getItems($_SERVER['REQUEST_URI']);
/* XXX workaround for dashboard */ /* XXX workaround for dashboard */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment