diff --cc core/includes/theme.inc index 45c794a,4d8e238..0000000 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@@ -1678,6 -1677,8 +1677,9 @@@ function theme_links($variables) $num_links = count($links); $i = 0; + $active = \Drupal::linkGenerator()->getActive(); ++ $language_url = language(Language::TYPE_URL); + foreach ($links as $key => $link) { $i++; @@@ -1693,12 -1700,41 +1701,40 @@@ $class[] = 'last'; } - $link += array( - 'href' => NULL, + $link_element = array( + '#type' => 'link', + '#title' => $link['title'], + '#options' => array_diff_key($link, MapArray::copyValuesToKeys(array('title', 'href', 'route_name', 'route_parameters'))), + '#href' => $link['href'], + '#route_name' => $link['route_name'], + '#route_parameters' => $link['route_parameters'], ); - // Handle links. - if (isset($link['href']) || isset($link['route_name'])) { + // @todo Reconcile Views usage of 'ajax' as a boolean with the rest of + // core's usage of it as an array. + if (isset($link['ajax']) && is_array($link['ajax'])) { + $link_element['#ajax'] = $link['ajax']; + } + + // Handle links and ensure that the active class is added on the LIs. + if (isset($link['route_name'])) { + $variables = array( + 'options' => array(), + ); + if (!empty($link['language'])) { + $variables['options']['language'] = $link['language']; + } + + if (($link['route_name'] == $active['route_name']) + // The language of an active link is equal to the current language. + && (empty($variables['options']['language']) || ($variables['options']['language']->id == $active['language'])) + && ($link['route_parameters'] == $active['parameters'])) { + $class[] = 'active'; + } + + $item = drupal_render($link_element); + } + elseif (isset($link['href'])) { - $language_url = language(Language::TYPE_URL); $is_current_path = ($link['href'] == current_path() || ($link['href'] == '' && drupal_is_front_page())); $is_current_language = (empty($link['language']) || $link['language']->id == $language_url->id); if ($is_current_path && $is_current_language) {