fixes bug in generated hyperlinks. Closes #40.

This commit is contained in:
Martin Monperrus
2015-09-29 22:56:53 +02:00
parent f0674d94f9
commit 946798f41b
2 changed files with 25 additions and 1 deletions
+10 -1
View File
@@ -1662,13 +1662,22 @@ class BibEntry {
$entry = htmlspecialchars($this->getFullText());
// Fields that should be hyperlinks
// the order matters
$hyperlinks = array('url' => '%O', 'file' => '%O', 'pdf' => '%O', 'doi' => 'http://dx.doi.org/%O', 'gsid' => 'http://scholar.google.com/scholar?cites=%O');
$vals = array();
foreach ($hyperlinks as $field => $url) {
if ($this->hasField($field)) {
$href = str_replace('%O', $this->getField($field), $url);
// this is not a parsing but a simple replacement
$entry = str_replace($this->getField($field), '<a'.(BIBTEXBROWSER_LINKS_IN_NEW_WINDOW?' target="_blank" ':'').' href="'.$href.'">'.$this->getField($field).'</a>', $entry);
$entry = str_replace($this->getField($field), '___'.$field.'___', $entry);
$vals[$field] = $href;
}
}
foreach ($vals as $field => $href) {
if ($this->hasField($field)) {
// this is not a parsing but a simple replacement
$entry = str_replace('___'.$field.'___', '<a'.(BIBTEXBROWSER_LINKS_IN_NEW_WINDOW?' target="_blank" ':'').' href="'.$href.'">'.$this->getField($field).'</a>', $entry);
}
}