title = 'Комментарии'; $this->params[ 'breadcrumbs' ][] = $this->title; $statuses = [ $searchModel::STATUS_ACTIVE => 'Активный', $searchModel::STATUS_HIDDEN => 'Скрытый', $searchModel::STATUS_DELETED => 'Удаленный', ]; Pjax::begin(); if (( $success = \Yii::$app->session->getFlash('artbox_comment_success') ) != NULL) { echo Html::tag('p', $success); } 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) { if (!empty($model->user)) { 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); }, ], 'template' => \Yii::$app->user->identity->isAdmin() ? '{update} {answer} {delete}' : '{update} {answer}', ], ], ] ); Pjax::end();