Test Failed
Push — master ( e3c39f...fe570d )
by Mihail
07:20
created

Apps/View/Admin/default/profile/field_update.php (1 issue)

Labels
Severity
1
<?php
2
3
use Ffcms\Core\Helper\Type\Str;
4
use Ffcms\Templex\Url\Url;
0 ignored issues
show
This use statement conflicts with another class in this namespace, Url. Consider defining an alias.

Let?s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let?s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
5
6
/** @var \Ffcms\Templex\Template\Template $this */
7
/** @var Apps\Model\Admin\Profile\FormFieldUpdate $model */
8
/** @var \Apps\ActiveRecord\ProfileField $record */
9
10
$this->layout('_layouts/default', [
11
    'title' => __('Manage field'),
12
    'breadcrumbs' => [
13
        Url::to('main/index') => __('Main'),
14
        Url::to('application/index') => __('Applications'),
15
        Url::to('profile/index') => __('Profile list'),
16
        Url::to('profile/fieldlist') => __('Profile fields'),
17
        __('Manage field')
18
    ]
19
]);
20
?>
21
22
<?php $this->start('body') ?>
23
24
<?= $this->insert('profile/_tabs') ?>
25
26
<h1><?= __('Manage addition field') ?></h1>
27
<?php $form = $this->form($model) ?>
28
29
<?= $form->start() ?>
30
31
<?php
32
$menu = $this->bootstrap()->nav('ul', ['class' => 'nav-tabs']);
33
foreach (\App::$Properties->get('languages') as $lang) {
34
    $menu->menu([
35
        'text' => Str::upperCase($lang),
36
        'tab' => function() use ($form, $lang) {
37
            return $form->fieldset()->text('name.' . $lang, null, __('Define field name, which be displayed for user for current language locale'));
38
        },
39
        'tabActive' => $lang === \App::$Request->getLanguage(),
40
    ]);
41
}
42
?>
43
44
<div class="nav-border">
45
    <?= $menu->display() ?>
46
</div>
47
48
<?= $form->fieldset()->select('type', ['options' => ['text', 'link']], __('Select additional field type')) ?>
49
<?= $form->fieldset()->text('reg_exp', null, __('Set regular expression to validate input data from user for this field. Example: /^[0-9]*$/')) ?>
50
<?= $form->fieldset()->select(
51
    'reg_cond',
52
    ['options' => [
53
            '0' => __('Reverse (exclude) condition'),
54
            '1' => __('Direct (include) condition')
55
    ], 'optionsKey' => true],
56
    __('Specify condition type of validation expression. Direct - if(cond), reverse - if(!cond)')
57
) ?>
58
<?php if ($model->reg_exp): ?>
59
    <div class="row">
60
        <div class="col-md-3">
61
            <label class="pull-right"><?= __('How it work') ?></label>
62
        </div>
63
        <div class="col-md-9">
64
<pre>
65
if (<?= $model->reg_cond == 0 ? '!' : null ?>preg_match('<?= $model->reg_exp ?>', $input)) {
66
    // validation passed
67
} else {
68
    // validation failed
69
}
70
</pre>
71
        </div>
72
    </div>
73
<?php endif; ?>
74
75
<?= $form->button()->submit(__('Save'), ['class' => 'btn btn-primary']) ?>
76
<?= $form->button()->cancel(__('Cancel'), ['link' => ['profile/fieldlist'], 'class' => 'btn btn-secondary']) ?>
77
78
<?= $form->stop() ?>
79
80
<?= $this->stop() ?>