Vinoteca: wine shop on 1C-Bitrix (module, template, components, pages)

This commit is contained in:
jimagie committed 2026-10-22 19:35:23 +05:00
commit 0590195880
593 files changed
+27942

No files matched your search

@@ -0,0 +1,9 @@
<?php
if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
die();
}
if (!empty($arResult["VINO_PRELOAD"])) {
$APPLICATION->AddHeadString('<link rel="preload" as="image" href="' . htmlspecialcharsbx($arResult["VINO_PRELOAD"]) . '" media="(max-width: 1023px)">');
}
$APPLICATION->AddHeadString('<link rel="preload" as="image" href="' . SITE_TEMPLATE_PATH . '/assets/media/hero-poster.webp?v=6" media="(min-width: 1024px)">');
@@ -0,0 +1,3 @@
<?php
$MESS["VINO_HERO_PAUSE"] = "Pause video";
$MESS["VINO_HERO_PLAY"] = "Play video";
@@ -0,0 +1,3 @@
<?php
$MESS["VINO_HERO_PAUSE"] = "Zatrzymaj wideo";
$MESS["VINO_HERO_PLAY"] = "Odtwórz wideo";
@@ -0,0 +1,3 @@
<?php
$MESS["VINO_HERO_PAUSE"] = "Остановить видео";
$MESS["VINO_HERO_PLAY"] = "Включить видео";
@@ -0,0 +1,18 @@
<?php
if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
die();
}
foreach ($arResult["ITEMS"] as $index => $item) {
$arResult["ITEMS"][$index] = \Jinove\Vinoteca\Catalog\LocalizedText::localizeItem($item, array("PREVIEW_TEXT"), array("KICKER", "LINK_TEXT"));
}
foreach ($arResult["ITEMS"] as &$item) {
$link = trim((string)($item["PROPERTIES"]["LINK"]["VALUE"] ?? ""));
$item["VINO_LINK"] = str_starts_with($link, "/") && !str_starts_with($link, "//") ? SITE_DIR . ltrim($link, "/") : $link;
}
unset($item);
$first = reset($arResult["ITEMS"]);
$arResult["VINO_PRELOAD"] = $first ? (string)($first["PREVIEW_PICTURE"]["SRC"] ?? "") : "";
$this->__component->SetResultCacheKeys(array("VINO_PRELOAD"));
@@ -0,0 +1,23 @@
(function () {
function init() {
var v = document.querySelector('.vino-hero__video');
if (!v || !window.matchMedia('(min-width:981px)').matches) return;
if (window.matchMedia('(prefers-reduced-motion: reduce)').matches) return;
v.muted = true;
function play() { var r = v.play(); if (r && r.catch) r.catch(function () {}); }
function load() {
if (v.dataset.loaded) return;
var src = v.getAttribute('data-src');
if (!src) return;
v.dataset.loaded = '1';
v.setAttribute('preload', 'auto');
v.src = src;
v.load();
play();
}
load();
document.addEventListener('click', function () { load(); play(); }, { once: true });
document.addEventListener('visibilitychange', function () { if (!document.hidden) { load(); play(); } });
}
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', init); else init();
})();
@@ -0,0 +1,36 @@
<?php if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) die();
if (empty($arResult["ITEMS"])) return;
$media = SITE_TEMPLATE_PATH . "/assets/media/";
$editLink = CIBlock::GetArrayByID($arParams["IBLOCK_ID"], "ELEMENT_EDIT");
$deleteLink = CIBlock::GetArrayByID($arParams["IBLOCK_ID"], "ELEMENT_DELETE");
?>
<section class="vino-hero" data-slider="hero">
<video class="vino-hero__video" muted loop playsinline preload="none" poster="<?= $media ?>hero-poster.webp?v=6" data-src="<?= $media ?>wine-pour.mp4?v=2"></video>
<?php foreach ($arResult["ITEMS"] as $arItem):
$this->AddEditAction($arItem["ID"], $arItem["EDIT_LINK"], $editLink);
$this->AddDeleteAction($arItem["ID"], $arItem["DELETE_LINK"], $deleteLink);
$prop = $arItem["PROPERTIES"];
$linkText = trim((string)($prop["LINK_TEXT"]["~VALUE"] ?? ""));
$kicker = trim((string)($prop["KICKER"]["~VALUE"] ?? ""));
?>
<a class="vino-hero__panel" id="<?= $this->GetEditAreaId($arItem["ID"]) ?>" href="<?= htmlspecialcharsbx($arItem["VINO_LINK"]) ?>">
<?php if (!empty($arItem["PREVIEW_PICTURE"]["SRC"])): ?><span class="vino-hero__img" style="--img:url('<?= $arItem["PREVIEW_PICTURE"]["SRC"] ?>')"></span><?php endif; ?>
<span class="vino-hero__veil"></span>
<span class="vino-hero__content">
<?php if ($kicker !== ""): ?><span class="vino-hero__kicker"><?= htmlspecialcharsbx($kicker) ?></span><?php endif; ?>
<span class="vino-hero__title"><?= htmlspecialcharsbx($arItem["~NAME"]) ?></span>
<span class="vino-hero__rule"></span>
<?php if ($arItem["PREVIEW_TEXT"] !== ""): ?><span class="vino-hero__desc"><?= htmlspecialcharsbx($arItem["~PREVIEW_TEXT"]) ?></span><?php endif; ?>
<?php if ($linkText !== ""): ?><span class="vino-hero__cta vino-link"><?= htmlspecialcharsbx($linkText) ?></span><?php endif; ?>
</span>
</a>
<?php endforeach; ?>
<span class="vino-hero__grain" aria-hidden="true"></span>
</section>
<?php if (count($arResult["ITEMS"]) > 1): ?>
<div class="vino-dots vino-dots--overlay" data-slider-dots="hero">
<?php foreach ($arResult["ITEMS"] as $i => $arItem): ?>
<button type="button" class="vino-dots__dot<?= $i ? "" : " vino-dots__dot--active" ?>" aria-label="<?= htmlspecialcharsbx($arItem["~NAME"]) ?>"<?= $i ? "" : ' aria-current="true"' ?>></button>
<?php endforeach; ?>
</div>
<?php endif; ?>
@@ -0,0 +1,4 @@
<?php
$MESS["VINO_BRANDS_KICKER"] = "Collection";
$MESS["VINO_BRANDS_TITLE"] = "Brands in the catalogue";
$MESS["VINO_BRANDS_ALL"] = "All brands";
@@ -0,0 +1,4 @@
<?php
$MESS["VINO_BRANDS_KICKER"] = "Kolekcja";
$MESS["VINO_BRANDS_TITLE"] = "Marki w katalogu";
$MESS["VINO_BRANDS_ALL"] = "Wszystkie marki";
@@ -0,0 +1,4 @@
<?php
$MESS["VINO_BRANDS_KICKER"] = "Коллекция";
$MESS["VINO_BRANDS_TITLE"] = "Бренды в каталоге";
$MESS["VINO_BRANDS_ALL"] = "Все бренды";
@@ -0,0 +1,12 @@
<?php
use Bitrix\Iblock\ElementTable;
if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
die();
}
foreach ($arResult["ITEMS"] as $index => $item) {
$arResult["ITEMS"][$index] = \Jinove\Vinoteca\Catalog\LocalizedText::localizeItem($item, array("PREVIEW_TEXT"), array("COUNTRY", "REGION", "GRAPE"));
}
$arResult["VINO_TOTAL"] = ElementTable::getCount(array("=IBLOCK_ID" => (int)$arResult["ID"], "=ACTIVE" => "Y"));
@@ -0,0 +1,49 @@
<?php
use Bitrix\Main\Localization\Loc;
if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
die();
}
if (empty($arResult["ITEMS"])) {
return;
}
$pages = array_chunk($arResult["ITEMS"], 4);
$editLink = CIBlock::GetArrayByID($arResult["ID"], "ELEMENT_EDIT");
$deleteLink = CIBlock::GetArrayByID($arResult["ID"], "ELEMENT_DELETE");
?>
<section class="vino-section vino-brands">
<div class="vino-wrap vino-section__inner">
<div class="vino-section__head">
<div class="vino-section__intro">
<p class="vino-kicker"><?= Loc::getMessage("VINO_BRANDS_KICKER") ?></p>
<h2 class="vino-section__title"><?= Loc::getMessage("VINO_BRANDS_TITLE") ?></h2>
</div>
<div class="vino-slider__head-actions vino-section__all">
<a class="vino-section__more" href="<?= htmlspecialcharsbx(preg_replace("#/{2,}#", "/", CComponentEngine::makePathFromTemplate($arResult["~LIST_PAGE_URL"] ?? $arResult["LIST_PAGE_URL"]))) ?>"><?= Loc::getMessage("VINO_BRANDS_ALL") ?> <span class="vino-section__count"><?= (int)$arResult["VINO_TOTAL"] ?></span></a>
</div>
</div>
<div class="vino-brands-plain vino-section__body">
<div class="vino-brands__grid vino-brands__grid--slider" data-slider="brands">
<?php foreach ($pages as $page): ?>
<div class="vino-brands__page">
<?php foreach ($page as $item):
$this->AddEditAction($item["ID"], $item["EDIT_LINK"], $editLink);
$this->AddDeleteAction($item["ID"], $item["DELETE_LINK"], $deleteLink);
$place = implode(" · ", array_filter(array($item["PROPERTIES"]["COUNTRY"]["~VALUE"] ?? "", $item["PROPERTIES"]["REGION"]["~VALUE"] ?? "")));
?>
<a class="vino-brands__item<?= !empty($item["PREVIEW_PICTURE"]["SRC"]) ? " vino-brands__item--logo" : "" ?>" id="<?= $this->GetEditAreaId($item["ID"]) ?>" href="<?= htmlspecialcharsbx($item["DETAIL_PAGE_URL"]) ?>"><?php if (!empty($item["PREVIEW_PICTURE"]["SRC"])): ?><img class="vino-brands__logo" src="<?= $item["PREVIEW_PICTURE"]["SRC"] ?>" width="<?= (int)$item["PREVIEW_PICTURE"]["WIDTH"] ?>" height="<?= (int)$item["PREVIEW_PICTURE"]["HEIGHT"] ?>" alt="" loading="lazy" decoding="async"><?php endif; ?><strong class="vino-brands__name"><?= $item["NAME"] ?></strong><span class="vino-brands__meta"><?= htmlspecialcharsbx($place) ?></span></a>
<?php endforeach; ?>
</div>
<?php endforeach; ?>
</div>
<?php if (count($pages) > 1): ?>
<div class="vino-dots vino-dots--lines vino-brands__dots" data-slider-dots="brands">
<?php foreach ($pages as $i => $page): ?>
<button type="button" class="vino-dots__dot<?= $i ? "" : " vino-dots__dot--active" ?>" aria-label="<?= htmlspecialcharsbx(implode(", ", array_column($page, "~NAME"))) ?>"<?= $i ? "" : ' aria-current="true"' ?>></button>
<?php endforeach; ?>
</div>
<?php endif; ?>
</div>
</div>
</section>
@@ -0,0 +1,17 @@
<?php
if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
die();
}
$schemaItems = array();
foreach ($arResult["ITEMS"] as $index => $item) {
$arResult["ITEMS"][$index] = \Jinove\Vinoteca\News::card($item);
$schemaItems[] = array("name" => (string)$arResult["ITEMS"][$index]["~NAME"], "url" => VINO_HOST . $item["DETAIL_PAGE_URL"]);
}
$page = (int)($arResult["NAV_RESULT"] ? $arResult["NAV_RESULT"]->NavPageNomer : 1);
$arResult["VINO_SCHEMA"] = \Jinove\Vinoteca\ArticleSchema::list(
$schemaItems,
\Jinove\Vinoteca\News::folder() . ($page > 1 ? "?PAGEN_1=" . $page : ""),
(string)$GLOBALS["APPLICATION"]->GetPageProperty("title"),
(string)$GLOBALS["APPLICATION"]->GetPageProperty("description")
);
@@ -0,0 +1,66 @@
(function (run) {
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', run);
else run();
})(function () {
var request = 0;
function box() {
return document.querySelector('[data-news-feed]');
}
function canRequest() {
return !!(window.BX && BX.ajax && BX.ajax.runAction);
}
function pageOf(url) {
var page = parseInt(url.searchParams.get('PAGEN_1') || '1', 10);
return page > 0 ? page : 1;
}
function load(url, push) {
var current = box();
if (!current || !canRequest()) {
window.location.href = url.href;
return;
}
var id = ++request;
current.setAttribute('aria-busy', 'true');
BX.ajax.runAction('jinove:vinoteca.news.page', { method: 'GET', getParameters: { PAGEN_1: pageOf(url) } })
.then(function (response) {
if (id !== request) return;
var doc = document.createElement('template');
doc.innerHTML = response.data.html;
var next = doc.content.querySelector('[data-news-feed]');
if (!next) throw new Error('content');
if (push) history.pushState({ vinoNews: true }, '', url.href);
current.innerHTML = next.innerHTML;
current.removeAttribute('aria-busy');
if (response.data.componentResult && response.data.componentResult.title) {
document.title = response.data.componentResult.title;
}
document.dispatchEvent(new CustomEvent('vino:content', { detail: { root: current } }));
var first = current.querySelector('.vino-news__link');
if (first) first.focus({ preventScroll: true });
var top = current.getBoundingClientRect().top;
if (top < 0) window.scrollTo({ top: window.scrollY + top - 120, behavior: 'smooth' });
})
.catch(function () {
if (id === request) window.location.href = url.href;
});
}
document.addEventListener('click', function (event) {
var link = event.target.closest('[data-news-feed] .vino-pager a');
if (!link || event.defaultPrevented || event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return;
event.preventDefault();
load(new URL(link.href, window.location.href), true);
});
window.addEventListener('popstate', function (event) {
if (event.state && event.state.vinoNews) load(new URL(window.location.href), false);
});
if (box() && !(history.state && history.state.vinoNews)) {
history.replaceState({ vinoNews: true }, '', window.location.href);
}
});
@@ -0,0 +1,24 @@
.vino-news-feed__content {
transition: opacity var(--duration-fast) var(--ease-base);
}
.vino-news-feed__content[aria-busy="true"] {
opacity: .45;
pointer-events: none;
}
.vino-news-feed .vino-news__grid--feed {
row-gap: var(--space-12);
}
@media (min-width:761px) {
.vino-news-feed .vino-news__grid--feed {
grid-template-columns: repeat(2, minmax(0, 1fr));
column-gap: var(--space-12);
}
.vino-news__grid--feed .vino-news__title {
font-size: var(--vino-news-feed-title-size);
}
}
@media (max-width:760px) {
.vino-news-feed .vino-news__grid--feed {
row-gap: var(--space-10);
}
}
@@ -0,0 +1,26 @@
<?php
if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
die();
}
$editLink = CIBlock::GetArrayByID($arParams["IBLOCK_ID"], "ELEMENT_EDIT");
$deleteLink = CIBlock::GetArrayByID($arParams["IBLOCK_ID"], "ELEMENT_DELETE");
?>
<div class="vino-news-feed__content" data-news-feed aria-live="polite">
<div class="vino-news__grid vino-news__grid--feed">
<?php foreach ($arResult["ITEMS"] as $index => $item):
$this->AddEditAction($item["ID"], $item["EDIT_LINK"], $editLink);
$this->AddDeleteAction($item["ID"], $item["DELETE_LINK"], $deleteLink);
$picture = $item["VINO_PICTURE"];
?>
<article class="vino-news__card" id="<?= $this->GetEditAreaId($item["ID"]) ?>">
<?php if ($picture): ?><a class="vino-news__media" href="<?= $item["DETAIL_PAGE_URL"] ?>" tabindex="-1" aria-hidden="true"><img class="vino-news__img" src="<?= $picture["SRC"] ?>" srcset="<?= $picture["SRCSET"] ?>" sizes="(max-width: 760px) calc(100vw - 32px), 620px" width="<?= $picture["WIDTH"] ?>" height="<?= $picture["HEIGHT"] ?>" alt="<?= htmlspecialcharsbx($picture["ALT"]) ?>"<?= $index > 1 ? ' loading="lazy"' : ($index === 0 ? ' fetchpriority="high"' : "") ?> decoding="async"></a><?php endif; ?>
<?php if ($item["VINO_DATE"]): ?><time class="vino-news__date" datetime="<?= $item["VINO_DATE"]["ISO"] ?>"><?= $item["VINO_DATE"]["TEXT"] ?></time><?php endif; ?>
<h2 class="vino-news__title"><a class="vino-news__link" href="<?= $item["DETAIL_PAGE_URL"] ?>"><?= htmlspecialcharsbx($item["~NAME"]) ?></a></h2>
<?php if ((string)$item["~PREVIEW_TEXT"] !== ""): ?><p class="vino-news__text"><?= htmlspecialcharsbx($item["~PREVIEW_TEXT"]) ?></p><?php endif; ?>
</article>
<?php endforeach; ?>
</div>
<?= $arResult["NAV_STRING"] ?>
</div>
<?php if (($arParams["VINO_AJAX"] ?? "N") !== "Y"): ?><script type="application/ld+json"><?= json_encode($arResult["VINO_SCHEMA"], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_HEX_TAG | JSON_HEX_AMP) ?></script><?php endif; ?>
@@ -0,0 +1,8 @@
<?php
if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
die();
}
foreach ($arResult["ITEMS"] as $index => $item) {
$arResult["ITEMS"][$index] = \Jinove\Vinoteca\News::card($item);
}
@@ -0,0 +1,19 @@
<?php if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) die();
if (empty($arResult["ITEMS"])) return;
$editLink = CIBlock::GetArrayByID($arParams["IBLOCK_ID"], "ELEMENT_EDIT");
$deleteLink = CIBlock::GetArrayByID($arParams["IBLOCK_ID"], "ELEMENT_DELETE");
?>
<div class="vino-news__grid">
<?php foreach ($arResult["ITEMS"] as $i => $arItem):
$this->AddEditAction($arItem["ID"], $arItem["EDIT_LINK"], $editLink);
$this->AddDeleteAction($arItem["ID"], $arItem["DELETE_LINK"], $deleteLink);
$pic = $arItem["VINO_PICTURE"];
?>
<article class="vino-news__card<?= $i ? " vino-news__card--compact" : "" ?>" id="<?= $this->GetEditAreaId($arItem["ID"]) ?>">
<?php if ($pic): ?><a class="vino-news__media" href="<?= $arItem["DETAIL_PAGE_URL"] ?>" tabindex="-1" aria-hidden="true"><img class="vino-news__img" loading="lazy" decoding="async" src="<?= $pic["SRC"] ?>" srcset="<?= $pic["SRCSET"] ?>" sizes="(max-width: 760px) <?= $i ? "150px" : "calc(100vw - 32px)" ?>, 400px" width="<?= $pic["WIDTH"] ?>" height="<?= $pic["HEIGHT"] ?>" alt="<?= htmlspecialcharsbx($pic["ALT"]) ?>"></a><?php endif; ?>
<?php if ($arItem["VINO_DATE"]): ?><time class="vino-news__date" datetime="<?= $arItem["VINO_DATE"]["ISO"] ?>"><?= $arItem["VINO_DATE"]["TEXT"] ?></time><?php endif; ?>
<h3 class="vino-news__title"><a class="vino-news__link" href="<?= $arItem["DETAIL_PAGE_URL"] ?>"><?= htmlspecialcharsbx($arItem["~NAME"]) ?></a></h3>
<?php if ((string)$arItem["~PREVIEW_TEXT"] !== ""): ?><p class="vino-news__text"><?= htmlspecialcharsbx($arItem["~PREVIEW_TEXT"]) ?></p><?php endif; ?>
</article>
<?php endforeach; ?>
</div>
@@ -0,0 +1,2 @@
<?php
$MESS["VINO_OFFERS_CODE"] = "Promo code";
@@ -0,0 +1,2 @@
<?php
$MESS["VINO_OFFERS_CODE"] = "Kod rabatowy";
@@ -0,0 +1,2 @@
<?php
$MESS["VINO_OFFERS_CODE"] = "Промокод";
@@ -0,0 +1,21 @@
<?php
if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
die();
}
$schemaItems = array();
foreach ($arResult["ITEMS"] as $index => $item) {
$arResult["ITEMS"][$index] = \Jinove\Vinoteca\Offers::card($item);
if (!$arResult["ITEMS"][$index]["VINO_OFFER"]["active"]) {
unset($arResult["ITEMS"][$index]);
continue;
}
$schemaItems[] = array("name" => (string)$arResult["ITEMS"][$index]["~NAME"], "url" => VINO_HOST . $item["DETAIL_PAGE_URL"]);
}
$arResult["ITEMS"] = array_values($arResult["ITEMS"]);
$arResult["VINO_SCHEMA"] = \Jinove\Vinoteca\OfferSchema::list(
$schemaItems,
\Jinove\Vinoteca\Offers::folder(),
(string)$GLOBALS["APPLICATION"]->GetPageProperty("title"),
(string)$GLOBALS["APPLICATION"]->GetPageProperty("description")
);
@@ -0,0 +1,130 @@
.vino-offers {
--vino-offers-gap: var(--space-8);
--vino-offers-pad: var(--space-8);
--vino-offers-title-size: 1.75rem;
--vino-offers-title-wide-size: var(--fs-h3);
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: var(--vino-offers-gap);
}
.vino-offers__card {
position: relative;
display: flex;
flex-direction: column;
border: 1px solid var(--color-line);
background: var(--color-bg-soft);
transition: border-color var(--duration-fast) var(--ease-base);
}
.vino-offers__card--wide {
grid-column: 1 / -1;
flex-direction: row;
}
.vino-offers__media {
display: block;
aspect-ratio: 16 / 9;
overflow: hidden;
}
.vino-offers__card--wide .vino-offers__media {
flex: 0 0 58%;
aspect-ratio: 16 / 10;
}
.vino-offers__img {
display: block;
width: 100%;
height: 100%;
object-fit: cover;
opacity: .85;
transition: opacity var(--duration-fast) var(--ease-base), transform var(--duration-soft) var(--ease-base);
}
.vino-offers__body {
display: flex;
flex: 1;
flex-direction: column;
align-items: flex-start;
gap: var(--space-4);
padding: var(--vino-offers-pad);
}
.vino-offers__card--wide .vino-offers__body {
justify-content: center;
}
.vino-offers__title {
margin: 0;
font-family: var(--font-serif);
font-size: var(--vino-offers-title-size);
font-weight: 400;
line-height: var(--leading-title);
transition: color var(--duration-fast) var(--ease-base);
}
.vino-offers__card--wide .vino-offers__title {
font-size: var(--vino-offers-title-wide-size);
}
.vino-offers__link {
color: inherit;
}
.vino-offers__link::after {
content: "";
position: absolute;
inset: 0;
}
.vino-offers__text {
display: -webkit-box;
overflow: hidden;
margin: 0;
color: var(--color-text-muted);
font-size: var(--text-base);
line-height: var(--leading-long);
-webkit-box-orient: vertical;
-webkit-line-clamp: 3;
}
.vino-offers__meta {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: var(--space-3) var(--space-5);
margin: auto 0 0;
padding-top: var(--space-2);
color: var(--color-text-faint);
font-size: var(--text-13);
letter-spacing: var(--tracking-xs);
}
.vino-offers__code {
position: relative;
z-index: 1;
padding: var(--space-1) var(--space-3);
border: 1px dashed color-mix(in srgb, var(--color-accent) 55%, transparent);
color: var(--color-text-muted);
}
.vino-offers__code-value {
color: var(--color-accent);
font-weight: 600;
}
@media (hover:hover) {
.vino-offers__card:hover {
border-color: color-mix(in srgb, var(--color-accent) 45%, transparent);
}
.vino-offers__card:hover .vino-offers__img {
opacity: 1;
transform: scale(1.04);
}
.vino-offers__card:hover .vino-offers__title {
color: var(--color-accent);
}
}
@media (max-width:980px) {
.vino-offers__card--wide {
flex-direction: column;
}
.vino-offers__card--wide .vino-offers__media {
flex: none;
aspect-ratio: 16 / 9;
}
}
@media (max-width:760px) {
.vino-offers {
--vino-offers-gap: var(--space-6);
--vino-offers-pad: var(--space-6);
--vino-offers-title-size: 1.5rem;
--vino-offers-title-wide-size: 1.75rem;
grid-template-columns: 1fr;
}
}
@@ -0,0 +1,39 @@
<?php
use Bitrix\Main\Localization\Loc;
if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
die();
}
if (empty($arResult["ITEMS"])) {
return;
}
$editLink = CIBlock::GetArrayByID($arParams["IBLOCK_ID"], "ELEMENT_EDIT");
$deleteLink = CIBlock::GetArrayByID($arParams["IBLOCK_ID"], "ELEMENT_DELETE");
?>
<div class="vino-offers">
<?php foreach ($arResult["ITEMS"] as $index => $item):
$this->AddEditAction($item["ID"], $item["EDIT_LINK"], $editLink);
$this->AddDeleteAction($item["ID"], $item["DELETE_LINK"], $deleteLink);
$picture = $item["VINO_PICTURE"];
$offer = $item["VINO_OFFER"];
?>
<article class="vino-offers__card<?= $index === 0 ? " vino-offers__card--wide" : "" ?>" id="<?= $this->GetEditAreaId($item["ID"]) ?>">
<?php if ($picture): ?>
<a class="vino-offers__media" href="<?= $item["DETAIL_PAGE_URL"] ?>" tabindex="-1" aria-hidden="true">
<img class="vino-offers__img" src="<?= $picture["SRC"] ?>" srcset="<?= $picture["SRCSET"] ?>" sizes="<?= $index === 0 ? "(max-width: 760px) calc(100vw - 32px), 760px" : "(max-width: 760px) calc(100vw - 32px), 620px" ?>" width="<?= $picture["WIDTH"] ?>" height="<?= $picture["HEIGHT"] ?>" alt="<?= htmlspecialcharsbx($picture["ALT"]) ?>"<?= $index === 0 ? ' fetchpriority="high"' : ' loading="lazy"' ?> decoding="async">
</a>
<?php endif; ?>
<div class="vino-offers__body">
<?php if ($offer["badge"] !== ""): ?><span class="vino-badge"><?= htmlspecialcharsbx($offer["badge"]) ?></span><?php endif; ?>
<h2 class="vino-offers__title"><a class="vino-offers__link" href="<?= $item["DETAIL_PAGE_URL"] ?>"><?= htmlspecialcharsbx($item["~NAME"]) ?></a></h2>
<?php if ((string)$item["~PREVIEW_TEXT"] !== ""): ?><p class="vino-offers__text"><?= htmlspecialcharsbx($item["~PREVIEW_TEXT"]) ?></p><?php endif; ?>
<p class="vino-offers__meta">
<span class="vino-offers__until"><?= htmlspecialcharsbx($item["VINO_UNTIL"]) ?></span>
<?php foreach ($offer["coupons"] as $coupon): ?><span class="vino-offers__code"><?= Loc::getMessage("VINO_OFFERS_CODE") ?> <b class="vino-offers__code-value"><?= htmlspecialcharsbx($coupon) ?></b></span><?php endforeach; ?>
</p>
</div>
</article>
<?php endforeach; ?>
</div>
<script type="application/ld+json"><?= json_encode($arResult["VINO_SCHEMA"], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_HEX_TAG | JSON_HEX_AMP) ?></script>
@@ -0,0 +1,27 @@
<?php
$MESS["VINO_REVIEWS_TITLE"] = 'Reviews';
$MESS["VINO_REVIEWS_AVG_LABEL"] = 'Average rating #VALUE# out of 5';
$MESS["VINO_REVIEWS_COUNT_PLURAL_0"] = '#COUNT# review';
$MESS["VINO_REVIEWS_COUNT_PLURAL_1"] = '#COUNT# reviews';
$MESS["VINO_REVIEWS_EMPTY"] = 'No reviews yet. The first review helps other customers choose a wine.';
$MESS["VINO_REVIEWS_WRITE"] = 'Write a review';
$MESS["VINO_REVIEWS_RATING_LABEL"] = 'Rated #VALUE# out of 5';
$MESS["VINO_REVIEWS_CLOSE"] = 'Close';
$MESS["VINO_REVIEWS_FORM_TITLE"] = 'Your review';
$MESS["VINO_REVIEWS_RATE"] = 'Your rating';
$MESS["VINO_REVIEWS_AUTHOR"] = 'Your name';
$MESS["VINO_REVIEWS_TEXT"] = 'What you liked, what you paired it with';
$MESS["VINO_REVIEWS_CONSENT"] = 'By clicking “#BUTTON#”, I agree to the processing of my <a class="vino-consent__link" href="#URL#" target="_blank">personal data</a> on the terms and for the purposes set out in the <a class="vino-consent__link" href="#PRIVACY_URL#" target="_blank">Privacy Policy</a>.';
$MESS["VINO_REVIEWS_SEND"] = 'Send review';
$MESS["VINO_REVIEWS_DONE_KICKER"] = 'Review sent';
$MESS["VINO_REVIEWS_DONE_TITLE"] = 'Thank you!';
$MESS["VINO_REVIEWS_DONE_TEXT"] = 'The review will appear on the page once it has been checked.';
$MESS["VINO_REVIEWS_ERR_RATING"] = 'Please rate the wine from 1 to 5.';
$MESS["VINO_REVIEWS_ERR_AUTHOR"] = 'Please enter your name.';
$MESS["VINO_REVIEWS_ERR_TEXT"] = 'Please write a review of at least 10 characters.';
$MESS["VINO_REVIEWS_ERR_CONSENT"] = 'Consent to personal data processing is required.';
$MESS["VINO_REVIEWS_ERR_TOO_OFTEN"] = 'The review has been sent. Another one can be left in a minute.';
$MESS["VINO_REVIEWS_ERR_COMMON"] = 'The review could not be sent. Please try again.';
$MESS["VINO_REVIEWS_LOGIN_TITLE"] = 'Sign in to leave a review';
$MESS["VINO_REVIEWS_LOGIN_LEAD"] = 'Only registered customers can publish reviews.';
$MESS["VINO_REVIEWS_ERR_ALTCHA"] = 'Verification failed. Please try again.';
@@ -0,0 +1,28 @@
<?php
$MESS["VINO_REVIEWS_TITLE"] = 'Opinie';
$MESS["VINO_REVIEWS_AVG_LABEL"] = 'Średnia ocena #VALUE# na 5';
$MESS["VINO_REVIEWS_COUNT_PLURAL_0"] = '#COUNT# opinia';
$MESS["VINO_REVIEWS_COUNT_PLURAL_1"] = '#COUNT# opinie';
$MESS["VINO_REVIEWS_COUNT_PLURAL_2"] = '#COUNT# opinii';
$MESS["VINO_REVIEWS_EMPTY"] = 'Nie ma jeszcze opinii. Pierwsza opinia pomoże innym klientom wybrać wino.';
$MESS["VINO_REVIEWS_WRITE"] = 'Napisz opinię';
$MESS["VINO_REVIEWS_RATING_LABEL"] = 'Ocena #VALUE# na 5';
$MESS["VINO_REVIEWS_CLOSE"] = 'Zamknij';
$MESS["VINO_REVIEWS_FORM_TITLE"] = 'Twoja opinia';
$MESS["VINO_REVIEWS_RATE"] = 'Twoja ocena';
$MESS["VINO_REVIEWS_AUTHOR"] = 'Twoje imię';
$MESS["VINO_REVIEWS_TEXT"] = 'Co smakowało, do czego pasowało wino';
$MESS["VINO_REVIEWS_CONSENT"] = 'Klikając „#BUTTON#”, wyrażam zgodę na przetwarzanie moich <a class="vino-consent__link" href="#URL#" target="_blank">danych osobowych</a> na warunkach i w celach określonych w <a class="vino-consent__link" href="#PRIVACY_URL#" target="_blank">Polityce prywatności</a>.';
$MESS["VINO_REVIEWS_SEND"] = 'Wyślij opinię';
$MESS["VINO_REVIEWS_DONE_KICKER"] = 'Opinia wysłana';
$MESS["VINO_REVIEWS_DONE_TITLE"] = 'Dziękujemy!';
$MESS["VINO_REVIEWS_DONE_TEXT"] = 'Opinia pojawi się na stronie po sprawdzeniu.';
$MESS["VINO_REVIEWS_ERR_RATING"] = 'Oceń wino w skali od 1 do 5.';
$MESS["VINO_REVIEWS_ERR_AUTHOR"] = 'Podaj imię.';
$MESS["VINO_REVIEWS_ERR_TEXT"] = 'Napisz opinię: co najmniej 10 znaków.';
$MESS["VINO_REVIEWS_ERR_CONSENT"] = 'Wymagana jest zgoda na przetwarzanie danych osobowych.';
$MESS["VINO_REVIEWS_ERR_TOO_OFTEN"] = 'Opinia została wysłana. Kolejną można dodać za minutę.';
$MESS["VINO_REVIEWS_ERR_COMMON"] = 'Nie udało się wysłać opinii. Spróbuj ponownie.';
$MESS["VINO_REVIEWS_LOGIN_TITLE"] = 'Zaloguj się, aby dodać opinię';
$MESS["VINO_REVIEWS_LOGIN_LEAD"] = 'Opinie mogą publikować tylko zarejestrowani klienci.';
$MESS["VINO_REVIEWS_ERR_ALTCHA"] = 'Weryfikacja nieudana. Spróbuj ponownie.';
@@ -0,0 +1,28 @@
<?php
$MESS["VINO_REVIEWS_TITLE"] = 'Отзывы';
$MESS["VINO_REVIEWS_AVG_LABEL"] = 'Средняя оценка #VALUE# из 5';
$MESS["VINO_REVIEWS_COUNT_PLURAL_0"] = '#COUNT# отзыв';
$MESS["VINO_REVIEWS_COUNT_PLURAL_1"] = '#COUNT# отзыва';
$MESS["VINO_REVIEWS_COUNT_PLURAL_2"] = '#COUNT# отзывов';
$MESS["VINO_REVIEWS_EMPTY"] = 'Отзывов пока нет. Первый отзыв поможет другим покупателям выбрать вино.';
$MESS["VINO_REVIEWS_WRITE"] = 'Написать отзыв';
$MESS["VINO_REVIEWS_RATING_LABEL"] = 'Оценка #VALUE# из 5';
$MESS["VINO_REVIEWS_CLOSE"] = 'Закрыть';
$MESS["VINO_REVIEWS_FORM_TITLE"] = 'Ваш отзыв';
$MESS["VINO_REVIEWS_RATE"] = 'Ваша оценка';
$MESS["VINO_REVIEWS_AUTHOR"] = 'Ваше имя';
$MESS["VINO_REVIEWS_TEXT"] = 'Что понравилось, к какому блюду подавали';
$MESS["VINO_REVIEWS_CONSENT"] = 'Нажимая «#BUTTON#», я соглашаюсь на обработку <a class="vino-consent__link" href="#URL#" target="_blank">персональных данных</a> на условиях и для целей, определённых <a class="vino-consent__link" href="#PRIVACY_URL#" target="_blank">Политикой конфиденциальности</a>.';
$MESS["VINO_REVIEWS_SEND"] = 'Отправить отзыв';
$MESS["VINO_REVIEWS_DONE_KICKER"] = 'Отзыв отправлен';
$MESS["VINO_REVIEWS_DONE_TITLE"] = 'Спасибо!';
$MESS["VINO_REVIEWS_DONE_TEXT"] = 'Отзыв появится на странице после проверки.';
$MESS["VINO_REVIEWS_ERR_RATING"] = 'Поставьте оценку от 1 до 5.';
$MESS["VINO_REVIEWS_ERR_AUTHOR"] = 'Укажите имя.';
$MESS["VINO_REVIEWS_ERR_TEXT"] = 'Напишите отзыв: от 10 символов.';
$MESS["VINO_REVIEWS_ERR_CONSENT"] = 'Нужно согласие на обработку персональных данных.';
$MESS["VINO_REVIEWS_ERR_TOO_OFTEN"] = 'Отзыв уже отправлен. Следующий можно оставить через минуту.';
$MESS["VINO_REVIEWS_ERR_COMMON"] = 'Не удалось отправить отзыв. Попробуйте ещё раз.';
$MESS["VINO_REVIEWS_LOGIN_TITLE"] = 'Войдите, чтобы оставить отзыв';
$MESS["VINO_REVIEWS_LOGIN_LEAD"] = 'Отзывы публикуют только зарегистрированные покупатели.';
$MESS["VINO_REVIEWS_ERR_ALTCHA"] = 'Проверка не пройдена. Повторите попытку.';
@@ -0,0 +1,23 @@
<?php
if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
die();
}
$sum = 0;
$count = 0;
foreach ($arResult["ITEMS"] as $key => $item) {
$rating = max(0, min(5, (int)($item["PROPERTIES"]["RATING"]["VALUE"] ?? 0)));
$arResult["ITEMS"][$key]["VINO_RATING"] = $rating;
$arResult["ITEMS"][$key]["VINO_DATE"] = MakeTimeStamp($item["ACTIVE_FROM"] ?: $item["DATE_CREATE"]);
if ($rating > 0) {
$sum += $rating;
$count++;
}
}
$arResult["VINO_COUNT"] = $count;
$arResult["VINO_AVG"] = $count > 0 ? round($sum / $count, 1) : 0;
$summary = \Jinove\Vinoteca\Catalog\ReviewStats::summary((int)($arParams["VINO_PRODUCT_ID"] ?? 0));
if ($summary !== null) {
$arResult["VINO_COUNT"] = $summary["count"];
$arResult["VINO_AVG"] = $summary["avg"];
}
@@ -0,0 +1,105 @@
<?php
use Bitrix\Main\Localization\Loc;
if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
die();
}
$this->addExternalCss("/local/components/jinove/auth.login/templates/.default/style.css");
$this->addExternalJs("/local/components/jinove/auth.login/templates/.default/script.js");
$count = (int)$arResult["VINO_COUNT"];
$avg = (float)$arResult["VINO_AVG"];
$number = function (float $value): string {
return number_format($value, 1, LANGUAGE_ID === "en" ? "." : ",", "");
};
$stars = function (int $filled): string {
$out = "";
for ($i = 1; $i <= 5; $i++) {
$out .= '<span class="vino-stars__star' . ($i <= $filled ? " vino-stars__star--full" : "") . '"></span>';
}
return $out;
};
$editLink = CIBlock::GetArrayByID($arResult["ID"], "ELEMENT_EDIT");
$deleteLink = CIBlock::GetArrayByID($arResult["ID"], "ELEMENT_DELETE");
?>
<section class="vino-reviews" id="reviews" aria-labelledby="vino-reviews-title">
<div class="vino-wrap">
<div class="vino-reviews__head">
<h2 class="vino-reviews__title" id="vino-reviews-title"><?= Loc::getMessage("VINO_REVIEWS_TITLE") ?></h2>
<?php if ($count > 0): ?>
<p class="vino-reviews__summary">
<span class="vino-stars" role="img" aria-label="<?= Loc::getMessage("VINO_REVIEWS_AVG_LABEL", array("#VALUE#" => $number($avg))) ?>"><?= $stars((int)round($avg)) ?></span>
<b class="vino-reviews__avg"><?= $number($avg) ?></b>
<span class="vino-reviews__count"><?= Loc::getMessagePlural("VINO_REVIEWS_COUNT", $count, array("#COUNT#" => $count)) ?></span>
</p>
<?php else: ?>
<p class="vino-reviews__empty"><?= Loc::getMessage("VINO_REVIEWS_EMPTY") ?></p>
<?php endif; ?>
<button type="button" class="vino-btn vino-btn--outline vino-reviews__write" data-review-open><?= Loc::getMessage("VINO_REVIEWS_WRITE") ?></button>
</div>
<?php if ($count > 0): ?>
<ul class="vino-reviews__list">
<?php foreach ($arResult["ITEMS"] as $item):
$this->AddEditAction($item["ID"], $item["EDIT_LINK"], $editLink);
$this->AddDeleteAction($item["ID"], $item["DELETE_LINK"], $deleteLink);
?>
<?php $reviewLang = preg_match("/\p{Cyrillic}/u", strip_tags((string)$item["PREVIEW_TEXT"])) ? "ru" : LANGUAGE_ID; ?>
<li class="vino-review" id="<?= $this->GetEditAreaId($item["ID"]) ?>"<?= $reviewLang !== LANGUAGE_ID ? ' lang="' . $reviewLang . '"' : "" ?>>
<div class="vino-review__head">
<span class="vino-review__author"><?= htmlspecialcharsbx((string)$item["PROPERTIES"]["AUTHOR"]["~VALUE"]) ?></span>
<time class="vino-review__date" datetime="<?= date("Y-m-d", $item["VINO_DATE"]) ?>"><?= date("d.m.Y", $item["VINO_DATE"]) ?></time>
</div>
<span class="vino-stars vino-stars--sm" role="img" aria-label="<?= Loc::getMessage("VINO_REVIEWS_RATING_LABEL", array("#VALUE#" => $item["VINO_RATING"])) ?>"><?= $stars($item["VINO_RATING"]) ?></span>
<p class="vino-review__text"><?= $item["PREVIEW_TEXT"] ?></p>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</div>
</section>
<dialog class="vino-modal" data-review-modal aria-labelledby="vino-review-title">
<div class="vino-modal__dialog">
<button type="button" class="vino-modal__close" data-review-close aria-label="<?= Loc::getMessage("VINO_REVIEWS_CLOSE") ?>">&times;</button>
<div class="vino-review-guest">
<?php $APPLICATION->IncludeComponent("jinove:auth.login", ".default", array("EMBED" => "Y", "TITLE" => Loc::getMessage("VINO_REVIEWS_LOGIN_TITLE"), "LEAD" => Loc::getMessage("VINO_REVIEWS_LOGIN_LEAD")), false); ?>
</div>
<div class="vino-review-user">
<div data-review-body>
<p class="vino-modal__kicker"><?= htmlspecialcharsbx((string)$arParams["VINO_PRODUCT_NAME"]) ?></p>
<h2 class="vino-modal__title" id="vino-review-title"><?= Loc::getMessage("VINO_REVIEWS_FORM_TITLE") ?></h2>
<form class="vino-modal__form" novalidate data-review-form data-product="<?= (int)$arParams["VINO_PRODUCT_ID"] ?>"
data-msg-rating="<?= Loc::getMessage("VINO_REVIEWS_ERR_RATING") ?>"
data-msg-author="<?= Loc::getMessage("VINO_REVIEWS_ERR_AUTHOR") ?>"
data-msg-text="<?= Loc::getMessage("VINO_REVIEWS_ERR_TEXT") ?>"
data-msg-consent="<?= Loc::getMessage("VINO_REVIEWS_ERR_CONSENT") ?>"
data-msg-altcha="<?= Loc::getMessage("VINO_REVIEWS_ERR_ALTCHA") ?>"
data-msg-too-often="<?= Loc::getMessage("VINO_REVIEWS_ERR_TOO_OFTEN") ?>"
data-msg-error="<?= Loc::getMessage("VINO_REVIEWS_ERR_COMMON") ?>">
<input type="text" name="website" class="vino-hp" tabindex="-1" autocomplete="off" aria-hidden="true">
<fieldset class="vino-rate">
<legend class="vino-rate__legend"><?= Loc::getMessage("VINO_REVIEWS_RATE") ?></legend>
<div class="vino-rate__stars">
<?php for ($i = 5; $i >= 1; $i--): ?>
<input class="vino-rate__input" type="radio" name="rating" id="vino-rate-<?= $i ?>" value="<?= $i ?>">
<label class="vino-rate__star" for="vino-rate-<?= $i ?>"><span class="vino-sr-only"><?= Loc::getMessage("VINO_REVIEWS_RATING_LABEL", array("#VALUE#" => $i)) ?></span></label>
<?php endfor; ?>
</div>
</fieldset>
<textarea class="vino-inp vino-txt" name="text" placeholder="<?= Loc::getMessage("VINO_REVIEWS_TEXT") ?>" aria-label="<?= Loc::getMessage("VINO_REVIEWS_TEXT") ?>" maxlength="2000" required></textarea>
<label class="vino-consent vino-consent--sm"><input class="vino-consent__checkbox" type="checkbox" name="consent" value="1" required><span class="vino-consent__text"><?= Loc::getMessage("VINO_REVIEWS_CONSENT", array("#BUTTON#" => Loc::getMessage("VINO_REVIEWS_SEND"), "#URL#" => SITE_DIR . "consent/", "#PRIVACY_URL#" => SITE_DIR . "privacy/")) ?></span></label>
<altcha-widget name="altcha" challenge="/bitrix/services/main/ajax.php?action=jinove:vinoteca.lead.challenge" auto="onload" display="invisible"></altcha-widget>
<p class="vino-modal__err" role="alert" data-review-err hidden></p>
<button class="vino-btn" type="submit"><?= Loc::getMessage("VINO_REVIEWS_SEND") ?></button>
</form>
</div>
<div class="vino-modal__done" data-review-done tabindex="-1" hidden>
<p class="vino-modal__kicker"><?= Loc::getMessage("VINO_REVIEWS_DONE_KICKER") ?></p>
<p class="vino-modal__title"><?= Loc::getMessage("VINO_REVIEWS_DONE_TITLE") ?></p>
<p class="vino-modal__lead"><?= Loc::getMessage("VINO_REVIEWS_DONE_TEXT") ?></p>
<button type="button" class="vino-btn vino-btn--outline" data-review-close><?= Loc::getMessage("VINO_REVIEWS_CLOSE") ?></button>
</div>
</div>
</div>
</dialog>