Issues (1256)

views/admin/articles/index.php (6 issues)

1
<?php
2
3
use yii\grid\GridView;
4
use yii\widgets\LinkPager;
5
use yii\helpers\{Url, Html};
6
use Itstructure\MFUploader\Module as MFUModule;
7
use app\models\{Article, ArticleSearch};
8
9
/* @var $searchModel ArticleSearch */
10
/* @var $dataProvider yii\data\ActiveDataProvider */
11
/* @var $this Itstructure\AdminModule\components\AdminView */
12
13
$this->title = Yii::t('articles', 'Articles');
14
$this->params['breadcrumbs'][] = $this->title;
15
?>
16
<div class="article-index">
17
18
    <?php  echo $this->render('_search', ['model' => $searchModel]); ?>
19
20
    <p>
21
        <?php echo Html::a(Yii::t('articles', 'Create article'), [
22
            $this->params['urlPrefix'].'create'
23
        ], [
24
            'class' => 'btn btn-success'
25
        ]) ?>
26
    </p>
27
28
    <?php echo LinkPager::widget(['pagination' => $dataProvider->getPagination()]) ?>
29
30
    <?php echo GridView::widget([
31
        'dataProvider' => $dataProvider,
32
        //'filterModel' => $searchModel,
33
        'columns' => [
34
35
            'id',
36
            'thumbnail' => [
37
                'label' => MFUModule::t('main', 'Thumbnail'),
38
                'value' => function($data) {
39
                    /* @var $data ArticleSearch */
40
                    $defaultThumbImage = $data->getDefaultThumbImage();
41
                    return !empty($defaultThumbImage) ? Html::a($defaultThumbImage, Url::to([
42
                        $this->params['urlPrefix'].'view',
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $this seems to be never defined.
Loading history...
43
                        'id' => $data->id
44
                    ])) : '';
45
                },
46
                'format' => 'raw',
47
            ],
48
            'icon' => [
49
                'label' => Yii::t('app', 'Icon'),
50
                'value' => function($searchModel) {
51
                    /* @var $searchModel ArticleSearch */
52
                    return Html::a(
53
                        Html::tag('i', '', ['class' => empty($searchModel->icon) ? 'fa fa-file fa-2x' : $searchModel->icon]),
54
                        Url::to([$this->params['urlPrefix'].'view', 'id' => $searchModel->id])
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $this seems to be never defined.
Loading history...
55
                    );
56
                },
57
                'format' => 'raw',
58
            ],
59
            'title' => [
60
                'label' => Yii::t('app', 'Title'),
61
                'value' => function($searchModel) {
62
                    /* @var $searchModel ArticleSearch */
63
                    return Html::a(
64
                        Html::encode($searchModel->title),
65
                        Url::to([$this->params['urlPrefix'].'view', 'id' => $searchModel->id])
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $this seems to be never defined.
Loading history...
66
                    );
67
                },
68
                'format' => 'raw',
69
            ],
70
            'description' => [
71
                'label' => Yii::t('app', 'Description'),
72
                'value' => function($searchModel) {
73
                    /* @var $searchModel ArticleSearch */
74
                    return $searchModel->description;
75
                },
76
                'format' => 'raw',
77
            ],
78
            'page' => [
79
                'label' => Yii::t('articles', 'Parent page'),
80
                'value' => function ($searchModel) {
81
                    /* @var $searchModel ArticleSearch */
82
                    return null === $searchModel->page ? '' : Html::a(
83
                        $searchModel->page->title,
84
                        Url::to(['/admin/pages/view', 'id' => $searchModel->page->id]),
85
                        [
86
                            'target' => '_blank'
87
                        ]
88
                    );
89
                },
90
                'format' => 'raw',
91
            ],
92
            [
93
                'attribute' => 'created_at',
94
                'format' =>  ['date', 'dd.MM.Y HH:mm:ss'],
95
                'label' => Yii::t('app', 'Created date'),
96
            ],
97
            [
98
                'attribute' => 'updated_at',
99
                'format' =>  ['date', 'dd.MM.Y HH:mm:ss'],
100
                'label' => Yii::t('app', 'Updated date'),
101
            ],
102
            'active' => [
103
                'label' => Yii::t('app', 'Active status'),
104
                'value' => function($searchModel) {
105
                    /* @var $searchModel Article */
106
                    if ($searchModel->active == 1){
107
                        return '<i class="fa fa-check-circle text-success"> ' . Yii::t('app', 'Active') . '</i>';
108
                    } else {
109
                        return '<i class="fa fa-times text-danger"> ' . Yii::t('app', 'Inactive') . '</i>';
110
                    }
111
                },
112
                'format' => 'raw',
113
            ],
114
            [
115
                'class' => 'yii\grid\ActionColumn',
116
                'header' => Yii::t('app', 'Actions'),
117
                'template' => '{view} {update} {delete}',
118
                'urlCreator'=>function($action, $model, $key, $index){
0 ignored issues
show
The parameter $index is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

118
                'urlCreator'=>function($action, $model, $key, /** @scrutinizer ignore-unused */ $index){

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
The parameter $key is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

118
                'urlCreator'=>function($action, $model, /** @scrutinizer ignore-unused */ $key, $index){

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
119
                    return Url::to([
120
                        $this->params['urlPrefix'].$action,
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $this seems to be never defined.
Loading history...
121
                        'id' => $model->id
122
                    ]);
123
                }
124
            ],
125
        ],
126
    ]); ?>
127
</div>
128