menu_parent_options
modules/menu/menu.module, строка 740
- Версии
- 5
menu_parent_options(
$mid,$pid= 0,$depth= 0)- 6
menu_parent_options($menus, $item)
Return a list of menu items that are valid possible parents for the given menu item. The list excludes the given item and its children.
Параметры
$mid
The menu item id for which to generate a list of parents.
If $mid
== 0 then the complete tree is returned.
$pid
The menu item id of the menu item at which to start the tree.
If $pid
> 0 then this item will be included in the tree.
$depth
The current depth in the tree - used when recursing to indent the tree.
Возвращаемое значение
An array of menu titles keyed on the mid.
Код
<?php
function menu_parent_options($mid, $pid = 0, $depth = 0) {
$options = array();
if (!($parent_item = menu_get_item($pid))) {
return $options;
}
// Exclude $mid and its children from the list unless $mid is 0.
if ($mid && $mid == $pid) {
return $options;
}
// Add the current $pid to the list.
if ($pid > 0 && ($parent_item['type'] & (MENU_MODIFIABLE_BY_ADMIN | MENU_IS_ROOT))) {
$title = ' '. $parent_item['title'];
for ($i = 0; $i < $depth; $i++) {
$title = '--'. $title;
}
if (!($parent_item['type'] & MENU_VISIBLE_IN_TREE)) {
$title .= ' ('. t('disabled') .')';
}
$options[$pid] = $title;
$depth ++;
}
// Add children of $pid to the list recursively.
if (isset($parent_item['children'])) {
usort($parent_item['children'], '_menu_sort');
foreach ($parent_item['children'] as $child) {
$options += menu_parent_options($mid, $child, $depth);
}
}
return $options;
}
?>
Войдите или зарегистрируйтесь, чтобы получить возможность отправлять комментарии