core/config/schema/core.data_types.schema.yml | 6 -- core/includes/common.inc | 14 ----- core/includes/menu.inc | 66 ------------------- core/includes/theme.inc | 20 ------ core/lib/Drupal/Core/Extension/ThemeHandler.php | 2 - .../Core/Menu/DefaultMenuLinkTreeManipulators.php | 27 -------- .../menu_ui/config/install/menu_ui.settings.yml | 2 - .../menu_ui/config/schema/menu_ui.schema.yml | 6 -- core/modules/menu_ui/menu_ui.links.task.yml | 6 -- core/modules/menu_ui/menu_ui.routing.yml | 8 --- core/modules/menu_ui/src/MenuSettingsForm.php | 73 ---------------------- .../system/config/install/system.theme.global.yml | 2 - core/modules/system/src/Form/ThemeSettingsForm.php | 2 - .../system/src/Tests/System/PageTitleTest.php | 2 - core/modules/system/system.module | 2 - core/modules/system/templates/page.html.twig | 5 +- .../block.block.bartik_mainnavigation_level1.yml | 25 ++++++++ .../block.block.bartik_useraccountmenu_level1.yml | 25 ++++++++ .../Menu/DefaultMenuLinkTreeManipulatorsTest.php | 59 ----------------- core/themes/bartik/bartik.theme | 4 +- core/themes/bartik/templates/page.html.twig | 9 +-- core/themes/seven/templates/page.html.twig | 3 - 22 files changed, 59 insertions(+), 309 deletions(-) diff --git a/core/config/schema/core.data_types.schema.yml b/core/config/schema/core.data_types.schema.yml index 248a072..76aec51 100644 --- a/core/config/schema/core.data_types.schema.yml +++ b/core/config/schema/core.data_types.schema.yml @@ -160,12 +160,6 @@ theme_settings: node_user_picture: type: boolean label: 'User pictures in posts' - main_menu: - type: boolean - label: 'Main menu' - secondary_menu: - type: boolean - label: 'Secondary menu' slogan: type: boolean label: 'Site slogan' diff --git a/core/includes/common.inc b/core/includes/common.inc index 5a90646..4ad7a2f 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -2543,20 +2543,6 @@ function drupal_prepare_page($page) { \Drupal::moduleHandler()->alter('page', $page); \Drupal::theme()->alter('page', $page); - // The "main" and "secondary" menus are never part of the page-level render - // array and therefore their cache tags will never bubble up into the page - // cache, even though they should be. This happens because they're rendered - // directly by the theme system. - // @todo Remove this once https://drupal.org/node/1869476 lands. - if (theme_get_setting('features.main_menu') && count(menu_main_menu())) { - $main_links_source = _menu_get_links_source('main_links', 'main'); - $page['page_top']['#cache']['tags']['menu'][$main_links_source] = $main_links_source; - } - if (theme_get_setting('features.secondary_menu') && count(menu_secondary_menu())) { - $secondary_links_source = _menu_get_links_source('secondary_links', 'account'); - $page['page_top']['#cache']['tags']['menu'][$secondary_links_source] = $secondary_links_source; - } - // If no module has taken care of the main content, add it to the page now. // This allows the site to still be usable even if no modules that // control page regions (for example, the Block module) are enabled. diff --git a/core/includes/menu.inc b/core/includes/menu.inc index 68c3c54..585aea5 100644 --- a/core/includes/menu.inc +++ b/core/includes/menu.inc @@ -465,72 +465,6 @@ function menu_list_system_menus() { } /** - * Returns an array of links to be rendered as the Main menu. - */ -function menu_main_menu() { - $main_links_source = _menu_get_links_source('main_links', 'main'); - return menu_navigation_links($main_links_source); -} - -/** - * Returns an array of links to be rendered as the Secondary links. - */ -function menu_secondary_menu() { - $main_links_source = _menu_get_links_source('main_links', 'main'); - $secondary_links_source = _menu_get_links_source('secondary_links', 'account'); - - // If the secondary menu source is set as the primary menu, we display the - // second level of the primary menu. - if ($secondary_links_source == $main_links_source) { - return menu_navigation_links($main_links_source, 1); - } - else { - return menu_navigation_links($secondary_links_source, 0); - } -} - -/** - * Returns the source of links of a menu. - * - * @param string $name - * A string configuration key of menu link source. - * @param string $default - * Default menu name. - * - * @return string - * Returns menu name, if exist - */ -function _menu_get_links_source($name, $default) { - $config = \Drupal::config('menu_ui.settings'); - return \Drupal::moduleHandler()->moduleExists('menu_ui') ? $config->get($name) : $default; -} - -/** - * Builds a renderable array for a navigation menu. - * - * @param string $menu_name - * The name of the menu. - * @param int $level - * Optional, the depth of the menu to be returned. - * - * @return array - * A renderable array. - */ -function menu_navigation_links($menu_name, $level = 0) { - $menu_tree = \Drupal::menuTree(); - $parameters = $menu_tree->getCurrentRouteMenuTreeParameters($menu_name); - $parameters->setMaxDepth($level + 1); - $tree = $menu_tree->load($menu_name, $parameters); - $manipulators = array( - array('callable' => 'menu.default_tree_manipulators:checkAccess'), - array('callable' => 'menu.default_tree_manipulators:generateIndexAndSort'), - array('callable' => 'menu.default_tree_manipulators:extractSubtreeOfActiveTrail', 'args' => array($level)), - ); - $tree = $menu_tree->transform($tree, $manipulators); - return $menu_tree->build($tree); -} - -/** * Collects the local tasks (tabs), action links, and the root path. * * @param int $level diff --git a/core/includes/theme.inc b/core/includes/theme.inc index d811f4d..0be1fa3 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -1806,8 +1806,6 @@ function template_preprocess_page(&$variables) { $variables['site_slogan'] = (theme_get_setting('features.slogan') ? Xss::filterAdmin($site_config->get('slogan')) : ''); if (!defined('MAINTENANCE_MODE')) { - $variables['main_menu'] = theme_get_setting('features.main_menu') ? menu_main_menu() : array(); - $variables['secondary_menu'] = theme_get_setting('features.secondary_menu') ? menu_secondary_menu() : array(); $variables['action_links'] = menu_get_local_actions(); $variables['tabs'] = menu_local_tabs(); @@ -1825,29 +1823,11 @@ function template_preprocess_page(&$variables) { } } else { - $variables['main_menu'] = array(); - $variables['secondary_menu'] = array(); $variables['action_links'] = array(); $variables['tabs'] = array(); $variables['feed_icons'] = ''; } - // Pass the main menu and secondary menu to the template as render arrays. - if (!empty($variables['main_menu'])) { - $variables['main_menu']['#heading'] = array( - 'text' => t('Main menu'), - 'class' => array('visually-hidden'), - 'attributes' => array('id' => 'links__system_main_menu'), - ); - } - if (!empty($variables['secondary_menu'])) { - $variables['secondary_menu']['#heading'] = array( - 'text' => t('Secondary menu'), - 'class' => array('visually-hidden'), - 'attributes' => array('id' => 'links__system_secondary_menu'), - ); - } - if ($node = \Drupal::routeMatch()->getParameter('node')) { $variables['node'] = $node; } diff --git a/core/lib/Drupal/Core/Extension/ThemeHandler.php b/core/lib/Drupal/Core/Extension/ThemeHandler.php index d9ef77e..5641c7b 100644 --- a/core/lib/Drupal/Core/Extension/ThemeHandler.php +++ b/core/lib/Drupal/Core/Extension/ThemeHandler.php @@ -34,8 +34,6 @@ class ThemeHandler implements ThemeHandlerInterface { 'node_user_picture', 'comment_user_picture', 'comment_user_verification', - 'main_menu', - 'secondary_menu', ); /** diff --git a/core/lib/Drupal/Core/Menu/DefaultMenuLinkTreeManipulators.php b/core/lib/Drupal/Core/Menu/DefaultMenuLinkTreeManipulators.php index 0c0d9ba..44b751b 100644 --- a/core/lib/Drupal/Core/Menu/DefaultMenuLinkTreeManipulators.php +++ b/core/lib/Drupal/Core/Menu/DefaultMenuLinkTreeManipulators.php @@ -155,31 +155,4 @@ public function flatten(array $tree) { return $tree; } - /** - * Extracts a subtree of the active trail. - * - * @param \Drupal\Core\Menu\MenuLinkTreeElement[] $tree - * The menu link tree to manipulate. - * @param int $level - * The level in the active trail to extract. - * - * @return \Drupal\Core\Menu\MenuLinkTreeElement[] - * The manipulated menu link tree. - */ - public function extractSubtreeOfActiveTrail(array $tree, $level) { - // Go down the active trail until the right level is reached. - while ($level-- > 0 && $tree) { - // Loop through the current level's elements until we find one that is in - // the active trail. - while ($element = array_shift($tree)) { - if ($element->inActiveTrail) { - // If the element is in the active trail, we continue in the subtree. - $tree = $element->subtree; - break; - } - } - } - return $tree; - } - } diff --git a/core/modules/menu_ui/config/install/menu_ui.settings.yml b/core/modules/menu_ui/config/install/menu_ui.settings.yml index a79ac97..c3ee6fb 100644 --- a/core/modules/menu_ui/config/install/menu_ui.settings.yml +++ b/core/modules/menu_ui/config/install/menu_ui.settings.yml @@ -1,3 +1 @@ -main_links: main -secondary_links: account override_parent_selector: false diff --git a/core/modules/menu_ui/config/schema/menu_ui.schema.yml b/core/modules/menu_ui/config/schema/menu_ui.schema.yml index 7625f0d..6d9d7eb 100644 --- a/core/modules/menu_ui/config/schema/menu_ui.schema.yml +++ b/core/modules/menu_ui/config/schema/menu_ui.schema.yml @@ -4,12 +4,6 @@ menu_ui.settings: type: mapping label: 'Menu settings' mapping: - main_links: - type: string - label: 'Main links' - secondary_links: - type: string - label: 'Source for secondary links' override_parent_selector: type: boolean label: 'Override parent selector' diff --git a/core/modules/menu_ui/menu_ui.links.task.yml b/core/modules/menu_ui/menu_ui.links.task.yml index 92aadeb..1248076 100644 --- a/core/modules/menu_ui/menu_ui.links.task.yml +++ b/core/modules/menu_ui/menu_ui.links.task.yml @@ -7,9 +7,3 @@ menu_ui.overview_page: title: 'List' route_name: menu_ui.overview_page base_route: menu_ui.overview_page - -menu_ui.settings: - title: 'Settings' - route_name: menu_ui.settings - base_route: menu_ui.overview_page - weight: 100 diff --git a/core/modules/menu_ui/menu_ui.routing.yml b/core/modules/menu_ui/menu_ui.routing.yml index b095c34..6a712cc 100644 --- a/core/modules/menu_ui/menu_ui.routing.yml +++ b/core/modules/menu_ui/menu_ui.routing.yml @@ -1,11 +1,3 @@ -menu_ui.settings: - path: '/admin/structure/menu/settings' - defaults: - _form: 'Drupal\menu_ui\MenuSettingsForm' - _title: 'Menus' - requirements: - _permission: 'administer menu' - menu_ui.overview_page: path: '/admin/structure/menu' defaults: diff --git a/core/modules/menu_ui/src/MenuSettingsForm.php b/core/modules/menu_ui/src/MenuSettingsForm.php deleted file mode 100644 index 9037bb5..0000000 --- a/core/modules/menu_ui/src/MenuSettingsForm.php +++ /dev/null @@ -1,73 +0,0 @@ -config('menu_ui.settings'); - $form['intro'] = array( - '#type' => 'item', - '#markup' => t('The Menu UI 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 Content types page, click the edit link for the content type, and go to the Menu settings section.', array('@content-types' => url('admin/structure/types'))), - ); - - $menu_options = menu_ui_get_menus(); - - $main = $config->get('main_links'); - $form['menu_main_links_source'] = array( - '#type' => 'select', - '#title' => t('Source for the Main links'), - '#default_value' => $main, - '#empty_option' => t('No Main links'), - '#options' => $menu_options, - '#tree' => FALSE, - '#description' => t('Select what should be displayed as the Main links (typically at the top of the page).'), - ); - - $form['menu_secondary_links_source'] = array( - '#type' => 'select', - '#title' => t('Source for the Secondary links'), - '#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 parent::buildForm($form, $form_state); - } - - /** - * {@inheritdoc} - */ - public function submitForm(array &$form, FormStateInterface $form_state) { - $this->config('menu_ui.settings') - ->set('main_links', $form_state->getValue('menu_main_links_source')) - ->set('secondary_links', $form_state->getValue('menu_secondary_links_source')) - ->save(); - - parent::submitForm($form, $form_state); - } - -} diff --git a/core/modules/system/config/install/system.theme.global.yml b/core/modules/system/config/install/system.theme.global.yml index 13036bf..5ee6cc7 100644 --- a/core/modules/system/config/install/system.theme.global.yml +++ b/core/modules/system/config/install/system.theme.global.yml @@ -10,8 +10,6 @@ features: logo: true name: true node_user_picture: true - main_menu: true - secondary_menu: true slogan: true logo: path: '' diff --git a/core/modules/system/src/Form/ThemeSettingsForm.php b/core/modules/system/src/Form/ThemeSettingsForm.php index 85a58a5..0d3fd9f 100644 --- a/core/modules/system/src/Form/ThemeSettingsForm.php +++ b/core/modules/system/src/Form/ThemeSettingsForm.php @@ -106,8 +106,6 @@ public function buildForm(array $form, FormStateInterface $form_state, $theme = 'comment_user_picture' => t('User pictures in comments'), 'comment_user_verification' => t('User verification status in comments'), 'favicon' => t('Shortcut icon'), - 'main_menu' => t('Main menu'), - 'secondary_menu' => t('Secondary menu'), ); // Some features are not always available diff --git a/core/modules/system/src/Tests/System/PageTitleTest.php b/core/modules/system/src/Tests/System/PageTitleTest.php index 6b2d249..4516a57 100644 --- a/core/modules/system/src/Tests/System/PageTitleTest.php +++ b/core/modules/system/src/Tests/System/PageTitleTest.php @@ -75,8 +75,6 @@ function testTitleXSS() { $edit = array( 'toggle_name' => TRUE, 'toggle_slogan' => TRUE, - 'toggle_main_menu' => TRUE, - 'toggle_secondary_menu' => TRUE, ); $this->drupalPostForm('admin/appearance/settings', $edit, t('Save configuration')); diff --git a/core/modules/system/system.module b/core/modules/system/system.module index a5c4123..f8f55ef 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -967,8 +967,6 @@ function _system_default_theme_features() { 'node_user_picture', 'comment_user_picture', 'comment_user_verification', - 'main_menu', - 'secondary_menu', ); } diff --git a/core/modules/system/templates/page.html.twig b/core/modules/system/templates/page.html.twig index ba013a2..430f860 100644 --- a/core/modules/system/templates/page.html.twig +++ b/core/modules/system/templates/page.html.twig @@ -26,9 +26,6 @@ * slogan has been disabled in theme settings. * * Navigation: - * - main_menu: The Main menu links for the site, if they have been configured. - * - secondary_menu: The Secondary menu links for the site, if they have been - * configured. * - breadcrumb: The breadcrumb trail for the current page. * * Page content (in order of occurrence in the default page.html.twig): @@ -95,12 +92,14 @@ {{ page.header }} +{# @todo Figure out how to replace this. {% if main_menu or secondary_menu %} {% endif %} +#} {{ breadcrumb }} diff --git a/core/profiles/standard/config/install/block.block.bartik_mainnavigation_level1.yml b/core/profiles/standard/config/install/block.block.bartik_mainnavigation_level1.yml new file mode 100644 index 0000000..e1071ba --- /dev/null +++ b/core/profiles/standard/config/install/block.block.bartik_mainnavigation_level1.yml @@ -0,0 +1,25 @@ +id: bartik_mainnavigation_level1 +theme: bartik +weight: 0 +status: true +langcode: en +region: header +plugin: 'system_menu_block:main' +settings: + visibility: {} + id: 'system_menu_block:main' + label: 'Main navigation (level 1)' + provider: system + label_display: '0' + cache: + max_age: -1 + contexts: { } + level: 1 + depth: 1 +dependencies: + entity: + - system.menu.main + module: + - system + theme: + - bartik diff --git a/core/profiles/standard/config/install/block.block.bartik_useraccountmenu_level1.yml b/core/profiles/standard/config/install/block.block.bartik_useraccountmenu_level1.yml new file mode 100644 index 0000000..3c91b29 --- /dev/null +++ b/core/profiles/standard/config/install/block.block.bartik_useraccountmenu_level1.yml @@ -0,0 +1,25 @@ +id: bartik_useraccountmenu_level1 +theme: bartik +weight: 0 +status: true +langcode: en +region: header +plugin: 'system_menu_block:account' +settings: + visibility: { } + id: 'system_menu_block:account' + label: 'User account menu (level 1)' + provider: system + label_display: '0' + cache: + max_age: -1 + contexts: { } + level: 1 + depth: 1 +dependencies: + entity: + - system.menu.account + module: + - system + theme: + - bartik diff --git a/core/tests/Drupal/Tests/Core/Menu/DefaultMenuLinkTreeManipulatorsTest.php b/core/tests/Drupal/Tests/Core/Menu/DefaultMenuLinkTreeManipulatorsTest.php index 6a01efa..9514d1f 100644 --- a/core/tests/Drupal/Tests/Core/Menu/DefaultMenuLinkTreeManipulatorsTest.php +++ b/core/tests/Drupal/Tests/Core/Menu/DefaultMenuLinkTreeManipulatorsTest.php @@ -217,63 +217,4 @@ public function testFlatten() { $this->assertEquals(array(1, 2, 5, 6, 8, 3, 4, 7), array_keys($tree)); } - /** - * Tests the extractSubtreeOfActiveTrail() tree manipulator. - * - * @covers ::extractSubtreeOfActiveTrail - */ - public function testExtractSubtreeOfActiveTrail() { - // No link in the active trail. - $this->mockTree(); - // Get level 0. - $tree = $this->defaultMenuTreeManipulators->extractSubtreeOfActiveTrail($this->originalTree, 0); - $this->assertEquals(array(1, 2, 5, 6, 8), array_keys($tree)); - // Get level 1. - $tree = $this->defaultMenuTreeManipulators->extractSubtreeOfActiveTrail($this->originalTree, 1); - $this->assertEquals(array(), array_keys($tree)); - // Get level 2. - $tree = $this->defaultMenuTreeManipulators->extractSubtreeOfActiveTrail($this->originalTree, 1); - $this->assertEquals(array(), array_keys($tree)); - - // Link 5 in the active trail. - $this->mockTree(); - $this->originalTree[5]->inActiveTrail = TRUE; - // Get level 0. - $tree = $this->defaultMenuTreeManipulators->extractSubtreeOfActiveTrail($this->originalTree, 0); - $this->assertEquals(array(1, 2, 5, 6, 8), array_keys($tree)); - // Get level 1. - $tree = $this->defaultMenuTreeManipulators->extractSubtreeOfActiveTrail($this->originalTree, 1); - $this->assertEquals(array(7), array_keys($tree)); - // Get level 2. - $tree = $this->defaultMenuTreeManipulators->extractSubtreeOfActiveTrail($this->originalTree, 2); - $this->assertEquals(array(), array_keys($tree)); - - // Link 2 in the active trail. - $this->mockTree(); - $this->originalTree[2]->inActiveTrail = TRUE; - // Get level 0. - $tree = $this->defaultMenuTreeManipulators->extractSubtreeOfActiveTrail($this->originalTree, 0); - $this->assertEquals(array(1, 2, 5, 6, 8), array_keys($tree)); - // Get level 1. - $tree = $this->defaultMenuTreeManipulators->extractSubtreeOfActiveTrail($this->originalTree, 1); - $this->assertEquals(array(3), array_keys($tree)); - // Get level 2. - $tree = $this->defaultMenuTreeManipulators->extractSubtreeOfActiveTrail($this->originalTree, 2); - $this->assertEquals(array(), array_keys($tree)); - - // Links 2 and 3 in the active trail. - $this->mockTree(); - $this->originalTree[2]->inActiveTrail = TRUE; - $this->originalTree[2]->subtree[3]->inActiveTrail = TRUE; - // Get level 0. - $tree = $this->defaultMenuTreeManipulators->extractSubtreeOfActiveTrail($this->originalTree, 0); - $this->assertEquals(array(1, 2, 5, 6, 8), array_keys($tree)); - // Get level 1. - $tree = $this->defaultMenuTreeManipulators->extractSubtreeOfActiveTrail($this->originalTree, 1); - $this->assertEquals(array(3), array_keys($tree)); - // Get level 2. - $tree = $this->defaultMenuTreeManipulators->extractSubtreeOfActiveTrail($this->originalTree, 2); - $this->assertEquals(array(4), array_keys($tree)); - } - } diff --git a/core/themes/bartik/bartik.theme b/core/themes/bartik/bartik.theme index 27f8973..bf18698 100644 --- a/core/themes/bartik/bartik.theme +++ b/core/themes/bartik/bartik.theme @@ -54,7 +54,7 @@ function bartik_preprocess_page(&$variables) { // Store back the classes to the htmlpage object. $attributes['class'] = $classes; - +/* @todo Figure out how to replace this. // Set additional attributes on the primary and secondary navigation menus. if (!empty($variables['main_menu'])) { $variables['main_menu']['#attributes']['id'] = 'main-menu-links'; @@ -65,7 +65,7 @@ function bartik_preprocess_page(&$variables) { $variables['secondary_menu']['#attributes']['class'][] = 'links'; $variables['secondary_menu']['#attributes']['class'][] = 'inline'; } - +*/ // Set the options that apply to both page and maintenance page. _bartik_process_page($variables); diff --git a/core/themes/bartik/templates/page.html.twig b/core/themes/bartik/templates/page.html.twig index 2456642..e5beb79 100644 --- a/core/themes/bartik/templates/page.html.twig +++ b/core/themes/bartik/templates/page.html.twig @@ -33,9 +33,6 @@ * added to make the site slogan visually hidden, but still accessible. * * Navigation: - * - main_menu: The Main menu links for the site, if they have been configured. - * - secondary_menu: The Secondary menu links for the site, if they have been - * configured. * - breadcrumb: The breadcrumb trail for the current page. * * Page content (in order of occurrence in the default page.html.twig): @@ -79,12 +76,14 @@ #}