Issues (1313)

views/admin/articles/view.php (3 issues)

1
<?php
2
3
use yii\helpers\{Html, Url};
4
use yii\grid\GridView;
5
use yii\widgets\DetailView;
6
use yii\data\{ArrayDataProvider, Pagination};
7
use Itstructure\FieldWidgets\TableMultilanguage;
8
use Itstructure\AdminModule\models\Language;
9
use Itstructure\MFUploader\Module as MFUModule;
10
use Itstructure\MFUploader\models\album\Album;
11
use Itstructure\MFUploader\interfaces\UploadModelInterface;
12
use Itstructure\MFUploader\models\Mediafile;
13
use app\models\Article;
14
15
/* @var $this yii\web\View */
16
/* @var $model Article */
17
/* @var $images array */
18
/* @var $images_items Mediafile[] */
19
/* @var $images_pagination Pagination */
20
21
$images_items = $images['items'];
22
$images_pagination = $images['pagination'];
23
24
$this->title = $model->getDefaultTranslate('title');
25
$this->params['breadcrumbs'][] = [
26
    'label' => Yii::t('articles', 'Articles'),
27
    'url' => [
28
        $this->params['urlPrefix'].'index'
29
    ]
30
];
31
$this->params['breadcrumbs'][] = $this->title;
32
?>
33
34
<style>
35
    h5 {
36
        font-weight: bold;
37
        padding: 5px;
38
    }
39
</style>
40
41
<div class="article-view">
42
43
    <p>
44
        <?php echo Html::a(Yii::t('app', 'Update'), [
45
            $this->params['urlPrefix'].'update',
46
            'id' => $model->id
47
        ], [
48
            'class' => 'btn btn-primary'
49
        ]) ?>
50
51
        <?php echo Html::a(Yii::t('app', 'Delete'), [
52
            $this->params['urlPrefix'].'delete',
53
            'id' => $model->id
54
        ], [
55
            'class' => 'btn btn-danger',
56
            'data'=>[
57
                'method' => 'post',
58
                'confirm' => Yii::t('app', 'Are you sure you want to do this action?'),
59
            ]
60
        ]) ?>
61
    </p>
62
63
    <h3><?php echo Yii::t('app', 'Translate'); ?></h3>
64
    <?php echo TableMultilanguage::widget([
65
        'fields' => [
66
            [
67
                'name' => 'title',
68
                'label' => Yii::t('app', 'Title'),
69
            ],
70
            [
71
                'name' => 'description',
72
                'label' => Yii::t('app', 'Description'),
73
            ],
74
            [
75
                'name' => 'content',
76
                'label' => Yii::t('app', 'Content'),
77
            ],
78
            [
79
                'name' => 'metaKeys',
80
                'label' => Yii::t('app', 'Meta keys'),
81
            ],
82
            [
83
                'name' => 'metaDescription',
84
                'label' => Yii::t('app', 'Meta description'),
85
            ],
86
        ],
87
        'model'         => $model,
88
        'languageModel' => new Language(),
89
    ]) ?>
90
91
    <?php echo DetailView::widget([
92
        'model' => $model,
93
        'attributes' => [
94
            'id',
95
            'thumbnail' => [
96
                'label' => MFUModule::t('main', 'Thumbnail'),
97
                'value' => function ($model) {
98
                    /* @var $model Article */
99
                    $thumbnailModel = $model->getThumbnailModel();
100
                    return $thumbnailModel == null ? '' : Html::a($model->getDefaultThumbImage(), Url::to($thumbnailModel->getThumbUrl(MFUModule::THUMB_ALIAS_LARGE)), [
101
                        'target' => '_blank'
102
                    ]);
103
                },
104
                'format' => 'raw',
105
            ],
106
            [
107
                'label' => Yii::t('app', 'Icon'),
108
                'value' => function($model) {
109
                    /* @var $model Article */
110
                    return Html::tag('i', '', ['class' => empty($model->icon) ? 'fa fa-file fa-2x' : $model->icon]);
111
                },
112
                'format' => 'raw',
113
            ],
114
            [
115
                'attribute' => 'alias',
116
                'label' => Yii::t('app', 'URL Alias'),
117
            ],
118
            [
119
                'label' => Yii::t('app', 'Active status'),
120
                'value' => function($model) {
121
                    /* @var $model Article */
122
                    if ($model->active == 1){
123
                        return '<i class="fa fa-check-circle text-success"> ' . Yii::t('app', 'Active') . '</i>';
124
                    } else {
125
                        return '<i class="fa fa-times text-danger"> ' . Yii::t('app', 'Inactive') . '</i>';
126
                    }
127
                },
128
                'format' => 'raw',
129
            ],
130
            [
131
                'label' => Yii::t('articles', 'Parent page'),
132
                'value' => function ($model) {
133
                    /* @var $model Article */
134
                    return null === $model->page ? '' : Html::a(
135
                        $model->page->getDefaultTranslate('title'),
136
                        Url::to(['/'.$this->params['shortLanguage'].'/admin/pages/view', 'id' => $model->page->id]),
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $this seems to be never defined.
Loading history...
137
                        [
138
                            'target' => '_blank'
139
                        ]
140
                    );
141
                },
142
                'format' => 'raw',
143
            ],
144
            [
145
                'attribute' => 'created_at',
146
                'format' =>  ['date', 'dd.MM.Y HH:mm:ss'],
147
                'label' => Yii::t('app', 'Created date'),
148
            ],
149
            [
150
                'attribute' => 'updated_at',
151
                'format' =>  ['date', 'dd.MM.Y HH:mm:ss'],
152
                'label' => Yii::t('app', 'Updated date'),
153
            ],
154
        ],
155
    ]) ?>
156
157
    <!-- Existing files begin -->
158
    <?php if ($images_pagination->totalCount > 0): ?>
159
        <div class="panel panel-default">
160
            <div class="panel-heading"><?php echo MFUModule::t('main', 'Existing files'); ?></div>
161
            <div class="panel-body">
162
                <?php echo $this->render('../mediafiles/_existing-mediafiles', [
163
                    'edition' => false,
164
                    'mediafiles' => $images_items,
165
                    'pages' => $images_pagination,
166
                    'fileType' => UploadModelInterface::FILE_TYPE_IMAGE,
167
                ]) ?>
168
            </div>
169
        </div>
170
    <?php endif; ?>
171
    <!-- Existing files end -->
172
173
    <?php if (count($albums = $model->getAlbums()) > 0): ?>
174
        <h3><?php echo MFUModule::t('album', 'Albums') ?></h3>
175
        <?php echo GridView::widget([
176
            'dataProvider' => new ArrayDataProvider([
177
                'allModels' => $albums
178
            ]),
179
            'columns' => [
180
                'thumbnail' => [
181
                    'label' => MFUModule::t('main', 'Thumbnail'),
182
                    'value' => function($item) {
183
                        /** @var Album $item */
184
                        return Html::a(
185
                            $item->getDefaultThumbImage(),
186
                            Url::to([
187
                                '/'.$this->params['shortLanguage'].'/mfuploader/'.$item->getFileType($item->type).'-album/view', 'id' => $item->id
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $this seems to be never defined.
Loading history...
188
                            ])
189
                        );
190
                    },
191
                    'format' => 'raw',
192
                ],
193
                'name' => [
194
                    'label' => MFUModule::t('album', 'Title'),
195
                    'value' => function($item) {
196
                        /** @var Album $item */
197
                        return Html::a(
198
                            Html::encode($item->title),
199
                            Url::to([
200
                                '/'.$this->params['shortLanguage'].'/mfuploader/'.$item->getFileType($item->type).'-album/view', 'id' => $item->id
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $this seems to be never defined.
Loading history...
201
                            ])
202
                        );
203
                    },
204
                    'format' => 'raw',
205
                ],
206
                'description' => [
207
                    'label' => MFUModule::t('album', 'Description'),
208
                    'value' => function($item) {
209
                        /** @var Album $item */
210
                        return $item->description;
211
                    },
212
                ],
213
            ],
214
        ]); ?>
215
    <?php endif; ?>
216
217
</div>
218