ILIAS  Release_5_0_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 
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 }