diff options
author | Dries Buytaert <dries@buytaert.net> | 2006-05-18 14:58:57 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2006-05-18 14:58:57 +0000 |
commit | 1b291a2917a1c18194c54fce8bf0fd895db98019 (patch) | |
tree | a46473123aeb5709f8cc6f07e685fc84df90bf06 /includes/theme.inc | |
parent | be7bb9be9bb41c83795fa8d7fa119ce4025f2de0 (diff) | |
download | brdo-1b291a2917a1c18194c54fce8bf0fd895db98019.tar.gz brdo-1b291a2917a1c18194c54fce8bf0fd895db98019.tar.bz2 |
- Patch #18260 by Ber, m3averck et al: allow overriding of links returned by modules
Diffstat (limited to 'includes/theme.inc')
-rw-r--r-- | includes/theme.inc | 27 |
1 files changed, 23 insertions, 4 deletions
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 <span> for adding title and class attributes + $output[] = '<span'. drupal_attributes($link['#attributes']) .'>'. $link['#title'] .'</span>'; + } + } } - return implode($delimiter, $links); + + return implode($delimiter, $output); } /** |