views_plugin_pager_none.inc 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. /**
  13. * {@inheritdoc}
  14. */
  15. public function init(&$view, &$display, $options = array()) {
  16. parent::init($view, $display, $options);
  17. // If the pager is set to none, then it should show all items.
  18. $this->set_items_per_page(0);
  19. }
  20. /**
  21. * {@inheritdoc}
  22. */
  23. public function summary_title() {
  24. if (!empty($this->options['offset'])) {
  25. return t('All items, skip @skip', array('@skip' => $this->options['offset']));
  26. }
  27. return t('All items');
  28. }
  29. /**
  30. * {@inheritdoc}
  31. */
  32. public function option_definition() {
  33. $options = parent::option_definition();
  34. $options['offset'] = array('default' => 0);
  35. return $options;
  36. }
  37. /**
  38. * Provide the default form for setting options.
  39. */
  40. public function options_form(&$form, &$form_state) {
  41. parent::options_form($form, $form_state);
  42. $form['offset'] = array(
  43. '#type' => 'textfield',
  44. '#title' => t('Offset'),
  45. '#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.'),
  46. '#default_value' => $this->options['offset'],
  47. );
  48. }
  49. /**
  50. * {@inheritdoc}
  51. */
  52. public function use_pager() {
  53. return FALSE;
  54. }
  55. /**
  56. * {@inheritdoc}
  57. */
  58. public function use_count_query() {
  59. return FALSE;
  60. }
  61. /**
  62. * {@inheritdoc}
  63. */
  64. public function get_items_per_page() {
  65. return 0;
  66. }
  67. /**
  68. * {@inheritdoc}
  69. */
  70. public function execute_count_query(&$count_query) {
  71. // If we are displaying all items, never count. But we can update the count
  72. // in post_execute.
  73. }
  74. /**
  75. * {@inheritdoc}
  76. */
  77. public function post_execute(&$result) {
  78. $this->total_items = count($result);
  79. }
  80. /**
  81. * {@inheritdoc}
  82. */
  83. public function query() {
  84. // The only query modifications we might do are offsets.
  85. if (!empty($this->options['offset'])) {
  86. $this->view->query->set_offset($this->options['offset']);
  87. }
  88. }
  89. }