Projet

Général

Profil

Paste
Télécharger (1,47 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / themes / bootstrap / theme / system / item-list.func.php @ 87dbc3bf

1
<?php
2
/**
3
 * @file
4
 * item-list.func.php
5
 */
6

    
7
/**
8
 * Overrides theme_item_list().
9
 */
10
function bootstrap_item_list($variables) {
11
  $items = $variables['items'];
12
  $title = $variables['title'];
13
  $type = $variables['type'];
14
  $attributes = $variables['attributes'];
15
  $output = '';
16

    
17
  if (isset($title)) {
18
    $output .= '<h3>' . $title . '</h3>';
19
  }
20

    
21
  if (!empty($items)) {
22
    $output .= "<$type" . drupal_attributes($attributes) . '>';
23
    $num_items = count($items);
24
    $i = 0;
25
    foreach ($items as $item) {
26
      $attributes = array();
27
      $children = array();
28
      $data = '';
29
      $i++;
30
      if (is_array($item)) {
31
        foreach ($item as $key => $value) {
32
          if ($key == 'data') {
33
            $data = $value;
34
          }
35
          elseif ($key == 'children') {
36
            $children = $value;
37
          }
38
          else {
39
            $attributes[$key] = $value;
40
          }
41
        }
42
      }
43
      else {
44
        $data = $item;
45
      }
46
      if (count($children) > 0) {
47
        // Render nested list.
48
        $data .= theme('item_list', array(
49
          'items' => $children,
50
          'title' => NULL,
51
          'type' => $type,
52
          'attributes' => $attributes,
53
        ));
54
      }
55
      if ($i == 1) {
56
        $attributes['class'][] = 'first';
57
      }
58
      if ($i == $num_items) {
59
        $attributes['class'][] = 'last';
60
      }
61
      $output .= '<li' . drupal_attributes($attributes) . '>' . $data . "</li>\n";
62
    }
63
    $output .= "</$type>";
64
  }
65

    
66
  return $output;
67
}