-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcategory-edit.html
438 lines (345 loc) · 23.2 KB
/
category-edit.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
{extends file="admin-layout.tpl"}
{block name="no-return-functions"}
{$admin_current_location = 'catalog'}
{/block}
{block name="check-resource"}admin.category{/block}
{block name="check-access"}update{/block}
{block name="page-title"}{intl l='Edit category'}{/block}
{block name="main-content"}
<div class="catalog edit-category">
<div id="wrapper" class="container">
{include file="includes/catalog-breadcrumb.html" editing_category="true"}
{hook name="category-edit.top" category_id=$category_id}
<div class="row">
{loop name="category_edit" type="category" visible="*" id="{$category_id}" backend_context="1" with_prev_next_info="true" lang="$edit_language_id"}
{* Define close url *}
{if $PARENT gt 0}
{assign var='close_url' value="{url path='/admin/categories' category_id=$PARENT}"}
{else}
{assign var='close_url' value="{url path='/admin/catalog'}"}
{/if}
<div class="col-md-12 general-block-decorator">
<div class="row">
<div class="col-md-7 title">
{intl l='Edit category %title' title={$TITLE}}
</div>
<div class="col-md-5 actions">
<a {if $HAS_PREVIOUS != 0}href="{url path='/admin/categories/update' category_id=$PREVIOUS}"{else}disabled="disabled"{/if} class="btn btn-default" title="{intl l='Edit previous category'}"><span class="glyphicon glyphicon-arrow-left"></span></a>
<a href="{$URL nofilter}" target="_blank" class="btn btn-default" title="{intl l='Preview category page'}"><span class="glyphicon glyphicon-eye-open"></span></a>
<a {if $HAS_NEXT != 0}href="{url path='/admin/categories/update' category_id=$NEXT}"{else}disabled="disabled"{/if} class="btn btn-default" title="{intl l='Edit next category'}"><span class="glyphicon glyphicon-arrow-right"></span></a>
</div>
</div>
<div class="row">
<div class="col-md-12">
{hookblock name="category.tab" id="{$category_id}" fields="id,title,href,content"}
{capture "category_tab_tab"}
{forhook rel="category.tab"}
<li>
<a href="#{$id}"
{if $href}data-href="{$href}"{/if}
data-toggle="tab">{$title}
</a>
</li>
{/forhook}
{/capture}
{capture "category_tab_content"}
{forhook rel="category.tab"}
<div class="tab-pane fade" id="{$id}">
{if $href}
{* ajax *}
<div class="text-center"><span class="loading">{intl l="Please wait, loading"}</span></div>
{else}
{$content nofilter}
{/if}
</div>
{/forhook}
{/capture}
{/hookblock}
<ul class="nav nav-tabs" id="tabbed-menu">
<li><a href="#general" data-toggle="tab">{intl l="General description"}</a></li>
<li><a href="#seo" data-toggle="tab">{intl l="SEO"}</a></li>
<li><a href="#associations" data-toggle="tab">{intl l="Associations"}</a></li>
<li><a href="#images" data-toggle="tab">{intl l="Images"}</a></li>
<li><a href="#documents" data-toggle="tab">{intl l="Documents"}</a></li>
{$smarty.capture.category_tab_tab nofilter}
<li><a href="#modules" data-toggle="tab">{intl l="Modules"}</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane fade" id="general">
<div class="form-container">
{form name="thelia.admin.category.modification"}
<form method="POST" action="{url path='/admin/categories/save'}" {form_enctype} class="clearfix">
{include
file="includes/inner-form-toolbar.html"
close_url=$close_url
}
{* Be sure to get the category ID, even if the form could not be validated *}
<input type="hidden" name="category_id" value="{$ID}" />
<input type="hidden" name="current_tab" value="general" />
{form_hidden_fields exclude="parent"}
{render_form_field field='success_url' value={$close_url}}
{* Display error message if exist *}
{include file='includes/notifications.html' message=$form_error_message}
<div class="row">
<div class="col-md-8">
{include file="includes/standard-description-form-fields.html"}
</div>
<div class="col-md-4">
{hook name="category.modification.form-right.top" category_id=$category_id}
{custom_render_form_field field='parent'}
<select {form_field_attributes field='parent' extra_class="form_control"}>
<option value="0">{intl l="Top level"}</option>
{$excludeCategories = []}
{loop name="exclude-categories" type="category" parent=$category_id}
{$excludeCategories[] = $ID}
{/loop}
{$myparent=$PARENT}
{loop name="cat-parent" type="category-tree" visible="*" category="0" exclude={','|implode:$excludeCategories}}
<option value="{$ID}" {if $myparent == $ID}selected="selected"{/if} {if $category_id == $ID}disabled="disabled"{/if}>{option_offset l=$LEVEL+1 label=$TITLE}</option>
{/loop}
</select>
{/custom_render_form_field}
{render_form_field field="default_template_id"}
{form_field field="visible"}
<label class="checkbox">
<input type="checkbox" {if $value != 0}checked{/if} name="{$name}" value="1"> {$label}
</label>
{/form_field}
{hook name="category.modification.form-right.bottom" category_id=$category_id}
</div>
</div>
{include
file="includes/inner-form-toolbar.html"
hide_submit_buttons = false
hide_flags = true
close_url=$close_url
}
<small>{intl l='Category created on %date_create. Last modification: %date_change' date_create="{format_date date=$CREATE_DATE}" date_change="{format_date date=$UPDATE_DATE}"}</small>
</form>
{/form}
</div>
</div>
<div class="tab-pane fade" id="seo">
{include file="includes/seo-tab.html"
formAction = "{url path='/admin/categories/seo/save'}"
pageUrl = "{url path='/admin/categories/update' category_id=$ID}"
current_id = $ID
closeUrl = $close_url
success_url = $close_url
seoType = 'category'
}
</div>
<div class="tab-pane fade" id="associations">
<div class="form-container">
<div class="form-group">
<form action="{url path='/admin/categories/related-content/add'}" id="related_content_form">
{include
file="includes/inner-form-toolbar.html"
hide_submit_buttons=true
close_url=$close_url
}
<p class="title title-without-tabs">{intl l='Related content'}</p>
<p>{intl l='You can attach here some content to this category'}</p>
<input type="hidden" name="category_id" value="{$ID}" />
<input type="hidden" name="current_tab" value="associations" />
{ifloop rel="folders"}
<div class="row">
<div class="col-md-6">
<div class="form-group">
<select name="folder_id" id="folder_id" class="form-control">
<option value="">{intl l='Select a folder...'}</option>
{loop name="folders" type="folder-tree" folder="0" backend_context="1" lang="$edit_language_id"}
<option value="{$ID}">{option_offset l=$LEVEL label={$TITLE}}</option>
{/loop}
</select>
</div>
<span class="help-block">{intl l='Select a folder to get its content'}</span>
</div>
<div class="col-md-6">
<div id="content_selector" class="hide">
<div class="input-group">
<select required="required" name="content_id" id="content_id" class="form-control">
<option value="">{intl l='Select a folder content...'}</option>
</select>
<span class="input-group-btn" id="content_add_button">
<button class="btn btn-primary action-btn" type="submit"><span class="glyphicon glyphicon-plus-sign"></span></button>
</span>
</div>
<span class="help-block">{intl l='Select a content and click (+) to add it to this category'}</span>
</div>
<div id="content_selector_empty" class="hide">
<div class="alert alert-info">
{intl l="No available content in this folder"}
</div>
</div>
</div>
</div>
{/ifloop}
{elseloop rel="folders"}
<div class="alert alert-info">{intl l="No folders found"}</div>
{/elseloop}
</form>
</div>
<div class="table-responsive">
<table class="table table-striped table-condensed table-left-aligned">
<thead>
<tr>
<th>{intl l='ID'}</th>
<th>{intl l='Content title'}</th>
{hook name="category.contents-table-header" location="category_contents_table_header" }
<th class="actions">{intl l="Actions"}</th>
</tr>
</thead>
<tbody>
{loop name="assigned_contents" type="associated_content" category="$ID" backend_context="1" lang="$edit_language_id"}
<tr>
<td>{$CONTENT_ID}</td>
<td><a href="{url path="/admin/content/update/%id" id=$CONTENT_ID}">{$TITLE}</a></td>
{hook name="category.contents-table-row" location="category_contents_table_row" }
<td class="actions">
{loop type="auth" name="can_create" role="ADMIN" resource="admin.configuration.category" access="UPDATE"}
<a class="btn btn-default btn-xs delete-content" title="{intl l='Delete this content'}" href="#delete_content_dialog" data-id="{$CONTENT_ID}" data-toggle="modal">
<span class="glyphicon glyphicon-trash"></span>
</a>
{/loop}
</td>
</tr>
{/loop}
{elseloop rel="assigned_contents"}
<tr>
<td colspan="3">
<div class="alert alert-info">
{intl l="This category contains no contents"}
</div>
</td>
</tr>
{/elseloop}
</tbody>
</table>
</div>
</div>
</div>
<div class="tab-pane fade" id="images">
{include file='includes/image-upload-form.html' imageType='category' parentId=$ID resource="admin.category"}
</div>
<div class="tab-pane fade" id="documents">
{include file='includes/document-upload-form.html' documentType='category' parentId=$ID resource="admin.category"}
</div>
{$smarty.capture.category_tab_content nofilter}
<div class="tab-pane fade" id="modules">
<div class="form-container">
{include
file = "includes/inner-form-toolbar.html"
hide_submit_buttons = true
page_url = {$pageUrl}
close_url = {$closeUrl}
current_tab = "modules"
}
</div>
{* ugly fix : {hook name="category.tab-content" id="{$category_id}" view="category"} *}
{include file="includes/module-tab-content.html" hook="category.tab-content" location="category-edit" id="{$category_id}" view="category"}
</div>
</div>
</div>
</div>
</div>
{/loop}
</div>
{hook name="category-edit.bottom" category_id=$category_id}
</div>
</div>
{* Delete related content confirmation dialog *}
{capture "delete_content_dialog"}
<input type="hidden" name="category_id" value="{$category_id}" />
<input type="hidden" name="content_id" id="content_delete_id" value="" />
<input type="hidden" name="folder_id" id="folder_delete_id" value="" />
<input type="hidden" name="current_tab" value="associations" />
{/capture}
{include
file = "includes/generic-confirm-dialog.html"
dialog_id = "delete_content_dialog"
dialog_title = {intl l="Remove related content"}
dialog_message = {intl l="Do you really want to remove this related content ?"}
form_action = {token_url path='/admin/categories/related-content/delete'}
form_content = {$smarty.capture.delete_content_dialog nofilter}
}
{/block}
{block name="javascript-initialization"}
{javascripts file='assets/js/dropzone.js'}
<script src="{$asset_url}"></script>
{/javascripts}
{javascripts file='assets/js/image-upload.js'}
<script src="{$asset_url}"></script>
{/javascripts}
{javascripts file='assets/js/document-upload.js'}
<script src="{$asset_url}"></script>
{/javascripts}
{javascripts file='assets/js/jquery-ui-1.10.3.custom.min.js'}
<script src="{$asset_url}"></script>
{/javascripts}
<script>
$(function() {
// Atomatic ajax tab load, if data-href is defined.
$('.nav-tabs a[data-href]').on('shown.bs.tab', function(ev) {
var $this = $(this);
$($this.attr('href')).load($this.data('href'), function(ev) {
if($this.data('callback')) {
eval($this.data('callback') + '();');
}
});
});
$.imageUploadManager.initImageDropZone();
$.documentUploadManager.initDocumentDropZone();
$('.use_default_rewriten_url').click(function(ev) {
alert("Not functionnal");
ev.preventDefault();
});
// Set proper content ID in delete content from
$('a.delete-content').click(function(ev) {
$('#content_delete_id').val($(this).data('id'));
$('#folder_delete_id').val($('#folder_id').val());
});
// Load active tab
$('.nav-tabs a[href="#{$current_tab}"]').trigger("click");
// Load content on folder selection
$('#folder_id').change(function(event) {
var val = $(this).val();
if (val != "") {
$.ajax({
url : '{url path="/admin/category/%id/available-related-content/" id=$category_id}' + val + '.xml',
type : 'get',
dataType : 'json',
success : function(json) {
$('#content_id :not(:first-child)').remove();
var have_content = false;
$.each(json, function(idx, value) {
$('#content_id').append($('<option>').text(value.title).attr('value', value.id));
have_content = true; // Lame...
});
if (have_content) {
$('#content_selector_empty').addClass('hide');
$('#content_selector').removeClass('hide');
}
else {
$('#content_selector_empty').removeClass('hide');
$('#content_selector').addClass('hide');
}
}
});
}
else {
$('#content_selector_empty').addClass('hide');
$('#content_selector').addClass('hide');
}
});
// Initialize folder select value
{if $folder_id != 0}
$('#folder_id').val("{$folder_id}").change();
{/if}
});
</script>
{/block}
{block name="javascript-last-call"}
{hook name="category.edit-js" location="category-edit-js" category_id=$category_id}
{hook name="wysiwyg.js" location="wysiwyg-category-edit-js" }
{/block}