Class Structures_BibTex

Description

Structures_BibTex

A class which provides common methods to access and create Strings in BibTex format. Example 1: Parsing a BibTex File and returning the number of entries

  1. $bibtex = new Structures_BibTex();
  2. $ret = $bibtex->loadFile('foo.bib');
  3. if (PEAR::isError($ret)) {
  4. die($ret->getMessage());
  5. }
  6. $bibtex->parse();
  7. print "There are ".$bibtex->amount()." entries";
Example 2: Parsing a BibTex File and getting all Titles
  1. $bibtex = new Structures_BibTex();
  2. $ret = $bibtex->loadFile('bibtex.bib');
  3. if (PEAR::isError($ret)) {
  4. die($ret->getMessage());
  5. }
  6. $bibtex->parse();
  7. foreach ($bibtex->data as $entry) {
  8. print $entry['title']."<br />";
  9. }
Example 3: Adding an entry and printing it in BibTex Format
  1. $bibtex = new Structures_BibTex();
  2. $addarray = array();
  3. $addarray['type'] = 'Article';
  4. $addarray['cite'] = 'art2';
  5. $addarray['title'] = 'Titel2';
  6. $addarray['author'][0] = 'John Doe';
  7. $addarray['author'][1] = 'Jane Doe';
  8. $bibtex->addEntry($addarray);
  9. print nl2br($bibtex->bibTex());

Located in /BibTex.php (line 75)


	
			
Variable Summary
string $content
array $data
string $htmlstring
string $rtfstring
array $warnings
Method Summary
void Structures_BibTex ([mixed $options = array()])
void addEntry (array $newentry)
int amount ()
string bibTex ()
void clearWarnings ()
array getStatistic ()
true hasWarning ()
string html ()
mixed loadFile (string $filename)
boolean parse ()
string rtf ()
mixed setOption (string $option, mixed $value)
Variables
string $content (line 90)

String with the BibTex content

  • access: public
array $data (line 83)

Array with the BibTex Data

  • access: public
string $htmlstring (line 125)

HTML Format String

  • access: public
string $rtfstring (line 118)

RTF Format String

  • access: public
array $warnings (line 104)

Array to store warnings

  • access: public
Methods
Constructor Structures_BibTex (line 133)

Constructor

  • access: public
void Structures_BibTex ([mixed $options = array()])
addEntry (line 816)

Adds a new BibTex entry to the data

  • access: public
void addEntry (array $newentry)
  • array $newentry: The new data to add
amount (line 750)

Returns the amount of available BibTex entries

  • return: The amount of available BibTex entries
  • access: public
int amount ()
bibTex (line 763)

Converts the stored BibTex entries to a BibTex String

In the field list, the author is the last field.

  • return: The BibTex string
  • access: public
string bibTex ()
clearWarnings (line 728)

Cleares all warnings

  • access: public
void clearWarnings ()
getStatistic (line 830)

Returns statistic

This functions returns a hash table. The keys are the different entry types and the values are the amount of these entries.

  • return: Hash Table with the data
  • access: public
array getStatistic ()
hasWarning (line 738)

Is there a warning?

  • return: if there is, false otherwise
  • access: public
true hasWarning ()
html (line 935)

Returns the stored data in HTML format

This method simply returns a HTML formatted string. This is done very simple and is not intended for heavy using and fine formatting. This should be done by BibTex! It is intended to give some kind of quick preview. If you want to change the default format you have to override the class variable "htmlstring". This variable is used and the placeholders simply replaced. Lines with no data cause an warning!

  • return: the HTML Strings
string html ()
loadFile (line 186)

Reads a give BibTex File

  • return: true on success PEAR_Error on failure
  • access: public
mixed loadFile (string $filename)
  • string $filename: Name of the file
parse (line 207)

Parses what is stored in content and clears the content if the parsing is successfull.

  • return: true on success and PEAR_Error if there was a problem
  • access: public
boolean parse ()
rtf (line 857)

Returns the stored data in RTF format

This method simply returns a RTF formatted string. This is done very simple and is not intended for heavy using and fine formatting. This should be done by BibTex! It is intended to give some kind of quick preview or to send someone a reference list as word/rtf format (even some people in the scientific field still use word). If you want to change the default format you have to override the class variable "rtfstring". This variable is used and the placeholders simply replaced. Lines with no data cause an warning!

  • return: the RTF Strings
string rtf ()
setOption (line 168)

Sets run-time configuration options

  • return: true on success PEAR_Error on failure
  • access: public
mixed setOption (string $option, mixed $value)
  • string $option: option name
  • mixed $value: value for the option

Documentation generated on Fri, 28 Jul 2006 20:01:02 +0200 by phpDocumentor 1.3.0RC5