ILIAS  release_4-4 Revision
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. More...
 
 writeRecord ($tags)
 Write a single record as an RIS string. More...
 

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 19 of file RISWriter.php.

Constructor & Destructor Documentation

◆ __construct()

LibRIS\RISWriter::__construct ( )

Definition at line 21 of file RISWriter.php.

21 {}

Member Function Documentation

◆ writeRecord()

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 49 of file RISWriter.php.

49  {
50  $buffer = array();
51  $fmt = '%s - %s';
52 
53  $buffer[] = sprintf($fmt, 'TY', $tags['TY'][0]);
54  unset($tags['TY']);
55 
56  foreach ($tags as $tag => $values) {
57  foreach ($values as $value) {
58  $buffer[] = sprintf($fmt, $tag, $value);
59  }
60  }
61  $buffer[] = 'ER - ';
62 
63  return implode(RISReader::RIS_EOL, $buffer);
64  }

◆ writeRecords()

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 31 of file RISWriter.php.

References $records.

31  {
32  $buffer = array();
33  foreach ($records as $record) {
34  $buffer[] = $this->writeRecord($record);
35  }
36  return implode(RISReader::RIS_EOL, $buffer);
37  }
writeRecord($tags)
Write a single record as an RIS string.
Definition: RISWriter.php:49
$records
Definition: simple_test.php:22

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