From ffdfe048580748a9dbcfdfdc3bf8c0b0b7f6bddb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Hojtsy?= Date: Wed, 29 Aug 2007 16:16:50 +0000 Subject: #103391 by m3avrck, RobRoy and dvessel: cleanup active list item classes --- includes/theme.inc | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/includes/theme.inc b/includes/theme.inc index c9e41401e..026ce50ac 100644 --- a/includes/theme.inc +++ b/includes/theme.inc @@ -1096,27 +1096,19 @@ function theme_links($links, $attributes = array('class' => 'links')) { $i = 1; foreach ($links as $key => $link) { - $class = ''; + $class = $key; - // Automatically add a class to each link and also to each LI - if (isset($link['attributes']) && isset($link['attributes']['class'])) { - $link['attributes']['class'] .= ' '. $key; - $class = $key; - } - else { - $link['attributes']['class'] = $key; - $class = $key; - } - - // Add first and last classes to the list of links to help out themers. - $extra_class = ''; + // Add first, last and active classes to the list of links to help out themers. if ($i == 1) { - $extra_class .= 'first '; + $class .= ' first'; } if ($i == $num_links) { - $extra_class .= 'last '; + $class .= ' last'; + } + if ($link['href'] == $_GET['q']) { + $class .= ' active'; } - $output .= '
  • '; + $output .= '
  • '; if (isset($link['href'])) { // Pass in $link as $options, they share the same keys. @@ -1127,7 +1119,11 @@ function theme_links($links, $attributes = array('class' => 'links')) { if (empty($link['html'])) { $link['title'] = check_plain($link['title']); } - $output .= ''. $link['title'] .''; + $span_attributes = ''; + if (isset($link['attributes'])) { + $span_attributes = drupal_attributes($link['attributes']); + } + $output .= ''. $link['title'] .''; } $i++; -- cgit v1.2.3