templates/pages/_includes/details/_gallery-modal.html.twig line 1

Open in your IDE?
  1. {% set shipEntityLabel = cruise.ship.name|default(cruise.ship.title|default('')) %}
  2. {% set shipPool = [] %}
  3. {% for media in shipMedias|default([]) %}
  4. {% if media.extension|default('')|lower != 'link' and (media.cdnUrl is not empty or media.url is not empty) %}
  5. {% set shipPool = shipPool|merge([media]) %}
  6. {% endif %}
  7. {% endfor %}
  8. {# Index media → escale (même jeu que stopoversMedias côté visionneuse) #}
  9. {% set stopoverEntityLabels = {} %}
  10. {% for stopover in getCruiseStopovers(cruise)|default([]) %}
  11. {% set stopoverEntityLabel = stopover.name|default(stopover.title|default('')) %}
  12. {% for media in crea_media_get_medias([], stopover)|default([]) %}
  13. {% if media.id is defined and media.id is not null %}
  14. {% set stopoverEntityLabels = stopoverEntityLabels|merge({ (media.id ~ ''): stopoverEntityLabel }) %}
  15. {% endif %}
  16. {% set labelMediaPath = media.cdnUrl|default(media.url|default('')) %}
  17. {% if labelMediaPath is not empty %}
  18. {% set stopoverEntityLabels = stopoverEntityLabels|merge({ (labelMediaPath): stopoverEntityLabel }) %}
  19. {% endif %}
  20. {% endfor %}
  21. {% endfor %}
  22. {% set stopoverImages = [] %}
  23. {% for media in stopoversMedias|default([]) %}
  24. {% if media.extension|default('')|lower != 'link' and (media.cdnUrl is not empty or media.url is not empty) %}
  25. {% set mediaPath = media.cdnUrl|default(media.url|default('')) %}
  26. {% set mediaId = media.id|default(null) %}
  27. {% set entityLabel = mediaId ? attribute(stopoverEntityLabels, mediaId ~ '')|default('') : '' %}
  28. {% if entityLabel is empty %}
  29. {% set entityLabel = attribute(stopoverEntityLabels, mediaPath)|default('') %}
  30. {% endif %}
  31. {% set stopoverImages = stopoverImages|merge([{
  32. id: mediaId,
  33. path: mediaPath,
  34. alt: media.title|default(entityLabel)|default('Image escale'),
  35. entityLabel: entityLabel,
  36. }]) %}
  37. {% endif %}
  38. {% endfor %}
  39. {% set cabinPool = [] %}
  40. {% for media in shipPool %}
  41. {% set hasBoardingLifeTag = false %}
  42. {% for mediaTag in media.tags|default([]) %}
  43. {% set tagName = mediaTag.name|default(mediaTag.slug|default(mediaTag|default('')))|lower %}
  44. {% if tagName == 'boarding_life' %}
  45. {% set hasBoardingLifeTag = true %}
  46. {% endif %}
  47. {% endfor %}
  48. {% if hasBoardingLifeTag %}
  49. {% set cabinPool = cabinPool|merge([media]) %}
  50. {% endif %}
  51. {% endfor %}
  52. {% set gallery = {} %}
  53. {% if shipPool is not empty %}
  54. {% set shipImages = [] %}
  55. {% for media in shipPool %}
  56. {% set mediaPath = media.cdnUrl|default(media.url|default('')) %}
  57. {% set shipImages = shipImages|merge([{
  58. id: media.id|default(null),
  59. path: mediaPath,
  60. alt: media.title|default(shipEntityLabel)|default('Image navire'),
  61. entityLabel: shipEntityLabel,
  62. }]) %}
  63. {% endfor %}
  64. {% set gallery = gallery|merge({
  65. ship: {
  66. tab: 'Navire',
  67. count: shipImages|length,
  68. images: shipImages
  69. }
  70. }) %}
  71. {% endif %}
  72. {% if stopoverImages is not empty %}
  73. {% set gallery = gallery|merge({
  74. stopovers: {
  75. tab: 'Escales',
  76. count: stopoverImages|length,
  77. images: stopoverImages
  78. }
  79. }) %}
  80. {% endif %}
  81. {% if cabinPool is not empty %}
  82. {% set cabinImages = [] %}
  83. {% for media in cabinPool %}
  84. {% set mediaPath = media.cdnUrl|default(media.url|default('')) %}
  85. {% set cabinImages = cabinImages|merge([{
  86. id: media.id|default(null),
  87. path: mediaPath,
  88. alt: media.title|default(shipEntityLabel)|default('Image cabine'),
  89. entityLabel: shipEntityLabel,
  90. }]) %}
  91. {% endfor %}
  92. {% set gallery = gallery|merge({
  93. cabin: {
  94. tab: 'Cabine',
  95. count: cabinImages|length,
  96. images: cabinImages
  97. }
  98. }) %}
  99. {% endif %}
  100. <div id="box-viewer" role="dialog" aria-modal="true">
  101. <div class="modale-inner">
  102. <nav>
  103. <div class="modale-title text-lg-sbd color-secondary-dark">
  104. <div>{{ getLucidIcon('grip-vertical') }}
  105. {{ 'details.gallery.title'|trans }} :
  106. {{ getCruiseName(cruise)|default('') }}</div>
  107. {% include 'pages/_includes/modals/_modale_closer.html.twig' with { closer_id: 'close-gallery' } %}
  108. </div>
  109. </nav>
  110. <div class="box">
  111. <div class="navbar">
  112. <ul>
  113. {% for key, category in gallery %}
  114. {% if category.tab is defined %}
  115. <li class="text-sm">
  116. <button class="gallery-tab br1 text-sm-{% if loop.first %}bd active {% else %}rg{% endif %}" data-category="{{ key }}" data-count="{{ category.count|default(0) }}">
  117. {{ category.tab }}
  118. {% if category.count|default(0) > 0 and key != 'map' %}
  119. ({{ category.count }})
  120. {% endif %}
  121. </button>
  122. </li>
  123. {% endif %}
  124. {% endfor %}
  125. </ul>
  126. </div>
  127. <div class="carousel-wrapper" id="gallery-carousel-wrapper">
  128. <div class="carousel-container">
  129. <div class="carousel" id="gallery-carousel"></div>
  130. </div>
  131. <button class="carousel-arrow left" aria-label="{{ 'common.previous'|trans }}">{{ getLucidIcon('chevron-left') }}</button>
  132. <button class="carousel-arrow right" aria-label="{{ 'common.next'|trans }}">{{ getLucidIcon('chevron-right') }}</button>
  133. </div>
  134. <div id="gallery-map-container" style="display: none;">
  135. <div id="gallery-map" class="leaflet-map" style="height: 100%; width: 100%;"></div>
  136. </div>
  137. <div class="carousel-thumbnails" id="gallery-thumbnails"></div>
  138. </div>
  139. </div>
  140. </div>
  141. <script type="application/json" data-gallery>
  142. {{ gallery|json_encode|raw }}
  143. </script>