ILIAS  release_4-4 Revision
getid3_writetags Class Reference

getID3() by James Heinrich info@.nosp@m.geti.nosp@m.d3.or.nosp@m.g // More...

+ Collaboration diagram for getid3_writetags:

Public Member Functions

 getid3_writetags ()
 
 WriteTags ()
 
 DeleteTags ($TagFormatsToDelete)
 
 MergeExistingTagData ($TagFormat, &$tag_data)
 
 FormatDataForAPE ()
 
 FormatDataForID3v1 ()
 
 FormatDataForID3v2 ($id3v2_majorversion)
 
 FormatDataForVorbisComment ()
 
 FormatDataForMetaFLAC ()
 
 FormatDataForReal ()
 

Data Fields

 $filename
 
 $tagformats = array()
 
 $tag_data = array(array())
 
 $tag_encoding = 'ISO-8859-1'
 
 $overwrite_tags = true
 
 $remove_other_tags = false
 
 $id3v2_tag_language = 'eng'
 
 $id3v2_paddedlength = 4096
 
 $warnings = array()
 
 $errors = array()
 
 $ThisFileInfo
 

Detailed Description

getID3() by James Heinrich info@.nosp@m.geti.nosp@m.d3.or.nosp@m.g //

//

Definition at line 47 of file write.php.

Member Function Documentation

◆ DeleteTags()

getid3_writetags::DeleteTags (   $TagFormatsToDelete)

Definition at line 346 of file write.php.

References $filename, and $success.

Referenced by WriteTags().

346  {
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  }
getID3() by James Heinrich info@getid3.org //
getID3() by James Heinrich info@getid3.org //
$success
Definition: Utf8Test.php:87
getID3() by James Heinrich info@getid3.org //
getID3() by James Heinrich info@getid3.org //
Definition: write.real.php:16
+ Here is the caller graph for this function:

◆ FormatDataForAPE()

getid3_writetags::FormatDataForAPE ( )

Definition at line 432 of file write.php.

References getid3_lib\iconv_fallback(), and MergeExistingTagData().

432  {
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  }
iconv_fallback($in_charset, $out_charset, $string)
Definition: getid3.lib.php:951
MergeExistingTagData($TagFormat, &$tag_data)
Definition: write.php:419
+ Here is the call graph for this function:

◆ FormatDataForID3v1()

getid3_writetags::FormatDataForID3v1 ( )

Definition at line 459 of file write.php.

References getid3_lib\iconv_fallback(), getid3_id3v1\LookupGenreID(), and MergeExistingTagData().

459  {
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  }
iconv_fallback($in_charset, $out_charset, $string)
Definition: getid3.lib.php:951
LookupGenreID($genre, $allowSCMPXextended=false)
MergeExistingTagData($TagFormat, &$tag_data)
Definition: write.php:419
+ Here is the call graph for this function:

◆ FormatDataForID3v2()

getid3_writetags::FormatDataForID3v2 (   $id3v2_majorversion)

Definition at line 485 of file write.php.

References $id3v2_tag_language, $tag_encoding, getid3_lib\iconv_fallback(), getid3_write_id3v2\ID3v2ShortFrameNameLookup(), and MergeExistingTagData().

485  {
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  }
iconv_fallback($in_charset, $out_charset, $string)
Definition: getid3.lib.php:951
ID3v2ShortFrameNameLookup($majorversion, $long_description)
MergeExistingTagData($TagFormat, &$tag_data)
Definition: write.php:419
+ Here is the call graph for this function:

◆ FormatDataForMetaFLAC()

getid3_writetags::FormatDataForMetaFLAC ( )

Definition at line 574 of file write.php.

References FormatDataForVorbisComment().

574  {
575  // FLAC & OggFLAC use VorbisComments same as OggVorbis
576  // but require metaflac to do the writing rather than vorbiscomment
577  return $this->FormatDataForVorbisComment();
578  }
FormatDataForVorbisComment()
Definition: write.php:545
+ Here is the call graph for this function:

◆ FormatDataForReal()

getid3_writetags::FormatDataForReal ( )

Definition at line 580 of file write.php.

References getid3_lib\iconv_fallback(), and MergeExistingTagData().

580  {
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  }
iconv_fallback($in_charset, $out_charset, $string)
Definition: getid3.lib.php:951
MergeExistingTagData($TagFormat, &$tag_data)
Definition: write.php:419
+ Here is the call graph for this function:

◆ FormatDataForVorbisComment()

getid3_writetags::FormatDataForVorbisComment ( )

Definition at line 545 of file write.php.

References $tag_data, getid3_lib\iconv_fallback(), and MergeExistingTagData().

Referenced by FormatDataForMetaFLAC().

545  {
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  }
iconv_fallback($in_charset, $out_charset, $string)
Definition: getid3.lib.php:951
MergeExistingTagData($TagFormat, &$tag_data)
Definition: write.php:419
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getid3_writetags()

getid3_writetags::getid3_writetags ( )

Definition at line 66 of file write.php.

66  {
67  return true;
68  }

◆ MergeExistingTagData()

getid3_writetags::MergeExistingTagData (   $TagFormat,
$tag_data 
)

Definition at line 419 of file write.php.

Referenced by FormatDataForAPE(), FormatDataForID3v1(), FormatDataForID3v2(), FormatDataForReal(), and FormatDataForVorbisComment().

419  {
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  }
+ Here is the caller graph for this function:

◆ WriteTags()

getid3_writetags::WriteTags ( )

Definition at line 71 of file write.php.

References $errors, $filename, $id3v2_paddedlength, $success, $tag_encoding, DeleteTags(), and getid3_lib\IncludeDependency().

71  {
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  }
getID3() by James Heinrich info@getid3.org //
DeleteTags($TagFormatsToDelete)
Definition: write.php:346
$success
Definition: Utf8Test.php:87
getID3() by James Heinrich info@getid3.org //
getID3() by James Heinrich info@getid3.org //
Definition: write.real.php:16
IncludeDependency($filename, $sourcefile, $DieOnFailure=false)
+ Here is the call graph for this function:

Field Documentation

◆ $errors

getid3_writetags::$errors = array()

Definition at line 61 of file write.php.

Referenced by WriteTags().

◆ $filename

getid3_writetags::$filename

Definition at line 50 of file write.php.

Referenced by DeleteTags(), and WriteTags().

◆ $id3v2_paddedlength

getid3_writetags::$id3v2_paddedlength = 4096

Definition at line 58 of file write.php.

Referenced by WriteTags().

◆ $id3v2_tag_language

getid3_writetags::$id3v2_tag_language = 'eng'

Definition at line 57 of file write.php.

Referenced by FormatDataForID3v2().

◆ $overwrite_tags

getid3_writetags::$overwrite_tags = true

Definition at line 54 of file write.php.

◆ $remove_other_tags

getid3_writetags::$remove_other_tags = false

Definition at line 55 of file write.php.

◆ $tag_data

getid3_writetags::$tag_data = array(array())

Definition at line 52 of file write.php.

Referenced by FormatDataForVorbisComment().

◆ $tag_encoding

getid3_writetags::$tag_encoding = 'ISO-8859-1'

Definition at line 53 of file write.php.

Referenced by FormatDataForID3v2(), and WriteTags().

◆ $tagformats

getid3_writetags::$tagformats = array()

Definition at line 51 of file write.php.

◆ $ThisFileInfo

getid3_writetags::$ThisFileInfo

Definition at line 64 of file write.php.

◆ $warnings

getid3_writetags::$warnings = array()

Definition at line 60 of file write.php.


The documentation for this class was generated from the following file: