improves the link target configuration
This commit is contained in:
@@ -81,6 +81,12 @@ class BTBTest extends PHPUnit_Framework_TestCase {
|
||||
// Vancouver style
|
||||
bibtexbrowser_configure('BIBLIOGRAPHYSTYLE','VancouverBibliographyStyle');
|
||||
$this->assertEquals("Foo Bar and Jane Doe. An Article. New Results. 2009;5:1-2.\n [bibtex]",strip_tags($first_entry->toHTML()));
|
||||
|
||||
// changing the target
|
||||
bibtexbrowser_configure('BIBLIOGRAPHYSTYLE','DefaultBibliographyStyle');
|
||||
bibtexbrowser_configure('BIBTEXBROWSER_LINKS_TARGET','_top');
|
||||
$this->assertEquals('<span itemscope="" itemtype="http://schema.org/ScholarlyArticle"><span class="bibtitle" itemprop="name">An Article</span> (<span class="bibauthor"><span itemprop="author" itemtype="http://schema.org/Person">Foo Bar</span> and <span itemprop="author" itemtype="http://schema.org/Person">Jane Doe</span></span>), <span class="bibbooktitle">In <span itemprop="isPartOf">New Results</span></span>, volume 5, <span itemprop="datePublished">2009</span>.<span class="Z3988" title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&rft.atitle=An+Article&rft.jtitle=New+Results&rft.volume=5&rft.issue=&rft.pub=&rfr_id=info%3Asid%2F%3A&rft.date=2009&rft.au=Foo+Bar&rft.au=Jane+Doe"></span></span> <span class="bibmenu"><a target="_top" class="biburl" title="aKeyA" href="bibtexbrowser.php?key=aKeyA&bib=inline">[bibtex]</a></span>',$first_entry->toHTML());
|
||||
|
||||
}
|
||||
|
||||
function testMultiSearch() {
|
||||
|
||||
+17
-13
@@ -68,10 +68,6 @@ if (defined('ENCODING')) {
|
||||
// if you don't like it, you can be disable it by adding in bibtexbrowser.local.php
|
||||
// @define('BIBTEXBROWSER_USE_PROGRESSIVE_ENHANCEMENT',false);
|
||||
@define('BIBTEXBROWSER_USE_PROGRESSIVE_ENHANCEMENT',true);
|
||||
// if you disable the Javascript progressive enhancement,
|
||||
// you may want the links to be open in a new window/tab
|
||||
// if yes, add in bibtexbrowser.local.php define('BIBTEXBROWSER_BIB_IN_NEW_WINDOW',true);
|
||||
@define('BIBTEXBROWSER_BIB_IN_NEW_WINDOW',false);
|
||||
@define('BIBLIOGRAPHYSTYLE','DefaultBibliographyStyle');// this is the name of a function
|
||||
@define('BIBLIOGRAPHYSECTIONS','DefaultBibliographySections');// this is the name of a function
|
||||
@define('BIBLIOGRAPHYTITLE','DefaultBibliographyTitle');// this is the name of a function
|
||||
@@ -134,7 +130,7 @@ if (defined('ENCODING')) {
|
||||
@define('BIBTEXBROWSER_GSID_LINKS',true);
|
||||
|
||||
// should pdf, doi, url, gsid links be opened in a new window?
|
||||
@define('BIBTEXBROWSER_LINKS_IN_NEW_WINDOW',false);
|
||||
@define('BIBTEXBROWSER_LINKS_TARGET','_self');// can be _blank (new window), _top (with frames)
|
||||
|
||||
// should authors be linked to [none/homepage/resultpage]
|
||||
// none: nothing
|
||||
@@ -291,6 +287,14 @@ function default_message() {
|
||||
echo "</div>";
|
||||
}
|
||||
|
||||
/** returns the target of links */
|
||||
function get_target() {
|
||||
if (c('BIBTEXBROWSER_LINKS_TARGET')!='_self') {
|
||||
return " target=\"".c('BIBTEXBROWSER_LINKS_TARGET')."\"";
|
||||
}
|
||||
else return "";
|
||||
}
|
||||
|
||||
/** @nodoc */
|
||||
function _zetDB($bibtex_filenames) {
|
||||
|
||||
@@ -1285,7 +1289,7 @@ class BibEntry {
|
||||
if ($altlabel==NULL) { $altlabel=$bibfield; }
|
||||
$str = $this->getIconOrTxt($altlabel,$iconurl);
|
||||
if ($this->hasField($bibfield)) {
|
||||
return '<a'.(BIBTEXBROWSER_LINKS_IN_NEW_WINDOW?' target="_blank" ':'').' href="'.$this->getField($bibfield).'">'.$str.'</a>';
|
||||
return '<a'.get_target().' href="'.$this->getField($bibfield).'">'.$str.'</a>';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
@@ -1296,7 +1300,7 @@ class BibEntry {
|
||||
$href = 'href="'.$this->getURL().'"';
|
||||
// we add biburl and title to be able to retrieve this important information
|
||||
// using Xpath expressions on the XHTML source
|
||||
$link = "<a".(BIBTEXBROWSER_BIB_IN_NEW_WINDOW?' target="_blank" ':'')." class=\"biburl\" title=\"".$this->getKey()."\" {$href}>$bibstr</a>";
|
||||
$link = '<a'.get_target()." class=\"biburl\" title=\"".$this->getKey()."\" {$href}>$bibstr</a>";
|
||||
return $link;
|
||||
}
|
||||
|
||||
@@ -1329,7 +1333,7 @@ class BibEntry {
|
||||
function getDoiLink($iconurl=NULL) {
|
||||
$str = $this->getIconOrTxt('doi',$iconurl);
|
||||
if ($this->hasField('doi')) {
|
||||
return '<a'.(BIBTEXBROWSER_LINKS_IN_NEW_WINDOW?' target="_blank" ':'').' href="http://dx.doi.org/'.$this->getField('doi').'">'.$str.'</a>';
|
||||
return '<a'.get_target().' href="http://dx.doi.org/'.$this->getField('doi').'">'.$str.'</a>';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
@@ -1338,7 +1342,7 @@ class BibEntry {
|
||||
function getGSLink($iconurl=NULL) {
|
||||
$str = $this->getIconOrTxt('cites',$iconurl);
|
||||
if ($this->hasField('gsid')) {
|
||||
return ' <a'.(BIBTEXBROWSER_LINKS_IN_NEW_WINDOW?' target="_blank" ':'').' href="http://scholar.google.com/scholar?cites='.$this->getField("gsid").'">'.$str.'</a>';
|
||||
return ' <a'.get_target().' href="http://scholar.google.com/scholar?cites='.$this->getField("gsid").'">'.$str.'</a>';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
@@ -1908,7 +1912,7 @@ class BibEntry {
|
||||
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);
|
||||
$entry = str_replace('___'.$field.'___', '<a'.get_target().' href="'.$href.'">'.$this->getField($field).'</a>', $entry);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2248,7 +2252,7 @@ function DefaultBibliographyStyle(&$bibentry) {
|
||||
// title
|
||||
// usually in bold: .bibtitle { font-weight:bold; }
|
||||
$title = '<span class="bibtitle" itemprop="name">'.$title.'</span>';
|
||||
if ($bibentry->hasField('url')) $title = ' <a'.(BIBTEXBROWSER_BIB_IN_NEW_WINDOW?' target="_blank" ':'').' href="'.$bibentry->getField('url').'">'.$title.'</a>';
|
||||
if ($bibentry->hasField('url')) $title = ' <a'.get_target().' href="'.$bibentry->getField('url').'">'.$title.'</a>';
|
||||
|
||||
|
||||
$coreInfo = $title;
|
||||
@@ -2366,7 +2370,7 @@ function JanosBibliographyStyle(&$bibentry) {
|
||||
|
||||
// title
|
||||
$title = '"'.$title.'"';
|
||||
if ($bibentry->hasField('url')) $title = ' <a'.(BIBTEXBROWSER_BIB_IN_NEW_WINDOW?' target="_blank" ':'').' href="'.$bibentry->getField('url').'">'.$title.'</a>';
|
||||
if ($bibentry->hasField('url')) $title = ' <a'.get_target().' href="'.$bibentry->getField('url').'">'.$title.'</a>';
|
||||
$entry[] = $title;
|
||||
|
||||
|
||||
@@ -2481,7 +2485,7 @@ function VancouverBibliographyStyle(&$bibentry) {
|
||||
$title = $title . '. ';
|
||||
}
|
||||
if ($bibentry->hasField('url')) {
|
||||
$title = ' <a'.(BIBTEXBROWSER_BIB_IN_NEW_WINDOW?' target="_blank" ':'').' href="'.$bibentry->getField('url').'">'.$title.'</a>';
|
||||
$title = ' <a'.get_target().' href="'.$bibentry->getField('url').'">'.$title.'</a>';
|
||||
}
|
||||
|
||||
$entry[] = $title;
|
||||
|
||||
Reference in New Issue
Block a user