Commit e4186f55 authored by Dave Reid's avatar Dave Reid

Merge branch '7.x-2.x' into 7.x-3.x

parents 6d258ef4 68ee87ba
......@@ -360,6 +360,17 @@ function menu_block_configure_form($form, &$form_state) {
),
'#description' => t('From the starting level, specify the maximum depth of the menu tree.'),
);
$form['depth_relative'] = array(
'#type' => 'checkbox',
'#title' => t('Make the maximum depth relative to the starting level while following the active menu item.'),
'#default_value' => $config['depth_relative'],
'#states' => array(
'visible' => array(
':input[name=follow]' => array('checked' => TRUE),
':input[name=depth]' => array('!value' => '0'),
),
),
);
$form['expanded'] = array(
'#type' => 'checkbox',
'#title' => t('<strong>Expand all children</strong> of this tree.'),
......@@ -384,7 +395,7 @@ function menu_block_configure_form($form, &$form_state) {
$form['menu-block-wrapper-close'] = array('#markup' => '</div>');
// Set visibility of advanced options.
foreach (array('title_link', 'follow', 'follow_parent', 'expanded', 'sort', 'parent') as $key) {
foreach (array('title_link', 'follow', 'depth_relative', 'follow_parent', 'expanded', 'sort', 'parent') as $key) {
$form[$key]['#states']['visible'][':input[name=display_options]'] = array('value' => 'advanced');
}
if ($config['title_link'] || $follow || $config['expanded'] || $config['sort'] || $config['parent_mlid']) {
......@@ -433,6 +444,7 @@ function _menu_block_block_save($delta = '', $edit = array()) {
variable_set("menu_block_{$delta}_level", $edit['level']);
variable_set("menu_block_{$delta}_follow", $edit['follow']);
variable_set("menu_block_{$delta}_depth", $edit['depth']);
variable_set("menu_block_{$delta}_depth_relative", $edit['depth_relative']);
variable_set("menu_block_{$delta}_expanded", $edit['expanded']);
variable_set("menu_block_{$delta}_sort", $edit['sort']);
}
......@@ -509,12 +521,9 @@ function menu_block_admin_settings_form($form, &$form_state) {
'#markup' => '<p>' . t('The above list will <em>not</em> affect menu blocks that are configured to use a specific menu.') . '</p>',
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save configuration'),
);
$form['#submit'][] = 'menu_block_admin_settings_form_submit';
return $form;
return system_settings_form($form);
}
/**
......@@ -528,20 +537,19 @@ function menu_block_admin_settings_form_submit($form, &$form_state) {
$menu_order[$menu_name] = (int) $row['weight'];
}
}
// Clear menu_order before it's written to the variable table by system_settings_form_submit().
unset($form_state['values']['menu_order']);
// Sort the keys by the weight stored in the value.
asort($menu_order);
foreach ($menu_order as $menu_name => $weight) {
// Now that the array is sorted, the weight is redundant data.
$menu_order[$menu_name] = '';
}
variable_set('menu_block_menu_order', $menu_order);
if ($form_state['values']['menu_block_suppress_core']) {
variable_set('menu_block_suppress_core', 1);
}
else {
variable_del('menu_block_suppress_core');
}
drupal_set_message(t('The configuration options have been saved.'));
// Add the menu_order to the values.
$form_state['values']['menu_block_menu_order'] = $menu_order;
}
/**
......
......@@ -5,7 +5,7 @@
*/
/**
* Denotes that the tree should use the menu picked by the curent page.
* Denotes that the tree should use the menu picked by the current page.
*/
define('MENU_TREE__CURRENT_PAGE_MENU', '_active');
......@@ -242,6 +242,7 @@ function menu_block_default_config() {
'level' => 1,
'follow' => 0,
'depth' => 0,
'depth_relative' => 0,
'expanded' => 0,
'sort' => 0,
);
......@@ -346,7 +347,7 @@ function menu_tree_block_data(array &$config) {
if ($config['expanded'] || $config['parent_mlid']) {
// Get the full, un-pruned tree.
if ($config['parent_mlid']) {
if ($config['parent_mlid'] || !empty($config['depth_relative'])) {
$tree = menu_tree_all_data($config['menu_name']);
}
else {
......@@ -356,8 +357,13 @@ function menu_tree_block_data(array &$config) {
menu_tree_add_active_path($tree);
}
else {
// Get the tree pruned for just the active trail.
$tree = menu_tree_page_data($config['menu_name'], $max_depth);
if (!empty($config['depth_relative'])) {
// Get the tree pruned for just the active trail.
$tree = menu_tree_page_data($config['menu_name']);
}
else {
$tree = menu_tree_page_data($config['menu_name'], $max_depth);
}
}
// Allow alteration of the tree and config before we begin operations on it.
......
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