diff --git a/bibtexbrowser.php b/bibtexbrowser.php
old mode 100644
new mode 100755
index 05a650a..1fa4e5b
--- a/bibtexbrowser.php
+++ b/bibtexbrowser.php
@@ -1,10 +1,10 @@
+
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
@@ -17,7 +17,7 @@ License, or (at your option) any later version.
// added on Wednesday, June 01 2011, bug found by Carlos Bras
if (!defined('BIBTEXBROWSER')) {
// this if block ends at the very end of this file, after all class and function declarations.
-define('BIBTEXBROWSER','v20121205');
+define('BIBTEXBROWSER','v__GITHUB__');
// *************** CONFIGURATION
@@ -80,6 +80,12 @@ define('BIBTEXBROWSER','v20121205');
// 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','v20121205');
@define('METADATA_DC',true);
@define('METADATA_EPRINTS',false);
-@define('LAYOUT','table'); // may be table/list/deflist. defines the HTML rendering options (
, /
,
, resp.). 'list' only works with 'ABBRV_TYPE'='index' (ordered list) and 'none' (unordered list, the default if another choice than 'list' is made).
-
// in embedded mode, we still need a URL for displaying bibtex entries alone
// this is usually resolved to bibtexbrowser.php
// but can be overridden in bibtexbrowser.local.php
@@ -141,7 +145,7 @@ define('Q_INNER_TYPE', 'x-bibtex-type');// used for representing the type of the
// we ensure that the pages won't get polluted
// if future versions of PHP change warning mechanisms...
-@error_reporting(E_ERROR);
+@error_reporting(/*pp4php:serl*/E_ALL/*lres*/);
/** parses $_GET[Q_FILE] and puts the result (an object of type BibDataBase) in $_GET[Q_DB].
@@ -243,7 +247,7 @@ function _zetDB($bibtex_filenames) {
&& is_readable($compiledbib)
&& filesize($compiledbib)>0
) {
- $f = fopen($compiledbib,'r+'); // my Unix seems to consider flock as a writing operation
+ $f = fopen($compiledbib,'r+'); // some Unix seem to consider flock as a writing operation
//we use a lock to avoid that a call to bibbtexbrowser made while we write the object loads an incorrect object
if (flock($f,LOCK_EX)) {
$s = filesize($compiledbib);
@@ -1245,7 +1249,7 @@ class BibEntry {
return $this->fields;
}
- /** Returns the abbreviation. */
+ /** Returns the raw, undecorated abbreviation depending on ABBRV_TYPE. */
function getRawAbbrv() {
if (ABBRV_TYPE == 'index') return $this->index;
if (ABBRV_TYPE == 'none') return '';
@@ -1260,10 +1264,10 @@ class BibEntry {
return $f($this);
}
- /** Returns the abbreviation. */
+ /** Returns the abbreviation, etc [1] if ABBRV_TYPE='index'. */
function getAbbrv() {
$abbrv = $this->getRawAbbrv();
- if ( ABBRV_TYPE == 'key' || ABBRV_TYPE == 'year' || ( ABBRV_TYPE == 'index' && LAYOUT != 'list' ) ) {
+ if ( ABBRV_TYPE != 'none' ) {
$abbrv = '['.$abbrv.']';
}
return $abbrv;
@@ -1309,44 +1313,48 @@ class BibEntry {
/** Outputs HTML line according to layout */
function toHTML() {
- switch(LAYOUT) { // open row
+ switch(BIBTEXBROWSER_LAYOUT) { // open row
case 'list':
- echo '
';
+ echo '
';
+ break;
+ case 'ordered_list':
+ echo '
';
break;
case 'table':
echo '
';
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 '
';
+ 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.
@@ -1398,7 +1406,7 @@ class BibEntry {
// referrer, the id pf a collection of objects
// see also http://www.openurl.info/registry/docs/pdf/info-sid.pdf
- $url_parts[]='rfr_id='.s3988('info:sid/'.$_SERVER['HTTP_HOST'].':'.@$_GET[Q_FILE]);
+ $url_parts[]='rfr_id='.s3988('info:sid/'.@$_SERVER['HTTP_HOST'].':'.@$_GET[Q_FILE]);
$url_parts[]='rft.date='.s3988($this->getYear());
@@ -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.
*/
+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 '' . $tag . '>';
+/** prints the footer of a layouted HTML, depending on BIBTEXBROWSER_LAYOUT e.g.
*/
+function print_footer_layout() {
+ echo '' . get_HTML_tag_for_layout() . '>';
}
/** 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;
}
@@ -1922,7 +1944,7 @@ class IndependentYearMenu {
function poweredby() {
$poweredby = "\n".'
';
$poweredby .= '';
- $poweredby .= 'Powered by bibtexbrowser';
+ $poweredby .= 'Powered by bibtexbrowser';
$poweredby .= '
'."\n";
return $poweredby;
}
@@ -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".'