12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- <?php
- use manager\models\Comments;
- use yii\helpers\Html;
- use yii\helpers\Url;
- use yii\grid\ActionColumn;
- use yii\grid\GridView;
- /** @var yii\web\View $this */
- /** @var yii\data\ActiveDataProvider $dataProvider */
- $this->title = 'Comments';
- $this->params['breadcrumbs'][] = $this->title;
- ?>
- <div class="comments-index">
- <h1><?= Html::encode($this->title) ?></h1>
- <p>
- <?= Html::a('Create Comments', ['create'], ['class' => 'btn btn-success']) ?>
- </p>
- <?php \yii\widgets\Pjax::begin([
- 'timeout'=>5000,
- 'enablePushState'=>false
- ])?>
- <?= GridView::widget([
- 'dataProvider' => $dataProvider,
- 'layout' => "{errors}\n{summary}\n{pager}\n{items}\n{pager}",
- 'pager' => [
- 'prevPageCssClass' => 'page-item',
- 'firstPageLabel' => 'Начало',
- 'lastPageLabel' => 'Конец',
- 'linkOptions' => [ 'class'=>'page-link'],
- 'pageCssClass' => 'page-item',
- 'disabledListItemSubTagOptions' => ['tag' => 'a', 'class' => 'page-link'],
- ],
- 'columns' => [
- 'created_at',
- ['label'=>"Новость","format"=>"raw","value"=>fn($model)=>isset( $model->post->title )?Html::a($model->post->title,$model->post->getUrl(),["target"=>"_blank"]).Html::a(" <i class='fas fa-edit'></i>",['/manager/news/update','id'=>$model->post->id],['target'=>"_blank"]):''],
- 'message:ntext',
- 'fakename',
- ['label'=>"Модерация","format"=>"raw","value"=>function($model){
- /**
- * @var $model Comments
- */
- $moderate_button_class = $model->visible=="Y"?"btn-danger":"btn-success";
- return Html::a($model->visible=="Y"?"Скрыть":"Пропустить",['/manager/comments/toggle',"id"=>$model->id,"value"=>$model->visible=="Y"?"N":"Y"],['class'=>"btn {$moderate_button_class}"]);
- }],
- [
- 'class' => ActionColumn::className(),
- 'urlCreator' => function ($action, Comments $model, $key, $index, $column) {
- return Url::toRoute([$action, 'id' => $model->id]);
- }
- ],
- ],
- ]); ?>
- <?php \yii\widgets\Pjax::end()?>
- </div>
|