| 1 |
|
<?php |
| 2 |
|
|
| 3 |
|
function fancy_navlinks($links) { |
| 4 |
|
$output = ''; |
| 5 |
|
|
| 6 |
|
if (count($links) > 0) { |
| 7 |
|
$output = '<ul>'; |
| 8 |
|
|
| 9 |
|
$i = 1; |
| 10 |
|
|
| 11 |
|
foreach ($links as $key => $link) { |
| 12 |
|
$class = ''; |
| 13 |
|
|
| 14 |
|
// Automatically add a current LI class ='current' to active link |
| 15 |
|
if ( stristr($key, 'active') ){ |
| 16 |
|
$class = ' class="current"'; |
| 17 |
|
} |
| 18 |
|
|
| 19 |
|
|
| 20 |
|
$output .= '<li id="primary-link-'.$i.'"' . $class .' >'; |
| 21 |
|
|
| 22 |
|
// Is the title HTML? |
| 23 |
|
$html = isset($link['html']) && $link['html']; |
| 24 |
|
|
| 25 |
|
// Initialize fragment and query variables. |
| 26 |
|
$link['query'] = isset($link['query']) ? $link['query'] : NULL; |
| 27 |
|
$link['fragment'] = isset($link['fragment']) ? $link['fragment'] : NULL; |
| 28 |
|
|
| 29 |
|
if (isset($link['href'])) { |
| 30 |
|
$output .= l($link['title'], $link['href'], $link['attributes'], $link['query'], $link['fragment'], FALSE, $html); |
| 31 |
|
} |
| 32 |
|
else if ($link['title']) { |
| 33 |
|
//Some links are actually not links, but we wrap these in <span> for adding title and class attributes |
| 34 |
|
if (!$html) { |
| 35 |
|
$link['title'] = check_plain($link['title']); |
| 36 |
|
} |
| 37 |
|
$output .= '<span'. drupal_attributes($link['attributes']) .'>'. $link['title'] .'</span>'; |
| 38 |
|
} |
| 39 |
|
|
| 40 |
|
$i++; |
| 41 |
|
$output .= "</li>\n"; |
| 42 |
|
} |
| 43 |
|
|
| 44 |
|
$output .= '</ul>'; |
| 45 |
|
} |
| 46 |
|
|
| 47 |
|
return $output; |
| 48 |
|
} |
| 49 |
|
|
| 50 |
|
?> |