Projet

Général

Profil

Paste
Télécharger (2,11 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / views / plugins / views_plugin_pager_none.inc @ 5d12d676

1
<?php
2

    
3
/**
4
 * @file
5
 * Definition of views_plugin_pager_none.
6
 */
7

    
8
/**
9
 * Plugin for views without pagers.
10
 *
11
 * @ingroup views_pager_plugins
12
 */
13
class views_plugin_pager_none extends views_plugin_pager {
14

    
15
  /**
16
   * {@inheritdoc}
17
   */
18
  public function init(&$view, &$display, $options = array()) {
19
    parent::init($view, $display, $options);
20

    
21
    // If the pager is set to none, then it should show all items.
22
    $this->set_items_per_page(0);
23
  }
24

    
25
  /**
26
   * {@inheritdoc}
27
   */
28
  public function summary_title() {
29
    if (!empty($this->options['offset'])) {
30
      return t('All items, skip @skip', array('@skip' => $this->options['offset']));
31
    }
32
    return t('All items');
33
  }
34

    
35
  /**
36
   * {@inheritdoc}
37
   */
38
  public function option_definition() {
39
    $options = parent::option_definition();
40
    $options['offset'] = array('default' => 0);
41

    
42
    return $options;
43
  }
44

    
45
  /**
46
   * Provide the default form for setting options.
47
   */
48
  public function options_form(&$form, &$form_state) {
49
    parent::options_form($form, $form_state);
50
    $form['offset'] = array(
51
      '#type' => 'textfield',
52
      '#title' => t('Offset'),
53
      '#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.'),
54
      '#default_value' => $this->options['offset'],
55
    );
56
  }
57

    
58
  /**
59
   * {@inheritdoc}
60
   */
61
  public function use_pager() {
62
    return FALSE;
63
  }
64

    
65
  /**
66
   * {@inheritdoc}
67
   */
68
  public function use_count_query() {
69
    return FALSE;
70
  }
71

    
72
  /**
73
   * {@inheritdoc}
74
   */
75
  public function get_items_per_page() {
76
    return 0;
77
  }
78

    
79
  /**
80
   * {@inheritdoc}
81
   */
82
  public function execute_count_query(&$count_query) {
83
    // If we are displaying all items, never count. But we can update the count
84
    // in post_execute.
85
  }
86

    
87
  /**
88
   * {@inheritdoc}
89
   */
90
  public function post_execute(&$result) {
91
    $this->total_items = count($result);
92
  }
93

    
94
  /**
95
   * {@inheritdoc}
96
   */
97
  public function query() {
98
    // The only query modifications we might do are offsets.
99
    if (!empty($this->options['offset'])) {
100
      $this->view->query->set_offset($this->options['offset']);
101
    }
102
  }
103

    
104
}