fix #72
This commit is contained in:
+22
-5
@@ -90,6 +90,16 @@ class BTBTest extends PHPUnit_Framework_TestCase {
|
|||||||
$this->assertEquals('<a class="bibanchor" name=""></a>',$first_entry->anchor());
|
$this->assertEquals('<a class="bibanchor" name=""></a>',$first_entry->anchor());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function extract_css_classes($str) {
|
||||||
|
$xml = new SimpleXMLElement($str);
|
||||||
|
$css_classes = array();
|
||||||
|
foreach($xml->xpath('//node()/@class') as $v) {
|
||||||
|
$css_classes[] = $v->__toString();
|
||||||
|
};
|
||||||
|
sort($css_classes);
|
||||||
|
return $css_classes;
|
||||||
|
}
|
||||||
|
|
||||||
function test_bibentry_to_html_article() {
|
function test_bibentry_to_html_article() {
|
||||||
$btb = $this->createDB();
|
$btb = $this->createDB();
|
||||||
$first_entry=$btb->getEntryByKey('aKeyA');
|
$first_entry=$btb->getEntryByKey('aKeyA');
|
||||||
@@ -99,21 +109,28 @@ class BTBTest extends PHPUnit_Framework_TestCase {
|
|||||||
|
|
||||||
// default style
|
// default style
|
||||||
bibtexbrowser_configure('BIBLIOGRAPHYSTYLE','DefaultBibliographyStyle');
|
bibtexbrowser_configure('BIBLIOGRAPHYSTYLE','DefaultBibliographyStyle');
|
||||||
$this->assertEquals("An Article (Foo Bar and Jane Doe), In New Results, volume 5, 2009. [bibtex]",strip_tags($first_entry->toHTML()));
|
bibtexbrowser_configure('BIBTEXBROWSER_LINK_STYLE','nothing');
|
||||||
$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 class="biburl" title="aKeyA" href="bibtexbrowser.php?key=aKeyA&bib=inline">[bibtex]</a></span>',$first_entry->toHTML());
|
$this->assertEquals("An Article (Foo Bar and Jane Doe), In New Results, volume 5, 2009. ",strip_tags($first_entry->toHTML()));
|
||||||
|
$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> ',$first_entry->toHTML());
|
||||||
|
|
||||||
|
// listing the CSS classes
|
||||||
|
$css_classes_before = $this->extract_css_classes($first_entry->toHTML());
|
||||||
|
|
||||||
// IEEE style
|
// IEEE style
|
||||||
bibtexbrowser_configure('BIBLIOGRAPHYSTYLE','JanosBibliographyStyle');
|
bibtexbrowser_configure('BIBLIOGRAPHYSTYLE','JanosBibliographyStyle');
|
||||||
$this->assertEquals("Foo Bar and Jane Doe, \"An Article\", In New Results, vol. 5, pp. 1-2, 2009.\n [bibtex]",strip_tags($first_entry->toHTML()));
|
$this->assertEquals("Foo Bar and Jane Doe, \"An Article\", In New Results, vol. 5, pp. 1-2, 2009.\n ",strip_tags($first_entry->toHTML()));
|
||||||
|
$css_classes_after = $this->extract_css_classes($first_entry->toHTML());
|
||||||
|
// contract: make sure the Janos style and default style use the same CSS classes
|
||||||
|
$this->assertEquals($css_classes_before, $css_classes_after);
|
||||||
|
|
||||||
// Vancouver style
|
// Vancouver style
|
||||||
bibtexbrowser_configure('BIBLIOGRAPHYSTYLE','VancouverBibliographyStyle');
|
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()));
|
$this->assertEquals("Foo Bar and Jane Doe. An Article. New Results. 2009;5:1-2.\n ",strip_tags($first_entry->toHTML()));
|
||||||
|
|
||||||
// changing the target
|
// changing the target
|
||||||
bibtexbrowser_configure('BIBLIOGRAPHYSTYLE','DefaultBibliographyStyle');
|
bibtexbrowser_configure('BIBLIOGRAPHYSTYLE','DefaultBibliographyStyle');
|
||||||
bibtexbrowser_configure('BIBTEXBROWSER_LINKS_TARGET','_top');
|
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());
|
$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> ',$first_entry->toHTML());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+10
-8
@@ -118,7 +118,7 @@ if (defined('ENCODING')) {
|
|||||||
@define('BIBTEXBROWSER_NO_DEFAULT', false);
|
@define('BIBTEXBROWSER_NO_DEFAULT', false);
|
||||||
|
|
||||||
// BIBTEXBROWSER_LINK_STYLE defines which function to use to display the links of a bibtex entry
|
// BIBTEXBROWSER_LINK_STYLE defines which function to use to display the links of a bibtex entry
|
||||||
@define('BIBTEXBROWSER_LINK_STYLE','bib2links_default');
|
@define('BIBTEXBROWSER_LINK_STYLE','bib2links_default'); // can be 'nothing' (a function that does nothing)
|
||||||
|
|
||||||
// do we add [bibtex] links ?
|
// do we add [bibtex] links ?
|
||||||
@define('BIBTEXBROWSER_BIBTEX_LINKS',true);
|
@define('BIBTEXBROWSER_BIBTEX_LINKS',true);
|
||||||
@@ -241,6 +241,8 @@ define('Q_INNER_TYPE', 'x-bibtex-type');// used for representing the type of the
|
|||||||
@ini_set("session.use_trans_sid",0);
|
@ini_set("session.use_trans_sid",0);
|
||||||
@ini_set("url_rewriter.tags","");
|
@ini_set("url_rewriter.tags","");
|
||||||
|
|
||||||
|
function nothing() {}
|
||||||
|
|
||||||
function config_value($key) {
|
function config_value($key) {
|
||||||
global $CONFIGURATION;
|
global $CONFIGURATION;
|
||||||
if (isset($CONFIGURATION[$key])) { return $CONFIGURATION[$key]; }
|
if (isset($CONFIGURATION[$key])) { return $CONFIGURATION[$key]; }
|
||||||
@@ -2019,7 +2021,7 @@ function bib2html($bibentry) {
|
|||||||
|
|
||||||
/** this function encapsulates the user-defined name for bib2links */
|
/** this function encapsulates the user-defined name for bib2links */
|
||||||
function bib2links($bibentry) {
|
function bib2links($bibentry) {
|
||||||
$function = BIBTEXBROWSER_LINK_STYLE;
|
$function = c('BIBTEXBROWSER_LINK_STYLE');
|
||||||
return $function($bibentry);
|
return $function($bibentry);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2357,11 +2359,11 @@ function JanosBibliographyStyle($bibentry) {
|
|||||||
|
|
||||||
// author
|
// author
|
||||||
if ($bibentry->hasField('author')) {
|
if ($bibentry->hasField('author')) {
|
||||||
$entry[] = $bibentry->getFormattedAuthorsString();
|
$entry[] = '<span class="bibauthor">'.$bibentry->getFormattedAuthorsString().'</span>';
|
||||||
}
|
}
|
||||||
|
|
||||||
// title
|
// title
|
||||||
$title = '"'.$title.'"';
|
$title = '"'.'<span class="bibtitle">'.$title.'</span>'.'"';
|
||||||
if ($bibentry->hasField('url')) $title = ' <a'.get_target().' href="'.$bibentry->getField('url').'">'.$title.'</a>';
|
if ($bibentry->hasField('url')) $title = ' <a'.get_target().' href="'.$bibentry->getField('url').'">'.$title.'</a>';
|
||||||
$entry[] = $title;
|
$entry[] = $title;
|
||||||
|
|
||||||
@@ -2374,15 +2376,15 @@ function JanosBibliographyStyle($bibentry) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($type=="inproceedings" && $bibentry->hasField(BOOKTITLE)) {
|
if ($type=="inproceedings" && $bibentry->hasField(BOOKTITLE)) {
|
||||||
$booktitle = 'In '.$bibentry->getField(BOOKTITLE);
|
$booktitle = '<span class="bibbooktitle">'.'In '.$bibentry->getField(BOOKTITLE).'</span>';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($type=="incollection" && $bibentry->hasField(BOOKTITLE)) {
|
if ($type=="incollection" && $bibentry->hasField(BOOKTITLE)) {
|
||||||
$booktitle = 'Chapter in '.$bibentry->getField(BOOKTITLE);
|
$booktitle = '<span class="bibbooktitle">'.'Chapter in '.$bibentry->getField(BOOKTITLE).'</span>';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($type=="article" && $bibentry->hasField("journal")) {
|
if ($type=="article" && $bibentry->hasField("journal")) {
|
||||||
$booktitle = 'In '.$bibentry->getField("journal");
|
$booktitle = '<span class="bibbooktitle">'.'In '.$bibentry->getField("journal").'</span>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -2435,7 +2437,7 @@ function JanosBibliographyStyle($bibentry) {
|
|||||||
// add the Coin URL
|
// add the Coin URL
|
||||||
$result .= "\n".$bibentry->toCoins();
|
$result .= "\n".$bibentry->toCoins();
|
||||||
|
|
||||||
return $result;
|
return '<span itemscope="" itemtype="http://schema.org/ScholarlyArticle">'.$result.'</span>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user