Projet

Général

Profil

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

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

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

    
7
/**
8
 * Overrides theme_breadcrumb().
9
 */
10
function bootstrap_status_messages($variables) {
11
  $display = $variables['display'];
12
  $output = '';
13

    
14
  $status_heading = array(
15
    'status' => t('Status message'),
16
    'error' => t('Error message'),
17
    'warning' => t('Warning message'),
18
    'info' => t('Informative message'),
19
  );
20

    
21
  // Map Drupal message types to their corresponding Bootstrap classes.
22
  // @see http://twitter.github.com/bootstrap/components.html#alerts
23
  $status_class = array(
24
    'status' => 'success',
25
    'error' => 'danger',
26
    'warning' => 'warning',
27
    // Not supported, but in theory a module could send any type of message.
28
    // @see drupal_set_message()
29
    // @see theme_status_messages()
30
    'info' => 'info',
31
  );
32

    
33
  foreach (drupal_get_messages($display) as $type => $messages) {
34
    $class = (isset($status_class[$type])) ? ' alert-' . $status_class[$type] : '';
35
    $output .= "<div class=\"alert alert-block$class\">\n";
36
    $output .= "  <a class=\"close\" data-dismiss=\"alert\" href=\"#\">&times;</a>\n";
37

    
38
    if (!empty($status_heading[$type])) {
39
      $output .= '<h4 class="element-invisible">' . $status_heading[$type] . "</h4>\n";
40
    }
41

    
42
    if (count($messages) > 1) {
43
      $output .= " <ul>\n";
44
      foreach ($messages as $message) {
45
        $output .= '  <li>' . $message . "</li>\n";
46
      }
47
      $output .= " </ul>\n";
48
    }
49
    else {
50
      $output .= $messages[0];
51
    }
52

    
53
    $output .= "</div>\n";
54
  }
55
  return $output;
56
}