Projet

Général

Profil

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

root / drupal7 / sites / all / modules / ctools / includes / collapsible.theme.inc @ 7e72b748

1
<?php
2

    
3
/**
4
 * @file
5
 * Theme function for the collapsible div tool.
6
 *
7
 * Call theme('ctools_collapsible', $handle, $content, $collapsed) to draw the
8
 * div. The theme function is not necessary; you can add the classes, js and css
9
 * yourself if you really want to.
10
 */
11

    
12
/**
13
 * Delegated implementation of hook_theme()
14
 */
15
function ctools_collapsible_theme(&$items) {
16
  $items['ctools_collapsible'] = array(
17
    'variables' => array('handle' => NULL, 'content' => NULL, 'collapsed' => FALSE),
18
    'file' => 'includes/collapsible.theme.inc',
19
  );
20
  $items['ctools_collapsible_remembered'] = array(
21
    'variables' => array('id' => NULL, 'handle' => NULL, 'content' => NULL, 'collapsed' => FALSE),
22
    'file' => 'includes/collapsible.theme.inc',
23
  );
24
}
25

    
26
/**
27
 * Render a collapsible div.
28
 *
29
 * @param $handle
30
 *   Text to put in the handle/title area of the div.
31
 * @param $content
32
 *   Text to put in the content area of the div, this is what will get
33
 *   collapsed
34
 * @param $collapsed = FALSE
35
 *   If true, this div will start out collapsed.
36
 */
37
function theme_ctools_collapsible($vars) {
38
  ctools_add_js('collapsible-div');
39
  ctools_add_css('collapsible-div');
40

    
41
  $class = $vars['collapsed'] ? ' ctools-collapsed' : '';
42
  $output = '<div class="ctools-collapsible-container' . $class . '">';
43
  $output .= '<div class="ctools-collapsible-handle">' . $vars['handle'] . '</div>';
44
  $output .= '<div class="ctools-collapsible-content">' . $vars['content'] . '</div>';
45
  $output .= '</div>';
46

    
47
  return $output;
48
}
49

    
50
/**
51
 * Render a collapsible div whose state will be remembered.
52
 *
53
 * @param $id
54
 *   The CSS id of the container. This is required.
55
 * @param $handle
56
 *   Text to put in the handle/title area of the div.
57
 * @param $content
58
 *   Text to put in the content area of the div, this is what will get
59
 *   collapsed
60
 * @param $collapsed = FALSE
61
 *   If true, this div will start out collapsed.
62
 */
63
function theme_ctools_collapsible_remembered($vars) {
64
  $id = $vars['id'];
65
  $handle = $vars['handle'];
66
  $content = $vars['content'];
67
  $collapsed = $vars['collapsed'];
68
  ctools_add_js('collapsible-div');
69
  ctools_add_css('collapsible-div');
70

    
71
  $class = $collapsed ? ' ctools-collapsed' : '';
72
  $output = '<div id="' . $id . '" class="ctools-collapsible-remember ctools-collapsible-container' . $class . '">';
73
  $output .= '<div class="ctools-collapsible-handle">' . $handle . '</div>';
74
  $output .= '<div class="ctools-collapsible-content">' . $content . '</div>';
75
  $output .= '</div>';
76

    
77
  return $output;
78
}