1
|
<?php
|
2
|
|
3
|
|
4
|
|
5
|
|
6
|
|
7
|
|
8
|
|
9
|
|
10
|
|
11
|
|
12
|
class PanelizerEntityFile extends PanelizerEntityDefault {
|
13
|
public $entity_admin_root = 'admin/structure/file-types/%';
|
14
|
public $entity_admin_bundle = 3;
|
15
|
public $views_table = 'file_managed';
|
16
|
|
17
|
public function entity_access($op, $entity) {
|
18
|
return file_entity_access($op, $entity);
|
19
|
}
|
20
|
|
21
|
|
22
|
|
23
|
|
24
|
public function entity_save($entity) {
|
25
|
file_save($entity);
|
26
|
}
|
27
|
|
28
|
|
29
|
|
30
|
|
31
|
public function entity_allows_revisions($entity) {
|
32
|
return array(FALSE, FALSE);
|
33
|
|
34
|
}
|
35
|
|
36
|
public function settings_form(&$form, &$form_state) {
|
37
|
parent::settings_form($form, $form_state);
|
38
|
|
39
|
$warn = FALSE;
|
40
|
foreach ($this->plugin['bundles'] as $info) {
|
41
|
if (!empty($info['status'])) {
|
42
|
$warn = TRUE;
|
43
|
break;
|
44
|
}
|
45
|
}
|
46
|
|
47
|
if ($warn) {
|
48
|
$task = page_manager_get_task('file_view');
|
49
|
if (!empty($task['disabled'])) {
|
50
|
drupal_set_message('The file template page is currently not enabled in page manager. You must enable this for Panelizer to be able to panelize files.', 'warning');
|
51
|
}
|
52
|
|
53
|
$handler = page_manager_load_task_handler($task, '', 'file_view_panelizer');
|
54
|
if (!empty($handler->disabled)) {
|
55
|
drupal_set_message('The panelizer variant on the file template page is currently not enabled in page manager. You must enable this for Panelizer to be able to panelize files.', 'warning');
|
56
|
}
|
57
|
}
|
58
|
}
|
59
|
|
60
|
public function entity_identifier($entity) {
|
61
|
return t('This file');
|
62
|
}
|
63
|
|
64
|
public function entity_bundle_label() {
|
65
|
return t('File type');
|
66
|
}
|
67
|
|
68
|
function get_default_display($bundle, $view_mode) {
|
69
|
|
70
|
|
71
|
return parent::get_default_display($bundle, $view_mode);
|
72
|
}
|
73
|
|
74
|
|
75
|
|
76
|
|
77
|
|
78
|
|
79
|
|
80
|
public function hook_default_page_manager_handlers(&$handlers) {
|
81
|
page_manager_get_task('file_view');
|
82
|
|
83
|
$handler = new stdClass;
|
84
|
$handler->disabled = FALSE;
|
85
|
$handler->api_version = 1;
|
86
|
$handler->name = 'file_view_panelizer';
|
87
|
$handler->task = 'file_view';
|
88
|
$handler->subtask = '';
|
89
|
$handler->handler = 'panelizer_node';
|
90
|
$handler->weight = -100;
|
91
|
$handler->conf = array(
|
92
|
'title' => t('File panelizer'),
|
93
|
'context' => 'argument_entity_id:file_1',
|
94
|
'access' => array(),
|
95
|
);
|
96
|
$handlers['file_view_panelizer'] = $handler;
|
97
|
|
98
|
return $handlers;
|
99
|
}
|
100
|
|
101
|
|
102
|
|
103
|
|
104
|
|
105
|
|
106
|
public function hook_form_alter(&$form, &$form_state, $form_id) {
|
107
|
if ($form_id == 'file_entity_file_type_form') {
|
108
|
if (isset($form['#file_type'])) {
|
109
|
$bundle = $form['#file_type']->type;
|
110
|
$this->add_bundle_setting_form($form, $form_state, $bundle, array('machine_name'));
|
111
|
}
|
112
|
}
|
113
|
}
|
114
|
|
115
|
public function hook_page_alter(&$page) {
|
116
|
|
117
|
}
|
118
|
|
119
|
public function hook_views_plugins_alter(&$plugins) {
|
120
|
|
121
|
}
|
122
|
|
123
|
}
|