function _ctools_menu_add_dynamic_items
1 call to _ctools_menu_add_dynamic_items()
- ctools_menu_local_tasks_alter in ./
ctools.module - Implements hook_menu_local_tasks_alter().
File
-
includes/
menu.inc, line 60
Code
function _ctools_menu_add_dynamic_items(&$data, &$router_item, &$root_path) {
if ($additions = ctools_menu_add_tab()) {
// If none of the static local tasks are active allow one of the dynamic
// active tasks to be marked as such.
$has_active = FALSE;
if (!empty($data['tabs'][0]['output'])) {
foreach ($data['tabs'][0]['output'] as $element) {
if (!empty($element['#link']['#active'])) {
$has_active = TRUE;
}
}
}
foreach ($additions as $addition) {
$addition['localized_options'] = isset($addition['options']) ? $addition['options'] : array();
if (isset($addition['type']) && $addition['type'] == MENU_LOCAL_ACTION) {
$data['actions']['output'][] = array(
'#theme' => 'menu_local_action',
'#link' => $addition,
);
}
else {
$data['tabs'][0]['output'][] = array(
'#theme' => 'menu_local_task',
'#link' => $addition,
'#active' => !$has_active && $root_path === $addition['href'],
);
}
}
if (!empty($data['tabs'][0]['output'])) {
uasort($data['tabs'][0]['output'], 'ctools_menu_sort');
$data['tabs'][0]['count'] = count($data['tabs'][0]['output']);
}
if (!empty($data['actions']['output'])) {
uasort($data['actions']['output'], 'ctools_menu_sort');
$data['actions']['count'] = count($data['actions']['output']);
}
}
}