function get_modules_menus
Search API
7.x misc.inc | get_modules_menus() |
6.x misc.inc | get_modules_menus() |
4.x misc.inc | get_modules_menus() |
5.x misc.inc | get_modules_menus() |
Similar to get_modules_permissions, this will scan through all installed modules' hook_menu() functions, and assemble an array which is sorted by "location" and then by "weight".
File
- includes/
misc.inc, line 3000 - This file contains misc functions for FlightPath
Code
function get_modules_menus() {
$menus = array();
foreach ($GLOBALS ["fp_system_settings"]["modules"] as $module => $value) {
if (isset($value ["disabled"]) && $value ["disabled"] == "yes") {
// Module is not enabled. Skip it.
continue;
}
if (function_exists($module . "_menu")) {
$menus [] = call_user_func($module . "_menu");
}
}
// Let's re-order based on weight...
// Convert to a single dimensional array for easier sorting.
$temp = array();
foreach ($menus as $c => $value) {
foreach ($menus [$c] as $d => $menu_data) {
$w = $menu_data ["weight"];
if ($w == "") {
$w = "0";
}
// We need to front-pad $w with zeros, so it is the same length
// for every entry. Otherwise it will not sort correctly.
$w = fp_number_pad($w, 10);
$temp [] = "$w~~$c~~$d";
}
}
//var_dump($temp);
// Now, sort $temp...
sort($temp);
//var_dump($temp);
// Now, go back through $temp and get our new array...
$new_array = array();
foreach ($temp as $t) {
$vals = explode("~~", $t);
$c = $vals [1];
$d = $vals [2];
// Place them into subarrays indexed by location
$new_array [$menus [$c][$d]["location"]][] = $menus [$c][$d];
}
return $new_array;
}