Révision 5d12d676
Ajouté par Assos Assos il y a environ 6 ans
drupal7/sites/all/modules/views/plugins/views_plugin_pager_full.inc | ||
---|---|---|
11 | 11 |
* @ingroup views_pager_plugins |
12 | 12 |
*/ |
13 | 13 |
class views_plugin_pager_full extends views_plugin_pager { |
14 |
function summary_title() { |
|
14 |
|
|
15 |
/** |
|
16 |
* {@inheritdoc} |
|
17 |
*/ |
|
18 |
public function summary_title() { |
|
15 | 19 |
if (!empty($this->options['offset'])) { |
16 | 20 |
return format_plural($this->options['items_per_page'], '@count item, skip @skip', 'Paged, @count items, skip @skip', array('@count' => $this->options['items_per_page'], '@skip' => $this->options['offset'])); |
17 | 21 |
} |
18 |
return format_plural($this->options['items_per_page'], '@count item', 'Paged, @count items', array('@count' => $this->options['items_per_page']));
|
|
22 |
return format_plural($this->options['items_per_page'], '@count item', 'Paged, @count items', array('@count' => $this->options['items_per_page'])); |
|
19 | 23 |
} |
20 | 24 |
|
21 |
function option_definition() { |
|
25 |
/** |
|
26 |
* {@inheritdoc} |
|
27 |
*/ |
|
28 |
public function option_definition() { |
|
22 | 29 |
$options = parent::option_definition(); |
23 | 30 |
$options['items_per_page'] = array('default' => 10); |
24 | 31 |
$options['offset'] = array('default' => 0); |
... | ... | |
52 | 59 |
/** |
53 | 60 |
* Provide the default form for setting options. |
54 | 61 |
*/ |
55 |
function options_form(&$form, &$form_state) { |
|
62 |
public function options_form(&$form, &$form_state) {
|
|
56 | 63 |
parent::options_form($form, $form_state); |
57 | 64 |
$pager_text = $this->display->handler->get_pager_text(); |
58 | 65 |
$form['items_per_page'] = array( |
... | ... | |
90 | 97 |
'#default_value' => $this->options['quantity'], |
91 | 98 |
); |
92 | 99 |
|
93 |
$form['tags'] = array (
|
|
100 |
$form['tags'] = array( |
|
94 | 101 |
'#type' => 'fieldset', |
95 | 102 |
'#collapsible' => FALSE, |
96 | 103 |
'#collapsed' => FALSE, |
... | ... | |
128 | 135 |
'#default_value' => $this->options['tags']['last'], |
129 | 136 |
); |
130 | 137 |
|
131 |
$form['expose'] = array (
|
|
138 |
$form['expose'] = array( |
|
132 | 139 |
'#type' => 'fieldset', |
133 | 140 |
'#collapsible' => FALSE, |
134 | 141 |
'#collapsed' => FALSE, |
... | ... | |
152 | 159 |
'#description' => t('Label to use in the exposed items per page form element.'), |
153 | 160 |
'#default_value' => $this->options['expose']['items_per_page_label'], |
154 | 161 |
'#dependency' => array( |
155 |
'edit-pager-options-expose-items-per-page' => array(1) |
|
162 |
'edit-pager-options-expose-items-per-page' => array(1),
|
|
156 | 163 |
), |
157 | 164 |
); |
158 | 165 |
|
... | ... | |
163 | 170 |
'#description' => t('Set between which values the user can choose when determining the items per page. Separated by comma.'), |
164 | 171 |
'#default_value' => $this->options['expose']['items_per_page_options'], |
165 | 172 |
'#dependency' => array( |
166 |
'edit-pager-options-expose-items-per-page' => array(1) |
|
173 |
'edit-pager-options-expose-items-per-page' => array(1),
|
|
167 | 174 |
), |
168 | 175 |
); |
169 | 176 |
|
170 |
|
|
171 | 177 |
$form['expose']['items_per_page_options_all'] = array( |
172 | 178 |
'#type' => 'checkbox', |
173 | 179 |
'#title' => t('Include all items option'), |
... | ... | |
199 | 205 |
'#description' => t('Label to use in the exposed offset form element.'), |
200 | 206 |
'#default_value' => $this->options['expose']['offset_label'], |
201 | 207 |
'#dependency' => array( |
202 |
'edit-pager-options-expose-offset' => array(1) |
|
208 |
'edit-pager-options-expose-offset' => array(1),
|
|
203 | 209 |
), |
204 | 210 |
); |
205 | 211 |
} |
206 | 212 |
|
207 |
function options_validate(&$form, &$form_state) { |
|
213 |
/** |
|
214 |
* {@inheritdoc} |
|
215 |
*/ |
|
216 |
public function options_validate(&$form, &$form_state) { |
|
208 | 217 |
// Only accept integer values. |
209 | 218 |
$error = FALSE; |
210 | 219 |
$exposed_options = $form_state['values']['pager_options']['expose']['items_per_page_options']; |
211 | 220 |
if (strpos($exposed_options, '.') !== FALSE) { |
212 | 221 |
$error = TRUE; |
213 | 222 |
} |
214 |
$options = explode(',',$exposed_options); |
|
223 |
$options = explode(',', $exposed_options);
|
|
215 | 224 |
if (!$error && is_array($options)) { |
216 | 225 |
foreach ($options as $option) { |
217 | 226 |
if (!is_numeric($option) || intval($option) == 0) { |
... | ... | |
237 | 246 |
} |
238 | 247 |
} |
239 | 248 |
|
240 |
function query() { |
|
249 |
/** |
|
250 |
* {@inheritdoc} |
|
251 |
*/ |
|
252 |
public function query() { |
|
241 | 253 |
if ($this->items_per_page_exposed()) { |
242 | 254 |
if (!empty($_GET['items_per_page']) && $_GET['items_per_page'] > 0) { |
243 | 255 |
$this->options['items_per_page'] = $_GET['items_per_page']; |
... | ... | |
265 | 277 |
$this->view->query->set_offset($offset); |
266 | 278 |
} |
267 | 279 |
|
268 |
function render($input) { |
|
280 |
/** |
|
281 |
* {@inheritdoc} |
|
282 |
*/ |
|
283 |
public function render($input) { |
|
269 | 284 |
$pager_theme = views_theme_functions('pager', $this->view, $this->display); |
270 | 285 |
// The 0, 1, 3, 4 index are correct. See theme_pager documentation. |
271 | 286 |
$tags = array( |
... | ... | |
286 | 301 |
/** |
287 | 302 |
* Set the current page. |
288 | 303 |
* |
289 |
* @param $number |
|
304 |
* @param int $number
|
|
290 | 305 |
* If provided, the page number will be set to this. If NOT provided, |
291 | 306 |
* the page number will be set from the global page array. |
292 | 307 |
*/ |
293 |
function set_current_page($number = NULL) { |
|
308 |
public function set_current_page($number = NULL) {
|
|
294 | 309 |
if (isset($number)) { |
295 | 310 |
$this->current_page = $number; |
296 | 311 |
return; |
... | ... | |
320 | 335 |
} |
321 | 336 |
} |
322 | 337 |
|
323 |
function get_pager_total() { |
|
338 |
/** |
|
339 |
* {@inheritdoc} |
|
340 |
*/ |
|
341 |
public function get_pager_total() { |
|
324 | 342 |
if ($items_per_page = intval($this->get_items_per_page())) { |
325 | 343 |
return ceil($this->total_items / $items_per_page); |
326 | 344 |
} |
... | ... | |
336 | 354 |
* items available and to update the current page if the requested |
337 | 355 |
* page is out of range. |
338 | 356 |
*/ |
339 |
function update_page_info() { |
|
357 |
public function update_page_info() {
|
|
340 | 358 |
if (!empty($this->options['total_pages'])) { |
341 | 359 |
if (($this->options['total_pages'] * $this->options['items_per_page']) < $this->total_items) { |
342 | 360 |
$this->total_items = $this->options['total_pages'] * $this->options['items_per_page']; |
... | ... | |
356 | 374 |
// Calculate and set the count of available pages. |
357 | 375 |
$pager_total[$pager_id] = $this->get_pager_total(); |
358 | 376 |
|
359 |
// See if the requested page was within range:
|
|
377 |
// See if the requested page was within range.
|
|
360 | 378 |
if ($this->current_page < 0) { |
361 | 379 |
$this->current_page = 0; |
362 | 380 |
} |
363 |
else if ($this->current_page >= $pager_total[$pager_id]) { |
|
364 |
// Pages are numbered from 0 so if there are 10 pages, the last page is 9. |
|
381 |
elseif ($this->current_page >= $pager_total[$pager_id]) { |
|
382 |
// Pages are numbered from 0 so if there are 10 pages, the last page is |
|
383 |
// 9. |
|
365 | 384 |
$this->current_page = $pager_total[$pager_id] - 1; |
366 | 385 |
} |
367 | 386 |
|
368 |
// Put this number in to guarantee that we do not generate notices when the pager
|
|
369 |
// goes to look for it later. |
|
387 |
// Put this number in to guarantee that we do not generate notices when |
|
388 |
// the pager goes to look for it later.
|
|
370 | 389 |
$pager_page_array[$pager_id] = $this->current_page; |
371 | 390 |
} |
372 | 391 |
} |
373 | 392 |
|
374 |
function uses_exposed() { |
|
393 |
/** |
|
394 |
* |
|
395 |
*/ |
|
396 |
public function uses_exposed() { |
|
375 | 397 |
return $this->items_per_page_exposed() || $this->offset_exposed(); |
376 | 398 |
} |
377 | 399 |
|
378 |
function items_per_page_exposed() { |
|
400 |
/** |
|
401 |
* |
|
402 |
*/ |
|
403 |
public function items_per_page_exposed() { |
|
379 | 404 |
return !empty($this->options['expose']['items_per_page']); |
380 | 405 |
} |
381 | 406 |
|
382 |
function offset_exposed() { |
|
407 |
/** |
|
408 |
* |
|
409 |
*/ |
|
410 |
public function offset_exposed() { |
|
383 | 411 |
return !empty($this->options['expose']['offset']); |
384 | 412 |
} |
385 | 413 |
|
386 |
function exposed_form_alter(&$form, &$form_state) { |
|
414 |
/** |
|
415 |
* {@inheritdoc} |
|
416 |
*/ |
|
417 |
public function exposed_form_alter(&$form, &$form_state) { |
|
387 | 418 |
if ($this->items_per_page_exposed()) { |
388 | 419 |
$options = explode(',', $this->options['expose']['items_per_page_options']); |
389 | 420 |
$sanitized_options = array(); |
... | ... | |
414 | 445 |
} |
415 | 446 |
} |
416 | 447 |
|
417 |
function exposed_form_validate(&$form, &$form_state) { |
|
448 |
/** |
|
449 |
* {@inheritdoc} |
|
450 |
*/ |
|
451 |
public function exposed_form_validate(&$form, &$form_state) { |
|
418 | 452 |
if (!empty($form_state['values']['offset']) && trim($form_state['values']['offset'])) { |
419 | 453 |
if (!is_numeric($form_state['values']['offset']) || $form_state['values']['offset'] < 0) { |
420 |
form_set_error('offset', t('Offset must be an number greater or equal than 0.'));
|
|
454 |
form_set_error('offset', t('Offset must be a number greater than or equal to 0.'));
|
|
421 | 455 |
} |
422 | 456 |
} |
423 | 457 |
} |
458 |
|
|
424 | 459 |
} |
Formats disponibles : Unified diff
Weekly update of contrib modules