I fixed the bug in the following function related to displaying duplicate references (with the same citekey):
Also the code below adds a anchor link which connects to the respective reference in the footer.

function _biblio_filter_replace_callback($matches, $op = '') {
  static $n = 0;
  static $store_matches = array();
  $str = '';
  if ($op == 'output footer') {
    if ($n > 0) {
      $str = '<p><hr /></p><h3>'. t('References') .'</h3>';
      $str .= '<div class="references"><ol>';
      for ($m = 1; $m <= $n; $m++) {
        $str .= '<li id="reference'. $m .'"><a name="ref'.$m.'">'. _biblio_citekey_print($store_matches[$m -1]) ." </a></li>\n\n";
      }
      $str .= '</ol></div>';
    }
    $n = 0;
    $store_matches = array();
    return $str;
  }
  //default op: act as called by preg_replace_callback()
  if (! ($ref = array_search($matches[1],$store_matches))) {
    $n++;
    array_push($store_matches, $matches[1]);    //$stores_matches[$matches[1]] = $n;
    $ref = $n;
  }  else {  
    $ref++;
  }
  $allowed_tags = array();
  $title = filter_xss($matches[1], $allowed_tags);
  //html attribute cannot contain quotes
  $title = str_replace('"', "&quot;", $title);
  //remove newlines. Browsers don't support them anyway and they'll confuse line break converter in filter.module
  $title = str_replace("\n", " ", $title);
  $title = str_replace("\r", "", $title);
  //return '<sup class="see_reference" title="'. $title .'"><a href="#reference'. $n .'">'. $n .'</a></sup>';
  //$text = '<span><a href="#reference'. $n .'">['. $n .']</a> </span>';
  //$text = '<span>['. $n .']</span>';
  //$text .= '<span class="hovertip">'._biblio_citekey_print($title) .'</span>';
  $text = '<span hovertip="reference'. $ref .'"><a href="#ref'.$ref.'">['. $ref .']</a></span>';
  if (module_exists('hovertip')) {
    $text .= '<span id="reference'. $ref .'" class="hovertip"><h1>Reference</h1>'. _biblio_citekey_print($title) .'</span>';
  }
  return $text;
}

Comments

erantone’s picture

The function above is from biblio.module

sleitao’s picture

Careful with array_search(..) because it may return 0 when the duplicate citation is the first item from the array. Must be checked if the result is 0 or FALSE (===).

rjerome’s picture

Status: Active » Fixed

Added to the code.

Ron.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.