summaryrefslogtreecommitdiff
path: root/includes/theme.inc
diff options
context:
space:
mode:
Diffstat (limited to 'includes/theme.inc')
-rw-r--r--includes/theme.inc27
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);
}
/**