diff --git a/bibtexbrowser-test.php b/bibtexbrowser-test.php
index e69c2a4..7a5351f 100755
--- a/bibtexbrowser-test.php
+++ b/bibtexbrowser-test.php
@@ -90,6 +90,16 @@ class BTBTest extends PHPUnit_Framework_TestCase {
$this->assertEquals('',$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() {
$btb = $this->createDB();
$first_entry=$btb->getEntryByKey('aKeyA');
@@ -99,21 +109,28 @@ class BTBTest extends PHPUnit_Framework_TestCase {
// default style
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()));
- $this->assertEquals('An Article (Foo Bar and Jane Doe), In New Results, volume 5, 2009. ',$first_entry->toHTML());
+ bibtexbrowser_configure('BIBTEXBROWSER_LINK_STYLE','nothing');
+ $this->assertEquals("An Article (Foo Bar and Jane Doe), In New Results, volume 5, 2009. ",strip_tags($first_entry->toHTML()));
+ $this->assertEquals('An Article (Foo Bar and Jane Doe), In New Results, volume 5, 2009. ',$first_entry->toHTML());
+ // listing the CSS classes
+ $css_classes_before = $this->extract_css_classes($first_entry->toHTML());
+
// IEEE style
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
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
bibtexbrowser_configure('BIBLIOGRAPHYSTYLE','DefaultBibliographyStyle');
bibtexbrowser_configure('BIBTEXBROWSER_LINKS_TARGET','_top');
- $this->assertEquals('An Article (Foo Bar and Jane Doe), In New Results, volume 5, 2009. ',$first_entry->toHTML());
+ $this->assertEquals('An Article (Foo Bar and Jane Doe), In New Results, volume 5, 2009. ',$first_entry->toHTML());
}
diff --git a/bibtexbrowser.php b/bibtexbrowser.php
index d98523d..e4ef317 100755
--- a/bibtexbrowser.php
+++ b/bibtexbrowser.php
@@ -118,7 +118,7 @@ if (defined('ENCODING')) {
@define('BIBTEXBROWSER_NO_DEFAULT', false);
// 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 ?
@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("url_rewriter.tags","");
+function nothing() {}
+
function config_value($key) {
global $CONFIGURATION;
if (isset($CONFIGURATION[$key])) { return $CONFIGURATION[$key]; }
@@ -2019,7 +2021,7 @@ function bib2html($bibentry) {
/** this function encapsulates the user-defined name for bib2links */
function bib2links($bibentry) {
- $function = BIBTEXBROWSER_LINK_STYLE;
+ $function = c('BIBTEXBROWSER_LINK_STYLE');
return $function($bibentry);
}
@@ -2357,11 +2359,11 @@ function JanosBibliographyStyle($bibentry) {
// author
if ($bibentry->hasField('author')) {
- $entry[] = $bibentry->getFormattedAuthorsString();
+ $entry[] = ''.$bibentry->getFormattedAuthorsString().'';
}
// title
- $title = '"'.$title.'"';
+ $title = '"'.''.$title.''.'"';
if ($bibentry->hasField('url')) $title = ' '.$title.'';
$entry[] = $title;
@@ -2374,15 +2376,15 @@ function JanosBibliographyStyle($bibentry) {
}
if ($type=="inproceedings" && $bibentry->hasField(BOOKTITLE)) {
- $booktitle = 'In '.$bibentry->getField(BOOKTITLE);
+ $booktitle = ''.'In '.$bibentry->getField(BOOKTITLE).'';
}
if ($type=="incollection" && $bibentry->hasField(BOOKTITLE)) {
- $booktitle = 'Chapter in '.$bibentry->getField(BOOKTITLE);
+ $booktitle = ''.'Chapter in '.$bibentry->getField(BOOKTITLE).'';
}
if ($type=="article" && $bibentry->hasField("journal")) {
- $booktitle = 'In '.$bibentry->getField("journal");
+ $booktitle = ''.'In '.$bibentry->getField("journal").'';
}
@@ -2435,7 +2437,7 @@ function JanosBibliographyStyle($bibentry) {
// add the Coin URL
$result .= "\n".$bibentry->toCoins();
- return $result;
+ return ''.$result.'';
}