Passed
Push — master ( ef8807...c1ca83 )
by Mihail
05:17
created

Apps/View/Admin/default/content/publish.php (1 issue)

Labels
Severity
1
<?php
2
3
use Ffcms\Core\Helper\Date;
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
use Ffcms\Core\Helper\Simplify;
6
7
/** @var \Apps\ActiveRecord\Content[]|\Illuminate\Support\Collection $records */
8
/** @var \Ffcms\Templex\Template\Template $this */
9
/** @var \Apps\Model\Admin\Content\FormContentPublish $model */
10
11
$this->layout('_layouts/default', [
12
    'title' => __('Content publish'),
13
    'breadcrumbs' => [
14
        Url::to('main/index') => __('Main'),
15
        Url::to('application/index') => __('Applications'),
16
        Url::to('content/index') => __('Contents'),
17
        __('Content publish')
18
    ]
19
]);
20
?>
21
22
<?php $this->start('body') ?>
23
24
<?= $this->insert('content/_tabs') ?>
25
26
<h1><?= __('Content publish') ?></h1>
27
<p><?= __('Are you sure to make this item public?') ?></p>
28
<?php
29
$table = $this->table(['class' => 'table table-striped'])
30
    ->head([
31
        ['text' => '#'],
32
        ['text' => __('Title')],
33
        ['text' => __('Author')],
34
        ['text' => __('Date')]
35
    ]);
36
37
foreach ($records as $record) {
38
    $table->row([
39
        ['text' => $record->id],
40
        ['text' => $record->getLocaled('title')],
41
        ['text' => Simplify::parseUserLink($record->author_id), 'html' => true],
42
        ['text' => Date::convertToDatetime($record->created_at, Date::FORMAT_TO_HOUR)]
43
    ]);
44
}
45
?>
46
47
<div class="table-responsive">
48
    <?= $table->display() ?>
49
</div>
50
51
<?php $form = $this->form($model) ?>
52
<?= $form->start() ?>
53
54
<?= $form->button()->submit(__('Publish'), ['class' => 'btn btn-primary']) ?>
55
<?= $form->button()->cancel(__('Cancel'), ['class' => 'btn btn-secondary', 'link' => ['content/index']]) ?>
56
57
<?= $form->stop() ?>
58
59
<?php $this->stop() ?>