Exporting --
Possibility to export the data using Structures_BibTex
Overview
The class Structures_BibTex provides some methods to export the data stored in the class.
Currently the class exports the data in the following formats:
BibTeX - The whole data in BibTeX
RTF - The data with enough matching data as a short list in RTF format
HTML - The data with enough matching data as a short list in HTML format
BibTeX
One of the basic features is of course the export in BibTeX format. This is simply done by invoking
the bibTex() method.
require_once 'Structures/BibTex.php';
$bibtex = new Structures_BibTex();
$ret = $bibtex->loadFile('foo.bib');
if (PEAR::isError($ret)) {
die($ret->getMessage());
}
$bibtex->parse();
echo 'The data in BibTeX format:<br />';
echo $bibtex->bibTex();
RTF
This feature was introduced to enable some kind of import into Word. Word (of course also Open Office or kword)
understands the RTF format. It is simply possible to save the output as 'somefile.rtf' and be opened in Word. This
will satisfy the Windows users. To use it simply call the method rtf().
require_once 'Structures/BibTex.php';
$bibtex = new Structures_BibTex();
$ret = $bibtex->loadFile('foo.bib');
if (PEAR::isError($ret)) {
die($ret->getMessage());
}
$bibtex->parse();
echo 'The data in RTF format:<br />';
echo $bibtex->rtf();
The default format for every entry is first the authors, then the title bold and in double quotes, then the journal
italic and finally the year. To change the default format you should override the class variable rtfstring. The default
rtfstring looks like this: 'AUTHORS, "{\b TITLE}", {\i JOURNAL}, YEAR'. The string AUTHORS, TITLE, JOURNAL and YEAR are
substituted with the corresponding values.
require_once 'Structures/BibTex.php';
$bibtex = new Structures_BibTex();
$ret = $bibtex->loadFile('foo.bib');
if (PEAR::isError($ret)) {
die($ret->getMessage());
}
$bibtex->parse();
$bibtex->rtfstring = 'AUTHORS, "TITLE", JOURNAL, YEAR';
echo 'The data in RTF format (but this time plain):<br />';
echo $bibtex->rtf();
HTML
This feature is just a simple HTML generation. The default formatting is the same as in rtf.
To use it call the method html().
require_once 'Structures/BibTex.php';
$bibtex = new Structures_BibTex();
$ret = $bibtex->loadFile('foo.bib');
if (PEAR::isError($ret)) {
die($ret->getMessage());
}
$bibtex->parse();
echo 'The data in HTML format:<br />';
echo $bibtex->html();
As with the RTF export it is possible to override the default HTML string.The default string is stored in the
class variable htmlstring and looks like this: AUTHORS, "<strong>TITLE</strong>", <em>JOURNAL</em>, YEAR<br />.
require_once 'Structures/BibTex.php';
$bibtex = new Structures_BibTex();
$ret = $bibtex->loadFile('foo.bib');
if (PEAR::isError($ret)) {
die($ret->getMessage());
}
$bibtex->parse();
$bibtex->htmlstring = 'AUTHORS, "TITLE", JOURNAL, YEAR';
echo 'The data in HTML format (but this time plain):<br />';
echo $bibtex->html();