ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
write.php
Go to the documentation of this file.
1 <?php
4 // available at http://getid3.sourceforge.net //
5 // or http://www.getid3.org //
7 // See readme.txt for more details //
10 // write.php //
11 // module for writing tags (APEv2, ID3v1, ID3v2) //
12 // dependencies: getid3.lib.php //
13 // write.apetag.php (optional) //
14 // write.id3v1.php (optional) //
15 // write.id3v2.php (optional) //
16 // write.vorbiscomment.php (optional) //
17 // write.metaflac.php (optional) //
18 // write.lyrics3.php (optional) //
19 // ///
21 
22 if (!defined('GETID3_INCLUDEPATH')) {
23  die('getid3.php MUST be included before calling getid3_writetags');
24 }
25 if (!include_once(GETID3_INCLUDEPATH.'getid3.lib.php')) {
26  die('write.php depends on getid3.lib.php, which is missing.');
27 }
28 
29 
30 // NOTES:
31 //
32 // You should pass data here with standard field names as follows:
33 // * TITLE
34 // * ARTIST
35 // * ALBUM
36 // * TRACKNUMBER
37 // * COMMENT
38 // * GENRE
39 // * YEAR
40 // * ATTACHED_PICTURE (ID3v2 only)
41 //
42 // http://www.personal.uni-jena.de/~pfk/mpp/sv8/apekey.html
43 // The APEv2 Tag Items Keys definition says "TRACK" is correct but foobar2000 uses "TRACKNUMBER" instead
44 // Pass data here as "TRACKNUMBER" for compatability with all formats
45 
46 
48 {
49  // public
50  var $filename; // absolute filename of file to write tags to
51  var $tagformats = array(); // array of tag formats to write ('id3v1', 'id3v2.2', 'id2v2.3', 'id3v2.4', 'ape', 'vorbiscomment', 'metaflac', 'real')
52  var $tag_data = array(array()); // 2-dimensional array of tag data (ex: $data['ARTIST'][0] = 'Elvis')
53  var $tag_encoding = 'ISO-8859-1'; // text encoding used for tag data ('ISO-8859-1', 'UTF-8', 'UTF-16', 'UTF-16LE', 'UTF-16BE', )
54  var $overwrite_tags = true; // if true will erase existing tag data and write only passed data; if false will merge passed data with existing tag data
55  var $remove_other_tags = false; // if true will erase remove all existing tags and only write those passed in $tagformats; if false will ignore any tags not mentioned in $tagformats
56 
57  var $id3v2_tag_language = 'eng'; // ISO-639-2 3-character language code needed for some ID3v2 frames (http://www.id3.org/iso639-2.html)
58  var $id3v2_paddedlength = 4096; // minimum length of ID3v2 tags (will be padded to this length if tag data is shorter)
59 
60  var $warnings = array(); // any non-critical errors will be stored here
61  var $errors = array(); // any critical errors will be stored here
62 
63  // private
64  var $ThisFileInfo; // analysis of file before writing
65 
66  function getid3_writetags() {
67  return true;
68  }
69 
70 
71  function WriteTags() {
72 
73  if (empty($this->filename)) {
74  $this->errors[] = 'filename is undefined in getid3_writetags';
75  return false;
76  } elseif (!file_exists($this->filename)) {
77  $this->errors[] = 'filename set to non-existant file "'.$this->filename.'" in getid3_writetags';
78  return false;
79  }
80 
81  if (!is_array($this->tagformats)) {
82  $this->errors[] = 'tagformats must be an array in getid3_writetags';
83  return false;
84  }
85 
86  $TagFormatsToRemove = array();
87  if (filesize($this->filename) == 0) {
88 
89  // empty file special case - allow any tag format, don't check existing format
90  // could be useful if you want to generate tag data for a non-existant file
91  $this->ThisFileInfo = array('fileformat'=>'');
92  $AllowedTagFormats = array('id3v1', 'id3v2.2', 'id3v2.3', 'id3v2.4', 'ape', 'lyrics3');
93 
94  } else {
95 
96  $getID3 = new getID3;
97  $getID3->encoding = $this->tag_encoding;
98  $this->ThisFileInfo = $getID3->analyze($this->filename);
99 
100  // check for what file types are allowed on this fileformat
101  switch (@$this->ThisFileInfo['fileformat']) {
102  case 'mp3':
103  case 'mp2':
104  case 'mp1':
105  case 'riff': // maybe not officially, but people do it anyway
106  $AllowedTagFormats = array('id3v1', 'id3v2.2', 'id3v2.3', 'id3v2.4', 'ape', 'lyrics3');
107  break;
108 
109  case 'mpc':
110  $AllowedTagFormats = array('ape');
111  break;
112 
113  case 'flac':
114  $AllowedTagFormats = array('metaflac');
115  break;
116 
117  case 'real':
118  $AllowedTagFormats = array('real');
119  break;
120 
121  case 'ogg':
122  switch (@$this->ThisFileInfo['audio']['dataformat']) {
123  case 'flac':
124  //$AllowedTagFormats = array('metaflac');
125  $this->errors[] = 'metaflac is not (yet) compatible with OggFLAC files';
126  return false;
127  break;
128  case 'vorbis':
129  $AllowedTagFormats = array('vorbiscomment');
130  break;
131  default:
132  $this->errors[] = 'metaflac is not (yet) compatible with Ogg files other than OggVorbis';
133  return false;
134  break;
135  }
136  break;
137 
138  default:
139  $AllowedTagFormats = array();
140  break;
141  }
142  foreach ($this->tagformats as $requested_tag_format) {
143  if (!in_array($requested_tag_format, $AllowedTagFormats)) {
144  $errormessage = 'Tag format "'.$requested_tag_format.'" is not allowed on "'.@$this->ThisFileInfo['fileformat'];
145  if (@$this->ThisFileInfo['fileformat'] != @$this->ThisFileInfo['audio']['dataformat']) {
146  $errormessage .= '.'.@$this->ThisFileInfo['audio']['dataformat'];
147  }
148  $errormessage .= '" files';
149  $this->errors[] = $errormessage;
150  return false;
151  }
152  }
153 
154  // List of other tag formats, removed if requested
155  if ($this->remove_other_tags) {
156  foreach ($AllowedTagFormats as $AllowedTagFormat) {
157  switch ($AllowedTagFormat) {
158  case 'id3v2.2':
159  case 'id3v2.3':
160  case 'id3v2.4':
161  if (!in_array('id3v2', $TagFormatsToRemove) && !in_array('id3v2.2', $this->tagformats) && !in_array('id3v2.3', $this->tagformats) && !in_array('id3v2.4', $this->tagformats)) {
162  $TagFormatsToRemove[] = 'id3v2';
163  }
164  break;
165 
166  default:
167  if (!in_array($AllowedTagFormat, $this->tagformats)) {
168  $TagFormatsToRemove[] = $AllowedTagFormat;
169  }
170  break;
171  }
172  }
173  }
174  }
175 
176  $WritingFilesToInclude = array_merge($this->tagformats, $TagFormatsToRemove);
177 
178  // Check for required include files and include them
179  foreach ($WritingFilesToInclude as $tagformat) {
180  switch ($tagformat) {
181  case 'ape':
182  $GETID3_ERRORARRAY = &$this->errors;
183  if (!getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'write.apetag.php', __FILE__, false)) {
184  return false;
185  }
186  break;
187 
188  case 'id3v1':
189  case 'lyrics3':
190  case 'vorbiscomment':
191  case 'metaflac':
192  case 'real':
193  $GETID3_ERRORARRAY = &$this->errors;
194  if (!getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'write.'.$tagformat.'.php', __FILE__, false)) {
195  return false;
196  }
197  break;
198 
199  case 'id3v2.2':
200  case 'id3v2.3':
201  case 'id3v2.4':
202  case 'id3v2':
203  $GETID3_ERRORARRAY = &$this->errors;
204  if (!getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'write.id3v2.php', __FILE__, false)) {
205  return false;
206  }
207  break;
208 
209  default:
210  $this->errors[] = 'unknown tag format "'.$tagformat.'" in $tagformats in WriteTags()';
211  return false;
212  break;
213  }
214 
215  }
216 
217  // Validation of supplied data
218  if (!is_array($this->tag_data)) {
219  $this->errors[] = '$tag_data is not an array in WriteTags()';
220  return false;
221  }
222  // convert supplied data array keys to upper case, if they're not already
223  foreach ($this->tag_data as $tag_key => $tag_array) {
224  if (strtoupper($tag_key) !== $tag_key) {
225  $this->tag_data[strtoupper($tag_key)] = $this->tag_data[$tag_key];
226  unset($this->tag_data[$tag_key]);
227  }
228  }
229  // convert source data array keys to upper case, if they're not already
230  if (!empty($this->ThisFileInfo['tags'])) {
231  foreach ($this->ThisFileInfo['tags'] as $tag_format => $tag_data_array) {
232  foreach ($tag_data_array as $tag_key => $tag_array) {
233  if (strtoupper($tag_key) !== $tag_key) {
234  $this->ThisFileInfo['tags'][$tag_format][strtoupper($tag_key)] = $this->ThisFileInfo['tags'][$tag_format][$tag_key];
235  unset($this->ThisFileInfo['tags'][$tag_format][$tag_key]);
236  }
237  }
238  }
239  }
240 
241  // Convert "TRACK" to "TRACKNUMBER" (if needed) for compatability with all formats
242  if (isset($this->tag_data['TRACK']) && !isset($this->tag_data['TRACKNUMBER'])) {
243  $this->tag_data['TRACKNUMBER'] = $this->tag_data['TRACK'];
244  unset($this->tag_data['TRACK']);
245  }
246 
247  // Remove all other tag formats, if requested
248  if ($this->remove_other_tags) {
249  $this->DeleteTags($TagFormatsToRemove);
250  }
251 
252  // Write data for each tag format
253  foreach ($this->tagformats as $tagformat) {
254  $success = false; // overridden if tag writing is successful
255  switch ($tagformat) {
256  case 'ape':
257  $ape_writer = new getid3_write_apetag;
258  if (($ape_writer->tag_data = $this->FormatDataForAPE()) !== false) {
259  $ape_writer->filename = $this->filename;
260  if (($success = $ape_writer->WriteAPEtag()) === false) {
261  $this->errors[] = 'WriteAPEtag() failed with message(s):<PRE><UL><LI>'.trim(implode('</LI><LI>', $ape_writer->errors)).'</LI></UL></PRE>';
262  }
263  } else {
264  $this->errors[] = 'FormatDataForAPE() failed';
265  }
266  break;
267 
268  case 'id3v1':
269  $id3v1_writer = new getid3_write_id3v1;
270  if (($id3v1_writer->tag_data = $this->FormatDataForID3v1()) !== false) {
271  $id3v1_writer->filename = $this->filename;
272  if (($success = $id3v1_writer->WriteID3v1()) === false) {
273  $this->errors[] = 'WriteID3v1() failed with message(s):<PRE><UL><LI>'.trim(implode('</LI><LI>', $id3v1_writer->errors)).'</LI></UL></PRE>';
274  }
275  } else {
276  $this->errors[] = 'FormatDataForID3v1() failed';
277  }
278  break;
279 
280  case 'id3v2.2':
281  case 'id3v2.3':
282  case 'id3v2.4':
283  $id3v2_writer = new getid3_write_id3v2;
284  $id3v2_writer->majorversion = intval(substr($tagformat, -1));
285  $id3v2_writer->paddedlength = $this->id3v2_paddedlength;
286  if (($id3v2_writer->tag_data = $this->FormatDataForID3v2($id3v2_writer->majorversion)) !== false) {
287  $id3v2_writer->filename = $this->filename;
288  if (($success = $id3v2_writer->WriteID3v2()) === false) {
289  $this->errors[] = 'WriteID3v2() failed with message(s):<PRE><UL><LI>'.trim(implode('</LI><LI>', $id3v2_writer->errors)).'</LI></UL></PRE>';
290  }
291  } else {
292  $this->errors[] = 'FormatDataForID3v2() failed';
293  }
294  break;
295 
296  case 'vorbiscomment':
297  $vorbiscomment_writer = new getid3_write_vorbiscomment;
298  if (($vorbiscomment_writer->tag_data = $this->FormatDataForVorbisComment()) !== false) {
299  $vorbiscomment_writer->filename = $this->filename;
300  if (($success = $vorbiscomment_writer->WriteVorbisComment()) === false) {
301  $this->errors[] = 'WriteVorbisComment() failed with message(s):<PRE><UL><LI>'.trim(implode('</LI><LI>', $vorbiscomment_writer->errors)).'</LI></UL></PRE>';
302  }
303  } else {
304  $this->errors[] = 'FormatDataForVorbisComment() failed';
305  }
306  break;
307 
308  case 'metaflac':
309  $metaflac_writer = new getid3_write_metaflac;
310  if (($metaflac_writer->tag_data = $this->FormatDataForMetaFLAC()) !== false) {
311  $metaflac_writer->filename = $this->filename;
312  if (($success = $metaflac_writer->WriteMetaFLAC()) === false) {
313  $this->errors[] = 'WriteMetaFLAC() failed with message(s):<PRE><UL><LI>'.trim(implode('</LI><LI>', $metaflac_writer->errors)).'</LI></UL></PRE>';
314  }
315  } else {
316  $this->errors[] = 'FormatDataForMetaFLAC() failed';
317  }
318  break;
319 
320  case 'real':
321  $real_writer = new getid3_write_real;
322  if (($real_writer->tag_data = $this->FormatDataForReal()) !== false) {
323  $real_writer->filename = $this->filename;
324  if (($success = $real_writer->WriteReal()) === false) {
325  $this->errors[] = 'WriteReal() failed with message(s):<PRE><UL><LI>'.trim(implode('</LI><LI>', $real_writer->errors)).'</LI></UL></PRE>';
326  }
327  } else {
328  $this->errors[] = 'FormatDataForReal() failed';
329  }
330  break;
331 
332  default:
333  $this->errors[] = 'Invalid tag format to write: "'.$tagformat.'"';
334  return false;
335  break;
336  }
337  if (!$success) {
338  return false;
339  }
340  }
341  return true;
342 
343  }
344 
345 
346  function DeleteTags($TagFormatsToDelete) {
347  foreach ($TagFormatsToDelete as $DeleteTagFormat) {
348  $success = false; // overridden if tag deletion is successful
349  switch ($DeleteTagFormat) {
350  case 'id3v1':
351  $id3v1_writer = new getid3_write_id3v1;
352  $id3v1_writer->filename = $this->filename;
353  if (($success = $id3v1_writer->RemoveID3v1()) === false) {
354  $this->errors[] = 'RemoveID3v1() failed with message(s):<PRE><UL><LI>'.trim(implode('</LI><LI>', $id3v1_writer->errors)).'</LI></UL></PRE>';
355  }
356  break;
357 
358  case 'id3v2':
359  $id3v2_writer = new getid3_write_id3v2;
360  $id3v2_writer->filename = $this->filename;
361  if (($success = $id3v2_writer->RemoveID3v2()) === false) {
362  $this->errors[] = 'RemoveID3v2() failed with message(s):<PRE><UL><LI>'.trim(implode('</LI><LI>', $id3v2_writer->errors)).'</LI></UL></PRE>';
363  }
364  break;
365 
366  case 'ape':
367  $ape_writer = new getid3_write_apetag;
368  $ape_writer->filename = $this->filename;
369  if (($success = $ape_writer->DeleteAPEtag()) === false) {
370  $this->errors[] = 'DeleteAPEtag() failed with message(s):<PRE><UL><LI>'.trim(implode('</LI><LI>', $ape_writer->errors)).'</LI></UL></PRE>';
371  }
372  break;
373 
374  case 'vorbiscomment':
375  $vorbiscomment_writer = new getid3_write_vorbiscomment;
376  $vorbiscomment_writer->filename = $this->filename;
377  if (($success = $vorbiscomment_writer->DeleteVorbisComment()) === false) {
378  $this->errors[] = 'DeleteVorbisComment() failed with message(s):<PRE><UL><LI>'.trim(implode('</LI><LI>', $vorbiscomment_writer->errors)).'</LI></UL></PRE>';
379  }
380  break;
381 
382  case 'metaflac':
383  $metaflac_writer = new getid3_write_metaflac;
384  $metaflac_writer->filename = $this->filename;
385  if (($success = $metaflac_writer->DeleteMetaFLAC()) === false) {
386  $this->errors[] = 'DeleteMetaFLAC() failed with message(s):<PRE><UL><LI>'.trim(implode('</LI><LI>', $metaflac_writer->errors)).'</LI></UL></PRE>';
387  }
388  break;
389 
390  case 'lyrics3':
391  $lyrics3_writer = new getid3_write_lyrics3;
392  $lyrics3_writer->filename = $this->filename;
393  if (($success = $lyrics3_writer->DeleteLyrics3()) === false) {
394  $this->errors[] = 'DeleteLyrics3() failed with message(s):<PRE><UL><LI>'.trim(implode('</LI><LI>', $lyrics3_writer->errors)).'</LI></UL></PRE>';
395  }
396  break;
397 
398  case 'real':
399  $real_writer = new getid3_write_real;
400  $real_writer->filename = $this->filename;
401  if (($success = $real_writer->RemoveReal()) === false) {
402  $this->errors[] = 'RemoveReal() failed with message(s):<PRE><UL><LI>'.trim(implode('</LI><LI>', $real_writer->errors)).'</LI></UL></PRE>';
403  }
404  break;
405 
406  default:
407  $this->errors[] = 'Invalid tag format to delete: "'.$tagformat.'"';
408  return false;
409  break;
410  }
411  if (!$success) {
412  return false;
413  }
414  }
415  return true;
416  }
417 
418 
419  function MergeExistingTagData($TagFormat, &$tag_data) {
420  // Merge supplied data with existing data, if requested
421  if ($this->overwrite_tags) {
422  // do nothing - ignore previous data
423  } else {
424  if (!isset($this->ThisFileInfo['tags'][$TagFormat])) {
425  return false;
426  }
427  $tag_data = array_merge_recursive($tag_data, $this->ThisFileInfo['tags'][$TagFormat]);
428  }
429  return true;
430  }
431 
432  function FormatDataForAPE() {
433  $ape_tag_data = array();
434  foreach ($this->tag_data as $tag_key => $valuearray) {
435  switch ($tag_key) {
436  case 'ATTACHED_PICTURE':
437  // ATTACHED_PICTURE is ID3v2 only - ignore
438  $this->warnings[] = '$data['.$tag_key.'] is assumed to be ID3v2 APIC data - NOT written to APE tag';
439  break;
440 
441  default:
442  foreach ($valuearray as $key => $value) {
443  if (is_string($value) || is_numeric($value)) {
444  $ape_tag_data[$tag_key][$key] = getid3_lib::iconv_fallback($this->tag_encoding, 'UTF-8', $value);
445  } else {
446  $this->warnings[] = '$data['.$tag_key.']['.$key.'] is not a string value - all of $data['.$tag_key.'] NOT written to APE tag';
447  unset($ape_tag_data[$tag_key]);
448  break;
449  }
450  }
451  break;
452  }
453  }
454  $this->MergeExistingTagData('ape', $ape_tag_data);
455  return $ape_tag_data;
456  }
457 
458 
459  function FormatDataForID3v1() {
460  $tag_data_id3v1['genreid'] = 255;
461  if (!empty($this->tag_data['GENRE'])) {
462  foreach ($this->tag_data['GENRE'] as $key => $value) {
463  if (getid3_id3v1::LookupGenreID($value) !== false) {
464  $tag_data_id3v1['genreid'] = getid3_id3v1::LookupGenreID($value);
465  break;
466  }
467  }
468  }
469 
470  $tag_data_id3v1['title'] = getid3_lib::iconv_fallback($this->tag_encoding, 'ISO-8859-1', @implode(' ', @$this->tag_data['TITLE']));
471  $tag_data_id3v1['artist'] = getid3_lib::iconv_fallback($this->tag_encoding, 'ISO-8859-1', @implode(' ', @$this->tag_data['ARTIST']));
472  $tag_data_id3v1['album'] = getid3_lib::iconv_fallback($this->tag_encoding, 'ISO-8859-1', @implode(' ', @$this->tag_data['ALBUM']));
473  $tag_data_id3v1['year'] = getid3_lib::iconv_fallback($this->tag_encoding, 'ISO-8859-1', @implode(' ', @$this->tag_data['YEAR']));
474  $tag_data_id3v1['comment'] = getid3_lib::iconv_fallback($this->tag_encoding, 'ISO-8859-1', @implode(' ', @$this->tag_data['COMMENT']));
475 
476  $tag_data_id3v1['track'] = intval(getid3_lib::iconv_fallback($this->tag_encoding, 'ISO-8859-1', @implode(' ', @$this->tag_data['TRACKNUMBER'])));
477  if ($tag_data_id3v1['track'] <= 0) {
478  $tag_data_id3v1['track'] = '';
479  }
480 
481  $this->MergeExistingTagData('id3v1', $tag_data_id3v1);
482  return $tag_data_id3v1;
483  }
484 
485  function FormatDataForID3v2($id3v2_majorversion) {
486  $tag_data_id3v2 = array();
487 
488  $ID3v2_text_encoding_lookup[2] = array('ISO-8859-1'=>0, 'UTF-16'=>1);
489  $ID3v2_text_encoding_lookup[3] = array('ISO-8859-1'=>0, 'UTF-16'=>1);
490  $ID3v2_text_encoding_lookup[4] = array('ISO-8859-1'=>0, 'UTF-16'=>1, 'UTF-16BE'=>2, 'UTF-8'=>3);
491  foreach ($this->tag_data as $tag_key => $valuearray) {
492  $ID3v2_framename = getid3_write_id3v2::ID3v2ShortFrameNameLookup($id3v2_majorversion, $tag_key);
493  switch ($ID3v2_framename) {
494  case 'APIC':
495  foreach ($valuearray as $key => $apic_data_array) {
496  if (isset($apic_data_array['data']) &&
497  isset($apic_data_array['picturetypeid']) &&
498  isset($apic_data_array['description']) &&
499  isset($apic_data_array['mime'])) {
500  $tag_data_id3v2['APIC'][] = $apic_data_array;
501  } else {
502  $this->errors[] = 'ID3v2 APIC data is not properly structured';
503  return false;
504  }
505  }
506  break;
507 
508  case '':
509  $this->errors[] = 'ID3v2: Skipping "'.$tag_key.'" because cannot match it to a known ID3v2 frame type';
510  // some other data type, don't know how to handle it, ignore it
511  break;
512 
513  default:
514  // most other (text) frames can be copied over as-is
515  foreach ($valuearray as $key => $value) {
516  if (isset($ID3v2_text_encoding_lookup[$id3v2_majorversion][$this->tag_encoding])) {
517  // source encoding is valid in ID3v2 - use it with no conversion
518  $tag_data_id3v2[$ID3v2_framename][$key]['encodingid'] = $ID3v2_text_encoding_lookup[$id3v2_majorversion][$this->tag_encoding];
519  $tag_data_id3v2[$ID3v2_framename][$key]['data'] = $value;
520  } else {
521  // source encoding is NOT valid in ID3v2 - convert it to an ID3v2-valid encoding first
522  if ($id3v2_majorversion < 4) {
523  // convert data from other encoding to UTF-16
524  $tag_data_id3v2[$ID3v2_framename][$key]['encodingid'] = 1;
525  $tag_data_id3v2[$ID3v2_framename][$key]['data'] = getid3_lib::iconv_fallback($this->tag_encoding, 'UTF-16', $value);
526 
527  } else {
528  // convert data from other encoding to UTF-8
529  $tag_data_id3v2[$ID3v2_framename][$key]['encodingid'] = 3;
530  $tag_data_id3v2[$ID3v2_framename][$key]['data'] = getid3_lib::iconv_fallback($this->tag_encoding, 'UTF-8', $value);
531  }
532  }
533 
534  // These values are not needed for all frame types, but if they're not used no matter
535  $tag_data_id3v2[$ID3v2_framename][$key]['description'] = '';
536  $tag_data_id3v2[$ID3v2_framename][$key]['language'] = $this->id3v2_tag_language;
537  }
538  break;
539  }
540  }
541  $this->MergeExistingTagData('id3v2', $tag_data_id3v2);
542  return $tag_data_id3v2;
543  }
544 
546  $tag_data_vorbiscomment = $this->tag_data;
547 
548  // check for multi-line comment values - split out to multiple comments if neccesary
549  // and convert data to UTF-8 strings
550  foreach ($tag_data_vorbiscomment as $tag_key => $valuearray) {
551  foreach ($valuearray as $key => $value) {
552  str_replace("\r", "\n", $value);
553  if (strstr($value, "\n")) {
554  unset($tag_data_vorbiscomment[$tag_key][$key]);
555  $multilineexploded = explode("\n", $value);
556  foreach ($multilineexploded as $newcomment) {
557  if (strlen(trim($newcomment)) > 0) {
558  $tag_data_vorbiscomment[$tag_key][] = getid3_lib::iconv_fallback($this->tag_encoding, 'UTF-8', $newcomment);
559  }
560  }
561  } elseif (is_string($value) || is_numeric($value)) {
562  $tag_data_vorbiscomment[$tag_key][$key] = getid3_lib::iconv_fallback($this->tag_encoding, 'UTF-8', $value);
563  } else {
564  $this->warnings[] = '$data['.$tag_key.']['.$key.'] is not a string value - all of $data['.$tag_key.'] NOT written to VorbisComment tag';
565  unset($tag_data_vorbiscomment[$tag_key]);
566  break;
567  }
568  }
569  }
570  $this->MergeExistingTagData('vorbiscomment', $tag_data_vorbiscomment);
571  return $tag_data_vorbiscomment;
572  }
573 
575  // FLAC & OggFLAC use VorbisComments same as OggVorbis
576  // but require metaflac to do the writing rather than vorbiscomment
577  return $this->FormatDataForVorbisComment();
578  }
579 
580  function FormatDataForReal() {
581  $tag_data_real['title'] = getid3_lib::iconv_fallback($this->tag_encoding, 'ISO-8859-1', @implode(' ', @$this->tag_data['TITLE']));
582  $tag_data_real['artist'] = getid3_lib::iconv_fallback($this->tag_encoding, 'ISO-8859-1', @implode(' ', @$this->tag_data['ARTIST']));
583  $tag_data_real['copyright'] = getid3_lib::iconv_fallback($this->tag_encoding, 'ISO-8859-1', @implode(' ', @$this->tag_data['COPYRIGHT']));
584  $tag_data_real['comment'] = getid3_lib::iconv_fallback($this->tag_encoding, 'ISO-8859-1', @implode(' ', @$this->tag_data['COMMENT']));
585 
586  $this->MergeExistingTagData('real', $tag_data_real);
587  return $tag_data_real;
588  }
589 
590 }
591 
592 ?>