From 77e262bad028234434b0060c6552c240539833f2 Mon Sep 17 00:00:00 2001 From: Jean-Yves Gaulier Date: Thu, 16 May 2019 17:26:24 +0200 Subject: [PATCH] PHRAS-2581_twig-macro-explode_4.1 explode commmon/macros.html.twig in 3 files for 3 macros --- templates/web/account/account.html.twig | 4 +- .../web/account/change-password.html.twig | 4 +- templates/web/account/reset-email.html.twig | 4 +- templates/web/common/caption.html.twig | 14 ++-- ...cros.html.twig => macro_captcha.html.twig} | 69 ------------------- templates/web/common/macro_caption.html.twig | 12 ++++ templates/web/common/macro_flashes.html.twig | 19 +++++ templates/web/lightbox/IE6/feed.html.twig | 4 +- templates/web/lightbox/IE6/validate.html.twig | 4 +- templates/web/lightbox/feed.html.twig | 4 +- templates/web/lightbox/validate.html.twig | 4 +- templates/web/login/index.html.twig | 5 +- templates/web/login/providers/bind.html.twig | 4 +- .../web/login/providers/mapping.html.twig | 4 +- .../web/login/register-classic.html.twig | 4 +- templates/web/prod/preview/caption.html.twig | 8 +-- templates/web/prod/results/list.html.twig | 4 +- templates/web/prod/results/record.html.twig | 4 +- 18 files changed, 67 insertions(+), 108 deletions(-) rename templates/web/common/{macros.html.twig => macro_captcha.html.twig} (59%) create mode 100644 templates/web/common/macro_caption.html.twig create mode 100644 templates/web/common/macro_flashes.html.twig diff --git a/templates/web/account/account.html.twig b/templates/web/account/account.html.twig index 29bccc7716..887b29ec03 100644 --- a/templates/web/account/account.html.twig +++ b/templates/web/account/account.html.twig @@ -1,6 +1,6 @@ {% extends "account/base.html.twig" %} -{% import "common/macros.html.twig" as auth_macro %} +{% import "common/macro_flashes.html.twig" as macro_flashes %} {% set selected = "informations" %} @@ -25,7 +25,7 @@ {% block content_account %}
- {{ auth_macro.flashes() }} + {{ macro_flashes.flashes() }}
diff --git a/templates/web/account/change-password.html.twig b/templates/web/account/change-password.html.twig index 93ae08b162..3a285d5a4d 100644 --- a/templates/web/account/change-password.html.twig +++ b/templates/web/account/change-password.html.twig @@ -1,6 +1,6 @@ {% extends "login/layout/sidebar-layout.html.twig" %} -{% import "common/macros.html.twig" as account_macro %} +{% import "common/macro_flashes.html.twig" as macro_flashes %} {% import "login/common/macros.html.twig" as auth_macro %} {% block title %} @@ -18,7 +18,7 @@
- {{ account_macro.flashes() }} + {{ macro_flashes.flashes() }}
- {{ auth_macro.flashes() }} + {{ macro_flashes.flashes() }}
diff --git a/templates/web/common/caption.html.twig b/templates/web/common/caption.html.twig index 51f277901c..0a71994974 100644 --- a/templates/web/common/caption.html.twig +++ b/templates/web/common/caption.html.twig @@ -1,21 +1,21 @@ -{% import 'common/macros.html.twig' as macro %} +{% import 'common/macro_caption.html.twig' as macro_caption %} {% set business = granted_on_collection(record.baseId, [constant('\\ACL::CANMODIFRECORD')]) %} {% set display_exif = true %} {% if view == 'answer' %} - {{ macro.caption(record, business, display_exif) }} + {{ macro_caption.caption(record, business, display_exif) }} {% elseif view == 'lazaret' %} - {{ macro.caption(record, business, display_exif) }} + {{ macro_caption.caption(record, business, display_exif) }} {% elseif view == 'preview' %} {% set display_exif = false %} - {{ macro.caption(record, business, display_exif, true) }} + {{ macro_caption.caption(record, business, display_exif, true) }} {% elseif view == 'basket' %} {% set display_exif = false %} - {{ macro.caption(record, business, display_exif) }} + {{ macro_caption.caption(record, business, display_exif) }} {% elseif view == 'overview' %} {% set display_exif = false %} - {{ macro.caption(record, business, display_exif) }} + {{ macro_caption.caption(record, business, display_exif) }} {% elseif view == 'publi' %} - {{ macro.caption(record, business, display_exif) }} + {{ macro_caption.caption(record, business, display_exif) }} {% endif %} diff --git a/templates/web/common/macros.html.twig b/templates/web/common/macro_captcha.html.twig similarity index 59% rename from templates/web/common/macros.html.twig rename to templates/web/common/macro_captcha.html.twig index 28a0a31f81..f1168ed1bd 100644 --- a/templates/web/common/macros.html.twig +++ b/templates/web/common/macro_captcha.html.twig @@ -67,72 +67,3 @@ {% endmacro %} - -{% macro flashes() %} - {% for type in app.getAvailableFlashTypes %} - {% for message in app.getFlash(type) %} -
- - - - - - -
{{ message }} - × -
-
- {% endfor %} - {% endfor %} -{% endmacro %} - -{% macro caption_value(field, bounceable) %} - {% autoescape false %} - {% set terms = [] %} - {% for data in field.values %} - {% if data.from_thesaurus and bounceable %} - {% set value = data.value|e|bounce(field.name, data.qjs, field.sbas_id)|parseColor %} - {% else %} - {% set value = data.value|e|parseColor %} - {% endif %} - {% set terms = [value]|merge(terms) %} - {% endfor %} - {{ terms|join(' ; ') }} - {% endautoescape %} -{% endmacro %} - -{% macro caption_field(field, bounceable, extra_classes) %} -
- {{ field.label_name }} : - {{ _self.caption_value(field, bounceable|default(true))|highlight|linkify }} -
-{% endmacro %} - -{% macro format_caption(record, highlight, search_engine, include_business, bounceable, technical_data) %} - {% for field in record.get_caption().get_highlight_fields(null, include_business) %} - {% set extra_classes = ['pair'] %} - {% if loop.index is odd %} - {% set extra_classes = ['impair'] %} - {% endif %} - {{ _self.caption_field(field, bounceable|default(true), extra_classes) }} - {% endfor %} - {% if technical_data|default(true) and app.getAuthenticatedUser() is not none and app['settings'].getUserSetting(app.getAuthenticatedUser(), 'technical_display') == 'group' %} -
- {% include 'common/technical_datas.html.twig' %} - {% endif %} -{% endmacro %} - -{% macro caption(record, can_see_business, display_exif, limitedWidth = false) %} -
- {% for name, value in record.getCaption(caption_field_order(record, can_see_business)) %} -
{{ caption_field_label(record, name) }}
-
{{ caption_field(record, name, value)|e|highlight|linkify|parseColor }}
- {% endfor %} -
- {% if display_exif|default(true) and app.getAuthenticator().user is not none and user_setting('technical_display') == 'group' %} -
- {% include 'common/technical_datas.html.twig' %} - {% endif %} -{% endmacro %} diff --git a/templates/web/common/macro_caption.html.twig b/templates/web/common/macro_caption.html.twig new file mode 100644 index 0000000000..21a1fab40d --- /dev/null +++ b/templates/web/common/macro_caption.html.twig @@ -0,0 +1,12 @@ +{% macro caption(record, can_see_business, display_exif, limitedWidth = false) %} +
+ {% for name, value in record.getCaption(caption_field_order(record, can_see_business)) %} +
{{ caption_field_label(record, name) }}
+
{{ caption_field(record, name, value)|e|highlight|linkify|parseColor }}
+ {% endfor %} +
+ {% if display_exif|default(true) and app.getAuthenticator().user is not none and user_setting('technical_display') == 'group' %} +
+ {% include 'common/technical_datas.html.twig' %} + {% endif %} +{% endmacro %} diff --git a/templates/web/common/macro_flashes.html.twig b/templates/web/common/macro_flashes.html.twig new file mode 100644 index 0000000000..8d5ea2e393 --- /dev/null +++ b/templates/web/common/macro_flashes.html.twig @@ -0,0 +1,19 @@ +{% macro flashes() %} + {% for type in app.getAvailableFlashTypes %} + {% for message in app.getFlash(type) %} +
+ + + + + + +
{{ message }} + × +
+
+ {% endfor %} + {% endfor %} +{% endmacro %} diff --git a/templates/web/lightbox/IE6/feed.html.twig b/templates/web/lightbox/IE6/feed.html.twig index eb76cafc57..4b5e132c4c 100644 --- a/templates/web/lightbox/IE6/feed.html.twig +++ b/templates/web/lightbox/IE6/feed.html.twig @@ -1,7 +1,7 @@ {% extends "lightbox/index_layout.html.twig" %} {% import 'common/thumbnail.html.twig' as thumbnail %} -{% import 'common/macros.html.twig' as macro %} +{% import 'common/macro_caption.html.twig' as macro_caption %} {% block javascript %} @@ -84,7 +84,7 @@
diff --git a/templates/web/lightbox/IE6/validate.html.twig b/templates/web/lightbox/IE6/validate.html.twig index 10e36c5899..bb60a470f3 100644 --- a/templates/web/lightbox/IE6/validate.html.twig +++ b/templates/web/lightbox/IE6/validate.html.twig @@ -1,7 +1,7 @@ {% extends "lightbox/index_layout.html.twig" %} {% import 'common/thumbnail.html.twig' as thumbnail %} -{% import 'common/macros.html.twig' as macro %} +{% import 'common/macro_caption.html.twig' as macro_caption %} {% block javascript %} @@ -95,7 +95,7 @@
diff --git a/templates/web/lightbox/feed.html.twig b/templates/web/lightbox/feed.html.twig index 721797b88b..0dc742d47d 100644 --- a/templates/web/lightbox/feed.html.twig +++ b/templates/web/lightbox/feed.html.twig @@ -1,7 +1,7 @@ {% extends "lightbox/index_layout.html.twig" %} {% import 'common/thumbnail.html.twig' as thumbnail %} -{% import 'common/macros.html.twig' as macro %} +{% import 'common/macro_caption.html.twig' as macro_caption %} {% block javascript %} @@ -81,7 +81,7 @@
diff --git a/templates/web/lightbox/validate.html.twig b/templates/web/lightbox/validate.html.twig index 5ca17f41c5..fbb1561817 100644 --- a/templates/web/lightbox/validate.html.twig +++ b/templates/web/lightbox/validate.html.twig @@ -1,7 +1,7 @@ {% extends "lightbox/index_layout.html.twig" %} {% import 'common/thumbnail.html.twig' as thumbnail %} -{% import 'common/macros.html.twig' as macro %} +{% import 'common/macro_caption.html.twig' as macro_caption %} {% block javascript %} @@ -95,7 +95,7 @@
diff --git a/templates/web/login/index.html.twig b/templates/web/login/index.html.twig index 4cbe37ba8f..6cca5039fe 100644 --- a/templates/web/login/index.html.twig +++ b/templates/web/login/index.html.twig @@ -1,6 +1,6 @@ {% extends "login/layout/sidebar-layout.html.twig" %} -{% import "common/macros.html.twig" as macro %} +{% import "common/macro_captcha.html.twig" as macro_captcha %} {% import "login/common/macros.html.twig" as auth_macro %} {% block main_title %} @@ -70,10 +70,11 @@ {{ "Forgot password?" | trans }}
+ {% if recaptcha_display %}
- {{ macro.captcha() }} + {{ macro_captcha.captcha() }}
{% endif %} diff --git a/templates/web/login/providers/bind.html.twig b/templates/web/login/providers/bind.html.twig index adce1a0263..41ce1530d5 100644 --- a/templates/web/login/providers/bind.html.twig +++ b/templates/web/login/providers/bind.html.twig @@ -1,6 +1,6 @@ {% extends "login/layout/sidebar-layout.html.twig" %} -{% import "common/macros.html.twig" as macro %} +{% import "common/macro_captcha.html.twig" as macro_captcha %} {% import "login/common/macros.html.twig" as auth_macro %} {% block title %} @@ -60,7 +60,7 @@ {% if recaptcha_display %}
- {{ macro.captcha() }} + {{ macro_captcha.captcha() }}
{% endif %} diff --git a/templates/web/login/providers/mapping.html.twig b/templates/web/login/providers/mapping.html.twig index 1016fa21e7..2a73222f4f 100644 --- a/templates/web/login/providers/mapping.html.twig +++ b/templates/web/login/providers/mapping.html.twig @@ -1,6 +1,6 @@ {% extends "login/layout/sidebar-layout.html.twig" %} -{% import "common/macros.html.twig" as macro %} +{% import "common/macro_captcha.html.twig" as macro_captcha %} {% import "login/common/macros.html.twig" as auth_macro %} {% block title %} @@ -76,7 +76,7 @@ {% if recaptcha_display %}
- {{ macro.captcha() }} + {{ macro_captcha.captcha() }}
{% endif %} diff --git a/templates/web/login/register-classic.html.twig b/templates/web/login/register-classic.html.twig index 9b31038a33..6d62cb45a8 100644 --- a/templates/web/login/register-classic.html.twig +++ b/templates/web/login/register-classic.html.twig @@ -1,7 +1,7 @@ {% extends "login/layout/sidebar-layout.html.twig" %} {% import "login/common/macros.html.twig" as auth_macro %} -{% import "common/macros.html.twig" as macro %} +{% import "common/macro_captcha.html.twig" as macro_captcha %} {% block title %} {{ "Register" | trans }} @@ -85,7 +85,7 @@ {% if recaptcha_display %}
- {{ macro.captcha() }} + {{ macro_captcha.captcha() }}
{% endif %} diff --git a/templates/web/prod/preview/caption.html.twig b/templates/web/prod/preview/caption.html.twig index 4f4b08063a..4758f02211 100644 --- a/templates/web/prod/preview/caption.html.twig +++ b/templates/web/prod/preview/caption.html.twig @@ -1,4 +1,4 @@ -{% import 'common/macros.html.twig' as macro %} +{% import 'common/macro_caption.html.twig' as macro_caption %} {% set can_edit = granted_on_collection(record.baseId, [constant('\\ACL::CANMODIFRECORD')]) %} {% set can_see_business = can_edit %} @@ -17,8 +17,4 @@ {% endfor %}
-{% if record.is_from_reg() %} - {{macro.caption(record, can_see_business)}} -{% else %} - {{macro.caption(record, can_see_business)}} -{% endif %} \ No newline at end of file +{{macro_caption.caption(record, can_see_business)}} diff --git a/templates/web/prod/results/list.html.twig b/templates/web/prod/results/list.html.twig index 790a4c2414..ca45b67914 100644 --- a/templates/web/prod/results/list.html.twig +++ b/templates/web/prod/results/list.html.twig @@ -1,4 +1,4 @@ -{% import 'common/macros.html.twig' as macro %} +{% import 'common/macro_caption.html.twig' as macro_caption %} {% block content_item %}
@@ -14,7 +14,7 @@
{% set can_see_business = granted_on_collection(record.baseId, [constant('\\ACL::CANMODIFRECORD')]) %} - {{ macro.caption(record, can_see_business) }} + {{ macro_caption.caption(record, can_see_business) }}
diff --git a/templates/web/prod/results/record.html.twig b/templates/web/prod/results/record.html.twig index 2d537dd72c..3707633998 100644 --- a/templates/web/prod/results/record.html.twig +++ b/templates/web/prod/results/record.html.twig @@ -1,5 +1,5 @@ {% import 'prod/results/macro.html.twig' as result_macro %} -{% import 'common/macros.html.twig' as macro %} +{% import 'common/macro_caption.html.twig' as macro_caption %}