function og_menu_block_view in Organic Groups Menu (OG Menu) 7.3
Same name and namespace in other branches
- 7.2 og_menu.module \og_menu_block_view()
Implements hook_block_view().
File
- ./
og_menu.module, line 246 - Integrates Menu with Organic Groups. Lots of menu forms duplication in OG context.
Code
function og_menu_block_view($delta = '') {
$block = array();
$context = og_context();
if ($delta == 'og_single_menu_block' && $context) {
$menus = og_menu_get_group_menus(array(
$context['group_type'] => array(
$context['gid'],
),
));
$menu = array_shift($menus);
if ($menu) {
if (variable_get('og_menu_block_links', FALSE)) {
$block['subject'] = l($menu['title'], $menu['group_type'] . '/' . $menu['gid']);
}
else {
$block['subject'] = check_plain($menu['title']);
}
$block['content'] = menu_tree($menu['menu_name']);
// Add contextual links.
if ($block['content']) {
if (in_array($menu['menu_name'], array_keys(menu_get_menus()))) {
$block['content']['#contextual_links']['og_menu'] = array(
'group/' . $context['group_type'] . '/' . $context['gid'] . '/admin/menus',
array(
$menu['menu_name'],
),
);
}
}
}
}
elseif ($delta == 'og_multi_menu_block' && $context) {
drupal_add_css(drupal_get_path('module', 'og_menu') . '/og_menu.css');
$menus = og_menu_get_group_menus(array(
$context['group_type'] => array(
$context['gid'],
),
));
$plural = count($menus) > 1 ? TRUE : FALSE;
$block['content'] = array();
foreach ($menus as $menu) {
$title = check_plain($menu['title']);
if (variable_get('og_menu_block_links', FALSE)) {
$title = l($menu['title'], $menu['group_type'] . '/' . $menu['gid']);
}
if ($tree = menu_tree($menu['menu_name'])) {
if ($plural) {
$block['subject'] = '';
if (!isset($block['content']['#markup'])) {
$block['content']["#markup"] = '';
}
$block['content']["#markup"] .= '<div class="block-og-menu-inset">' . '<h2 class="block-title">' . $title . '</h2>' . render($tree) . '</div>';
}
else {
$block['subject'] = $title;
$tree = menu_tree($menu['menu_name']);
$block['content'] = $tree;
}
}
}
// Add contextual links for first menu.
// @TODO Find a proper solution for displaying contextual links for all menus.
if ($block['content']) {
if (!isset($block['content']['#contextual_links'])) {
if (in_array($menu['menu_name'], array_keys(menu_get_menus()))) {
$block['content']['#contextual_links']['og_menu'] = array(
'group/' . $context['group_type'] . '/' . $context['gid'] . '/admin/menus',
array(
$menu['menu_name'],
),
);
}
}
}
}
return $block;
}