Completed
Push — master ( 27322b...2405c1 )
by Andrey
01:30
created

src/views/fieldsMultilanguage.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 15 and the first side effect is on line 20.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
3
use yii\helpers\ArrayHelper;
4
use yii\db\ActiveRecord;
5
use yii\widgets\ActiveForm;
6
use Itstructure\FieldWidgets\FieldType;
7
use Itstructure\FieldWidgets\interfaces\{LanguageListInterface, LanguageFieldInterface};
8
9
/** @var LanguageListInterface|ActiveRecord $languageModel */
10
/** @var LanguageFieldInterface|ActiveRecord $language */
11
/** @var array[] $fields */
12
/** @var ActiveRecord $model */
13
/** @var ActiveForm $form */
14
15
function isActive(LanguageFieldInterface $language)
16
{
17
    return $language->getDefault() == 1 ? 'active' : '';
18
}
19
?>
20
21
<ul class="nav nav-tabs" id="languages">
22
    <?php foreach ($languageModel->getLanguageList() as $language): ?>
23
        <li class="<?php echo isActive($language) ?>">
24
            <a href="#<?php echo $language->getShortName() ?>" data-toggle="tab"><?php echo $language->getName() ?></a>
25
        </li>
26
    <?php endforeach; ?>
27
</ul>
28
29
<div class="tab-content">
30
    <?php foreach ($languageModel->getLanguageList() as $language): ?>
31
        <div class="tab-pane <?php echo isActive($language) ?>" id="<?php echo $language->getShortName() ?>">
32
33 View Code Duplication
            <?php foreach ($fields as $field): ?>
34
35
                <?php if (null === $field || empty($field)){continue;} ?>
36
37
                <?php echo FieldType::widget(ArrayHelper::merge($field, [
38
                    'model' => $model,
39
                    'form' => $form,
40
                    'language' => $language,
41
                ])) ?>
42
43
            <?php endforeach; ?>
44
45
        </div>
46
    <?php endforeach; ?>
47
</div>
48