You are here

function mediafront_get_playlist in MediaFront 7.2

Same name and namespace in other branches
  1. 6.2 mediafront.module \mediafront_get_playlist()
  2. 6 mediafront.module \mediafront_get_playlist()
  3. 7 mediafront.module \mediafront_get_playlist()

Gets a playlist

1 call to mediafront_get_playlist()
mediafront_get_playlist_json in ./mediafront.module
Gets a playlist in JSON format.

File

./mediafront.module, line 280

Code

function mediafront_get_playlist($playlist, $limit = 10, $start = 0) {

  // Get the views object.
  $view = views_get_view($playlist);
  if (empty($view)) {
    return array(
      'error' => 'Playlist not found.',
    );
  }

  // Check access
  if (!$view
    ->access('default')) {
    return array(
      'error' => 'Access Denied.',
    );
  }

  // Setup our view for query.
  if (method_exists($view, 'set_use_pager')) {
    $view
      ->set_use_pager(FALSE);
  }
  else {
    $view->display_handler
      ->set_option('pager', array(
      'type' => 'some',
      'options' => $view->display_handler->options['pager']['options'],
    ));
  }
  $view
    ->set_items_per_page($limit);
  $view
    ->set_offset($start);
  $view->get_total_rows = TRUE;
  $view
    ->execute();

  // Return our playlist...
  return mediafront_get_playlist_from_view($view, $limit, $start);
}