You are here

function media_views_plugins in D7 Media 7.4

Same name and namespace in other branches
  1. 7.2 media.views.inc \media_views_plugins()
  2. 7.3 media.views.inc \media_views_plugins()

Implements hook_views_plugins().

Generate a list of which base-tables to enabled the plugins for.

File

./media.views.inc, line 13
Provide Views data and handlers for media.module

Code

function media_views_plugins() {
  $plugins = array();

  // Always allow the actual file-table
  $base = array(
    'file_managed',
  );
  if (module_exists('search_api')) {

    // If the Search API module exists, also allow indices of the file-entity
    // that has the fid field indexed.
    $indices = search_api_index_load_multiple(FALSE);
    foreach ($indices as $machine_name => $index) {
      if ($index->item_type == 'file' && isset($index->options['fields']['fid'])) {
        $base[] = 'search_api_index_' . $machine_name;
      }
    }
  }

  // Display plugin.
  $plugins['display']['media_browser'] = array(
    'title' => t('Media browser tab'),
    'help' => t('Display as a tab in the media browser.'),
    'handler' => 'media_views_plugin_display_media_browser',
    'theme' => 'views_view',
    'theme path' => drupal_get_path('module', 'views') . '/theme',
    'base' => $base,
    'use ajax' => TRUE,
    'use pager' => TRUE,
    'accept attachments' => TRUE,
  );

  // Style plugin.
  $plugins['style']['media_browser'] = array(
    'title' => t('Media browser'),
    'help' => t('Displays rows as an HTML list.'),
    'handler' => 'media_views_plugin_style_media_browser',
    'theme' => 'media_views_view_media_browser',
    'base' => $base,
    'uses row plugin' => FALSE,
    'uses row class' => FALSE,
    'uses options' => FALSE,
    'uses fields' => FALSE,
    'type' => 'normal',
    'help topic' => 'style-media-browser',
  );
  return $plugins;
}