views_plugin_pager_some.inc

Definition of views_plugin_pager_some.

File

plugins/views_plugin_pager_some.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * Definition of views_plugin_pager_some.
  5. */
  6. /**
  7. * Plugin for views without pagers.
  8. *
  9. * @ingroup views_pager_plugins
  10. */
  11. class views_plugin_pager_some extends views_plugin_pager {
  12. function summary_title() {
  13. if (!empty($this->options['offset'])) {
  14. return format_plural($this->options['items_per_page'], '@count item, skip @skip', '@count items, skip @skip', array('@count' => $this->options['items_per_page'], '@skip' => $this->options['offset']));
  15. }
  16. return format_plural($this->options['items_per_page'], '@count item', '@count items', array('@count' => $this->options['items_per_page']));
  17. }
  18. function option_definition() {
  19. $options = parent::option_definition();
  20. $options['items_per_page'] = array('default' => 10);
  21. $options['offset'] = array('default' => 0);
  22. return $options;
  23. }
  24. /**
  25. * Provide the default form for setting options.
  26. */
  27. function options_form(&$form, &$form_state) {
  28. parent::options_form($form, $form_state);
  29. $pager_text = $this->display->handler->get_pager_text();
  30. $form['items_per_page'] = array(
  31. '#title' => $pager_text['items per page title'],
  32. '#type' => 'textfield',
  33. '#description' => $pager_text['items per page description'],
  34. '#default_value' => $this->options['items_per_page'],
  35. );
  36. $form['offset'] = array(
  37. '#type' => 'textfield',
  38. '#title' => t('Offset'),
  39. '#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.'),
  40. '#default_value' => $this->options['offset'],
  41. );
  42. }
  43. function use_pager() {
  44. return FALSE;
  45. }
  46. function use_count_query() {
  47. return FALSE;
  48. }
  49. function query() {
  50. $this->view->query->set_limit($this->options['items_per_page']);
  51. $this->view->query->set_offset($this->options['offset']);
  52. }
  53. }