views_bulk_operations.module 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /**
  3. * @file
  4. * Allows operations to be performed on items selected in a view.
  5. */
  6. use Drupal\Core\Routing\RouteMatchInterface;
  7. /**
  8. * Implements hook_views_data_alter().
  9. */
  10. function views_bulk_operations_views_data_alter(&$data) {
  11. $data['views']['views_bulk_operations_bulk_form'] = [
  12. 'title' => t('Views bulk operations'),
  13. 'help' => t("Process entities returned by the view with Views Bulk Operations' actions."),
  14. 'field' => [
  15. 'id' => 'views_bulk_operations_bulk_form',
  16. ],
  17. ];
  18. }
  19. /**
  20. * Implements hook_help().
  21. */
  22. function views_bulk_operations_help($route_name, RouteMatchInterface $route_match) {
  23. switch ($route_name) {
  24. case 'help.page.views_bulk_operations':
  25. $filepath = dirname(__FILE__) . '/README.txt';
  26. if (file_exists($filepath)) {
  27. $readme = file_get_contents($filepath);
  28. $output = '<pre>' . $readme . '</pre>';
  29. return $output;
  30. }
  31. }
  32. }
  33. /**
  34. * Implements hook_preprocess_THEME().
  35. */
  36. function views_bulk_operations_preprocess_views_view_table(&$variables) {
  37. if (!empty($variables['view']->style_plugin->options['views_bulk_operations_enabled'])) {
  38. // Add module own class to improve resistance to theme overrides.
  39. $variables['attributes']['class'][] = 'vbo-table';
  40. }
  41. }