Exporting

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

Author

The default is to export the name of the author in this format: "VON LAST, JR, FIRST". The corresponding placeholder will be substituted. The placeholders have to be uppercase. The format string is defined in the class variable authorstring. Changing the ouput of the author in the entries to this format "FIRST LAST" can be done like this:

Changing author format

<?php
require_once 'Structures/BibTex.php';
$bibtex               = new Structures_BibTex();
$bibtex->authorstring 'FIRST LAST';
?>

BibTeX

One of the basic features is of course the export in BibTeX format. This is simply done by invoking the bibTex() method.

Exporting in BibTeX format

<?php
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().

Exporting in RTF format

<?php
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.

Exporting in RTF format with different RTF string

<?php
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().

Exporting in HTML format

<?php
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 />.

Exporting in HTML format with different HTML string

<?php
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();
?>
Usage of warnings when using Structures_BibTex (Previous) Miscellaneous methods in the class Structures_BibTex (Next)
Last updated: Sat, 16 Feb 2019 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report.
View this page in:
  • English

User Notes:

There are no user contributed notes for this page.