function footermap_get_menu in footermap: a footer site map 7
Same name and namespace in other branches
- 5.2 footermap.module \footermap_get_menu()
- 5 footermap.module \footermap_get_menu()
- 6 footermap.module \footermap_get_menu()
1 call to footermap_get_menu()
File
- ./
footermap.module, line 232
Code
function footermap_get_menu($mlid, &$mapref, $recurse, $level) {
global $user;
if ($recurse != 0 && $level >= $recurse) {
return;
}
$avail_menus = variable_get('avail_menus', array());
$query = db_select('menu_links', 'ml');
$query
->fields('ml')
->condition('ml.plid', $mlid, '=')
->condition('ml.hidden', 0, '=')
->orderBy('ml.plid')
->orderBy('ml.weight')
->orderBy('ml.link_title');
$query
->leftJoin('menu_router', 'mr', 'ml.router_path = mr.path');
$query
->fields('mr')
->orderBy('mr.title');
if (variable_get('sys_menus', 0) == 0) {
$query
->condition('ml.module', 'system', '<>');
}
$res = $query
->execute();
foreach ($res as $item) {
// available menus check
if (!_footermap_check_menu_item($avail_menus, $item)) {
continue;
}
// access check for menu router items
if (isset($item->path)) {
if (empty($item->access_callback)) {
// automatic fail
continue;
}
$map = array();
$args = array();
$map = explode('/', $item->link_path);
if (!empty($item->to_arg_functions)) {
_menu_link_map_translate($map, $item->to_arg_functions);
}
$args = menu_unserialize($item->access_arguments, $map);
// There's no way that I can do access callback stuff for every
// custom access callback with custom arguments under the sun.
// It's out of scope of this module, and a non-issue.
if ($item->access_callback == 'user_access') {
if (!empty($args[0])) {
if (!user_access($args[0], $user)) {
continue;
}
}
}
else {
if ($item->access_callback == 'node_access') {
if (is_numeric($args[1])) {
$node = node_load($args[1]);
if (!node_access('view', $node)) {
continue;
}
}
else {
// Let's continue here;
continue;
}
}
}
}
// Mapref reference becomes child.
if (isset($mapref[$item->menu_name])) {
$child =& $mapref[$item->menu_name]['#items'];
}
else {
$child =& $mapref;
}
$options = $item->options ? unserialize($item->options) : array();
$item->link_path = preg_replace("/\\/%\$/", '', $item->link_path);
$child['menu-' . $item->mlid] = array(
'#theme' => 'footermap_item',
'#href' => $item->link_path,
'#title' => $item->link_title,
'#options' => $options,
'#attributes' => array(
'class' => array(
'footermap-item',
'footermap-item-' . $level,
),
'id' => 'footermap-item-' . $item->mlid,
),
'#level' => $level,
'#language' => isset($item->language) ? $item->language : LANGUAGE_NONE,
);
if ($item->has_children == 1) {
footermap_get_menu($item->mlid, $child['menu-' . $item->mlid]['#children'], $recurse, $level + 1);
}
}
}