1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* Views field handler for rendering node links that point to panelizer tabs.
|
5
|
*/
|
6
|
class panelizer_handler_panelizer_status extends views_handler_field_entity {
|
7
|
function option_definition() {
|
8
|
$options = parent::option_definition();
|
9
|
$options['view_mode'] = array('default' => 'page_manager');
|
10
|
$options['not_panelized'] = array('default' => 'Not panelized', 'translatable' => TRUE);
|
11
|
$options['custom'] = array('default' => 'Custom', 'translatable' => TRUE);
|
12
|
return $options;
|
13
|
}
|
14
|
|
15
|
function options_form(&$form, &$form_state) {
|
16
|
parent::options_form($form, $form_state);
|
17
|
$entity_type = $this->definition['entity_type'];
|
18
|
$handler = panelizer_entity_plugin_get_handler($entity_type);
|
19
|
|
20
|
$view_modes = array();
|
21
|
foreach ($handler->plugin['view modes'] as $view_mode => $view_mode_info) {
|
22
|
$view_modes[$view_mode] = $view_mode_info['label'];
|
23
|
}
|
24
|
|
25
|
$form['view_mode'] = array(
|
26
|
'#type' => 'select',
|
27
|
'#title' => t('View mode'),
|
28
|
'#options' => $view_modes,
|
29
|
);
|
30
|
|
31
|
$form['custom'] = array(
|
32
|
'#type' => 'textfield',
|
33
|
'#title' => t('Customized text'),
|
34
|
'#default_value' => $this->options['custom'],
|
35
|
'#description' => t('Text to display if the entity has a custom panel.'),
|
36
|
);
|
37
|
$form['not_panelized'] = array(
|
38
|
'#type' => 'textfield',
|
39
|
'#title' => t('Not panelized text'),
|
40
|
'#default_value' => $this->options['not_panelized'],
|
41
|
'#description' => t('Text to display if the entity is not panelized.'),
|
42
|
);
|
43
|
}
|
44
|
|
45
|
function render($values) {
|
46
|
if ($entity = $this->get_value($values)) {
|
47
|
$view_mode = $this->options['view_mode'];
|
48
|
if (!empty($entity->panelizer[$view_mode]->name)) {
|
49
|
$panelizer = ctools_export_crud_load('panelizer_defaults', $entity->panelizer[$view_mode]->name);
|
50
|
$status = !empty($panelizer->title) ? check_plain($panelizer->title) : t('Default');
|
51
|
}
|
52
|
else if (!empty($entity->panelizer[$view_mode]->did)) {
|
53
|
$status = $this->options['custom'];
|
54
|
}
|
55
|
else {
|
56
|
$status = $this->options['not_panelized'];
|
57
|
}
|
58
|
|
59
|
return $status;
|
60
|
}
|
61
|
}
|
62
|
|
63
|
}
|