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

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

Check for conflicting imported classes with local classes.

Bug Major
1
<?php
2
3
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...
4
5
/** @var \Ffcms\Templex\Template\Template $this */
6
/** @var \Apps\Model\Admin\Main\EntityUpdate $entityModel */
7
/** @var \Apps\Model\Admin\Main\FormUpdateDatabase $dbModel */
8
/** @var \Apps\Model\Admin\Main\FormUpdateDownload $downloadModel */
9
10
$this->layout('_layouts/default', [
11
    'title' => __('Updates'),
12
    'breadcrumbs' => [
13
        Url::to('main/index') => __('Main'),
14
        __('Updates')
15
    ]
16
]);
17
?>
18
19
<?php $this->start('body') ?>
20
<h1><?= __('Update manager') ?></h1>
21
<div class="table-responsive">
22
    <?= $this->table(['class' => 'table table-striped table-hover'])
23
        ->row([
24
            ['text' => __('Scripts version')],
25
            ['text' => $entityModel->scriptVersion],
26
            'properties' => ['class' => $entityModel->haveRemoteNew ? 'warning' : null]
27
        ])
28
        ->row([
29
            ['text' => __('Database version')],
30
            ['text' => $entityModel->dbVersion],
31
            'properties' => ['class' => !$entityModel->versionsEqual ? 'danger' : null]
32
        ])
33
        ->row([
34
            ['text' => __('Last version')],
35
            ['text' => $entityModel->lastVersion],
36
            'properties' => ['class' => $entityModel->haveRemoteNew ? 'success' : null]
37
        ])->display() ?>
38
</div>
39
<?php if (!$entityModel->versionsEqual): ?>
40
    <p class="alert alert-warning"><?= __('Seems like scripts and database of your website have different versions. You should do update right now or your website can working unstable') ?></p>
41
    <p><?= __('This updates for database will be applied:') ?></p>
42
    <?php
43
    $li = $this->listing('ul');
44
    foreach ($dbModel->updateQueries as $file) {
45
        $li->li(['text' => $file]);
46
    }
47
    echo $li->display();
48
49
    $form = $this->form($dbModel);
50
    echo $form->start();
51
    echo $form->button()->submit(__('Update database'), ['class' => 'btn btn-info']);
52
    echo $form->stop();
53
    ?>
54
<?php elseif ($entityModel->haveRemoteNew): ?>
55
    <p class="alert alert-warning"><?= __('The newest version: <b>%version%</b> with title &laquo;<em>%title%</em>&raquo; is available to update. You can start update right now', [
56
            'version' => $entityModel->lastVersion,
57
            'title' => $entityModel->lastInfo['name']
58
        ]) ?>
59
    </p>
60
    <?php
61
    $form = $this->form($downloadModel);
62
    echo $form->start();
63
    echo $form->button()->submit(__('Download update'), ['class' => 'btn btn-primary']);
64
    echo $form->stop();
65
    ?>
66
<?php else: ?>
67
    <p class="alert alert-success"><?= __('Your system is up to date. No updates is available') ?></p>
68
<?php endif; ?>
69
<?php $this->stop() ?>
70