improved abbrv for list; factorized code for toHTML(); reverted modifications to bib2html and created bib2links() instead.
This commit is contained in:
+52
-51
@@ -1246,27 +1246,29 @@ class BibEntry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the abbreviation. */
|
/** Returns the abbreviation. */
|
||||||
function getAbbrv() {
|
function getRawAbbrv() {
|
||||||
if (ABBRV_TYPE == 'index') {
|
if (ABBRV_TYPE == 'index') return $this->index;
|
||||||
if ( LAYOUT == 'list' ) { // <ul> expects a raw number
|
|
||||||
return $this->index;
|
|
||||||
} else {
|
|
||||||
return '['.$this->index.']';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (ABBRV_TYPE == 'none') return '';
|
if (ABBRV_TYPE == 'none') return '';
|
||||||
if (ABBRV_TYPE == 'key') return '['.$this->getKey().']';
|
if (ABBRV_TYPE == 'key') return $this->getKey();
|
||||||
if (ABBRV_TYPE == 'year') return '['.$this->getYear().']';
|
if (ABBRV_TYPE == 'year') return $this->getYear();
|
||||||
if (ABBRV_TYPE == 'x-abbrv') {
|
if (ABBRV_TYPE == 'x-abbrv') {
|
||||||
if ($this->hasField('x-abbrv')) {return $this->getField('x-abbrv');}
|
if ($this->hasField('x-abbrv')) {return $this->getField('x-abbrv');}
|
||||||
return $this->abbrv;
|
return $this->abbrv;
|
||||||
}
|
}
|
||||||
|
|
||||||
// otherwise it is a user-defined function in bibtexbrowser.local.php
|
// otherwise it is a user-defined function in bibtexbrowser.local.php
|
||||||
$f = ABBRV_TYPE;
|
$f = ABBRV_TYPE;
|
||||||
return $f($this);
|
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]) */
|
/** Sets the abbreviation (e.g. [OOPSLA] or [1]) */
|
||||||
function setAbbrv($abbrv) {
|
function setAbbrv($abbrv) {
|
||||||
@@ -1307,10 +1309,37 @@ class BibEntry {
|
|||||||
|
|
||||||
/** Outputs HTML line according to layout */
|
/** Outputs HTML line according to layout */
|
||||||
function toHTML() {
|
function toHTML() {
|
||||||
switch(LAYOUT) {
|
switch(LAYOUT) { // open row
|
||||||
case 'list': $this->toLI(); break;
|
case 'list':
|
||||||
case 'table': $this->toTR(); break;
|
echo '<li class="bibline" value="'.$this->getAbbrv().'">';
|
||||||
case 'deflist': $this->toDD(); break;
|
break;
|
||||||
|
case 'table':
|
||||||
|
echo '<tr class="bibline"><td class="bibref">';
|
||||||
|
break;
|
||||||
|
case 'deflist':
|
||||||
|
echo '<dl class="bibline"><dt class="bibref">'; break;
|
||||||
|
}
|
||||||
|
$this->anchor();
|
||||||
|
switch(LAYOUT) { // close bibref and open bibitem
|
||||||
|
case 'table':
|
||||||
|
echo $this->getAbbrv().'</td><td class="bibitem">';
|
||||||
|
break;
|
||||||
|
case 'deflist':
|
||||||
|
echo $this->getAbbrv().'</dt><dd class="bibitem">';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
echo bib2html($this);
|
||||||
|
echo bib2links($this);
|
||||||
|
switch(LAYOUT) { // close row
|
||||||
|
case 'list':
|
||||||
|
echo '</li>';
|
||||||
|
break;
|
||||||
|
case 'table':
|
||||||
|
echo '</td></tr>';
|
||||||
|
break;
|
||||||
|
case 'deflist':
|
||||||
|
echo '</dd></dl>';
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1319,36 +1348,6 @@ class BibEntry {
|
|||||||
echo '<a name="'.$this->getAbbrv().'"></a>';
|
echo '<a name="'.$this->getAbbrv().'"></a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Outputs an TR line with two TDS inside
|
|
||||||
*/
|
|
||||||
function toTR() {
|
|
||||||
echo '<tr class="bibline">';
|
|
||||||
echo '<td class="bibref">';
|
|
||||||
$this->anchor();
|
|
||||||
echo $this->getAbbrv().'</td> ';
|
|
||||||
echo '<td class="bibitem">';
|
|
||||||
echo bib2html($this);
|
|
||||||
echo "</td></tr>\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 '<li class="bibline" value="'.$this->getAbbrv().'">';
|
|
||||||
$this->anchor();
|
|
||||||
echo bib2html($this);
|
|
||||||
echo "</li>\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Outputs an DL line (<dt>+<dd>) */
|
|
||||||
function toDD() {
|
|
||||||
echo '<dl class="bibline"><dt class="bibref">';
|
|
||||||
$this->anchor();
|
|
||||||
echo $this->getAbbrv().'</dt><dd class="bibitem">';
|
|
||||||
echo bib2html($this);
|
|
||||||
echo "</dd></dl>\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Outputs an coins URL: see http://ocoins.info/cobg.html
|
/** Outputs an coins URL: see http://ocoins.info/cobg.html
|
||||||
* Used by Zotero, mendeley, etc.
|
* Used by Zotero, mendeley, etc.
|
||||||
*/
|
*/
|
||||||
@@ -1486,7 +1485,10 @@ function layoutFooterHTML($tag) {
|
|||||||
/** this function encapsulates the user-defined name for bib to HTML*/
|
/** this function encapsulates the user-defined name for bib to HTML*/
|
||||||
function bib2html(&$bibentry) {
|
function bib2html(&$bibentry) {
|
||||||
$function = BIBLIOGRAPHYSTYLE;
|
$function = BIBLIOGRAPHYSTYLE;
|
||||||
$str = $function($bibentry);
|
return $function($bibentry);
|
||||||
|
}
|
||||||
|
|
||||||
|
function bib2links(&$bibentry) {
|
||||||
$href = 'href="'.$bibentry->getURL().'"';
|
$href = 'href="'.$bibentry->getURL().'"';
|
||||||
|
|
||||||
if (BIBTEXBROWSER_BIBTEX_LINKS) {
|
if (BIBTEXBROWSER_BIBTEX_LINKS) {
|
||||||
@@ -1494,14 +1496,14 @@ function bib2html(&$bibentry) {
|
|||||||
// using Xpath expressions on the XHTML source
|
// using Xpath expressions on the XHTML source
|
||||||
$str .= " <a".(BIBTEXBROWSER_BIB_IN_NEW_WINDOW?' target="_blank" ':'')." class=\"biburl\" title=\"".$bibentry->getKey()."\" {$href}>[bibtex]</a>";
|
$str .= " <a".(BIBTEXBROWSER_BIB_IN_NEW_WINDOW?' target="_blank" ':'')." class=\"biburl\" title=\"".$bibentry->getKey()."\" {$href}>[bibtex]</a>";
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns an empty string if no url present
|
// returns an empty string if no url present
|
||||||
$str .= $bibentry->getUrlLink();
|
$str .= $bibentry->getUrlLink();
|
||||||
|
|
||||||
if ($bibentry->hasField('doi')) {
|
if ($bibentry->hasField('doi')) {
|
||||||
$str .= ' <a href="http://dx.doi.org/'.$bibentry->getField("doi").'">[doi]</a>';
|
$str .= ' <a href="http://dx.doi.org/'.$bibentry->getField("doi").'">[doi]</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Google Scholar ID
|
// Google Scholar ID
|
||||||
if ($bibentry->hasField('gsid')) {
|
if ($bibentry->hasField('gsid')) {
|
||||||
$str .= ' <a href="http://scholar.google.com/scholar?cites='.$bibentry->getField("gsid").'">[cites]</a>';
|
$str .= ' <a href="http://scholar.google.com/scholar?cites='.$bibentry->getField("gsid").'">[cites]</a>';
|
||||||
@@ -2439,8 +2441,7 @@ class AcademicDisplay {
|
|||||||
echo "\n".'<div class="btb-header">'.$title.'</div>'."\n";
|
echo "\n".'<div class="btb-header">'.$title.'</div>'."\n";
|
||||||
$tag = layoutHeaderHTML();
|
$tag = layoutHeaderHTML();
|
||||||
|
|
||||||
// by default the abbreviation is incremented over all
|
// by default the abbreviation is incremented over all searches
|
||||||
// searches
|
|
||||||
|
|
||||||
// since we don't know before hand all section, we can not index in decreasing order
|
// since we don't know before hand all section, we can not index in decreasing order
|
||||||
static $count;
|
static $count;
|
||||||
@@ -3247,7 +3248,7 @@ class PagedDisplay {
|
|||||||
$index = ($this->page-1)*PAGE_SIZE + $i;
|
$index = ($this->page-1)*PAGE_SIZE + $i;
|
||||||
if (isset($this->entries[$index])) {
|
if (isset($this->entries[$index])) {
|
||||||
$bib = $this->entries[$index];
|
$bib = $this->entries[$index];
|
||||||
$bib->toHTML();
|
$bib->toHTML();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
//break;
|
//break;
|
||||||
|
|||||||
Reference in New Issue
Block a user