| 1 |
<?php |
<?php |
| 2 |
// $Id: audio_feeds_views.inc,v 1.8 2007/08/03 02:41:13 drewish Exp $ |
// $Id: audio_feeds_views.inc,v 1.9 2007/08/27 23:23:54 drewish Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 13 |
'theme' => 'audio_feeds_views_xspf', |
'theme' => 'audio_feeds_views_xspf', |
| 14 |
'summary_theme' => 'views_summary', |
'summary_theme' => 'views_summary', |
| 15 |
); |
); |
| 16 |
return $items; |
return $items; |
| 17 |
} |
} |
| 18 |
|
|
| 19 |
/** |
/** |
| 21 |
*/ |
*/ |
| 22 |
function theme_audio_feeds_views_xspf($view, $nodes, $type) { |
function theme_audio_feeds_views_xspf($view, $nodes, $type) { |
| 23 |
if (isset($_GET['xspf'])) { |
if (isset($_GET['xspf'])) { |
| 24 |
return audio_feeds_views_prepare_xspf(views_get_title($view, $type), url($view->real_url, null, null, true), $nodes); |
return audio_feeds_views_prepare_xspf(views_get_title($view, $type), url($view->real_url, array('absolute' => true)), $nodes); |
| 25 |
} |
} |
| 26 |
elseif (isset($_GET['m3u'])) { |
elseif (isset($_GET['m3u'])) { |
| 27 |
return theme('audio_feeds_views_m3u', $view, $nodes, $type); |
return theme('audio_feeds_views_m3u', $view, $nodes, $type); |
| 41 |
} |
} |
| 42 |
} |
} |
| 43 |
$filters = $query_string ? audio_feeds_query_string_encode($query_string) .'%26xspf' : 'xspf'; |
$filters = $query_string ? audio_feeds_query_string_encode($query_string) .'%26xspf' : 'xspf'; |
| 44 |
$playlist_url = url($view->real_url, $filters, NULL, TRUE); |
$playlist_url = url($view->real_url, array('query' => $filters, 'absolute' => TRUE)); |
| 45 |
$output = theme($player['theme_xspf'], $playlist_url); |
$output = theme($player['theme_xspf'], $playlist_url); |
| 46 |
$output .= theme('audio_feeds_views_links', $view, $query_string); |
$output .= theme('audio_feeds_views_links', $view, $query_string); |
| 47 |
return $output; |
return $output; |
| 55 |
global $base_url; |
global $base_url; |
| 56 |
|
|
| 57 |
// prepare feed metadata |
// prepare feed metadata |
| 58 |
$metadata = array('title' => $title, |
$metadata = array( |
| 59 |
'author' => $base_url, |
'title' => $title, |
| 60 |
'link' => $base_url, |
'author' => $base_url, |
| 61 |
'feed_url' => $url |
'link' => $base_url, |
| 62 |
); |
'feed_url' => $url |
| 63 |
|
); |
| 64 |
|
|
| 65 |
// prepare feed items |
// prepare feed items |
| 66 |
foreach ($nodes as $n) { |
foreach ($nodes as $n) { |
| 67 |
$audio = node_load($n->nid); |
$audio = node_load($n->nid); |
| 68 |
// use the first image uploaded as the included image if it exists |
// use the first image uploaded as the included image if it exists |
| 69 |
$image = is_array($audio->audio_images) ? current($audio->audio_images) : ''; |
$image = is_array($audio->audio_images) ? current($audio->audio_images) : ''; |
| 70 |
$items[] = array('title' => $audio->audio_tags['title'] ? $audio->audio_tags['title'] : $audio->title, |
$items[] = array( |
| 71 |
'author' => $audio->audio_tags['artist'], |
'title' => $audio->audio_tags['title'] ? $audio->audio_tags['title'] : $audio->title, |
| 72 |
'album' => $audio->audio_tags['album'], |
'author' => $audio->audio_tags['artist'], |
| 73 |
'duration' => $audio->audio_file['playtime'], |
'album' => $audio->audio_tags['album'], |
| 74 |
'link' => url('node/'.$audio->nid, NULL, NULL, TRUE), |
'duration' => $audio->audio_file['playtime'], |
| 75 |
'image' => $image ? array('url' => $base_url .'/'. $image['filepath']) : '', |
'link' => url('node/'. $audio->nid, array('absolute' => TRUE)), |
| 76 |
'enclosure' => array('url' => $audio->url_play) |
'image' => $image ? array('url' => $base_url .'/'. $image['filepath']) : '', |
| 77 |
); |
'enclosure' => array('url' => $audio->url_play) |
| 78 |
|
); |
| 79 |
} |
} |
| 80 |
audio_feeds_generate_xspf($items, $metadata); |
audio_feeds_generate_xspf($items, $metadata); |
| 81 |
} |
} |
| 99 |
// prepare feed items |
// prepare feed items |
| 100 |
foreach ($nodes as $n) { |
foreach ($nodes as $n) { |
| 101 |
$audio = node_load($n->nid); |
$audio = node_load($n->nid); |
| 102 |
$items[] = array('title' => $audio->audio_tags['title'] ? $audio->audio_tags['title'] : $audio->title, |
$items[] = array( |
| 103 |
'author' => $audio->audio_tags['artist'], |
'title' => $audio->audio_tags['title'] ? $audio->audio_tags['title'] : $audio->title, |
| 104 |
'duration' => $audio->audio_file['playtime'], |
'author' => $audio->audio_tags['artist'], |
| 105 |
'enclosure' => array('url' => $audio->url_play) |
'duration' => $audio->audio_file['playtime'], |
| 106 |
); |
'enclosure' => array('url' => $audio->url_play) |
| 107 |
|
); |
| 108 |
} |
} |
| 109 |
audio_feeds_generate_m3u($items, $metadata); |
audio_feeds_generate_m3u($items, $metadata); |
| 110 |
} |
} |
| 128 |
// prepare feed items |
// prepare feed items |
| 129 |
foreach ($nodes as $n) { |
foreach ($nodes as $n) { |
| 130 |
$audio = node_load($n->nid); |
$audio = node_load($n->nid); |
| 131 |
$items[] = array('title' => $audio->audio_tags['title'] ? $audio->audio_tags['title'] : $audio->title, |
$items[] = array( |
| 132 |
'author' => $audio->audio_tags['artist'], |
'title' => $audio->audio_tags['title'] ? $audio->audio_tags['title'] : $audio->title, |
| 133 |
'duration' => $audio->audio_file['playtime'], |
'author' => $audio->audio_tags['artist'], |
| 134 |
'enclosure' => array('url' => $audio->url_play) |
'duration' => $audio->audio_file['playtime'], |
| 135 |
); |
'enclosure' => array('url' => $audio->url_play) |
| 136 |
|
); |
| 137 |
} |
} |
| 138 |
audio_feeds_generate_pls($items, $metadata); |
audio_feeds_generate_pls($items, $metadata); |
| 139 |
} |
} |
| 148 |
|
|
| 149 |
$links = array(); |
$links = array(); |
| 150 |
$links['m3u']['title'] = t('m3u'); |
$links['m3u']['title'] = t('m3u'); |
| 151 |
$links['m3u']['href'] = url($view->real_url, $m3u_filter, null, true); |
$links['m3u']['href'] = url($view->real_url, array('query' => $m3u_filter, 'absolute' => true)); |
| 152 |
$links['pls']['title'] = t('pls'); |
$links['pls']['title'] = t('pls'); |
| 153 |
$links['pls']['href'] = url($view->real_url, $pls_filter, null, true); |
$links['pls']['href'] = url($view->real_url, array('query' => $pls_filter, 'absolute' => true)); |
| 154 |
$links['xspf']['title'] = t('xspf'); |
$links['xspf']['title'] = t('xspf'); |
| 155 |
$links['xspf']['href'] = url($view->real_url, $xspf_filter, null, true); |
$links['xspf']['href'] = url($view->real_url, array('query' => $xspf_filter, 'absolute' => true)); |
| 156 |
return theme('links', $links); |
return theme('links', $links); |
| 157 |
} |
} |
| 158 |
|
|
| 163 |
$view = new stdClass(); |
$view = new stdClass(); |
| 164 |
$view->name = 'audio_feeds'; |
$view->name = 'audio_feeds'; |
| 165 |
$view->description = 'Audio XSPF Player'; |
$view->description = 'Audio XSPF Player'; |
| 166 |
$view->access = array ( |
$view->access = array( |
| 167 |
0 => '1', |
0 => '1', |
| 168 |
1 => '2', |
1 => '2', |
| 169 |
); |
); |
| 180 |
$view->url = 'audio/listen'; |
$view->url = 'audio/listen'; |
| 181 |
$view->use_pager = FALSE; |
$view->use_pager = FALSE; |
| 182 |
$view->nodes_per_page = '15'; |
$view->nodes_per_page = '15'; |
| 183 |
$view->sort = array ( |
$view->sort = array( |
| 184 |
array ( |
array( |
| 185 |
'tablename' => 'node', |
'tablename' => 'node', |
| 186 |
'field' => 'created', |
'field' => 'created', |
| 187 |
'sortorder' => 'DESC', |
'sortorder' => 'DESC', |
| 188 |
'options' => 'normal', |
'options' => 'normal', |
| 189 |
), |
), |
| 190 |
); |
); |
| 191 |
$view->argument = array ( |
$view->argument = array( |
| 192 |
array ( |
array( |
| 193 |
'type' => 'rss_feed', |
'type' => 'rss_feed', |
| 194 |
'argdefault' => '2', |
'argdefault' => '2', |
| 195 |
'title' => '', |
'title' => '', |
| 198 |
'wildcard_substitution' => '', |
'wildcard_substitution' => '', |
| 199 |
), |
), |
| 200 |
); |
); |
| 201 |
$view->field = array ( |
$view->field = array( |
| 202 |
array ( |
array( |
| 203 |
'tablename' => 'node', |
'tablename' => 'node', |
| 204 |
'field' => 'title', |
'field' => 'title', |
| 205 |
'label' => '', |
'label' => '', |
| 207 |
'options' => 'link', |
'options' => 'link', |
| 208 |
), |
), |
| 209 |
); |
); |
| 210 |
$view->filter = array ( |
$view->filter = array( |
| 211 |
array ( |
array( |
| 212 |
'tablename' => 'node', |
'tablename' => 'node', |
| 213 |
'field' => 'type', |
'field' => 'type', |
| 214 |
'operator' => 'OR', |
'operator' => 'OR', |
| 215 |
'options' => '', |
'options' => '', |
| 216 |
'value' => array ( |
'value' => array( |
| 217 |
0 => 'audio', |
0 => 'audio', |
| 218 |
), |
), |
| 219 |
), |
), |
| 220 |
array ( |
array( |
| 221 |
'tablename' => 'node', |
'tablename' => 'node', |
| 222 |
'field' => 'status', |
'field' => 'status', |
| 223 |
'operator' => '=', |
'operator' => '=', |