form.inc
2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
function drupalexp_status_messages($variables) {
$display = $variables['display'];
$output = '';
$status_heading = array(
'status' => t('Status message'),
'error' => t('Error message'),
'warning' => t('Warning message'),
);
$status_classes = array(
'status' => 'success',
'error' => 'danger',
'warning' => 'warning',
);
foreach (drupal_get_messages($display) as $type => $messages) {
$output .= "<div class=\"alert alert-{$status_classes[$type]} alert-dismissable\">\n";
$output .= "<button type=\"button\" class=\"close\" data-dismiss=\"alert\" aria-hidden=\"true\">×</button>";
if (!empty($status_heading[$type])) {
$output .= '<h2 class="element-invisible">' . $status_heading[$type] . "</h2>\n";
}
if (count($messages) > 1) {
$output .= " <ul>\n";
foreach ($messages as $message) {
$output .= ' <li>' . $message . "</li>\n";
}
$output .= " </ul>\n";
}
else {
$output .= $messages[0];
}
$output .= "</div>\n";
}
return $output;
}
/**
* Preprocessor for theme('button').
*/
function drupalexp_preprocess_button(&$vars) {
$vars['element']['#attributes']['class'][] = 'btn';
if (isset($vars['element']['#value'])) {
$classes = array(
//specifics
t('Save and add') => 'btn-info',
t('Add another item') => 'btn-info',
t('Add effect') => 'btn-primary',
t('Add and configure') => 'btn-primary',
t('Update style') => 'btn-primary',
t('Download feature') => 'btn-primary',
//generals
t('Save') => 'btn-default',
t('Apply') => 'btn-primary',
t('Create') => 'btn-primary',
t('Confirm') => 'btn-primary',
t('Submit') => 'btn-primary',
t('Export') => 'btn-primary',
t('Import') => 'btn-primary',
t('Restore') => 'btn-primary',
t('Rebuild') => 'btn-primary',
t('Search') => 'btn-primary',
t('Add') => 'btn-info',
t('Update') => 'btn-info',
t('Delete') => 'btn-danger',
t('Remove') => 'btn-danger',
t('Send message') => 'btn-default',
t('Log in') => 'btn-primary',
);
foreach ($classes as $search => $class) {
if (strpos($vars['element']['#value'], $search) !== FALSE) {
$vars['element']['#attributes']['class'][] = $class;
break;
}
}
}
}