1 | <?php |
---|
2 | |
---|
3 | /** |
---|
4 | * Plugin for views without pagers. |
---|
5 | * |
---|
6 | * @ingroup views_pager_plugins |
---|
7 | */ |
---|
8 | class views_plugin_pager_none extends views_plugin_pager { |
---|
9 | |
---|
10 | function init(&$view, &$display, $options = array()) { |
---|
11 | parent::init($view, $display, $options); |
---|
12 | |
---|
13 | // If the pager is set to none, then it should show all items. |
---|
14 | $this->set_items_per_page(0); |
---|
15 | } |
---|
16 | |
---|
17 | function summary_title() { |
---|
18 | if (!empty($this->options['offset'])) { |
---|
19 | return t('All items, skip @skip', array('@skip' => $this->options['offset'])); |
---|
20 | } |
---|
21 | return t('All items'); |
---|
22 | } |
---|
23 | |
---|
24 | function option_definition() { |
---|
25 | $options = parent::option_definition(); |
---|
26 | $options['offset'] = array('default' => 0); |
---|
27 | |
---|
28 | return $options; |
---|
29 | } |
---|
30 | |
---|
31 | /** |
---|
32 | * Provide the default form for setting options. |
---|
33 | */ |
---|
34 | function options_form(&$form, &$form_state) { |
---|
35 | $form['offset'] = array( |
---|
36 | '#type' => 'textfield', |
---|
37 | '#title' => t('Offset'), |
---|
38 | '#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.'), |
---|
39 | '#default_value' => $this->options['offset'], |
---|
40 | ); |
---|
41 | } |
---|
42 | |
---|
43 | function use_pager() { |
---|
44 | return FALSE; |
---|
45 | } |
---|
46 | |
---|
47 | function use_count_query() { |
---|
48 | return FALSE; |
---|
49 | } |
---|
50 | |
---|
51 | function get_items_per_page() { |
---|
52 | return 0; |
---|
53 | } |
---|
54 | |
---|
55 | function execute_count_query(&$count_query, $args) { |
---|
56 | // If we are displaying all items, never count. But we can update the count in post_execute. |
---|
57 | } |
---|
58 | |
---|
59 | function post_execute($result) { |
---|
60 | $this->total_items = count($result); |
---|
61 | } |
---|
62 | |
---|
63 | function query() { |
---|
64 | // The only query modifications we might do are offsets. |
---|
65 | if (!empty($this->options['offset'])) { |
---|
66 | $this->view->query->set_offset($this->options['offset']); |
---|
67 | } |
---|
68 | } |
---|
69 | } |
---|