Projet

Général

Profil

Paste
Télécharger (2,03 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / ctools / plugins / content_types / page / page_tabs.inc @ c304a780

1
<?php
2

    
3
/**
4
 * @file
5
 * Plugin to handle the 'page' content type which allows the standard page
6
 * template variables to be embedded into a panel.
7
 */
8

    
9
/**
10
 * Plugins are described by creating a $plugin array which will be used
11
 * by the system that includes this file.
12
 */
13
$plugin = array(
14
  'title' => t('Tabs'),
15
  'single' => TRUE,
16
  'icon' => 'icon_page.png',
17
  'description' => t('Add the tabs (local tasks) as content.'),
18
  'category' => t('Page elements'),
19
  'render last' => TRUE,
20
  'defaults' => array(
21
    'type' => 'both',
22
    'id' => 'tabs',
23
  ),
24
);
25

    
26
/**
27
 * Output function for the 'page_tabs' content type.
28
 *
29
 * Outputs the tabs (local tasks) of the current page.
30
 */
31
function ctools_page_tabs_content_type_render($subtype, $conf, $panel_args) {
32
  $block = new stdClass();
33
  $menus = menu_local_tabs();
34

    
35
  if (empty($menus['#secondary']) && empty($menus['#primary'])) {
36
    return;
37
  }
38

    
39
  switch ($conf['type']) {
40
    case 'primary':
41
      unset($menus['#secondary']);
42
      break;
43

    
44
    case 'secondary':
45
      unset($menus['#primary']);
46
      break;
47
  }
48
  if ($conf['id']) {
49
    $menus['#theme_wrappers'][] = 'container';
50
    $menus['#attributes']['id'] = $conf['id'];
51
  }
52

    
53
  $block->content = $menus;
54

    
55
  return $block;
56
}
57

    
58
function ctools_page_tabs_content_type_edit_form($form, &$form_state) {
59
  $conf = $form_state['conf'];
60

    
61
  $form['type'] = array(
62
    '#title' => t('Tabs type'),
63
    '#type' => 'select',
64
    '#options' => array(
65
      'both' => t('Primary and secondary'),
66
      'primary' => t('Primary'),
67
      'secondary' => t('Secondary'),
68
    ),
69
    '#default_value' => $conf['type'],
70
  );
71

    
72
  $form['id'] = array(
73
    '#title' => t('CSS id to use'),
74
    '#type' => 'textfield',
75
    '#default_value' => $conf['id'],
76
  );
77
  return $form;
78
}
79

    
80
/**
81
 * The submit form stores the data in $conf.
82
 */
83
function ctools_page_tabs_content_type_edit_form_submit($form, &$form_state) {
84
  foreach (array_keys($form_state['plugin']['defaults']) as $key) {
85
    if (isset($form_state['values'][$key])) {
86
      $form_state['conf'][$key] = $form_state['values'][$key];
87
    }
88
  }
89
}