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\bootstrap\ButtonDropdown; |
||
10 | use yii\grid\GridView; |
||
11 | use yii\helpers\ArrayHelper; |
||
12 | use yii\helpers\Html; |
||
13 | use yii\helpers\Url; |
||
14 | use yii\widgets\Pjax; |
||
15 | |||
16 | /* @var $this yii\web\View */ |
||
17 | /* @var $searchModel common\models\search\Post */ |
||
18 | /* @var $dataProvider yii\data\ActiveDataProvider */ |
||
19 | /* @var $postType common\models\PostType */ |
||
20 | /* @var $user integer */ |
||
21 | |||
22 | $this->title = $postType->plural_name; |
||
23 | $this->params['breadcrumbs'][] = $this->title; |
||
24 | ?> |
||
25 | <div class="post-index"> |
||
26 | <div class="form-inline grid-nav" role="form"> |
||
27 | <div class="form-group"> |
||
28 | <?= Html::dropDownList( |
||
29 | 'bulk-action', |
||
30 | null, |
||
31 | ArrayHelper::merge($searchModel->getPostStatuses(), ['delete' => 'Delete']), |
||
32 | ['class' => 'bulk-action form-control', 'prompt' => Yii::t('writesdown', 'Bulk Action')] |
||
33 | ) ?> |
||
34 | |||
35 | <?= Html::button(Yii::t('writesdown', 'Apply'), ['class' => 'btn btn-flat btn-warning bulk-button']) ?> |
||
36 | |||
37 | <?= Html::a( |
||
38 | Yii::t('writesdown', 'Add New {postType}', ['postType' => $postType->singular_name]), |
||
39 | ['create', 'type' => $postType->id, ], |
||
40 | ['class' => 'btn btn-flat btn-primary'] |
||
41 | ) ?> |
||
42 | |||
43 | <?= ButtonDropdown::widget([ |
||
44 | 'label' => Html::tag('i', '', ['class' => 'fa fa-user']) . ' Author', |
||
45 | 'dropdown' => [ |
||
46 | 'items' => [ |
||
47 | [ |
||
48 | 'label' => 'My Posts', |
||
49 | 'url' => ['index', 'type' => $postType->id, 'user' => Yii::$app->user->id], |
||
50 | ], |
||
51 | ['label' => 'All Posts', 'url' => ['index', 'type' => $postType->id]], |
||
52 | ], |
||
53 | ], |
||
54 | 'split' => true, |
||
55 | 'encodeLabel' => false, |
||
56 | 'options' => ['class' => 'btn btn-flat btn-danger'], |
||
57 | ]) ?> |
||
58 | |||
59 | <?= Html::button(Html::tag('i', '', ['class' => 'fa fa-search']), [ |
||
60 | 'class' => 'btn btn-flat btn-info', |
||
61 | 'data-toggle' => 'collapse', |
||
62 | 'data-target' => '#post-search', |
||
63 | ]) ?> |
||
64 | |||
65 | </div> |
||
66 | </div> |
||
67 | <?php Pjax::begin() ?> |
||
68 | <?= $this->render('_search', ['model' => $searchModel, 'postType' => $postType, 'user' => $user]) ?> |
||
69 | <?= GridView::widget([ |
||
70 | 'dataProvider' => $dataProvider, |
||
71 | 'filterModel' => $searchModel, |
||
72 | 'id' => 'post-grid-view', |
||
73 | 'columns' => [ |
||
74 | [ |
||
75 | 'class' => 'yii\grid\CheckboxColumn', |
||
76 | 'checkboxOptions' => function ($model) { |
||
77 | /* @var $model \common\models\search\Post */ |
||
78 | if ($model->getPermission()) { |
||
79 | return ['value' => $model->id]; |
||
80 | } |
||
81 | |||
82 | return ['disabled' => 'disabled']; |
||
83 | }, |
||
84 | ], |
||
85 | [ |
||
86 | 'attribute' => 'username', |
||
87 | 'value' => function ($model) { |
||
88 | /* @var $model \common\models\search\Post */ |
||
89 | return $model->postAuthor->username; |
||
90 | }, |
||
91 | ], |
||
92 | 'title:ntext', |
||
93 | 'date', |
||
94 | ['attribute' => 'status', 'filter' => $searchModel->getPostStatuses()], |
||
95 | ['attribute' => 'comment_status', 'filter' => $searchModel->getCommentStatuses()], |
||
96 | 'comment_count', |
||
97 | |||
98 | [ |
||
99 | 'class' => 'yii\grid\ActionColumn', |
||
100 | 'buttons' => [ |
||
101 | View Code Duplication | 'view' => function ($url, $model) { |
|
0 ignored issues
–
show
|
|||
102 | return Html::a('<span class="glyphicon glyphicon-eye-open"></span>', $model->url, [ |
||
103 | 'title' => Yii::t('yii', 'View'), |
||
104 | 'data-pjax' => '0', |
||
105 | ]); |
||
106 | }, |
||
107 | View Code Duplication | 'update' => 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. ![]() |
|||
108 | /* @var $model \common\models\search\Post */ |
||
109 | if ($model->getPermission()) { |
||
110 | return Html::a('<span class="glyphicon glyphicon-pencil"></span>', $url, [ |
||
111 | 'title' => Yii::t('yii', 'Update'), |
||
112 | 'data-pjax' => '0', |
||
113 | ]); |
||
114 | } |
||
115 | |||
116 | return ''; |
||
117 | }, |
||
118 | View Code Duplication | 'delete' => 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. ![]() |
|||
119 | /* @var $model \common\models\search\Post */ |
||
120 | if ($model->getPermission()) { |
||
121 | return Html::a('<span class="glyphicon glyphicon-trash"></span>', $url, [ |
||
122 | 'title' => Yii::t('yii', 'Delete'), |
||
123 | 'data-confirm' => Yii::t('yii', 'Are you sure you want to delete this item?'), |
||
124 | 'data-method' => 'post', |
||
125 | 'data-pjax' => '0', |
||
126 | ]); |
||
127 | } |
||
128 | |||
129 | return ''; |
||
130 | }, |
||
131 | ], |
||
132 | ], |
||
133 | ], |
||
134 | ]) ?> |
||
135 | |||
136 | <?php Pjax::end() ?> |
||
137 | |||
138 | </div> |
||
139 | <?php $this->registerJs('jQuery(".bulk-button").click(function(e){ |
||
140 | e.preventDefault(); |
||
141 | if(confirm("' . Yii::t("app", "Are you sure to do this?") . '")){ |
||
142 | var ids = $("#post-grid-view").yiiGridView("getSelectedRows"); // returns an array of pkeys, and #grid is your grid element id |
||
143 | var action = $(this).parents(".form-group").find(".bulk-action").val(); |
||
144 | $.ajax({ |
||
145 | url: "' . Url::to(["bulk-action"]) . '", |
||
146 | data: { ids: ids, action: action, _csrf: yii.getCsrfToken() }, |
||
147 | type:"POST", |
||
148 | success: function(data){ |
||
149 | $.pjax.reload({container:"#post-grid-view"}); |
||
150 | } |
||
151 | }); |
||
152 | } |
||
153 | });') ?> |
||
154 |
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.