function menu_overview_tree_rows in Drupal 4
Same name and namespace in other branches
- 5 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 626 - Allows administrators to customize the site navigation menu.
Code
function menu_overview_tree_rows($pid = 0, $depth = 0) {
$parent_item = menu_get_item($pid);
$rows = array();
if (isset($parent_item) && isset($parent_item['children'])) {
usort($parent_item['children'], '_menu_sort');
foreach ($parent_item['children'] as $mid) {
$item = menu_get_item($mid);
// Populate the title field.
$title = '';
if ($pid == 0) {
// Top-level items are menu names, and don't have an associated path.
$title .= check_plain($item['title']);
}
else {
$title .= l($item['title'], $item['path']);
}
if ($depth > 0) {
$title = '- ' . $title;
}
for ($i = 1; $i < $depth; $i++) {
$title = ' ' . $title;
}
// Populate the operations field.
$operations = array();
if (!($item['type'] & MENU_MODIFIABLE_BY_ADMIN)) {
$operations[] = array(
'data' => t('locked'),
'colspan' => '3',
'align' => 'center',
);
}
else {
// Set the edit column.
if ($item['type'] & (MENU_VISIBLE_IN_TREE | MENU_VISIBLE_IF_HAS_CHILDREN)) {
$operations[] = array(
'data' => l(t('edit'), 'admin/menu/item/edit/' . $mid),
);
}
else {
$operations[] = array(
'data' => '',
);
}
// Set the disable column.
if ($item['type'] & (MENU_IS_ROOT | MENU_VISIBLE_IF_HAS_CHILDREN)) {
// Disabling entire menus is done from block admin page.
// MENU_VISIBLE_IF_HAS_CHILDREN menus are always enabled so hide this operation.
$operations[] = array(
'data' => '',
);
}
else {
if ($item['type'] & MENU_VISIBLE_IN_TREE) {
$operations[] = array(
'data' => l(t('disable'), 'admin/menu/item/disable/' . $mid),
);
}
else {
$operations[] = array(
'data' => l(t('enable'), 'admin/menu/item/edit/' . $mid),
);
}
}
// Set the reset column.
if ($item['type'] & MENU_CREATED_BY_ADMIN) {
$operations[] = array(
'data' => l(t('delete'), 'admin/menu/item/delete/' . $mid),
);
}
else {
if ($item['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 ($item['type'] & (MENU_VISIBLE_IN_TREE | MENU_VISIBLE_IF_HAS_CHILDREN)) {
$class = 'menu-enabled';
}
else {
$title .= ' (' . t('disabled') . ')';
$class = 'menu-disabled';
}
if ($item['type'] & (MENU_MODIFIABLE_BY_ADMIN | MENU_VISIBLE_IN_TREE)) {
$row = array(
array(
'data' => $title,
'class' => $class,
),
array(
'data' => $item['children'] ? $item['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;
}