Fix for overriding favorite nodes links

  1. function phptemplate_links($links, $attributes = array('class' => 'links')) {
  2.   $output = '';
  3.  
  4.   if (count($links) > 0) {
  5.     $output = '<ul'. drupal_attributes($attributes) .'>';
  6.  
  7.     $num_links = count($links);
  8.     $i = 1;
  9.  
  10.     foreach ($links as $key => $link) {
  11.       $class = $key;
  12.  
  13.       // Add first, last and active classes to the list of links to help out themers.
  14.       if ($i == 1) {
  15.         $class .= ' first';
  16.       }
  17.       if ($i == $num_links) {
  18.         $class .= ' last';
  19.       }
  20.       if (isset($link['href']) && ($link['href'] == $_GET['q'] || ($link['href'] == '<front>' && drupal_is_front_page()))) {
  21.         $class .= ' active';
  22.       }
  23.       $output .= '<li class="'. $class .'">';
  24.  
  25.       if (isset($link['href'])) {
  26.         // Pass in $link as $options, they share the same keys.
  27.         $output .= '<div>'. l($link['title'], $link['href'], $link) .'</div>';
  28.       }
  29.       else if (!empty($link['title'])) {
  30.         // Some links are actually not links, but we wrap these in <span> for adding title and class attributes
  31.         if (empty($link['html'])) {
  32.           $link['title'] = check_plain($link['title']);
  33.         }
  34.         $span_attributes = '';
  35.         if (isset($link['attributes'])) {
  36.           $span_attributes = drupal_attributes($link['attributes']);
  37.         }
  38.         $output .= '<span'. $span_attributes .'>'. $link['title'] .'</span>';
  39.       }
  40.  
  41.       $i++;
  42.       $output .= "</li>\n";
  43.     }
  44.  
  45.     $output .= '</ul>';
  46.   }
  47.  
  48.   return $output;
  49. }