views_plugin_pager_none.inc

Definition of views_plugin_pager_none.

File

plugins/views_plugin_pager_none.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * Definition of views_plugin_pager_none.
  5. */
  6. /**
  7. * Plugin for views without pagers.
  8. *
  9. * @ingroup views_pager_plugins
  10. */
  11. class views_plugin_pager_none extends views_plugin_pager {
  12. function init(&$view, &$display, $options = array()) {
  13. parent::init($view, $display, $options);
  14. // If the pager is set to none, then it should show all items.
  15. $this->set_items_per_page(0);
  16. }
  17. function summary_title() {
  18. if (!empty($this->options['offset'])) {
  19. return t('All items, skip @skip', array('@skip' => $this->options['offset']));
  20. }
  21. return t('All items');
  22. }
  23. function option_definition() {
  24. $options = parent::option_definition();
  25. $options['offset'] = array('default' => 0);
  26. return $options;
  27. }
  28. /**
  29. * Provide the default form for setting options.
  30. */
  31. function options_form(&$form, &$form_state) {
  32. parent::options_form($form, $form_state);
  33. $form['offset'] = array(
  34. '#type' => 'textfield',
  35. '#title' => t('Offset'),
  36. '#description' => t('The number of items to skip. For example, if this field is 3, the first 3 items will be skipped and not displayed.'),
  37. '#default_value' => $this->options['offset'],
  38. );
  39. }
  40. function use_pager() {
  41. return FALSE;
  42. }
  43. function use_count_query() {
  44. return FALSE;
  45. }
  46. function get_items_per_page() {
  47. return 0;
  48. }
  49. function execute_count_query(&$count_query) {
  50. // If we are displaying all items, never count. But we can update the count in post_execute.
  51. }
  52. function post_execute(&$result) {
  53. $this->total_items = count($result);
  54. }
  55. function query() {
  56. // The only query modifications we might do are offsets.
  57. if (!empty($this->options['offset'])) {
  58. $this->view->query->set_offset($this->options['offset']);
  59. }
  60. }
  61. }