diff --git a/bibtexbrowser.php b/bibtexbrowser.php
index f49baa4..05a650a 100644
--- a/bibtexbrowser.php
+++ b/bibtexbrowser.php
@@ -1246,27 +1246,29 @@ class BibEntry {
}
/** Returns the abbreviation. */
- function getAbbrv() {
- if (ABBRV_TYPE == 'index') {
- if ( LAYOUT == 'list' ) { //
expects a raw number
- return $this->index;
- } else {
- return '['.$this->index.']';
- }
- }
+ function getRawAbbrv() {
+ if (ABBRV_TYPE == 'index') return $this->index;
if (ABBRV_TYPE == 'none') return '';
- if (ABBRV_TYPE == 'key') return '['.$this->getKey().']';
- if (ABBRV_TYPE == 'year') return '['.$this->getYear().']';
+ if (ABBRV_TYPE == 'key') return $this->getKey();
+ if (ABBRV_TYPE == 'year') return $this->getYear();
if (ABBRV_TYPE == 'x-abbrv') {
if ($this->hasField('x-abbrv')) {return $this->getField('x-abbrv');}
return $this->abbrv;
}
-
// otherwise it is a user-defined function in bibtexbrowser.local.php
$f = ABBRV_TYPE;
return $f($this);
}
+ /** Returns the abbreviation. */
+ function getAbbrv() {
+ $abbrv = $this->getRawAbbrv();
+ if ( ABBRV_TYPE == 'key' || ABBRV_TYPE == 'year' || ( ABBRV_TYPE == 'index' && LAYOUT != 'list' ) ) {
+ $abbrv = '['.$abbrv.']';
+ }
+ return $abbrv;
+ }
+
/** Sets the abbreviation (e.g. [OOPSLA] or [1]) */
function setAbbrv($abbrv) {
@@ -1307,10 +1309,37 @@ class BibEntry {
/** Outputs HTML line according to layout */
function toHTML() {
- switch(LAYOUT) {
- case 'list': $this->toLI(); break;
- case 'table': $this->toTR(); break;
- case 'deflist': $this->toDD(); break;
+ switch(LAYOUT) { // open row
+ case 'list':
+ echo '- ';
+ break;
+ case 'table':
+ echo '
';
+ break;
+ case 'deflist':
+ echo '- '; break;
+ }
+ $this->anchor();
+ switch(LAYOUT) { // close bibref and open bibitem
+ case 'table':
+ echo $this->getAbbrv().'
| ';
+ break;
+ case 'deflist':
+ echo $this->getAbbrv().'- ';
+ break;
+ }
+ echo bib2html($this);
+ echo bib2links($this);
+ switch(LAYOUT) { // close row
+ case 'list':
+ echo '';
+ break;
+ case 'table':
+ echo '
|
';
+ break;
+ case 'deflist':
+ echo '';
+ break;
}
}
@@ -1319,36 +1348,6 @@ class BibEntry {
echo '';
}
- /** Outputs an TR line with two TDS inside
- */
- function toTR() {
- echo '';
- echo '';
- $this->anchor();
- echo $this->getAbbrv().' | ';
- echo '';
- echo bib2html($this);
- echo " |
\n"; // toTR() must be self-contained
- }
-
-
- /** Outputs an LI line with SPANs for each element, setting the item value according to getAbbrv(). */
- function toLI() {
- echo ' - ';
- $this->anchor();
- echo bib2html($this);
- echo "
\n";
- }
-
- /** Outputs an DL line (- +
- ) */
- function toDD() {
- echo '
- ';
- $this->anchor();
- echo $this->getAbbrv().'
- ';
- echo bib2html($this);
- echo "
\n";
- }
-
/** Outputs an coins URL: see http://ocoins.info/cobg.html
* Used by Zotero, mendeley, etc.
*/
@@ -1486,7 +1485,10 @@ function layoutFooterHTML($tag) {
/** this function encapsulates the user-defined name for bib to HTML*/
function bib2html(&$bibentry) {
$function = BIBLIOGRAPHYSTYLE;
- $str = $function($bibentry);
+ return $function($bibentry);
+}
+
+function bib2links(&$bibentry) {
$href = 'href="'.$bibentry->getURL().'"';
if (BIBTEXBROWSER_BIBTEX_LINKS) {
@@ -1494,14 +1496,14 @@ function bib2html(&$bibentry) {
// using Xpath expressions on the XHTML source
$str .= " getKey()."\" {$href}>[bibtex]";
}
-
+
// returns an empty string if no url present
$str .= $bibentry->getUrlLink();
if ($bibentry->hasField('doi')) {
$str .= ' [doi]';
}
-
+
// Google Scholar ID
if ($bibentry->hasField('gsid')) {
$str .= ' [cites]';
@@ -2439,8 +2441,7 @@ class AcademicDisplay {
echo "\n".''."\n";
$tag = layoutHeaderHTML();
- // by default the abbreviation is incremented over all
- // searches
+ // by default the abbreviation is incremented over all searches
// since we don't know before hand all section, we can not index in decreasing order
static $count;
@@ -3247,7 +3248,7 @@ class PagedDisplay {
$index = ($this->page-1)*PAGE_SIZE + $i;
if (isset($this->entries[$index])) {
$bib = $this->entries[$index];
- $bib->toHTML();
+ $bib->toHTML();
} else {
//break;