From 1b291a2917a1c18194c54fce8bf0fd895db98019 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Thu, 18 May 2006 14:58:57 +0000 Subject: - Patch #18260 by Ber, m3averck et al: allow overriding of links returned by modules --- includes/theme.inc | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'includes/theme.inc') diff --git a/includes/theme.inc b/includes/theme.inc index 19e0f4b71..89f388dce 100644 --- a/includes/theme.inc +++ b/includes/theme.inc @@ -486,17 +486,36 @@ function theme_status_messages() { * Return a themed set of links. * * @param $links - * An array of links to be themed. + * A keyed array of links to be themed. * @param $delimiter * A string used to separate the links. * @return * A string containing the themed links. */ function theme_links($links, $delimiter = ' | ') { - if (!is_array($links)) { - return ''; + $output = array(); + + if (is_array($links)) { + foreach ($links as $key => $link) { + //Automatically add a class to each link and convert all _ to - for XHTML compliance + if (isset($link['#attributes']) && isset($link['#attributes']['class'])) { + $link['#attributes']['class'] .= ' '. str_replace('_', '-', $key); + } + else { + $link['#attributes']['class'] = str_replace('_', '-', $key); + } + + if ($link['#href']) { + $output[] = l($link['#title'], $link['#href'], $link['#attributes'], $link['#query'], $link['#fragment']); + } + else if ($link['#title']) { + //Some links are actually not links, but we wrap these in for adding title and class attributes + $output[] = ''. $link['#title'] .''; + } + } } - return implode($delimiter, $links); + + return implode($delimiter, $output); } /** -- cgit v1.2.3