index.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. use manager\models\Comments;
  3. use yii\helpers\Html;
  4. use yii\helpers\Url;
  5. use yii\grid\ActionColumn;
  6. use yii\grid\GridView;
  7. /** @var yii\web\View $this */
  8. /** @var yii\data\ActiveDataProvider $dataProvider */
  9. $this->title = 'Comments';
  10. $this->params['breadcrumbs'][] = $this->title;
  11. ?>
  12. <div class="comments-index">
  13. <h1><?= Html::encode($this->title) ?></h1>
  14. <p>
  15. <?= Html::a('Create Comments', ['create'], ['class' => 'btn btn-success']) ?>
  16. </p>
  17. <?php \yii\widgets\Pjax::begin([
  18. 'timeout'=>5000,
  19. 'enablePushState'=>false
  20. ])?>
  21. <?= GridView::widget([
  22. 'dataProvider' => $dataProvider,
  23. 'layout' => "{errors}\n{summary}\n{pager}\n{items}\n{pager}",
  24. 'pager' => [
  25. 'prevPageCssClass' => 'page-item',
  26. 'firstPageLabel' => 'Начало',
  27. 'lastPageLabel' => 'Конец',
  28. 'linkOptions' => [ 'class'=>'page-link'],
  29. 'pageCssClass' => 'page-item',
  30. 'disabledListItemSubTagOptions' => ['tag' => 'a', 'class' => 'page-link'],
  31. ],
  32. 'columns' => [
  33. 'created_at',
  34. ['label'=>"Новость","format"=>"raw","value"=>fn($model)=>isset( $model->post->title )?Html::a($model->post->title,$model->post->getUrl(),["target"=>"_blank"]).Html::a("&nbsp;&nbsp;&nbsp;<i class='fas fa-edit'></i>",['/manager/news/update','id'=>$model->post->id],['target'=>"_blank"]):''],
  35. 'message:ntext',
  36. 'fakename',
  37. ['label'=>"Модерация","format"=>"raw","value"=>function($model){
  38. /**
  39. * @var $model Comments
  40. */
  41. $moderate_button_class = $model->visible=="Y"?"btn-danger":"btn-success";
  42. return Html::a($model->visible=="Y"?"Скрыть":"Пропустить",['/manager/comments/toggle',"id"=>$model->id,"value"=>$model->visible=="Y"?"N":"Y"],['class'=>"btn {$moderate_button_class}"]);
  43. }],
  44. [
  45. 'class' => ActionColumn::className(),
  46. 'urlCreator' => function ($action, Comments $model, $key, $index, $column) {
  47. return Url::toRoute([$action, 'id' => $model->id]);
  48. }
  49. ],
  50. ],
  51. ]); ?>
  52. <?php \yii\widgets\Pjax::end()?>
  53. </div>