1 |
caf16a48
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
|
4 |
|
|
|
5 |
|
|
|
6 |
|
|
|
7 |
|
|
|
8 |
|
|
|
9 |
|
|
|
10 |
|
|
|
11 |
|
|
|
12 |
|
|
|
13 |
|
|
|
14 |
|
|
|
15 |
|
|
|
16 |
|
|
|
17 |
|
|
|
18 |
|
|
|
19 |
|
|
|
20 |
|
|
|
21 |
|
|
|
22 |
|
|
|
23 |
|
|
|
24 |
|
|
function bootstrap_file_upload_help($variables) {
|
25 |
|
|
|
26 |
|
|
if (!bootstrap_setting('popover_enabled')) {
|
27 |
|
|
return theme_file_upload_help($variables);
|
28 |
|
|
}
|
29 |
|
|
|
30 |
|
|
$build = array();
|
31 |
|
|
if (!empty($variables['description'])) {
|
32 |
|
|
$build['description'] = array(
|
33 |
|
|
'#markup' => $variables['description'] . '<br>',
|
34 |
|
|
);
|
35 |
|
|
}
|
36 |
|
|
|
37 |
|
|
$descriptions = array();
|
38 |
|
|
$upload_validators = $variables['upload_validators'];
|
39 |
|
|
if (isset($upload_validators['file_validate_size'])) {
|
40 |
|
|
$descriptions[] = t('Files must be less than !size.', array('!size' => '<strong>' . format_size($upload_validators['file_validate_size'][0]) . '</strong>'));
|
41 |
|
|
}
|
42 |
|
|
if (isset($upload_validators['file_validate_extensions'])) {
|
43 |
|
|
$descriptions[] = t('Allowed file types: !extensions.', array('!extensions' => '<strong>' . check_plain($upload_validators['file_validate_extensions'][0]) . '</strong>'));
|
44 |
|
|
}
|
45 |
|
|
if (isset($upload_validators['file_validate_image_resolution'])) {
|
46 |
|
|
$max = $upload_validators['file_validate_image_resolution'][0];
|
47 |
|
|
$min = $upload_validators['file_validate_image_resolution'][1];
|
48 |
|
|
if ($min && $max && $min == $max) {
|
49 |
|
|
$descriptions[] = t('Images must be exactly !size pixels.', array('!size' => '<strong>' . $max . '</strong>'));
|
50 |
|
|
}
|
51 |
|
|
elseif ($min && $max) {
|
52 |
|
|
$descriptions[] = t('Images must be between !min and !max pixels.', array('!min' => '<strong>' . $min . '</strong>', '!max' => '<strong>' . $max . '</strong>'));
|
53 |
|
|
}
|
54 |
|
|
elseif ($min) {
|
55 |
|
|
$descriptions[] = t('Images must be larger than !min pixels.', array('!min' => '<strong>' . $min . '</strong>'));
|
56 |
|
|
}
|
57 |
|
|
elseif ($max) {
|
58 |
|
|
$descriptions[] = t('Images must be smaller than !max pixels.', array('!max' => '<strong>' . $max . '</strong>'));
|
59 |
|
|
}
|
60 |
|
|
}
|
61 |
|
|
|
62 |
|
|
if ($descriptions) {
|
63 |
|
|
$id = drupal_html_id('upload-instructions');
|
64 |
|
|
$build['instructions'] = array(
|
65 |
|
|
'#theme' => 'link__file_upload_requirements',
|
66 |
|
|
|
67 |
|
|
'#text' => _bootstrap_icon('question-sign') . ' ' . t('More information'),
|
68 |
|
|
'#path' => '#',
|
69 |
|
|
'#options' => array(
|
70 |
|
|
'attributes' => array(
|
71 |
|
|
'data-toggle' => 'popover',
|
72 |
|
|
'data-target' => "#$id",
|
73 |
|
|
'data-html' => TRUE,
|
74 |
|
|
'data-placement' => 'bottom',
|
75 |
|
|
'data-title' => t('File requirements'),
|
76 |
|
|
),
|
77 |
|
|
'html' => TRUE,
|
78 |
|
|
'external' => TRUE,
|
79 |
|
|
),
|
80 |
|
|
);
|
81 |
|
|
$build['requirements'] = array(
|
82 |
|
|
'#theme_wrappers' => array('container__file_upload_requirements'),
|
83 |
|
|
'#attributes' => array(
|
84 |
|
|
'id' => $id,
|
85 |
|
|
'class' => array('element-invisible', 'help-block'),
|
86 |
|
|
),
|
87 |
|
|
);
|
88 |
|
|
$build['requirements']['validators'] = array(
|
89 |
|
|
'#theme' => 'item_list__file_upload_requirements',
|
90 |
|
|
'#items' => $descriptions,
|
91 |
|
|
);
|
92 |
|
|
}
|
93 |
|
|
|
94 |
|
|
return drupal_render($build);
|
95 |
|
|
} |