You are here

public function BrightcovePlaylistEntityUIController::overviewTable in Brightcove Video Connect 7.7

Same name and namespace in other branches
  1. 7.6 brightcove.playlist.inc \BrightcovePlaylistEntityUIController::overviewTable()

Renders the playlist overview table.

Return value

string Rendered overivew page.

Overrides EntityDefaultUIController::overviewTable

1 call to BrightcovePlaylistEntityUIController::overviewTable()
BrightcovePlaylistEntityUIController::overviewForm in ./brightcove.playlist.inc
Overrides EntityDefaultUIController::overviewForm()

File

./brightcove.playlist.inc, line 212
Brightcove playlist related functions.

Class

BrightcovePlaylistEntityUIController
Entity UI Controller class for brightcove playlists.

Code

public function overviewTable($conditions = []) {
  $client = $conditions['client'];
  $table = [
    'header' => [
      t('ID'),
      t('Title'),
      [
        'colspan' => 2,
        'data' => t('Operations'),
      ],
    ],
  ];
  module_load_include('inc', 'brightcove', 'brightcove.playlist');
  $page = filter_input(INPUT_GET, 'page', FILTER_SANITIZE_NUMBER_INT);
  if (empty($page)) {
    $page = 0;
  }
  $playlists = brightcove_get_playlists($client, 'name', $page);
  if ($playlists) {
    foreach ($playlists as $playlist) {
      $playlist_entity_id = $playlist
        ->getId() . '-' . $client->bcid;
      $playlist_entity = brightcove_playlist_load($playlist_entity_id);
      $table['rows'][] = $this
        ->overviewRow($playlist_entity);
    }
  }
  else {
    $table['rows'][] = [
      [
        'data' => t('No playlist found.'),
        'colspan' => count($table['header']),
      ],
    ];
  }

  // Restore original url for the pager.
  if (isset($this->form_state['complete form']['#action'])) {
    $action = $this->form_state['complete form']['#action'];
    $qmark_pos = strripos($action, '?');
    $_GET['q'] = $qmark_pos !== FALSE ? substr($action, 0, $qmark_pos) : substr($action, 0);
  }
  pager_default_initialize(_brightcove_playlist_items_total($client), variable_get('brightcove_pager_max_items', 20), 0);
  return theme('table', $table) . theme('pager', [
    'parameters' => [
      'client' => $client->bcid,
    ],
  ]);
}