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

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

Labels
1
<?php
2
3
use Ffcms\Core\Helper\Date;
4
use Ffcms\Core\Helper\Simplify;
5
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...
6
7
/** @var \Apps\ActiveRecord\CommentPost $record */
8
/** @var \Ffcms\Templex\Template\Template $this */
9
10
$this->layout('_layouts/default', [
11
    'title' => __('View comment'),
12
    'breadcrumbs' => [
13
        Url::to('main/index') => __('Main'),
14
        Url::to('widget/index') => __('Widgets'),
15
        Url::to('comments/index') => __('Comments'),
16
        __('View comment')
17
    ]
18
]);
19
?>
20
21
<?php $this->start('body') ?>
22
23
<?= $this->insert('comments/_tabs') ?>
24
25
<h1><?= __('Read comment #%id%', ['id' => $record->id]) ?></h1>
26
<div class="card">
27
    <div class="card-header">
28
        <?php
29
        $author = Simplify::parseUserNick($record->user_id, $record->guest_name);
30
        if ($record->user_id > 0) {
31
            $author = Url::a(['user/update', [$record->user_id]], $author);
32
        }
33
        ?>
34
        <?= $author . ', ' . Date::convertToDatetime($record->created_at, Date::FORMAT_TO_HOUR) ?>
35
        <div class="pull-right">
36
            <?php
37
            $btngrp = $this->bootstrap()->btngroup(['class' => 'btn-group btn-group-sm']);
38
            if ($record->moderate) {
39
                $btngrp->add('<i class="fa fa-eye"></i>', ['comments/publish', ['comment', $record->id]], ['class' => 'btn btn-success', 'html' => true]);
40
            }
41
            $btngrp->add('<i class="fa fa-pencil"></i>', ['comments/edit', ['comment', $record->id]], ['class' => 'btn btn-primary', 'html' => true]);
42
            $btngrp->add('<i class="fa fa-trash-o"></i>', ['comments/delete', ['comment', $record->id]], ['class' => 'btn btn-danger', 'html' => true]);
43
            echo $btngrp->display();
44
            ?>
45
        </div>
46
    </div>
47
    <div class="card-body<?= ((bool)$record->moderate ? ' text-warning' : null) ?>">
48
        <?= $record->message ?>
49
    </div>
50
</div>
51
<?php
52
/** @var \Apps\ActiveRecord\CommentAnswer[]|\Illuminate\Support\Collection $answers */
53
$answers = $record->answers;
54
if (!$answers || $answers->count() < 1) {
55
    $this->stop();
56
    return null;
57
}
58
?>
59
60
<h2><?= __('Comment answers') ?></h2>
61
<?php foreach ($answers as $answer):?>
62
    <div class="card" id="answer-<?= $answer->id ?>">
63
        <div class="card-header">
64
            <?php
65
            $answerAuthor = Simplify::parseUserLink($answer->user_id, $answer->guest_name, 'user/update');
66
            ?>
67
            <?= $answerAuthor . ', ' . Date::convertToDatetime($answer->created_at, Date::FORMAT_TO_HOUR) ?>
68
            <div class="pull-right">
69
                <?php
70
                $btngrp = $this->bootstrap()->btngroup(['class' => 'btn-group btn-group-sm']);
71
                if ($answer->moderate) {
72
                    $btngrp->add('<i class="fa fa-eye"></i>', ['comments/publish', ['answer', $answer->id]], ['class' => 'btn btn-success', 'html' => true]);
73
                }
74
                $btngrp->add('<i class="fa fa-pencil"></i>', ['comments/edit', ['answer', $answer->id]], ['class' => 'btn btn-primary', 'html' => true]);
75
                $btngrp->add('<i class="fa fa-trash-o"></i>', ['comments/delete', ['answer', $answer->id]], ['class' => 'btn btn-danger', 'html' => true]);
76
                echo $btngrp->display();
77
                ?>
78
            </div>
79
        </div>
80
        <div class="card-body<?= ((bool)$answer->moderate ? ' text-warning' : null)?>">
81
            <?= $answer->message ?>
82
        </div>
83
    </div>
84
<?php endforeach; ?>
85
86
<?php $this->stop() ?>
87