Skip to content

Commit 765b94d

Browse files
committed
+ Add single file block
1 parent ba2b199 commit 765b94d

4 files changed

Lines changed: 104 additions & 0 deletions

File tree

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<type xmlns="http://schemas.sulu.io/template/template"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xmlns:xi="http://www.w3.org/2001/XInclude"
5+
xsi:schemaLocation="http://schemas.sulu.io/template/template http://schemas.sulu.io/template/template-1.0.xsd"
6+
name="file_block">
7+
<meta>
8+
<title lang="en">File Block</title>
9+
<title lang="fr">Bloc Fichier</title>
10+
</meta>
11+
<properties>
12+
<xi:include href='sulu-block-bundle://properties/title.xml'/>
13+
<xi:include href='sulu-block-bundle://properties/file.xml'/>
14+
</properties>
15+
</type>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0" ?>
2+
<property xmlns="http://schemas.sulu.io/template/template"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xmlns:xi="http://www.w3.org/2001/XInclude"
5+
xsi:schemaLocation="http://schemas.sulu.io/template/template http://schemas.sulu.io/template/template-1.0.xsd"
6+
name="file"
7+
type="single_media_selection"
8+
>
9+
<meta>
10+
<title lang="en">File</title>
11+
<title lang="fr">Fichier</title>
12+
</meta>
13+
<xi:include href='sulu-block-bundle://app-property-params/file.xml'
14+
xpointer='xmlns(sulu=http://schemas.sulu.io/template/template) xpointer(/sulu:params)'
15+
parse='xml'>
16+
<xi:fallback>
17+
<params>
18+
<xi:include href='sulu-block-bundle://app-property-params/images_config.xml'
19+
parse='xml'>
20+
<xi:fallback>
21+
<param name="types" value="document"/>
22+
</xi:fallback>
23+
</xi:include>
24+
<xi:include href='sulu-block-bundle://app-property-params/images_additions.xml'
25+
xpointer='xmlns(sulu=http://schemas.sulu.io/template/template) xpointer(/sulu:params/sulu:param)'
26+
parse='xml'>
27+
<xi:fallback/>
28+
</xi:include>
29+
</params>
30+
</xi:fallback>
31+
</xi:include>
32+
</property>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{% extends '@Block/html5/base.html.twig' %}
2+
3+
{% block section_content %}
4+
<div class="file-block">
5+
{% if block['file'] is defined and block['file'] is not empty %}
6+
<div class="file-block-download">
7+
{% include '@Block/html5/parts/file.html.twig' %}
8+
</div>
9+
{% endif %}
10+
</div>
11+
{% endblock %}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{% if block['file'] is defined and block['file'] is not empty %}
2+
{% set file = sulu_resolve_media(block['file'], app.request.locale) %}
3+
{% if file %}
4+
<div class="file-block-item">
5+
<a href="{{ file.url }}"
6+
class="file-download-link"
7+
download="{{ file.name }}"
8+
target="_blank"
9+
rel="noopener noreferrer">
10+
<span class="file-download-icon">
11+
<svg width="20" height="20" fill="none" stroke="currentColor" viewBox="0 0 24 24">
12+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 10v6m0 0l-3-3m3 3l3-3m2 8H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"/>
13+
</svg>
14+
</span>
15+
<span class="file-details">
16+
<span class="file-title">
17+
{% if block['title'] is defined and block['title'] is not empty %}
18+
{{ block['title'] }}
19+
{% else %}
20+
{{ file.title|default(file.name) }}
21+
{% endif %}
22+
</span>
23+
{% if file.size %}
24+
<span class="file-meta">
25+
{% set size = file.size %}
26+
<span class="file-size">
27+
{% if size < 1024 %}
28+
{{ size }} octets
29+
{% elseif size < 1048576 %}
30+
{{ (size / 1024)|round(1) }} Ko
31+
{% elseif size < 1073741824 %}
32+
{{ (size / 1048576)|round(1) }} Mo
33+
{% else %}
34+
{{ (size / 1073741824)|round(1) }} Go
35+
{% endif %}
36+
</span>
37+
{% if file.extension %}
38+
<span class="file-extension">{{ file.extension|upper }}</span>
39+
{% endif %}
40+
</span>
41+
{% endif %}
42+
</span>
43+
</a>
44+
</div>
45+
{% endif %}
46+
{% endif %}

0 commit comments

Comments
 (0)