mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
185 lines
7.2 KiB
Twig
185 lines
7.2 KiB
Twig
{#
|
|
Template to render a person
|
|
OPTIONS
|
|
* render string ['raw'|'label'|'bloc']
|
|
* addAltNames bool
|
|
* addLink bool
|
|
* addEntity bool
|
|
* addId bool
|
|
* addInfo bool
|
|
* addAge bool
|
|
* addCenter bool
|
|
* hLevel integer
|
|
* addDeath bool
|
|
* address_multiline bool
|
|
* customButtons [
|
|
'before' Twig\Markup, (injected with macro)
|
|
'replace' Twig\Markup,
|
|
'after' Twig\Markup
|
|
]
|
|
* customArea [
|
|
'beforeLabel' Twig\Markup,
|
|
'afterLabel' Twig\Markup,
|
|
]
|
|
#}
|
|
|
|
{% macro raw(person, options) %}
|
|
<span class="firstname">{{ person.firstName }}</span>
|
|
<span class="lastname">
|
|
{{ person.lastName }}
|
|
{%- if options['addDeath'] -%}
|
|
{% if person.deathdate is not null %} (‡){% endif %}
|
|
{% endif %}
|
|
</span>
|
|
{%- if options['addAltNames'] -%}
|
|
<span class="altnames">
|
|
{%- for n in person.altNames -%}
|
|
<span class="altname altname-{{ n.key }}">
|
|
{{- n.label -}}
|
|
</span>
|
|
{%- endfor -%}
|
|
</span>
|
|
{%- endif -%}
|
|
{% endmacro raw %}
|
|
|
|
{% macro label(person, options) %}
|
|
<div class="entity-label">
|
|
<div class="denomination {{ 'h' ~ options['hLevel'] }}">
|
|
{%- if options['addLink'] and is_granted('CHILL_PERSON_SEE', person) -%}
|
|
<a href="{{ chill_path_add_return_path('chill_person_view', { 'person_id': person.id }) }}">
|
|
{%- endif -%}
|
|
|
|
{% if options['customArea']['beforeLabel'] is defined %}
|
|
{{ options['customArea']['beforeLabel'] }}
|
|
{% endif %}
|
|
|
|
{{ _self.raw(person, options) }}
|
|
|
|
{% if options['customArea']['afterLabel'] is defined %}
|
|
{{ options['customArea']['afterLabel'] }}
|
|
{% endif %}
|
|
|
|
{%- if options['addLink'] and is_granted('CHILL_PERSON_SEE', person) -%}
|
|
</a>
|
|
{%- endif -%}
|
|
|
|
{%- if options['addEntity'] -%}
|
|
<span class="badge rounded-pill bg-secondary">{{ 'Person'|trans }}</span>
|
|
{%- endif -%}
|
|
{%- if options['addId'] -%}
|
|
<span class="id-number" title="{{ 'Person'|trans ~ ' n° ' ~ person.id }}">
|
|
{{ person.id|upper -}}
|
|
</span>
|
|
{%- endif -%}
|
|
</div>
|
|
{%- if options['addInfo'] -%}
|
|
{% set gender = (person.gender == 'woman') ? 'fa-venus' :
|
|
(person.gender == 'man') ? 'fa-mars' : (person.gender == 'neuter') ? 'fa-neuter' : 'fa-genderless' %}
|
|
{% set genderTitle = (person.gender == 'woman') ? 'woman' :
|
|
(person.gender == 'man') ? 'man' : (person.gender == 'neuter') ? 'neuter' : 'Not given'|trans %}
|
|
<p class="moreinfo">
|
|
<i class="fa fa-fw {{ gender }}" title="{{ genderTitle|trans }}"></i>
|
|
|
|
{%- if person.deathdate is not null -%}
|
|
{%- if person.birthdate is not null -%}
|
|
{# must be on one line to avoid spaces with dash #}
|
|
<time datetime="{{ person.birthdate|date('Y-m-d') }}" title="{{ 'birthdate'|trans|e('html_attr') }}">{{ person.birthdate|format_date("medium") }}</time>–
|
|
{%- else -%}
|
|
{{ 'Date of death'|trans }}:
|
|
{%- endif -%}
|
|
{#- must be on one line to avoid spaces with dash -#}
|
|
<time datetime="{{ person.deathdate|date('Y-m-d') }}" title="{{ 'deathdate'|trans }}">{{ person.deathdate|format_date("medium") }} </time>
|
|
{%- if options['addAge'] -%}
|
|
<span class="age">({{ 'years_old'|trans({ 'age': person.age }) }})</span>
|
|
{%- endif -%}
|
|
{%- elseif person.birthdate is not null -%}
|
|
<time datetime="{{ person.birthdate|date('Y-m-d') }}" title="{{ 'Birthdate'|trans }}">
|
|
{{ 'Born the date'|trans({'gender': person.gender,
|
|
'birthdate': person.birthdate|format_date("medium") }) }}
|
|
</time>
|
|
{%- if options['addAge'] -%}
|
|
<span class="age">({{- 'years_old'|trans({ 'age': person.age }) -}})</span>
|
|
{%- endif -%}
|
|
{%- endif -%}
|
|
</p>
|
|
{%- endif -%}
|
|
{#- tricks to remove easily whitespace after template -#}
|
|
{%- if true -%}</div>{%- endif -%}
|
|
{% endmacro label %}
|
|
|
|
|
|
{%- if render == 'raw' -%}
|
|
<span class="entity-raw">
|
|
{{ _self.raw(person, options) }}
|
|
</span>
|
|
{%- endif -%}
|
|
|
|
{%- if render == 'label' -%}
|
|
{{ _self.label(person, options) }}
|
|
{%- endif -%}
|
|
|
|
{%- if render == 'bloc' -%}
|
|
<div class="item-row entity-bloc">
|
|
<div class="item-col">
|
|
{{ _self.label(person, options) }}
|
|
</div>
|
|
<div class="item-col">
|
|
<ul class="list-content fa-ul">
|
|
{% if person.getCurrentPersonAddress is not null %}
|
|
{% set multiline = (options['address_multiline']) ? true : false %}
|
|
{{ person.getCurrentPersonAddress|chill_entity_render_box({
|
|
'render': 'list',
|
|
'with_picto': true,
|
|
'multiline': multiline,
|
|
'with_valid_from': false
|
|
}) }}
|
|
{% endif %}
|
|
<li>
|
|
{% if person.mobilenumber %}
|
|
<i class="fa fa-li fa-mobile"></i><a href="{{ 'tel:' ~ person.mobilenumber }}">
|
|
{{ person.mobilenumber|chill_format_phonenumber }}
|
|
</a>
|
|
{% else %}
|
|
<i class="fa fa-li fa-phone"></i>
|
|
{% if person.phonenumber %}
|
|
<a href="{{ 'tel:' ~ person.phonenumber }}">
|
|
{{ person.phonenumber|chill_format_phonenumber }}
|
|
</a>
|
|
{% else %}
|
|
<span class="chill-no-data-statement">{{ 'No data given'|trans }}</span>
|
|
{% endif %}
|
|
{% endif %}
|
|
</li>
|
|
{% if options['addCenter'] and person|chill_resolve_center|length > 0 %}
|
|
<li>
|
|
<i class="fa fa-li fa-long-arrow-right"></i>
|
|
{% for c in person|chill_resolve_center %}
|
|
{{ c.name|upper }}{% if not loop.last %}, {% endif %}
|
|
{% endfor %}
|
|
</li>
|
|
{% endif %}
|
|
</ul>
|
|
<ul class="record_actions">
|
|
{% if options['customButtons']['before'] is defined %}
|
|
{{ options['customButtons']['before'] }}
|
|
{% endif %}
|
|
|
|
{%- if options['customButtons']['replace'] is defined -%}
|
|
{{ options['customButtons']['replace'] }}
|
|
{%- elseif is_granted('CHILL_PERSON_SEE', person) -%}
|
|
<li>
|
|
<a class="btn btn-sm btn-show" title="{{ 'Show person'|trans }}"
|
|
href="{{ path('chill_person_view', { person_id: person.id }) }}"></a>
|
|
</li>
|
|
{%- else -%}
|
|
{%- endif -%}
|
|
|
|
{% if options['customButtons']['after'] is defined %}
|
|
{{ options['customButtons']['after'] }}
|
|
{% endif %}
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
{%- endif -%}
|
|
|