diff options
-rw-r--r-- | config.php.example | 25 | ||||
-rw-r--r-- | inc/dashboard.inc.php | 38 | ||||
-rw-r--r-- | inc/module.inc.php | 12 |
3 files changed, 48 insertions, 27 deletions
diff --git a/config.php.example b/config.php.example index 6e760f1c..67a45d18 100644 --- a/config.php.example +++ b/config.php.example @@ -30,10 +30,21 @@ define('CONFIG_PROXY_CONF', '/opt/openslx/proxy/config'); define('CONFIG_DOZMOD_URL', 'http://127.0.0.1:9080'); define('CONFIG_DOZMOD_EXPIRE', 60); -// Sort order for menu - optional, if missing, order will be alphabetically -$MENU_CAT_SORT_ORDER = array('main.content' => 0, 'main.settings-client' => 1, 'main.settings-server' => 2, 'main.status' => 3, 'main.users' => 4); -$MENU_SETTING_SORT_ORDER = array( - 'news' => 0, 'sysconfig' => 1, 'baseconfig' => 2, 'locations' => 3, // main.content - 'serversetup' => 0, 'internetaccess' => 1, 'vmstore' => 2, 'webinterface' => 3, 'backup' => 4, // main.settings - 'systemstatus' => 0, 'eventlog' => 1, 'syslog' => 2, 'statistics' => 3 // main.status -); +// Sort order for menu +// Optional - if missing, will be sorted by module id (internal name) +// Here it is also possible to assign a module to a different category, +// overriding the config.json entry +$MENU_CAT_OVERRIDE = array( + 'main.content' => array( + 'news', 'locations', 'exams', 'dozmod', 'translation' + ), + 'main.settings-client' => array( + 'sysconfig', 'baseconfig', 'minilinux' + ), + 'main.settings-server' => array( + 'serversetup', 'vmstore', 'webinterface', 'backup' + ), + 'main.status' => array( + 'systemstatus', 'eventlog', 'syslog', 'statistics' + ) +);
\ No newline at end of file diff --git a/inc/dashboard.inc.php b/inc/dashboard.inc.php index 3c913b76..01572461 100644 --- a/inc/dashboard.inc.php +++ b/inc/dashboard.inc.php @@ -8,23 +8,37 @@ class Dashboard public static function createMenu() { - global $MENU_SETTING_SORT_ORDER, $MENU_CAT_SORT_ORDER; + global $MENU_CAT_OVERRIDE; $modByCategory = array(); - $all = Module::getEnabled(); + $modById = array(); + if (isset($MENU_CAT_OVERRIDE)) { + foreach ($MENU_CAT_OVERRIDE as $cat => $list) { + foreach ($list as $mod) { + $modByCategory[$cat][$mod] = false; + $modById[$mod] =& $modByCategory[$cat][$mod]; + } + } + } + $all = Module::getEnabled(true); foreach ($all as $module) { $cat = $module->getCategory(); if ($cat === false) continue; - $modByCategory[$cat][] = $module; + $modId = $module->getIdentifier(); + if (isset($modById[$modId])) { + $modById[$modId] = $module; + } else { + $modByCategory[$cat][$modId] = $module; + } } $currentPage = Page::getModule()->getIdentifier(); $categories = array(); $catSort = array(); foreach ($modByCategory as $catId => $modList) { $modules = array(); - $sectionSort = array(); - foreach ($modList as $module) { - $modId = $module->getIdentifier(); + foreach ($modList as $modId => $module) { + if ($module === false) + continue; // Was set in $MENU_CAT_OVERRIDE, but is not enabled $newEntry = array( 'displayName' => $module->getDisplayName(), 'identifier' => $module->getIdentifier() @@ -34,25 +48,13 @@ class Dashboard $newEntry['subMenu'] = self::$subMenu; } $modules[] = $newEntry; - if (isset($MENU_SETTING_SORT_ORDER[$modId])) { - $sectionSort[] = (string)($MENU_SETTING_SORT_ORDER[$modId] + 1000); - } else { - $sectionSort[] = '9999' . $modId; - } } - array_multisort($sectionSort, SORT_ASC, $modules); $categories[] = array( 'icon' => self::getCategoryIcon($catId), 'displayName' => Dictionary::getCategoryName($catId), 'modules' => $modules ); - if (isset($MENU_CAT_SORT_ORDER[$catId])) { - $catSort[] = (string)($MENU_CAT_SORT_ORDER[$catId] + 1000); - } else { - $catSort[] = '9999' . $catId; - } } - array_multisort($catSort, SORT_ASC, $categories); Render::setDashboard(array( 'categories' => $categories, 'url' => urlencode($_SERVER['REQUEST_URI']), diff --git a/inc/module.inc.php b/inc/module.inc.php index a7a767ef..960a0a87 100644 --- a/inc/module.inc.php +++ b/inc/module.inc.php @@ -68,12 +68,20 @@ class Module /** * @return \Module[] List of valid, enabled modules */ - public static function getEnabled() + public static function getEnabled($sortById = false) { $ret = array(); + $sort = array(); foreach (self::$modules as $module) { - if (self::resolveDeps($module)) + if (self::resolveDeps($module)) { $ret[] = $module; + } + if ($sortById) { + $sort[] = $module->name; + } + } + if ($sortById) { + array_multisort($sort, SORT_ASC, $ret); } return $ret; } |