Blame view

common/modules/comment/views/manage/index.php 2.55 KB
d8c1a2e0   Yarik   Big commit artbox
1
2
3
4
5
6
7
8
9
10
11
12
13
  <?php
      use common\modules\comment\models\CommentModelSearch;
      use yii\data\ActiveDataProvider;
      use yii\grid\GridView;
      use yii\helpers\Html;
      use yii\widgets\Pjax;
      
      /**
       * @var ActiveDataProvider $dataProvider
       * @var CommentModelSearch $searchModel
       * @var string             $commentModel
       */
      $statuses = [
5c2eb7c8   Yarik   Big commit almost...
14
15
          $searchModel::STATUS_ACTIVE  => 'Активный',
          $searchModel::STATUS_HIDDEN  => 'Скрытый',
d8c1a2e0   Yarik   Big commit artbox
16
17
18
          $searchModel::STATUS_DELETED => 'Удаленный',
      ];
      Pjax::begin();
5c2eb7c8   Yarik   Big commit almost...
19
      if(( $success = \Yii::$app->session->getFlash('artbox_comment_success') ) != NULL) {
d8c1a2e0   Yarik   Big commit artbox
20
21
22
23
          echo Html::tag('p', $success);
      }
      echo GridView::widget([
          'dataProvider' => $dataProvider,
5c2eb7c8   Yarik   Big commit almost...
24
25
          'filterModel'  => $searchModel,
          'columns'      => [
d8c1a2e0   Yarik   Big commit artbox
26
              [
5c2eb7c8   Yarik   Big commit almost...
27
                  'class'    => 'yii\grid\ActionColumn',
d8c1a2e0   Yarik   Big commit artbox
28
29
30
31
                  'template' => '{update} {delete}',
              ],
              [
                  'attribute' => 'artbox_comment_id',
5c2eb7c8   Yarik   Big commit almost...
32
                  'label'     => 'Идентификатор',
d8c1a2e0   Yarik   Big commit artbox
33
34
              ],
              [
8af13427   Yarik   For leha commit.
35
                  'attribute' => 'created_at',
5c2eb7c8   Yarik   Big commit almost...
36
37
38
39
40
                  'format'    => [
                      'date',
                      'php:d.m.Y',
                  ],
                  'filter'    => false,
d8c1a2e0   Yarik   Big commit artbox
41
42
43
44
              ],
              'text:text',
              [
                  'attribute' => 'user_id',
5c2eb7c8   Yarik   Big commit almost...
45
46
                  'value'     => function($model) {
                      if(!empty( $model->user_id )) {
d8c1a2e0   Yarik   Big commit artbox
47
48
                          return $model->user->username . ' (id:' . $model->user->id . ')';
                      } else {
5c2eb7c8   Yarik   Big commit almost...
49
                          return $model->username . ' ' . $model->email . ' (Гость)';
d8c1a2e0   Yarik   Big commit artbox
50
                      }
5c2eb7c8   Yarik   Big commit almost...
51
                  },
d8c1a2e0   Yarik   Big commit artbox
52
53
54
              ],
              [
                  'attribute' => 'status',
5c2eb7c8   Yarik   Big commit almost...
55
56
57
58
                  'filter'    => $statuses,
                  'value'     => function($model) use ($statuses) {
                      return $statuses[ $model->status ];
                  },
d8c1a2e0   Yarik   Big commit artbox
59
60
              ],
              [
8af13427   Yarik   For leha commit.
61
                  'attribute' => 'ratingValue',
5c2eb7c8   Yarik   Big commit almost...
62
63
                  'value'     => function($model) {
                      if(!empty( $model->rating )) {
d8c1a2e0   Yarik   Big commit artbox
64
65
66
                          return $model->rating->value;
                      }
                      return NULL;
5c2eb7c8   Yarik   Big commit almost...
67
                  },
d8c1a2e0   Yarik   Big commit artbox
68
69
70
71
              ],
              'entity',
              'entity_id',
              [
8af13427   Yarik   For leha commit.
72
                  'attribute' => 'childrenCount',
5c2eb7c8   Yarik   Big commit almost...
73
                  'value'     => function($model) {
d8c1a2e0   Yarik   Big commit artbox
74
                      return count($model->children);
5c2eb7c8   Yarik   Big commit almost...
75
                  },
d8c1a2e0   Yarik   Big commit artbox
76
77
78
79
              ],
          ],
      ]);
      Pjax::end();