1 |
87dbc3bf
|
Benjamin Luce
|
<?php
|
2 |
|
|
|
3 |
|
|
|
4 |
|
|
|
5 |
|
|
|
6 |
|
|
|
7 |
|
|
|
8 |
|
|
|
9 |
|
|
|
10 |
|
|
function bootstrap_file_widget($variables) {
|
11 |
|
|
$element = $variables['element'];
|
12 |
|
|
$output = '';
|
13 |
|
|
|
14 |
|
|
$hidden_elements = array();
|
15 |
|
|
foreach (element_children($element) as $child) {
|
16 |
|
|
if ($element[$child]['#type'] === 'hidden') {
|
17 |
|
|
$hidden_elements[$child] = $element[$child];
|
18 |
|
|
unset($element[$child]);
|
19 |
|
|
}
|
20 |
|
|
}
|
21 |
|
|
|
22 |
|
|
$element['upload_button']['#prefix'] = '<span class="input-group-btn">';
|
23 |
|
|
$element['upload_button']['#suffix'] = '</span>';
|
24 |
|
|
|
25 |
|
|
|
26 |
|
|
$output .= '<div class="file-widget form-managed-file clearfix input-group">';
|
27 |
|
|
if (!empty($element['fid']['#value'])) {
|
28 |
|
|
|
29 |
|
|
$element['filename']['#markup'] .= ' <span class="file-size">(' . format_size($element['#file']->filesize) . ')</span> ';
|
30 |
|
|
}
|
31 |
|
|
$output .= drupal_render_children($element);
|
32 |
|
|
$output .= '</div>';
|
33 |
|
|
$output .= render($hidden_elements);
|
34 |
|
|
return $output;
|
35 |
|
|
} |