Blame view

common/modules/comment/views/manage/index.php 3.47 KB
4253cbec   root   first commit
1
2
3
4
5
  <?php
      use common\modules\comment\models\CommentModelSearch;
      use yii\data\ActiveDataProvider;
      use yii\grid\GridView;
      use yii\helpers\Html;
d39ab828   Alexey Boroda   -Comments view fixed
6
7
      use yii\helpers\StringHelper;
      use yii\web\View;
4253cbec   root   first commit
8
9
10
11
12
13
      use yii\widgets\Pjax;
      
      /**
       * @var ActiveDataProvider $dataProvider
       * @var CommentModelSearch $searchModel
       * @var string             $commentModel
d39ab828   Alexey Boroda   -Comments view fixed
14
       * @var View               $this
4253cbec   root   first commit
15
       */
d39ab828   Alexey Boroda   -Comments view fixed
16
      
4253cbec   root   first commit
17
      $statuses = [
d39ab828   Alexey Boroda   -Comments view fixed
18
19
          $searchModel::STATUS_ACTIVE  => 'Активный',
          $searchModel::STATUS_HIDDEN  => 'Скрытый',
4253cbec   root   first commit
20
21
22
          $searchModel::STATUS_DELETED => 'Удаленный',
      ];
      Pjax::begin();
d39ab828   Alexey Boroda   -Comments view fixed
23
      if (( $success = \Yii::$app->session->getFlash('artbox_comment_success') ) != null) {
4253cbec   root   first commit
24
25
          echo Html::tag('p', $success);
      }
d39ab828   Alexey Boroda   -Comments view fixed
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
      echo GridView::widget(
          [
              'dataProvider' => $dataProvider,
              'filterModel'  => $searchModel,
              'columns'      => [
                  [
                      'class'    => 'yii\grid\ActionColumn',
                      'template' => '{update} {delete}',
                  ],
                  [
                      'attribute' => 'artbox_comment_id',
                      'label'     => 'Идентификатор',
                  ],
                  [
                      'attribute' => 'date_add',
                      'format'    => [
                          'date',
                          'php:d.m.Y',
                      ],
                      'filter'    => false,
                  ],
                  [
                      'attribute' => 'text',
                      'value'     => function ($model) {
                          if (empty($model->text)) {
                              return '';
                          } else {
                              return StringHelper::truncate($model->text, 25, '...');
                          }
                      },
                      'format'    => 'html',
                  ],
                  [
                      'attribute' => 'user_id',
                      'value'     => function ($model) {
                          if (!empty($model->user_id)) {
                              return $model->user->username . ' (id:' . $model->user->id . ')';
                          } else {
                              return $model->username . ' ' . $model->email . ' (Гость)';
                          }
                      },
                  ],
                  [
                      'attribute' => 'status',
                      'filter'    => $statuses,
                      'value'     => function ($model) use ($statuses) {
                          return $statuses[ $model->status ];
                      },
                  ],
                  [
                      'attribute' => 'rating_value',
                      'label'     => $searchModel->getAttributeLabel('rating_value'),
                      'value'     => function ($model) {
                          if (!empty($model->rating)) {
                              return $model->rating->value;
                          }
                          return null;
                      },
                  ],
                  //            'entity',
                  //            'entity_id',
                  [
                      'attribute' => 'children_count',
                      'label'     => $searchModel->getAttributeLabel('children_count'),
                      'value'     => function ($model) {
                          return count($model->children);
                      },
                  ],
4253cbec   root   first commit
94
              ],
d39ab828   Alexey Boroda   -Comments view fixed
95
96
          ]
      );
4253cbec   root   first commit
97
      Pjax::end();