function mediafront_get_playlist_from_view in MediaFront 7
Same name and namespace in other branches
- 6.2 mediafront.module \mediafront_get_playlist_from_view()
- 6 mediafront.module \mediafront_get_playlist_from_view()
- 7.2 mediafront.module \mediafront_get_playlist_from_view()
Returns a playlist provided a view.
2 calls to mediafront_get_playlist_from_view()
- mediafront_get_playlist in ./
mediafront.module - Gets a playlist
- theme_mediafront_player_view in ./
mediafront.module - Implement the theme for the media player for the Views module.
File
- ./
mediafront.module, line 337
Code
function mediafront_get_playlist_from_view($view, $args = null) {
// Create our playlist array.
$playlist = array();
$playlist['nodes'] = array();
$playlist['name'] = $view->name;
$playlist['total_rows'] = $view->total_rows ? $view->total_rows : ($view->query->pager ? $view->query->pager
->get_total_items() : 0);
// Iterate through our result and get our player nodes.
if ($view->base_table == 'node') {
foreach ($view->result as $node) {
if ($node = mediafront_get_node($node->nid, $args)) {
$playlist['nodes'][] = $node;
}
}
}
else {
if ($view->base_table == 'file_managed') {
foreach ($view->result as $file) {
$media = file_load($file->fid);
$node = array(
'title' => $media->filename,
);
mediafront_add_media($node, $media);
if ($preview = mediafront_get_media_preview($media)) {
$node["mediafiles"]["images"]["thumbnail"] = $preview;
$node["mediafiles"]["images"]["preview"] = str_replace('square_thumbnail', 'large', $preview);
}
$playlist['nodes'][] = $node;
}
}
}
// Return the playlist.
return $playlist;
}