function hs_menu_hierarchical_select_children in Hierarchical Select 5.3
Same name and namespace in other branches
- 6.3 modules/hs_menu.module \hs_menu_hierarchical_select_children()
- 7.3 modules/hs_menu.module \hs_menu_hierarchical_select_children()
Implementation of hook_hierarchical_select_children().
1 call to hs_menu_hierarchical_select_children()
- hs_menu_hierarchical_select_root_level in modules/
hs_menu.module - Implementation of hook_hierarchical_select_root_level().
File
- modules/
hs_menu.module, line 98 - Implementation of the Hierarchical Select API for the Menu module.
Code
function hs_menu_hierarchical_select_children($parent, $params) {
$children = array();
$mid = $params['mid'];
$pid = $parent;
$parent_mid = $params['parent_mid'];
if (!($parent_item = menu_get_item($pid))) {
return $children;
}
else {
if (!isset($parent_item['children'])) {
return $children;
}
}
foreach ($parent_item['children'] as $child_mid) {
// Don't include the given item in the hierarchy!
if ($child_mid == $params['mid']) {
continue;
}
$child = menu_get_item($child_mid);
if ($child['type'] & (MENU_MODIFIABLE_BY_ADMIN | MENU_IS_ROOT)) {
$title = $child['title'];
if (!($child['type'] & MENU_VISIBLE_IN_TREE)) {
$title .= ' (' . t('disabled') . ')';
}
$children[$child_mid] = $title;
}
}
// If this is the root level, it might contain the menu to which menu
// items are restricted. If it does contain it, remove all other menus.
if (isset($children[$parent_mid])) {
foreach ($children as $child_mid => $child) {
if ($child_mid != $parent_mid) {
unset($children[$child_mid]);
}
}
}
return $children;
}