views_plugin_pager_mini.inc 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. /**
  3. * @file
  4. * Definition of views_plugin_pager_mini.
  5. */
  6. /**
  7. * The plugin to handle mini pager.
  8. *
  9. * @ingroup views_pager_plugins
  10. */
  11. class views_plugin_pager_mini extends views_plugin_pager_full {
  12. /**
  13. * {@inheritdoc}
  14. */
  15. public function summary_title() {
  16. if (!empty($this->options['offset'])) {
  17. return format_plural($this->options['items_per_page'], 'Mini pager, @count item, skip @skip', 'Mini pager, @count items, skip @skip', array('@count' => $this->options['items_per_page'], '@skip' => $this->options['offset']));
  18. }
  19. return format_plural($this->options['items_per_page'], 'Mini pager, @count item', 'Mini pager, @count items', array('@count' => $this->options['items_per_page']));
  20. }
  21. /**
  22. * {@inheritdoc}
  23. */
  24. public function option_definition() {
  25. $options = parent::option_definition();
  26. // Overrides the full pager options form by deleting unused settings.
  27. unset($options['quantity']);
  28. unset($options['tags']['first']);
  29. unset($options['tags']['last']);
  30. $options['tags']['previous']['default'] = '‹‹';
  31. $options['tags']['next']['default'] = '››';
  32. return $options;
  33. }
  34. /**
  35. * {@inheritdoc}
  36. */
  37. public function options_form(&$form, &$form_state) {
  38. parent::options_form($form, $form_state);
  39. // Overrides the full pager options form by deleting unused settings.
  40. unset($form['quantity']);
  41. unset($form['tags']['first']);
  42. unset($form['tags']['last']);
  43. }
  44. /**
  45. * {@inheritdoc}
  46. */
  47. public function render($input) {
  48. // Overrides the full pager renderer by changing the theme function and
  49. // leaving out variables that are not used in the mini pager.
  50. $pager_theme = views_theme_functions('views_mini_pager', $this->view, $this->display);
  51. // The 1, 3 index are correct.
  52. // @see theme_pager().
  53. $tags = array(
  54. 1 => $this->options['tags']['previous'],
  55. 3 => $this->options['tags']['next'],
  56. );
  57. return theme($pager_theme, array(
  58. 'tags' => $tags,
  59. 'element' => $this->get_pager_id(),
  60. 'parameters' => $input,
  61. ));
  62. }
  63. }