/common/comment/views/default/index.php

https://gitlab.com/joepa37/ierschool.dev · PHP · 131 lines · 113 code · 12 blank · 6 comment · 0 complexity · fbefed7f1c193d75bdbf6cb8208e720a MD5 · raw file

  1. <?php
  2. use common\grid\columns\DateRangePicker\DateRangePicker;
  3. use common\comments\Comments;
  4. use common\comments\models\Comment;
  5. use common\grid\GridPageSize;
  6. use common\grid\GridQuickLinks;
  7. use common\grid\GridView;
  8. use yii\helpers\Html;
  9. use yii\helpers\Url;
  10. use yii\widgets\Pjax;
  11. /* @var $this yii\web\View */
  12. /* @var $searchModel common\comment\models\search\CommentSearch */
  13. /* @var $dataProvider yii\data\ActiveDataProvider */
  14. $this->title = Comments::t('comments', 'Comments');
  15. $this->params['breadcrumbs'][] = $this->title;
  16. ?>
  17. <div class="comment-index">
  18. <div class="box box-primary">
  19. <div class="panel-body">
  20. <?php
  21. Pjax::begin([
  22. 'id' => 'comment-grid-pjax',
  23. ])
  24. ?>
  25. <div class="row">
  26. <div class="col-sm-6">
  27. <?php
  28. echo GridQuickLinks::widget([
  29. 'model' => Comment::className(),
  30. 'searchModel' => $searchModel,
  31. 'options' => [
  32. ['label' => Yii::t('core', 'All'), 'filterWhere' => []],
  33. ['label' => Yii::t('core', 'Approved'), 'filterWhere' => ['status' => Comment::STATUS_APPROVED]],
  34. ['label' => Yii::t('core', 'Pending'), 'filterWhere' => ['status' => Comment::STATUS_PENDING]],
  35. ['label' => Yii::t('core', 'Spam'), 'filterWhere' => ['status' => Comment::STATUS_SPAM]],
  36. ['label' => Yii::t('core', 'Trash'), 'filterWhere' => ['status' => Comment::STATUS_TRASH]],
  37. ]
  38. ])
  39. ?>
  40. </div>
  41. <div class="col-sm-6 text-right">
  42. <?= GridPageSize::widget(['pjaxId' => 'comment-grid-pjax']) ?>
  43. </div>
  44. </div>
  45. <?=
  46. GridView::widget([
  47. 'id' => 'comment-grid',
  48. 'dataProvider' => $dataProvider,
  49. 'filterModel' => $searchModel,
  50. 'bulkActionOptions' => [
  51. 'gridId' => 'comment-grid',
  52. 'actions' => [
  53. Url::to(['bulk-activate']) => Comments::t('comments', 'Approve'),
  54. Url::to(['bulk-deactivate']) => Comments::t('comments', 'Unapprove'),
  55. Url::to(['bulk-spam']) => Comments::t('comments', 'Mark as Spam'),
  56. Url::to(['bulk-trash']) => Comments::t('comments', 'Move to Trash'),
  57. Url::to(['bulk-delete']) => Yii::t('core', 'Delete'),
  58. ]
  59. ],
  60. 'columns' => [
  61. ['class' => 'common\grid\CheckboxColumn', 'options' => ['style' => 'width:10px']],
  62. [
  63. 'class' => 'common\grid\columns\TitleActionColumn',
  64. 'controller' => '/comment/default',
  65. 'attribute' => 'content',
  66. 'title' => function (Comment $model) {
  67. return Html::a(mb_substr($model->content, 0, 32) . '...',
  68. ['/comment/default/update', 'id' => $model->id], ['data-pjax' => 0]);
  69. },
  70. 'buttonsTemplate' => '{update} {delete}',
  71. ],
  72. [
  73. 'label' => Yii::t('core', 'User'),
  74. 'value' => function (Comment $model) {
  75. return $model->getAuthor();
  76. },
  77. 'options' => ['style' => 'width:150px'],
  78. ],
  79. [
  80. 'attribute' => 'model',
  81. 'value' => function (Comment $model) {
  82. return $model->model . (($model->model_id) ? ' [' . $model->model_id . ']'
  83. : '');
  84. },
  85. 'options' => ['style' => 'width:120px'],
  86. ],
  87. // 'email:email',
  88. // 'parent_id',
  89. [
  90. 'class' => 'common\grid\columns\StatusColumn',
  91. 'attribute' => 'status',
  92. 'optionsArray' => Comment::getStatusOptionsList(),
  93. 'options' => ['style' => 'width:100px'],
  94. ],
  95. [
  96. 'attribute' => 'created_at',
  97. 'value' => function ($model) {
  98. return $model->createdDatetime;
  99. },
  100. 'options' => ['style' => 'width:150px'],
  101. ],
  102. // 'updated_at',
  103. [
  104. 'attribute' => 'user_ip',
  105. 'options' => ['style' => 'width:100px'],
  106. ],
  107. ],
  108. ]);
  109. ?>
  110. <?php Pjax::end() ?>
  111. </div>
  112. </div>
  113. </div>
  114. <?php
  115. DateRangePicker::widget([
  116. 'model' => $searchModel,
  117. 'attribute' => 'created_at',
  118. ])
  119. ?>