Commit 7155e01f authored by Dries's avatar Dries

- Patch #1697170 by tobiasb, nick_schuch, adamdicarlo, dagmar: convert...

- Patch #1697170 by tobiasb, nick_schuch, adamdicarlo, dagmar: convert menu_configure() to new configuration system.
parent 3ed46905
......@@ -1756,21 +1756,30 @@ function menu_list_system_menus() {
* Return an array of links to be rendered as the Main menu.
*/
function menu_main_menu() {
return menu_navigation_links(variable_get('menu_main_links_source', 'main-menu'));
$config = config('menu.settings');
$menu_enabled = module_exists('menu');
// When menu module is not enabled, we need a hardcoded default value.
$main_links_source = $menu_enabled ? $config->get('main_links') : 'main-menu';
return menu_navigation_links($main_links_source);
}
/**
* Return an array of links to be rendered as the Secondary links.
*/
function menu_secondary_menu() {
$config = config('menu.settings');
$menu_enabled = module_exists('menu');
// When menu module is not enabled, we need a hardcoded default value.
$main_links_source = $menu_enabled ? $config->get('main_links') : 'main-menu';
$secondary_links_source = $menu_enabled ? $config->get('secondary_links') : 'user-menu';
// If the secondary menu source is set as the primary menu, we display the
// second level of the primary menu.
if (variable_get('menu_secondary_links_source', 'user-menu') == variable_get('menu_main_links_source', 'main-menu')) {
return menu_navigation_links(variable_get('menu_main_links_source', 'main-menu'), 1);
if ($secondary_links_source == $main_links_source) {
return menu_navigation_links($main_links_source, 1);
}
else {
return menu_navigation_links(variable_get('menu_secondary_links_source', 'user-menu'), 0);
return menu_navigation_links($secondary_links_source, 0);
}
}
......
......@@ -678,8 +678,12 @@ function menu_reset_item_confirm_submit($form, &$form_state) {
/**
* Menu callback; Build the form presenting menu configuration options.
*
* @ingroup forms
* @see menu_configure_submit()
*/
function menu_configure() {
function menu_configure($form, &$form_state) {
$config = config('menu.settings');
$form['intro'] = array(
'#type' => 'item',
'#markup' => t('The menu module allows on-the-fly creation of menu links in the content authoring forms. To configure these settings for a particular content type, visit the <a href="@content-types">Content types</a> page, click the <em>edit</em> link for the content type, and go to the <em>Menu settings</em> section.', array('@content-types' => url('admin/structure/types'))),
......@@ -687,11 +691,11 @@ function menu_configure() {
$menu_options = menu_get_menus();
$main = variable_get('menu_main_links_source', 'main-menu');
$main = $config->get('main_links');
$form['menu_main_links_source'] = array(
'#type' => 'select',
'#title' => t('Source for the Main links'),
'#default_value' => variable_get('menu_main_links_source', 'main-menu'),
'#default_value' => $main,
'#empty_option' => t('No Main links'),
'#options' => $menu_options,
'#tree' => FALSE,
......@@ -701,12 +705,22 @@ function menu_configure() {
$form['menu_secondary_links_source'] = array(
'#type' => 'select',
'#title' => t('Source for the Secondary links'),
'#default_value' => variable_get('menu_secondary_links_source', 'user-menu'),
'#default_value' => $config->get('secondary_links'),
'#empty_option' => t('No Secondary links'),
'#options' => $menu_options,
'#tree' => FALSE,
'#description' => t('Select the source for the Secondary links. An advanced option allows you to use the same source for both Main links (currently %main) and Secondary links: if your source menu has two levels of hierarchy, the top level menu links will appear in the Main links, and the children of the active link will appear in the Secondary links.', array('%main' => $main ? $menu_options[$main] : t('none'))),
);
return system_settings_form($form);
return system_config_form($form, $form_state);
}
/**
* Form submission handler for menu_configure().
*/
function menu_configure_submit($form, &$form_state) {
config('menu.settings')
->set('main_links', $form_state['values']['menu_main_links_source'])
->set('secondary_links', $form_state['values']['menu_secondary_links_source'])
->save();
}
......@@ -69,3 +69,14 @@ function menu_uninstall() {
menu_router_rebuild();
}
/**
* Moves menu settings from variables to config.
*
* @ingroup config_upgrade
*/
function menu_update_8000() {
update_variables_to_config('menu.settings', array(
'menu_main_links_source' => 'main_links',
'menu_secondary_links_source' => 'secondary_links',
));
}
check:
disabled_extensions: '0'
interval_days: '1'
fetch:
url: ''
max_attempts: '2'
timeout: '5'
notification:
emails: []
threshold: '0'
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