ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
All Data Structures Namespaces Files Functions Variables Modules 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. 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 20 of file RISWriter.php.

Constructor & Destructor Documentation

◆ __construct()

LibRIS\RISWriter::__construct ( )

Definition at line 22 of file RISWriter.php.

22 { }

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

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

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

References $records.

34  {
35  $buffer = array();
36  foreach ($records as $record) {
37  $buffer[] = $this->writeRecord($record);
38  }
39 
40  return implode(RISReader::RIS_EOL, $buffer);
41  }
writeRecord($tags)
Write a single record as an RIS string.
Definition: RISWriter.php:55
$records
Definition: simple_test.php:17

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