index.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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 = 'Список комментариев';
  10. $this->params['breadcrumbs'][] = $this->title;
  11. ?>
  12. <div class="comments-index">
  13. <?php \yii\widgets\Pjax::begin([
  14. 'timeout'=>5000,
  15. 'enablePushState'=>false
  16. ])?>
  17. <?= GridView::widget([
  18. 'dataProvider' => $dataProvider,
  19. 'layout' => "{errors}\n{summary}\n{pager}\n{items}\n{pager}",
  20. 'pager' => [
  21. 'prevPageCssClass' => 'page-item',
  22. 'firstPageLabel' => 'Начало',
  23. 'lastPageLabel' => 'Конец',
  24. 'linkOptions' => [ 'class'=>'page-link'],
  25. 'pageCssClass' => 'page-item',
  26. 'disabledListItemSubTagOptions' => ['tag' => 'a', 'class' => 'page-link'],
  27. ],
  28. 'columns' => [
  29. 'created_at',
  30. ['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"]):''],
  31. 'message:ntext',
  32. 'fakename',
  33. ['label'=>"Модерация","format"=>"raw","value"=>function($model){
  34. /**
  35. * @var $model Comments
  36. */
  37. $moderate_button_class = $model->visible=="Y"?"btn-danger":"btn-success";
  38. return Html::a($model->visible=="Y"?"Скрыть":"Пропустить",['/manager/comments/toggle',"id"=>$model->id,"value"=>$model->visible=="Y"?"N":"Y"],['class'=>"btn {$moderate_button_class}"]);
  39. }],
  40. [
  41. 'class' => ActionColumn::className(),
  42. 'template' => '{view}{update}{filter}{delete}',
  43. 'urlCreator' => function ($action, Comments $model, $key, $index, $column) {
  44. return Url::toRoute([$action, 'id' => $model->id]);
  45. },
  46. 'buttons' =>
  47. [
  48. 'filter' => function ($url, $model, $key) {
  49. return Html::a("<i class='fas fa-filter'></i>", $url, ['class' => 'btn btn-default btn-sm', 'title' => 'Фильтр на основе коментария']);
  50. },
  51. ],
  52. 'buttonOptions' => ['class' => 'btn btn-default btn-sm'],
  53. 'contentOptions'=>['style'=>'min-width: 180px;'],
  54. 'options' =>
  55. [
  56. 'class' => 'nowrap',
  57. ],
  58. ],
  59. ],
  60. ]); ?>
  61. <?php \yii\widgets\Pjax::end()?>
  62. </div>