index.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. use yii\grid\GridView;
  3. use yii\helpers\Html;
  4. /* @var $this yii\web\View */
  5. /* @var $dataProvider yii\data\ActiveDataProvider */
  6. $this->title = '评论';
  7. $this->params['breadcrumbs'][] = $this->title;
  8. ?>
  9. <style>
  10. .comment-index img{width:80px;height:80px;margin-right:10px;}
  11. </style>
  12. <div class="comment-index">
  13. <?= $this->render('_search', ['model' => $searchModel]) ?>
  14. <div class="box box-success">
  15. <div class="box-body">
  16. <?= GridView::widget([
  17. 'dataProvider' => $dataProvider,
  18. 'columns' => [
  19. 'id',
  20. [
  21. 'attribute' => 'user_id',
  22. 'value' => function($model) {
  23. return $model->user->username;
  24. }
  25. ],
  26. 'user_ip',
  27. [
  28. 'label' => '源',
  29. 'value' => function ($model) {
  30. return \common\helpers\Util::getEntityName($model->entity) . ':' . $model->entity_id;
  31. }
  32. ],
  33. [
  34. 'attribute' => 'content',
  35. 'options' => ['width' => '40%'],
  36. 'value' => function($model) {
  37. return \yii\helpers\Markdown::process($model->content);
  38. },
  39. 'format' => 'html'
  40. ],
  41. 'created_at:datetime',
  42. [
  43. 'class' => 'common\helpers\DiyActionColumn',
  44. 'template' => '{update} {delete} {ban}',
  45. 'buttons' => [
  46. 'ban' => function($url, $model, $key) {
  47. return Html::a(Html::icon('ban'),
  48. ['/user/admin/block', 'id' => $model->user_id],
  49. [
  50. 'class' => 'btn btn-default btn-xs',
  51. 'title' => '封禁用户',
  52. 'data-confirm' => '确定要封禁用户吗?',
  53. 'data-ajax' => '1',
  54. 'data-method' => 'post'
  55. ]
  56. );
  57. }
  58. ]
  59. ],
  60. ],
  61. ]); ?>
  62. </div>
  63. </div>
  64. </div>
  65. <?php $this->beginBlock('js') ?>
  66. <script>
  67. layer.ready(function () {
  68. layer.photos({
  69. photos:'.comment-index',
  70. shift:5
  71. });
  72. })
  73. </script>
  74. <?php $this->endBlock() ?>