Issues (1256)

views/admin/social/index.php (4 issues)

1
<?php
2
3
use yii\grid\GridView;
4
use yii\helpers\{Url, Html};
5
use app\models\SocialSearch;
6
7
/* @var $searchModel SocialSearch */
8
/* @var $dataProvider yii\data\ActiveDataProvider */
9
/* @var $this Itstructure\AdminModule\components\AdminView */
10
11
$this->title = Yii::t('social', 'Social');
12
$this->params['breadcrumbs'][] = $this->title;
13
?>
14
<div class="social-index">
15
16
    <?php  //echo $this->render('_search', ['model' => $searchModel]); ?>
17
18
    <p>
19
        <?php echo Html::a(Yii::t('social', 'Create social'), [
20
            $this->params['urlPrefix'].'create'
21
        ], [
22
            'class' => 'btn btn-success'
23
        ]) ?>
24
    </p>
25
26
    <?php echo GridView::widget([
27
        'dataProvider' => $dataProvider,
28
        //'filterModel' => $searchModel,
29
        'columns' => [
30
31
            'id',
32
            'icon' => [
33
                'label' => Yii::t('app', 'Icon'),
34
                'value' => function($searchModel) {
35
                    /* @var $searchModel SocialSearch */
36
                    return Html::a(
37
                        Html::tag('i', '', ['class' => $searchModel->icon]),
38
                        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...
39
                    );
40
                },
41
                'format' => 'raw',
42
            ],
43
            'url' => [
44
                'label' => Yii::t('social', 'Url'),
45
                'value' => function($searchModel) {
46
                    /* @var $searchModel SocialSearch */
47
                    return Html::a(
48
                        Html::encode($searchModel->url),
49
                        Url::to($searchModel->url),
50
                        [
51
                            'target' => '_blank'
52
                        ]
53
                    );
54
                },
55
                'format' => 'raw',
56
            ],
57
            'contacts' => [
58
                'label' => Yii::t('social', 'Parent contact records'),
59
                'value' => function ($searchModel) {
60
                    /* @var $searchModel SocialSearch */
61
                    $contactRecords = '';
62
                    foreach ($searchModel->contacts as $contactRecord) {
63
                        $contactRecords .= Html::tag('li',
64
                            Html::a($contactRecord->title,
65
                                Url::to(['/admin/contacts/view', 'id' => $contactRecord->id]),
66
                                [
67
                                    'target' => '_blank'
68
                                ]
69
                            )
70
                        );
71
                    }
72
73
                    return empty($contactRecords) ? '' : Html::tag('ul', $contactRecords, [
74
                        'style' => 'margin-left: 10px; padding-left: 10px;'
75
                    ]);
76
                },
77
                'format' => 'raw',
78
            ],
79
            [
80
                'attribute' => 'created_at',
81
                'format' =>  ['date', 'dd.MM.Y HH:mm:ss'],
82
                'label' => Yii::t('app', 'Created date'),
83
            ],
84
            [
85
                'attribute' => 'updated_at',
86
                'format' =>  ['date', 'dd.MM.Y HH:mm:ss'],
87
                'label' => Yii::t('app', 'Updated date'),
88
            ],
89
            [
90
                'class' => 'yii\grid\ActionColumn',
91
                'header' => Yii::t('app', 'Actions'),
92
                'template' => '{view} {update} {delete}',
93
                'urlCreator'=>function($action, $model, $key, $index){
0 ignored issues
show
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

93
                '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...
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

93
                '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...
94
                    return Url::to([
95
                        $this->params['urlPrefix'].$action,
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $this seems to be never defined.
Loading history...
96
                        'id' => $model->id
97
                    ]);
98
                }
99
            ],
100
        ],
101
    ]); ?>
102
</div>
103