diff --git a/common/modules/comment/views/manage/index.php b/common/modules/comment/views/manage/index.php index dcd3f50..ed09712 100755 --- a/common/modules/comment/views/manage/index.php +++ b/common/modules/comment/views/manage/index.php @@ -3,76 +3,95 @@ use yii\data\ActiveDataProvider; use yii\grid\GridView; use yii\helpers\Html; + use yii\helpers\StringHelper; + use yii\web\View; use yii\widgets\Pjax; /** * @var ActiveDataProvider $dataProvider * @var CommentModelSearch $searchModel * @var string $commentModel + * @var View $this */ + $statuses = [ - $searchModel::STATUS_ACTIVE => 'Активный', - $searchModel::STATUS_HIDDEN => 'Скрытый', + $searchModel::STATUS_ACTIVE => 'Активный', + $searchModel::STATUS_HIDDEN => 'Скрытый', $searchModel::STATUS_DELETED => 'Удаленный', ]; Pjax::begin(); - if(($success = \Yii::$app->session->getFlash('artbox_comment_success')) != null) { + if (( $success = \Yii::$app->session->getFlash('artbox_comment_success') ) != null) { echo Html::tag('p', $success); } - echo GridView::widget([ - 'dataProvider' => $dataProvider, - 'filterModel' => $searchModel, - 'columns' => [ - [ - 'class' => 'yii\grid\ActionColumn', - 'template' => '{update} {delete}', - ], - [ - 'attribute' => 'artbox_comment_id', - 'label' => 'Идентификатор', - ], - [ - 'attribute' => 'date_add', - 'format' => ['date', 'php:d.m.Y'], - 'filter' => false, - ], - 'text:text', - [ - 'attribute' => 'user_id', - 'value' => function($model) { - if(!empty($model->user_id)) { - 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' => 'rating_value', - 'label' => $searchModel->getAttributeLabel('rating_value'), - 'value' => function($model) { - if(!empty($model->rating)) { - return $model->rating->value; - } - return NULL; - } - ], - 'entity', - 'entity_id', - [ - 'attribute' => 'children_count', - 'label' => $searchModel->getAttributeLabel('children_count'), - 'value' => function($model) { - return count($model->children); - } + echo GridView::widget( + [ + 'dataProvider' => $dataProvider, + 'filterModel' => $searchModel, + 'columns' => [ + [ + 'class' => 'yii\grid\ActionColumn', + 'template' => '{update} {delete}', + ], + [ + 'attribute' => 'artbox_comment_id', + 'label' => 'Идентификатор', + ], + [ + 'attribute' => 'date_add', + 'format' => [ + 'date', + 'php:d.m.Y', + ], + 'filter' => false, + ], + [ + 'attribute' => 'text', + 'value' => function ($model) { + if (empty($model->text)) { + return ''; + } else { + return StringHelper::truncate($model->text, 25, '...'); + } + }, + 'format' => 'html', + ], + [ + 'attribute' => 'user_id', + 'value' => function ($model) { + if (!empty($model->user_id)) { + 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' => 'rating_value', + 'label' => $searchModel->getAttributeLabel('rating_value'), + 'value' => function ($model) { + if (!empty($model->rating)) { + return $model->rating->value; + } + return null; + }, + ], + // 'entity', + // 'entity_id', + [ + 'attribute' => 'children_count', + 'label' => $searchModel->getAttributeLabel('children_count'), + 'value' => function ($model) { + return count($model->children); + }, + ], ], - ], - ]); + ] + ); Pjax::end(); \ No newline at end of file -- libgit2 0.21.4