Turns doi, url, gsid etc. into hyperlinks in bibtex entry display
Does not yet work in js progressive enhancement mode
This commit is contained in:
committed by
Martin Monperrus
parent
dbc28d4448
commit
ef908a3298
+9
-3
@@ -1622,10 +1622,16 @@ class BibEntry {
|
|||||||
$result = "";
|
$result = "";
|
||||||
$result .= '<pre class="purebibtex">'; // pre is nice when it is embedded with no CSS available
|
$result .= '<pre class="purebibtex">'; // pre is nice when it is embedded with no CSS available
|
||||||
$entry = htmlspecialchars($this->getFullText());
|
$entry = htmlspecialchars($this->getFullText());
|
||||||
if ($this->hasField('url')) {
|
|
||||||
$url = $this->getField('url');
|
// Fields that should be hyperlinks
|
||||||
|
$hyperlinks = array('url' => '%O', 'file' => '%O', 'pdf' => '%O', 'doi' => 'http://dx.doi.org/%O', 'gsid' => 'http://scholar.google.com/scholar?cites=%O');
|
||||||
|
|
||||||
|
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
|
// this is not a parsing but a simple replacement
|
||||||
$entry = str_replace($url,'<a href="'.$url.'">'.$url.'</a>', $entry);
|
$entry = str_replace($this->getField($field), '<a'.(BIBTEXBROWSER_LINKS_IN_NEW_WINDOW?' target="_blank" ':'').' href="'.$href.'">'.$this->getField($field).'</a>', $entry);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$result .= $entry;
|
$result .= $entry;
|
||||||
|
|||||||
Reference in New Issue
Block a user