Fixing function name conflict with audio module
[project/views_bonus.git] / views_bonus_audio_playlist.module
CommitLineData
82f496fe
EM
1<?php
2// $Id$
3
4function views_bonus_audio_playlist_views_style_plugins() {
5 if (file_exists('./' . drupal_get_path('module', 'audio') .'/flash_mp3_player/')) {
6 $items['audio_playlist'] = array(
7 'name' => t('Audio: Playlist'),
8 'theme' => 'views_bonus_audio_playlist',
9 'summary_theme' => 'views_summary',
10 );
11 }
12 return $items;
13}
14
15function theme_views_bonus_audio_playlist($view, $nodes, $type) {
16 if (isset($_GET['playlist'])) {
17 return views_bonus_audio_playlist($view, $nodes, $type);
18 }
19 else {
41d41d40 20 return views_bonus_audio_view($view, $nodes, $type);
82f496fe
EM
21 }
22}
23
41d41d40 24function views_bonus_audio_view($view, $nodes, $type) {
82f496fe
EM
25 global $base_url;
26
27 $flash_mp3_player = $base_url .'/'. drupal_get_path('module', 'audio') .'/flash_mp3_player/';
28 $options = array_merge((array) $options, array(
29 'file' => url($view->real_url, 'playlist', NULL, true),
82f496fe
EM
30 ));
31
32 $url = url($flash_mp3_player . 'mp3player.swf');
33 if ($options) {
34 $flashvars = drupal_query_string_encode($options);
35 }
36
37 $output = <<<EOF
38<object
39 classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
40 width="300"
41 height="200"
42 id="mp3player"
43 codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"
44>
45 <param
46 name="movie"
47 value="$url"
48 />
49 <param
50 name="flashvars"
51 value="$flashvars"
52 />
53 <embed
54 src="$url" width="300" height="200" name="mp3player"
55 flashvars="$flashvars"
56 type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"
57 />
58</object>
59EOF;
60
61 return $output;
62}
63
64function views_bonus_audio_playlist($view, $nodes, $type) {
65 $output = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n";
66 $output .= "<playlist version=\"1\" xmlns=\"http://xspf.org/ns/0/\">\n";
67 $output .= " <title>" . views_get_title($view, $type) . "</title>\n";
68 $output .= " <trackList>\n";
69 foreach ($nodes as $n) {
70 $node = node_load($n->nid);
71 $output .= theme('views_bonus_audio_track_xml', $node);
72 }
73 $output .= " </trackList>\n";
74 $output .= "</playlist>\n";
75 drupal_set_header('Content-Type: text/xml; charset=utf-8');
76 print $output;
77 exit;
78}
79
80function theme_views_bonus_audio_track_xml($node) {
81 $output .= " <track>\n";
82 $output .= " <annotation>" . check_plain($node->title) . "</annotation>\n";
83 $output .= " <title>" . check_plain($node->audio_tags['title']) . "</title>\n";
84 $output .= " <track>" . check_plain($node->audio_tags['track']) . "</track>\n";
e4b201a3 85 $output .= " <location>" . check_url($node->url_play) . "?" . $node->audio_fileinfo['fileformat'] . "</location>\n";
82f496fe
EM
86 $output .= " <info>" . url("node/$node->nid", NULL, NULL, TRUE) . "</info>\n";
87 $output .= " <identifier>" . $node->nid . "</identifier>\n";
88 $output .= " </track>\n";
89 return $output;
90}