Issues (46)

src/views/albums/index.php (2 issues)

1
<?php
2
3
use yii\helpers\{Html, Url};
4
use yii\grid\GridView;
5
use Itstructure\MFUploader\Module;
6
use Itstructure\MFUploader\models\album\Album;
7
8
/* @var $this yii\web\View */
9
/* @var $searchModel Itstructure\MFUploader\models\album\AlbumSearch */
10
/* @var $dataProvider yii\data\ActiveDataProvider */
11
12
$this->title = Module::t('album', ucfirst($searchModel->getFileType($searchModel->type)).' albums');
13
$this->params['breadcrumbs'][] = $this->title;
14
?>
15
<div class="album-index">
16
17
    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>
18
19
    <p>
20
        <?php echo Html::a(Module::t('album', 'Create album'), [
21
            $this->params['urlPrefix'].'create'
22
        ], [
23
            'class' => 'btn btn-success'
24
        ]) ?>
25
    </p>
26
27
    <?php echo GridView::widget([
28
        'dataProvider' => $dataProvider,
29
        //'filterModel' => $searchModel,
30
        'columns' => [
31
            [
32
                'label' => Module::t('main', 'ID'),
33
                'value' => function($data) {
34
                    /* @var $data Album */
35
                    return Html::a(
36
                        Html::encode($data->id),
37
                        Url::to([
38
                            $this->params['urlPrefix'].'view',
39
                            'id' => $data->id
40
                        ])
41
                    );
42
                },
43
                'format' => 'raw',
44
            ],
45
            [
46
                'label' => Module::t('main', 'Thumbnail'),
47
                'value' => function($data) {
48
                    /* @var $data Album */
49
                    $defaultThumbImage = $data->getDefaultThumbImage();
50
                    return !empty($defaultThumbImage) ? Html::a($defaultThumbImage, Url::to([
51
                        $this->params['urlPrefix'].'view',
52
                        'id' => $data->id
53
                    ])) : '';
54
                },
55
                'format' => 'raw',
56
            ],
57
            [
58
                'label' => Module::t('album', 'Title'),
59
                'value' => function($data) {
60
                    /* @var $data Album */
61
                    return Html::a(
62
                        Html::encode($data->title),
63
                        Url::to([
64
                            $this->params['urlPrefix'].'view',
65
                            'id' => $data->id
66
                        ])
67
                    );
68
                },
69
                'format' => 'raw',
70
            ],
71
            [
72
                'attribute' => 'description',
73
                'label' =>  Module::t('album', 'Description'),
74
            ],
75
            [
76
                'attribute' => 'type',
77
                'label' =>  Module::t('album', 'Type'),
78
                'value' => function($data) {
79
                    /* @var Album */
80
                    return Album::getAlbumTypes($data->type);
81
                }
82
            ],
83
            [
84
                'attribute' => 'created_at',
85
                'label' => Module::t('main', 'Created date'),
86
                'format' =>  ['date', 'dd.MM.YY HH:mm:ss'],
87
            ],
88
            [
89
                'attribute' => 'updated_at',
90
                'label' => Module::t('main', 'Updated date'),
91
                'format' =>  ['date', 'dd.MM.Y HH:mm:ss'],
92
            ],
93
            [
94
                'class' => 'yii\grid\ActionColumn',
95
                'header' => Module::t('main', 'Actions'),
96
                'template' => '{view} {update} {delete}',
97
                '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

97
                '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

97
                '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...
98
                    return Url::to([
99
                        $this->params['urlPrefix'].$action,
100
                        'id' => $model->id
101
                    ]);
102
                }
103
            ],
104
        ],
105
    ]); ?>
106
</div>
107