4 'title' => t('AJAX Tab - Tabs'),
5 'description' => t('List of Tabs to control a container'),
7 'category' => t('AJAX Tabs'),
8 'required context' => array(
9 new
ctools_context_optional(t('Entity Context'), 'entity'),
11 'render callback' => 'panels_ajax_tab_tabs_render',
12 'edit form' => 'panels_ajax_tab_tabs_edit_form'
15 function panels_ajax_tab_tabs_render($subtype, $conf, $panel_args, &$contexts) {
16 static
$default_tab_container_id = 0;
17 ctools_include('context');
18 ctools_include('plugins', 'panels');
19 $block = new
stdClass();
23 // Add required JavaScript and CSS
24 drupal_add_js(drupal_get_path('module', 'panels_ajax_tab') .
'/js/panels_ajax_tab.js');
26 // Generate the context string
27 if (!$contexts[0]->data
) {
28 $context_string = 'none';
31 $entity_type = $contexts[0]->type
[2];
32 $entity_ids = entity_extract_ids($entity_type, $contexts[0]->data
);
33 $entity_id = array_shift($entity_ids);
34 $context_string = $entity_type .
':' .
$entity_id;
37 // sort and load the mini-panels
38 $minipanels = array();
39 uasort($conf['mini_panels'], function($a,$b) { return $a['weight'] - $b['weight']; });
40 foreach ($conf['mini_panels'] as
$panel_name => $panel_conf) {
41 if ($panel_conf['selected']) {
42 $minipanels[] = panels_mini_load($panel_name);
47 $block->content .
= theme('panels_ajax_tab_tabs', array('minipanels' => $minipanels, 'tab_container_id' => $conf['container_id'], 'context_string' => $context_string));
52 function panels_ajax_tab_tabs_edit_form($form, &$form_state) {
53 $conf = $form_state['conf'];
54 $panels = panels_mini_load_all();
55 foreach($panels as
$panel_name => $panel) {
56 $panels[$panel_name] = (array) $panel;
57 $panels[$panel_name] = empty($conf['mini_panels'][$panel_name]) ?
$panels[$panel_name] : array_merge($panels[$panel_name],$conf['mini_panels'][$panel_name]);
59 if(!empty($conf['mini_panels'][$panel_name])) {
60 uasort($panels, function($a,$b) { return $a['weight'] - $b['weight'];});
63 $form['mini_panels']['#tree'] = TRUE
;
64 foreach ($panels as
$mini_panel) {
65 $form['mini_panels'][$mini_panel['name']] = array(
68 '#type' => 'checkbox',
69 '#default_value' => $mini_panel['selected'],
73 '#markup' => $mini_panel['admin_title'],
78 '#title' => t('Weight'),
79 '#default_value' => $mini_panel['weight'],
81 '#title-display' => 'invisible',
86 $form['container_id'] = array(
87 '#title' => t('Container ID'),
88 '#type' => 'textfield',
89 '#description' => 'If you are using tabs in seperate pane, you must supply a unique container id string.',
90 '#default_value' => $conf['container_id'],
93 $form['#theme'] = array('panels_ajax_tab_tabs_edit_form');
98 function panels_ajax_tab_tabs_edit_form_submit(&$form, &$form_state) {
99 $form_state['conf']['mini_panels'] = $form_state['values']['mini_panels'];
100 $form_state['conf']['container_id'] = $form_state['values']['container_id'];