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 = '';
  12.  
  13.       // Automatically add a class to each link and also to each LI
  14.       if (isset($link['attributes']) && isset($link['attributes']['class'])) {
  15.         $link['attributes']['class'] .= ' ' . $key;
  16.         $class = $key;
  17.       }
  18.       else {
  19.         $link['attributes']['class'] = $key;
  20.         $class = $key;
  21.       }
  22.  
  23.       // Add first and last classes to the list of links to help out themers.
  24.       $extra_class = '';
  25.       if ($i == 1) {
  26.         $extra_class .= 'first ';
  27.       }
  28.       if ($i == $num_links) {
  29.         $extra_class .= 'last ';
  30.       }
  31.       $output .= '<li class="'. $extra_class . $class .'">';
  32.  
  33.       // Is the title HTML?
  34.       $html = isset($link['html']) && $link['html'];
  35.  
  36.       // Initialize fragment and query variables.
  37.       $link['query'] = isset($link['query']) ? $link['query'] : NULL;
  38.       $link['fragment'] = isset($link['fragment']) ? $link['fragment'] : NULL;
  39.  
  40.       if (isset($link['href'])) {
  41.         $output .= '<div>'. l($link['title'], $link['href'], $link['attributes'], $link['query'], $link['fragment'], FALSE, $html) .'</div>;
  42.      }
  43.      else if ($link['title']) {
  44.        //Some links are actually not links, but we wrap these in <span> for adding title and class attributes
  45.        if (!$html) {
  46.          $link['title'] = check_plain($link['title']);
  47.        }
  48.        $output .= '<span'. drupal_attributes($link['attributes']) .'>'. $link['title'] .'</span>';
  49.      }
  50.  
  51.      $i++;
  52.      $output .= "</li>\n";
  53.    }
  54.  
  55.    $output .= '</ul>';
  56.  }
  57.  
  58.  return $output;
  59. }