1 |
caf16a48
|
Assos Assos
|
<?php
|
2 |
eefc2ac0
|
Assos Assos
|
|
3 |
caf16a48
|
Assos Assos
|
|
4 |
|
|
|
5 |
|
|
|
6 |
|
|
|
7 |
|
|
|
8 |
|
|
|
9 |
|
|
|
10 |
|
|
|
11 |
|
|
|
12 |
|
|
|
13 |
|
|
|
14 |
|
|
|
15 |
|
|
|
16 |
|
|
|
17 |
|
|
|
18 |
|
|
|
19 |
|
|
|
20 |
|
|
|
21 |
|
|
|
22 |
eefc2ac0
|
Assos Assos
|
function bootstrap_file_widget_multiple(array $variables) {
|
23 |
caf16a48
|
Assos Assos
|
$element = $variables['element'];
|
24 |
|
|
|
25 |
|
|
|
26 |
|
|
$weight_class = $element['#id'] . '-weight';
|
27 |
|
|
$table_id = $element['#id'] . '-table';
|
28 |
|
|
|
29 |
|
|
|
30 |
|
|
$headers = array();
|
31 |
|
|
$headers[] = t('File information');
|
32 |
|
|
if ($element['#display_field']) {
|
33 |
|
|
$headers[] = array(
|
34 |
|
|
'data' => t('Display'),
|
35 |
|
|
'class' => array('checkbox'),
|
36 |
|
|
);
|
37 |
|
|
}
|
38 |
|
|
$headers[] = t('Weight');
|
39 |
|
|
$headers[] = t('Operations');
|
40 |
|
|
|
41 |
|
|
|
42 |
|
|
|
43 |
|
|
$widgets = array();
|
44 |
|
|
foreach (element_children($element) as $key) {
|
45 |
|
|
$widgets[] = &$element[$key];
|
46 |
|
|
}
|
47 |
|
|
usort($widgets, '_field_sort_items_value_helper');
|
48 |
|
|
|
49 |
|
|
$rows = array();
|
50 |
|
|
foreach ($widgets as $key => &$widget) {
|
51 |
|
|
|
52 |
4eeb3b46
|
Assos Assos
|
if (!isset($widget['#file']) || $widget['#file'] === FALSE) {
|
53 |
caf16a48
|
Assos Assos
|
$widget['#title'] = $element['#file_upload_title'];
|
54 |
|
|
$widget['#description'] = $element['#file_upload_description'];
|
55 |
|
|
continue;
|
56 |
|
|
}
|
57 |
|
|
|
58 |
|
|
|
59 |
|
|
|
60 |
|
|
$operations_elements = array();
|
61 |
|
|
foreach (element_children($widget) as $sub_key) {
|
62 |
|
|
if (isset($widget[$sub_key]['#type']) && $widget[$sub_key]['#type'] == 'submit') {
|
63 |
|
|
hide($widget[$sub_key]);
|
64 |
|
|
$operations_elements[] = &$widget[$sub_key];
|
65 |
|
|
}
|
66 |
|
|
}
|
67 |
|
|
|
68 |
|
|
|
69 |
|
|
|
70 |
|
|
if ($element['#display_field']) {
|
71 |
|
|
hide($widget['display']);
|
72 |
|
|
}
|
73 |
|
|
hide($widget['_weight']);
|
74 |
|
|
|
75 |
|
|
|
76 |
|
|
$widget['#theme_wrappers'] = array();
|
77 |
|
|
$information = drupal_render($widget);
|
78 |
|
|
|
79 |
|
|
|
80 |
|
|
|
81 |
|
|
$operations = '';
|
82 |
|
|
foreach ($operations_elements as $operation_element) {
|
83 |
|
|
$operation_element['#attributes']['class'][] = 'btn-xs';
|
84 |
|
|
switch ($operation_element['#value']) {
|
85 |
|
|
case t('Remove'):
|
86 |
|
|
$operation_element['#icon'] = _bootstrap_icon('remove');
|
87 |
|
|
break;
|
88 |
|
|
}
|
89 |
|
|
$operations .= render($operation_element);
|
90 |
|
|
}
|
91 |
|
|
$display = '';
|
92 |
|
|
if ($element['#display_field']) {
|
93 |
|
|
unset($widget['display']['#title']);
|
94 |
|
|
$display = array(
|
95 |
|
|
'data' => render($widget['display']),
|
96 |
|
|
'class' => array('checkbox'),
|
97 |
|
|
);
|
98 |
|
|
}
|
99 |
|
|
$widget['_weight']['#attributes']['class'] = array($weight_class);
|
100 |
|
|
$weight = render($widget['_weight']);
|
101 |
|
|
|
102 |
|
|
|
103 |
|
|
$row = array();
|
104 |
|
|
$row[] = $information;
|
105 |
|
|
if ($element['#display_field']) {
|
106 |
|
|
$row[] = $display;
|
107 |
|
|
}
|
108 |
|
|
$row[] = $weight;
|
109 |
|
|
$row[] = $operations;
|
110 |
|
|
$rows[] = array(
|
111 |
|
|
'data' => $row,
|
112 |
|
|
'class' => isset($widget['#attributes']['class']) ? array_merge($widget['#attributes']['class'], array('draggable')) : array('draggable'),
|
113 |
|
|
);
|
114 |
|
|
}
|
115 |
|
|
|
116 |
|
|
drupal_add_tabledrag($table_id, 'order', 'sibling', $weight_class);
|
117 |
|
|
|
118 |
|
|
$output = '';
|
119 |
|
|
if (!empty($rows)) {
|
120 |
|
|
$table = array(
|
121 |
|
|
'#theme' => 'table',
|
122 |
|
|
'#header' => $headers,
|
123 |
|
|
'#rows' => $rows,
|
124 |
|
|
'#attributes' => array(
|
125 |
|
|
'id' => $table_id,
|
126 |
|
|
'class' => array(
|
127 |
|
|
'managed-files',
|
128 |
|
|
),
|
129 |
|
|
),
|
130 |
|
|
);
|
131 |
|
|
$output = drupal_render($table);
|
132 |
|
|
}
|
133 |
|
|
$output .= drupal_render_children($element);
|
134 |
|
|
return $output;
|
135 |
|
|
} |