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

Apps/View/Admin/default/main/settings.php (1 issue)

Labels
Severity
1
<?php
2
3
/** @var \Ffcms\Templex\Template\Template $this */
4
/** @var \Apps\Model\Admin\Main\FormSettings $model */
5
6
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...
7
8
$this->layout('_layouts/default', [
9
    'title' => __('Settings'),
10
    'breadcrumbs' => [
11
        Url::to('main/index') => __('Main'),
12
        __('Settings')
13
    ]
14
])
15
?>
16
17
<?php $this->push('css') ?>
18
<link rel="stylesheet" href="<?= \App::$Alias->scriptUrl ?>/vendor/phpffcms/ffcms-assets/node_modules/selectize/dist/css/selectize.default.css" />
19
<?php $this->stop() ?>
20
21
<?php $this->start('body') ?>
22
<h1><?= __('Settings') ?></h1>
23
24
<?php $form = $this->form($model) ?>
25
26
<?= $form->start() ?>
27
28
<?= $this->bootstrap()->nav('ul', ['class' => 'nav-tabs'])
29
    ->menu(['text' => __('Base'), 'tab' => function() use ($form) {
30
        return $form->fieldset()->text('baseDomain', ['class' => 'form-control'], __('Main domain of website. Use only in console or cron tasks, if domain cannot be defined from request string')) .
31
            $form->fieldset()->radio('baseProto', ['options' => ['http', 'https']], __('Main website transfer protocol. Use only if request data is not available in console or cron tasks')) .
32
            $form->fieldset()->text('basePath', ['class' => 'form-control'], __('FFCMS installation sub-directory, used if installed not in root. Example: /subdir/')) .
33
            $form->fieldset()->select('timezone', ['class' => 'selectize-select', 'options' => DateTimeZone::listIdentifiers()], __('Define website default timezone id')) .
34
            $form->fieldset()->boolean('userCron', null, __('Initialize cron manager when user load website? Enable this option if you are not configured cron tasks in your operation system')) .
35
            $form->fieldset()->boolean('debug.all', null, __('Enable debug bar panel for all visitors? Recommended only on development environment')) .
36
            $form->fieldset()->boolean('testSuite', null, __('Enable codeception test suite adapter? Use this option ONLY to run codeception tests! Disable this option on production'));
37
    }, 'tabActive' => true])
38
    ->menu(['text' => __('Themes'), 'tab' => function() use ($form, $model) {
39
        return $form->fieldset()->select('theme.Front', ['class' => 'form-control', 'options' => $model->getAvailableThemes('Front')], __('Set theme for user part of website')) .
40
            $form->fieldset()->select('theme.Admin', ['class' => 'form-control', 'options' => $model->getAvailableThemes('Admin')], __('Set theme for admin panel'));
41
    }])
42
    ->menu(['text' => __('Mail'), 'tab' => function() use ($form) {
43
        return '<p>' . __('Configure sendmail over smtp server. You should set host:port and auth data for your smtp server') . '</p>' .
44
            $form->fieldset()->boolean('mail.enable', ['options' => [0 => 'Disabled', 1 => 'Enabled'], 'optionsKey' => true], __('Is mailing features enabled?')) .
45
            $form->fieldset()->text('mail.host', ['class' => 'form-control'], __('Set SMTP hostname or ip')) .
46
            $form->fieldset()->text('mail.port', ['class' => 'form-control'], __('Set SMTP connection port')) .
47
            $form->fieldset()->select('mail.encrypt', ['class' => 'form-control', 'options' => ['tls', 'ssl', 'none']], __('Set encryption method for your smtp server. For remote service we are strongly recommend use tls/ssl encryption')) .
48
            $form->fieldset()->text('mail.user', ['class' => 'form-control'], __('Set auth user name if required')) .
49
            $form->fieldset()->text('mail.password', ['class' => 'form-control'], __('Set auth user password if exist'));
50
    }])
51
    ->menu(['text' => __('Localization'), 'tab' => function() use ($form) {
52
        return $form->fieldset()->select('singleLanguage', ['class' => 'form-control', 'options' => \App::$Translate->getAvailableLangs()], __('Default language of website')) .
53
            $form->fieldset()->boolean('multiLanguage', null, __('Must we use multi language system in site pathway')) .
54
            $form->fieldset()->text('baseLanguage', ['class' => 'form-control', 'disabled' => null], __('Website base script language. Do not change it')) .
55
            $form->fieldset()->checkboxes('languages', ['options' => App::$Translate->getAvailableLangs()], __('Website available languages'));
56
57
    }])
58
    ->menu(['text' => __('Database'), 'tab' => function() use ($form) {
59
        return '<p>' . __('Do not change any information in this tab if you not sure what you do!') . '</p>' .
60
            $form->fieldset()->select('database.driver', ['class' => 'form-control', 'options' => ['mysql', 'sqlite', 'pgsql']], __('Database connection driver')) .
61
            $form->fieldset()->text('database.host', ['class' => 'form-control'], __('Database connection host name')) .
62
            $form->fieldset()->text('database.database', ['class' => 'form-control'], __('Database name or path to sqlite created file database')) .
63
            $form->fieldset()->text('database.username', ['class' => 'form-control'], __('User name for database connection')) .
64
            $form->fieldset()->text('database.password', ['class' => 'form-control'], __('Password for user of database connection')) .
65
            $form->fieldset()->text('database.charset', ['class' => 'form-control']) .
66
            $form->fieldset()->text('database.collation', ['class' => 'form-control']) .
67
            $form->fieldset()->text('database.prefix', ['class' => 'form-control'], __('Database tables prefix'));
68
    }])
69
    ->menu(['text' => __('Debug'), 'tab' => function() use ($form){
70
        return '<p>' . __('The key-value of cookie to enable debugging on website') . '. ' . __('If user got this cookie he can see debug bar') . '. ' .
71
            Url::a(['main/debugcookie'], __('Set cookie for me')) . '</p>' .
72
            $form->fieldset()->text('debug.cookie.key', ['class' => 'form-control'], __('Set cookie name(key) for enable debug bar panel')) .
73
            $form->fieldset()->text('debug.cookie.value', ['class' => 'form-control'], __('Set cookie value for enable debug bar panel'));
74
    }])
75
    ->menu(['text' => __('Other'), 'tab' => function() use ($form){
76
        return $form->fieldset()->text('trustedProxy', ['class' => 'form-control'], __('Set trusted proxy list to accept X-FORWARDED data. Example: 103.21.244.15,103.22.200.0/22'));
77
    }])
78
    ->display(); ?>
79
80
<?= $form->button()->submit(__('Save'), ['class' => 'btn btn-primary']) ?>
81
82
<?= $form->stop() ?>
83
84
<?php $this->stop() ?>
85
86
<?php $this->push('javascript') ?>
87
<script src="<?= \App::$Alias->scriptUrl ?>/vendor/phpffcms/ffcms-assets/node_modules/selectize/dist/js/standalone/selectize.min.js"></script>
88
<script>
89
    $(document).ready(function(){
90
        $('.selectize-select').selectize({
91
            sortField: 'text'
92
        });
93
94
        var status = $('#formAdminConfig-mail-enable').is(':checked');
95
        if (status !== true) {
96
            $('#formAdminConfig-mail-host,#formAdminConfig-mail-port,#formAdminConfig-mail-encrypt,#formAdminConfig-mail-user,#formAdminConfig-mail-password').attr('disabled', 'disabled');
97
        }
98
99
        $('#formAdminConfig-mail-enable').change(function(){
100
            var chk = this.checked;
101
            if (!chk) {
102
                $('#formAdminConfig-mail-host,#formAdminConfig-mail-port,#formAdminConfig-mail-encrypt,#formAdminConfig-mail-user,#formAdminConfig-mail-password').attr('disabled', 'disabled');
103
            } else {
104
                $('#formAdminConfig-mail-host,#formAdminConfig-mail-port,#formAdminConfig-mail-encrypt,#formAdminConfig-mail-user,#formAdminConfig-mail-password').removeAttr('disabled');
105
            }
106
        })
107
    });
108
</script>
109
<?php $this->stop() ?>
110