root / drupal7 / sites / all / themes / bootstrap / templates / file / file-managed-file.func.php @ 27370441
1 |
<?php
|
---|---|
2 |
/**
|
3 |
* @file
|
4 |
* Stub file for bootstrap_file_managed_file().
|
5 |
*/
|
6 |
|
7 |
/**
|
8 |
* Returns HTML for a managed file element.
|
9 |
*
|
10 |
* @param array $variables
|
11 |
* An associative array containing:
|
12 |
* - element: A render element representing the file.
|
13 |
*
|
14 |
* @return string
|
15 |
* The constructed HTML.
|
16 |
*
|
17 |
* @see theme_file_managed_file()
|
18 |
*
|
19 |
* @ingroup theme_functions
|
20 |
*/
|
21 |
function bootstrap_file_managed_file($variables) { |
22 |
$output = ''; |
23 |
$element = $variables['element']; |
24 |
|
25 |
$attributes = array(); |
26 |
if (isset($element['#id'])) { |
27 |
$attributes['id'] = $element['#id']; |
28 |
} |
29 |
if (!empty($element['#attributes']['class'])) { |
30 |
$attributes['class'] = (array) $element['#attributes']['class']; |
31 |
} |
32 |
$attributes['class'][] = 'form-managed-file'; |
33 |
$attributes['class'][] = 'input-group'; |
34 |
|
35 |
$element['upload_button']['#attributes']['class'][] = 'btn-primary'; |
36 |
$element['upload_button']['#prefix'] = '<span class="input-group-btn">'; |
37 |
$element['upload_button']['#suffix'] = '</span>'; |
38 |
$element['remove_button']['#prefix'] = '<span class="input-group-btn">'; |
39 |
$element['remove_button']['#suffix'] = '</span>'; |
40 |
$element['remove_button']['#attributes']['class'][] = 'btn-danger'; |
41 |
|
42 |
if (!empty($element['filename'])) { |
43 |
$element['filename']['#prefix'] = '<div class="form-control">'; |
44 |
$element['filename']['#suffix'] = '</div>'; |
45 |
} |
46 |
|
47 |
// This wrapper is required to apply JS behaviors and CSS styling.
|
48 |
$output .= '<div' . drupal_attributes($attributes) . '>'; |
49 |
|
50 |
// Immediately render hidden elements before the rest of the output.
|
51 |
// The uploadprogress extension requires that the hidden identifier input
|
52 |
// element appears before the file input element. They must also be siblings
|
53 |
// inside the same parent element.
|
54 |
// @see https://www.drupal.org/node/2155419
|
55 |
foreach (element_children($element) as $child) { |
56 |
if (isset($element[$child]['#type']) && $element[$child]['#type'] === 'hidden') { |
57 |
$output .= drupal_render($element[$child]); |
58 |
} |
59 |
} |
60 |
|
61 |
// Render the rest of the element.
|
62 |
$output .= drupal_render_children($element); |
63 |
$output .= '</div>'; |
64 |
return $output; |
65 |
} |