media.views.inc

  1. cis7 sites/all/modules/ulmus/media/media.views.inc
  2. cle7 sites/all/modules/ulmus/media/media.views.inc
  3. ecd7 sites/all/modules/ulmus/media/media.views.inc
  4. elmsmedia7 sites/all/modules/ulmus/media/media.views.inc
  5. harmony7 sites/all/modules/ulmus/media/media.views.inc
  6. icor7 sites/all/modules/ulmus/media/media.views.inc
  7. meedjum_blog7 sites/all/modules/ulmus/media/media.views.inc
  8. mooc7 sites/all/modules/ulmus/media/media.views.inc

Provide Views data and handlers for media.module

Functions

File

sites/all/modules/ulmus/media/media.views.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * Provide Views data and handlers for media.module
  5. */
  6. /**
  7. * Implements hook_views_plugins().
  8. *
  9. * Generate a list of which base-tables to enabled the plugins for.
  10. */
  11. function media_views_plugins() {
  12. $plugins = array();
  13. // Always allow the actual file-table
  14. $base = array('file_managed');
  15. if (module_exists('search_api')) {
  16. // If the Search API module exists, also allow indices of the file-entity
  17. // that has the fid field indexed.
  18. $indices = search_api_index_load_multiple(NULL);
  19. foreach ($indices as $machine_name => $index) {
  20. if ($index->item_type == 'file' && isset($index->options['fields']['fid'])) {
  21. $base[] = 'search_api_index_' . $machine_name;
  22. }
  23. }
  24. }
  25. // Display plugin.
  26. $plugins['display']['media_browser'] = array(
  27. 'title' => t('Media browser tab'),
  28. 'help' => t('Display as a tab in the media browser.'),
  29. 'handler' => 'media_views_plugin_display_media_browser',
  30. 'theme' => 'views_view',
  31. 'base' => $base,
  32. 'use ajax' => TRUE,
  33. 'use pager' => TRUE,
  34. 'accept attachments' => TRUE,
  35. );
  36. // Style plugin.
  37. $plugins['style']['media_browser'] = array(
  38. 'title' => t('Media browser'),
  39. 'help' => t('Displays rows as an HTML list.'),
  40. 'handler' => 'media_views_plugin_style_media_browser',
  41. 'theme' => 'media_views_view_media_browser',
  42. 'base' => $base,
  43. 'uses row plugin' => FALSE,
  44. 'uses row class' => FALSE,
  45. 'uses options' => FALSE,
  46. 'uses fields' => FALSE,
  47. 'type' => 'normal',
  48. 'help topic' => 'style-media-browser',
  49. );
  50. return $plugins;
  51. }
  52. /**
  53. * Display the view as a media browser.
  54. */
  55. function template_preprocess_media_views_view_media_browser(&$vars) {
  56. module_load_include('inc', 'media', 'includes/media.browser');
  57. // Load file objects for each View result.
  58. $fids = array();
  59. foreach ($vars['rows'] as $index => $row) {
  60. // The Search API module returns the row in a slightly different format,
  61. // so convert it to the format that the normal file_managed table returns.
  62. if (!empty($row->entity->fid)) {
  63. $vars['rows'][$index]->fid = $row->entity->fid;
  64. }
  65. $fids[$index] = $row->fid;
  66. }
  67. $files = file_load_multiple($fids);
  68. // Render the preview for each file.
  69. foreach ($vars['rows'] as $index => $row) {
  70. $file = $files[$row->fid];
  71. // Add url/preview to the file object.
  72. media_browser_build_media_item($file);
  73. $vars['rows'][$index] = $file;
  74. $vars['rows'][$index]->preview = $file->preview;
  75. }
  76. // Add the files to JS so that they are accessible inside the browser.
  77. drupal_add_js(array('media' => array('files' => array_values($files))), 'setting');
  78. // Add the browser parameters to the settings and that this display exists.
  79. drupal_add_js(array(
  80. 'media' => array(
  81. 'browser' => array(
  82. 'params' => media_get_browser_params(),
  83. 'views' => array(
  84. $vars['view']->name => array(
  85. $vars['view']->current_display,
  86. ),
  87. ),
  88. ),
  89. ),
  90. ), 'setting');
  91. // Add classes and wrappers from the style plugin.
  92. $handler = $vars['view']->style_plugin;
  93. $class = explode(' ', $handler->options['class']);
  94. $class = array_map('drupal_clean_css_identifier', $class);
  95. $wrapper_class = explode(' ', $handler->options['wrapper_class']);
  96. $wrapper_class = array_map('drupal_clean_css_identifier', $wrapper_class);
  97. $vars['class'] = implode(' ', $class);
  98. $vars['wrapper_class'] = implode(' ', $wrapper_class);
  99. $vars['wrapper_prefix'] = '<div class="' . implode(' ', $wrapper_class) . '">';
  100. $vars['wrapper_suffix'] = '</div>';
  101. $vars['list_type_prefix'] = '<' . $handler->options['type'] . ' id="media-browser-library-list" class="' . implode(' ', $class) . '">';
  102. $vars['list_type_suffix'] = '</' . $handler->options['type'] . '>';
  103. // Run theming variables through a standard Views preprocess function.
  104. template_preprocess_views_view_unformatted($vars);
  105. // Add media browser javascript and CSS.
  106. drupal_add_js(drupal_get_path('module', 'media') . '/js/plugins/media.views.js');
  107. }
  108. /**
  109. * Implements hook_views_invalidate_cache().
  110. */
  111. function media_views_invalidate_cache() {
  112. cache_clear_all('media:browser:plugin', 'cache', TRUE);
  113. drupal_static_reset('media_get_browser_plugin_info');
  114. }
Error | ELMSLN API

Error

×

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/api.elmsln.org/includes/common.inc:2791) in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/api.elmsln.org/sites/all/modules/apc/drupal_apc_cache.inc).
The website encountered an unexpected error. Please try again later.