ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
LibRIS\RISWriter Class Reference

Class for writing RIS data. More...

+ Collaboration diagram for LibRIS\RISWriter:

Public Member Functions

 __construct ()
 writeRecords ($records)
 Write a series of records to a single RIS string.
 writeRecord ($tags)
 Write a single record as an RIS string.

Detailed Description

Class for writing RIS data.

General usage:

<?php
use \LibRIS\RISWriter;
$writer = new RISWriter();
// Write an associative array of records to a string.
$str = $writer->writeRecords($records);
?>

Definition at line 20 of file RISWriter.php.

Constructor & Destructor Documentation

LibRIS\RISWriter::__construct ( )

Definition at line 22 of file RISWriter.php.

{ }

Member Function Documentation

LibRIS\RISWriter::writeRecord (   $tags)

Write a single record as an RIS string.

The record should be an associative array of tags to values.

Parameters
array$tagsAn associative array of key => array(value1, value2,...).
Return values
stringThe record as a string.

Definition at line 55 of file RISWriter.php.

{
$buffer = array();
$fmt = '%s - %s';
$buffer[] = sprintf($fmt, 'TY', $tags['TY'][0]);
unset($tags['TY']);
foreach ($tags as $tag => $values) {
foreach ($values as $value) {
$buffer[] = sprintf($fmt, $tag, $value);
}
}
$buffer[] = 'ER - ';
return implode(RISReader::RIS_EOL, $buffer);
}
LibRIS\RISWriter::writeRecords (   $records)

Write a series of records to a single RIS string.

Parameters
array$recordsAn array in the format generated by RISReader::parseFile()
Return values
stringThe record as a string.

Definition at line 34 of file RISWriter.php.

References $records.

{
$buffer = array();
foreach ($records as $record) {
$buffer[] = $this->writeRecord($record);
}
return implode(RISReader::RIS_EOL, $buffer);
}

The documentation for this class was generated from the following file: