function panels_move_menu_tabs in Panels 5.2
1 call to panels_move_menu_tabs()
- panels_page_view_page in panels_page/
panels_page.module - Page callback to view a panel page.
File
- panels_page/
panels_page.module, line 570 - panels_page.module
Code
function panels_move_menu_tabs($path, $tab) {
global $_menu;
// Get my menu item.
$my_mid = menu_get_active_item();
// Get my parent menu item.
$my_parent = $_menu['items'][$my_mid]['pid'];
// Check the existing children to see if there is a default local task
// already.
if (!isset($_menu['items'][$my_parent]['children'])) {
$_menu['items'][$my_parent]['children'] = array();
}
$local_tasks = FALSE;
if ($my_parent != 1) {
// We do not run this loop if the parent is the top level menu item
// since that way lies madness.
foreach ($_menu['items'][$my_parent]['children'] as $child_mid) {
if ($_menu['items'][$child_mid]['type'] & MENU_IS_LOCAL_TASK) {
$local_tasks = TRUE;
break;
}
}
}
if (!$local_tasks) {
// Move the administrative items from the admin menu to here.
$admin_item = $_menu['path index'][$path];
$_menu['items'][$my_mid]['children'] = $_menu['items'][$admin_item]['children'];
}
else {
// But if we do have tabs, just add the admin item itself to the tabs.
// Get the menu item we want to move us to.
$path .= $tab;
$admin_item = $_menu['path index'][$path];
$_menu['items'][$my_parent]['children'][] = $admin_item;
$_menu['items'][$admin_item]['title'] = t('Edit panel');
$_menu['items'][$admin_item]['weight'] += 50;
$_menu['items'][$admin_item]['type'] = MENU_LOCAL_TASK;
}
}