Commit d39ab828c01ea0fce27d2c3977330f1832a59b45
1 parent
563a6d54
-Comments view fixed
Showing
1 changed file
with
77 additions
and
58 deletions
Show diff stats
common/modules/comment/views/manage/index.php
@@ -3,76 +3,95 @@ | @@ -3,76 +3,95 @@ | ||
3 | use yii\data\ActiveDataProvider; | 3 | use yii\data\ActiveDataProvider; |
4 | use yii\grid\GridView; | 4 | use yii\grid\GridView; |
5 | use yii\helpers\Html; | 5 | use yii\helpers\Html; |
6 | + use yii\helpers\StringHelper; | ||
7 | + use yii\web\View; | ||
6 | use yii\widgets\Pjax; | 8 | use yii\widgets\Pjax; |
7 | 9 | ||
8 | /** | 10 | /** |
9 | * @var ActiveDataProvider $dataProvider | 11 | * @var ActiveDataProvider $dataProvider |
10 | * @var CommentModelSearch $searchModel | 12 | * @var CommentModelSearch $searchModel |
11 | * @var string $commentModel | 13 | * @var string $commentModel |
14 | + * @var View $this | ||
12 | */ | 15 | */ |
16 | + | ||
13 | $statuses = [ | 17 | $statuses = [ |
14 | - $searchModel::STATUS_ACTIVE => 'Активный', | ||
15 | - $searchModel::STATUS_HIDDEN => 'Скрытый', | 18 | + $searchModel::STATUS_ACTIVE => 'Активный', |
19 | + $searchModel::STATUS_HIDDEN => 'Скрытый', | ||
16 | $searchModel::STATUS_DELETED => 'Удаленный', | 20 | $searchModel::STATUS_DELETED => 'Удаленный', |
17 | ]; | 21 | ]; |
18 | Pjax::begin(); | 22 | Pjax::begin(); |
19 | - if(($success = \Yii::$app->session->getFlash('artbox_comment_success')) != null) { | 23 | + if (( $success = \Yii::$app->session->getFlash('artbox_comment_success') ) != null) { |
20 | echo Html::tag('p', $success); | 24 | echo Html::tag('p', $success); |
21 | } | 25 | } |
22 | - echo GridView::widget([ | ||
23 | - 'dataProvider' => $dataProvider, | ||
24 | - 'filterModel' => $searchModel, | ||
25 | - 'columns' => [ | ||
26 | - [ | ||
27 | - 'class' => 'yii\grid\ActionColumn', | ||
28 | - 'template' => '{update} {delete}', | ||
29 | - ], | ||
30 | - [ | ||
31 | - 'attribute' => 'artbox_comment_id', | ||
32 | - 'label' => 'Идентификатор', | ||
33 | - ], | ||
34 | - [ | ||
35 | - 'attribute' => 'date_add', | ||
36 | - 'format' => ['date', 'php:d.m.Y'], | ||
37 | - 'filter' => false, | ||
38 | - ], | ||
39 | - 'text:text', | ||
40 | - [ | ||
41 | - 'attribute' => 'user_id', | ||
42 | - 'value' => function($model) { | ||
43 | - if(!empty($model->user_id)) { | ||
44 | - return $model->user->username . ' (id:' . $model->user->id . ')'; | ||
45 | - } else { | ||
46 | - return $model->username.' '.$model->email.' (Гость)'; | ||
47 | - } | ||
48 | - } | ||
49 | - ], | ||
50 | - [ | ||
51 | - 'attribute' => 'status', | ||
52 | - 'filter' => $statuses, | ||
53 | - 'value' => function($model) use($statuses) { | ||
54 | - return $statuses[$model->status]; | ||
55 | - } | ||
56 | - ], | ||
57 | - [ | ||
58 | - 'attribute' => 'rating_value', | ||
59 | - 'label' => $searchModel->getAttributeLabel('rating_value'), | ||
60 | - 'value' => function($model) { | ||
61 | - if(!empty($model->rating)) { | ||
62 | - return $model->rating->value; | ||
63 | - } | ||
64 | - return NULL; | ||
65 | - } | ||
66 | - ], | ||
67 | - 'entity', | ||
68 | - 'entity_id', | ||
69 | - [ | ||
70 | - 'attribute' => 'children_count', | ||
71 | - 'label' => $searchModel->getAttributeLabel('children_count'), | ||
72 | - 'value' => function($model) { | ||
73 | - return count($model->children); | ||
74 | - } | 26 | + echo GridView::widget( |
27 | + [ | ||
28 | + 'dataProvider' => $dataProvider, | ||
29 | + 'filterModel' => $searchModel, | ||
30 | + 'columns' => [ | ||
31 | + [ | ||
32 | + 'class' => 'yii\grid\ActionColumn', | ||
33 | + 'template' => '{update} {delete}', | ||
34 | + ], | ||
35 | + [ | ||
36 | + 'attribute' => 'artbox_comment_id', | ||
37 | + 'label' => 'Идентификатор', | ||
38 | + ], | ||
39 | + [ | ||
40 | + 'attribute' => 'date_add', | ||
41 | + 'format' => [ | ||
42 | + 'date', | ||
43 | + 'php:d.m.Y', | ||
44 | + ], | ||
45 | + 'filter' => false, | ||
46 | + ], | ||
47 | + [ | ||
48 | + 'attribute' => 'text', | ||
49 | + 'value' => function ($model) { | ||
50 | + if (empty($model->text)) { | ||
51 | + return ''; | ||
52 | + } else { | ||
53 | + return StringHelper::truncate($model->text, 25, '...'); | ||
54 | + } | ||
55 | + }, | ||
56 | + 'format' => 'html', | ||
57 | + ], | ||
58 | + [ | ||
59 | + 'attribute' => 'user_id', | ||
60 | + 'value' => function ($model) { | ||
61 | + if (!empty($model->user_id)) { | ||
62 | + return $model->user->username . ' (id:' . $model->user->id . ')'; | ||
63 | + } else { | ||
64 | + return $model->username . ' ' . $model->email . ' (Гость)'; | ||
65 | + } | ||
66 | + }, | ||
67 | + ], | ||
68 | + [ | ||
69 | + 'attribute' => 'status', | ||
70 | + 'filter' => $statuses, | ||
71 | + 'value' => function ($model) use ($statuses) { | ||
72 | + return $statuses[ $model->status ]; | ||
73 | + }, | ||
74 | + ], | ||
75 | + [ | ||
76 | + 'attribute' => 'rating_value', | ||
77 | + 'label' => $searchModel->getAttributeLabel('rating_value'), | ||
78 | + 'value' => function ($model) { | ||
79 | + if (!empty($model->rating)) { | ||
80 | + return $model->rating->value; | ||
81 | + } | ||
82 | + return null; | ||
83 | + }, | ||
84 | + ], | ||
85 | + // 'entity', | ||
86 | + // 'entity_id', | ||
87 | + [ | ||
88 | + 'attribute' => 'children_count', | ||
89 | + 'label' => $searchModel->getAttributeLabel('children_count'), | ||
90 | + 'value' => function ($model) { | ||
91 | + return count($model->children); | ||
92 | + }, | ||
93 | + ], | ||
75 | ], | 94 | ], |
76 | - ], | ||
77 | - ]); | 95 | + ] |
96 | + ); | ||
78 | Pjax::end(); | 97 | Pjax::end(); |
79 | \ No newline at end of file | 98 | \ No newline at end of file |