diff --git a/bibtexbrowser.bibliography.php b/bibtexbrowser.bibliography.php
index bcd8a02..591afbc 100644
--- a/bibtexbrowser.bibliography.php
+++ b/bibtexbrowser.bibliography.php
@@ -13,9 +13,9 @@ $DB = load_DB();
$citations = array();
// Function to create a link for a bibtex entry
-function linkify($a) {
- if ( empty($a) ) { return "?"; }
- return '' . $a . '' ;
+function linkify($txt,$a) {
+ if ( empty($a) ) { return '?'; }
+ return '' . $a . '' ;
}
// Create citations from bibtex entries. One argument per bibtex entry.
@@ -30,7 +30,8 @@ function cite() {
$bib = $DB->getEntryByKey($entry);
if ( empty($bib) ) {
$ref = array(); // empty ref for detection by linkify, while getting last with sort()
- $refs[] = $ref;
+ $txt = "Unknown key «$entry»";
+ $refs[$txt] = $ref;
continue;
}
if (ABBRV_TYPE != 'index') {
@@ -44,10 +45,14 @@ function cite() {
$citations[$entry] = $ref ;
}
}
- $refs[] = $ref;
+ $txt = $bib->getVeryCompactedAuthors() . ", «" . $bib->getTitle() . "», " . $bib->getYear() ;
+ $refs[$txt] = $ref;
+ }
+ asort( $refs );
+ $links = array();
+ foreach ( $refs as $txt => $ref ) {
+ $links[] = linkify($txt,$ref);
}
- sort( $refs );
- $links = array_map( 'linkify', $refs );
echo "[" . implode(",",$links) . "]" ;
}
@@ -57,10 +62,23 @@ function make_bibliography() {
$bibfile = $_GET[Q_FILE]; // save bibfilename before resetting $_GET
$_GET = array();
$_GET['bib'] = $bibfile;
- $_GET['bibliography']=1; // also sets $_GET['assoc_keys']=1
+ $_GET['bibliography'] = 1; // also sets $_GET['assoc_keys']=1
$_GET['keys'] = json_encode(array_flip($citations));
//print_r($_GET);
include( 'bibtexbrowser.php' );
+?>
+
+
diff --git a/bibtexbrowser.php b/bibtexbrowser.php
index a41c621..1d3e6e7 100644
--- a/bibtexbrowser.php
+++ b/bibtexbrowser.php
@@ -1252,6 +1252,16 @@ class BibEntry {
return $this->formatAuthor($authors[0]) . $etal;
}
+ /**
+ * Returns a compacted string form of author names by throwing away
+ * all author names except for the first one and appending ", et al."
+ */
+ function getVeryCompactedAuthors(){
+ $authors = $this->getRawAuthors();
+ $etal = count($authors) > 1 ? ', et al.' : '';
+ list($firstname, $lastname) = splitFullName($authors[0]);
+ return $lastname . $etal;
+ }
/** add the link to the homepage if it is defined in a string
* e.g. @string{hp_MartinMonperrus="http://www.monperrus.net/martin"}