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