ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5
RISWriter.php
Go to the documentation of this file.
1 <?php
2 namespace LibRIS;
3 
20 class RISWriter {
21 
22  public function __construct() { }
23 
24 
34  public function writeRecords($records) {
35  $buffer = array();
36  foreach ($records as $record) {
37  $buffer[] = $this->writeRecord($record);
38  }
39 
40  return implode(RISReader::RIS_EOL, $buffer);
41  }
42 
43 
55  public function writeRecord($tags) {
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  }
69 }
writeRecords($records)
Write a series of records to a single RIS string.
Definition: RISWriter.php:34
writeRecord($tags)
Write a single record as an RIS string.
Definition: RISWriter.php:55
$records
Definition: simple_test.php:17
Class for writing RIS data.
Definition: RISWriter.php:20
This is a library for parsing RIS files.