| 22 |
* Implementation of hook_theme(). |
* Implementation of hook_theme(). |
| 23 |
*/ |
*/ |
| 24 |
function filefieldmp3player_theme() { |
function filefieldmp3player_theme() { |
| 25 |
|
$path = drupal_get_path('module', 'filefieldmp3player') .'/theme'; |
| 26 |
$theme = array(); |
$theme = array(); |
| 27 |
$players = mp3player_players(); |
$players = mp3player_players(); |
| 28 |
|
|
| 32 |
'function' => 'theme_filefieldmp3player_formatter_mp3player', |
'function' => 'theme_filefieldmp3player_formatter_mp3player', |
| 33 |
); |
); |
| 34 |
} |
} |
| 35 |
|
|
| 36 |
|
$theme['filefieldmp3player_description'] = array( |
| 37 |
|
'template' => 'description', |
| 38 |
|
'arguments' => array( |
| 39 |
|
'title' => NULL, |
| 40 |
|
'artist' => NULL, |
| 41 |
|
'album' => NULL, |
| 42 |
|
'year' => NULL, |
| 43 |
|
'track' => NULL, |
| 44 |
|
'genre' => NULL, |
| 45 |
|
), |
| 46 |
|
'path' => $path, |
| 47 |
|
); |
| 48 |
|
|
| 49 |
return $theme; |
return $theme; |
| 50 |
} |
} |
| 54 |
*/ |
*/ |
| 55 |
function theme_filefieldmp3player_formatter_mp3player($element) { |
function theme_filefieldmp3player_formatter_mp3player($element) { |
| 56 |
$item = $element['#item']; |
$item = $element['#item']; |
| 57 |
$parts = explode('_', $element['#formatter']); |
if($item['list'] == "0") { |
| 58 |
unset($parts[0]); |
// Isn't listed so bail now |
| 59 |
$player = implode('_', $parts); |
return; |
| 60 |
|
} |
| 61 |
|
|
| 62 |
|
if(variable_get('mp3player_description', 'description') == 'id3' && module_exists(getid3) && getid3_load() == TRUE) { |
| 63 |
|
$info = getid3_analyze($item['filepath']); |
| 64 |
|
|
| 65 |
if(isset($item['data']['description']) && is_array($item['data'])) { |
$title = $info['tags']['id3v2']['title'][0]; |
| 66 |
|
$artist = $info['tags']['id3v2']['artist'][0]; |
| 67 |
|
$album = $info['tags']['id3v2']['album'][0]; |
| 68 |
|
$year = $info['tags']['id3v2']['year'][0]; |
| 69 |
|
$track = $info['tags']['id3v2']['track'][0]; |
| 70 |
|
$genre = $info['tags']['id3v2']['genre'][0]; |
| 71 |
|
|
| 72 |
|
$description = theme('filefieldmp3player_description', $title, $artist, $album, $year, $track, $genre); |
| 73 |
|
} |
| 74 |
|
else if(isset($item['data']['description']) && is_array($item['data'])) { |
| 75 |
//Data straight from node isn't serialized |
//Data straight from node isn't serialized |
| 76 |
$description = $item['data']['description']; |
$description = $item['data']['description']; |
| 77 |
} |
} |
| 80 |
$bits = unserialize($item['data']); |
$bits = unserialize($item['data']); |
| 81 |
$description = $bits['description']; |
$description = $bits['description']; |
| 82 |
} |
} |
| 83 |
|
|
| 84 |
|
$parts = explode('_', $element['#formatter']); |
| 85 |
|
unset($parts[0]); |
| 86 |
|
$player = implode('_', $parts); |
| 87 |
|
|
| 88 |
if (!empty($item['filepath'])) { |
if (!empty($item['filepath'])) { |
| 89 |
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') { |
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') { |