blob: 3ab92a5b6c7190fc7dbde4ab95e015285654b62b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
<?php
/**
* @var array $languages
* @var array $attributes
* @var string $base_lang
* @var string $name
* @var I18NString $value
*
*/
?>
<? foreach ($languages as $locale => $lang): ?>
<?
$attr = $attributes;
if ($locale === $base_lang) {
$attr['name'] = $name;
$attr['value'] = $value->original();
} else {
$attr['name'] = "{$name}_i18n[{$locale}]";
$attr['value'] = $value->translation($locale);
if (isset($attr['id'])) {
unset($attr['id']);
}
// Remove required attribute if no text has been set
if (isset($attr['required']) && !$attr['value']) {
unset($attr['required']);
}
}
// If special attribute locale_names is defined, use name from that
if (isset($attr['locale_names']) && is_array($attr['locale_names'])) {
$attr['name'] = $attr['locale_names'][$locale];
unset($attr['locale_names']);
}
?>
<div class="i18n" data-lang="<?= $lang['name'] ?>" data-icon="url(<?= Assets::image_path("languages/{$lang['picture']}") ?>)">
<input type="text" <?= arrayToHtmlAttributes($attr) ?>>
</div>
<? endforeach; ?>
|