From 2fa2bb665d8ca5e837147f85267f865f1b8b0503 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 10 May 2016 16:57:06 +0200 Subject: Translating module strings and custom sections works --- inc/dashboard.inc.php | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) (limited to 'inc/dashboard.inc.php') diff --git a/inc/dashboard.inc.php b/inc/dashboard.inc.php index ef8be110..13d713bb 100644 --- a/inc/dashboard.inc.php +++ b/inc/dashboard.inc.php @@ -7,32 +7,48 @@ class Dashboard public static function createMenu() { - $modulesAssoc = array(); + global $MENU_SETTING_SORT_ORDER, $MENU_CAT_SORT_ORDER; + $modByCategory = array(); $all = Module::getEnabled(); foreach ($all as $module) { $cat = $module->getCategory(); if ($cat === false) continue; - $modulesAssoc[$cat][] = $module; + $modByCategory[$cat][] = $module; } - $modulesArray = array(); - foreach ($modulesAssoc as $id => $list) { - $momomo = array(); - foreach ($list as $module) { - $momomo[] = array( + $categories = array(); + $catSort = array(); + foreach ($modByCategory as $catId => $modList) { + $modules = array(); + $sectionSort = array(); + foreach ($modList as $module) { + $modId = $module->getIdentifier(); + $modules[] = array( 'displayName' => $module->getDisplayName(), 'identifier' => $module->getIdentifier(), 'className' => ($module->getIdentifier() === Page::getModule()->getIdentifier()) ? 'active' : '' ); + if (isset($MENU_SETTING_SORT_ORDER[$modId])) { + $sectionSort[] = (string)($MENU_SETTING_SORT_ORDER[$modId] + 1000); + } else { + $sectionSort[] = '9999' . $modId; + } } - $modulesArray[] = array( - 'icon' => self::getCategoryIcon($id), - 'displayName' => Dictionary::getCategoryName($id), - 'modules' => $momomo + 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' => $modulesArray, + 'categories' => $categories, 'url' => urlencode($_SERVER['REQUEST_URI']), 'langs' => Dictionary::getLanguages(true), 'dbupdate' => Database::needSchemaUpdate(), -- cgit v1.2.3-55-g7522