Projet

Général

Profil

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

root / drupal7 / sites / all / themes / bootstrap / theme / file / file-managed-file.func.php @ 87dbc3bf

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

    
7
/**
8
 * Overrides theme_file_managed_file().
9
 */
10
function bootstrap_file_managed_file($variables) {
11
  $element = $variables['element'];
12

    
13
  $attributes = array();
14
  if (isset($element['#id'])) {
15
    $attributes['id'] = $element['#id'];
16
  }
17
  if (!empty($element['#attributes']['class'])) {
18
    $attributes['class'] = (array) $element['#attributes']['class'];
19
  }
20
  $attributes['class'][] = 'form-managed-file';
21
  $attributes['class'][] = 'input-group';
22

    
23
  $element['upload_button']['#prefix'] = '<span class="input-group-btn">';
24
  $element['upload_button']['#suffix'] = '</span>';
25
  $element['remove_button']['#prefix'] = '<span class="input-group-btn">';
26
  $element['remove_button']['#suffix'] = '</span>';
27

    
28
  if (!empty($element['filename'])) {
29
    $element['filename']['#prefix'] = '<div class="form-control">';
30
    $element['filename']['#suffix'] = '</div>';
31
  }
32

    
33
  $hidden_elements = array();
34
  foreach (element_children($element) as $child) {
35
    if ($element[$child]['#type'] === 'hidden') {
36
      $hidden_elements[$child] = $element[$child];
37
      unset($element[$child]);
38
    }
39
  }
40

    
41
  // This wrapper is required to apply JS behaviors and CSS styling.
42
  $output = '';
43
  $output .= '<div' . drupal_attributes($attributes) . '>';
44
  $output .= drupal_render_children($element);
45
  $output .= '</div>';
46
  $output .= render($hidden_elements);
47
  return $output;
48
}