Inverted order of conditionals in GetUrlLink, and renamed function.

Fixes #50.

Fixed test case as well.
This commit is contained in:
Federico Poloni
2016-07-31 14:51:40 +02:00
parent 1465b13198
commit c6f82792bd
2 changed files with 7 additions and 7 deletions
+5 -5
View File
@@ -1199,13 +1199,13 @@ class BibEntry {
}
/** returns a "[pdf]" link if relevant. modified to exploit the new method, while keeping backward compatibility */
function getUrlLink($iconurl = NULL, $label = 'pdf') {
if ($this->hasField('url')) {
return $this->getLink('url', $iconurl, $label);
}
function getPdfLink($iconurl = NULL, $label = 'pdf') {
if ($this->hasField('pdf')) {
return $this->getLink('pdf', $iconurl, $label);
}
if ($this->hasField('url')) {
return $this->getLink('url', $iconurl, $label);
}
// Adding link to PDF file exported by Zotero
// ref: https://github.com/monperrus/bibtexbrowser/pull/14
if ($this->hasField('file')) {
@@ -1816,7 +1816,7 @@ function bib2links_default(&$bibentry) {
}
if (BIBTEXBROWSER_PDF_LINKS) {
$link = $bibentry->getUrlLink();
$link = $bibentry->getPdfLink();
if ($link != '') { $links[] = $link; };
}