fixed faulty title issye for vertical tabs option of tabs style plugin
[project/panels_style_pack.git] / plugins / styles / tabs.inc
1 <?php
2
3
4 /**
5 * @file
6 * Definition of the 'Tabs' panel style.
7 */
8
9 // Plugin definition
10 $plugin = array(
11 'title' => t('Tabs'),
12 'description' => t('Show panel panes in a region as tabs.'),
13 'render region' => 'panels_style_pack_tabs_style_render_region',
14 'settings form' => 'panels_style_pack_tabs_style_settings_form',
15 );
16
17 /**
18 * Render callback.
19 *
20 * @ingroup themeable
21 */
22 function theme_panels_style_pack_tabs_style_render_region($vars) {
23 $display = $vars['display'];
24 $region_id = $vars['region_id'];
25 $owner_id = $vars['owner_id'];
26 $panes = $vars['panes'];
27 $settings_tabs = $vars['settings'];
28 $tab_id = 'tabs-' . $owner_id . '-' . $region_id;
29
30 if($settings_tabs['tab_type'] === 'horizontal' || $settings_tabs['tab_type'] === 'bottom') {
31 $element = array(
32 '#prefix' => '<div id="' . $tab_id . '">',
33 '#suffix' => '</div>',
34 '#attached' => array(
35 'library' => array(array('system', 'ui.tabs')),
36 'js' => array(
37 drupal_get_path('module', 'panels_style_pack') . '/js/panels_style_pack.js' => array('type' => 'file'),
38 ),
39 ),
40 );
41 $settings = array();
42 $settings['panelsTabs']['tab_style'] = $settings_tabs['tab_style'];
43 $settings['panelsTabs']['tabsID'][] = $tab_id;
44 $settings['type'] = 'tabs';
45 $settings['panelsTabs']['orientation'] = $settings_tabs['tab_type'];
46
47 $element['#attached']['js'][] = array(
48 'type' => 'setting',
49 'data' => $settings,
50 );
51
52 // Get the pane titles.
53 $items = array();
54 $delta = 1;
55 foreach ($display->panels[$region_id] as $pane_id) {
56 // Make sure the pane exists.
57 if (!empty($panes[$pane_id])) {
58 $title = panels_style_pack_pane_titles($display->did, $pane_id);
59 $title = $title ? $title : t('Tab @delta', array('@delta' => $delta));
60 $items[] = '<a href="#'. $tab_id . '-' . $delta .'">' . $title . '</a>';
61 ++$delta;
62 }
63 }
64
65 $element['tabs_title'] = array('#theme' => 'item_list', '#items' => $items);
66
67 $items = array();
68 $delta = 1;
69 foreach ($panes as $pane_id => $item) {
70 $element['tabs_content'][$pane_id] = array(
71 '#prefix' => '<div id="' . $tab_id . '-' . $delta . '">',
72 '#suffix' => '</div>',
73 '#markup' => $item,
74 );
75 ++$delta;
76 }
77 if($settings_tabs['tab_type'] === 'bottom') {
78 $element['#prefix'] = '<div id="' . $tab_id . '" class="tabs-bottom">';
79 }
80 return drupal_render($element);
81 }
82 else if($settings_tabs['tab_type'] === 'vertical_left') {
83
84 $form['vertical_tabs'] = array(
85 '#type' => 'vertical_tabs',
86 '#tree' => TRUE,
87 );
88
89 $items = array();
90 $delta = 1;
91 foreach ($display->panels[$region_id] as $pane_id) {
92 // Make sure the pane exists.
93 if (!empty($panes[$pane_id])) {
94 $title = panels_style_pack_pane_titles($display->did, $pane_id);
95 $title = $title ? $title : t('Tab @delta', array('@delta' => $delta));
96 $items[] = $title;
97 ++$delta;
98 }
99 }
100 foreach($panes as $pane_id => $item) {
101 $pane = $display->content[$pane_id];
102 $form['vertical_tabs'][$pane_id] = array(
103 '#type' => 'fieldset',
104 '#title' => $items[$pane_id-1],
105 '#group' => 'vertical_tabs',
106 '#tree' => TRUE,
107 );
108
109 $form['vertical_tabs'][$pane_id]['content'] = array(
110 '#prefix' => '<div id="' . $tab_id . '-' . $delta . '">',
111 '#suffix' => '</div>',
112 '#markup' => $item,
113 );
114 ++$delta;
115 }
116 return drupal_render($form);
117 }
118 }
119
120 function panels_style_pack_tabs_style_settings_form($style_settings) {
121 $form = array();
122
123 $form['tab_type'] = array(
124 '#type' => 'select',
125 '#title' => t('Tab Type'),
126 '#default_value' => $style_settings['tab_type'],
127 '#options' => array(
128 'horizontal' => t('Horizontal'),
129 'vertical_left' => t('Vertical Left'),
130 'bottom' => t('Bottom'),
131 ),
132 '#description' => t('The type of tab'),
133 );
134
135 $form['tab_style'] = array(
136 '#type' => 'select',
137 '#title' => t('Tab Style'),
138 '#default_value' => $style_settings['tab_style'],
139 '#options' => array(
140 'collapsible' => t('Collapsible'),
141 'open_mouseover' => t('Open on mouseover'),
142 ),
143 '#description' => t('The Style of the tabs'),
144 );
145 return $form;
146 }