Skip to content
Snippets Groups Projects
Commit 23fc2390 authored by Tim Steiner's avatar Tim Steiner
Browse files

[gh-294] Merging from testing into staging -c 1454

git-svn-id: file:///tmp/wdn_thm_drupal/branches/drupal-7.x/staging@1457 20a16fea-79d4-4915-8869-1ea9d5ebf173
parent c78618e1
No related branches found
No related tags found
No related merge requests found
Menu Block 7.x-2.3, 2012-02-04
------------------------------
- #1105372 by mikl, fabsor and JohnAlbin: Add menu tree ctools content type to D7
- #1425342 by JohnAlbin and Dave Reid: Menu block fails with Drupal core 7.12; remove work-around for core bug #942782.
- #1243978 by Dave Reid: Fixed menu_block_export_menu() items were not translatable since they were not located in menu_block_export.module.
- #1243978 by Dave Reid: Fixed menu_block_menu() items were not translatable since they were not located in menu_block.module.
- by Dave Reid: Moved menu_block_menu_alter() to menu_block.menu so that it doesn't cause a module hook cache miss.
- #1155052 by Dave Reid: Fixed errors if block module is not enabled.
- #1162038 by Dave Reid: Fixed 'Add menu block' local action only appears on default theme.
- #1114722 by dropcube: Fixed i18n menu support
- #1154122 by Dave Reid: Moved block module hook implementations to menu_block.module to prevent problems with hook implementation caching.
- #1078806 by Dave Reid: Fixed string untranslated warning from coder.
- #1139530 by Dave Reid: Add a base form ID of block_add_block_form to menu_block_add_block_form so other modules can properly and easily alter it.
- #1139522 by Dave Reid: Fixed fatal error with current page menu trees.
Menu Block 7.x-2.2, 2011-03-09 Menu Block 7.x-2.2, 2011-03-09
------------------------------ ------------------------------
- #1086376: Custom menu fix doesn't work for new installations - #1086376: Custom menu fix doesn't work for new installations
......
This diff is collapsed.
...@@ -4,50 +4,6 @@ ...@@ -4,50 +4,6 @@
* Provides infrequently used functions and hooks for menu_block. * Provides infrequently used functions and hooks for menu_block.
*/ */
/**
* Implements hook_menu().
*/
function _menu_block_menu() {
$items['admin/structure/block/add-menu-block'] = array(
'title' => 'Add menu block',
'description' => 'Add a new menu block.',
'access arguments' => array('administer blocks'),
'page callback' => 'drupal_get_form',
'page arguments' => array('menu_block_add_block_form'),
'type' => MENU_LOCAL_ACTION,
'file' => 'menu_block.admin.inc',
);
$items['admin/structure/block/delete-menu-block'] = array(
'title' => 'Delete menu block',
'access arguments' => array('administer blocks'),
'page callback' => 'drupal_get_form',
'page arguments' => array('menu_block_delete'),
'type' => MENU_CALLBACK,
'file' => 'menu_block.admin.inc',
);
$items['admin/config/user-interface/menu-block'] = array(
'title' => 'Menu block',
'description' => 'Configure menu block.',
'access arguments' => array('administer blocks'),
'page callback' => 'drupal_get_form',
'page arguments' => array('menu_block_admin_settings_form'),
'type' => MENU_NORMAL_ITEM,
'file' => 'menu_block.admin.inc',
);
return $items;
}
/**
* Implements hook_menu_alter().
*/
function menu_block_menu_alter(&$items) {
// Fake the necessary menu attributes necessary for a contextual link.
$items['admin/content/book/%node']['title'] = 'Edit book outline';
$items['admin/content/book/%node']['type'] = MENU_LOCAL_TASK;
$items['admin/content/book/%node']['context'] = (MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE);
$items['admin/content/book/%node']['tab_root'] = 'admin/content/book';
}
/** /**
* Implements hook_theme(). * Implements hook_theme().
*/ */
...@@ -89,7 +45,18 @@ function _menu_block_ctools_plugin_directory($module, $plugin) { ...@@ -89,7 +45,18 @@ function _menu_block_ctools_plugin_directory($module, $plugin) {
*/ */
function menu_block_add_block_form($form, &$form_state) { function menu_block_add_block_form($form, &$form_state) {
module_load_include('inc', 'block', 'block.admin'); module_load_include('inc', 'block', 'block.admin');
return block_admin_configure($form, $form_state, 'menu_block', NULL); $form = block_admin_configure($form, $form_state, 'menu_block', NULL);
// Other modules should be able to use hook_form_block_add_block_form_alter()
// to modify this form, so add a base form ID.
$form_state['build_info']['base_form_id'] = 'block_add_block_form';
// Prevent block_add_block_form_validate/submit() from being automatically
// added because of the base form ID by providing these handlers manually.
$form['#validate'] = array();
$form['#submit'] = array('menu_block_add_block_form_submit');
return $form;
} }
/** /**
...@@ -99,6 +66,7 @@ function menu_block_add_block_form_submit($form, &$form_state) { ...@@ -99,6 +66,7 @@ function menu_block_add_block_form_submit($form, &$form_state) {
// Determine the delta of the new block. // Determine the delta of the new block.
$block_ids = variable_get('menu_block_ids', array()); $block_ids = variable_get('menu_block_ids', array());
$delta = empty($block_ids) ? 1 : max($block_ids) + 1; $delta = empty($block_ids) ? 1 : max($block_ids) + 1;
$form_state['values']['delta'] = $delta;
// Save the new array of blocks IDs. // Save the new array of blocks IDs.
$block_ids[] = $delta; $block_ids[] = $delta;
...@@ -541,14 +509,11 @@ function menu_block_admin_settings_form($form, &$form_state) { ...@@ -541,14 +509,11 @@ function menu_block_admin_settings_form($form, &$form_state) {
'#title' => t('Suppress Drupal’s standard menu blocks'), '#title' => t('Suppress Drupal’s standard menu blocks'),
'#default_value' => variable_get('menu_block_suppress_core', 0), '#default_value' => variable_get('menu_block_suppress_core', 0),
'#description' => t('On the blocks admin page, hide Drupal’s standard blocks of menus.'), '#description' => t('On the blocks admin page, hide Drupal’s standard blocks of menus.'),
'#access' => module_exists('block'),
); );
// Retrieve core's menus. // Retrieve core's menus.
$menus = menu_get_menus(); $menus = menu_get_menus();
// Include book support.
if (module_exists('book')) {
module_load_include('inc', 'menu_block', 'menu_block.book');
}
// Retrieve all the menu names provided by hook_menu_block_get_sort_menus(). // Retrieve all the menu names provided by hook_menu_block_get_sort_menus().
$menus = array_merge($menus, module_invoke_all('menu_block_get_sort_menus')); $menus = array_merge($menus, module_invoke_all('menu_block_get_sort_menus'));
asort($menus); asort($menus);
...@@ -633,7 +598,7 @@ function menu_block_admin_settings_form_submit($form, &$form_state) { ...@@ -633,7 +598,7 @@ function menu_block_admin_settings_form_submit($form, &$form_state) {
else { else {
variable_del('menu_block_suppress_core'); variable_del('menu_block_suppress_core');
} }
drupal_set_message('The configuration options have been saved.'); drupal_set_message(t('The configuration options have been saved.'));
} }
/** /**
......
...@@ -2,22 +2,21 @@ name = "Menu Block" ...@@ -2,22 +2,21 @@ name = "Menu Block"
description = "Provides configurable blocks of menu items." description = "Provides configurable blocks of menu items."
core = 7.x core = 7.x
dependencies[] = menu dependencies[] = menu (>7.11)
files[] = menu_block.module files[] = menu_block.module
files[] = menu_block.admin.inc files[] = menu_block.admin.inc
files[] = menu_block.book.inc
files[] = menu_block.follow.inc files[] = menu_block.follow.inc
files[] = menu_block.pages.inc files[] = menu_block.pages.inc
files[] = menu_block.sort.inc files[] = menu_block.sort.inc
files[] = menu_block.install files[] = menu_block.install
# files[] = plugins/content_types/menu_tree/menu_tree.inc files[] = plugins/content_types/menu_tree/menu_tree.inc
configure = admin/config/user-interface/menu-block configure = admin/config/user-interface/menu-block
; Information added by drupal.org packaging script on 2011-03-09 ; Information added by drupal.org packaging script on 2012-02-03
version = "7.x-2.2" version = "7.x-2.3"
core = "7.x" core = "7.x"
project = "menu_block" project = "menu_block"
datestamp = "1299683174" datestamp = "1328286646"
...@@ -37,8 +37,6 @@ function menu_block_uninstall() { ...@@ -37,8 +37,6 @@ function menu_block_uninstall() {
*/ */
function menu_block_enable() { function menu_block_enable() {
drupal_set_message(t('To use menu blocks, find the "Add menu block" link on the <a href="@url">administer blocks page</a>.', array('@url' => url('admin/structure/block')))); drupal_set_message(t('To use menu blocks, find the "Add menu block" link on the <a href="@url">administer blocks page</a>.', array('@url' => url('admin/structure/block'))));
// @TODO Remove this when after this core bug is fixed: #942782.
menu_block_fix_custom_menus();
} }
/** /**
......
...@@ -4,19 +4,12 @@ ...@@ -4,19 +4,12 @@
* Provides configurable blocks of menu items. * Provides configurable blocks of menu items.
*/ */
// A core bug in Drupal 7.0 requires this fix.
module_load_include('inc', 'menu_block', 'custom_menu_active_trail');
/** /**
* Denotes that the tree should use the menu picked by the curent page. * Denotes that the tree should use the menu picked by the curent page.
*/ */
define('MENU_TREE__CURRENT_PAGE_MENU', '_active'); define('MENU_TREE__CURRENT_PAGE_MENU', '_active');
// Off-load the following infrequently called hooks to another file. // Off-load the following infrequently called hooks to another file.
function menu_block_menu() {
module_load_include('inc', 'menu_block', 'menu_block.admin');
return _menu_block_menu();
}
function menu_block_theme(&$existing, $type, $theme, $path) { function menu_block_theme(&$existing, $type, $theme, $path) {
module_load_include('inc', 'menu_block', 'menu_block.admin'); module_load_include('inc', 'menu_block', 'menu_block.admin');
return _menu_block_theme($existing, $type, $theme, $path); return _menu_block_theme($existing, $type, $theme, $path);
...@@ -37,13 +30,72 @@ function menu_block_form_block_admin_display_form_alter(&$form, $form_state) { ...@@ -37,13 +30,72 @@ function menu_block_form_block_admin_display_form_alter(&$form, $form_state) {
module_load_include('inc', 'menu_block', 'menu_block.admin'); module_load_include('inc', 'menu_block', 'menu_block.admin');
return _menu_block_form_block_admin_display_form_alter($form, $form_state); return _menu_block_form_block_admin_display_form_alter($form, $form_state);
} }
/* -- temporarily remove until ctools is ported to D7.
function menu_block_ctools_plugin_directory($module, $plugin) { function menu_block_ctools_plugin_directory($module, $plugin) {
module_load_include('inc', 'menu_block', 'menu_block.admin'); module_load_include('inc', 'menu_block', 'menu_block.admin');
return _menu_block_ctools_plugin_directory($module, $plugin); return _menu_block_ctools_plugin_directory($module, $plugin);
} }
*/
/**
* Implements hook_menu().
*/
function menu_block_menu() {
// @todo Remove this check if block module is re-added as a dependency.
if (module_exists('block')) {
$items['admin/structure/block/add-menu-block'] = array(
'title' => 'Add menu block',
'description' => 'Add a new menu block.',
'page callback' => 'drupal_get_form',
'page arguments' => array('menu_block_add_block_form'),
'access arguments' => array('administer blocks'),
'type' => MENU_LOCAL_ACTION,
'file' => 'menu_block.admin.inc',
);
$default_theme = variable_get('theme_default', 'bartik');
foreach (list_themes() as $key => $theme) {
if ($key != $default_theme) {
$items['admin/structure/block/list/' . $key . '/add-menu-block'] = array(
'title' => 'Add menu block',
'description' => 'Add a new menu block.',
'page callback' => 'drupal_get_form',
'page arguments' => array('menu_block_add_block_form'),
'access arguments' => array('administer blocks'),
'type' => MENU_LOCAL_ACTION,
'file' => 'menu_block.admin.inc',
);
}
}
$items['admin/structure/block/delete-menu-block'] = array(
'title' => 'Delete menu block',
'page callback' => 'drupal_get_form',
'page arguments' => array('menu_block_delete'),
'access arguments' => array('administer blocks'),
'type' => MENU_CALLBACK,
'file' => 'menu_block.admin.inc',
);
}
$items['admin/config/user-interface/menu-block'] = array(
'title' => 'Menu block',
'description' => 'Configure menu block.',
'page callback' => 'drupal_get_form',
'page arguments' => array('menu_block_admin_settings_form'),
'access arguments' => array('administer blocks'),
'type' => MENU_NORMAL_ITEM,
'file' => 'menu_block.admin.inc',
);
return $items;
}
/**
* Implements hook_menu_alter().
*/
function menu_block_menu_alter(&$items) {
// Fake the necessary menu attributes necessary for a contextual link.
$items['admin/content/book/%node']['title'] = 'Edit book outline';
$items['admin/content/book/%node']['type'] = MENU_LOCAL_TASK;
$items['admin/content/book/%node']['context'] = (MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE);
$items['admin/content/book/%node']['tab_root'] = 'admin/content/book';
}
/** /**
* Implements hook_help(). * Implements hook_help().
...@@ -108,10 +160,6 @@ function menu_block_get_all_menus() { ...@@ -108,10 +160,6 @@ function menu_block_get_all_menus() {
else { else {
// Retrieve core's menus. // Retrieve core's menus.
$all_menus = menu_get_menus(); $all_menus = menu_get_menus();
// Include book support.
if (module_exists('book')) {
module_load_include('inc', 'menu_block', 'menu_block.book');
}
// Retrieve all the menu names provided by hook_menu_block_get_menus(). // Retrieve all the menu names provided by hook_menu_block_get_menus().
$all_menus = array_merge($all_menus, module_invoke_all('menu_block_get_menus')); $all_menus = array_merge($all_menus, module_invoke_all('menu_block_get_menus'));
// Add an option to use the menu for the active menu item. // Add an option to use the menu for the active menu item.
...@@ -228,11 +276,11 @@ function menu_tree_build($config) { ...@@ -228,11 +276,11 @@ function menu_tree_build($config) {
else { else {
// Check if the menu matches one of the available patterns. // Check if the menu matches one of the available patterns.
foreach (array_keys($patterns) as $pattern) { foreach (array_keys($patterns) as $pattern) {
if (preg_match($pattern, $item['menu_name'])) { if (preg_match($pattern, $item->menu_name)) {
// Mark the menu. // Mark the menu.
$menu_order[$pattern] = MENU_TREE__CURRENT_PAGE_MENU; $menu_order[$pattern] = MENU_TREE__CURRENT_PAGE_MENU;
// Store the actual menu name. // Store the actual menu name.
$patterns[$pattern] = $item['menu_name']; $patterns[$pattern] = $item->menu_name;
} }
} }
} }
...@@ -255,9 +303,6 @@ function menu_tree_build($config) { ...@@ -255,9 +303,6 @@ function menu_tree_build($config) {
$menu_names = menu_block_get_all_menus(); $menu_names = menu_block_get_all_menus();
menu_block_set_title(t($menu_names[$config['menu_name']])); menu_block_set_title(t($menu_names[$config['menu_name']]));
// @TODO: Remove work-around for core bug #942782.
__menu_block_set_menu_trail($config['menu_name']);
if ($config['expanded'] || $config['parent_mlid']) { if ($config['expanded'] || $config['parent_mlid']) {
// Get the full, un-pruned tree. // Get the full, un-pruned tree.
$tree = menu_tree_all_data($config['menu_name']); $tree = menu_tree_all_data($config['menu_name']);
...@@ -269,15 +314,12 @@ function menu_tree_build($config) { ...@@ -269,15 +314,12 @@ function menu_tree_build($config) {
$tree = menu_tree_page_data($config['menu_name']); $tree = menu_tree_page_data($config['menu_name']);
} }
// @TODO: Remove work-around for core bug #942782.
__menu_block_set_menu_trail();
// Allow alteration of the tree and config before we begin operations on it. // Allow alteration of the tree and config before we begin operations on it.
drupal_alter('menu_block_tree', $tree, $config); drupal_alter('menu_block_tree', $tree, $config);
// Localize the tree. // Localize the tree.
if (module_exists('i18nmenu')) { if (module_exists('i18n_menu')) {
i18nmenu_localize_tree($tree); $tree = i18n_menu_localize_tree($tree);
} }
// Prune the tree along the active trail to the specified level. // Prune the tree along the active trail to the specified level.
...@@ -673,3 +715,23 @@ function menu_block_tree_output(&$tree, $config = array()) { ...@@ -673,3 +715,23 @@ function menu_block_tree_output(&$tree, $config = array()) {
return $build; return $build;
} }
/**
* Implements hook_menu_block_get_menus() on behalf of book.module.
*/
function book_menu_block_get_menus() {
$menus = array();
foreach (book_get_books() AS $book) {
$menus[$book['menu_name']] = $book['title'];
}
return $menus;
}
/**
* Implements hook_menu_block_get_sort_menus() on behalf of book.module.
*/
function book_menu_block_get_sort_menus() {
return array(
'/^book\-toc\-.+/' => t('Book navigation'),
);
}
...@@ -5,33 +5,6 @@ ...@@ -5,33 +5,6 @@
* Provides infrequently used functions and hooks for menu_block_export. * Provides infrequently used functions and hooks for menu_block_export.
*/ */
/**
* Implements hook_menu().
*/
function _menu_block_export_menu() {
$items['admin/config/user-interface/menu-block/config'] = array(
'title' => 'Configure',
'type' => MENU_DEFAULT_LOCAL_TASK,
);
$items['admin/config/user-interface/menu-block/export'] = array(
'title' => 'export',
'description' => 'Export menu blocks.',
'access arguments' => array('administer blocks'),
'page callback' => 'menu_block_export_export',
'type' => MENU_LOCAL_TASK,
'file' => 'menu_block_export.admin.inc',
);
$items['admin/config/user-interface/menu-block/export/results'] = array(
'title' => 'Menu block bulk export results',
'description' => 'Exported menu blocks.',
'access arguments' => array('administer blocks'),
'page callback' => 'menu_block_export_export',
'type' => MENU_CALLBACK,
'file' => 'menu_block_export.admin.inc',
);
return $items;
}
/** /**
* Page callback to export menu blocks in bulk. * Page callback to export menu blocks in bulk.
*/ */
......
...@@ -10,9 +10,9 @@ files[] = menu_block_export.admin.inc ...@@ -10,9 +10,9 @@ files[] = menu_block_export.admin.inc
configure = admin/config/user-interface/menu-block/export configure = admin/config/user-interface/menu-block/export
; Information added by drupal.org packaging script on 2011-03-09 ; Information added by drupal.org packaging script on 2012-02-03
version = "7.x-2.2" version = "7.x-2.3"
core = "7.x" core = "7.x"
project = "menu_block" project = "menu_block"
datestamp = "1299683174" datestamp = "1328286646"
...@@ -5,8 +5,29 @@ ...@@ -5,8 +5,29 @@
* Provides export interface for Menu block. * Provides export interface for Menu block.
*/ */
// Off-load the following infrequently called hooks to another file. /**
* Implements hook_menu().
*/
function menu_block_export_menu() { function menu_block_export_menu() {
module_load_include('inc', 'menu_block_export', 'menu_block_export.admin'); $items['admin/config/user-interface/menu-block/config'] = array(
return _menu_block_export_menu(); 'title' => 'Configure',
'type' => MENU_DEFAULT_LOCAL_TASK,
);
$items['admin/config/user-interface/menu-block/export'] = array(
'title' => 'export',
'description' => 'Export menu blocks.',
'access arguments' => array('administer blocks'),
'page callback' => 'menu_block_export_export',
'type' => MENU_LOCAL_TASK,
'file' => 'menu_block_export.admin.inc',
);
$items['admin/config/user-interface/menu-block/export/results'] = array(
'title' => 'Menu block bulk export results',
'description' => 'Exported menu blocks.',
'access arguments' => array('administer blocks'),
'page callback' => 'menu_block_export_export',
'type' => MENU_CALLBACK,
'file' => 'menu_block_export.admin.inc',
);
return $items;
} }
...@@ -97,7 +97,7 @@ function menu_block_menu_tree_content_type_render($subtype, $conf, $args, $conte ...@@ -97,7 +97,7 @@ function menu_block_menu_tree_content_type_render($subtype, $conf, $args, $conte
/** /**
* 'Edit form' callback for the content type. * 'Edit form' callback for the content type.
*/ */
function menu_block_menu_tree_content_type_edit_form(&$form, &$form_state) { function menu_block_menu_tree_content_type_edit_form($form, &$form_state) {
$conf = $form_state['conf']; $conf = $form_state['conf'];
// Load the standard config form. // Load the standard config form.
...@@ -106,16 +106,20 @@ function menu_block_menu_tree_content_type_edit_form(&$form, &$form_state) { ...@@ -106,16 +106,20 @@ function menu_block_menu_tree_content_type_edit_form(&$form, &$form_state) {
$sub_form_state = array('values' => $conf); $sub_form_state = array('values' => $conf);
$form += menu_block_configure_form($form, $sub_form_state); $form += menu_block_configure_form($form, $sub_form_state);
// Hide the menu selector.
$form['menu_name']['#type'] = 'hidden';
// Set the options to a simple list of menu links for the configured menu. // Set the options to a simple list of menu links for the configured menu.
$menus = menu_block_get_all_menus(); $menus = menu_block_get_all_menus();
$form['parent']['#options'] = menu_parent_options(array($conf['menu_name'] => $menus[$conf['menu_name']]), array('mlid' => 0)); $form['parent_mlid']['#options'] = menu_parent_options(array($conf['menu_name'] => $menus[$conf['menu_name']]), array('mlid' => 0));
// Hide the Parent item option for the special "active" menu. // Hide the Parent item option for the special "active" menu.
if ($conf['menu_name'] == MENU_TREE__CURRENT_PAGE_MENU) { if ($conf['menu_name'] == MENU_TREE__CURRENT_PAGE_MENU) {
$form['parent']['#type'] = 'hidden'; $form['parent_mlid']['#type'] = 'hidden';
$form['admin_title']['#suffix'] = '<div id="edit-parent-wrapper"><strong>' . t('Parent item:') . '</strong><br />' . t('<em>The menu selected by the page</em> can be customized on the <a href="!url">Menu block settings page</a>.', array('!url' => url('admin/config/user-interface/menu-block'))) . '</div>';
} }
// Remove CSS class hooks for jQuery script on parent select. // Remove CSS class hooks for jQuery script on parent select.
unset($form['parent']['#attributes']); unset($form['parent_mlid']['#attributes']);
return $form;
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment