You are here

function theme_filefieldmp3player_formatter_mp3player in MP3 Player 6.2

Same name and namespace in other branches
  1. 6 filefieldmp3player/filefieldmp3player.module \theme_filefieldmp3player_formatter_mp3player()

Formatter theme function for file fields presented as a Flash MP3 Player.

1 string reference to 'theme_filefieldmp3player_formatter_mp3player'
filefieldmp3player_theme in filefieldmp3player/filefieldmp3player.module
Implementation of hook_theme().

File

filefieldmp3player/filefieldmp3player.module, line 46

Code

function theme_filefieldmp3player_formatter_mp3player($element) {
  $item = $element['#item'];
  if (empty($item['filepath']) || $item['list'] == "0") {
    return FALSE;
  }
  $description = $item['filename'];
  $title = $artist = NULL;
  if (variable_get('mp3player_description', 'description') == 'id3' && module_exists('getid3') && getid3_load() == TRUE) {
    $id3 = getid3_analyze($item['filepath']);
    $title = $id3['tags']['id3v2']['title'][0];
    $artist = $id3['tags']['id3v2']['artist'][0];
    $description = theme('filefieldmp3player_description', $id3);
  }
  else {
    if (isset($item['data']['description'])) {

      //Data straight from node isn't serialized
      $description = $item['data']['description'];
    }
    else {
      if (gettype($item['data']) == 'string' && is_array(unserialize($item['data']))) {

        //Data from a View is on the other hand
        $bits = unserialize($item['data']);
        $description = $bits['description'];
      }
    }
  }
  $parts = explode('_', $element['#formatter']);
  unset($parts[0]);
  $player = implode('_', $parts);
  if ($item['filemime'] == 'audio/mpeg' || $item['filemime'] == 'audio/x-mpeg' || $item['filemime'] == 'audio/mp3' || $item['filemime'] == 'audio/x-mp3' || $item['filemime'] == 'audio/mpeg3' || $item['filemime'] == 'audio/x-mpeg3' || $item['filemime'] == 'audio/mpg' || $item['filemime'] == 'audio/x-mpg' || $item['filemime'] == 'audio/mpegaudi') {

    //MP3 files get special treatment.
    $out = theme('mp3player', $player, file_create_url($item['filepath']), $title, $artist, $description);
  }
  else {

    // Fall back to filefield's default behavior.
    $out = theme('filefield_formatter_default', $element);
  }
  return $out;
}