a0e8d4e0
Alexey Boroda
first commit
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
<?php
use common\models\SitemapDynamic;
use common\models\SitemapStatic;
use yii\bootstrap\ActiveForm;
use yii\bootstrap\Html;
use yii\helpers\Url;
use yii\web\View;
use yiister\gentelella\widgets\Panel;
/**
* @var View $this
* @var SitemapStatic[] $models
* @var SitemapDynamic[] $entity_models
*/
$this->params[ 'breadcrumbs' ][] = [
|
809b0ee3
Eugeny Galkovskiy
Переводы 1
|
16
|
'label' => \Yii::t('core', 'Карта сайта'),
|
a0e8d4e0
Alexey Boroda
first commit
|
17
18
|
'url' => [ 'index' ],
];
|
809b0ee3
Eugeny Galkovskiy
Переводы 1
|
19
|
$this->title = \Yii::t('core', 'Обновить карту сайта');
|
a0e8d4e0
Alexey Boroda
first commit
|
20
21
22
23
|
$this->params[ 'breadcrumbs' ][] = $this->title;
$form = ActiveForm::begin();
$xPanel = Panel::begin(
[
|
809b0ee3
Eugeny Galkovskiy
Переводы 1
|
24
|
'header' => \Yii::t('core', 'Статические страницы'),
|
a0e8d4e0
Alexey Boroda
first commit
|
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
'collapsable' => true,
'options' => [
'class' => 'x_panel dynamic_fields',
],
]
);
foreach ($models as $index => $model) {
echo Html::tag(
'div',
$form->field(
$model,
"[$index]url",
[
'options' => [
'class' => 'form-group col-xs-5 col-sm-6',
],
]
)
->textInput() . $form->field(
$model,
"[$index]frequency",
[
'options' => [
'class' => 'form-group col-xs-3 col-sm-3',
],
]
)
->dropDownList(
[
|
809b0ee3
Eugeny Galkovskiy
Переводы 1
|
54
55
56
57
58
59
60
|
'always' => 'всегда',
'hourly' => 'ежечасно',
'daily' => 'ежедневно',
'weekly' => 'еженедельно',
'monthly' => 'ежемесячно',
'yearly' => 'ежегодно',
'never' => 'никогда',
|
a0e8d4e0
Alexey Boroda
first commit
|
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
]
) . $form->field(
$model,
"[$index]priority",
[
'options' => [
'class' => 'form-group col-xs-3 col-sm-2',
],
]
)
->textInput() . Html::icon(
'minus',
[
'class' => 'col-xs-1 field-group-remove',
'onclick' => 'sitemap_remove(this)',
]
),
[
'class' => 'row field-group',
]
);
}
echo Html::button(
|
809b0ee3
Eugeny Galkovskiy
Переводы 1
|
84
|
\Yii::t('core', 'Добавить поле'),
|
a0e8d4e0
Alexey Boroda
first commit
|
85
86
87
88
89
90
91
92
93
94
95
|
[
'class' => 'btn btn-default',
'onclick' => 'sitemap_add(this)',
'data' => [
'url' => Url::to([ 'create-static' ]),
],
]
);
$xPanel::end();
$xPanel2 = Panel::begin(
[
|
809b0ee3
Eugeny Galkovskiy
Переводы 1
|
96
|
'header' => \Yii::t('core', 'Динамические страницы'),
|
a0e8d4e0
Alexey Boroda
first commit
|
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
'collapsable' => true,
]
);
?>
<div class="col-xs-9 col-sm-10"></div>
<div class="col-xs-3 col-sm-2 text-center"><?php echo $entity_models[ 0 ]->getAttributeLabel('priority'); ?></div>
<div class="clearfix"></div>
<?php
foreach ($entity_models as $index => $entity_model) {
?>
<div class="form-group col-xs-6 col-sm-8">
<?php
echo Html::tag(
'div',
Html::activeInput(
'text',
$entity_model,
"[$index]entity",
[
'class' => 'form-control',
'readonly' => 1,
]
) . Html::tag(
'span',
Html::activeCheckbox(
$entity_model,
"[$index]status",
[
'label' => false,
]
),
[
'class' => 'input-group-addon',
]
),
[
'class' => 'input-group',
]
);
?>
</div>
<div class="form-group col-xs-3 col-sm-2">
<?php
echo $form->field($entity_model, "[$index]frequency")
->label(false)
->dropDownList(
[
|
809b0ee3
Eugeny Galkovskiy
Переводы 1
|
144
145
146
147
148
149
150
|
'always' => 'всегда',
'hourly' => 'ежечасно',
'daily' => 'ежедневно',
'weekly' => 'еженедельно',
'monthly' => 'ежемесячно',
'yearly' => 'ежегодно',
'never' => 'никогда',
|
a0e8d4e0
Alexey Boroda
first commit
|
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
|
]
);
?>
</div>
<div class="form-group col-xs-3 col-sm-2">
<?php
echo $form->field($entity_model, "[$index]priority")
->label(false)
->input(
'number',
[
'step' => 0.1,
'min' => 0,
'max' => 1,
]
);
?>
</div>
<?php
}
$xPanel2::end();
echo Html::submitButton(
|
809b0ee3
Eugeny Galkovskiy
Переводы 1
|
173
|
\Yii::t('core', 'Сохранить'),
|
a0e8d4e0
Alexey Boroda
first commit
|
174
175
176
177
178
|
[
'class' => 'btn btn-success',
]
);
echo Html::submitButton(
|
809b0ee3
Eugeny Galkovskiy
Переводы 1
|
179
|
\Yii::t('core', 'Сохранить и сгенерировать'),
|
a0e8d4e0
Alexey Boroda
first commit
|
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
|
[
'class' => 'btn btn-primary',
'name' => 'action',
'value' => 'generate',
]
);
$form::end();
$js = <<<JS
function sitemap_add(e) {
var url = $(e)
.data('url');
var form_id = $(e)
.parents('form')
.attr('id');
var form = $('#' + form_id);
var count = $('.field-group').length;
$.get(
url, {
'formId': form_id,
'count': count
}, function(data) {
form.find('.field-group')
.last()
.after(data);
}
);
}
function sitemap_remove(e) {
if($('.field-group').length > 1) {
$(e)
.parents('.field-group')
.remove();
}
}
JS;
$this->registerJs($js, $this::POS_END);
|