1 |
85ad3d82
|
Assos Assos
|
<?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 |
|
|
function summary_title() {
|
15 |
|
|
if (!empty($this->options['offset'])) {
|
16 |
|
|
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']));
|
17 |
|
|
}
|
18 |
|
|
return format_plural($this->options['items_per_page'], '@count item', '@count items', array('@count' => $this->options['items_per_page']));
|
19 |
|
|
}
|
20 |
|
|
|
21 |
|
|
function option_definition() {
|
22 |
|
|
$options = parent::option_definition();
|
23 |
|
|
$options['items_per_page'] = array('default' => 10);
|
24 |
|
|
$options['offset'] = array('default' => 0);
|
25 |
|
|
|
26 |
|
|
return $options;
|
27 |
|
|
}
|
28 |
|
|
|
29 |
|
|
/**
|
30 |
|
|
* Provide the default form for setting options.
|
31 |
|
|
*/
|
32 |
|
|
function options_form(&$form, &$form_state) {
|
33 |
|
|
parent::options_form($form, $form_state);
|
34 |
|
|
$pager_text = $this->display->handler->get_pager_text();
|
35 |
|
|
$form['items_per_page'] = array(
|
36 |
|
|
'#title' => $pager_text['items per page title'],
|
37 |
|
|
'#type' => 'textfield',
|
38 |
|
|
'#description' => $pager_text['items per page description'],
|
39 |
|
|
'#default_value' => $this->options['items_per_page'],
|
40 |
|
|
);
|
41 |
|
|
|
42 |
|
|
$form['offset'] = array(
|
43 |
|
|
'#type' => 'textfield',
|
44 |
|
|
'#title' => t('Offset'),
|
45 |
|
|
'#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.'),
|
46 |
|
|
'#default_value' => $this->options['offset'],
|
47 |
|
|
);
|
48 |
|
|
}
|
49 |
|
|
|
50 |
|
|
function use_pager() {
|
51 |
|
|
return FALSE;
|
52 |
|
|
}
|
53 |
|
|
|
54 |
|
|
function use_count_query() {
|
55 |
|
|
return FALSE;
|
56 |
|
|
}
|
57 |
|
|
|
58 |
|
|
function query() {
|
59 |
|
|
$this->view->query->set_limit($this->options['items_per_page']);
|
60 |
|
|
$this->view->query->set_offset($this->options['offset']);
|
61 |
|
|
}
|
62 |
|
|
} |