This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * @link http://www.writesdown.com/ |
||
4 | * @author Agiel K. Saputra <[email protected]> |
||
5 | * @copyright Copyright (c) 2015 WritesDown |
||
6 | * @license http://www.writesdown.com/license/ |
||
7 | */ |
||
8 | |||
9 | use yii\grid\GridView; |
||
10 | use yii\helpers\ArrayHelper; |
||
11 | use yii\helpers\Html; |
||
12 | use yii\helpers\Url; |
||
13 | use yii\widgets\Pjax; |
||
14 | |||
15 | /* @var $this yii\web\View */ |
||
16 | /* @var $searchModel common\models\search\Media */ |
||
17 | /* @var $dataProvider yii\data\ActiveDataProvider */ |
||
18 | |||
19 | $this->title = Yii::t('writesdown', 'Media'); |
||
20 | $this->params['breadcrumbs'][] = $this->title; |
||
21 | ?> |
||
22 | <div class="media-index"> |
||
23 | <div class="form-inline grid-nav" role="form"> |
||
24 | <div class="form-group"> |
||
25 | <?= Html::dropDownList('bulk-action', null, ['delete' => 'Delete Permanently'], [ |
||
26 | 'prompt' => Yii::t('writesdown', 'Bulk Action'), |
||
27 | 'class' => 'bulk-action form-control', |
||
28 | ]) ?> |
||
29 | |||
30 | <?= Html::button(Yii::t('writesdown', 'Apply'), [ |
||
31 | 'class' => 'btn btn-flat btn-warning bulk-button', |
||
32 | 'data-type' => 'DELETE', |
||
33 | ]) ?> |
||
34 | |||
35 | <?= Html::a(Yii::t('writesdown', 'Add New Media'), ['create'], ['class' => 'btn btn-flat btn-primary']) ?> |
||
36 | |||
37 | <?= Html::button(Html::tag('i', '', ['class' => 'fa fa-search']), [ |
||
38 | 'class' => 'btn btn-flat btn-info', |
||
39 | "data-toggle" => "collapse", |
||
40 | "data-target" => "#media-search", |
||
41 | ]) ?> |
||
42 | |||
43 | </div> |
||
44 | </div> |
||
45 | <?php Pjax::begin() ?> |
||
46 | <?= $this->render('_search', ['model' => $searchModel]) ?> |
||
47 | <?= GridView::widget([ |
||
48 | 'dataProvider' => $dataProvider, |
||
49 | 'filterModel' => $searchModel, |
||
50 | 'id' => 'media-grid-view', |
||
51 | 'columns' => [ |
||
52 | [ |
||
53 | 'class' => 'yii\grid\CheckboxColumn', |
||
54 | 'checkboxOptions' => function ($model) { |
||
55 | if (!Yii::$app->user->can('editor') && $model->author !== Yii::$app->user->id) { |
||
56 | return ['disabled' => 'disabled']; |
||
57 | } |
||
58 | |||
59 | return ['value' => $model->id]; |
||
60 | }, |
||
61 | ], |
||
62 | [ |
||
63 | 'attribute' => Yii::t('writesdown', 'Preview'), |
||
64 | 'format' => 'raw', |
||
65 | 'value' => function ($model) { |
||
66 | /* @var $model common\models\Media */ |
||
67 | $metadata = $model->getMeta('metadata'); |
||
68 | $iconUrl = ArrayHelper::getValue($metadata, 'icon_url'); |
||
69 | |||
70 | if (preg_match('/^image\//', $model->mime_type)) { |
||
71 | return Html::a(Html::img($model->getUploadUrl() . $iconUrl), [ |
||
72 | 'update', |
||
73 | 'id' => $model->id, |
||
74 | ], ['class' => 'media-mime-icon']); |
||
75 | } |
||
76 | |||
77 | return Html::a(Html::img(Url::base(true) . '/' . $iconUrl), [ |
||
78 | 'update', |
||
79 | 'id' => $model->id, |
||
80 | ], ['class' => 'media-mime-icon']); |
||
81 | }, |
||
82 | ], |
||
83 | [ |
||
84 | 'label' => Yii::t('writesdown', 'File Name'), |
||
85 | 'format' => 'html', |
||
86 | View Code Duplication | 'value' => function ($model) { |
|
0 ignored issues
–
show
|
|||
87 | /* @var $model common\models\Media */ |
||
88 | $metadata = $model->getMeta('metadata'); |
||
89 | |||
90 | return Html::a(ArrayHelper::getValue($metadata, 'filename', '#'), ['update', 'id' => $model->id]); |
||
91 | }, |
||
92 | ], |
||
93 | [ |
||
94 | 'attribute' => 'username', |
||
95 | 'value' => function ($model) { |
||
96 | return $model->mediaAuthor->username; |
||
97 | }, |
||
98 | ], |
||
99 | 'date:datetime', |
||
100 | |||
101 | [ |
||
102 | 'class' => 'yii\grid\ActionColumn', |
||
103 | 'buttons' => [ |
||
104 | View Code Duplication | 'view' => function ($url, $model) { |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
105 | return Html::a('<span class="glyphicon glyphicon-eye-open"></span>', $model->url, [ |
||
106 | 'title' => Yii::t('yii', 'View'), |
||
107 | 'data-pjax' => '0', |
||
108 | ]); |
||
109 | }, |
||
110 | 'update' => function ($url, $model) { |
||
111 | View Code Duplication | if (!Yii::$app->user->can('editor') && $model->author !== Yii::$app->user->id) { |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
112 | return ''; |
||
113 | } |
||
114 | |||
115 | return Html::a('<span class="glyphicon glyphicon-pencil"></span>', $url, [ |
||
116 | 'title' => Yii::t('yii', 'Update'), |
||
117 | 'data-pjax' => '0', |
||
118 | ]); |
||
119 | }, |
||
120 | 'delete' => function ($url, $model) { |
||
121 | View Code Duplication | if (!Yii::$app->user->can('editor') && $model->author !== Yii::$app->user->id) { |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
122 | return ''; |
||
123 | } |
||
124 | |||
125 | return Html::a('<span class="glyphicon glyphicon-trash"></span>', $url, [ |
||
126 | 'title' => Yii::t('yii', 'Delete'), |
||
127 | 'data-confirm' => Yii::t('yii', 'Are you sure you want to delete this item?'), |
||
128 | 'data-method' => 'post', |
||
129 | 'data-pjax' => '0', |
||
130 | ]); |
||
131 | }, |
||
132 | ], |
||
133 | ], |
||
134 | ], |
||
135 | ]) ?> |
||
136 | |||
137 | <?php Pjax::end() ?> |
||
138 | |||
139 | </div> |
||
140 | <?php $this->registerJs('jQuery(document).on("click", ".bulk-button", function(e){ |
||
141 | e.preventDefault(); |
||
142 | if(confirm("' . Yii::t('writesdown', 'Are you sure?') . '")){ |
||
143 | var ids = $("#media-grid-view").yiiGridView("getSelectedRows"); |
||
144 | var action = $(this).closest(".form-group").find(".bulk-action").val(); |
||
145 | $.ajax({ |
||
146 | url: "' . Url::to(['bulk-action']) . '", |
||
147 | data: { ids: ids, action: action, _csrf: yii.getCsrfToken() }, |
||
148 | type: "POST", |
||
149 | success: function(data){ |
||
150 | $.pjax.reload({container:"#media-grid-view"}); |
||
151 | } |
||
152 | }); |
||
153 | } |
||
154 | });'); ?> |
||
155 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.