a2cde075
Yarik
first commit
|
1
|
<?php
|
1317fa68
Alexey Boroda
-Comments started
|
2
|
use artweb\artbox\comment\models\CommentModel;
|
a2cde075
Yarik
first commit
|
3
4
5
|
use artweb\artbox\comment\models\CommentModelSearch;
use yii\data\ActiveDataProvider;
use yii\grid\GridView;
|
a2cde075
Yarik
first commit
|
6
|
use yii\helpers\Html;
|
1317fa68
Alexey Boroda
-Comments started
|
7
|
use yii\helpers\StringHelper;
|
ce440bf9
Alexey Boroda
-Comments upgrade...
|
8
|
use yii\web\View;
|
a2cde075
Yarik
first commit
|
9
10
11
12
13
14
|
use yii\widgets\Pjax;
/**
* @var ActiveDataProvider $dataProvider
* @var CommentModelSearch $searchModel
* @var string $commentModel
|
ce440bf9
Alexey Boroda
-Comments upgrade...
|
15
|
* @var View $this
|
a2cde075
Yarik
first commit
|
16
|
*/
|
ce440bf9
Alexey Boroda
-Comments upgrade...
|
17
18
19
20
|
$this->title = 'Комментарии';
$this->params[ 'breadcrumbs' ][] = $this->title;
|
a2cde075
Yarik
first commit
|
21
22
23
24
25
26
|
$statuses = [
$searchModel::STATUS_ACTIVE => 'Активный',
$searchModel::STATUS_HIDDEN => 'Скрытый',
$searchModel::STATUS_DELETED => 'Удаленный',
];
Pjax::begin();
|
ce440bf9
Alexey Boroda
-Comments upgrade...
|
27
|
if (( $success = \Yii::$app->session->getFlash('artbox_comment_success') ) != NULL) {
|
a2cde075
Yarik
first commit
|
28
29
|
echo Html::tag('p', $success);
}
|
ce440bf9
Alexey Boroda
-Comments upgrade...
|
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
|
echo GridView::widget(
[
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
[
'attribute' => 'artbox_comment_id',
'label' => 'Id',
],
[
'label' => 'url',
'content' => function (CommentModel $model) {
return $model->getLink();
},
],
[
'label' => 'Ссылка',
],
[
'attribute' => 'created_at',
'format' => [
'date',
'php:d.m.Y',
],
'filter' => false,
],
[
'label' => 'Комментарий',
'content' => function(CommentModel $model) {
return StringHelper::truncate($model->text, 40, '...');
},
],
[
'attribute' => 'user_id',
'value' => function($model) {
|
2ac6a2f4
Yarik
Comments fix
|
65
|
if (!empty($model->user)) {
|
ce440bf9
Alexey Boroda
-Comments upgrade...
|
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
100
|
return $model->user->username . ' (id:' . $model->user->id . ')';
} else {
return $model->username . ' ' . $model->email . ' (Гость)';
}
},
],
[
'attribute' => 'status',
'filter' => $statuses,
'value' => function($model) use ($statuses) {
return $statuses[ $model->status ];
},
],
[
'attribute' => 'ratingValue',
'value' => function($model) {
if (!empty($model->rating)) {
return $model->rating->value;
}
return NULL;
},
],
[
'attribute' => 'childrenCount',
'value' => function($model) {
return count($model->children);
},
],
[
'class' => 'yii\grid\ActionColumn',
'buttons' => [
'answer' => function(string $url) {
return Html::a(Html::tag('i', '', [ 'class' => 'glyphicon glyphicon-bullhorn' ]), $url);
},
],
|
a86913e4
Alexey Boroda
-Remove delete co...
|
101
|
'template' => \Yii::$app->user->identity->isAdmin() ? '{update} {answer} {delete}' : '{update} {answer}',
|
a2cde075
Yarik
first commit
|
102
|
],
|
1317fa68
Alexey Boroda
-Comments started
|
103
|
],
|
ce440bf9
Alexey Boroda
-Comments upgrade...
|
104
105
|
]
);
|
a2cde075
Yarik
first commit
|
106
|
Pjax::end();
|