1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
use yii\grid\GridView; |
4
|
|
|
use yii\helpers\Html; |
5
|
|
|
use yii\helpers\StringHelper; |
6
|
|
|
use yii\widgets\Pjax; |
7
|
|
|
use yii2mod\moderation\enums\Status; |
8
|
|
|
|
9
|
|
|
/* @var $this yii\web\View */ |
10
|
|
|
/* @var $dataProvider yii\data\ActiveDataProvider */ |
11
|
|
|
/* @var $searchModel \yii2mod\comments\models\search\CommentSearch */ |
12
|
|
|
/* @var $commentModel \yii2mod\comments\models\CommentModel */ |
13
|
|
|
|
14
|
|
|
$this->title = Yii::t('yii2mod.comments', 'Comments Management'); |
15
|
|
|
$this->params['breadcrumbs'][] = $this->title; |
16
|
|
|
?> |
17
|
|
|
<div class="comments-index"> |
18
|
|
|
|
19
|
|
|
<h1><?php echo Html::encode($this->title); ?></h1> |
20
|
|
|
<?php Pjax::begin(['timeout' => 10000]); ?> |
21
|
|
|
<?php echo GridView::widget([ |
22
|
|
|
'dataProvider' => $dataProvider, |
23
|
|
|
'filterModel' => $searchModel, |
24
|
|
|
'columns' => [ |
25
|
|
|
[ |
26
|
|
|
'attribute' => 'id', |
27
|
|
|
'contentOptions' => ['style' => 'max-width: 50px;'], |
28
|
|
|
], |
29
|
|
|
[ |
30
|
|
|
'attribute' => 'content', |
31
|
|
|
'contentOptions' => ['style' => 'max-width: 350px;'], |
32
|
|
|
'value' => function ($model) { |
33
|
|
|
return StringHelper::truncate($model->content, 100); |
34
|
|
|
}, |
35
|
|
|
], |
36
|
|
|
'attribute' => 'relatedTo', |
37
|
|
|
[ |
38
|
|
|
'attribute' => 'createdBy', |
39
|
|
|
'value' => function ($model) { |
40
|
|
|
return $model->getAuthorName(); |
41
|
|
|
}, |
42
|
|
|
'filter' => $commentModel::getAuthors(), |
43
|
|
|
'filterInputOptions' => ['prompt' => Yii::t('yii2mod.comments', 'Select Author'), 'class' => 'form-control'], |
44
|
|
|
], |
45
|
|
|
[ |
46
|
|
|
'attribute' => 'status', |
47
|
|
|
'value' => function ($model) { |
48
|
|
|
return Status::getLabel($model->status); |
49
|
|
|
}, |
50
|
|
|
'filter' => Status::listData(), |
51
|
|
|
'filterInputOptions' => ['prompt' => Yii::t('yii2mod.comments', 'Select Status'), 'class' => 'form-control'], |
52
|
|
|
], |
53
|
|
|
[ |
54
|
|
|
'attribute' => 'createdAt', |
55
|
|
|
'value' => function ($model) { |
56
|
|
|
return Yii::$app->formatter->asDatetime($model->createdAt); |
57
|
|
|
}, |
58
|
|
|
'filter' => false, |
59
|
|
|
], |
60
|
|
|
[ |
61
|
|
|
'header' => 'Actions', |
62
|
|
|
'class' => 'yii\grid\ActionColumn', |
63
|
|
|
'template' => '{view}{update}{delete}', |
64
|
|
|
'buttons' => [ |
65
|
|
|
'view' => function ($url, $model, $key) { |
|
|
|
|
66
|
|
|
$title = Yii::t('yii2mod.comments', 'View'); |
67
|
|
|
$options = [ |
68
|
|
|
'title' => $title, |
69
|
|
|
'aria-label' => $title, |
70
|
|
|
'data-pjax' => '0', |
71
|
|
|
'target' => '_blank', |
72
|
|
|
]; |
73
|
|
|
$icon = Html::tag('span', '', ['class' => 'glyphicon glyphicon-eye-open']); |
74
|
|
|
$url = $model->getViewUrl(); |
75
|
|
|
|
76
|
|
|
if (!empty($url)) { |
77
|
|
|
return Html::a($icon, $url, $options); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
return null; |
81
|
|
|
}, |
82
|
|
|
], |
83
|
|
|
], |
84
|
|
|
], |
85
|
|
|
]); |
86
|
|
|
?> |
87
|
|
|
<?php Pjax::end(); ?> |
88
|
|
|
</div> |
89
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.