Browse Source

Update bibtexbrowser.php

pull/96/head
Martin Monperrus 6 years ago
committed by GitHub
parent
commit
bf2964dd46
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      bibtexbrowser.php

16
bibtexbrowser.php

@ -1315,9 +1315,9 @@ class BibEntry {
return $link; return $link;
} }
/** same as `getPdfLink`, kept for backward compatibility */
function getUrlLink($iconurl, $label) {
return $this->getPdfLink($iconurl, $label);
/** kept for backward compatibility */
function getPdfLink($iconurl = NULL, $label = NULL) {
return $this->getUrlLink($iconurl, $label);
} }
/** returns a "[pdf]" link for the entry, if possible. /** returns a "[pdf]" link for the entry, if possible.
@ -1325,7 +1325,7 @@ class BibEntry {
Performs a sanity check that the file extension is 'pdf' or 'ps' and uses that as link label. Performs a sanity check that the file extension is 'pdf' or 'ps' and uses that as link label.
Otherwise (and if no explicit $label is set) the field name is used instead. Otherwise (and if no explicit $label is set) the field name is used instead.
*/ */
function getPdfLink($iconurl = NULL, $label = NULL) {
function getUrlLink($iconurl = NULL, $label = NULL) {
if ($this->hasField('pdf')) { if ($this->hasField('pdf')) {
return $this->getExtensionLink('pdf', $iconurl, $label); return $this->getExtensionLink('pdf', $iconurl, $label);
} }
@ -1345,12 +1345,12 @@ class BibEntry {
function getExtensionLink($bibfield, $iconurl=NULL, $altlabel=NULL) { function getExtensionLink($bibfield, $iconurl=NULL, $altlabel=NULL) {
$extension = strtolower(pathinfo(parse_url($this->getField($bibfield),PHP_URL_PATH),PATHINFO_EXTENSION)); $extension = strtolower(pathinfo(parse_url($this->getField($bibfield),PHP_URL_PATH),PATHINFO_EXTENSION));
switch ($extension) { switch ($extension) {
case 'pdf': break;
case 'ps': break;
// overriding the label if it's a known extension
case 'pdf': return $this->getLink($bibfield, $iconurl, 'pdf'); break;
case 'ps': return $this->getLink($bibfield, $iconurl, 'ps'); break;
default: default:
return $this->getLink($bibfield, $iconurl, $altlabel); return $this->getLink($bibfield, $iconurl, $altlabel);
} }
return $this->getLink($bibfield, NULL, $extension);
} }
@ -2014,7 +2014,7 @@ function bib2links_default($bibentry) {
} }
if (BIBTEXBROWSER_PDF_LINKS) { if (BIBTEXBROWSER_PDF_LINKS) {
$link = $bibentry->getPdfLink();
$link = $bibentry->getUrlLink();
if ($link != '') { $links[] = $link; }; if ($link != '') { $links[] = $link; };
} }

Loading…
Cancel
Save