-
-
Notifications
You must be signed in to change notification settings - Fork 117
/
browser.html.twig
320 lines (272 loc) · 19.1 KB
/
browser.html.twig
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
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends '@SonataAdmin/empty_layout.html.twig' %}
{% set ckParameters = {'CKEditor': app.request.get('CKEditor'), 'CKEditorFuncNum': app.request.get('CKEditorFuncNum')} %}
{% block stylesheets %}
{{ parent() }}
<style>
.content {
padding: 20px 15px;
}
.wrapper {
background: #ecf0f5 !important;
}
</style>
{% endblock %}
{% block javascripts %}
{{ parent() }}
<script>
$(function () {
$(".select").click(function (e) {
e.preventDefault();
window.opener.CKEDITOR.tools.callFunction({{ app.request.get('CKEditorFuncNum')|escape('js') }}, $(this).attr("href"));
window.close();
});
});
</script>
{% endblock %}
{% block preview %}{% endblock %}
{% import _self as tree %}
{% macro navigate_child(collection, admin, root, current_category, depth) %}
{% import _self as tree %}
{% if root and collection|length == 0 %}
<div>
<p class="bg-warning">{{ 'warning_no_category'|trans({}, admin.translationdomain) }}</p>
</div>
{% endif %}
<ul{% if root %} class="sonata-tree sonata-tree--small js-treeview sonata-tree--toggleable"{% endif %}>
{% for element in collection %}
<li>
<div class="sonata-tree__item{% if element.id == current_category %} is-active{% endif %}"{% if depth < 2 %} data-treeview-toggled{% endif %}>
{% if element.parent or root %}<i class="fa fa-caret-right" data-treeview-toggler></i>{% endif %}
<a class="sonata-tree__item__edit" href="{{ url(app.request.attributes.get('_route'), app.request.query.all|merge({category: element.id})) }}">{{ element.name }}</a>
</div>
{% if element.children|length %}
{{ tree.navigate_child(element.children, admin, false, current_category, depth + 1) }}
{% endif %}
</li>
{% endfor %}
</ul>
{% endmacro %}
{% block list_table %}
<div class="col-xs-6 col-md-3">
{% if root_category is not null %}
{{ tree.navigate_child([root_category], admin, true, datagrid.values['category']['value'], 1) }}
{% endif %}
</div>
<div class="col-xs-12 col-md-9">
<div class="box box-primary">
<div class="box-body {% if admin.datagrid.results|length > 0 %}table-responsive no-padding{% endif %}">
{{ sonata_block_render_event('sonata.admin.list.table.top', { 'admin': admin }) }}
{% block list_header %}{% endblock %}
{% if admin.datagrid.results|length > 0 %}
<table class="table table-bordered table-striped">
{% block table_header %}
<thead>
<tr class="sonata-ba-list-field-header">
{% for field_description in admin.list.elements %}
{% if field_description.getOption('code') == '_batch' or field_description.name == '_action' %}
{# Disable batch and actions #}
{% else %}
{% set sortable = false %}
{% if field_description.options.sortable is defined and field_description.options.sortable%}
{% set sortable = true %}
{% set sort_parameters = admin.modelmanager.sortparameters(field_description, admin.datagrid)|merge(ckParameters) %}
{% set current = admin.datagrid.values._sort_by == field_description or admin.datagrid.values._sort_by.fieldName == sort_parameters.filter._sort_by %}
{% set sort_active_class = current ? 'sonata-ba-list-field-order-active' : '' %}
{% set sort_by = current ? admin.datagrid.values._sort_order : field_description.options._sort_order %}
{% endif %}
{% apply spaceless %}
<th class="sonata-ba-list-field-header-{{ field_description.type}} {% if sortable %} sonata-ba-list-field-header-order-{{ sort_by|lower }} {{ sort_active_class }}{% endif %}">
{% if sortable %}<a href="{{ admin.generateUrl('ckeditor_browser', sort_parameters) }}">{% endif %}
{{ field_description.label|trans }}
{% if sortable %}</a>{% endif %}
</th>
{% endapply %}
{% endif %}
{% endfor %}
</tr>
</thead>
{% endblock %}
{% block table_body %}
<tbody>
{% for object in admin.datagrid.results %}
<tr>
<td colspan="{{ (admin.list.elements|length) - 1}}">
<div>
<a href="{{ sonata_path(object, 'reference') }}" class="select" style="float: left; margin-right: 6px;">{{ sonata_thumbnail(object, 'admin', {'width': 75, 'height': 60}) }}</a>
<strong><a href="{{ sonata_path(object, 'reference') }}" class="select">{{ object.name }}</a></strong> <br />
{{ object.providerName|trans({}, 'SonataMediaBundle') }}{% if object.width %}: {{ object.width }}{% if object.height %}x{{ object.height }}{% endif %}px{% endif %}
{% if formats[object.id]|length > 0 %}
- {{ 'title.formats'|trans({}, 'SonataMediaBundle') }}:
{% for name, format in formats[object.id] %}
<a href="{{ sonata_path(object, name) }}" class="select">{{ name }}</a> {% if format.width %}({{ format.width }}{% if format.height %}x{{ format.height }}{% endif %}px){% endif %}
{% endfor %}
{% endif %}
<br />
</div>
</td>
</tr>
{% endfor %}
</tbody>
{% endblock %}
{% block table_footer %}
{% endblock %}
</table>
{% else %}
<div class="callout callout-info">
{{ 'no_result'|trans({}, 'SonataAdminBundle') }}
</div>
{% endif %}
{{ sonata_block_render_event('sonata.admin.list.table.bottom', { 'admin': admin }) }}
</div>
{% block list_footer %}
{% if admin.datagrid.results|length > 0 %}
<div class="box-footer">
<div class="form-inline clearfix">
{% if not app.request.isXmlHttpRequest %}
<div class="pull-right">
{% block pager_results %}
{% block num_pages %}
{{ admin.datagrid.pager.page }} / {{ admin.datagrid.pager.lastpage }}
-
{% endblock %}
{% block num_results %}
{{ 'list_results_count'|trans({'%count%': admin.datagrid.pager.nbresults}, 'SonataAdminBundle') }}
-
{% endblock %}
{% block max_per_page %}
<label class="control-label" for="{{ admin.uniqid }}_per_page">{{ 'label_per_page'|trans({}, 'SonataAdminBundle') }}</label>
<select class="per-page small" id="{{ admin.uniqid }}_per_page" style="width: auto; height: auto">
{% for per_page in admin.getperpageoptions %}
<option {% if per_page == admin.datagrid.pager.maxperpage %}selected="selected"{% endif %} value="{{ admin.generateUrl('ckeditor_browser', {'filter': admin.datagrid.values|merge({'_per_page': per_page})}|merge(ckParameters)) }}">
{{ per_page }}
</option>
{% endfor %}
</select>
{% endblock %}
{% endblock %}
</div>
{% block pager_links %}
{% if admin.datagrid.pager.haveToPaginate() %}
<hr/>
<div class="text-center">
<ul class="pagination">
{% if admin.datagrid.pager.page > 2 %}
<li><a href="{{ admin.generateUrl('ckeditor_browser', admin.modelmanager.paginationparameters(admin.datagrid, 1)|merge(ckParameters)) }}" title="{{ 'link_first_pager'|trans({}, 'SonataAdminBundle') }}">«</a></li>
{% endif %}
{% if admin.datagrid.pager.page != admin.datagrid.pager.previouspage %}
<li><a href="{{ admin.generateUrl('ckeditor_browser', admin.modelmanager.paginationparameters(admin.datagrid, admin.datagrid.pager.previouspage)|merge(ckParameters)) }}" title="{{ 'link_previous_pager'|trans({}, 'SonataAdminBundle') }}">‹</a></li>
{% endif %}
{# Set the number of pages to display in the pager #}
{% for page in admin.datagrid.pager.getLinks(admin_pool.getOption('pager_links')) %}
{% if page == admin.datagrid.pager.page %}
<li class="active"><a href="{{ admin.generateUrl('ckeditor_browser', admin.modelmanager.paginationparameters(admin.datagrid, page)|merge(ckParameters)) }}">{{ page }}</a></li>
{% else %}
<li><a href="{{ admin.generateUrl('ckeditor_browser', admin.modelmanager.paginationparameters(admin.datagrid, page)|merge(ckParameters)) }}">{{ page }}</a></li>
{% endif %}
{% endfor %}
{% if admin.datagrid.pager.page != admin.datagrid.pager.nextpage %}
<li><a href="{{ admin.generateUrl('ckeditor_browser', admin.modelmanager.paginationparameters(admin.datagrid, admin.datagrid.pager.nextpage)|merge(ckParameters)) }}" title="{{ 'link_next_pager'|trans({}, 'SonataAdminBundle') }}">›</a></li>
{% endif %}
{% if admin.datagrid.pager.page != admin.datagrid.pager.lastpage and admin.datagrid.pager.lastpage != admin.datagrid.pager.nextpage %}
<li><a href="{{ admin.generateUrl('ckeditor_browser', admin.modelmanager.paginationparameters(admin.datagrid, admin.datagrid.pager.lastpage)|merge(ckParameters)) }}" title="{{ 'link_last_pager'|trans({}, 'SonataAdminBundle') }}">»</a></li>
{% endif %}
</ul>
</div>
{% endif %}
{% endblock %}
{% endif %}
</div>
</div>
{% endif %}
{% endblock %}
</div>
</div>
{% endblock %}
{% block list_filters_actions %}
{%- if admin.datagrid.filters|length %}
<ul class="nav navbar-nav navbar-right">
<li class="dropdown sonata-actions">
<a href="#" class="dropdown-toggle sonata-ba-action" data-toggle="dropdown">
<i class="fa fa-filter"></i>
{{ 'link_filters'|trans({}, 'SonataAdminBundle') }} <b class="caret"></b>
</a>
<ul class="dropdown-menu" role="menu">
{% for filter in admin.datagrid.filters|filter(filter => filter.options['show_filter'] is same as(true) or filter.options['show_filter'] is null) %}
<li>
<a href="#" class="sonata-toggle-filter sonata-ba-action" filter-target="filter-{{ admin.uniqid }}-{{ filter.name }}" filter-container="filter-container-{{ admin.uniqid() }}">
<i class="fa {{ (filter.isActive() or filter.options['show_filter']) ? 'fa-check-square-o' : 'fa-square-o' }}"></i>{{ admin.trans(filter.label, {}, filter.translationDomain) }}
</a>
</li>
{% endfor %}
</ul>
</li>
</ul>
{% endif -%}
{% endblock %}
{% block list_filters %}
{% if admin.datagrid.filters %}
{% form_theme form admin.getTemplate('filter') %}
<div class="col-xs-12 col-md-12 sonata-filters-box" style="display: {{ admin.datagrid.hasDisplayableFilters ? 'block' : 'none' }}" id="filter-container-{{ admin.uniqid() }}">
<div class="box box-primary" >
<div class="box-body">
<form class="sonata-filter-form form-horizontal {{ admin.isChild and 1 == admin.datagrid.filters|length ? 'hide' : '' }}" action="{{ admin.generateUrl('ckeditor_browser') }}" method="GET" role="form">
{{ form_errors(form) }}
<div class="row">
<div class="col-sm-9">
{% for filter in admin.datagrid.filters %}
<div class="form-group" id="filter-{{ admin.uniqid }}-{{ filter.name }}" sonata-filter="{{ (filter.options['show_filter'] is same as(true) or filter.options['show_filter'] is null) ? 'true' : 'false' }}" style="display: {% if (filter.isActive() and filter.options['show_filter'] is null) or (filter.options['show_filter'] is same as(true)) %}block{% else %}none{% endif %}">
{% if filter.label is not same as(false) %}
<label for="{{ form.children[filter.formName].children['value'].vars.id }}" class="col-sm-3 control-label">{{ filter.label|trans({}, filter.translationDomain) }}</label>
{% endif %}
{% set attr = form.children[filter.formName].children['type'].vars.attr|default({}) %}
<div class="col-sm-4 advanced-filter">
{{ form_widget(form.children[filter.formName].children['type'], {'attr': attr}) }}
</div>
<div class="col-sm-4">
{{ form_widget(form.children[filter.formName].children['value']) }}
</div>
<div class="col-sm-1">
<label class="control-label">
<a href="#" class="sonata-toggle-filter sonata-ba-action" filter-target="filter-{{ admin.uniqid }}-{{ filter.name }}" filter-container="filter-container-{{ admin.uniqid() }}">
<i class="fa fa-minus-circle"></i>
</a>
</label>
</div>
</div>
{% endfor %}
</div>
<div class="col-sm-3 text-center">
<input type="hidden" name="filter[_page]" id="filter__page" value="1">
{% set foo = form.children['_page'].setRendered() %}
{{ form_rest(form) }}
<div class="form-group">
<button type="submit" class="btn btn-primary">
<i class="fa fa-filter"></i> {{ 'btn_filter'|trans({}, 'SonataAdminBundle') }}
</button>
<a class="btn" href="{{ admin.generateUrl('ckeditor_browser', {filters: 'reset'}|merge(ckParameters)) }}">
{{ 'link_reset_filter'|trans({}, 'SonataAdminBundle') }}
</a>
</div>
<div class="form-group">
<a href="#" data-toggle="advanced-filter">
<i class="fa fa-cogs"></i>
{{ 'btn_advanced_filters'|trans({}, 'SonataAdminBundle') }}
</a>
</div>
</div>
</div>
{% for paramKey, paramValue in admin.persistentParameters|merge(ckParameters) %}
<input type="hidden" name="{{ paramKey }}" value="{{ paramValue }}">
{% endfor %}
</form>
</div>
</div>
</div>
{% endif %}
{% endblock %}