function _popup_menuelement in Popup 7
Same name and namespace in other branches
- 8 includes/popup.util.inc \_popup_menuelement()
- 7.x includes/popup.util.inc \_popup_menuelement()
- 6.x includes/popup.util.inc \_popup_menuelement()
Recursively generates popup menus
1 call to _popup_menuelement()
- _popup_menu in includes/
popup.api.inc
File
- includes/
popup.util.inc, line 264
Code
function _popup_menuelement($menu, $attributes, $level = 0) {
global $user;
$body = '';
$title = isset($attributes['title']) && $attributes['title'] ? $attributes['title'] : $menu['link']['title'];
$link = isset($menu['link']['link_path']) ? drupal_get_path_alias(str_replace('%', $user->uid, $menu['link']['link_path'])) : FALSE;
if ($menu['link']['has_children'] && is_array($menu['below']) && count($menu['below'])) {
$children = _popup_menuelement_visible_items($menu['below']);
$child_attributes = _popup_menuelement_child_attribs($attributes);
if (isset($attributes['flat']) && $attributes['flat']) {
$child_attributes['expand'] = $attributes['expand'];
$child_attributes['origin'] = $attributes['origin'];
}
foreach ($children as $child) {
$body .= _popup_menuelement($child, $child_attributes, isset($attributes['flat']) && $attributes['flat'] ? $level : $level + 1);
}
if (isset($menu['link']['in_active_trail']) && $menu['link']['in_active_trail']) {
$attributes['classes']['element'][] = 'popup-menu-branch-active';
}
$attributes['classes']['body'][] = 'popup-menu-branch-body-' . _popup_title_to_key($title);
$attributes['classes']['element'][] = 'popup-menu-branch-element-' . _popup_title_to_key($title);
$attributes['classes']['element'][] = 'popup-menu-branch';
$attributes['classes']['title'][] = 'popup-menu-branch-title';
$attributes['classes']['title'][] = 'popup-menu-item';
$attributes['classes']['title'][] = 'popup-menu-item-' . _popup_title_to_key($title);
$attributes['link'] = $link;
if ($level > 0) {
$attributes['classes']['element'][] = 'popup-menu-child';
}
return isset($attributes['flat']) && $attributes['flat'] ? '<div class="popup-menu-flat' . ($attributes['inline'] ? ' popup-menu-inline' : ' popup-menu-block') . ' popup-style-' . _popup_title_to_key($attributes['style']) . '">' . $body . '</div>' : popup_element($title, $body, $attributes);
}
else {
return l('<span>' . $title . '</span>', $link, array(
'html' => TRUE,
'attributes' => array(
'class' => array(
'popup-menu-item',
'popup-menu-leaf-title',
$attributes['activate'] == 'hover' ? ' activate-hover' : '',
'popup-menu-item-' . _popup_title_to_key($title),
),
),
));
}
}