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

Apps/View/Front/default/content/my.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
6
/** @var \Ffcms\Templex\Template\Template $this */
7
/** @var \Apps\ActiveRecord\Content[] $records */
8
/** @var array $pagination */
9
10
$this->layout('_layouts/default', [
11
    'title' => __('My content'),
12
    'breadcrumbs' => [
13
        Url::to('/') => __('Home'),
14
        Url::to('content/index') => __('Contents'),
15
        __('My content')
16
    ]
17
]);
18
19
?>
20
<?php $this->start('body') ?>
21
<h1><?= __('My content')?></h1>
22
<hr />
23
<?php
24
if (!$records || $records->count() < 1) {
25
    $this->bootstrap()->alert('warning', __('Content is not found yet'));
26
    $this->stop();
27
    return;
28
}
29
?>
30
31
<p><?= __('Remember you can edit content only on moderate stage!') ?></p>
32
33
<?php
34
$table = $this->table(['class' => 'table'])
35
    ->head([
36
        ['text' => '#'],
37
        ['text' => __('Title')],
38
        ['text' => 'Published'],
39
        ['text' => __('Date')]
40
    ]);
41
42
foreach ($records as $record) {
43
    $moderate = !(bool)$record->display;
44
    $title = $record->getLocaled('title');
45
    if (!(bool)$record->display) {
46
        $title = Url::a(['content/update', [$record->id]], $title) . ' <i class="fa fa-pencil"></i>';
47
    }
48
49
    $table->row([
50
        ['text' => $record->id],
51
        ['text' => $title, 'html' => true],
52
        ['text' => $moderate ? __('No') : __('Yes'), 'properties' => ['class' => $moderate ? 'text-danger' : 'text-success']],
53
        ['text' => Date::convertToDatetime($record->created_at, Date::FORMAT_TO_HOUR)]
54
    ]);
55
}
56
?>
57
58
<div class="table-responsive">
59
    <?= $table->display() ?>
60
</div>
61
62
<?= $this->bootstrap()->pagination(['content/my'], ['class' => 'pagination justify-content-center'])
63
    ->size($pagination['total'], $pagination['page'], $pagination['step'])
64
    ->display(); ?>
65
66
<?= Url::a(['content/update'], __('Add content'), ['class' => 'btn btn-primary']) ?>
67
68
<?php $this->stop() ?>
69