ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 }