1
|
<?php
|
2
|
|
3
|
|
4
|
/**
|
5
|
* @file
|
6
|
* Unformatted PDF style
|
7
|
*/
|
8
|
|
9
|
|
10
|
/**
|
11
|
* This class holds all the funtionality used for the unformatted style plugin.
|
12
|
*/
|
13
|
class views_pdf_plugin_style_unformatted extends views_plugin_style {
|
14
|
/**
|
15
|
* Render the grouping sets.
|
16
|
*
|
17
|
* Plugins may override this method if they wish some other way of handling
|
18
|
* grouping.
|
19
|
*
|
20
|
* @param $sets
|
21
|
* Array containing the grouping sets to render.
|
22
|
* @param $level
|
23
|
* Integer indicating the hierarchical level of the grouping.
|
24
|
*
|
25
|
* @return string
|
26
|
* Rendered output of given grouping sets.
|
27
|
*/
|
28
|
function render_grouping_sets($sets, $level = 0) {
|
29
|
|
30
|
$output = '';
|
31
|
|
32
|
$next_level = $level + 1;
|
33
|
foreach ($sets as $set) {
|
34
|
$row = reset($set['rows']);
|
35
|
// Render as a grouping set.
|
36
|
if (is_array($row) && isset($row['group'])) {
|
37
|
$field_id = $this->options['grouping'][$level]['field'];
|
38
|
$options = array();
|
39
|
if(isset($this->row_plugin->options['formats'][$field_id])) {
|
40
|
$options = $this->row_plugin->options['formats'][$field_id];
|
41
|
}
|
42
|
$this->view->pdf->drawContent($set['group'], $options, $this->view);
|
43
|
$this->render_grouping_sets($set['rows'], $next_level);
|
44
|
}
|
45
|
// Render as a record set.
|
46
|
else {
|
47
|
if (!empty($set['group'])) {
|
48
|
$field_id = $this->options['grouping'][$level]['field'];
|
49
|
$options = array();
|
50
|
if(isset($this->row_plugin->options['formats'][$field_id])) {
|
51
|
$options = $this->row_plugin->options['formats'][$field_id];
|
52
|
}
|
53
|
$this->view->pdf->drawContent($set['group'], $options, $this->view);
|
54
|
}
|
55
|
|
56
|
if ($this->uses_row_plugin()) {
|
57
|
foreach ($set['rows'] as $index => $row) {
|
58
|
$this->view->row_index = $index;
|
59
|
$set['rows'][$index] = $this->row_plugin->render($row);
|
60
|
}
|
61
|
}
|
62
|
}
|
63
|
}
|
64
|
|
65
|
unset($this->view->row_index);
|
66
|
return $output;
|
67
|
}
|
68
|
|
69
|
/**
|
70
|
* Attach this view to another display as a feed.
|
71
|
*
|
72
|
* Provide basic functionality for all export style views like attaching a
|
73
|
* feed image link.
|
74
|
*/
|
75
|
function attach_to($display_id, $path, $title) {
|
76
|
$display = $this->view->display[$display_id]->handler;
|
77
|
$url_options = array();
|
78
|
$input = $this->view->get_exposed_input();
|
79
|
if ($input) {
|
80
|
$url_options['query'] = $input;
|
81
|
}
|
82
|
|
83
|
if (empty($this->view->feed_icon)) {
|
84
|
$this->view->feed_icon = '';
|
85
|
}
|
86
|
$this->view->feed_icon .= theme(
|
87
|
'views_pdf_icon',
|
88
|
array(
|
89
|
'path' => $this->view->get_url(NULL, $path),
|
90
|
'title' => $title,
|
91
|
'options' => $url_options
|
92
|
)
|
93
|
);
|
94
|
}
|
95
|
|
96
|
}
|