Projet

Général

Profil

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

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

1
<?php
2

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

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

    
15
  /**
16
   *
17
   */
18
  public function summary_title() {
19
    if (!empty($this->options['offset'])) {
20
      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']));
21
    }
22
    return format_plural($this->options['items_per_page'], '@count item', '@count items', array('@count' => $this->options['items_per_page']));
23
  }
24

    
25
  /**
26
   * {@inheritdoc}
27
   */
28
  public function option_definition() {
29
    $options = parent::option_definition();
30
    $options['items_per_page'] = array('default' => 10);
31
    $options['offset'] = array('default' => 0);
32

    
33
    return $options;
34
  }
35

    
36
  /**
37
   * Provide the default form for setting options.
38
   */
39
  public function options_form(&$form, &$form_state) {
40
    parent::options_form($form, $form_state);
41
    $pager_text = $this->display->handler->get_pager_text();
42
    $form['items_per_page'] = array(
43
      '#title' => $pager_text['items per page title'],
44
      '#type' => 'textfield',
45
      '#description' => $pager_text['items per page description'],
46
      '#default_value' => $this->options['items_per_page'],
47
    );
48

    
49
    $form['offset'] = array(
50
      '#type' => 'textfield',
51
      '#title' => t('Offset'),
52
      '#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.'),
53
      '#default_value' => $this->options['offset'],
54
    );
55
  }
56

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

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

    
71
  /**
72
   * {@inheritdoc}
73
   */
74
  public function query() {
75
    $this->view->query->set_limit($this->options['items_per_page']);
76
    $this->view->query->set_offset($this->options['offset']);
77
  }
78

    
79
}