1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Contains the default summary style plugin, which displays items in an HTML list.
|
6
|
*/
|
7
|
|
8
|
/**
|
9
|
* The default style plugin for summaries.
|
10
|
*
|
11
|
* @ingroup views_style_plugins
|
12
|
*/
|
13
|
class views_plugin_style_summary extends views_plugin_style {
|
14
|
function option_definition() {
|
15
|
$options = parent::option_definition();
|
16
|
|
17
|
$options['base_path'] = array('default' => '');
|
18
|
$options['count'] = array('default' => TRUE, 'bool' => TRUE);
|
19
|
$options['override'] = array('default' => FALSE, 'bool' => TRUE);
|
20
|
$options['items_per_page'] = array('default' => 25);
|
21
|
|
22
|
return $options;
|
23
|
}
|
24
|
|
25
|
function query() {
|
26
|
if (!empty($this->options['override'])) {
|
27
|
$this->view->set_items_per_page(intval($this->options['items_per_page']));
|
28
|
}
|
29
|
}
|
30
|
|
31
|
function options_form(&$form, &$form_state) {
|
32
|
$form['base_path'] = array(
|
33
|
'#type' => 'textfield',
|
34
|
'#title' => t('Base path'),
|
35
|
'#default_value' => $this->options['base_path'],
|
36
|
'#description' => t('Define the base path for links in this summary
|
37
|
view, i.e. http://example.com/<strong>your_view_path/archive</strong>.
|
38
|
Do not include beginning and ending forward slash. If this value
|
39
|
is empty, views will use the first path found as the base path,
|
40
|
in page displays, or / if no path could be found.'),
|
41
|
);
|
42
|
$form['count'] = array(
|
43
|
'#type' => 'checkbox',
|
44
|
'#default_value' => !empty($this->options['count']),
|
45
|
'#title' => t('Display record count with link'),
|
46
|
);
|
47
|
$form['override'] = array(
|
48
|
'#type' => 'checkbox',
|
49
|
'#default_value' => !empty($this->options['override']),
|
50
|
'#title' => t('Override number of items to display'),
|
51
|
);
|
52
|
|
53
|
$form['items_per_page'] = array(
|
54
|
'#type' => 'textfield',
|
55
|
'#title' => t('Items to display'),
|
56
|
'#default_value' => $this->options['items_per_page'],
|
57
|
'#dependency' => array(
|
58
|
'edit-options-summary-options-' . str_replace('_', '-', $this->definition['name']) . '-override' => array(1)
|
59
|
),
|
60
|
);
|
61
|
}
|
62
|
|
63
|
function render() {
|
64
|
$rows = array();
|
65
|
foreach ($this->view->result as $row) {
|
66
|
// @todo: Include separator as an option.
|
67
|
$rows[] = $row;
|
68
|
}
|
69
|
|
70
|
return theme($this->theme_functions(), array(
|
71
|
'view' => $this->view,
|
72
|
'options' => $this->options,
|
73
|
'rows' => $rows
|
74
|
));
|
75
|
}
|
76
|
}
|