1 |
87dbc3bf
|
Benjamin Luce
|
<?php
|
2 |
|
|
|
3 |
|
|
|
4 |
|
|
|
5 |
|
|
|
6 |
|
|
|
7 |
|
|
|
8 |
|
|
|
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 |
|
|
|
22 |
|
|
|
23 |
|
|
$status_class = array(
|
24 |
|
|
'status' => 'success',
|
25 |
|
|
'error' => 'danger',
|
26 |
|
|
'warning' => 'warning',
|
27 |
|
|
|
28 |
|
|
|
29 |
|
|
|
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=\"#\">×</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 |
|
|
} |