ILIAS  release_4-4 Revision
RISWriter.php
Go to the documentation of this file.
1 <?php
2 namespace LibRIS;
3 
19 class RISWriter {
20 
21  public function __construct() {}
22 
31  public function writeRecords($records) {
32  $buffer = array();
33  foreach ($records as $record) {
34  $buffer[] = $this->writeRecord($record);
35  }
36  return implode(RISReader::RIS_EOL, $buffer);
37  }
38 
49  public function writeRecord($tags) {
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  }
65 
66 }
writeRecords($records)
Write a series of records to a single RIS string.
Definition: RISWriter.php:31
writeRecord($tags)
Write a single record as an RIS string.
Definition: RISWriter.php:49
$records
Definition: simple_test.php:22
Class for writing RIS data.
Definition: RISWriter.php:19
This is a library for parsing RIS files.