bibtexbrowser: publication lists with bibtex and PHP

by Martin Monperrus

bibtexbrowser is a PHP script that creates publication lists from Bibtex files. bibtexbrowser is stable, mature and easy to install. It is used in 100+ different universities around the globe (in 329 different domains according to Google).

This documentation is collaborative, you can improve it using a pull request on GitHub (file bibtexbrowser-documentation.wiki).

Features

* (02/2016) support for OpenGraph metadata
* (10/2015) support for filtering bibtex fields
* (10/2013) support for localization (see below)
* (07/2012) new label types (see config value ABBRV_TYPE)
* (10/2011) if a bibtex entry contains a field gsid (like Google Scholar ID), bibtexbrowser includes a link [cites] to the cited-by page of Google Scholar (e.g. http://scholar.google.com/scholar?cites=15080874515065717592)
* (03/2011) bibtexbrowser includes a hide/show mechanism for bibtex entries (in Javascript, see configuration variable BIBTEXBROWSER_USE_PROGRESSIVE_ENHANCEMENT)
* (10/2010) bibtexbrowser now supports cross-references (Bibtex crossref)
* (09/2010) bibtexbrowser now supports multiple bibtex files (bibtexbrowser.php?bib=file1.bib;file2.bib)
* (05/2010) bibtexbrowser adds links to your co-author pages if you define the corresponding @string (see function addHomepageLink)
* (01/2010) bibtexbrowser can handle user-defined bibliographic styles
* bibtexbrowser generates publication RSS feeds (simply add &rss at the end of the URL)! demo
* (10/2009) bibtexbrowser is able to generate a bibtex file containing only the selected entries (simply add &astext at the end of the link)
* (10/2009) bibtexbrowser is now independent of the configuration of register_globals
* (01/2009) bibtexbrowser allows multi criteria search, e.g. demo
* bibtexbrowser generates COinS for automatic import of bibliographic entries with Zotero and Mendeley.
* bibtexbrowser generates Google Scholar metadata so as to improve the visibility of your papers on Google Scholar.
* bibtexbrowser replaces constants defined in @STRING
* bibtexbrowser is very fast because it keeps a compiled version of the bibtex file (PHP object serialized)
* bibtexbrowser is compatible with PHP 4.x and PHP 5.x
* bibtexbrowser can display the menu and all entries with framesets demo
* bibtexbrowser can display all entries out of a bibtex file demo
* bibtexbrowser can display all entries for a given year demo
* bibtexbrowser can display a single bibtex entry demo
* bibtexbrowser can display found entries with a search word (it can be in any bib field) demo
* bibtexbrowser can display all entries with a bib keyword e.g. "?keywords=components". It matches against the "keywords" bibtex field. demo
* bibtexbrowser outputs valid XHTML 1.0 Transitional
* bibtexbrowser can display all entries for an author demo
* bibtexbrowser can be used with different encodings (change the default iso-8859-1 encoding if your bib file is in UTF-8 define('BIBTEX_INPUT_ENCODING','UTF-8') )
* bibtexbrowser is easy to install: just a single file.

Download

For feature requests or bug reports, please comment this page below; patches can be contributed as pull requests on github:)

Demo and screenshot

Basic installation

Create a bib file with the publication records (e.g. csgroup2008.bib) and upload it to your server.
* Use the link bibtexbrowser.php?bib=csgroup2008.bib (frameset based view)
* Use the link bibtexbrowser.php?bib=csgroup2008.bib&all (pub list sorted by year)
* Use the link bibtexbrowser.php?bib=csgroup2008.bib&all&academic (pub list sorted by publication type, then by year, see "Sectioning in academic mode" below)

Warning: bibtexbrowser maintains a cached version of the parsed bibtex, for high performance, check that PHP can write in the working directory of PHP.

Handling mutliple bibtex files: If you want to include several bibtex files, just give bibtexbrowser the files separated by semi-columns e.g:bibtexbrowser.php?bib=strings.bib;csgroup2008.bib

For instance, one can tweak the output by disabling the display of some headers and pieces of information.

.bibmenu {display:none} /* disables the [bibtex] and the like */
.bibanchor {display:none} /* disables the index [1] or [Name2010], etc. depending on the value of the configuration value ABBRV_TYPE and BIBTEXBROWSER_LAYOUT
.theader {display:none}
.sheader {display:none} /* disables the year header e.g., 2001 */

By setting your own style function
The bibliography style is encapsulated in a function. If you want to modify the bibliography style, you can copy the default style in a new file, say bibtexbrowser-yourstyle.php, and rename the function DefaultBibliographyStyle in say MyFancyBibliographyStyle.
Then, add in the file bibtexbrowser.local.php:

You can use your personalized function to add support for new fields in bibtex (pdf, file, etc.). Check-out the documentation of functions getLink(), getBibLink(), getGSLink() and getDoiLink(): they accept an optional argument for providing an image/icon instead of printing text.

// returns an empty string if no pdf field present
$result .= $bibentry->getLink('pdf','http://url.to/icons/pdf.png');
// returns an empty string if no slides field present
$result .= $bibentry->getLink('slides');
// returns an empty string if no poster field present
$result .= $bibentry->getLink('poster');

How to specify the encoding of bibtex files (UTF-8/ISO-8859-1/etc.)?

By default, bibtexbrowser assumes that the bibtex file is UTF-8 encoded. If you want to change it to e.g. ISO-8859-1, add into bibtexbrowser.local.php:

define('BIBTEX_INPUT_ENCODING','ISO-8859-1');

Note that if the bibtex only contains latex-encoded diacritics (e.g. \'e), it does not matter. The encoding of the bibtex file and the one of the generated HTML is identical.

How to disable Javascript progressive enhancement?

add into bibtexbrowser.local.php:define('BIBTEXBROWSER_USE_PROGRESSIVE_ENHANCEMENT',false);

How to remove the "[bibtex]" links?

@define('BIBTEXBROWSER_BIBTEX_LINKS',false);

How to change the reference indices?

// index => [1] The essence of metamodeling
// year => [2005] The essence of metamodeling
// x-abbrv => [SoSyM] The essence of metamodeling if the bibtex entry contains a field x-abbrv
define('ABBRV_TYPE','year');// may be year/x-abbrv/key/none/index

How to get the individual bib pages embedded as well?

define('BIBTEXBROWSER_URL',"");

How to add links to the slides of a conference/workshop paper?

You can simply fill the comment field of the bib entry with an HTML link:
@inproceedings{foo,
author="Jean Dupont",
title="Bibtexbrowser",
year=2009,
booktitle="Proceedings of the BIB conference",
comment={<a href="myslides.pdf">[slides]</a>}
}
This comment field can also be used to add acceptance rates and impact factors.

Copyright

This script is a fork from an excellent script of Joel Garcia, Leonardo Ruiz, and Yoonsik Cheon from the University of Texas at El Paso.

Bibtexbrowser is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

API Documentation

StateBasedBibtexParser

is a generic parser of bibtex files.
usage:

$delegate = new XMLPrettyPrinter();// or another delegate such as BibDBBuilder
$parser = new StateBasedBibtexParser($delegate);
$parser->parse(fopen('bibacid-utf8.bib','r'));

notes:
- It has no dependencies, it can be used outside of bibtexbrowser
- The delegate is expected to have some methods, see classes BibDBBuilder and XMLPrettyPrinter

ParserDelegate

a default empty implementation of a delegate for StateBasedBibtexParser

entryValuePart($key, $value, $type)

called for each sub parts of type {part} of a field value
for now, only CURLYTOP and CURLYONE events

XMLPrettyPrinter

is a possible delegate for StateBasedBibParser.
usage:
see snippet of [[#StateBasedBibParser]]

entryValuePart($key, $value, $type)

called for each sub parts of type {part} of a field value
for now, only CURLYTOP and CURLYONE events

notes:
- BibEntry are usually obtained with getEntryByKey or multisearch

__toString()

returns a debug string representation

BibEntry()

Creates an empty new bib entry. Each bib entry is assigned a unique
identification number.

setFile($filename)

Sets the name of the file containing this entry

timestamp()

Adds timestamp to this object

getTimestamp()

Returns the timestamp of this object

getType()

Returns the type of this bib entry.

setKey($value)

Sets the key of this bib entry.

removeField($name)

removes a field from this bibtex entry

setField($name, $value)

Sets a field of this bib entry.

setType($value)

Sets a type of this bib entry.

getURL()

Tries to build a good URL for this entry. The URL should be absolute (better for the generated RSS)

bib2links()

@see bib2links(), kept for backward compatibility

getLink($bibfield, $iconurl, $altlabel)

Read the bibtex field $bibfield and return a link with icon (if $iconurl is given) or text
e.g. given the bibtex entry: @article{myarticle, pdf={myarticle.pdf}},
$bibtexentry->getLink('pdf') creates a link to myarticle.pdf using the text '[pdf]'.
$bibtexentry->getLink('pdf','pdficon.png') returns &lt;a href="myarticle.pdf">&lt;img src="pdficon.png"/>&lt;/a>
if you want a label that is different from the bibtex field, add a third parameter.

getBibLink($iconurl)

returns a "[bib]" link

getUrlLink($iconurl, $label)

same as `getPdfLink`, kept for backward compatibility

getPdfLink($iconurl, $label)

returns a "[pdf]" link for the entry, if possible.
Tries to get the target URL from the 'pdf' field first, then from 'url' or 'file'.

getDoiLink($iconurl)

DOI are a special kind of links, where the url depends on the doi

getGSLink($iconurl)

GS (Google Scholar) are a special kind of links, where the url depends on the google scholar id

getIconOrTxt($txt, $iconurl)

replace [$ext] with an icon whose url is defined in a string
e.g. getIconOrTxt('pdf') will print '[pdf]'
or getIconOrTxt('pdf','http://link/to/icon.png') will use the icon linked by the url, or print '[pdf']
if the url does not point to a valid file (using the "alt" property of the "img" html tag)

getAbstract()

Reruns the abstract

getLastName($author)

Returns the last name of an author name.

getFirstName($author)

Returns the first name of an author name.

hasField($name)

Has this entry the given field?

getAuthor()

Returns the authors of this entry. If "author" is not given,
return a string 'Unknown'.

getKey()

Returns the key of this entry

getTitle()

Returns the title of this entry?

getPublisher()

Returns the publisher of this entry
It encodes a specific logic

getRawAuthors()

Returns the authors of this entry as an array (split by " and ")

formatAuthor($author)

Returns the formated author name w.r.t to the user preference
encoded in USE_COMMA_AS_NAME_SEPARATOR_IN_OUTPUT and USE_INITIALS_FOR_NAMES

formatAuthorCanonical($author)

Returns the formated author name as "FirstName LastName".

formatAuthorCommaSeparated($author)

Returns the formated author name as "LastName, FirstName".

formatAuthorInitials($author)

Returns the formated author name as "LastName Initials".
e.g. for Vancouver-style used by PubMed.

formattedAuthors()

@deprecated

getFormattedAuthors()

@deprecated

getFormattedAuthorsImproved()

@deprecated

getFormattedAuthorsArray()

Returns the authors as an array of strings (one string per author).

getFormattedAuthorsString()

Adds to getFormattedAuthors() the home page links and returns a string (not an array). Is configured with BIBTEXBROWSER_AUTHOR_LINKS and USE_COMMA_AS_NAME_SEPARATOR_IN_OUTPUT.

addAuthorPageLink($author)

adds a link to the author page

getCanonicalAuthors()

Returns the authors of this entry as an array in a canonical form

getArrayOfCommaSeparatedAuthors()

Returns the authors of this entry as an array in a comma-separated form

getCompactedAuthors()

Returns a compacted string form of author names by throwing away
all author names except for the first one and appending ", et al."

addHomepageLink($author)

add the link to the homepage if it is defined in a string
e.g. @string{hp_MartinMonperrus="http://www.monperrus.net/martin"}
The string is a concatenation of firstname, lastname, prefixed by hp_
Warning: by convention @string are case sensitive so please be keep the same case as author names
@thanks Eric Bodden for the idea

getEditors()

Returns the editors of this entry as an arry

getFormattedEditors()

Returns the editors of this entry as an arry

getYear()

Returns the year of this entry?

getKeywords()

returns the array of keywords

getField($name)

Returns the value of the given field?

getFields()

Returns the fields

getRawAbbrv()

Returns the raw, undecorated abbreviation depending on ABBRV_TYPE.

getAbbrv()

Returns the abbreviation, etc [1] if ABBRV_TYPE='index'.

setAbbrv($abbrv)

Sets the abbreviation (e.g. [OOPSLA] or [1])

getText()

Returns the verbatim text of this bib entry.

hasPhrase($phrase, $field)

Returns true if this bib entry contains the given phrase (PREG regexp)
in the given field. if $field is null, all fields are considered.
Note that this method is NOT case sensitive

toHTML($wrapped)

Outputs HTML line according to layout

toCoins()

Outputs an coins URL: see http://ocoins.info/cobg.html
Used by Zotero, mendeley, etc.

anchor()

Returns an anchor for this entry.

getConstants()

rebuild the set of constants used if any as a string

toEntryUnformatted()

Displays a

text of the given bib entry.
URLs are replaced by HTML links.

getFullText()

Gets the raw text of the entry (crossref + strings + entry)

getPages()

returns the first and last page of the entry as an array ([0]->first, [2]->last)

Displays a list menu in a table.
$title: title of the menu (string)
$list: list of menu items (string)
$page: page number to display (number)
$pageSize: size of each page
$pageKey: URL query name to send the page number to the server
$targetKey: URL query name to send the target of the menu item

menuPageBar($queryKey, $numEntries, $page, $pageSize, $start, $end)

Returns a string to displays forward and reverse page controls.
$queryKey: key to send the page number as a URL query string
$page: current page number to display
$numEntries: number of menu items
$start: start index of the current page
$end: end index of the current page

displayMenuItems($items, $startIndex, $endIndex, $queryKey)

Displays menu items (anchors) from the start index (inclusive) to
the end index (exclusive). For each menu, the following form of
string is printed:
<a href="...?bib=cheon.bib&author=Yoonsik+Cheon">
Cheon, Yoonsik</a>
<div class="mini_se"></div>

clears the query string in $_GET so that bibtexbrowser can be called multiple times

range()

Allow the user to search for a range of dates
The query string can comprise several elements separated by commas and
optionally white-space.
Each element can either be one number (a year) or two numbers
(a range of years) separated by anything non-numerical.

academic()

the academic keyword in URLs switch from a year based viey to a publication type based view