function advanced_menu_submenu_block_view_alter in Advanced Menu 7
Implements hook_block_view_alter().
File
- submenu/
advanced_menu_submenu.module, line 100 - Provides advanced menu submenus.
Code
function advanced_menu_submenu_block_view_alter(&$data, $block) {
global $user, $language;
$system_menus = array(
'navigation',
'management',
'user-menu',
'main-menu',
);
if ($block->module == 'superfish') {
list($menu_name, $mlid) = explode(':', variable_get('superfish_menu_' . $block->delta, 'main-menu:0'));
$cache_key = 'links:' . $menu_name . ':all-cid:' . $mlid . ':' . $user->uid . ':' . $language->language;
_advanced_menu_submenu_cache($cache_key);
$data = superfish_contents($block->delta);
}
if (in_array($block->delta, $system_menus) && $block->module == 'system' || ($block->module == 'menu' || $block->module == 'menu_block')) {
$new_content = array();
$orig_content = $data['content'];
if ($block->module == 'menu_block') {
$orig_content = $data['content']['#content'];
}
foreach ($orig_content as $key => $item) {
if (is_numeric($key)) {
$new_data = _advanced_menu_submenu_trees($item);
if ($new_data != $orig_content[$key]) {
$orig_content[$key] = $new_data;
if (is_array($new_data)) {
$new_content = array_merge($new_content, $new_data);
}
else {
$new_content[$key] = $new_data;
}
}
else {
$new_content[$key] = $item;
}
}
else {
$new_content[$key] = $item;
}
}
if ($block->module == 'menu_block') {
$data['content']['#content'] = $new_content;
}
else {
$data['content'] = $new_content;
}
}
}