Same name and namespace in other branches
- 4.7.x modules/menu.module \menu_overview_tree_rows()
- 5.x modules/menu/menu.module \menu_overview_tree_rows()
1 call to menu_overview_tree_rows()
- menu_overview_tree in modules/
menu.module - Present the menu tree, rendered along with links to edit menu items.
File
- modules/
menu.module, line 399 - Allows administrators to customize the site navigation menu.
Code
function menu_overview_tree_rows($pid = 0, $depth = 0) {
$menu = menu_get_menu();
$rows = array();
if (isset($menu['items'][$pid]) && $menu['items'][$pid]['children']) {
usort($menu['items'][$pid]['children'], '_menu_sort');
foreach ($menu['items'][$pid]['children'] as $mid) {
// Populate the title field.
$title = '';
if ($pid == 0) {
// Top-level items are menu names, and don't have an associated path.
$title .= $menu['items'][$mid]['title'];
}
else {
$title .= l($menu['items'][$mid]['title'], $menu['items'][$mid]['path']);
}
if ($depth > 0) {
$title = '- ' . $title;
}
for ($i = 1; $i < $depth; $i++) {
$title = ' ' . $title;
}
// Populate the operations field.
$operations = array();
if (!($menu['items'][$mid]['type'] & MENU_MODIFIABLE_BY_ADMIN)) {
$operations[] = array(
'data' => t('locked'),
'colspan' => '3',
'align' => 'center',
);
}
else {
if ($menu['items'][$mid]['type'] & MENU_VISIBLE_IN_TREE) {
$operations[] = array(
'data' => l(t('edit'), 'admin/menu/item/edit/' . $mid),
);
if ($menu['items'][$mid]['type'] & MENU_IS_ROOT) {
// Disabling entire menus is done from block admin page.
$operations[] = array(
'data' => '',
);
}
else {
$operations[] = array(
'data' => l(t('disable'), 'admin/menu/item/disable/' . $mid),
);
}
}
else {
$operations[] = array(
'data' => '',
);
$operations[] = array(
'data' => l(t('enable'), 'admin/menu/item/edit/' . $mid),
);
}
if ($menu['items'][$mid]['type'] & MENU_CREATED_BY_ADMIN) {
$operations[] = array(
'data' => l(t('delete'), 'admin/menu/item/delete/' . $mid),
);
}
else {
if ($menu['items'][$mid]['type'] & MENU_MODIFIED_BY_ADMIN) {
$operations[] = array(
'data' => l(t('reset'), 'admin/menu/item/reset/' . $mid),
);
}
else {
$operations[] = array(
'data' => '',
);
}
}
}
// Call out disabled items.
if ($menu['items'][$mid]['type'] & MENU_VISIBLE_IN_TREE) {
$class = 'menu-enabled';
}
else {
$title .= ' (' . t('disabled') . ')';
$class = 'menu-disabled';
}
if ($menu['items'][$mid]['type'] & (MENU_MODIFIABLE_BY_ADMIN | MENU_VISIBLE_IN_TREE)) {
$row = array(
array(
'data' => $title,
'class' => $class,
),
array(
'data' => $menu['items'][$mid]['children'] ? $menu['items'][$mid]['type'] & MENU_EXPANDED ? t('Yes') : t('No') : '',
'class' => $class,
),
);
foreach ($operations as $operation) {
$operation['class'] = $class;
$row[] = $operation;
}
$rows[] = $row;
$rows = array_merge($rows, menu_overview_tree_rows($mid, $depth + 1));
}
else {
// Skip items that are hidden and locked; admins will never care about them.
$rows = array_merge($rows, menu_overview_tree_rows($mid, $depth));
}
}
}
return $rows;
}