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

Apps/View/Admin/default/comments/index.php (1 issue)

Labels
1
<?php
2
3
use Ffcms\Core\Helper\Date;
4
use Ffcms\Core\Helper\Simplify;
5
use Ffcms\Core\Helper\Text;
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
/** @var \Ffcms\Templex\Template\Template $this */
9
/** @var \Apps\ActiveRecord\CommentPost[]|\Illuminate\Support\Collection $records */
10
/** @var array $pagination */
11
12
$this->layout('_layouts/default', [
13
    'title' => __('Comments list'),
14
    'breadcrumbs' => [
15
        Url::to('main/index') => __('Main'),
16
        Url::to('widget/index') => __('Widgets'),
17
        __('Comments')
18
    ]
19
]);
20
?>
21
22
<?php $this->start('body') ?>
23
24
<?= $this->insert('comments/_tabs'); ?>
25
26
<h1><?= __('Comments list') ?></h1>
27
28
<?php
29
if (!$records || $records->count() < 1) {
30
    echo $this->bootstrap()->alert('warning', __('Comments is not founded'));
31
    $this->stop();
32
    return;
33
}
34
$items = [];
35
$moderateIsFound = false;
36
$table = $this->table(['class' => 'table table-striped'])
37
    ->head([
38
        ['text' => '#'],
39
        ['text' => __('Comment')],
40
        ['text' => __('Answers')],
41
        ['text' => __('Author')],
42
        ['text' => __('Page')],
43
        ['text' => __('Date')],
44
        ['text' => __('Actions')],
45
    ]);
46
47
foreach ($records as $item) {
48
    $message = Text::cut(\App::$Security->strip_tags($item->message), 0, 75);
49
50
    $moderate = (bool)$item->moderate;
51
    // if even one moderate item is found - change global flag to true
52
    if ($moderate) {
53
        $moderateIsFound = true;
54
    }
55
56
    $btngrp = $this->bootstrap()->btngroup(['class' => 'btn-group btn-group-sm']);
57
58
    if ($moderate) {
59
        $btngrp->add('<i class="fa fa-eye-slash" style="color: #aa2222;"></i>', ['comments/display', ['comment', $item->id]], ['class' => 'btn btn-light', 'data-toggle' => 'tooltip', 'title' => __('Comment is hidden'), 'html' => true]);
60
    } else {
61
        $btngrp->add('<i class="fa fa-eye" style="color: #1a8007"></i>', ['comments/display', ['comment', $item->id]], ['class' => 'btn btn-light', 'data-toggle' => 'tooltip', 'title' => __('Comment is public'), 'html' => true]);
62
    }
63
64
    $btngrp->add('<i class="fa fa-list"></i>', ['comments/read', [$item->id]], ['class' => 'btn btn-primary', 'html' => true])
65
        ->add('<i class="fa fa-trash-o"></i>', ['comments/delete', ['comment', $item->id]], ['class' => 'btn btn-danger', 'html' => true]);
66
67
    $table->row([
68
        ['text' => $item->id],
69
        ['text' => Url::a(['comments/read', [$item->id]], $message), 'html' => true],
70
        ['text' => '<span class="badge badge-light">' . $item->getAnswerCount() . '</span>', 'html' => true],
71
        ['text' => Simplify::parseUserLink((int)$item->user_id, $item->guest_name, 'user/update'), 'html' => true],
72
        ['text' => '<a href="'.Url::stringUrl($item->app_name . '/comments/' . $item->app_relation_id).'" target="_blank">' . $item->app_name . '/' . $item->app_relation_id . '</a>', 'html' => true],
73
        ['text' => Date::convertToDatetime($item->created_at, Date::FORMAT_TO_HOUR)],
74
        ['text' => $btngrp->display(), 'html' => true
75
        ],
76
        'properties' => ['class' => 'checbox-row']
77
    ]);
78
}
79
80
$table->selectize(0, 'selected');
81
?>
82
83
<div class="table-responsive">
84
    <?= $table->display() ?>
85
</div>
86
87
<?= $this->javascript()->submitSelectizeTable('input[name="selected[]"]', 'selected', __('Delete selected'), ['comments/delete', ['comment']], ['class' => 'btn btn-danger']) ?>
88
<?php if ($moderateIsFound) {
89
    echo $this->javascript()->submitSelectizeTable('input[name="selected[]"]', 'selected', __('Publish'), ['comments/publish', ['comment']], ['class' => 'btn btn-warning']);
90
} ?>
91
92
<?= $this->bootstrap()->pagination($pagination['url'], ['class' => 'pagination justify-content-center'])
93
    ->size($pagination['total'], $pagination['page'], $pagination['step'])
94
    ->display(); ?>
95
96
97
<?php $this->stop() ?>