blob: 7b5fe8263465f394ab24795f73c58808706983f9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
<?php
/**
* @file
* Contains the file view row style plugin.
*/
/**
* Plugin which performs a file_view on the resulting object.
*
* Most of the code on this object is in the theme function.
*/
class views_plugin_row_file_view extends views_plugin_row {
// Basic properties that let the row style follow relationships.
var $base_table = 'file_managed';
var $base_field = 'fid';
// Stores the files loaded with pre_render.
var $files = array();
function option_definition() {
$options = parent::option_definition();
$options['view_mode'] = array('default' => 'default');
$options['links'] = array('default' => TRUE);
return $options;
}
function options_form(&$form, &$form_state) {
parent::options_form($form, $form_state);
$form['view_mode'] = array(
'#type' => 'select',
'#options' => file_entity_view_mode_labels(),
'#title' => t('View mode'),
'#default_value' => $this->options['view_mode'],
);
$form['links'] = array(
'#type' => 'checkbox',
'#title' => t('Display links'),
'#default_value' => $this->options['links'],
);
}
function summary_title() {
$view_mode_label = file_entity_view_mode_label($this->options['view_mode'], t('Unknown'));
return check_plain($view_mode_label);
}
function pre_render($values) {
$fids = array();
foreach ($values as $row) {
$fids[] = $row->{$this->field_alias};
}
$this->files = file_load_multiple($fids);
}
function render($row) {
$file = $this->files[$row->{$this->field_alias}];
$file->view = $this->view;
$build = file_view($file, $this->options['view_mode']);
return drupal_render($build);
}
}
|