Projet

Général

Profil

Paste
Télécharger (1,77 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / views / plugins / views_plugin_pager_none.inc @ 7547bb19

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
  function init(&$view, &$display, $options = array()) {
16
    parent::init($view, $display, $options);
17

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

    
22
  function summary_title() {
23
    if (!empty($this->options['offset'])) {
24
      return t('All items, skip @skip', array('@skip' => $this->options['offset']));
25
    }
26
    return t('All items');
27
  }
28

    
29
  function option_definition() {
30
    $options = parent::option_definition();
31
    $options['offset'] = array('default' => 0);
32

    
33
    return $options;
34
  }
35

    
36
  /**
37
   * Provide the default form for setting options.
38
   */
39
  function options_form(&$form, &$form_state) {
40
    parent::options_form($form, $form_state);
41
    $form['offset'] = array(
42
      '#type' => 'textfield',
43
      '#title' => t('Offset'),
44
      '#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.'),
45
      '#default_value' => $this->options['offset'],
46
    );
47
  }
48

    
49
  function use_pager() {
50
    return FALSE;
51
  }
52

    
53
  function use_count_query() {
54
    return FALSE;
55
  }
56

    
57
  function get_items_per_page() {
58
    return 0;
59
  }
60

    
61
  function execute_count_query(&$count_query) {
62
    // If we are displaying all items, never count. But we can update the count in post_execute.
63
  }
64

    
65
  function post_execute(&$result) {
66
    $this->total_items = count($result);
67
  }
68

    
69
  function query() {
70
    // The only query modifications we might do are offsets.
71
    if (!empty($this->options['offset'])) {
72
      $this->view->query->set_offset($this->options['offset']);
73
    }
74
  }
75
}