index.php
3.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?php
use common\modules\comment\models\Comment;
use yii\helpers\Html;
use yii\grid\GridView;
use yii\helpers\Url;
/* @var $this yii\web\View */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Комменты';
$this->params[ 'breadcrumbs' ][] = $this->title;
?>
<div class="comment-index">
<h1><?= Html::encode($this->title) ?></h1>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
[
'class' => 'yii\grid\ActionColumn',
'template' => '{approve} {update} {delete}',
'buttons' => [
'approve' => function($url, $model, $key) {
/**
* @var Comment $model
*/
$options = array_merge([
'title' => "Подтвердить",
'aria-label' => "Подтвердить",
'data-confirm' => "Комментарий и оценка отобразится на публичной части сайта, подтвердить?",
'data-method' => 'post',
'data-pjax' => '0',
]);
$glyphicon = 'glyphicon-ok';
if($model->status == $model::STATUS_ACTIVE) {
$url = Url::to(['comment/disapprove', 'id' => $model->comment_id]);
$glyphicon = 'glyphicon-remove';
}
return Html::a('<span class="glyphicon '.$glyphicon.'"></span>', $url, $options);
}
]
],
'comment_id',
[
'attribute' => 'rating.value',
'label' => 'Оценка',
],
'text:ntext',
[
'content' => function($model) {
/**
* @var Comment $model
*/
if(!empty( $model->user )) {
return $model->user->username . " (ID: " . $model->user->id . ")";
} else {
return $model->user_name . " (Гость: " . $model->user_email . ")";
}
},
'label' => 'Пользователь',
],
[
'attribute' => 'status',
'value' => function($model) {
/**
* @var Comment $model
*/
$status = '';
switch($model->status) {
case Comment::STATUS_ACTIVE:
$status = 'Активный';
break;
case Comment::STATUS_HIDDEN:
$status = 'Новый';
break;
case Comment::STATUS_DELETED:
$status = 'Удаленный';
break;
default:
$status = 'Неизвестно';
};
return $status;
},
],
'date_add',
[
'attribute' => 'model',
'value' => function($model) {
/**
* @var Comment $model
*/
return $model->model . " (ID: " . $model->model_id . ")";
},
],
],
]); ?>
</div>