diff --git a/bibtexbrowser.php b/bibtexbrowser.php index c8922b6..1fa4e5b 100755 --- a/bibtexbrowser.php +++ b/bibtexbrowser.php @@ -4,7 +4,7 @@ URL: http://www.monperrus.net/martin/bibtexbrowser/ Feedback & Bug Reports: martin.monperrus@gmail.com (C) 2013 Matthieu Guillaumin -(C) 2006-2012 Martin Monperrus +(C) 2006-2013 Martin Monperrus (C) 2005-2006 The University of Texas at El Paso / Joel Garcia, Leonardo Ruiz, and Yoonsik Cheon This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -80,6 +80,12 @@ define('BIBTEXBROWSER','v__GITHUB__'); // their publication lists according to this bibtex @define('BIBTEXBROWSER_AUTHOR_LINKS','homepage'); +// BIBTEXBROWSER_LAYOUT defines the HTML rendering layout of the produced HTML +// may be table/list/ordered_list/definition (for ,
    ,
    resp.). +// for list/ordered_list, the abbrevations are not taken into account (see ABBRV_TYPE) +// for ordered_list, the index is given by HTML directly (in increasing order) +@define('BIBTEXBROWSER_LAYOUT','table'); + @define('BIBTEXBROWSER_DEBUG',false); @define('COMMA_NAMES',false);// do have authors in a comma separated form? @@ -118,8 +124,6 @@ define('BIBTEXBROWSER','v__GITHUB__'); @define('METADATA_DC',true); @define('METADATA_EPRINTS',false); -@define('LAYOUT','table'); // may be table/list/deflist. defines the HTML rendering options (
,
    /
'; + echo ''."\n"; break; - case 'deflist': - echo ''; + case 'definition': + echo ''."\n"; break; } } - /** Create the entry anchor */ - function anchor() { - echo ''; - } /** Outputs an coins URL: see http://ocoins.info/cobg.html * Used by Zotero, mendeley, etc. @@ -1409,6 +1417,40 @@ class BibEntry { } + /** Returns an anchor for this entry. */ + function anchor() { + return ''; + } + + /** returns a collection of links for the given bibtex entry + * e.g. [bibtex] [doi][pdf] + */ + function bib2links() { + $href = 'href="'.$this->getURL().'"'; + + $str = ''; + + if (BIBTEXBROWSER_BIBTEX_LINKS) { + // we add biburl and title to be able to retrieve this important information + // using Xpath expressions on the XHTML source + $str .= " getKey()."\" {$href}>[bibtex]"; + } + + // returns an empty string if no url present + $str .= $this->getUrlLink(); + + if ($this->hasField('doi')) { + $str .= ' [doi]'; + } + + // Google Scholar ID + if ($this->hasField('gsid')) { + $str .= ' [cites]'; + } + + return $str; + } + /** @@ -1454,32 +1496,36 @@ class BibEntry { } } +/** returns an HTML tag depending on BIBTEXBROWSER_LAYOUT e.g.
'; break; - case 'deflist': - echo '
'; break; + case 'definition': + echo '
'; + if (ABBRV_TYPE=='none') { die ('Cannot define an empty term!'); } + break; } - $this->anchor(); - switch(LAYOUT) { // close bibref and open bibitem + echo $this->anchor(); + switch(BIBTEXBROWSER_LAYOUT) { // close bibref and open bibitem case 'table': echo $this->getAbbrv().'
'; break; - case 'deflist': + case 'definition': echo $this->getAbbrv().'
'; break; } echo bib2html($this); - echo bib2links($this); - switch(LAYOUT) { // close row + echo $this->bib2links(); + switch(BIBTEXBROWSER_LAYOUT) { // close row case 'list': - echo ''; + echo ''."\n"; + break; + case 'ordered_list': + echo ''."\n"; break; case 'table': - echo '
*/ +function get_HTML_tag_for_layout() { + switch(BIBTEXBROWSER_LAYOUT) { /* switch for different layouts */ + case 'list': + $tag='ul'; + break; + case 'ordered_list': + $tag='ol'; + break; + case 'table': + $tag = 'table'; + break; + case 'definition': + $tag = 'div'; + break; + default: + die('Unknown BIBTEXBROWSER_LAYOUT'); + } + return $tag; +} -function layoutHeaderHTML() { - $tag = ''; - switch(LAYOUT) { /* switch for different layouts */ - case 'list': - if (ABBRV_TYPE=='index') { - $tag='ol'; - } else { // assume none - $tag='ul'; - } - break; - case 'table': - $tag = 'table'; - break; - case 'deflist': - $tag = 'div'; - break; - default: - die('Unknown LAYOUT'); - } - echo '<' . $tag . ' class="result">'; - return $tag; + +/** prints the header of a layouted HTML, depending on BIBTEXBROWSER_LAYOUT e.g.
*/ +function print_header_layout() { + echo '<' . get_HTML_tag_for_layout() . ' class="result">'."\n"; } -function layoutFooterHTML($tag) { - echo ''; +/** prints the footer of a layouted HTML, depending on BIBTEXBROWSER_LAYOUT e.g.
*/ +function print_footer_layout() { + echo ''; } /** this function encapsulates the user-defined name for bib to HTML*/ @@ -1488,30 +1534,6 @@ function bib2html(&$bibentry) { return $function($bibentry); } -function bib2links(&$bibentry) { - $href = 'href="'.$bibentry->getURL().'"'; - - if (BIBTEXBROWSER_BIBTEX_LINKS) { - // we add biburl and title to be able to retrieve this important information - // 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]'; - } - - return $str; -} - /** encapsulates the user-defined sections. @nodoc */ function _DefaultBibliographySections() { $function = BIBLIOGRAPHYSECTIONS; @@ -1727,7 +1749,7 @@ function DefaultBibliographyStyle(&$bibentry) { } // add the Coin URL - $result .= "\n".$bibentry->toCoins(); + $result .= $bibentry->toCoins(); return $result; } @@ -2371,7 +2393,7 @@ class SimpleDisplay { echo 'Options: '.@implode(',',$this->options).'
'; } - $tag = layoutHeaderHTML(); + print_header_layout(); $count = count($this->entries); $i=0; @@ -2382,7 +2404,7 @@ class SimpleDisplay { $bib->toHTML(); } // end foreach - layoutFooterHTML($tag); + print_footer_layout(); } // end function } // end class @@ -2438,21 +2460,21 @@ class AcademicDisplay { uasort($entries, ORDER_FUNCTION); if (count($entries)>0) { - echo "\n".'
'.$title.'
'."\n"; - $tag = layoutHeaderHTML(); + echo "\n".'
'.$title.'
'."\n"; + print_header_layout(); - // 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; - if ($count == NULL) { $count = 1; } // init - $id = $count; - foreach ($entries as $bib) { - $bib->setIndex($id++); - $bib->toHTML(); - } // end foreach - $count = @$count + count($entries); - layoutFooterHTML($tag); + // 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; + if ($count == NULL) { $count = 1; } // init + $id = $count; + foreach ($entries as $bib) { + $bib->setIndex($id++); + $bib->toHTML(); + } // end foreach + $count = @$count + count($entries); + print_footer_layout(); } } @@ -3243,7 +3265,7 @@ class PagedDisplay { } $this->menu($less, $more); - $tag = layoutHeaderHTML(); + print_header_layout(); for ($i = 0; $i < PAGE_SIZE; $i++) { $index = ($this->page-1)*PAGE_SIZE + $i; if (isset($this->entries[$index])) { @@ -3254,7 +3276,8 @@ class PagedDisplay { //break; } } // end foreach - layoutFooterHTML($tag); + + print_footer_layout(); $this->menu($less, $more); } @@ -3640,4 +3663,4 @@ class Dispatcher { $class = BIBTEXBROWSER_MAIN;// extension point $main = new $class(); $main->main(); -?> +?> \ No newline at end of file