Commit 7f85abe0 authored by Gábor Hojtsy's avatar Gábor Hojtsy

#191360 by chx: allow contributed modules to override the book and menu parent...

#191360 by chx: allow contributed modules to override the book and menu parent selectors (to improve usability and performance)
parent 8e73e460
......@@ -328,6 +328,9 @@ function book_form_alter(&$form, $form_state, $form_id) {
* form element.
*/
function _book_parent_select($book_link) {
if (variable_get('menu_override_parent_selector', FALSE)) {
return array();
}
// Offer a message or a drop-down to choose a different parent page.
$form = array(
'#type' => 'hidden',
......
......@@ -229,6 +229,7 @@ function menu_edit_item(&$form_state, $type, $item, $menu) {
'#tree' => TRUE,
'#weight' => -2,
'#attributes' => array('class' => 'menu-item-form'),
'#item' => $item,
);
if ($type == 'add' || empty($item)) {
// This is an add form, initialize the menu link.
......
......@@ -202,7 +202,13 @@ function menu_load($menu_name) {
* and mlid. The list excludes the given item and its children.
*/
function menu_parent_options($menus, $item) {
// The menu_links table can be practically any size and we need a way to
// allow contrib modules to provide more scalable pattern choosers.
// hook_form_alter is too late in itself because all the possible parents are
// retrieved here, unless menu_override_parent_selector is set to TRUE.
if (variable_get('menu_override_parent_selector', FALSE)) {
return array();
}
// If the item has children, there is an added limit to the depth of valid parents.
if (isset($item['parent_depth_limit'])) {
$limit = $item['parent_depth_limit'];
......@@ -378,6 +384,7 @@ function menu_form_alter(&$form, $form_state, $form_id) {
foreach (array('mlid', 'module', 'hidden', 'has_children', 'customized', 'options', 'expanded', 'hidden', 'parent_depth_limit') as $key) {
$form['menu'][$key] = array('#type' => 'value', '#value' => $item[$key]);
}
$form['menu']['#item'] = $item;
$form['menu']['link_title'] = array('#type' => 'textfield',
'#title' => t('Menu link title'),
......
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