source: sipes/modules_contrib/views/plugins/views_plugin_pager.inc @ a8b1f3f

stableversion-3.0
Last change on this file since a8b1f3f was 65dadeb, checked in by José Gregorio Puentes <jpuentes@…>, 8 años ago

se agregaron los archivos de la nueva version del modulo

  • Propiedad mode establecida a 100644
File size: 5.0 KB
Línea 
1<?php
2
3/**
4 * The base plugin to handle pager.
5 *
6 * @ingroup views_pager_plugins
7 */
8class views_plugin_pager extends views_plugin {
9  var $current_page = NULL;
10  var $total_items = 0;
11
12  /**
13   * Initialize the plugin.
14   *
15   * @param $view
16   *   The view object.
17   * @param $display
18   *   The display handler.
19   */
20  function init(&$view, &$display, $options = array()) {
21    $this->view = &$view;
22    $this->display = &$display;
23
24    $this->unpack_options($this->options, $options);
25  }
26
27  /**
28   * Get how many items per page this pager will display.
29   *
30   * All but the leanest pagers should probably return a value here, so
31   * most pagers will not need to override this method.
32   */
33  function get_items_per_page() {
34    return isset($this->options['items_per_page']) ? $this->options['items_per_page'] : 0;
35  }
36
37  /**
38   * Set how many items per page this pager will display.
39   *
40   * This is mostly used for things that will override the value.
41   */
42  function set_items_per_page($items) {
43    $this->options['items_per_page'] = $items;
44  }
45
46  /**
47   * Get the page offset, or how many items to skip.
48   *
49   * Even pagers that don't actually page can skip items at the beginning,
50   * so few pagers will need to override this method.
51   */
52  function get_offset() {
53    return isset($this->options['offset']) ? $this->options['offset'] : 0;
54  }
55
56  /**
57   * Set the page offset, or how many items to skip.
58   */
59  function set_offset($offset) {
60    $this->options['offset'] = $offset;
61  }
62
63  /**
64   * Get the current page.
65   *
66   * If NULL, we do not know what the current page is.
67   */
68  function get_current_page() {
69    return $this->current_page;
70  }
71
72  /**
73   * Set the current page.
74   *
75   * @param $number
76   *   If provided, the page number will be set to this. If NOT provided,
77   *   the page number will be set from the global page array.
78   */
79  function set_current_page($number = NULL) {
80    $this->current_page = $number;
81  }
82
83  /**
84   * Get the total number of items.
85   *
86   * If NULL, we do not yet know what the total number of items are.
87   */
88  function get_total_items() {
89    return $this->total_items;
90  }
91
92  /**
93   * Get the pager id, if it exists
94   */
95  function get_pager_id() {
96    return isset($this->options['id']) ? $this->options['id'] : 0;
97  }
98
99  /**
100   * Provide the default form form for validating options
101   */
102  function options_validate(&$form, &$form_state) { }
103
104  /**
105   * Provide the default form form for submitting options
106   */
107  function options_submit($form, &$form_state) { }
108
109  /**
110   * Return a string to display as the clickable title for the
111   * pager plugin.
112   */
113  function summary_title() {
114    return t('Unknown');
115  }
116
117  /**
118   * Determine if this pager actually uses a pager.
119   *
120   * Only a couple of very specific pagers will set this to false.
121   */
122  function use_pager() {
123    return TRUE;
124  }
125
126  /**
127   * Determine if a pager needs a count query.
128   *
129   * If a pager needs a count query, a simple query
130   */
131  function use_count_query() {
132    return TRUE;
133  }
134
135  /**
136   * Execute the count query, which will be done just prior to the query
137   * itself being executed.
138   */
139  function execute_count_query(&$count_query, $args) {
140    $query_plugin = $this->view->query;
141    $this->total_items = $query_plugin->db_result($query_plugin->db_query($count_query, $args));
142    if (!empty($this->options['offset'])) {
143      $this->total_items -= $this->options['offset'];
144    }
145
146    $this->update_page_info();
147    return $this->total_items;
148  }
149
150  /**
151   * If there are pagers that need global values set, this method can
152   * be used to set them. It will be called when the count query is run.
153   */
154  function update_page_info() {
155
156  }
157
158  /**
159   * Modify the query for paging
160   *
161   * This is called during the build phase and can directly modify the query.
162   */
163  function query() { }
164
165  /**
166   * Perform any needed actions just prior to the query executing.
167   */
168  function pre_execute(&$query, &$args) { }
169
170  /**
171   * Perform any needed actions just after the query executing.
172   */
173  function post_execute(&$result) { }
174
175  /**
176   * Perform any needed actions just before rendering.
177   */
178  function pre_render(&$result) { }
179
180  /**
181   * Render the pager.
182   *
183   * Called during the view render process, this will render the
184   * pager.
185   *
186   * @param $input
187   *   Any extra GET parameters that should be retained, such as exposed
188   *   input.
189   */
190  function render($input) { }
191
192  /**
193   * Determine if there are more records available.
194   *
195   * This is primarily used to control the display of a more link.
196   */
197  function has_more_records() {
198    return $this->get_items_per_page()
199      && $this->total_items > (intval($this->current_page) + 1) * $this->get_items_per_page();
200  }
201
202  function exposed_form_alter(&$form, &$form_state) { }
203
204  function exposed_form_validate(&$form, &$form_state) { }
205
206  function exposed_form_submit(&$form, &$form_state, &$exclude) { }
207
208  function uses_exposed() {
209    return FALSE;
210  }
211
212  function items_per_page_exposed() {
213    return FALSE;
214  }
215
216  function offset_exposed() {
217    return FALSE;
218  }
219}
Nota: Vea TracBrowser para ayuda de uso del navegador del repositorio.