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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
<?php
/**
* @file
* Definition of the 'vertical tabs' panel style.
* See https://drupal.org/node/1101536
*/
// Plugin definition
$plugin = array(
'title' => t('Tabs'),
'description' => t('Presents the panes in a tabs fieldset.'),
'render region' => 'panels_tabs_style_render_region',
'settings form' => 'panels_tabs_style_settings_form',
'settings validate' => 'panels_tabs_style_settings_validate',
);
/**
* Render callback.
*
* @ingroup themeable
*/
function theme_panels_tabs_style_render_region($vars) {
$display = $vars['display'];
$region_id = $vars['region_id'];
$panes = $vars['panes'];
$settings = $vars['settings'];
//Build items and fieldset
$items = array();
$owner = $vars['owner_id'];
$build[$owner] = array(
'#type' => 'vertical_tabs',
'#weight' => 99,
);
foreach ($panes as $pane_id => $item) {
// Only getting the "Override Title" for now... needs work to get the pane title
$title = $display->content[$pane_id]->configuration['override_title_text'];
$pane_class = "pane_" . $pane_id;
$build[$pane_class] = array(
'#type' => 'fieldset',
'#title' => $title,
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#group' => $owner,
'#attributes' => array(
'class' => array($pane_class),
),
'#tree' => TRUE,
'#weight' => -2,
);
$build[$pane_class]['items'] = array(
'#markup' => $item,
);
}
return theme($settings['tabs_type'], array(
'element' => array(
'#children' => render($build),
),
));
}
/**
* Settings form callback.
*/
function panels_tabs_style_settings_form($style_settings) {
//Vertical tabs are in core
$options['vertical_tabs'] = t('Vertical');
//field_group.module allows same structure, for horizontal tabs
if (module_exists('field_group')) $options['horizontal_tabs'] = t('Horizontal');
$form['tabs_type'] = array(
'#type' => 'select',
'#title' => t('Tabs type'),
'#options' => $options,
'#default_value' => (isset($style_settings['tabs_type'])) ? $style_settings['tabs_type'] : 'vertical_tabs',
);
return $form;
}
|