Commit b4280bde authored by davereid's avatar davereid Committed by Dave Reid

Issue #1978528 by Dave Reid, omasjuan, bobodrone, babruix, yerlix: Fixed some...

Issue #1978528 by Dave Reid, omasjuan, bobodrone, babruix, yerlix: Fixed some PHP notices if menu is not available or deleted. Improved admin label of deleted menus' menu blocks in Panels.
parent 0d1af888
......@@ -194,9 +194,12 @@ function _menu_block_format_title($config) {
}
$menus = menu_block_get_all_menus();
$menus[MENU_TREE__CURRENT_PAGE_MENU] = t('Current menu');
if (empty($config['menu_name']) || empty($menus[$config['menu_name']])) {
if (empty($config['menu_name'])) {
$title = t('Unconfigured menu block');
}
elseif (!isset($menus[$config['menu_name']])) {
$title = t('Deleted/missing menu @menu', array('@menu' => $config['menu_name']));
}
else {
// Show the configured levels in the block info
$replacements = array(
......
......@@ -426,12 +426,13 @@ function menu_tree_build(&$config) {
}
// Get the default block name.
drupal_static_reset('menu_block_set_title');
$menu_names = menu_block_get_all_menus();
menu_block_set_title($menu_names[$config['menu_name']]);
// Get the raw menu tree data.
$tree = menu_tree_block_data($config);
$title = menu_block_get_title($config['title_link'], $config);
$title = menu_block_get_title($config['title_link']);
// Create a renderable tree.
$data = array();
......@@ -464,12 +465,16 @@ function menu_tree_build(&$config) {
function menu_block_get_title($render_title_as_link = TRUE) {
$menu_item = menu_block_set_title();
// The tree's title is a menu title, a normal string.
if (empty($menu_item)) {
// menu_block_set_title() has not been used yet.
return '';
}
if (is_string($menu_item)) {
// The tree's title is a menu title, a normal string.
$title = array('#markup' => check_plain($menu_item));
}
// The tree's title is a menu item with a link.
elseif ($render_title_as_link) {
// The tree's title is a menu item with a link.
if (!empty($menu_item['in_active_trail'])) {
if (!empty($menu_item['localized_options']['attributes']['class'])) {
$menu_item['localized_options']['attributes']['class'][] = 'active-trail';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment