commit 52795535ae5a1a86363d38f22e72383c1e83820b Author: jimagie Date: Thu Oct 22 23:22:27 2026 +0500 Vinoteca: wine shop on 1C-Bitrix (module, template, components, pages) diff --git a/.access.php b/.access.php new file mode 100644 index 0000000..0659fdc --- /dev/null +++ b/.access.php @@ -0,0 +1,8 @@ + \ No newline at end of file diff --git a/.bottom.menu.php b/.bottom.menu.php new file mode 100644 index 0000000..9a4ad56 --- /dev/null +++ b/.bottom.menu.php @@ -0,0 +1,9 @@ + \ No newline at end of file diff --git a/.section.php b/.section.php new file mode 100644 index 0000000..0aacaaf --- /dev/null +++ b/.section.php @@ -0,0 +1,5 @@ + 'Vinoteca: a curated wine shop. Wines from the best regions of the world, fair prices and a sommelier to help you choose.', + 'robots' => 'index, follow', +]; diff --git a/.top.menu.php b/.top.menu.php new file mode 100644 index 0000000..f0fa711 --- /dev/null +++ b/.top.menu.php @@ -0,0 +1,8 @@ +SetTitle(Loc::getMessage("VINO_404_TITLE")); +$APPLICATION->SetPageProperty("title", Loc::getMessage("VINO_404_TITLE")); +$APPLICATION->SetPageProperty("description", Loc::getMessage("VINO_404_TITLE")); +$APPLICATION->SetPageProperty("robots", "noindex, follow"); +$APPLICATION->SetPageProperty("vino_alternates", "N"); +Asset::getInstance()->addJs(SITE_TEMPLATE_PATH . "/assets/js/vino-slider.js"); +?> +
+
+ +

+


+ +
+
+
+
+

+ IncludeComponent("bitrix:catalog.section.list", "vinoteca-tiles", \Jinove\Vinoteca\Catalog\Listing::sectionTilesParams() + array("VINO_SCHEMA" => "N"), false); ?> +
+
+
+
+
+
+

+
+
+ + +
+
+
+
+
+ IncludeComponent("bitrix:catalog.top", "vinoteca-row", \Jinove\Vinoteca\Catalog\Listing::prepareBestsellers(), false); ?> +
+
+
+
+
+
+ diff --git a/about/index.php b/about/index.php new file mode 100644 index 0000000..5c7b105 --- /dev/null +++ b/about/index.php @@ -0,0 +1,4 @@ +IncludeComponent("jinove:about", ".default", array()); +require($_SERVER["DOCUMENT_ROOT"] . "/bitrix/footer.php"); diff --git a/articles/index.php b/articles/index.php new file mode 100644 index 0000000..4dd0523 --- /dev/null +++ b/articles/index.php @@ -0,0 +1,32 @@ +IncludeComponent("bitrix:news", "vinoteca-news", array( + "IBLOCK_TYPE" => "news", + "IBLOCK_ID" => \Jinove\Vinoteca\News::iblockId(), + "CHECK_DATES" => "Y", + "SEF_MODE" => "Y", + "SEF_FOLDER" => \Jinove\Vinoteca\News::folder(), + "SEF_URL_TEMPLATES" => array( + "news" => "", + "section" => "", + "detail" => "#ELEMENT_CODE#/", + ), + "DETAIL_FIELD_CODE" => array("PREVIEW_PICTURE", "PREVIEW_TEXT", "DETAIL_TEXT", "DETAIL_PICTURE", "ACTIVE_FROM", "TIMESTAMP_X"), + "DETAIL_PROPERTY_CODE" => array("NAME_EN", "NAME_PL", "PREVIEW_TEXT_EN", "PREVIEW_TEXT_PL", "DETAIL_TEXT_EN", "DETAIL_TEXT_PL"), + "USE_SEARCH" => "N", + "USE_RSS" => "N", + "USE_RATING" => "N", + "USE_CATEGORIES" => "N", + "USE_FILTER" => "N", + "USE_REVIEW" => "N", + "USE_PERMISSIONS" => "N", + "AJAX_MODE" => "N", + "CACHE_TYPE" => "A", + "CACHE_TIME" => "36000000", + "CACHE_GROUPS" => "N", + "SET_STATUS_404" => "Y", + "SHOW_404" => "Y", + "FILE_404" => "", + "MESSAGE_404" => "", +), false); +require($_SERVER["DOCUMENT_ROOT"] . "/bitrix/footer.php"); diff --git a/brands/index.php b/brands/index.php new file mode 100644 index 0000000..ff16ff3 --- /dev/null +++ b/brands/index.php @@ -0,0 +1,54 @@ +addCss(SITE_TEMPLATE_PATH . "/catalog-styles.css"); +$APPLICATION->SetPageProperty("og_image", VINO_HOST . SITE_TEMPLATE_PATH . "/assets/media/og-catalog.jpg"); +$APPLICATION->IncludeComponent("bitrix:news", "vinoteca-brands", array( + "IBLOCK_TYPE" => "catalog", + "IBLOCK_ID" => VINO_BRANDS_IBLOCK, + "NEWS_COUNT" => "100", + "SORT_BY1" => "SORT", + "SORT_ORDER1" => "ASC", + "SORT_BY2" => "NAME", + "SORT_ORDER2" => "ASC", + "CHECK_DATES" => "Y", + "SEF_MODE" => "Y", + "SEF_FOLDER" => SITE_DIR . "brands/", + "SEF_URL_TEMPLATES" => array( + "news" => "", + "section" => "", + "detail" => "#ELEMENT_CODE#/", + ), + "LIST_FIELD_CODE" => array("PREVIEW_PICTURE"), + "LIST_PROPERTY_CODE" => array("COUNTRY", "REGION"), + "DETAIL_FIELD_CODE" => array("PREVIEW_TEXT", "PREVIEW_PICTURE", "DETAIL_PICTURE"), + "DETAIL_PROPERTY_CODE" => array("COUNTRY", "REGION", "REGION_FULL", "FOUNDED", "GRAPE"), + "USE_SEARCH" => "N", + "USE_RSS" => "N", + "USE_RATING" => "N", + "USE_CATEGORIES" => "N", + "USE_FILTER" => "N", + "USE_REVIEW" => "N", + "USE_PERMISSIONS" => "N", + "AJAX_MODE" => "N", + "CACHE_TYPE" => "A", + "CACHE_TIME" => "36000000", + "CACHE_FILTER" => "N", + "CACHE_GROUPS" => "Y", + "SET_TITLE" => "Y", + "SET_LAST_MODIFIED" => "N", + "INCLUDE_IBLOCK_INTO_CHAIN" => "N", + "ADD_SECTIONS_CHAIN" => "N", + "ADD_ELEMENT_CHAIN" => "Y", + "DISPLAY_TOP_PAGER" => "N", + "DISPLAY_BOTTOM_PAGER" => "N", + "SET_STATUS_404" => "Y", + "SHOW_404" => "Y", + "FILE_404" => "", + "MESSAGE_404" => "", +), false); +require($_SERVER["DOCUMENT_ROOT"] . "/bitrix/footer.php"); diff --git a/catalog/.section.php b/catalog/.section.php new file mode 100644 index 0000000..5133e22 --- /dev/null +++ b/catalog/.section.php @@ -0,0 +1,2 @@ + \ No newline at end of file diff --git a/catalog/index.php b/catalog/index.php new file mode 100644 index 0000000..85ed34d --- /dev/null +++ b/catalog/index.php @@ -0,0 +1,8 @@ +addCss(SITE_TEMPLATE_PATH . "/catalog-styles.css"); +\Bitrix\Main\Localization\Loc::loadMessages(__FILE__); +$APPLICATION->SetTitle(\Bitrix\Main\Localization\Loc::getMessage("VINO_CATALOG_PAGE_TITLE")); +$APPLICATION->SetPageProperty("description", \Bitrix\Main\Localization\Loc::getMessage("VINO_CATALOG_PAGE_DESCRIPTION")); +$APPLICATION->IncludeComponent("bitrix:catalog", "vinoteca", \Jinove\Vinoteca\Catalog\Listing::catalogParams(), false); +require($_SERVER["DOCUMENT_ROOT"] . "/bitrix/footer.php"); diff --git a/catalog/lang/en/index.php b/catalog/lang/en/index.php new file mode 100644 index 0000000..9da0cf7 --- /dev/null +++ b/catalog/lang/en/index.php @@ -0,0 +1,3 @@ + +
+ IncludeComponent( + "bitrix:main.include", + "", + Array( + "AREA_FILE_SHOW" => "file", + "PATH" => SITE_DIR."include/socnet_sidebar.php", + "AREA_FILE_RECURSIVE" => "N", + "EDIT_MODE" => "html", + ), + false, + Array('HIDE_ICONS' => 'Y') + );?> +
+ +
+ IncludeComponent( + "bitrix:main.include", + "", + Array( + "AREA_FILE_SHOW" => "file", + "PATH" => SITE_DIR."include/about.php", + "AREA_FILE_RECURSIVE" => "N", + "EDIT_MODE" => "html", + ), + false, + Array('HIDE_ICONS' => 'N') + );?> +
+ +
+ IncludeComponent( + "bitrix:main.include", + "", + Array( + "AREA_FILE_SHOW" => "file", + "PATH" => SITE_DIR."include/info.php", + "AREA_FILE_RECURSIVE" => "N", + "EDIT_MODE" => "html", + ), + false, + Array('HIDE_ICONS' => 'N') + );?> +
\ No newline at end of file diff --git a/compare/index.php b/compare/index.php new file mode 100644 index 0000000..124a38b --- /dev/null +++ b/compare/index.php @@ -0,0 +1,27 @@ + +
+
+ GetTitle()))); ?> +

ShowTitle(false); ?>

+
+
+ +
+
+
+ +
+

+

\Jinove\Vinoteca\Catalog\Comparison::MAX)) ?>

+
+
+
+
+
+IncludeComponent("bitrix:catalog.compare.result", "vinoteca", \Jinove\Vinoteca\Catalog\Comparison::params(), false); +endif; +require($_SERVER["DOCUMENT_ROOT"] . "/bitrix/footer.php"); diff --git a/consent/index.php b/consent/index.php new file mode 100644 index 0000000..74a53f3 --- /dev/null +++ b/consent/index.php @@ -0,0 +1,41 @@ +addCss(SITE_TEMPLATE_PATH . "/legal-styles.css"); +$email = \Jinove\Vinoteca\Config::contacts()["email"]; +$mail = '' . htmlspecialcharsbx($email) . ''; +$host = htmlspecialcharsbx((string)parse_url(\Jinove\Vinoteca\Config::host(), PHP_URL_HOST)); +$version = \Jinove\Vinoteca\Consent::VERSION; +$date = \Jinove\Vinoteca\DateFormat::long(\Jinove\Vinoteca\Consent::timestamp($version), LANGUAGE_ID); +$APPLICATION->SetTitle(Loc::getMessage("VINO_CONSENT_H1")); +$APPLICATION->SetPageProperty("title", Loc::getMessage("VINO_CONSENT_TITLE")); +$APPLICATION->SetPageProperty("description", Loc::getMessage("VINO_CONSENT_DESCRIPTION")); +$APPLICATION->SetPageProperty("og_image", VINO_HOST . SITE_TEMPLATE_PATH . "/assets/media/og-home.jpg"); +?> +
+
+ +

+

$date)) ?>

+
+
+ + + +IncludeComponent("jinove:auth.forgot", ".default", array()); +require($_SERVER["DOCUMENT_ROOT"] . "/bitrix/footer.php"); diff --git a/include/about.php b/include/about.php new file mode 100644 index 0000000..f48c4e4 --- /dev/null +++ b/include/about.php @@ -0,0 +1,14 @@ +
+

Почему Мы?

+ +
\ No newline at end of file diff --git a/include/about_title.php b/include/about_title.php new file mode 100644 index 0000000..d981e85 --- /dev/null +++ b/include/about_title.php @@ -0,0 +1 @@ +О магазине \ No newline at end of file diff --git a/include/catalog_title.php b/include/catalog_title.php new file mode 100644 index 0000000..d7935d0 --- /dev/null +++ b/include/catalog_title.php @@ -0,0 +1 @@ +Каталог товаров \ No newline at end of file diff --git a/include/company_about.php b/include/company_about.php new file mode 100644 index 0000000..7030676 --- /dev/null +++ b/include/company_about.php @@ -0,0 +1 @@ +Добро пожаловать в интернет-магазин одежды! Мы предлагаем широкий ассортимент качественной одежды по адекватным ценам. Покупая одежду в нашем Интернет-магазине, вы можете быть уверены в её качестве - ведь мы работаем только с крупными и проверенными производителями. \ No newline at end of file diff --git a/include/company_logo.php b/include/company_logo.php new file mode 100644 index 0000000..94cc9be --- /dev/null +++ b/include/company_logo.php @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/include/company_logo_mobile.php b/include/company_logo_mobile.php new file mode 100644 index 0000000..bc1938d --- /dev/null +++ b/include/company_logo_mobile.php @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/include/company_name.php b/include/company_name.php new file mode 100644 index 0000000..882a6ed --- /dev/null +++ b/include/company_name.php @@ -0,0 +1 @@ +Vinoteca \ No newline at end of file diff --git a/include/copyright.php b/include/copyright.php new file mode 100644 index 0000000..c93402c --- /dev/null +++ b/include/copyright.php @@ -0,0 +1 @@ +© Интернет-магазин одежды, 2020 \ No newline at end of file diff --git a/include/facebook_plugin.php b/include/facebook_plugin.php new file mode 100644 index 0000000..1cacd51 --- /dev/null +++ b/include/facebook_plugin.php @@ -0,0 +1,9 @@ + +IncludeComponent("bitrix:eshop.facebook.plugin", "", + array( + "ESHOP_FACEBOOK_LINK"=>"http://www.facebook.com/1CBitrix" + ), + false +); +?> \ No newline at end of file diff --git a/include/home-story.php b/include/home-story.php new file mode 100644 index 0000000..ad251c1 --- /dev/null +++ b/include/home-story.php @@ -0,0 +1,3 @@ + +

A wine cellar, not just a shop

+

Our collection spans the Old World and the New: Italian and French classics, sun-soaked wines from Spain and Portugal, California, Argentina, New Zealand and Hungarian Tokaji. Our sommelier will suggest what to pour with steak or fish, which wine makes a good gift and which one is worth cellaring for a few years. You can ask your question right here on the site.

diff --git a/include/info.php b/include/info.php new file mode 100644 index 0000000..145dc03 --- /dev/null +++ b/include/info.php @@ -0,0 +1,51 @@ +
+

Полезная информация

+
+ +
+
+ +

О магазине

+
+
Узнайте больше о нашем магазине: кто мы, наши клиенты и почему они выбрали именно нас. Наши контакты и реквизиты.
Подробнее +
+
+ +
+
+ +

Доставка

+
+
Доставим ваш заказ в любой регион России, в удобное время и день. Работаем для вас, без выходных.
Подробнее +
+
+ +
+
+ +

Мы гарантируем

+
+
Мы гордимся безупречной репутацией нашего магазина. Если товар не устроит вас, вы всегда сможете вернуть деньги.
Подробнее +
+
+ +
+
+ +

Как купить

+
+
Ваш первый заказ в интернет-магазине? Мы с радостью подскажем как сделать покупки в интернете простыми и удобными.
Подробнее +
+
+ +
+
+ +

Всегда на связи

+
+
Связаться с нами можно любым удобным для вас способом: e-mail, телефон, социальные сети и мессенджеры.
Подробнее +
+
+
+ +
diff --git a/include/personal.php b/include/personal.php new file mode 100644 index 0000000..5266b7f --- /dev/null +++ b/include/personal.php @@ -0,0 +1 @@ +Персональный раздел \ No newline at end of file diff --git a/include/reg_info.php b/include/reg_info.php new file mode 100644 index 0000000..db2f747 --- /dev/null +++ b/include/reg_info.php @@ -0,0 +1,7 @@ +

Использование информации предоставленной Клиентом и получаемой Продавцом.

+

Продавец использует предоставленные Клиентом данные в течение всего срока регистрации Клиента на Сайте в целях:

+ \ No newline at end of file diff --git a/include/schedule.php b/include/schedule.php new file mode 100644 index 0000000..8f80596 --- /dev/null +++ b/include/schedule.php @@ -0,0 +1 @@ +Пн-Вс 10-19 \ No newline at end of file diff --git a/include/sender.php b/include/sender.php new file mode 100644 index 0000000..2660dba --- /dev/null +++ b/include/sender.php @@ -0,0 +1,7 @@ + +
+

РАССЫЛКА

+ IncludeComponent("bitrix:sender.subscribe", "", array( + "SET_TITLE" => "N" + ));?> +
\ No newline at end of file diff --git a/include/socnet_footer.php b/include/socnet_footer.php new file mode 100644 index 0000000..7c6c253 --- /dev/null +++ b/include/socnet_footer.php @@ -0,0 +1,17 @@ + + +IncludeComponent( + "bitrix:eshop.socnet.links", + "big_squares", + array( + "FACEBOOK" => "https://www.facebook.com/1CBitrix", + "VKONTAKTE" => "https://vk.com/bitrix_1c", + "TWITTER" => "https://twitter.com/1c_bitrix", + "GOOGLE" => "https://plus.google.com/111119180387208976312/", + "INSTAGRAM" => "https://instagram.com/1CBitrix/" + ), + false, + array( + "HIDE_ICONS" => "N" + ) +);?> \ No newline at end of file diff --git a/include/socnet_sidebar.php b/include/socnet_sidebar.php new file mode 100644 index 0000000..7ef9e7e --- /dev/null +++ b/include/socnet_sidebar.php @@ -0,0 +1,18 @@ + + +IncludeComponent( + "bitrix:eshop.socnet.links", + "bootstrap_v4", + array( + "COMPONENT_TEMPLATE" => "bootstrap_v4", + "FACEBOOK" => "https://www.facebook.com/1CBitrix", + "VKONTAKTE" => "https://vk.com/bitrix_1c", + "TWITTER" => "https://twitter.com/1c_bitrix", + "GOOGLE" => "https://plus.google.com/111119180387208976312/", + "INSTAGRAM" => "https://instagram.com/1CBitrix/" + ), + false, + array( + "HIDE_ICONS" => "N" + ) +);?> \ No newline at end of file diff --git a/include/telephone.php b/include/telephone.php new file mode 100644 index 0000000..f9ff748 --- /dev/null +++ b/include/telephone.php @@ -0,0 +1 @@ +8 (495) 212 85 06 \ No newline at end of file diff --git a/include/twitter.php b/include/twitter.php new file mode 100644 index 0000000..65ca8b8 --- /dev/null +++ b/include/twitter.php @@ -0,0 +1,6 @@ +
+
+ + +
+
\ No newline at end of file diff --git a/include/viewed_product.php b/include/viewed_product.php new file mode 100644 index 0000000..dee76aa --- /dev/null +++ b/include/viewed_product.php @@ -0,0 +1,38 @@ + +IncludeComponent("bitrix:catalog.viewed.products", "bootstrap_v4", array( + "HIDE_NOT_AVAILABLE" => "N", + "PAGE_ELEMENT_COUNT" => "5", + "SHOW_DISCOUNT_PERCENT" => "Y", + "PRODUCT_SUBSCRIPTION" => "N", + "SHOW_NAME" => "Y", + "SHOW_IMAGE" => "Y", + "MESS_BTN_BUY" => "Купить", + "MESS_BTN_DETAIL" => "Подробнее", + "MESS_BTN_SUBSCRIBE" => "Подписаться", + "LINE_ELEMENT_COUNT" => "5", + "TEMPLATE_THEME" => "site", + "SHOW_OLD_PRICE" => "N", + "PRICE_CODE" => array( + 0 => "BASE", + ), + "SHOW_PRICE_COUNT" => "1", + "PRICE_VAT_INCLUDE" => "Y", + "CONVERT_CURRENCY" => "N", + "BASKET_URL" => "/personal/cart/", + "ACTION_VARIABLE" => "action_cvp", + "PRODUCT_ID_VARIABLE" => "id", + "ADD_PROPERTIES_TO_BASKET" => "Y", + "PRODUCT_PROPS_VARIABLE" => "prop", + "PARTIAL_PRODUCT_PROPERTIES" => "N", + "USE_PRODUCT_QUANTITY" => "N", + "SHOW_PRODUCTS_2" => "Y", + "OFFER_TREE_PROPS_3" => array( + 0 => "COLOR_REF", + 1 => "SIZES_SHOES", + 2 => "SIZES_CLOTHES", + ), + "PRODUCT_QUANTITY_VARIABLE" => "quantity", + "CACHE_GROUPS" => "Y" + ), + false +);?> \ No newline at end of file diff --git a/index.php b/index.php new file mode 100644 index 0000000..1eefc23 --- /dev/null +++ b/index.php @@ -0,0 +1,184 @@ +SetPageProperty("description", Loc::getMessage("VINO_HOME_DESCRIPTION")); +$APPLICATION->SetPageProperty("og_image", VINO_HOST . SITE_TEMPLATE_PATH . "/assets/media/og-home.jpg"); +$APPLICATION->SetTitle(Loc::getMessage("VINO_HOME_TITLE")); +$tpl = SITE_TEMPLATE_PATH; +Asset::getInstance()->addJs(SITE_TEMPLATE_PATH . "/assets/js/vino-slider.js"); +$wineCount = ServiceLocator::getInstance()->get("jinove.vinoteca.wineStats")->getActiveCount(); +?> +

+IncludeComponent("bitrix:news.list", "vhero", array( + "IBLOCK_TYPE" => "content", + "IBLOCK_ID" => VINO_BANNERS_IBLOCK, + "NEWS_COUNT" => "4", + "SORT_BY1" => "SORT", + "SORT_ORDER1" => "ASC", + "SORT_BY2" => "ID", + "SORT_ORDER2" => "ASC", + "FIELD_CODE" => array("PREVIEW_PICTURE", "PREVIEW_TEXT"), + "PROPERTY_CODE" => array("KICKER", "LINK", "LINK_TEXT"), + "CHECK_DATES" => "Y", + "SET_TITLE" => "N", + "SET_BROWSER_TITLE" => "N", + "SET_META_KEYWORDS" => "N", + "SET_META_DESCRIPTION" => "N", + "SET_LAST_MODIFIED" => "N", + "SET_STATUS_404" => "N", + "SHOW_404" => "N", + "INCLUDE_IBLOCK_INTO_CHAIN" => "N", + "ADD_SECTIONS_CHAIN" => "N", + "DISPLAY_TOP_PAGER" => "N", + "DISPLAY_BOTTOM_PAGER" => "N", + "CACHE_TYPE" => "A", + "CACHE_TIME" => "36000000", + "CACHE_GROUPS" => "N", +), false); ?> + +IncludeComponent("bitrix:news.list", "vinoteca-brands", array( + "IBLOCK_TYPE" => "catalog", + "IBLOCK_ID" => VINO_BRANDS_IBLOCK, + "NEWS_COUNT" => "8", + "DETAIL_URL" => SITE_DIR . "brands/#ELEMENT_CODE#/", + "SORT_BY1" => "SORT", + "SORT_ORDER1" => "ASC", + "SORT_BY2" => "NAME", + "SORT_ORDER2" => "ASC", + "FIELD_CODE" => array("PREVIEW_PICTURE"), + "PROPERTY_CODE" => array("COUNTRY", "REGION"), + "CHECK_DATES" => "Y", + "SET_TITLE" => "N", + "SET_BROWSER_TITLE" => "N", + "SET_META_KEYWORDS" => "N", + "SET_META_DESCRIPTION" => "N", + "SET_LAST_MODIFIED" => "N", + "SET_STATUS_404" => "N", + "SHOW_404" => "N", + "INCLUDE_IBLOCK_INTO_CHAIN" => "N", + "ADD_SECTIONS_CHAIN" => "N", + "DISPLAY_TOP_PAGER" => "N", + "DISPLAY_BOTTOM_PAGER" => "N", + "CACHE_TYPE" => "A", + "CACHE_TIME" => "36000000", + "CACHE_GROUPS" => "N", +), false); ?> + +
+
+
+
+

+

+
+
+ + +
+
+
+
+
+ IncludeComponent("bitrix:catalog.top", "vinoteca-row", \Jinove\Vinoteca\Catalog\Listing::prepareBestsellers(), false); ?> +
+
+
+
+
+
+ +
+
+
+
+

+

+
+
+ $wineCount)) ?> +
+ + +
+
+
+
+
+ IncludeComponent("bitrix:catalog.top", "vinoteca-row", array( + "IBLOCK_TYPE" => "catalog", + "IBLOCK_ID" => VINO_CATALOG_IBLOCK, + "ELEMENT_COUNT" => "8", + "ELEMENT_SORT_FIELD" => "PROPERTY_VINTAGE", + "ELEMENT_SORT_ORDER" => "desc", + "ELEMENT_SORT_FIELD2" => "ID", + "ELEMENT_SORT_ORDER2" => "desc", + "PROPERTY_CODE" => array("WINE_COLOR", "SUGAR", "VOLUME", "REGION", "COUNTRY"), + "PRICE_CODE" => array("BASE"), + "PRICE_VAT_INCLUDE" => "Y", + "USE_PRICE_COUNT" => "N", + "SHOW_PRICE_COUNT" => "1", + "CONVERT_CURRENCY" => "N", + "HIDE_NOT_AVAILABLE" => "N", + "DETAIL_URL" => SITE_DIR . "catalog/#SECTION_CODE#/#ELEMENT_CODE#/", + "SECTION_URL" => SITE_DIR . "catalog/#SECTION_CODE#/", + "CACHE_TYPE" => "A", + "CACHE_TIME" => "3600", + "CACHE_GROUPS" => "N", + "CACHE_FILTER" => "N", + ), false); ?> +
+
+
+
+
+ +
+
+
+
+ + + <?= htmlspecialcharsbx(Loc::getMessage("> + +
+
+ IncludeComponent("bitrix:main.include", "", array("AREA_FILE_SHOW" => "file", "PATH" => SITE_DIR . "include/home-story.php"), false); ?> + +
+
+
+
+ +
+
+
+
+

+

+
+ +
+
+ IncludeComponent("bitrix:news.list", "vinoteca-news", \Jinove\Vinoteca\News::homeParams(), false); ?> +
+
+
+ +SetTitle($title); + $APPLICATION->SetPageProperty("title", (string)Loc::getMessage("VINO_ABOUT_BROWSER_TITLE")); + $APPLICATION->SetPageProperty("description", (string)Loc::getMessage("VINO_ABOUT_DESCRIPTION")); + $contacts = Config::contacts(); + $counts = $this->counts(); + $this->arResult = [ + "TITLE" => $title, + "WINES" => $counts["wines"], + "BRANDS" => $counts["brands"], + "TYPES" => $counts["types"], + "PHONE" => (string)($contacts["phone"] ?? ""), + "PHONE_LABEL" => (string)($contacts["phoneLabel"] ?? ""), + "EMAIL" => (string)($contacts["email"] ?? ""), + "MAP_URL" => "https://yandex.ru/maps/?text=" . rawurlencode(self::MAP_ADDRESS), + "CATALOG_URL" => SITE_DIR . "catalog/", + "BRANDS_URL" => SITE_DIR . "brands/", + "DESCRIPTION" => (string)Loc::getMessage("VINO_ABOUT_DESCRIPTION"), + "SCHEMA" => PageSchema::aboutPage(SITE_DIR . "about/", $title, (string)Loc::getMessage("VINO_ABOUT_DESCRIPTION"), PageSchema::image(Config::host() . SITE_DIR . "about/#image", Config::host() . SITE_TEMPLATE_PATH . "/assets/media/about-intro-1400.webp", 1400, 933)), + "MAP" => ["LAT" => self::MAP_LAT, "LON" => self::MAP_LON, "ZOOM" => self::MAP_ZOOM, "STYLE" => SITE_TEMPLATE_PATH . "/assets/map/vinoteca-dark.json"], + ]; + $this->includeComponentTemplate(); + + return $this->arResult; + } + + private function counts(): array + { + $cache = Cache::createInstance(); + if ($cache->initCache(self::CACHE_TTL, "counts-" . LANGUAGE_ID, self::CACHE_DIR)) { + return (array)$cache->getVars(); + } + $cache->startDataCache(); + $taggedCache = Application::getInstance()->getTaggedCache(); + $taggedCache->startTagCache(self::CACHE_DIR); + try { + $brandsId = Config::iblockId("brands"); + $taggedCache->registerTag("iblock_id_" . Config::iblockId("catalog")); + $taggedCache->registerTag("iblock_id_" . $brandsId); + $counts = [ + "wines" => ServiceLocator::getInstance()->get("jinove.vinoteca.wineStats")->getActiveCount(), + "brands" => Loader::includeModule("iblock") ? ElementTable::getCount(["=IBLOCK_ID" => $brandsId, "=ACTIVE" => "Y"]) : 0, + "types" => MegaMenu::types(Config::iblockId("catalog")), + ]; + } catch (\Throwable $e) { + $taggedCache->abortTagCache(); + $cache->abortDataCache(); + + return ["wines" => 0, "brands" => 0, "types" => []]; + } + $taggedCache->endTagCache(); + $cache->endDataCache($counts); + + return $counts; + } +} diff --git a/local/components/jinove/about/lang/en/class.php b/local/components/jinove/about/lang/en/class.php new file mode 100644 index 0000000..0341bfa --- /dev/null +++ b/local/components/jinove/about/lang/en/class.php @@ -0,0 +1,4 @@ + htmlspecialcharsbx((string)Loc::getMessage($key)); +$stats = [ + ["value" => $arResult["WINES"], "label" => Loc::getMessagePlural("VINO_ABOUT_WINES", $arResult["WINES"]), "url" => $arResult["CATALOG_URL"]], + ["value" => $arResult["BRANDS"], "label" => Loc::getMessagePlural("VINO_ABOUT_BRANDS", $arResult["BRANDS"]), "url" => $arResult["BRANDS_URL"]], +]; +$steps = ["ASK", "PAY", "PICKUP"]; +$note = static function (string $step): string { + $line = htmlspecialcharsbx((string)Loc::getMessage("VINO_ABOUT_" . $step . "_D")); + $label = htmlspecialcharsbx((string)Loc::getMessage("VINO_ABOUT_" . $step . "_LINK")); + if ($step === "ASK") { + $link = ''; + } elseif ($step === "PICKUP") { + $link = '' . $label . ''; + } else { + return $line; + } + + return str_replace("#LINK#", $link, $line); +}; +?> +
+
+
+
+ +

+

' . $text("VINO_ABOUT_ACCENT") . '', $text("VINO_ABOUT_LEAD")) ?>

+

+
+ <?= $text(" fetchpriority="high" decoding="async"> +
+
+ 0): ?> +
+
+

+
    + +
  • + + "> +
  • + +
+ +
    + +
  • + + "> +
  • + +
+ +
+
+ +
+
+

+
    + $step): ?> + 0): ?> +
  1. + + +
  2. + +
+
+
+
+
+
+

+
+
+
+
+
+ +
+
+
">
+
+ + +
+
+
">
+
+ +
+
+ + "> +
+ " target="_blank" rel="noopener noreferrer"> +
+
+
" data-lon="" data-zoom="" data-style="" data-lang="" data-lib-js="/assets/vendor/maplibre/maplibre-gl.js" data-lib-css="/assets/vendor/maplibre/maplibre-gl.css" data-text-windows="" data-text-mac="" data-text-mobile="" data-text-zoom-in="" data-text-zoom-out="" data-text-stub="" data-text-fail="" role="region" aria-label=""> +
+
+

+ +
+
+
+
+
+
+ diff --git a/local/components/jinove/auth.forgot/class.php b/local/components/jinove/auth.forgot/class.php new file mode 100644 index 0000000..c747d2d --- /dev/null +++ b/local/components/jinove/auth.forgot/class.php @@ -0,0 +1,30 @@ +getId() > 0) { + LocalRedirect(SITE_DIR); + } + $GLOBALS["APPLICATION"]->SetTitle(Loc::getMessage("VINO_FORGOT_PAGE_TITLE")); + $GLOBALS["APPLICATION"]->SetPageProperty("description", Loc::getMessage("VINO_FORGOT_PAGE_DESCRIPTION")); + $GLOBALS["APPLICATION"]->SetPageProperty("vino_alternates", "N"); + $GLOBALS["APPLICATION"]->SetPageProperty("vino_schema", "N"); + $GLOBALS["APPLICATION"]->SetPageProperty("robots", "noindex, nofollow"); + $this->arResult = ["LOGIN_URL" => SITE_DIR . "login/"]; + $this->includeComponentTemplate(); + + return $this->arResult; + } +} diff --git a/local/components/jinove/auth.forgot/lang/en/class.php b/local/components/jinove/auth.forgot/lang/en/class.php new file mode 100644 index 0000000..eac149e --- /dev/null +++ b/local/components/jinove/auth.forgot/lang/en/class.php @@ -0,0 +1,3 @@ +personal data on the terms and for the purposes set out in the Privacy Policy.'; +$MESS["VINO_FORGOT_DONE"] = "If an account with this e-mail exists, a password reset link has been sent to it."; +$MESS["VINO_FORGOT_ERR_ALTCHA"] = "Verification failed. Please try again."; +$MESS["VINO_FORGOT_ERR_TOO_OFTEN"] = "Too many attempts, try again later"; +$MESS["VINO_FORGOT_ERR_RETRY"] = "Please submit again"; +$MESS["VINO_FORGOT_ERR_COMMON"] = "Failed. Please try again later"; diff --git a/local/components/jinove/auth.forgot/templates/.default/lang/pl/template.php b/local/components/jinove/auth.forgot/templates/.default/lang/pl/template.php new file mode 100644 index 0000000..ae1759b --- /dev/null +++ b/local/components/jinove/auth.forgot/templates/.default/lang/pl/template.php @@ -0,0 +1,16 @@ +danych osobowych na warunkach i w celach określonych w Polityce prywatności.'; +$MESS["VINO_FORGOT_DONE"] = "Jeśli konto z tym adresem e-mail istnieje, link do zmiany hasła został wysłany na ten adres."; +$MESS["VINO_FORGOT_ERR_ALTCHA"] = "Weryfikacja nieudana. Spróbuj ponownie."; +$MESS["VINO_FORGOT_ERR_TOO_OFTEN"] = "Zbyt wiele prób, spróbuj ponownie później"; +$MESS["VINO_FORGOT_ERR_RETRY"] = "Wyślij ponownie"; +$MESS["VINO_FORGOT_ERR_COMMON"] = "Błąd. Spróbuj ponownie później"; diff --git a/local/components/jinove/auth.forgot/templates/.default/lang/ru/template.php b/local/components/jinove/auth.forgot/templates/.default/lang/ru/template.php new file mode 100644 index 0000000..bd1fd82 --- /dev/null +++ b/local/components/jinove/auth.forgot/templates/.default/lang/ru/template.php @@ -0,0 +1,16 @@ +персональных данных на условиях и для целей, определённых Политикой конфиденциальности.'; +$MESS["VINO_FORGOT_DONE"] = "Если аккаунт с таким e-mail есть, на него отправлена ссылка для смены пароля."; +$MESS["VINO_FORGOT_ERR_ALTCHA"] = "Проверка не пройдена. Повторите попытку."; +$MESS["VINO_FORGOT_ERR_TOO_OFTEN"] = "Слишком много попыток, повторите позже"; +$MESS["VINO_FORGOT_ERR_RETRY"] = "Повторите отправку"; +$MESS["VINO_FORGOT_ERR_COMMON"] = "Не удалось. Повторите позже"; diff --git a/local/components/jinove/auth.forgot/templates/.default/script.js b/local/components/jinove/auth.forgot/templates/.default/script.js new file mode 100644 index 0000000..cf38596 --- /dev/null +++ b/local/components/jinove/auth.forgot/templates/.default/script.js @@ -0,0 +1,83 @@ +(function () { + function init() { + var form = document.querySelector('[data-auth-forgot]'); + if (!form) return; + if (!window.BX || !BX.ajax || !BX.ajax.runAction) { + form.addEventListener('submit', function (event) { + event.preventDefault(); + }); + return; + } + var email = form.elements.email; + var consent = form.elements.consent; + var submit = form.querySelector('[type="submit"]'); + var err = form.querySelector('[data-auth-err]'); + var done = document.querySelector('[data-auth-done]'); + var consentBox = form.querySelector('.vino-auth__consent'); + var guard = form.querySelector('altcha-widget'); + var started = Date.now(); + var codes = { too_often: 'tooOften', altcha: 'altcha', retry: 'retry', email: 'email' }; + + function message(code) { + var key = codes[code] || 'error'; + return form.dataset['msg' + key.charAt(0).toUpperCase() + key.slice(1)] || form.dataset.msgError; + } + + function mark(field, bad) { + field.classList.toggle('vino-inp--invalid', bad); + field.setAttribute('aria-invalid', bad ? 'true' : 'false'); + } + + VinoAltcha.arm(guard); + + form.addEventListener('input', function (event) { + if (event.target.classList.contains('vino-inp--invalid')) mark(event.target, false); + }); + consent.addEventListener('change', function () { + consentBox.classList.remove('vino-consent--invalid'); + }); + + form.addEventListener('submit', function (event) { + event.preventDefault(); + var emailValue = email.value.trim(); + var badEmail = !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(emailValue); + var badConsent = !consent.checked; + mark(email, badEmail); + consentBox.classList.toggle('vino-consent--invalid', badConsent); + consent.setAttribute('aria-invalid', badConsent ? 'true' : 'false'); + if (badEmail || badConsent) { + err.textContent = badEmail ? form.dataset.msgEmail : form.dataset.msgConsent; + (badEmail ? email : consent).focus(); + return; + } + err.textContent = ''; + submit.disabled = true; + VinoAltcha.armed(guard).then(function (ok) { + if (!ok) return Promise.reject({ errors: [{ code: 'altcha' }] }); + return BX.ajax.runAction('jinove:vinoteca.password.request', { + data: { + email: emailValue, + website: form.elements.website.value, + elapsed: String(Date.now() - started), + altcha: form.elements.altcha ? form.elements.altcha.value : '' + } + }); + }).then(function () { + form.hidden = true; + done.hidden = false; + done.focus(); + }, function (response) { + submit.disabled = false; + VinoAltcha.reset(guard); + var code = response && response.errors && response.errors[0] ? response.errors[0].code : ''; + err.textContent = message(code); + }); + }); + } + + if (document.readyState === 'loading') { + document.addEventListener('DOMContentLoaded', init); + } else { + init(); + } +})(); diff --git a/local/components/jinove/auth.forgot/templates/.default/template.php b/local/components/jinove/auth.forgot/templates/.default/template.php new file mode 100644 index 0000000..ff3abef --- /dev/null +++ b/local/components/jinove/auth.forgot/templates/.default/template.php @@ -0,0 +1,40 @@ +addExternalCss("/local/components/jinove/auth.login/templates/.default/style.css"); +$uid = "vino-forgot"; +?> +
+
+

+

+

+

+ +
" + data-msg-consent="" + data-msg-altcha="" + data-msg-too-often="" + data-msg-retry="" + data-msg-error=""> + +
+ + +
+ + + + + +
+
+
diff --git a/local/components/jinove/auth.login/class.php b/local/components/jinove/auth.login/class.php new file mode 100644 index 0000000..2de855b --- /dev/null +++ b/local/components/jinove/auth.login/class.php @@ -0,0 +1,44 @@ +getContext()->getRequest(); + $embed = ($this->arParams["EMBED"] ?? "") === "Y"; + $back = $embed ? (string)$GLOBALS["APPLICATION"]->GetCurPageParam("", array(), false) : (string)$request->getQuery("back"); + $safeBack = \Jinove\Vinoteca\Redirect::safe($back); + if (!$embed) { + if ((int)CurrentUser::get()->getId() > 0) { + LocalRedirect($safeBack !== "" ? $safeBack : SITE_DIR); + } + $GLOBALS["APPLICATION"]->SetTitle(Loc::getMessage("VINO_AUTH_PAGE_TITLE")); + $GLOBALS["APPLICATION"]->SetPageProperty("description", Loc::getMessage("VINO_AUTH_PAGE_DESCRIPTION")); + $GLOBALS["APPLICATION"]->SetPageProperty("vino_alternates", "N"); + $GLOBALS["APPLICATION"]->SetPageProperty("vino_schema", "N"); + $GLOBALS["APPLICATION"]->SetPageProperty("robots", "noindex, nofollow"); + } + $this->arResult = [ + "EMBED" => $embed, + "TITLE" => (string)($this->arParams["TITLE"] ?? ""), + "LEAD" => (string)($this->arParams["LEAD"] ?? ""), + "BACK" => $safeBack, + "REGISTER_URL" => SITE_DIR . "register/" . ($safeBack !== "" ? "?back=" . rawurlencode($safeBack) : ""), + "FORGOT_URL" => SITE_DIR . "forgot-password/", + ]; + $this->includeComponentTemplate(); + + return $this->arResult; + } +} diff --git a/local/components/jinove/auth.login/lang/en/class.php b/local/components/jinove/auth.login/lang/en/class.php new file mode 100644 index 0000000..dd72ee8 --- /dev/null +++ b/local/components/jinove/auth.login/lang/en/class.php @@ -0,0 +1,3 @@ +personal data on the terms and for the purposes set out in the Privacy Policy.'; +$MESS["VINO_AUTH_ERR_INVALID"] = "Wrong e-mail or password"; +$MESS["VINO_AUTH_ERR_TOO_OFTEN"] = "Too many attempts, try again later"; +$MESS["VINO_AUTH_ERR_COMMON"] = "Could not sign in. Please try again"; +$MESS["VINO_AUTH_ASIDE_TITLE"] = "After signing in you will be able to"; +$MESS["VINO_AUTH_ERR_ALTCHA"] = "Verification failed. Please try again."; +$MESS["VINO_AUTH_PERK_PROFILE"] = "Edit your profile and contact details"; +$MESS["VINO_AUTH_PERK_ORDERS"] = "View the history and status of orders"; +$MESS["VINO_AUTH_PERK_REVIEW"] = "Leave wine reviews"; diff --git a/local/components/jinove/auth.login/templates/.default/lang/pl/template.php b/local/components/jinove/auth.login/templates/.default/lang/pl/template.php new file mode 100644 index 0000000..faab42c --- /dev/null +++ b/local/components/jinove/auth.login/templates/.default/lang/pl/template.php @@ -0,0 +1,24 @@ +danych osobowych na warunkach i w celach określonych w Polityce prywatności.'; +$MESS["VINO_AUTH_ERR_INVALID"] = "Nieprawidłowy e-mail lub hasło"; +$MESS["VINO_AUTH_ERR_TOO_OFTEN"] = "Zbyt wiele prób, spróbuj ponownie później"; +$MESS["VINO_AUTH_ERR_COMMON"] = "Nie udało się zalogować. Spróbuj ponownie"; +$MESS["VINO_AUTH_ASIDE_TITLE"] = "Po zalogowaniu możesz"; +$MESS["VINO_AUTH_ERR_ALTCHA"] = "Weryfikacja nieudana. Spróbuj ponownie."; +$MESS["VINO_AUTH_PERK_PROFILE"] = "Edytować profil i dane kontaktowe"; +$MESS["VINO_AUTH_PERK_ORDERS"] = "Przeglądać historię i status zamówień"; +$MESS["VINO_AUTH_PERK_REVIEW"] = "Dodawać opinie o winach"; diff --git a/local/components/jinove/auth.login/templates/.default/lang/ru/template.php b/local/components/jinove/auth.login/templates/.default/lang/ru/template.php new file mode 100644 index 0000000..33458fa --- /dev/null +++ b/local/components/jinove/auth.login/templates/.default/lang/ru/template.php @@ -0,0 +1,24 @@ +персональных данных на условиях и для целей, определённых Политикой конфиденциальности.'; +$MESS["VINO_AUTH_ERR_INVALID"] = "Неверный e-mail или пароль"; +$MESS["VINO_AUTH_ERR_TOO_OFTEN"] = "Слишком много попыток, повторите позже"; +$MESS["VINO_AUTH_ERR_COMMON"] = "Не удалось войти. Повторите попытку"; +$MESS["VINO_AUTH_ASIDE_TITLE"] = "После входа вы сможете"; +$MESS["VINO_AUTH_ERR_ALTCHA"] = "Проверка не пройдена. Повторите попытку."; +$MESS["VINO_AUTH_PERK_PROFILE"] = "Редактировать профиль и контактные данные"; +$MESS["VINO_AUTH_PERK_ORDERS"] = "Просматривать историю и статус заказов"; +$MESS["VINO_AUTH_PERK_REVIEW"] = "Оставлять отзывы о винах"; diff --git a/local/components/jinove/auth.login/templates/.default/script.js b/local/components/jinove/auth.login/templates/.default/script.js new file mode 100644 index 0000000..5f1b3ce --- /dev/null +++ b/local/components/jinove/auth.login/templates/.default/script.js @@ -0,0 +1,94 @@ +(function () { + function init() { + var form = document.querySelector('[data-auth-login]'); + if (!form || !window.BX || !BX.ajax || !BX.ajax.runAction) return; + var email = form.elements.email; + var password = form.elements.password; + var submit = form.querySelector('[type="submit"]'); + var err = form.querySelector('[data-auth-err]'); + var started = Date.now(); + var codes = { invalid: 'invalid', too_often: 'tooOften', altcha: 'altcha' }; + var guard = form.querySelector('altcha-widget'); + + function say(text) { + err.textContent = text; + } + + function mark(field, bad) { + field.classList.toggle('vino-inp--invalid', bad); + field.setAttribute('aria-invalid', bad ? 'true' : 'false'); + } + + function message(code) { + var key = codes[code] || 'error'; + return form.dataset['msg' + key.charAt(0).toUpperCase() + key.slice(1)] || form.dataset.msgError; + } + + VinoAltcha.arm(guard); + + + form.addEventListener('input', function (event) { + if (event.target.classList.contains('vino-inp--invalid')) mark(event.target, false); + }); + form.elements.consent.addEventListener('change', function () { + form.querySelector('.vino-auth__consent').classList.remove('vino-consent--invalid'); + }); + + form.addEventListener('submit', function (event) { + event.preventDefault(); + var value = email.value.trim(); + var badEmail = !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value); + var badPassword = password.value === ''; + var badConsent = !form.elements.consent.checked; + mark(email, badEmail); + mark(password, badPassword); + form.querySelector('.vino-auth__consent').classList.toggle('vino-consent--invalid', badConsent); + form.elements.consent.setAttribute('aria-invalid', badConsent ? 'true' : 'false'); + if (badEmail || badPassword || badConsent) { + say(badEmail ? form.dataset.msgEmail : badPassword ? form.dataset.msgPassword : form.dataset.msgConsent); + (badEmail ? email : badPassword ? password : form.elements.consent).focus(); + return; + } + say(''); + submit.disabled = true; + VinoAltcha.armed(guard).then(function (ok) { + if (!ok) return Promise.reject({ errors: [{ code: 'altcha' }] }); + return BX.ajax.runAction('jinove:vinoteca.auth.login', { + data: { + email: value, + password: password.value, + remember: form.elements.remember.checked ? '1' : '', + consent: '1', + back: form.dataset.back || '', + lang: document.documentElement.lang || 'en', + website: form.elements.website.value, + elapsed: String(Date.now() - started), + altcha: form.elements.altcha ? form.elements.altcha.value : '' + } + }); + }).then(function (response) { + if (form.dataset.embed === '1') { + try { sessionStorage.setItem('vinoOpenReview', '1'); } catch (e) {} + window.location.reload(); + return; + } + window.location.href = (response.data && response.data.redirect) || '/'; + }, function (response) { + submit.disabled = false; + VinoAltcha.reset(guard); + var code = response && response.errors && response.errors[0] ? response.errors[0].code : ''; + if (code === 'invalid') { + mark(email, true); + mark(password, true); + } + say(message(code)); + }); + }); + } + + if (document.readyState === 'loading') { + document.addEventListener('DOMContentLoaded', init); + } else { + init(); + } +})(); diff --git a/local/components/jinove/auth.login/templates/.default/style.css b/local/components/jinove/auth.login/templates/.default/style.css new file mode 100644 index 0000000..a2a1da6 --- /dev/null +++ b/local/components/jinove/auth.login/templates/.default/style.css @@ -0,0 +1,234 @@ +.vino-auth { + display: grid; + grid-template-columns: minmax(0, 360px) minmax(0, 440px); + gap: clamp(var(--space-10), 7vw, 112px); + align-items: center; + justify-content: center; + min-height: 62vh; + padding: var(--space-head) var(--gutter) var(--space-section); +} +.vino-auth__aside-title { + margin: 0 0 var(--space-6); + font-family: var(--font-serif); + font-weight: 500; + font-size: clamp(1.6rem, 2.4vw, 2.1rem); +} +.vino-auth__perks { + display: grid; + gap: var(--space-6); + margin: 0; + padding: 0; + list-style: none; +} +.vino-auth__perk { + display: flex; + align-items: center; + gap: var(--space-3); +} +.vino-auth__perk-icon { + flex: 0 0 auto; + width: 23px; + height: 23px; + color: var(--color-accent); +} +.vino-auth__perk-title { + color: var(--color-text); + font-size: var(--text-base); + line-height: 1.4; +} +.vino-auth--embed { + display: block; + min-height: 0; + padding: 0; +} +.vino-auth--embed .vino-auth__card { + max-width: none; + padding: 0; + border: 0; + background: transparent; +} +.vino-auth__card { + width: 100%; + max-width: 440px; + padding: clamp(var(--space-6), 4vw, var(--space-10)); + background: var(--color-surface); + border: 1px solid var(--color-line); + border-top: 2px solid var(--color-accent); +} +.vino-auth__kicker { + margin: 0 0 var(--space-3); + color: var(--color-accent); + font-size: var(--text-13); + letter-spacing: var(--tracking-wide); + text-transform: uppercase; +} +.vino-auth__title { + margin: 0 0 var(--space-3); + font-family: var(--font-serif); + font-weight: 500; + font-size: clamp(2rem, 4vw, 2.6rem); + line-height: 1.08; +} +.vino-auth__lead { + margin: 0 0 var(--space-6); + color: var(--color-text-muted); + font-size: var(--text-15); + line-height: 1.5; +} +.vino-auth--single { + grid-template-columns: minmax(0, 560px); +} +.vino-auth--single .vino-auth__card { + max-width: 560px; +} +.vino-auth__demo { + margin: 0 0 var(--space-6); + padding: var(--space-3) var(--space-4); + background: color-mix(in srgb, var(--color-danger) 26%, transparent); + border: 1px solid color-mix(in srgb, var(--color-danger-soft) 50%, transparent); + color: var(--color-text); + font-size: var(--text-15); + line-height: 1.5; +} +.vino-auth__done { + margin: 0 0 var(--space-6); + color: var(--color-text); + font-size: var(--text-base); + line-height: 1.5; +} +.vino-auth__err--static { + min-height: 0; + margin-bottom: var(--space-4); +} +.vino-auth__form[hidden] { + display: none; +} +.vino-auth__form { + display: grid; + gap: var(--space-4); +} +.vino-auth__field { + display: grid; + gap: var(--space-2); +} +.vino-auth__label { + color: var(--color-accent); + font-size: var(--text-13); + letter-spacing: .14em; + text-transform: uppercase; +} +.vino-auth__hint { + color: var(--color-text-faint); + font-size: var(--text-13); + line-height: 1.5; +} +.vino-auth__input.vino-inp { + margin: 0; + padding: var(--space-3-5) var(--space-4); +} +.vino-auth__input.vino-inp--invalid { + border-color: var(--color-danger-soft); + box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-danger-soft) 20%, transparent); +} +.vino-auth__password { + position: relative; + display: block; +} +.vino-auth__password .vino-auth__input { + padding-right: 112px; +} +.vino-auth__toggle { + position: absolute; + top: 0; + right: 0; + bottom: 0; + padding: 0 var(--space-4); + border: 0; + background: transparent; + color: var(--color-text-muted); + font: inherit; + font-size: var(--text-13); + letter-spacing: .08em; + text-transform: uppercase; + cursor: pointer; + transition: color var(--duration-fast) var(--ease-base); +} +.vino-auth__toggle[hidden] { + display: none; +} +.vino-auth__toggle:focus-visible { + outline: 2px solid var(--color-accent); + outline-offset: -4px; +} +.vino-auth__consent.vino-consent--invalid .vino-consent__checkbox { + border-color: var(--color-danger-soft); + box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-danger-soft) 20%, transparent); +} +.vino-auth__link { + color: var(--color-accent); + font-size: var(--text-15); + text-decoration: none; + border-bottom: 1px solid color-mix(in srgb, var(--color-accent) 40%, transparent); + transition: color var(--duration-fast) var(--ease-base), border-color var(--duration-fast) var(--ease-base); +} +.vino-auth__err { + min-height: calc(1em * var(--leading-ui)); + margin: 0; + color: var(--color-danger-soft); + font-size: var(--text-13); + line-height: var(--leading-ui); +} +.vino-auth__form .vino-auth__submit { + justify-content: center; + width: 100%; + min-height: 52px; + text-align: center; +} +.vino-auth__form .vino-consent { + margin: 0; +} +.vino-auth__form .vino-consent--sm .vino-consent__text { + font-size: var(--text-13); + line-height: 1.5; +} +.vino-auth__links { + display: flex; + flex-wrap: wrap; + justify-content: center; + gap: var(--space-2) var(--space-6); +} +.vino-auth__input.vino-inp:-webkit-autofill, +.vino-auth__input.vino-inp:-webkit-autofill:focus { + border-color: var(--color-line-field); +} +@media (hover: hover) { + .vino-auth__toggle:hover { + color: var(--color-text); + } + .vino-auth__link:hover { + color: var(--color-accent-hover); + border-color: var(--color-accent-hover); + } +} +@media (max-width: 980px) { + .vino-auth:not(.vino-auth--embed):not(.vino-auth--single) { + grid-template-columns: minmax(0, 440px); + } + .vino-auth__aside { + display: none; + } +} +@media (max-width: 760px) { + .vino-auth__link { + position: relative; + } + .vino-auth__link::before { + content: ""; + position: absolute; + inset: -12px -6px; + } + .vino-auth__form .vino-consent { + padding-block: var(--space-3); + margin-block: -12px; + } +} diff --git a/local/components/jinove/auth.login/templates/.default/template.php b/local/components/jinove/auth.login/templates/.default/template.php new file mode 100644 index 0000000..4da77a5 --- /dev/null +++ b/local/components/jinove/auth.login/templates/.default/template.php @@ -0,0 +1,59 @@ + + +
"> + +
+

+
    +
  • +
  • +
  • +
+
+ +
+

+ < class="vino-auth__title">> +

+
" data-back="" + data-msg-email="" + data-msg-password="" + data-msg-consent="" + data-msg-invalid="" + data-msg-altcha="" + data-msg-too-often="" + data-msg-error="" + data-label-show="" + data-label-hide=""> + +
+ + +
+
+ + + + + +
+ + + + + + +
+
+
diff --git a/local/components/jinove/auth.register/class.php b/local/components/jinove/auth.register/class.php new file mode 100644 index 0000000..72db1aa --- /dev/null +++ b/local/components/jinove/auth.register/class.php @@ -0,0 +1,37 @@ +getContext()->getRequest(); + $safeBack = Redirect::safe((string)$request->getQuery("back")); + if ((int)CurrentUser::get()->getId() > 0) { + LocalRedirect($safeBack !== "" ? $safeBack : SITE_DIR); + } + $GLOBALS["APPLICATION"]->SetTitle(Loc::getMessage("VINO_REG_PAGE_TITLE")); + $GLOBALS["APPLICATION"]->SetPageProperty("description", Loc::getMessage("VINO_REG_PAGE_DESCRIPTION")); + $GLOBALS["APPLICATION"]->SetPageProperty("vino_alternates", "N"); + $GLOBALS["APPLICATION"]->SetPageProperty("vino_schema", "N"); + $GLOBALS["APPLICATION"]->SetPageProperty("robots", "noindex, nofollow"); + $this->arResult = [ + "BACK" => $safeBack, + "LOGIN_URL" => SITE_DIR . "login/" . ($safeBack !== "" ? "?back=" . rawurlencode($safeBack) : ""), + ]; + $this->includeComponentTemplate(); + + return $this->arResult; + } +} diff --git a/local/components/jinove/auth.register/lang/en/class.php b/local/components/jinove/auth.register/lang/en/class.php new file mode 100644 index 0000000..52d6592 --- /dev/null +++ b/local/components/jinove/auth.register/lang/en/class.php @@ -0,0 +1,3 @@ +personal data on the terms and for the purposes set out in the Privacy Policy.'; +$MESS["VINO_REG_ASIDE_TITLE"] = "After registering you will be able to"; +$MESS["VINO_REG_PERK_PROFILE"] = "Edit your profile and contact details"; +$MESS["VINO_REG_PERK_ORDERS"] = "View the history and status of orders"; +$MESS["VINO_REG_PERK_REVIEW"] = "Leave wine reviews"; +$MESS["VINO_REG_ERR_RETRY"] = "Please submit again"; +$MESS["VINO_REG_DEMO"] = "Registration is disabled on this demonstration site"; diff --git a/local/components/jinove/auth.register/templates/.default/lang/pl/template.php b/local/components/jinove/auth.register/templates/.default/lang/pl/template.php new file mode 100644 index 0000000..315b060 --- /dev/null +++ b/local/components/jinove/auth.register/templates/.default/lang/pl/template.php @@ -0,0 +1,26 @@ +danych osobowych na warunkach i w celach określonych w Polityce prywatności.'; +$MESS["VINO_REG_ASIDE_TITLE"] = "Po rejestracji możesz"; +$MESS["VINO_REG_PERK_PROFILE"] = "Edytować profil i dane kontaktowe"; +$MESS["VINO_REG_PERK_ORDERS"] = "Przeglądać historię i status zamówień"; +$MESS["VINO_REG_PERK_REVIEW"] = "Dodawać opinie o winach"; +$MESS["VINO_REG_ERR_RETRY"] = "Wyślij ponownie"; +$MESS["VINO_REG_DEMO"] = "Na stronie demonstracyjnej rejestracja jest wyłączona"; diff --git a/local/components/jinove/auth.register/templates/.default/lang/ru/template.php b/local/components/jinove/auth.register/templates/.default/lang/ru/template.php new file mode 100644 index 0000000..59d1c01 --- /dev/null +++ b/local/components/jinove/auth.register/templates/.default/lang/ru/template.php @@ -0,0 +1,26 @@ +персональных данных на условиях и для целей, определённых Политикой конфиденциальности.'; +$MESS["VINO_REG_ASIDE_TITLE"] = "После регистрации вы сможете"; +$MESS["VINO_REG_PERK_PROFILE"] = "Редактировать профиль и контактные данные"; +$MESS["VINO_REG_PERK_ORDERS"] = "Просматривать историю и статус заказов"; +$MESS["VINO_REG_PERK_REVIEW"] = "Оставлять отзывы о винах"; +$MESS["VINO_REG_ERR_RETRY"] = "Повторите отправку"; +$MESS["VINO_REG_DEMO"] = "На демонстрационном сайте регистрация отключена"; diff --git a/local/components/jinove/auth.register/templates/.default/script.js b/local/components/jinove/auth.register/templates/.default/script.js new file mode 100644 index 0000000..686cdbb --- /dev/null +++ b/local/components/jinove/auth.register/templates/.default/script.js @@ -0,0 +1,89 @@ +(function () { + function init() { + var form = document.querySelector('[data-auth-register]'); + if (!form || !window.BX || !BX.ajax || !BX.ajax.runAction) return; + var name = form.elements.name; + var email = form.elements.email; + var password = form.elements.password; + var submit = form.querySelector('[type="submit"]'); + var err = form.querySelector('[data-auth-err]'); + var started = Date.now(); + var codes = { too_often: 'tooOften', altcha: 'altcha', retry: 'retry' }; + var guard = form.querySelector('altcha-widget'); + + function say(text) { + err.textContent = text; + } + + function mark(field, bad) { + field.classList.toggle('vino-inp--invalid', bad); + field.setAttribute('aria-invalid', bad ? 'true' : 'false'); + } + + function message(code) { + var key = codes[code] || 'error'; + return form.dataset['msg' + key.charAt(0).toUpperCase() + key.slice(1)] || form.dataset.msgError; + } + + VinoAltcha.arm(guard); + + + form.addEventListener('input', function (event) { + if (event.target.classList.contains('vino-inp--invalid')) mark(event.target, false); + }); + form.elements.consent.addEventListener('change', function () { + form.querySelector('.vino-auth__consent').classList.remove('vino-consent--invalid'); + }); + + form.addEventListener('submit', function (event) { + event.preventDefault(); + var nameValue = name.value.trim(); + var emailValue = email.value.trim(); + var badName = nameValue === ''; + var badEmail = !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(emailValue); + var badPassword = password.value.length < 8; + var badConsent = !form.elements.consent.checked; + mark(name, badName); + mark(email, badEmail); + mark(password, badPassword); + form.querySelector('.vino-auth__consent').classList.toggle('vino-consent--invalid', badConsent); + form.elements.consent.setAttribute('aria-invalid', badConsent ? 'true' : 'false'); + if (badName || badEmail || badPassword || badConsent) { + say(badName ? form.dataset.msgName : badEmail ? form.dataset.msgEmail : badPassword ? form.dataset.msgPassword : form.dataset.msgConsent); + (badName ? name : badEmail ? email : badPassword ? password : form.elements.consent).focus(); + return; + } + say(''); + submit.disabled = true; + VinoAltcha.armed(guard).then(function (ok) { + if (!ok) return Promise.reject({ errors: [{ code: 'altcha' }] }); + return BX.ajax.runAction('jinove:vinoteca.register.create', { + data: { + name: nameValue, + email: emailValue, + password: password.value, + consent: '1', + back: form.dataset.back || '', + lang: document.documentElement.lang || 'en', + website: form.elements.website.value, + elapsed: String(Date.now() - started), + altcha: form.elements.altcha ? form.elements.altcha.value : '' + } + }); + }).then(function (response) { + window.location.href = (response.data && response.data.redirect) || '/'; + }, function (response) { + submit.disabled = false; + VinoAltcha.reset(guard); + var code = response && response.errors && response.errors[0] ? response.errors[0].code : ''; + say(message(code)); + }); + }); + } + + if (document.readyState === 'loading') { + document.addEventListener('DOMContentLoaded', init); + } else { + init(); + } +})(); diff --git a/local/components/jinove/auth.register/templates/.default/template.php b/local/components/jinove/auth.register/templates/.default/template.php new file mode 100644 index 0000000..69e27b2 --- /dev/null +++ b/local/components/jinove/auth.register/templates/.default/template.php @@ -0,0 +1,63 @@ +addExternalCss("/local/components/jinove/auth.login/templates/.default/style.css"); +$uid = "vino-reg"; +?> +
+
+

+
    +
  • +
  • +
  • +
+
+
+

+

+

+

+
" + data-msg-name="" + data-msg-email="" + data-msg-password="" + data-msg-consent="" + data-msg-altcha="" + data-msg-too-often="" + data-msg-retry="" + data-msg-error="" + data-label-show="" + data-label-hide=""> + +
+ + +
+
+ + +
+
+ + + + + + +
+ + + + + +
+
+
diff --git a/local/components/jinove/auth.reset/class.php b/local/components/jinove/auth.reset/class.php new file mode 100644 index 0000000..3f04562 --- /dev/null +++ b/local/components/jinove/auth.reset/class.php @@ -0,0 +1,42 @@ +getId() > 0) { + LocalRedirect(SITE_DIR); + } + $request = Application::getInstance()->getContext()->getRequest(); + $rawLogin = $request->getQuery("login"); + $rawCheckword = $request->getQuery("checkword"); + $login = is_string($rawLogin) ? $rawLogin : ""; + $checkword = is_string($rawCheckword) ? $rawCheckword : ""; + $GLOBALS["APPLICATION"]->SetTitle(Loc::getMessage("VINO_RESET_PAGE_TITLE")); + $GLOBALS["APPLICATION"]->SetPageProperty("description", Loc::getMessage("VINO_RESET_PAGE_DESCRIPTION")); + $GLOBALS["APPLICATION"]->SetPageProperty("vino_alternates", "N"); + $GLOBALS["APPLICATION"]->SetPageProperty("vino_schema", "N"); + $GLOBALS["APPLICATION"]->SetPageProperty("robots", "noindex, nofollow"); + $GLOBALS["APPLICATION"]->AddHeadString(''); + $this->arResult = [ + "LOGIN" => mb_strlen($login) <= 254 ? $login : "", + "CHECKWORD" => preg_match('/^[A-Za-z0-9]{32}$/', $checkword) ? $checkword : "", + "LOGIN_URL" => SITE_DIR . "login/", + "FORGOT_URL" => SITE_DIR . "forgot-password/", + ]; + $this->includeComponentTemplate(); + + return $this->arResult; + } +} diff --git a/local/components/jinove/auth.reset/lang/en/class.php b/local/components/jinove/auth.reset/lang/en/class.php new file mode 100644 index 0000000..ef197b7 --- /dev/null +++ b/local/components/jinove/auth.reset/lang/en/class.php @@ -0,0 +1,3 @@ +addExternalCss("/local/components/jinove/auth.login/templates/.default/style.css"); +$uid = "vino-reset"; +$valid = $arResult["LOGIN"] !== "" && $arResult["CHECKWORD"] !== ""; +?> +
+
+

+

+ + + + + +

+
" + data-checkword="" + data-again="" + data-msg-password="" + data-msg-again="" + data-msg-link="" + data-msg-altcha="" + data-msg-too-often="" + data-msg-retry="" + data-msg-error="" + data-label-show="" + data-label-hide=""> + +
+ + + + + + +
+ + + +
+ +
+
diff --git a/local/components/jinove/cart/class.php b/local/components/jinove/cart/class.php new file mode 100644 index 0000000..42dc343 --- /dev/null +++ b/local/components/jinove/cart/class.php @@ -0,0 +1,42 @@ +SetTitle(Loc::getMessage("VINO_CART_PAGE_TITLE")); + $APPLICATION->SetPageProperty("title", Loc::getMessage("VINO_CART_BROWSER_TITLE")); + $APPLICATION->SetPageProperty("description", Loc::getMessage("VINO_CART_PAGE_DESCRIPTION")); + $APPLICATION->SetPageProperty("vino_alternates", "N"); + $APPLICATION->SetPageProperty("vino_schema", "N"); + $APPLICATION->SetPageProperty("robots", "noindex, nofollow"); + $basket = Cart::load(); + $shareCode = (string)Context::getCurrent()->getRequest()->getQuery("share"); + $shareItems = $basket !== null && $shareCode !== "" ? Cart::parseShare($shareCode) : []; + $this->arResult = [ + "TITLE" => (string)Loc::getMessage("VINO_CART_PAGE_TITLE"), + "SHARED" => $shareItems ? Cart::shared($shareItems) : null, + "SHARE_REQUESTED" => $shareCode !== "", + "CART_URL" => SITE_DIR . "personal/cart/", + "CART" => $basket !== null ? Cart::view($basket) : ["count" => 0, "summary" => "", "items" => [], "base" => "", "discount" => "", "total" => "", "coupons" => []], + "CATALOG_URL" => SITE_DIR . "catalog/", + "CHECKOUT_URL" => SITE_DIR . "personal/order/", + "MAX_QUANTITY" => Cart::MAX_QUANTITY, + ]; + $this->includeComponentTemplate(); + + return $this->arResult; + } +} diff --git a/local/components/jinove/cart/lang/en/class.php b/local/components/jinove/cart/lang/en/class.php new file mode 100644 index 0000000..69cad2e --- /dev/null +++ b/local/components/jinove/cart/lang/en/class.php @@ -0,0 +1,4 @@ +'; + li.appendChild(span); + li.appendChild(button); + return li; + } + + function lock(li, on) { + var removed = field(li, 'removed'); + Array.prototype.forEach.call(li.children, function (child) { + if (child !== removed) child.inert = on; + }); + li.classList.toggle('vino-cart__item--removed', on); + removed.hidden = !on; + } + + function patch(cart) { + var seen = {}; + cart.items.forEach(function (data) { + var li = item(data.id); + if (!li) return; + seen[data.id] = true; + if (!timers[data.id]) { + if (li.classList.contains('vino-cart__item--removed')) lock(li, false); + field(li, 'value').textContent = data.quantity; + } + li.classList.toggle('vino-cart__item--unavailable', !data.available); + field(li, 'unavailable').hidden = data.available; + field(li, 'price').textContent = data.price; + var old = field(li, 'old'); + old.textContent = data.basePrice; + old.hidden = !data.basePrice; + field(li, 'sum').textContent = data.sum; + }); + root.querySelectorAll('[data-cart-item]').forEach(function (li) { + var id = li.getAttribute('data-cart-item'); + var removed = li.classList.contains('vino-cart__item--removed'); + if (!seen[id] && !timers[id] && (clearing || !removed)) li.remove(); + }); + root.querySelector('[data-cart-count-text]').textContent = cart.summary; + root.querySelector('[data-cart-base]').textContent = cart.base; + root.querySelector('[data-cart-total]').textContent = cart.total; + root.querySelector('[data-cart-discount]').textContent = cart.discount || '—'; + root.querySelector('[data-cart-discount-line]').classList.toggle('vino-cart__line--none', !cart.discount); + couponList.textContent = ''; + var applied = 0; + cart.coupons.forEach(function (coupon) { + if (!coupon.applied) return; + couponList.appendChild(couponRow(coupon.code)); + applied++; + }); + if (!applied) couponExpanded = false; + couponRowBox.hidden = applied > 0 && !couponExpanded; + couponHint.hidden = couponRowBox.hidden; + couponMore.hidden = applied === 0 || couponExpanded; + var left = root.querySelectorAll('[data-cart-item]').length; + layout.hidden = !left; + empty.hidden = !!left; + } + + function apply(res, sent) { + var data = res && res.data; + if (!data || !data.cart || sent !== version) return; + if (data.state) document.dispatchEvent(new CustomEvent('vino:basket', { detail: data.state })); + showFail(!data.ok); + patch(data.cart); + } + + function recover(sent) { + if (sent !== version) return; + showFail(true); + BX.ajax.runAction('jinove:vinoteca.basket.cart', { method: 'GET' }).then(function (res) { + if (sent === version && res.data && res.data.cart) { + if (res.data.state) document.dispatchEvent(new CustomEvent('vino:basket', { detail: res.data.state })); + patch(res.data.cart); + } + }, noop); + } + + function busy() { + root.classList.toggle('vino-cart--busy', inflight > 0 || Object.keys(timers).length > 0); + } + + function request(action, data) { + var run = function () { + return BX.ajax.runAction('jinove:vinoteca.basket.' + action, { data: data || {} }); + }; + inflight++; + busy(); + var result = queue.then(run); + queue = result.then(noop, noop); + queue.then(function () { + inflight--; + busy(); + }); + return result; + } + + function call(action, data) { + version++; + var sent = version; + return request(action, data).then(function (res) { + apply(res, sent); + return res; + }, function (res) { + recover(sent); + throw res; + }); + } + + function send(id, qty) { + clearTimeout(timers[id]); + timers[id] = setTimeout(function () { + delete timers[id]; + call('update', { id: id, qty: qty }).then(noop, noop); + }, 350); + busy(); + } + + function cancel(id) { + clearTimeout(timers[id]); + delete timers[id]; + busy(); + } + + function step(li, delta) { + var id = li.getAttribute('data-cart-item'); + var value = field(li, 'value'); + var qty = Math.max(1, Math.min(max, (parseInt(value.textContent, 10) || 1) + delta)); + if (String(qty) === value.textContent) return; + value.textContent = qty; + send(id, qty); + } + + function remove(li) { + var id = li.getAttribute('data-cart-item'); + li.setAttribute('data-cart-was', field(li, 'value').textContent); + cancel(id); + lock(li, true); + field(li, 'restore').focus(); + call('update', { id: id, qty: 0 }).then(noop, noop); + } + + function restore(li) { + var id = li.getAttribute('data-cart-item'); + var qty = parseInt(li.getAttribute('data-cart-was'), 10) || 1; + cancel(id); + lock(li, false); + field(li, 'value').textContent = qty; + field(li, 'remove').focus(); + call('update', { id: id, qty: qty }).then(noop, noop); + } + + function flush() { + Object.keys(timers).forEach(function (id) { + var li = item(id); + cancel(id); + if (li) call('update', { id: id, qty: parseInt(field(li, 'value').textContent, 10) || 1 }).then(noop, noop); + }); + } + + function checkout(link, e) { + if (!root.classList.contains('vino-cart--busy')) return; + e.preventDefault(); + if (link.getAttribute('aria-busy') === 'true') return; + link.setAttribute('aria-busy', 'true'); + flush(); + queue.then(function () { + link.removeAttribute('aria-busy'); + if (fail.hidden) location.href = link.href; + }); + } + + function toggleConfirm(on) { + confirmBox.hidden = !on; + actions.hidden = on; + (on ? root.querySelector('[data-cart-clear-no]') : clearButton).focus(); + } + + function clearCart() { + confirmBox.hidden = true; + actions.hidden = false; + Object.keys(timers).forEach(cancel); + clearing = true; + layout.hidden = true; + empty.hidden = false; + emptyTitle.focus(); + call('clear').then(noop, noop).then(function () { clearing = false; }); + } + + function shareLink() { + var pairs = []; + root.querySelectorAll('[data-cart-item]:not(.vino-cart__item--removed)').forEach(function (li) { + pairs.push(li.getAttribute('data-cart-item') + '-' + (parseInt(field(li, 'value').textContent, 10) || 1)); + }); + return location.origin + location.pathname + '?share=' + pairs.join('.'); + } + + function copied() { + var done = root.querySelector('[data-cart-share-done]').textContent; + shareButton.classList.add('vino-cart__share--done'); + shareStatus.textContent = done; + clearTimeout(shareTimer); + shareTimer = setTimeout(function () { + shareButton.classList.remove('vino-cart__share--done'); + shareStatus.textContent = ''; + }, 2500); + } + + function showLink(link) { + var input = shareFallback.querySelector('[data-cart-share-input]'); + input.value = link; + shareFallback.hidden = false; + input.focus(); + input.select(); + } + + function share() { + var link = shareLink(); + shareFallback.hidden = true; + if (navigator.share && window.matchMedia('(pointer: coarse)').matches) { + navigator.share({ title: shareButton.getAttribute('data-title'), url: link }).catch(noop); + return; + } + if (navigator.clipboard && window.isSecureContext) { + navigator.clipboard.writeText(link).then(copied, function () { showLink(link); }); + return; + } + showLink(link); + } + + function addShared(button) { + var box = button.closest('[data-cart-shared]'); + button.disabled = true; + BX.ajax.runAction('jinove:vinoteca.basket.addShared', { data: { code: box.getAttribute('data-cart-shared') } }).then(function () { + location.replace(box.getAttribute('data-cart-url')); + }, function () { + button.disabled = false; + showFail(true); + }); + } + + function expandCoupon() { + couponExpanded = true; + couponRowBox.hidden = false; + couponMore.hidden = true; + couponInput.focus(); + } + + function couponFail(message) { + couponError.textContent = message; + couponError.hidden = !message; + couponForm.classList.toggle('vino-cart__coupon--error', !!message); + couponInput.setAttribute('aria-invalid', message ? 'true' : 'false'); + } + + root.addEventListener('click', function (e) { + var target = e.target.closest('button'); + if (!target || !root.contains(target)) return; + var li = target.closest('[data-cart-item]'); + if (target.hasAttribute('data-cart-step') && li) step(li, parseInt(target.getAttribute('data-cart-step'), 10)); + else if (target.hasAttribute('data-cart-remove') && li) remove(li); + else if (target.hasAttribute('data-cart-restore') && li) restore(li); + else if (target.hasAttribute('data-cart-share')) share(); + else if (target.hasAttribute('data-cart-shared-add')) addShared(target); + else if (target.hasAttribute('data-cart-coupon-more')) expandCoupon(); + else if (target.hasAttribute('data-cart-clear')) toggleConfirm(true); + else if (target.hasAttribute('data-cart-clear-no')) toggleConfirm(false); + else if (target.hasAttribute('data-cart-clear-yes')) clearCart(); + else if (target.hasAttribute('data-cart-coupon-remove')) { + call('couponRemove', { code: target.getAttribute('data-cart-coupon-remove') }).then(function () { couponInput.focus(); }, noop); + } + }); + + root.addEventListener('click', function (e) { + var link = e.target.closest('[data-cart-checkout]'); + if (link) checkout(link, e); + }); + + root.addEventListener('keydown', function (e) { + if (e.key !== 'Escape') return; + if (!confirmBox.hidden) toggleConfirm(false); + else if (!shareFallback.hidden) { + shareFallback.hidden = true; + shareButton.focus(); + } + }); + + couponForm.addEventListener('submit', function (e) { + e.preventDefault(); + var code = couponInput.value.trim(); + if (!code) { + couponFail(text('coupon-empty')); + couponInput.focus(); + return; + } + couponFail(''); + var button = couponForm.querySelector('[type="submit"]'); + button.disabled = true; + version++; + var sent = version; + request('coupon', { code: code }).then(function (res) { + button.disabled = false; + couponInput.value = ''; + couponExpanded = false; + apply(res, sent); + var chip = couponList.querySelector('button'); + if (chip) chip.focus(); + }, function (res) { + var error = res && res.errors && res.errors[0]; + button.disabled = false; + if (error && error.code === 'coupon') couponFail(text('coupon-error')); + else showFail(true); + couponInput.focus(); + }); + }); + + couponHint.addEventListener('click', function (e) { + var fill = e.target.closest('[data-cart-coupon-fill]'); + if (!fill) return; + couponInput.value = fill.getAttribute('data-cart-coupon-fill'); + couponInput.dispatchEvent(new Event('input')); + couponInput.focus(); + }); + + couponInput.addEventListener('input', function () { + if (!couponError.hidden) couponFail(''); + }); +})(); diff --git a/local/components/jinove/cart/templates/.default/style.css b/local/components/jinove/cart/templates/.default/style.css new file mode 100644 index 0000000..ed7b244 --- /dev/null +++ b/local/components/jinove/cart/templates/.default/style.css @@ -0,0 +1,659 @@ +.vino-cart { + --vino-cart-summary-width: 360px; + --vino-cart-field-height: 48px; + --vino-cart-qty-width: 120px; + --vino-cart-shared-sum-width: 110px; + --vino-cart-icon-sm: 14px; + --vino-cart-icon: 20px; + --vino-cart-disabled-opacity: .45; + --vino-cart-shared-pic-width: 72px; + --vino-cart-shared-pic-height: 90px; + --vino-cart-pic-width: 80px; + --vino-cart-pic-height: 100px; + padding: var(--space-10) var(--gutter) var(--space-section); +} +.vino-cart__layout, +.vino-cart__empty { + max-width: var(--container); + margin: 0 auto; +} +.vino-cart__layout { + display: grid; + grid-template-columns: minmax(0, 1fr) var(--vino-cart-summary-width); + gap: var(--space-grid-wide); + align-items: start; +} +.vino-cart__layout[hidden], +.vino-cart__empty[hidden] { + display: none; +} +.vino-cart__main { + min-width: 0; + container: vino-cart-main / inline-size; +} +.vino-cart__toolbar { + position: relative; + display: flex; + flex-wrap: wrap; + align-items: center; + justify-content: space-between; + gap: var(--space-3) var(--space-6); + min-height: var(--size-tap); + padding-bottom: var(--space-4); + border-bottom: 1px solid var(--color-line); +} +.vino-cart__count { + margin: 0; + color: var(--color-text-muted); + font-size: var(--text-15); +} +.vino-cart__actions { + display: flex; + flex-wrap: wrap; + gap: 0 var(--space-6); +} +.vino-cart__actions[hidden] { + display: none; +} +.vino-cart__share { + display: inline-grid; + align-items: center; +} +.vino-cart__share-label { + grid-area: 1 / 1; + transition: opacity var(--duration-fast) var(--ease-base); +} +.vino-cart__share-label--done, +.vino-cart__share--done .vino-cart__share-label--idle { + opacity: 0; +} +.vino-cart__share--done .vino-cart__share-label--done { + opacity: 1; +} +.vino-cart__share-fallback { + position: absolute; + top: 100%; + right: 0; + z-index: 2; + display: block; + width: min(420px, 100%); + margin-top: var(--space-2); + padding: var(--space-3); + background: var(--color-surface); + border: 1px solid var(--color-line); + border-radius: var(--radius-sm); +} +.vino-cart__share-fallback[hidden] { + display: none; +} +.vino-cart__share-input.vino-inp { + width: 100%; + margin: 0; +} +.vino-cart__shared { + max-width: var(--container); + margin: 0 auto var(--space-10); + padding: var(--space-card); + background: var(--color-surface); + border: 1px solid color-mix(in srgb, var(--color-accent) 40%, transparent); + border-radius: var(--radius-sm); +} +.vino-cart__shared-title { + margin: 0; + font-family: var(--font-serif); + font-size: var(--fs-h4); + font-weight: 400; + line-height: var(--leading-title); +} +.vino-cart__shared-hint { + margin: var(--space-2) 0 0; + color: var(--color-text-muted); + font-size: var(--text-15); +} +.vino-cart__shared-list { + margin: var(--space-4) 0 0; + padding: 0; + list-style: none; +} +.vino-cart__shared-item { + display: grid; + grid-template-columns: var(--vino-cart-shared-pic-width) minmax(0, 1fr) auto var(--vino-cart-shared-sum-width); + align-items: center; + gap: var(--space-4); + padding: var(--space-2) 0; + border-bottom: 1px solid var(--color-line); + font-size: var(--text-15); +} +.vino-cart__shared-pic { + position: relative; + display: flex; + width: var(--vino-cart-shared-pic-width); + height: var(--vino-cart-shared-pic-height); + background: var(--color-bg); + border-radius: var(--radius-sm); + overflow: hidden; +} +.vino-cart__shared-name { + color: var(--color-text); + text-decoration: none; + transition: color var(--duration-fast) var(--ease-base); +} +.vino-cart__shared-qty { + color: var(--color-text-muted); + font-variant-numeric: tabular-nums; +} +.vino-cart__shared-sum { + font-variant-numeric: tabular-nums; + text-align: right; + white-space: nowrap; +} +.vino-cart__shared-foot { + display: flex; + flex-wrap: wrap; + align-items: center; + gap: var(--space-3); + margin-top: var(--space-4); +} +.vino-cart__shared-total { + margin: 0 auto 0 0; + color: var(--color-text-muted); + font-size: var(--text-15); +} +.vino-cart__shared-total-value { + color: var(--color-text); + font-weight: 600; +} +.vino-cart__link, +.vino-cart__restore { + min-height: var(--size-tap); + padding: 0; + border: 0; + background: none; + color: var(--color-accent); + font-family: var(--font-sans); + font-size: var(--text-13); + letter-spacing: var(--tracking-sm); + text-transform: uppercase; + cursor: pointer; +} +.vino-cart__confirm { + display: flex; + flex-wrap: wrap; + align-items: center; + gap: var(--space-3); +} +.vino-cart__confirm[hidden] { + display: none; +} +.vino-cart__confirm-text { + margin: 0; + font-size: var(--text-15); +} +.vino-cart__fail { + margin: var(--space-4) 0 0; + color: var(--color-danger-soft); + font-size: var(--text-15); +} +.vino-cart__list { + margin: 0; + padding: 0; + list-style: none; +} +.vino-cart__item { + position: relative; + display: grid; + grid-template-columns: var(--vino-cart-pic-width) minmax(0, 1fr) auto var(--vino-cart-qty-width) var(--size-tap); + align-items: center; + gap: var(--space-6); + padding: var(--space-4) 0; + border-bottom: 1px solid var(--color-line); +} +.vino-cart__pic { + position: relative; + display: flex; + align-items: center; + justify-content: center; + width: var(--vino-cart-pic-width); + height: var(--vino-cart-pic-height); + background: var(--color-surface); + border-radius: var(--radius-sm); + overflow: hidden; +} +.vino-cart__img { + width: 100%; + height: 100%; + object-fit: cover; +} +.vino-cart__info { + min-width: 0; +} +.vino-cart__name { + display: inline-block; + color: var(--color-text); + font-family: var(--font-serif); + font-size: var(--fs-h4); + line-height: var(--leading-title); + text-decoration: none; + transition: color var(--duration-fast) var(--ease-base); +} +.vino-cart__meta { + margin: var(--space-1) 0 0; + color: var(--color-text-faint); + font-size: var(--text-13); + line-height: var(--leading-ui); +} +.vino-cart__unit { + margin: var(--space-2) 0 0; + color: var(--color-text-muted); + font-size: var(--text-13); +} +.vino-cart__old { + margin-left: var(--space-2); + color: var(--color-text-faint); +} +.vino-cart__old[hidden], +.vino-cart__warning[hidden] { + display: none; +} +.vino-cart__warning { + margin: var(--space-2) 0 0; + color: var(--color-danger-soft); + font-size: var(--text-13); +} +.vino-cart__item--unavailable .vino-cart__pic, +.vino-cart__item--unavailable .vino-cart__sum { + opacity: var(--vino-cart-disabled-opacity); +} +.vino-cart__qty { + display: inline-flex; + align-items: center; + height: var(--size-tap); + border-bottom: 1px solid color-mix(in srgb, var(--color-accent) 55%, transparent); + border-radius: 0; +} +.vino-cart__step { + display: flex; + align-items: center; + justify-content: center; + width: var(--size-tap); + height: calc(var(--size-tap) - 1px); + padding: 0; + border: 0; + border-radius: 0; + background: transparent; + color: var(--color-accent); + cursor: pointer; + transition: background var(--duration-fast) var(--ease-base), color var(--duration-fast) var(--ease-base); +} +.vino-cart__step-icon { + width: var(--vino-cart-icon-sm); + height: var(--vino-cart-icon-sm); +} +.vino-cart__value { + display: flex; + align-items: center; + justify-content: center; + align-self: stretch; + min-width: 3ch; + color: var(--color-text); + font-size: var(--text-15); + font-weight: 600; + font-variant-numeric: tabular-nums; + text-align: center; +} +.vino-cart__sum { + margin: 0; + color: var(--color-accent); + font-size: var(--text-17); + font-weight: 600; + font-variant-numeric: tabular-nums; + text-align: right; + white-space: nowrap; +} +.vino-cart__remove, +.vino-cart__coupon-remove { + display: flex; + align-items: center; + justify-content: center; + width: var(--size-tap); + height: var(--size-tap); + padding: 0; + border: 0; + background: none; + color: var(--color-text-faint); + cursor: pointer; + transition: color var(--duration-fast) var(--ease-base); +} +.vino-cart__remove-icon { + width: var(--vino-cart-icon); + height: var(--vino-cart-icon); +} +.vino-cart__removed { + position: absolute; + inset: 0; + display: flex; + align-items: center; + justify-content: space-between; + gap: var(--space-4); + padding: 0 var(--space-4); + background: var(--color-bg); + font-size: var(--text-15); +} +.vino-cart__removed[hidden] { + display: none; +} +.vino-cart__removed-text { + color: var(--color-text-muted); +} +.vino-cart__summary { + position: sticky; + top: calc(var(--size-header) + var(--space-6)); + padding: var(--space-card); + background: var(--color-surface); + border: 1px solid var(--color-line); + border-radius: var(--radius-sm); +} +.vino-cart__summary-title { + margin: 0 0 var(--space-6); + font-family: var(--font-serif); + font-size: var(--fs-h4); + font-weight: 400; + line-height: var(--leading-title); +} +.vino-cart__coupon-head { + position: relative; + display: flex; + align-items: baseline; + justify-content: space-between; + gap: var(--space-3); + margin-bottom: var(--space-2); +} +.vino-cart__coupon-more { + position: relative; + padding: 0; + border: 0; + background: none; + color: var(--color-accent); + font-family: var(--font-sans); + font-size: var(--text-13); + cursor: pointer; + transition: color var(--duration-fast) var(--ease-base); +} +.vino-cart__coupon-more[hidden] { + display: inline; + visibility: hidden; +} +.vino-cart__coupon-more::before { + content: ""; + position: absolute; + inset: -12px -8px; +} +.vino-cart__label { + display: block; + margin-bottom: var(--space-2); + color: var(--color-text-muted); + font-size: var(--text-13); +} +.vino-cart__coupon-head .vino-cart__label { + margin-bottom: 0; +} +.vino-cart__coupon-row { + display: flex; + gap: var(--space-2); +} +.vino-cart__coupon-row[hidden] { + display: none; +} +.vino-cart__coupon-row:not([hidden]) + .vino-cart__coupons:not(:empty) { + margin-top: var(--space-3); +} +.vino-cart__coupon-hint { + margin: var(--space-2) 0 0; + color: var(--color-text-muted); + font-size: var(--text-13); + line-height: var(--leading-ui); +} +.vino-cart__coupon-hint-line { + display: block; +} +.vino-cart__coupon-fill { + padding: 0; + border: 0; + background: none; + color: var(--color-accent); + font: inherit; + font-weight: 600; + cursor: pointer; + transition: color var(--duration-fast) var(--ease-base), transform var(--duration-fast) var(--ease-base); +} +.vino-cart__coupon-fill:active { + transform: scale(.97); +} +.vino-cart__coupon-hint[hidden] { + display: none; +} +.vino-cart__coupon-input.vino-inp { + flex: 1 1 auto; + min-width: 0; + min-height: var(--vino-cart-field-height); + margin: 0; + background: transparent; +} +.vino-cart__coupon-apply.vino-btn { + flex: 0 0 auto; + justify-content: center; + padding-top: 0; + padding-bottom: 0; +} +.vino-cart__coupon--error .vino-cart__coupon-input { + border-color: var(--color-danger-soft); + box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-danger-soft) 22%, transparent); +} +.vino-cart__error { + min-height: calc(var(--text-13) * 1.45); + margin: var(--space-2) 0 0; + color: var(--color-danger-soft); + font-size: var(--text-13); + line-height: var(--leading-ui); +} +.vino-cart__error[hidden] { + display: block; + visibility: hidden; +} +.vino-cart__coupons { + margin: 0; + padding: 0; + list-style: none; +} +.vino-cart__coupon-item { + display: flex; + align-items: center; + height: var(--vino-cart-field-height); + justify-content: space-between; + padding-left: var(--space-3); + border: 1px dashed var(--color-line-field); + border-radius: var(--radius-sm); + font-size: var(--text-15); + letter-spacing: var(--tracking-xs); +} +.vino-cart__coupon-item + .vino-cart__coupon-item { + margin-top: var(--space-2); +} +.vino-cart__totals { + margin: 0 0 var(--space-6); + padding-top: var(--space-4); + border-top: 1px solid var(--color-line); +} +.vino-cart__sum, +.vino-cart__count, +.vino-cart__totals { + transition: opacity var(--duration-fast) var(--ease-base); +} +.vino-cart__checkout[aria-busy="true"] { + opacity: .6; + pointer-events: none; +} +.vino-cart--busy .vino-cart__sum, +.vino-cart--busy .vino-cart__count, +.vino-cart--busy .vino-cart__totals { + opacity: .45; +} +.vino-cart__line { + display: flex; + justify-content: space-between; + gap: var(--space-4); + padding: var(--space-1) 0; + color: var(--color-text-muted); + font-size: var(--text-15); +} +.vino-cart__line[hidden] { + display: none; +} +.vino-cart__term, +.vino-cart__value-line { + margin: 0; +} +.vino-cart__value-line { + font-variant-numeric: tabular-nums; + white-space: nowrap; +} +.vino-cart__line--discount .vino-cart__value-line { + color: var(--color-accent); +} +.vino-cart__line--none .vino-cart__value-line { + color: var(--color-text-faint); +} +.vino-cart__line--total { + margin-top: var(--space-2); + color: var(--color-text); + font-size: var(--text-19); + font-weight: 600; +} +.vino-cart__checkout { + justify-content: center; + width: 100%; + min-height: var(--size-tap); +} +.vino-cart__empty { + padding: var(--space-16) 0; + text-align: center; +} +.vino-cart__empty-title { + margin: 0; + font-family: var(--font-serif); + font-size: var(--fs-h3); + line-height: var(--leading-title); +} +.vino-cart__empty-text { + margin: var(--space-3) 0 var(--space-8); + color: var(--color-text-muted); +} +@media (hover: hover) { + .vino-cart__coupon-apply.vino-btn:hover { + transform: none; + } + .vino-cart__coupon-more:hover, + .vino-cart__coupon-fill:hover { + color: var(--color-accent-hover); + } + .vino-cart__name:hover, + .vino-cart__shared-name:hover { + color: var(--color-accent); + } + .vino-cart__step:hover { + color: var(--color-text); + } + .vino-cart__remove:hover, + .vino-cart__coupon-remove:hover { + color: var(--color-accent); + } + .vino-cart__link:hover, + .vino-cart__restore:hover { + color: var(--color-accent-hover); + } +} +@media (pointer: coarse) { + .vino-cart__name, + .vino-cart__shared-name { + position: relative; + } + .vino-cart__name::before, + .vino-cart__shared-name::before { + content: ""; + position: absolute; + inset: calc((var(--size-tap) - 100%) / -2) 0; + } +} +@media (max-width: 980px) { + .vino-cart__layout { + grid-template-columns: minmax(0, 1fr); + } + .vino-cart__summary { + position: static; + } +} +@media (max-width: 560px) { + .vino-cart { + --vino-cart-pic-width: 72px; + --vino-cart-pic-height: 90px; + padding-top: var(--space-6); + } + .vino-cart__shared-item { + grid-template-columns: var(--vino-cart-shared-pic-width) auto minmax(0, 1fr); + grid-template-areas: + "pic name name" + "pic qty sum"; + gap: var(--space-1) var(--space-4); + } + .vino-cart__shared-pic { + grid-area: pic; + } + .vino-cart__shared-total { + flex: 1 1 100%; + } + .vino-cart__shared-button.vino-btn { + flex: 1 1 100%; + justify-content: center; + } + .vino-cart__shared-name { + grid-area: name; + } + .vino-cart__shared-qty { + grid-area: qty; + } + .vino-cart__shared-sum { + grid-area: sum; + } +} +@container vino-cart-main (max-width: 640px) { + .vino-cart__item { + grid-template-columns: var(--vino-cart-pic-width) auto minmax(0, 1fr) var(--size-tap); + grid-template-areas: + "pic info info remove" + "pic qty sum sum"; + gap: var(--space-3) var(--space-4); + } + .vino-cart__pic { + grid-area: pic; + align-self: start; + } + .vino-cart__info { + grid-area: info; + } + .vino-cart__qty { + grid-area: qty; + justify-self: start; + } + .vino-cart__sum { + grid-area: sum; + justify-self: end; + } + .vino-cart__remove { + grid-area: remove; + align-self: start; + } +} +.vino-cart .vino-btn--sm { + min-height: var(--size-tap); + justify-content: center; +} diff --git a/local/components/jinove/cart/templates/.default/template.php b/local/components/jinove/cart/templates/.default/template.php new file mode 100644 index 0000000..d286a85 --- /dev/null +++ b/local/components/jinove/cart/templates/.default/template.php @@ -0,0 +1,139 @@ + $coupon["applied"])); +$text = static fn(string $key): string => htmlspecialcharsbx((string)Loc::getMessage($key)); +$title = htmlspecialcharsbx($arResult["TITLE"]); +?> +
+
+ +

+
+
+ +
" data-text-coupon-error="" data-text-coupon-empty="" data-text-coupon-remove="" data-text-fail=""> + +
" data-cart-url="" aria-labelledby="vino-cart-shared-title" role="region"> +

+ +

+
    + +
  • + + " width="72" height="90" alt="" loading="lazy" decoding="async"> + + "> + × + +
  • + +
+
+

+ + "> +
+ +

+ +
+ +
> +
+
+

+
+ + +
+ + +
+

+ +
    "> + $item): ?> +
  • " data-cart-item=""> + < class="vino-cart__pic"> + + " width="80" height="100" alt="" decoding="async"> + + + + > +
    + < class="vino-cart__name">> +

    +

    + + > +

    +

    >

    +
    +
    $item["name"]])) ?>"> + + + +
    +

    + + +
  • + +
+
+ +
+
> +

+

+ "> +
+
diff --git a/local/components/jinove/catalog.listing/.description.php b/local/components/jinove/catalog.listing/.description.php new file mode 100644 index 0000000..4dc1ebf --- /dev/null +++ b/local/components/jinove/catalog.listing/.description.php @@ -0,0 +1,10 @@ + "Vinoteca: список вин раздела", + "DESCRIPTION" => "Умный фильтр и список вин раздела каталога, подгружается контроллером модуля", + "PATH" => ["ID" => "jinove", "NAME" => "Jinove"], +]; diff --git a/local/components/jinove/catalog.listing/class.php b/local/components/jinove/catalog.listing/class.php new file mode 100644 index 0000000..40081ab --- /dev/null +++ b/local/components/jinove/catalog.listing/class.php @@ -0,0 +1,220 @@ +getContext()->getRequest(); + $sort = (string)$request->getQuery("sort"); + $params["SECTION_CODE"] = (string)($params["SECTION_CODE"] ?? ""); + $params["FILTER_PATH"] = (string)($params["FILTER_PATH"] ?? ""); + $params["COUNTRY_CODE"] = (string)($params["COUNTRY_CODE"] ?? ""); + $params["SORT"] = in_array($sort, Listing::SORTS, true) ? $sort : ""; + $params["PAGE"] = max(1, (int)$request->getQuery("PAGEN_1")); + $params["VIEW"] = $request->getCookieRaw("vino_view") === "list" ? "list" : "grid"; + $params["AJAX"] = ($params["AJAX"] ?? "") === "Y" ? "Y" : "N"; + + return $params; + } + + public function executeComponent(): array + { + if ($this->arParams["COUNTRY_CODE"] !== "") { + return $this->executeCountry(); + } + $catalog = Listing::catalogParams(); + $sectionCode = $this->arParams["SECTION_CODE"]; + $filterPath = $this->arParams["FILTER_PATH"]; + $sort = $this->arParams["SORT"]; + $basePath = Listing::basePath($sectionCode, $filterPath); + $priceCode = (string)(reset($catalog["PRICE_CODE"]) ?: ""); + + $this->arResult = [ + "SECTION_CODE" => $sectionCode, + "FILTER_PARAMS" => Listing::filterParams($sectionCode, $filterPath), + "SECTION_PARAMS" => $this->sectionParams($catalog, $basePath, $priceCode), + ]; + $this->includeComponentTemplate(); + + return $this->arResult; + } + + private function executeCountry(): array + { + $code = $this->arParams["COUNTRY_CODE"]; + $countries = Countries::names(); + if (!isset($countries[$code])) { + Tools::process404("", true, true, true); + + return []; + } + $name = EnumNames::name("COUNTRY", $code, $countries[$code]); + $GLOBALS["wineFilter"] = ["PROPERTY_COUNTRY_VALUE" => $countries[$code]]; + global $APPLICATION; + $APPLICATION->SetTitle($name); + $APPLICATION->SetPageProperty("title", Loc::getMessage("VINO_LISTING_COUNTRY_TITLE", ["#COUNTRY#" => $name])); + $APPLICATION->SetPageProperty("description", Loc::getMessage("VINO_LISTING_COUNTRY_DESCRIPTION", ["#COUNTRY#" => $name])); + $path = Listing::countryPath($code); + $APPLICATION->SetPageProperty("vino_canonical", $this->arParams["PAGE"] > 1 ? $path . "?PAGEN_1=" . $this->arParams["PAGE"] : $path); + $APPLICATION->SetPageProperty("og_image", VINO_HOST . SITE_TEMPLATE_PATH . "/assets/media/og-catalog.jpg"); + + $catalog = Listing::catalogParams(); + $this->arResult = [ + "COUNTRY_NAME" => $name, + "SECTION_PARAMS" => [ + "IBLOCK_TYPE" => $catalog["IBLOCK_TYPE"], + "IBLOCK_ID" => $catalog["IBLOCK_ID"], + "SECTION_ID" => 0, + "FILTER_NAME" => "wineFilter", + "PRICE_CODE" => $catalog["PRICE_CODE"], + "BASKET_URL" => $catalog["BASKET_URL"], + "PAGE_ELEMENT_COUNT" => "24", + "LINE_ELEMENT_COUNT" => "3", + "INCLUDE_SUBSECTIONS" => "Y", + "ELEMENT_SORT_FIELD" => "SORT", + "ELEMENT_SORT_ORDER" => "ASC", + "ELEMENT_SORT_FIELD2" => "ID", + "ELEMENT_SORT_ORDER2" => "DESC", + "PROPERTY_CODE" => $catalog["LIST_PROPERTY_CODE"], + "CACHE_TYPE" => $catalog["CACHE_TYPE"], + "CACHE_TIME" => $catalog["CACHE_TIME"], + "CACHE_GROUPS" => $catalog["CACHE_GROUPS"], + "SET_TITLE" => "N", + "SET_BROWSER_TITLE" => "N", + "SET_META_KEYWORDS" => "N", + "SET_META_DESCRIPTION" => "N", + "SET_STATUS_404" => "N", + "ADD_SECTIONS_CHAIN" => "N", + "ACTION_VARIABLE" => $catalog["ACTION_VARIABLE"], + "PRODUCT_ID_VARIABLE" => $catalog["PRODUCT_ID_VARIABLE"], + "USE_PRODUCT_QUANTITY" => "Y", + "ADD_TO_BASKET_ACTION" => "ADD", + "DISPLAY_TOP_PAGER" => "N", + "DISPLAY_BOTTOM_PAGER" => "Y", + "PAGER_TEMPLATE" => "vinoteca", + "PAGER_SHOW_ALWAYS" => "N", + "PAGER_TITLE" => Loc::getMessage("VINO_LISTING_PAGER_TITLE"), + "VINO_TITLE_TAG" => "h2", + "SECTION_URL" => $catalog["SEF_FOLDER"] . $catalog["SEF_URL_TEMPLATES"]["section"], + "HIDE_NOT_AVAILABLE" => "N", + ], + ]; + $this->includeComponentTemplate("country"); + + return $this->arResult; + } + + private function sectionParams(array $catalog, string $basePath, string $priceCode): array + { + $sectionCode = $this->arParams["SECTION_CODE"]; + $filterPath = $this->arParams["FILTER_PATH"]; + $sort = $this->arParams["SORT"]; + $ajax = $this->arParams["AJAX"] === "Y"; + $priceField = "CATALOG_PRICE_" . PricePresets::groupId($priceCode); + $sorts = [ + "new" => ["ID", "DESC"], + "price_asc" => [$priceField, "ASC"], + "price_desc" => [$priceField, "DESC"], + "name" => ["NAME", "ASC"], + ]; + $sortUrls = ["" => $basePath]; + foreach (array_keys($sorts) as $code) { + $sortUrls[$code] = $basePath . "?sort=" . $code; + } + $pagePath = Listing::pagePath($sectionCode, $filterPath, $sort, $this->arParams["PAGE"]); + + return [ + "IBLOCK_TYPE" => $catalog["IBLOCK_TYPE"], + "IBLOCK_ID" => $catalog["IBLOCK_ID"], + "SECTION_CODE" => $sectionCode, + "FILTER_NAME" => "wineFilter", + "PRICE_CODE" => $catalog["PRICE_CODE"], + "BASKET_URL" => $catalog["BASKET_URL"], + "PAGE_ELEMENT_COUNT" => "12", + "LINE_ELEMENT_COUNT" => "3", + "INCLUDE_SUBSECTIONS" => "Y", + "ELEMENT_SORT_FIELD" => $sort !== "" ? $sorts[$sort][0] : "SORT", + "ELEMENT_SORT_ORDER" => $sort !== "" ? $sorts[$sort][1] : "ASC", + "ELEMENT_SORT_FIELD2" => "ID", + "ELEMENT_SORT_ORDER2" => "DESC", + "PROPERTY_CODE" => $catalog["LIST_PROPERTY_CODE"], + "CACHE_TYPE" => $catalog["CACHE_TYPE"], + "CACHE_TIME" => $catalog["CACHE_TIME"], + "CACHE_GROUPS" => $catalog["CACHE_GROUPS"], + "SET_TITLE" => "N", + "SET_BROWSER_TITLE" => "N", + "SET_META_KEYWORDS" => "N", + "SET_META_DESCRIPTION" => "N", + "SET_STATUS_404" => $ajax ? "N" : $catalog["SET_STATUS_404"], + "SHOW_404" => $ajax ? "N" : $catalog["SHOW_404"], + "FILE_404" => $catalog["FILE_404"], + "MESSAGE_404" => $catalog["MESSAGE_404"], + "ADD_SECTIONS_CHAIN" => "N", + "ACTION_VARIABLE" => $catalog["ACTION_VARIABLE"], + "PRODUCT_ID_VARIABLE" => $catalog["PRODUCT_ID_VARIABLE"], + "USE_PRODUCT_QUANTITY" => "Y", + "ADD_TO_BASKET_ACTION" => "ADD", + "SHOW_OLD_PRICE" => "Y", + "SHOW_DISCOUNT_PERCENT" => "Y", + "PRODUCT_DISPLAY_MODE" => "Y", + "DISPLAY_TOP_PAGER" => "N", + "DISPLAY_BOTTOM_PAGER" => "Y", + "PAGER_TEMPLATE" => "vinoteca", + "PAGER_SHOW_ALWAYS" => "N", + "PAGER_TITLE" => Loc::getMessage("VINO_LISTING_PAGER_TITLE"), + "PAGER_BASE_LINK_ENABLE" => "Y", + "PAGER_BASE_LINK" => $sortUrls[$sort], + "SECTION_URL" => $catalog["SEF_FOLDER"] . $catalog["SEF_URL_TEMPLATES"]["section"], + "DETAIL_URL" => $catalog["SEF_FOLDER"] . $catalog["SEF_URL_TEMPLATES"]["element"], + "HIDE_NOT_AVAILABLE" => "N", + "TEMPLATE_THEME" => "", + "VINO_AJAX" => $ajax ? "Y" : "N", + "VINO_TOOLBAR" => "Y", + "VINO_SORT" => $sort, + "VINO_SORT_URLS" => $sortUrls, + "VINO_PRICE_PRESETS" => $this->pricePresets($priceCode), + "VINO_VIEW" => $this->arParams["VIEW"], + "VINO_LIST_ID" => VINO_HOST . $pagePath . "#items", + "VINO_TITLE_TAG" => "h2", + ]; + } + + private function pricePresets(string $priceCode): array + { + if ($priceCode === "") { + return []; + } + $sectionCode = $this->arParams["SECTION_CODE"]; + $filterPath = $this->arParams["FILTER_PATH"]; + $sectionPath = Listing::sectionPath($sectionCode); + $presets = []; + foreach (PricePresets::limits(VINO_CATALOG_IBLOCK, $sectionCode, $priceCode) as $limit) { + $presetPath = "price-" . strtolower($priceCode) . "-to-" . $limit; + $active = $filterPath === $presetPath; + $presets[] = [ + "LIMIT" => $limit, + "URL" => $active ? $sectionPath : $sectionPath . "filter/" . $presetPath . "/apply/", + "ACTIVE" => $active, + ]; + } + if ($filterPath !== "" && !in_array(true, array_column($presets, "ACTIVE"), true)) { + return []; + } + + return $presets; + } +} diff --git a/local/components/jinove/catalog.listing/lang/en/class.php b/local/components/jinove/catalog.listing/lang/en/class.php new file mode 100644 index 0000000..660aa5a --- /dev/null +++ b/local/components/jinove/catalog.listing/lang/en/class.php @@ -0,0 +1,4 @@ + +
+
+ +

+
+
+
+
+ IncludeComponent("bitrix:catalog.section", "vinoteca", $arResult["SECTION_PARAMS"], $component); ?> +
+
diff --git a/local/components/jinove/catalog.listing/templates/.default/lang/en/country.php b/local/components/jinove/catalog.listing/templates/.default/lang/en/country.php new file mode 100644 index 0000000..e30fd75 --- /dev/null +++ b/local/components/jinove/catalog.listing/templates/.default/lang/en/country.php @@ -0,0 +1,2 @@ + +
+ + + + +
" tabindex="-1" data-chips-label="" data-chips-reset="" data-chips-remove="" data-chips-from="" data-chips-to="" data-chips-range=""> + IncludeComponent("bitrix:catalog.section", "vinoteca", $arResult["SECTION_PARAMS"], $component); ?> +
+
diff --git a/local/components/jinove/catalog.megamenu/.description.php b/local/components/jinove/catalog.megamenu/.description.php new file mode 100644 index 0000000..8c3246a --- /dev/null +++ b/local/components/jinove/catalog.megamenu/.description.php @@ -0,0 +1,11 @@ + "Vinoteca: мега-меню каталога", + "DESCRIPTION" => "Разделы, страны и бренды каталога с числом вин", + "PATH" => ["ID" => "jinove", "NAME" => "Jinove"], + "CACHE_PATH" => "Y", +]; diff --git a/local/components/jinove/catalog.megamenu/class.php b/local/components/jinove/catalog.megamenu/class.php new file mode 100644 index 0000000..2624b17 --- /dev/null +++ b/local/components/jinove/catalog.megamenu/class.php @@ -0,0 +1,40 @@ +arParams["IBLOCK_ID"] <= 0) { + return; + } + if ($this->startResultCache()) { + $this->arResult = MegaMenu::collect($this->arParams["IBLOCK_ID"], $this->arParams["BRANDS_LIMIT"]); + $taggedCache = Application::getInstance()->getTaggedCache(); + foreach (MegaMenu::tags($this->arParams["IBLOCK_ID"]) as $tag) { + $taggedCache->registerTag($tag); + } + if (empty($this->arResult["TYPES"])) { + $this->abortResultCache(); + + return; + } + $this->includeComponentTemplate(); + } + } +} diff --git a/local/components/jinove/catalog.megamenu/templates/.default/lang/en/template.php b/local/components/jinove/catalog.megamenu/templates/.default/lang/en/template.php new file mode 100644 index 0000000..dcfa25b --- /dev/null +++ b/local/components/jinove/catalog.megamenu/templates/.default/lang/en/template.php @@ -0,0 +1,12 @@ + Loc::getMessage("VINO_MEGA_WINES"), "ITEMS" => $arResult["TYPES"], "MORE" => ["TEXT" => Loc::getMessagePlural("VINO_MEGA_ALL", $total, ["#COUNT#" => $total]), "URL" => SITE_DIR . "catalog/"]], + ["TITLE" => Loc::getMessage("VINO_MEGA_COUNTRIES"), "ITEMS" => $arResult["COUNTRIES"], "MORE" => null], + ["TITLE" => Loc::getMessage("VINO_MEGA_BRANDS"), "ITEMS" => $arResult["BRANDS"], "MORE" => ["TEXT" => Loc::getMessage("VINO_MEGA_ALL_BRANDS"), "URL" => SITE_DIR . "brands/"]], +]; +?> + diff --git a/local/components/jinove/order.done/class.php b/local/components/jinove/order.done/class.php new file mode 100644 index 0000000..cb35852 --- /dev/null +++ b/local/components/jinove/order.done/class.php @@ -0,0 +1,69 @@ +SetPageProperty("vino_alternates", "N"); + $APPLICATION->SetPageProperty("vino_schema", "N"); + $APPLICATION->SetPageProperty("robots", "noindex, nofollow"); + $query = Context::getCurrent()->getRequest()->getQueryList()->toArray(); + $order = Checkout::find((int)($query["id"] ?? 0), (string)($query["hash"] ?? "")); + $state = "missing"; + $data = []; + if ($order !== null && !$order->isCanceled()) { + $method = Checkout::methodOf($order); + if ($method !== "cash" && ($query["cancel"] ?? "") !== "Y") { + Checkout::finishPayment($order, $query); + $order = \Bitrix\Sale\Order::load($order->getId()); + } + $payment = $order->getPaymentCollection()->current(); + $state = $method !== "cash" ? ($payment !== null && $payment->isPaid() ? "paid" : "pending") : "cash"; + $properties = []; + foreach ($order->getPropertyCollection() as $property) { + $properties[(string)$property->getField("CODE")] = (string)$property->getValue(); + } + $items = []; + foreach ($order->getBasket() as $item) { + $items[] = [ + "name" => (string)$item->getField("NAME"), + "quantity" => (int)$item->getQuantity(), + "sum" => Money::format((float)$item->getFinalPrice(), (string)$item->getCurrency()), + ]; + } + $data = [ + "ID" => (int)$order->getId(), + "HASH" => (string)$order->getHash(), + "NUMBER" => (string)$order->getField("ACCOUNT_NUMBER"), + "TOTAL" => Money::format((float)$order->getPrice(), (string)$order->getCurrency()), + "NAME" => $properties["NAME"] ?? "", + "PHONE" => $properties["PHONE"] ?? "", + "EMAIL" => $properties["EMAIL"] ?? "", + "METHOD" => $payment !== null ? (string)Loc::getMessage("VINO_PAY_" . strtoupper($method)) : "", + "ITEMS" => $items, + "CANCELLED" => ($query["cancel"] ?? "") === "Y", + ]; + } + $title = (string)Loc::getMessage("VINO_DONE_TITLE_" . strtoupper($state)); + $APPLICATION->SetTitle($title); + $APPLICATION->SetPageProperty("title", $title . " | Vinoteca"); + $APPLICATION->SetPageProperty("description", (string)Loc::getMessage("VINO_DONE_DESCRIPTION")); + $this->arResult = ["STATE" => $state, "TITLE" => $title, "ORDER" => $data, "CATALOG_URL" => SITE_DIR . "catalog/", "AUTOPAY" => ($query["autopay"] ?? "") === "Y", "PAY_FAILED" => ($query["pay"] ?? "") === "failed"]; + $this->includeComponentTemplate(); + + return $this->arResult; + } +} diff --git a/local/components/jinove/order.done/lang/en/class.php b/local/components/jinove/order.done/lang/en/class.php new file mode 100644 index 0000000..f28b970 --- /dev/null +++ b/local/components/jinove/order.done/lang/en/class.php @@ -0,0 +1,6 @@ + htmlspecialcharsbx((string)Loc::getMessage($key)); +$lead = $state === "pending" && !empty($order["CANCELLED"]) ? "VINO_DONE_LEAD_CANCEL" : "VINO_DONE_LEAD_" . strtoupper($state); +?> +
+
+ +

+
+
+ +
" data-text-busy=""> +
+

+ + "> + +

:

+ +
+ + +
+ +
+
+

+
    + +
  • ×
  • + +
+

+
+
+


+
+
+
+
+

+ "> + +
+
diff --git a/local/components/jinove/order/class.php b/local/components/jinove/order/class.php new file mode 100644 index 0000000..bbd96ca --- /dev/null +++ b/local/components/jinove/order/class.php @@ -0,0 +1,39 @@ +SetTitle(Loc::getMessage("VINO_ORDER_PAGE_TITLE")); + $APPLICATION->SetPageProperty("title", Loc::getMessage("VINO_ORDER_BROWSER_TITLE")); + $APPLICATION->SetPageProperty("description", Loc::getMessage("VINO_ORDER_PAGE_DESCRIPTION")); + $APPLICATION->SetPageProperty("vino_alternates", "N"); + $APPLICATION->SetPageProperty("vino_schema", "N"); + $APPLICATION->SetPageProperty("robots", "noindex, nofollow"); + Loc::loadMessages($_SERVER["DOCUMENT_ROOT"] . SITE_TEMPLATE_PATH . "/footer.php"); + $basket = Cart::load(); + $cart = $basket !== null ? Cart::view($basket) : null; + $this->arResult = [ + "TITLE" => (string)Loc::getMessage("VINO_ORDER_PAGE_TITLE"), + "CART" => $cart !== null && array_filter($cart["items"], static fn(array $item): bool => $item["available"]) ? $cart : null, + "METHODS" => Checkout::methods(), + "CART_URL" => SITE_DIR . "personal/cart/", + "CATALOG_URL" => SITE_DIR . "catalog/", + ]; + $this->includeComponentTemplate(); + + return $this->arResult; + } +} diff --git a/local/components/jinove/order/lang/en/class.php b/local/components/jinove/order/lang/en/class.php new file mode 100644 index 0000000..0f92486 --- /dev/null +++ b/local/components/jinove/order/lang/en/class.php @@ -0,0 +1,4 @@ + 1) message = text('many'); + else if (missing === 1) message = !f.name.value.trim() ? text('name') : (phone && !phone.filled() ? text('phone') : text('email')); + if (!missing) { + if (phone && !phone.complete()) bad(f.phone, text('phone')); + if (!/^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/.test(email)) bad(f.email, text('email')); + } + if (!f.consent.checked) bad(f.consent, text('consent')); + say(message); + if (focus) focus.focus(); + return !focus; + } + + function serverMessage(res) { + var code = res && res.errors && res.errors[0] && res.errors[0].code; + if (code === 'rate') return text('rate'); + if (code === 'empty' || code === 'cart') return text('empty'); + return text('fail'); + } + + form.addEventListener('input', function (e) { clear(e.target); }); + form.addEventListener('change', function (e) { clear(e.target); }); + if (window.VinoAltcha) VinoAltcha.arm(guard); + + window.addEventListener('pageshow', function (e) { + if (!e.persisted) return; + var submit = form.querySelector('[type="submit"]'); + submit.disabled = false; + submit.classList.remove('vino-btn--loading'); + }); + + form.addEventListener('submit', function (e) { + e.preventDefault(); + if (!check()) return; + var button = form.querySelector('[type="submit"]'); + var payInput = form.querySelector('[name="pay"]:checked'); + var online = !!payInput && payInput.getAttribute('data-online') === 'Y'; + button.disabled = true; + if (online && window.VinoBusy) VinoBusy.show(text('busy')); + else button.classList.add('vino-btn--loading'); + say(''); + (window.VinoAltcha ? VinoAltcha.armed(guard) : Promise.resolve(false)) + .then(function (ok) { + if (!ok) throw new Error('guard'); + var f = form.elements; + var pay = form.querySelector('[name="pay"]:checked'); + return BX.ajax.runAction('jinove:vinoteca.order.create', { + data: { + name: f.name.value, + phone: f.phone.vinoPhone.value(), + email: f.email.value, + comment: f.comment.value, + pay: pay ? pay.value : '', + consent: f.consent.checked ? 'Y' : '', + website: f.website.value, + altcha: f.altcha ? f.altcha.value : '', + page: window.location.pathname, + base: base + } + }); + }) + .then(function (res) { + if (res && res.data && res.data.ok && res.data.redirect) { + window.location.href = res.data.redirect; + return; + } + button.disabled = false; + button.classList.remove('vino-btn--loading'); + if (window.VinoBusy) VinoBusy.hide(); + say(text('fail')); + }) + .catch(function (res) { + button.disabled = false; + button.classList.remove('vino-btn--loading'); + if (window.VinoBusy) VinoBusy.hide(); + if (window.VinoAltcha) VinoAltcha.reset(guard); + say(serverMessage(res)); + }); + }); +})(); diff --git a/local/components/jinove/order/templates/.default/style.css b/local/components/jinove/order/templates/.default/style.css new file mode 100644 index 0000000..9f091d6 --- /dev/null +++ b/local/components/jinove/order/templates/.default/style.css @@ -0,0 +1,294 @@ +.vino-order { + --vino-order-summary-width: 400px; + --vino-order-pic-width: 56px; + --vino-order-pic-height: 70px; + --vino-order-radio: 20px; + padding: var(--space-10) var(--gutter) var(--space-section); +} +.vino-order__layout, +.vino-order__empty { + max-width: var(--container); + margin: 0 auto; +} +.vino-order__layout { + display: grid; + grid-template-columns: minmax(0, 1fr) var(--vino-order-summary-width); + gap: var(--space-grid-wide); + align-items: start; +} +.vino-order__form { + display: grid; + gap: var(--space-8); + min-width: 0; +} +.vino-order__block { + display: grid; + gap: var(--space-4); + min-width: 0; + margin: 0; + padding: 0; + border: 0; +} +.vino-order__legend { + margin: 0 0 var(--space-4); + padding: 0; + font-family: var(--font-serif); + font-size: var(--fs-h4); + line-height: var(--leading-title); +} +.vino-order__field { + display: grid; + gap: var(--space-2); +} +.vino-order__label { + color: var(--color-text-muted); + font-size: var(--text-13); +} +.vino-order__field .vino-inp { + width: 100%; + margin: 0; +} +.vino-order__pickup { + display: grid; + grid-template-columns: minmax(0, 1fr) auto; + gap: var(--space-1) var(--space-4); + padding: var(--space-card); + background: var(--color-surface); + border: 1px solid var(--color-line); + border-radius: var(--radius-sm); +} +.vino-order__pickup-name { + margin: 0; + font-size: var(--text-17); +} +.vino-order__pickup-text { + grid-column: 1; + margin: 0; + color: var(--color-text-muted); + font-size: var(--text-15); +} +.vino-order__pickup-free { + grid-column: 2; + grid-row: 1 / span 2; + align-self: center; + margin: 0; + color: var(--color-accent); + font-size: var(--text-15); + font-weight: 600; +} +.vino-order__methods { + display: grid; + gap: var(--space-3); +} +.vino-order__method { + position: relative; + display: flex; + align-items: flex-start; + gap: var(--space-4); + padding: var(--space-card); + background: var(--color-surface); + border: 1px solid var(--color-line); + border-radius: var(--radius-sm); + cursor: pointer; + transition: border-color var(--duration-fast) var(--ease-base); +} +.vino-order__method:has(.vino-order__radio:checked) { + border-color: var(--color-accent); +} +.vino-order__method:has(.vino-order__radio:focus-visible) { + box-shadow: var(--shadow-focus); +} +.vino-order__radio { + appearance: none; + flex: none; + width: var(--vino-order-radio); + height: var(--vino-order-radio); + margin: 2px 0 0; + border: 1px solid var(--color-line-field); + border-radius: 50%; + background: transparent; + cursor: pointer; + transition: border-color var(--duration-fast) var(--ease-base), background var(--duration-fast) var(--ease-base); +} +.vino-order__radio:checked { + border-color: var(--color-accent); + background: radial-gradient(circle, var(--color-accent) 0 40%, transparent 45%); +} +.vino-order__method-body { + display: grid; + gap: var(--space-1); + min-width: 0; +} +.vino-order__method-name { + font-size: var(--text-17); +} +.vino-order__method-hint { + color: var(--color-text-muted); + font-size: var(--text-15); + line-height: var(--leading-ui); +} +.vino-order__error { + min-height: calc(var(--text-15) * 1.45); + margin: 0; + color: var(--color-danger-soft); + font-size: var(--text-15); + line-height: var(--leading-ui); +} +.vino-order__error[hidden] { + display: block; + visibility: hidden; +} +.vino-order__submit { + justify-content: center; + width: 100%; + min-height: var(--size-tap); +} +.vino-order__summary { + position: sticky; + top: calc(var(--size-header) + var(--space-6)); + padding: var(--space-card); + background: var(--color-surface); + border: 1px solid var(--color-line); + border-radius: var(--radius-sm); +} +.vino-order__summary-title { + margin: 0 0 var(--space-5); + font-family: var(--font-serif); + font-size: var(--fs-h4); + font-weight: 400; + line-height: var(--leading-title); +} +.vino-order__items { + display: grid; + gap: var(--space-4); + margin: 0; + padding: 0; + list-style: none; +} +.vino-order__item { + display: grid; + grid-template-columns: var(--vino-order-pic-width) minmax(0, 1fr) auto; + grid-template-areas: + "pic name sum" + "pic qty sum"; + gap: var(--space-1) var(--space-3); + align-items: center; +} +.vino-order__pic { + position: relative; + display: flex; + grid-area: pic; + width: var(--vino-order-pic-width); + height: var(--vino-order-pic-height); + background: var(--color-bg); + border-radius: var(--radius-sm); + overflow: hidden; +} +.vino-order__img { + width: 100%; + height: 100%; + object-fit: cover; +} +.vino-order__item-name { + grid-area: name; + align-self: end; + font-family: var(--font-serif); + font-size: var(--text-17); + line-height: var(--leading-title); +} +.vino-order__item-qty { + grid-area: qty; + align-self: start; + color: var(--color-text-muted); + font-size: var(--text-13); +} +.vino-order__item-sum { + grid-area: sum; + color: var(--color-accent); + font-size: var(--text-15); + font-weight: 600; + font-variant-numeric: tabular-nums; + white-space: nowrap; +} +.vino-order__totals { + margin: var(--space-5) 0 var(--space-4); + padding-top: var(--space-4); + border-top: 1px solid var(--color-line); +} +.vino-order__line { + display: flex; + justify-content: space-between; + gap: var(--space-4); + padding: var(--space-1) 0; + color: var(--color-text-muted); + font-size: var(--text-15); +} +.vino-order__term, +.vino-order__value { + margin: 0; +} +.vino-order__value { + font-variant-numeric: tabular-nums; + white-space: nowrap; +} +.vino-order__line--discount .vino-order__value { + color: var(--color-accent); +} +.vino-order__line--total { + margin-top: var(--space-2); + color: var(--color-text); + font-size: var(--text-19); + font-weight: 600; +} +.vino-order__edit { + color: var(--color-accent); + font-size: var(--text-13); + letter-spacing: var(--tracking-sm); + text-transform: uppercase; + text-decoration: none; + transition: color var(--duration-fast) var(--ease-base); +} +.vino-order__empty { + padding: var(--space-16) 0; + text-align: center; +} +.vino-order__empty-title { + margin: 0 0 var(--space-8); + font-family: var(--font-serif); + font-size: var(--fs-h3); + line-height: var(--leading-title); +} +@media (hover: hover) { + .vino-order__method:hover { + border-color: color-mix(in srgb, var(--color-accent) 60%, transparent); + } + .vino-order__edit:hover { + color: var(--color-accent-hover); + } +} +@media (pointer: coarse) { + .vino-order__edit { + display: inline-block; + padding: var(--space-3) 0; + } +} +@media (max-width: 980px) { + .vino-order__layout { + grid-template-columns: minmax(0, 1fr); + } + .vino-order__summary { + position: static; + } +} +@media (max-width: 560px) { + .vino-order { + padding-top: var(--space-6); + } + .vino-order__pickup { + grid-template-columns: minmax(0, 1fr); + } + .vino-order__pickup-free { + grid-column: 1; + grid-row: auto; + } +} diff --git a/local/components/jinove/order/templates/.default/template.php b/local/components/jinove/order/templates/.default/template.php new file mode 100644 index 0000000..dd557e0 --- /dev/null +++ b/local/components/jinove/order/templates/.default/template.php @@ -0,0 +1,111 @@ + htmlspecialcharsbx((string)Loc::getMessage($key)); +$title = htmlspecialcharsbx($arResult["TITLE"]); +$button = (string)Loc::getMessage("VINO_ORDER_SUBMIT"); +?> +
+
+ +

+
+
+ + +
+
+

+ "> +
+
+ +
" data-text-phone="" data-text-email="" data-text-consent="" data-text-many="" data-text-rate="" data-text-empty="" data-text-fail="" data-text-busy=""> +
+
+ +
+ + + + + +
+
+ +
+

+

+

+
+
+
+ +
+ $method): ?> + + +
+
+ + + + +
+ +
+
+ diff --git a/local/components/jinove/personal.nav/class.php b/local/components/jinove/personal.nav/class.php new file mode 100644 index 0000000..f368922 --- /dev/null +++ b/local/components/jinove/personal.nav/class.php @@ -0,0 +1,31 @@ + "", "orders" => "orders/", "reviews" => "reviews/"]; + + public function executeComponent(): array + { + $items = []; + foreach (self::SECTIONS as $code => $path) { + $items[] = [ + "CODE" => $code, + "URL" => SITE_DIR . "personal/" . $path, + "ACTIVE" => ($this->arParams["ACTIVE"] ?? "") === $code, + ]; + } + $this->arResult = ["ITEMS" => $items]; + $this->includeComponentTemplate(); + + return $this->arResult; + } +} diff --git a/local/components/jinove/personal.nav/templates/.default/lang/en/template.php b/local/components/jinove/personal.nav/templates/.default/lang/en/template.php new file mode 100644 index 0000000..e4498de --- /dev/null +++ b/local/components/jinove/personal.nav/templates/.default/lang/en/template.php @@ -0,0 +1,7 @@ + + diff --git a/local/components/jinove/personal.orders/class.php b/local/components/jinove/personal.orders/class.php new file mode 100644 index 0000000..5932127 --- /dev/null +++ b/local/components/jinove/personal.orders/class.php @@ -0,0 +1,43 @@ +getId(); + if ($userId <= 0) { + LocalRedirect(SITE_DIR . "login/?back=" . rawurlencode(Application::getInstance()->getContext()->getRequest()->getRequestUri())); + } + $request = Application::getInstance()->getContext()->getRequest(); + $completed = (string)$request->getQuery("status") === "completed"; + $page = max(1, min(50, (int)$request->getQuery("page"))); + $result = Orders::forUser($userId, $completed, $page); + $GLOBALS["APPLICATION"]->SetTitle(Loc::getMessage("VINO_ORD_PAGE_TITLE")); + $GLOBALS["APPLICATION"]->SetPageProperty("description", Loc::getMessage("VINO_ORD_PAGE_DESCRIPTION")); + $GLOBALS["APPLICATION"]->SetPageProperty("vino_alternates", "N"); + $GLOBALS["APPLICATION"]->SetPageProperty("vino_schema", "N"); + $GLOBALS["APPLICATION"]->SetPageProperty("robots", "noindex, nofollow"); + $this->arResult = [ + "COMPLETED" => $completed, + "ORDERS" => $result["orders"], + "MORE_URL" => $result["more"] ? SITE_DIR . "personal/orders/?" . ($completed ? "status=completed&" : "") . "page=" . ($page + 1) : "", + "BASE_URL" => SITE_DIR . "personal/orders/", + "CATALOG_URL" => SITE_DIR . "catalog/", + ]; + $this->includeComponentTemplate(); + + return $this->arResult; + } +} diff --git a/local/components/jinove/personal.orders/lang/en/class.php b/local/components/jinove/personal.orders/lang/en/class.php new file mode 100644 index 0000000..7c2ad04 --- /dev/null +++ b/local/components/jinove/personal.orders/lang/en/class.php @@ -0,0 +1,3 @@ +addExternalCss("/local/components/jinove/personal.profile/templates/.default/style.css"); +$number = static fn(float $value): string => rtrim(rtrim(number_format($value, 3, ",", ""), "0"), ","); +?> +
+ IncludeComponent("jinove:personal.nav", ".default", ["ACTIVE" => "orders"]); ?> +
+

+ + +
+

+ "> +
+ +
    + +
  • +
    +

    htmlspecialcharsbx($order["number"]), "#DATE#" => \Jinove\Vinoteca\DateFormat::long($order["date"], LANGUAGE_ID)]) ?>

    +

    ">

    +
    +
      + +
    • + " width="64" height="64" alt="" loading="lazy" decoding="async"> +
      + "> + × +
      +
    • + +
    +

    +
  • + +
+ + "> + + +
+
diff --git a/local/components/jinove/personal.profile/class.php b/local/components/jinove/personal.profile/class.php new file mode 100644 index 0000000..c32ac05 --- /dev/null +++ b/local/components/jinove/personal.profile/class.php @@ -0,0 +1,37 @@ +getId(); + if ($userId <= 0) { + LocalRedirect(SITE_DIR . "login/?back=" . rawurlencode(SITE_DIR . "personal/")); + } + $row = UserTable::getRow(["select" => ["NAME", "EMAIL", "PERSONAL_PHONE"], "filter" => ["=ID" => $userId]]) ?? []; + $GLOBALS["APPLICATION"]->SetTitle(Loc::getMessage("VINO_CAB_PAGE_TITLE")); + $GLOBALS["APPLICATION"]->SetPageProperty("description", Loc::getMessage("VINO_CAB_PAGE_DESCRIPTION")); + $GLOBALS["APPLICATION"]->SetPageProperty("vino_alternates", "N"); + $GLOBALS["APPLICATION"]->SetPageProperty("vino_schema", "N"); + $GLOBALS["APPLICATION"]->SetPageProperty("robots", "noindex, nofollow"); + $this->arResult = [ + "NAME" => (string)($row["NAME"] ?? ""), + "EMAIL" => (string)($row["EMAIL"] ?? ""), + "PHONE" => preg_replace('/^\+7(\d{3})(\d{3})(\d{2})(\d{2})$/', '+7 $1 $2 $3 $4', (string)($row["PERSONAL_PHONE"] ?? "")), + ]; + $this->includeComponentTemplate(); + + return $this->arResult; + } +} diff --git a/local/components/jinove/personal.profile/lang/en/class.php b/local/components/jinove/personal.profile/lang/en/class.php new file mode 100644 index 0000000..78b3daa --- /dev/null +++ b/local/components/jinove/personal.profile/lang/en/class.php @@ -0,0 +1,3 @@ +"; +$MESS["VINO_CAB_ERR_POLICY"] = "The password does not meet the site requirements"; diff --git a/local/components/jinove/personal.profile/templates/.default/lang/pl/template.php b/local/components/jinove/personal.profile/templates/.default/lang/pl/template.php new file mode 100644 index 0000000..f8ccc80 --- /dev/null +++ b/local/components/jinove/personal.profile/templates/.default/lang/pl/template.php @@ -0,0 +1,31 @@ +"; +$MESS["VINO_CAB_ERR_POLICY"] = "Hasło nie spełnia wymagań serwisu"; diff --git a/local/components/jinove/personal.profile/templates/.default/lang/ru/template.php b/local/components/jinove/personal.profile/templates/.default/lang/ru/template.php new file mode 100644 index 0000000..0c5b970 --- /dev/null +++ b/local/components/jinove/personal.profile/templates/.default/lang/ru/template.php @@ -0,0 +1,31 @@ +"; +$MESS["VINO_CAB_ERR_POLICY"] = "Пароль не подходит по требованиям сайта"; diff --git a/local/components/jinove/personal.profile/templates/.default/script.js b/local/components/jinove/personal.profile/templates/.default/script.js new file mode 100644 index 0000000..1fff5fb --- /dev/null +++ b/local/components/jinove/personal.profile/templates/.default/script.js @@ -0,0 +1,111 @@ +(function () { + function init() { + if (!window.BX || !BX.ajax || !BX.ajax.runAction) return; + var saveForm = document.querySelector('[data-cab-save]'); + var passwordForm = document.querySelector('[data-cab-password]'); + + function key(code) { + return code.replace(/_([a-z])/g, function (match, letter) { return letter.toUpperCase(); }); + } + + function message(form, code) { + var name = 'msg' + key(code).charAt(0).toUpperCase() + key(code).slice(1); + return form.dataset[name] || form.dataset.msgError; + } + + function status(form, text, ok) { + var line = form.querySelector('[data-cab-status]'); + line.textContent = text; + line.classList.toggle('vino-cab__status--ok', !!ok); + } + + function mark(field, bad) { + field.classList.toggle('vino-inp--invalid', bad); + field.setAttribute('aria-invalid', bad ? 'true' : 'false'); + } + + function code(response) { + return response && response.errors && response.errors[0] ? response.errors[0].code : ''; + } + + function phoneValue(input) { + var digits = input.value.replace(/\D/g, ''); + return digits.length > 1 ? '+' + digits : ''; + } + + [saveForm, passwordForm].forEach(function (form) { + if (!form) return; + form.addEventListener('input', function (event) { + if (event.target.classList.contains('vino-inp--invalid')) mark(event.target, false); + status(form, '', false); + }); + }); + + if (saveForm) { + saveForm.addEventListener('submit', function (event) { + event.preventDefault(); + var name = saveForm.elements.name; + var phone = saveForm.elements.phone; + var submit = saveForm.querySelector('[type="submit"]'); + var badName = name.value.trim() === '' || /[<>\x00-\x1f]/.test(name.value); + var badPhone = !phone.checkValidity(); + mark(name, badName); + mark(phone, badPhone); + if (badName || badPhone) { + status(saveForm, badName ? (name.value.trim() === '' ? saveForm.dataset.msgName : saveForm.dataset.msgNameChars) : saveForm.dataset.msgPhone, false); + (badName ? name : phone).focus(); + return; + } + status(saveForm, '', false); + if (submit.getAttribute('aria-disabled') === 'true') return; + submit.setAttribute('aria-disabled', 'true'); + BX.ajax.runAction('jinove:vinoteca.profile.save', { data: { name: name.value.trim(), phone: phoneValue(phone) } }).then(function () { + submit.removeAttribute('aria-disabled'); + status(saveForm, saveForm.dataset.msgDone, true); + }, function (response) { + submit.removeAttribute('aria-disabled'); + status(saveForm, message(saveForm, code(response)), false); + }); + }); + } + + if (passwordForm) { + passwordForm.addEventListener('submit', function (event) { + event.preventDefault(); + var current = passwordForm.elements.current; + var next = passwordForm.elements.password; + var submit = passwordForm.querySelector('[type="submit"]'); + var badCurrent = current.value === ''; + var badNext = next.value.length < 8; + mark(current, badCurrent); + mark(next, badNext); + if (badCurrent || badNext) { + status(passwordForm, badCurrent ? passwordForm.dataset.msgCurrent : passwordForm.dataset.msgPassword, false); + (badCurrent ? current : next).focus(); + return; + } + status(passwordForm, '', false); + if (submit.getAttribute('aria-disabled') === 'true') return; + submit.setAttribute('aria-disabled', 'true'); + BX.ajax.runAction('jinove:vinoteca.profile.password', { data: { current: current.value, password: next.value } }).then(function () { + submit.removeAttribute('aria-disabled'); + current.value = ''; + next.value = ''; + status(passwordForm, passwordForm.dataset.msgDone, true); + }, function (response) { + submit.removeAttribute('aria-disabled'); + var errorCode = code(response); + if (errorCode === 'current') mark(current, true); + if (errorCode === 'password' || errorCode === 'same') mark(next, true); + status(passwordForm, message(passwordForm, errorCode), false); + }); + }); + } + } + + if (document.readyState === 'loading') { + document.addEventListener('DOMContentLoaded', init); + } else { + init(); + } +})(); diff --git a/local/components/jinove/personal.profile/templates/.default/style.css b/local/components/jinove/personal.profile/templates/.default/style.css new file mode 100644 index 0000000..beff3b0 --- /dev/null +++ b/local/components/jinove/personal.profile/templates/.default/style.css @@ -0,0 +1,171 @@ +.vino-cab { + display: grid; + grid-template-columns: minmax(0, 240px) minmax(0, 860px); + gap: clamp(var(--space-8), 5vw, var(--space-16)); + align-items: start; + justify-content: center; + min-height: 62vh; + padding: var(--space-head) var(--gutter) var(--space-section); +} +.vino-cab__kicker { + margin: 0 0 var(--space-4); + color: var(--color-accent); + font-size: var(--text-13); + letter-spacing: var(--tracking-wide); + text-transform: uppercase; +} +.vino-cab__list { + display: grid; + margin: 0; + padding: 0; + list-style: none; +} +.vino-cab__link { + display: block; + width: 100%; + padding: var(--space-3) var(--space-6); + border: 0; + background: transparent; + color: var(--color-text); + font: inherit; + font-size: var(--text-15); + font-weight: 500; + text-align: left; + text-decoration: none; + cursor: pointer; + transition: color var(--duration-fast) var(--ease-base), background-color var(--duration-fast) var(--ease-base), transform var(--duration-fast) var(--ease-base); +} +.vino-cab__link--active { + background: var(--color-accent); + color: var(--color-bg); +} +.vino-cab__link:active { + transform: scale(.97); +} +.vino-cab__link:focus-visible { + outline: 2px solid var(--color-accent); + outline-offset: -2px; +} +.vino-cab__title { + margin: 0 0 var(--space-6); + font-family: var(--font-serif); + font-weight: 500; + font-size: clamp(1.75rem, 3.4vw, 2.25rem); + line-height: 1.1; +} +.vino-cab__panel { + margin: 0 0 var(--space-8); +} +.vino-cab__panel + .vino-cab__panel { + padding-top: var(--space-8); + border-top: 1px solid var(--color-line); +} +.vino-cab__panel.vino-cab__empty { + padding: 0; + border: 0; +} +.vino-cab__heading { + margin: 0 0 var(--space-4); + font-family: var(--font-serif); + font-weight: 500; + font-size: clamp(1.25rem, 2.2vw, 1.5rem); +} +.vino-auth__form.vino-cab__form { + grid-template-columns: repeat(2, minmax(0, 1fr)); + gap: var(--space-5) var(--space-4); + align-items: start; + max-width: 640px; +} +.vino-cab__form .vino-auth__label { + color: var(--color-text); + font-size: var(--text-15); + font-weight: 500; + letter-spacing: 0; + text-transform: none; +} +.vino-cab__form .vino-auth__err { + grid-column: 1 / -1; +} +.vino-auth__form.vino-cab__form .vino-auth__submit { + grid-column: 1 / -1; + justify-self: start; + width: auto; + min-width: 220px; +} +.vino-auth__err.vino-cab__status--ok { + color: var(--color-accent); +} +.vino-cab-list { + display: grid; + gap: var(--space-6); + margin: 0; + padding: 0; + list-style: none; +} +.vino-cab-card { + padding: clamp(var(--space-5), 3vw, var(--space-8)); + background: var(--color-surface); + border: 1px solid var(--color-line); +} +.vino-cab-card__head { + display: flex; + flex-wrap: wrap; + justify-content: space-between; + gap: var(--space-2) var(--space-6); + margin: 0 0 var(--space-4); +} +.vino-cab-card__title { + margin: 0; + color: var(--color-text); + font-size: var(--text-19); + font-weight: 500; +} +.vino-cab-card__name { + color: var(--color-text); + text-decoration: none; + overflow-wrap: anywhere; +} +.vino-cab-card__title .vino-cab-card__name { + font: inherit; +} +.vino-cab-card__status { + margin: 0; + color: var(--color-accent); + font-size: var(--text-15); + letter-spacing: .08em; + text-transform: uppercase; +} +.vino-cab-card__status--canceled { + color: var(--color-danger-soft); +} +@media (hover: hover) { + .vino-cab-card__name:hover { + color: var(--color-accent-hover); + } + .vino-cab__link:not(.vino-cab__link--active):hover { + background: color-mix(in srgb, var(--color-accent) 14%, transparent); + } +} +@media (max-width: 760px) { + .vino-cab { + grid-template-columns: minmax(0, 1fr); + gap: var(--space-6); + } + .vino-cab__list { + display: flex; + flex-wrap: wrap; + gap: var(--space-2); + } + .vino-cab__link { + min-height: 44px; + padding: var(--space-3) var(--space-4); + width: auto; + } + .vino-auth__form.vino-cab__form { + grid-template-columns: minmax(0, 1fr); + } + .vino-auth__form.vino-cab__form .vino-auth__submit { + justify-self: stretch; + width: 100%; + } +} diff --git a/local/components/jinove/personal.profile/templates/.default/template.php b/local/components/jinove/personal.profile/templates/.default/template.php new file mode 100644 index 0000000..01759f4 --- /dev/null +++ b/local/components/jinove/personal.profile/templates/.default/template.php @@ -0,0 +1,75 @@ +addExternalCss("/local/components/jinove/auth.login/templates/.default/style.css"); +$e = static fn(string $code): string => htmlspecialcharsbx((string)Loc::getMessage($code)); +?> +
+ IncludeComponent("jinove:personal.nav", ".default", ["ACTIVE" => "profile"]); ?> +
+

+
+

+
" + data-msg-name-chars="" + data-msg-phone="" + data-msg-auth="" + data-msg-error="" + data-msg-done=""> +
+ + " aria-describedby="vino-cab-contacts-err" required> +
+
+ + " readonly aria-describedby="vino-cab-email-note"> + +
+
+ + " data-phone-code="7" data-phone-digits="10" data-phone-groups="3,3,2,2" data-phone-error="" aria-describedby="vino-cab-contacts-err"> +
+ + +
+
+
+

+
" + data-msg-password="" + data-msg-same="" + data-msg-policy="" + data-msg-too-often="" + data-msg-auth="" + data-msg-error="" + data-msg-done="" + data-label-show="" + data-label-hide=""> +
+ + + + + +
+
+ + + + + + +
+ + +
+
+
+
diff --git a/local/components/jinove/personal.reviews/class.php b/local/components/jinove/personal.reviews/class.php new file mode 100644 index 0000000..d61e36e --- /dev/null +++ b/local/components/jinove/personal.reviews/class.php @@ -0,0 +1,35 @@ +getId(); + if ($userId <= 0) { + LocalRedirect(SITE_DIR . "login/?back=" . rawurlencode(SITE_DIR . "personal/reviews/")); + } + $GLOBALS["APPLICATION"]->SetTitle(Loc::getMessage("VINO_REV_PAGE_TITLE")); + $GLOBALS["APPLICATION"]->SetPageProperty("description", Loc::getMessage("VINO_REV_PAGE_DESCRIPTION")); + $GLOBALS["APPLICATION"]->SetPageProperty("vino_alternates", "N"); + $GLOBALS["APPLICATION"]->SetPageProperty("vino_schema", "N"); + $GLOBALS["APPLICATION"]->SetPageProperty("robots", "noindex, nofollow"); + $this->arResult = [ + "REVIEWS" => Reviews::forUser($userId), + "CATALOG_URL" => SITE_DIR . "catalog/", + ]; + $this->includeComponentTemplate(); + + return $this->arResult; + } +} diff --git a/local/components/jinove/personal.reviews/lang/en/class.php b/local/components/jinove/personal.reviews/lang/en/class.php new file mode 100644 index 0000000..c682f53 --- /dev/null +++ b/local/components/jinove/personal.reviews/lang/en/class.php @@ -0,0 +1,3 @@ +addExternalCss("/local/components/jinove/personal.profile/templates/.default/style.css"); +$stars = static function (int $filled): string { + $out = ""; + for ($i = 1; $i <= 5; $i++) { + $out .= ''; + } + + return $out; +}; +?> +
+ IncludeComponent("jinove:personal.nav", ".default", ["ACTIVE" => "reviews"]); ?> +
+

+ +
+

+ "> +
+ +
    + +
  • +
    +

    ">

    +

    ">

    +
    +
    + $review["rating"]])) ?>"> + 0): ?> +
    +

    +
  • + +
+ +
+
diff --git a/local/modules/jinove.vinoteca/.settings.php b/local/modules/jinove.vinoteca/.settings.php new file mode 100644 index 0000000..3913938 --- /dev/null +++ b/local/modules/jinove.vinoteca/.settings.php @@ -0,0 +1,54 @@ + [ + "value" => [ + "host" => "https://vinoteca.jimagie.com", + "ageExitUrl" => "https://www.google.com/", + "languages" => [ + "en" => ["dir" => "/", "label" => "EN", "locale" => "en_US"], + "pl" => ["dir" => "/pl/", "label" => "PL", "locale" => "pl_PL"], + "ru" => ["dir" => "/ru/", "label" => "RU", "locale" => "ru_RU"], + ], + "iblocks" => [ + "catalog" => 2, + "brands" => 6, + "news" => 1, + "banners" => 5, + "offers" => 10, + ], + ], + "readonly" => true, + ], + "controllers" => [ + "value" => [ + "defaultNamespace" => "\\Jinove\\Vinoteca\\Controller", + ], + "readonly" => true, + ], + "contacts" => [ + "value" => [ + "phone" => "+70123456789", + "phoneLabel" => "+7 (012) 345-67-89", + "email" => "info@vinoteca.jimagie.com", + "telegram" => "https://t.me/jimagie_vinoteca", + "demoMail" => "siema@jimagie.com", + ], + "readonly" => true, + ], + "basket" => [ + "value" => [ + "siteId" => "s1", + ], + "readonly" => true, + ], + "services" => [ + "value" => [ + "jinove.vinoteca.wineStats" => [ + "className" => \Jinove\Vinoteca\Catalog\WineStats::class, + "constructorParams" => ["catalog", "wine"], + ], + ], + "readonly" => true, + ], +]; diff --git a/local/modules/jinove.vinoteca/include.php b/local/modules/jinove.vinoteca/include.php new file mode 100644 index 0000000..074c853 --- /dev/null +++ b/local/modules/jinove.vinoteca/include.php @@ -0,0 +1,12 @@ +MODULE_VERSION = $arModuleVersion["VERSION"]; + $this->MODULE_VERSION_DATE = $arModuleVersion["VERSION_DATE"]; + $this->MODULE_NAME = Loc::getMessage("JINOVE_VINOTECA_MODULE_NAME"); + $this->MODULE_DESCRIPTION = Loc::getMessage("JINOVE_VINOTECA_MODULE_DESCRIPTION"); + $this->PARTNER_NAME = Loc::getMessage("JINOVE_VINOTECA_PARTNER_NAME"); + $this->PARTNER_URI = "https://vinoteca.jimagie.com"; + } + + public function DoInstall(): void + { + ModuleManager::registerModule($this->MODULE_ID); + $this->InstallDB(); + } + + public function DoUninstall(): void + { + $this->UnInstallDB(); + ModuleManager::unRegisterModule($this->MODULE_ID); + } + + public function InstallDB(): bool + { + Loader::includeModule($this->MODULE_ID); + $connection = Application::getConnection(); + $table = FavoriteTable::getTableName(); + if (!$connection->isTableExists($table)) { + FavoriteTable::getEntity()->createDbTable(); + $connection->createIndex($table, "ux_" . $table, ["FUSER_ID", "PRODUCT_ID"], null, $connection::INDEX_UNIQUE); + } + + return true; + } + + public function UnInstallDB(): bool + { + Loader::includeModule($this->MODULE_ID); + $connection = Application::getConnection(); + $table = FavoriteTable::getTableName(); + if ($connection->isTableExists($table)) { + $connection->dropTable($table); + } + + return true; + } +} diff --git a/local/modules/jinove.vinoteca/install/version.php b/local/modules/jinove.vinoteca/install/version.php new file mode 100644 index 0000000..6d8c2ad --- /dev/null +++ b/local/modules/jinove.vinoteca/install/version.php @@ -0,0 +1,6 @@ + "1.0.0", + "VERSION_DATE" => "2026-10-02 00:00:00", +]; diff --git a/local/modules/jinove.vinoteca/lang/en/install/index.php b/local/modules/jinove.vinoteca/lang/en/install/index.php new file mode 100644 index 0000000..1bb7faa --- /dev/null +++ b/local/modules/jinove.vinoteca/lang/en/install/index.php @@ -0,0 +1,5 @@ +getId() > 0; + } + + public static function url(): string + { + return SITE_DIR . (self::isAuthorized() ? "personal/" : "login/"); + } + + public static function label(string $accountCode, string $loginCode): string + { + $code = self::isAuthorized() ? $accountCode : $loginCode; + $text = (string)Loc::getMessage($code); + + return $text !== "" ? $text : (string)Loc::getMessage($accountCode); + } +} diff --git a/local/modules/jinove.vinoteca/lib/altcha.php b/local/modules/jinove.vinoteca/lib/altcha.php new file mode 100644 index 0000000..bae5a7a --- /dev/null +++ b/local/modules/jinove.vinoteca/lib/altcha.php @@ -0,0 +1,85 @@ +createChallenge(new CreateChallengeOptions( + algorithm: new Pbkdf2(), + cost: self::COST, + counter: random_int(self::COUNTER_MIN, self::COUNTER_MAX), + expiresAt: time() + self::TTL, + ))->toArray(); + } + + public static function verify(string $raw): bool + { + $library = self::library(); + if ($library === null || $raw === "" || strlen($raw) > self::MAX_PAYLOAD) { + return false; + } + try { + $payload = Payload::fromBase64($raw); + $result = $library->verifySolution(new VerifySolutionOptions(algorithm: new Pbkdf2(), payload: $payload)); + } catch (\Throwable) { + return false; + } + if (!$result->verified || $payload->challenge->signature === null) { + return false; + } + + return self::markUsed($payload->challenge->signature); + } + + private static function markUsed(string $signature): bool + { + $handle = @fopen(self::dir() . "/altcha-used/" . hash("sha256", $signature), "x"); + if (!$handle) { + return false; + } + fclose($handle); + if (random_int(1, 50) === 1) { + foreach (glob(self::dir() . "/altcha-used/*") ?: [] as $old) { + if (filemtime($old) < time() - 3600) { + @unlink($old); + } + } + } + + return true; + } + + private static function library(): ?Library + { + $key = trim((string)@file_get_contents(self::dir() . "/altcha.key")); + + return $key === "" ? null : new Library(hmacSignatureSecret: $key); + } + + private static function dir(): string + { + return dirname(Application::getDocumentRoot()) . "/data"; + } +} diff --git a/local/modules/jinove.vinoteca/lib/articleschema.php b/local/modules/jinove.vinoteca/lib/articleschema.php new file mode 100644 index 0000000..79f0d4a --- /dev/null +++ b/local/modules/jinove.vinoteca/lib/articleschema.php @@ -0,0 +1,81 @@ + $item) { + $list[] = ["@type" => "ListItem", "position" => $index + 1, "url" => $item["url"], "name" => $item["name"]]; + } + + return [ + "@context" => self::CONTEXT, + "@graph" => [ + [ + "@type" => "CollectionPage", + "@id" => $url . "#webpage", + "url" => $url, + "name" => $name, + "description" => $description, + "inLanguage" => LANGUAGE_ID, + "about" => ["@id" => Config::host() . "/#store"], + "mainEntity" => ["@id" => $url . "#items"], + "workTranslation" => PageSchema::translations($path, "CollectionPage"), + ], + [ + "@type" => "ItemList", + "@id" => $url . "#items", + "url" => $url, + "numberOfItems" => count($list), + "itemListElement" => $list, + ], + ], + ]; + } + + public static function detail(array $article): array + { + $url = Config::host() . $article["path"]; + $store = ["@id" => Config::host() . "/#store"]; + $node = [ + "@type" => "Article", + "@id" => $url . "#article", + "url" => $url, + "headline" => $article["name"], + "description" => $article["description"], + "inLanguage" => LANGUAGE_ID, + "datePublished" => $article["published"], + "dateModified" => $article["modified"], + "author" => $store, + "publisher" => $store, + "wordCount" => $article["words"], + ]; + $page = [ + "@type" => "WebPage", + "@id" => $url . "#webpage", + "url" => $url, + "name" => $article["name"], + "description" => $article["description"], + "inLanguage" => LANGUAGE_ID, + "mainEntity" => ["@id" => $url . "#article"], + "datePublished" => $article["published"], + "dateModified" => $article["modified"], + "workTranslation" => PageSchema::translations($article["path"], "WebPage"), + ]; + if ($article["image"]) { + $image = PageSchema::image($url . "#image", $article["image"]["url"], $article["image"]["width"], $article["image"]["height"]); + $node["image"] = $image; + $page["primaryImageOfPage"] = ["@id" => $url . "#image"]; + } + + return ["@context" => self::CONTEXT, "@graph" => [$page, $node]]; + } +} diff --git a/local/modules/jinove.vinoteca/lib/breadcrumbs.php b/local/modules/jinove.vinoteca/lib/breadcrumbs.php new file mode 100644 index 0000000..4c99919 --- /dev/null +++ b/local/modules/jinove.vinoteca/lib/breadcrumbs.php @@ -0,0 +1,53 @@ +AddChainItem((string)Loc::getMessage("VINO_BREADCRUMBS_HOME"), SITE_DIR); + foreach ($items as $item) { + $link = (string)($item[1] ?? ""); + if ($link !== "" && str_starts_with($link, "/") && !str_starts_with($link, SITE_DIR)) { + $link = SITE_DIR . ltrim($link, "/"); + } + $APPLICATION->AddChainItem((string)$item[0], $link); + } + $APPLICATION->IncludeComponent("bitrix:breadcrumb", "vinoteca", [ + "START_FROM" => "0", + "PATH" => "", + "SITE_ID" => SITE_ID, + ], false, ["HIDE_ICONS" => "Y"]); + } + + public static function schema(array $chain, string $self): array + { + $last = count($chain) - 1; + $items = []; + foreach ($chain as $i => $item) { + $link = (string)$item["LINK"]; + $items[] = [ + "@type" => "ListItem", + "position" => $i + 1, + "name" => $item["TITLE"], + "item" => $i < $last && $link !== "" ? Config::host() . $link : $self, + ]; + } + + return [ + "@context" => "https://schema.org", + "@type" => "BreadcrumbList", + "@id" => $self . "#breadcrumb", + "itemListElement" => $items, + ]; + } +} diff --git a/local/modules/jinove.vinoteca/lib/cached.php b/local/modules/jinove.vinoteca/lib/cached.php new file mode 100644 index 0000000..4ee89bc --- /dev/null +++ b/local/modules/jinove.vinoteca/lib/cached.php @@ -0,0 +1,37 @@ +initCache($ttl, $id, $dir)) { + return $cache->getVars(); + } + + $cache->startDataCache(); + $taggedCache = Application::getInstance()->getTaggedCache(); + $taggedCache->startTagCache($dir); + try { + foreach ($tags as $tag) { + $taggedCache->registerTag($tag); + } + $value = $load(); + } catch (\Throwable $e) { + $taggedCache->abortTagCache(); + $cache->abortDataCache(); + throw $e; + } + $taggedCache->endTagCache(); + $cache->endDataCache($value); + + return $value; + } +} diff --git a/local/modules/jinove.vinoteca/lib/cart.php b/local/modules/jinove.vinoteca/lib/cart.php new file mode 100644 index 0000000..46b0e4a --- /dev/null +++ b/local/modules/jinove.vinoteca/lib/cart.php @@ -0,0 +1,273 @@ + $productId, "QUANTITY" => $quantity], ["LID" => Config::basketSiteId()])->isSuccess(); + } + if ($quantity === 0) { + $item->delete(); + } elseif (!$item->setField("QUANTITY", $quantity)->isSuccess()) { + return false; + } + + return $basket->save()->isSuccess(); + } + + public static function addMany(BasketBase $basket, array $items): bool + { + $ok = true; + foreach ($items as $productId => $quantity) { + $item = self::findItem($basket, (int)$productId); + $current = $item === null ? 0 : (int)$item->getQuantity(); + $ok = self::setQuantity($basket, (int)$productId, $current + (int)$quantity) && $ok; + } + + return $ok; + } + + public static function parseShare(string $code): array + { + if (!preg_match('/^\d{1,9}-\d{1,2}(\.\d{1,9}-\d{1,2}){0,' . (self::SHARE_MAX_ITEMS - 1) . '}$/', $code)) { + return []; + } + $items = []; + foreach (explode(".", $code) as $pair) { + [$productId, $quantity] = array_map("intval", explode("-", $pair)); + if ($productId > 0 && $quantity > 0) { + $items[$productId] = min(self::MAX_QUANTITY, ($items[$productId] ?? 0) + $quantity); + } + } + + return $items; + } + + public static function shared(array $items): array + { + $productIds = array_keys($items); + $products = Related::summariesById($productIds); + $prices = Prices::optimal(array_keys($products), Config::basketSiteId()); + $meta = SearchMeta::get($productIds); + $images = Media::thumbs($productIds, self::THUMB_WIDTH, self::THUMB_HEIGHT); + $list = []; + $sum = 0.0; + $currency = ""; + foreach ($items as $productId => $quantity) { + if (!isset($products[$productId], $prices[$productId])) { + continue; + } + $price = $prices[$productId]; + $currency = $price["currency"]; + $sum += $price["price"] * $quantity; + $list[] = [ + "id" => $productId, + "name" => $products[$productId]["name"], + "url" => $products[$productId]["url"], + "brand" => (string)($meta[$productId]["BRAND"] ?? ""), + "image" => (string)($images[$productId] ?? ""), + "quantity" => $quantity, + "sum" => Money::format($price["price"] * $quantity, $currency), + ]; + } + + return [ + "items" => $list, + "code" => implode(".", array_map(static fn(array $row): string => $row["id"] . "-" . $row["quantity"], $list)), + "total" => $list ? Money::format($sum, $currency) : "", + ]; + } + + public static function clear(BasketBase $basket): bool + { + foreach ($basket as $item) { + if (!$item->isDelay()) { + $item->delete(); + } + } + + return $basket->save()->isSuccess(); + } + + public static function addCoupon(string $code): bool + { + DiscountCouponsManager::init(); + + return DiscountCouponsManager::add($code); + } + + public static function removeCoupon(string $code): bool + { + DiscountCouponsManager::init(); + + return DiscountCouponsManager::delete($code); + } + + public static function state(BasketBase $basket): array + { + $items = []; + $count = 0; + foreach ($basket as $item) { + if (!$item->canBuy() || $item->isDelay()) { + continue; + } + $productId = (int)$item->getProductId(); + $quantity = (int)$item->getQuantity(); + $items[$productId] = ($items[$productId] ?? 0) + $quantity; + $count += $quantity; + } + + return ["count" => $count, "items" => (object)$items]; + } + + public static function view(BasketBase $basket, bool $refresh = true): array + { + DiscountCouponsManager::init(); + if ($refresh) { + $basket->refresh(RefreshFactory::create(RefreshFactory::TYPE_FULL)); + $basket->save(); + } + self::applyDiscounts($basket); + $productIds = []; + foreach ($basket as $item) { + if (!$item->isDelay()) { + $productIds[] = (int)$item->getProductId(); + } + } + $products = Related::summariesById($productIds); + $meta = SearchMeta::get($productIds); + $images = Media::thumbs($productIds, self::THUMB_WIDTH, self::THUMB_HEIGHT); + $currency = ""; + $items = []; + $count = 0; + $lines = 0; + $sum = 0.0; + $base = 0.0; + foreach ($basket as $item) { + if ($item->isDelay()) { + continue; + } + $productId = (int)$item->getProductId(); + $quantity = (int)$item->getQuantity(); + $price = (float)$item->getPrice(); + $basePrice = max($price, (float)$item->getBasePrice()); + $currency = (string)$item->getCurrency(); + $available = $item->canBuy(); + if ($available) { + $lines++; + $count += $quantity; + $sum += $price * $quantity; + $base += $basePrice * $quantity; + } + $items[] = [ + "id" => $productId, + "name" => (string)($products[$productId]["name"] ?? $item->getField("NAME")), + "url" => (string)($products[$productId]["url"] ?? ""), + "meta" => (string)($meta[$productId]["META"] ?? ""), + "brand" => (string)($meta[$productId]["BRAND"] ?? ""), + "image" => (string)($images[$productId] ?? ""), + "quantity" => $quantity, + "available" => $available, + "price" => Money::format($price, $currency), + "basePrice" => $basePrice > $price ? Money::format($basePrice, $currency) : "", + "sum" => Money::format($price * $quantity, $currency), + ]; + } + if ($currency === "") { + $currency = Loader::includeModule("currency") ? (string)CurrencyManager::getBaseCurrency() : ""; + } + + return [ + "count" => $count, + "summary" => Loc::getMessagePlural("VINO_CART_LINES", $lines, ["#COUNT#" => $lines]) . ", " . Loc::getMessagePlural("VINO_CART_BOTTLES", $count, ["#COUNT#" => $count]), + "items" => $items, + "base" => Money::format($base, $currency), + "discount" => $base > $sum ? "\u{2212}" . Money::format($base - $sum, $currency) : "", + "total" => Money::format($sum, $currency), + "coupons" => self::coupons(), + ]; + } + + private static function coupons(): array + { + $coupons = []; + foreach ((array)DiscountCouponsManager::get(true, [], true, true) as $coupon) { + $coupons[] = [ + "code" => (string)$coupon["COUPON"], + "applied" => (int)$coupon["STATUS"] === DiscountCouponsManager::STATUS_APPLYED, + ]; + } + + return $coupons; + } + + private static function applyDiscounts(BasketBase $basket): void + { + $discount = Discount::buildFromBasket($basket, new FuserContext((int)$basket->getFUserId(true))); + if ($discount === null) { + return; + } + $result = $discount->calculate(); + if ($result->isSuccess()) { + $data = $result->getData(); + if (isset($data["BASKET_ITEMS"])) { + $basket->applyDiscount($data["BASKET_ITEMS"]); + } + } + } + + private static function findItem(BasketBase $basket, int $productId): ?BasketItemBase + { + foreach ($basket as $item) { + if ((int)$item->getProductId() === $productId && !$item->isDelay()) { + return $item; + } + } + + return null; + } +} diff --git a/local/modules/jinove.vinoteca/lib/catalog/brandschema.php b/local/modules/jinove.vinoteca/lib/catalog/brandschema.php new file mode 100644 index 0000000..f7c6e74 --- /dev/null +++ b/local/modules/jinove.vinoteca/lib/catalog/brandschema.php @@ -0,0 +1,143 @@ + $item) { + $list[] = ["@type" => "ListItem", "position" => $index + 1, "url" => $item["url"], "name" => $item["name"]]; + } + $page = [ + "@type" => "CollectionPage", + "@id" => $url . "#webpage", + "url" => $url, + "name" => $name, + "description" => $description, + "inLanguage" => LANGUAGE_ID, + "about" => ["@id" => Config::host() . "/#store"], + "mainEntity" => ["@id" => $url . "#items"], + "workTranslation" => PageSchema::translations(SITE_DIR . "brands/", "CollectionPage"), + ]; + $itemList = ["@type" => "ItemList", "@id" => $url . "#items", "numberOfItems" => count($list), "itemListElement" => $list]; + + return ["@context" => self::CONTEXT, "@graph" => [$page, $itemList]]; + } + + public static function detail(array $brand, array $wines, int $winesTotal): array + { + $url = $brand["url"]; + $node = [ + "@type" => ["Brand", "Winery"], + "@id" => $url . "#brand", + "name" => $brand["name"], + "url" => $url, + ]; + if ($brand["description"] !== "") { + $node["description"] = $brand["description"]; + } + if ($brand["logo"] !== "") { + $node["logo"] = PageSchema::image($url . "#logo", $brand["logo"], $brand["logoWidth"], $brand["logoHeight"]); + } + $address = ["@type" => "PostalAddress"]; + if ($brand["country"] !== "") { + $address["addressCountry"] = $brand["country"]; + } + if ($brand["region"] !== "") { + $address["addressRegion"] = $brand["region"]; + } + if (count($address) > 1) { + $node["address"] = $address; + } + if (preg_match('/^\d{4}$/', $brand["founded"])) { + $node["foundingDate"] = $brand["founded"]; + } + $list = []; + foreach (array_values($wines) as $index => $wine) { + $list[] = ["@type" => "ListItem", "position" => $index + 1, "url" => Config::host() . $wine["url"], "name" => $wine["name"]]; + } + $page = [ + "@type" => "CollectionPage", + "@id" => $url . "#webpage", + "url" => $url, + "name" => $brand["name"], + "description" => $brand["pageDescription"], + "inLanguage" => LANGUAGE_ID, + "mainEntity" => ["@id" => $url . "#brand"], + "workTranslation" => PageSchema::translations($brand["path"], "CollectionPage"), + ]; + $graph = [$page, $node]; + if ($list) { + $graph[] = ["@type" => "ItemList", "@id" => $url . "#items", "numberOfItems" => $winesTotal, "itemListElement" => $list]; + } + + return ["@context" => self::CONTEXT, "@graph" => $graph]; + } + + public static function countryCode(string $englishName): string + { + return [ + "Argentina" => "AR", "Australia" => "AU", "France" => "FR", "Hungary" => "HU", "Italy" => "IT", + "New Zealand" => "NZ", "Portugal" => "PT", "Spain" => "ES", "USA" => "US", + ][trim($englishName)] ?? ""; + } + + public static function wines(int $brandId): array + { + $catalogId = Config::iblockId("catalog"); + if ($brandId <= 0 || $catalogId <= 0 || !Loader::includeModule("iblock")) { + return ["items" => [], "total" => 0]; + } + \CIBlock::registerWithTagCache($catalogId); + $property = PropertyTable::getRow(["select" => ["ID"], "filter" => ["=IBLOCK_ID" => $catalogId, "=CODE" => "BRAND"]]); + if ($property === null) { + return ["items" => [], "total" => 0]; + } + $ids = []; + $rows = ElementPropertyTable::getList([ + "select" => ["IBLOCK_ELEMENT_ID"], + "filter" => ["=IBLOCK_PROPERTY_ID" => (int)$property["ID"], "=VALUE_NUM" => $brandId], + ]); + while ($row = $rows->fetch()) { + $ids[] = (int)$row["IBLOCK_ELEMENT_ID"]; + } + if (!$ids) { + return ["items" => [], "total" => 0]; + } + $now = new DateTime(); + $ordered = ElementTable::getList([ + "select" => ["ID"], + "filter" => [ + "=IBLOCK_ID" => $catalogId, + "=ID" => $ids, + "=ACTIVE" => "Y", + ["LOGIC" => "OR", ["=ACTIVE_FROM" => false], ["<=ACTIVE_FROM" => $now]], + ["LOGIC" => "OR", ["=ACTIVE_TO" => false], [">=ACTIVE_TO" => $now]], + ], + "order" => ["SORT" => "ASC", "ID" => "DESC"], + ])->fetchAll(); + $sortedIds = array_map(static fn(array $row): int => (int)$row["ID"], $ordered); + $summaries = Related::summariesById(array_slice($sortedIds, 0, self::WINES_LIMIT)); + + return [ + "items" => array_values(array_filter(array_map(static fn(int $id): ?array => $summaries[$id] ?? null, array_slice($sortedIds, 0, self::WINES_LIMIT)))), + "total" => count($sortedIds), + ]; + } +} diff --git a/local/modules/jinove.vinoteca/lib/catalog/comparison.php b/local/modules/jinove.vinoteca/lib/catalog/comparison.php new file mode 100644 index 0000000..1923d33 --- /dev/null +++ b/local/modules/jinove.vinoteca/lib/catalog/comparison.php @@ -0,0 +1,240 @@ +SetTitle((string)Loc::getMessage("VINO_COMPARE_H1")); + $APPLICATION->SetPageProperty("title", (string)Loc::getMessage("VINO_COMPARE_H1")); + $APPLICATION->SetPageProperty("robots", "noindex, follow"); + $APPLICATION->SetPageProperty("vino_alternates", "N"); + } + + public static function isEmpty(): bool + { + return !self::read(); + } + + public static function read(): array + { + $list = Application::getInstance()->getSession()[self::SESSION_KEY] ?? []; + + return (array)($list[Config::iblockId("catalog")]["ITEMS"] ?? []); + } + + public static function write(array $items): void + { + $session = Application::getInstance()->getSession(); + $list = (array)($session[self::SESSION_KEY] ?? []); + $list[Config::iblockId("catalog")]["ITEMS"] = $items; + $session[self::SESSION_KEY] = $list; + } + + public static function prune(): array + { + $items = self::read(); + if (!$items || !Loader::includeModule("iblock")) { + return $items; + } + $active = array_flip(array_map("intval", array_column(\Bitrix\Iblock\ElementTable::getList([ + "select" => ["ID"], + "filter" => ["=ID" => array_map("intval", array_keys($items)), "=IBLOCK_ID" => Config::iblockId("catalog"), "=ACTIVE" => "Y"], + ])->fetchAll(), "ID"))); + $kept = array_intersect_key($items, $active); + if (count($kept) !== count($items)) { + self::write($kept); + } + + return $kept; + } + + public static function params(): array + { + $catalog = Listing::catalogParams(); + + return [ + "NAME" => self::SESSION_KEY, + "IBLOCK_TYPE" => $catalog["IBLOCK_TYPE"], + "IBLOCK_ID" => $catalog["IBLOCK_ID"], + "FIELD_CODE" => [], + "PROPERTY_CODE" => [], + "OFFERS_FIELD_CODE" => [], + "OFFERS_PROPERTY_CODE" => [], + "PRICE_CODE" => $catalog["PRICE_CODE"], + "USE_PRICE_COUNT" => "N", + "SHOW_PRICE_COUNT" => "1", + "PRICE_VAT_INCLUDE" => "Y", + "CONVERT_CURRENCY" => "N", + "BASKET_URL" => $catalog["BASKET_URL"], + "ACTION_VARIABLE" => $catalog["ACTION_VARIABLE"], + "PRODUCT_ID_VARIABLE" => $catalog["PRODUCT_ID_VARIABLE"], + "SECTION_ID_VARIABLE" => "SECTION_ID", + "DETAIL_URL" => $catalog["SEF_FOLDER"] . $catalog["SEF_URL_TEMPLATES"]["element"], + "DISPLAY_ELEMENT_SELECT_BOX" => "N", + "ELEMENT_SORT_FIELD" => "sort", + "ELEMENT_SORT_ORDER" => "asc", + "HIDE_NOT_AVAILABLE" => "N", + "TEMPLATE_THEME" => "", + ]; + } + + public static function build(array $compareItems): array + { + $ids = []; + foreach ($compareItems as $item) { + $ids[] = (int)($item["ID"] ?? 0); + } + $ids = array_values(array_filter($ids)); + if (!$ids || !Loader::includeModule("iblock")) { + return ["ITEMS" => [], "ROWS" => []]; + } + $summaries = Related::summariesById($ids); + $prices = Prices::optimal($ids); + $available = self::availability($ids); + $catalogId = Config::iblockId("catalog"); + $elements = []; + $rows = \CIBlockElement::GetList([], ["ID" => $ids, "IBLOCK_ID" => $catalogId], false, false, ["ID", "IBLOCK_ID", "NAME", "PREVIEW_PICTURE", "DETAIL_PICTURE"]); + while ($row = $rows->Fetch()) { + $row["PROPERTIES"] = []; + $elements[(int)$row["ID"]] = $row; + } + if ($elements) { + $properties = array_fill_keys(array_keys($elements), []); + \CIBlockElement::GetPropertyValuesArray($properties, $catalogId, ["ID" => array_keys($elements)]); + foreach ($properties as $id => $values) { + $elements[$id]["PROPERTIES"] = $values; + } + } + $brands = self::brandNames($elements); + $items = []; + $values = []; + foreach ($ids as $id) { + $element = $elements[$id] ?? null; + $summary = $summaries[$id] ?? null; + if ($element === null || $summary === null) { + continue; + } + $items[] = self::item($element, $summary, $prices[$id] ?? null, $available[$id] ?? false); + foreach (self::ROWS as $code) { + $values[$code][] = self::value($code, $element["PROPERTIES"], $brands); + } + } + $table = []; + foreach (self::ROWS as $code) { + $cells = $values[$code] ?? []; + if (!array_filter($cells, static fn(string $cell): bool => $cell !== "")) { + continue; + } + $same = count($cells) > 1 && count(array_unique($cells)) === 1; + $table[] = ["LABEL" => (string)Loc::getMessage("VINO_COMPARE_ROW_" . $code), "VALUES" => $cells, "SAME" => $same]; + } + + return ["ITEMS" => $items, "ROWS" => $table]; + } + + private static function item(array $element, array $summary, ?array $price, bool $available): array + { + $pictureId = (int)($element["PREVIEW_PICTURE"] ?: $element["DETAIL_PICTURE"]); + $prices = []; + if ($price) { + $prices[] = [ + "RATIO_PRICE" => $price["price"], + "PRINT_RATIO_PRICE" => htmlspecialcharsbx(Money::format($price["price"], $price["currency"])), + "RATIO_BASE_PRICE" => $price["base"], + "PRINT_RATIO_BASE_PRICE" => htmlspecialcharsbx(Money::format($price["base"], $price["currency"])), + "PERCENT" => $price["base"] > 0 ? round(100 - $price["price"] / $price["base"] * 100) : 0, + ]; + } + + return [ + "ID" => (int)$element["ID"], + "NAME" => htmlspecialcharsbx((string)$summary["name"]), + "~NAME" => (string)$summary["name"], + "DETAIL_PAGE_URL" => htmlspecialcharsbx((string)$summary["url"]), + "~DETAIL_PAGE_URL" => (string)$summary["url"], + "PREVIEW_PICTURE" => $pictureId > 0 ? ["ID" => $pictureId] : null, + "DETAIL_PICTURE" => null, + "PROPERTIES" => $element["PROPERTIES"], + "ITEM_PRICES" => $prices, + "ITEM_PRICE_SELECTED" => 0, + "CAN_BUY" => $available && $prices !== [], + ]; + } + + private static function value(string $code, array $properties, array $brands): string + { + $raw = $properties[$code]["~VALUE"] ?? $properties[$code]["VALUE"] ?? ""; + if (is_array($raw) && !isset($raw["TEXT"])) { + $raw = implode(", ", array_filter($raw)); + } + $plain = trim(is_array($raw) ? (string)($raw["TEXT"] ?? "") : (string)$raw); + $number = static fn(string $value): string => LANGUAGE_ID === "en" ? $value : str_replace(".", ",", $value); + + return match ($code) { + "WINE_COLOR", "COUNTRY", "REGION", "GRAPE", "SUGAR" => EnumNames::fromProperty($properties[$code] ?? []), + "BRAND" => $brands[(int)$plain] ?? "", + "ABV" => $plain !== "" ? $number((string)(float)$plain) . "%" : "", + "VOLUME" => $plain !== "" ? (string)Loc::getMessage("VINO_COMPARE_VOLUME", ["#VALUE#" => $number($plain)]) : "", + "AGING" => LocalizedText::property($properties, $code), + default => $plain, + }; + } + + private static function brandNames(array $elements): array + { + $ids = []; + foreach ($elements as $element) { + $value = $element["PROPERTIES"]["BRAND"]["VALUE"] ?? 0; + $ids[] = (int)(is_array($value) ? reset($value) : $value); + } + $ids = array_values(array_unique(array_filter($ids))); + if (!$ids) { + return []; + } + $names = []; + $rows = \Bitrix\Iblock\ElementTable::getList(["select" => ["ID", "NAME"], "filter" => ["=ID" => $ids]]); + while ($row = $rows->fetch()) { + $names[(int)$row["ID"]] = (string)$row["NAME"]; + } + + return $names; + } + + private static function availability(array $ids): array + { + if (!Loader::includeModule("catalog")) { + return []; + } + $available = []; + $rows = ProductTable::getList(["select" => ["ID", "AVAILABLE"], "filter" => ["=ID" => $ids]]); + while ($row = $rows->fetch()) { + $available[(int)$row["ID"]] = $row["AVAILABLE"] === "Y"; + } + + return $available; + } +} diff --git a/local/modules/jinove.vinoteca/lib/catalog/countries.php b/local/modules/jinove.vinoteca/lib/catalog/countries.php new file mode 100644 index 0000000..9e83555 --- /dev/null +++ b/local/modules/jinove.vinoteca/lib/catalog/countries.php @@ -0,0 +1,33 @@ + "ASC", "VALUE" => "ASC"], ["IBLOCK_ID" => $catalogId, "CODE" => "COUNTRY"]); + while ($row = $rows->Fetch()) { + $names[(string)$row["XML_ID"]] = (string)$row["VALUE"]; + } + + return $names; + }); + } +} diff --git a/local/modules/jinove.vinoteca/lib/catalog/enumnames.php b/local/modules/jinove.vinoteca/lib/catalog/enumnames.php new file mode 100644 index 0000000..b2a5e5a --- /dev/null +++ b/local/modules/jinove.vinoteca/lib/catalog/enumnames.php @@ -0,0 +1,35 @@ + $xmlId) { + if ((string)$xmlId === "") { + continue; + } + $names[] = self::name((string)$property["CODE"], (string)$xmlId, (string)($values[$index] ?? "")); + } + + return implode(", ", $names); + } +} diff --git a/local/modules/jinove.vinoteca/lib/catalog/favorite.php b/local/modules/jinove.vinoteca/lib/catalog/favorite.php new file mode 100644 index 0000000..0fbd494 --- /dev/null +++ b/local/modules/jinove.vinoteca/lib/catalog/favorite.php @@ -0,0 +1,95 @@ +configurePrimary()->configureAutocomplete(), + (new IntegerField("FUSER_ID"))->configureRequired(), + (new IntegerField("PRODUCT_ID"))->configureRequired(), + (new DatetimeField("DATE_CREATE"))->configureDefaultValue(static fn(): DateTime => new DateTime()), + ]; + } + + public static function productIds(int $fuserId): array + { + if ($fuserId <= 0) { + return []; + } + $ids = array_map("intval", array_column(self::getList([ + "select" => ["PRODUCT_ID"], + "filter" => ["=FUSER_ID" => $fuserId], + "order" => ["ID" => "ASC"], + ])->fetchAll(), "PRODUCT_ID")); + if (!$ids || !Loader::includeModule("iblock")) { + return []; + } + $active = array_flip(array_map("intval", array_column(ElementTable::getList([ + "select" => ["ID"], + "filter" => ["=ID" => $ids, "=IBLOCK_ID" => Config::iblockId("catalog"), "=ACTIVE" => "Y"], + ])->fetchAll(), "ID"))); + + return array_values(array_filter($ids, static fn(int $id): bool => isset($active[$id]))); + } + + public static function onElementDelete(array $fields): void + { + $productId = (int)($fields["ID"] ?? 0); + if ($productId <= 0) { + return; + } + $rows = self::getList(["select" => ["ID"], "filter" => ["=PRODUCT_ID" => $productId]]); + while ($row = $rows->fetch()) { + self::delete((int)$row["ID"]); + } + } + + public static function rememberGuest(): void + { + if (Loader::includeModule("sale")) { + self::$guestFuser = (int)Fuser::getId(true); + } + } + + public static function mergeGuest(): void + { + if (self::$guestFuser <= 0 || !Loader::includeModule("sale")) { + return; + } + $userFuser = (int)Fuser::getId(true); + if ($userFuser <= 0 || $userFuser === self::$guestFuser) { + return; + } + $owned = array_flip(array_map("intval", array_column(self::getList(["select" => ["PRODUCT_ID"], "filter" => ["=FUSER_ID" => $userFuser]])->fetchAll(), "PRODUCT_ID"))); + $rows = self::getList(["select" => ["ID", "PRODUCT_ID"], "filter" => ["=FUSER_ID" => self::$guestFuser]]); + while ($row = $rows->fetch()) { + if (isset($owned[(int)$row["PRODUCT_ID"]])) { + self::delete((int)$row["ID"]); + } else { + self::update((int)$row["ID"], ["FUSER_ID" => $userFuser]); + } + } + self::$guestFuser = 0; + } +} diff --git a/local/modules/jinove.vinoteca/lib/catalog/favorites.php b/local/modules/jinove.vinoteca/lib/catalog/favorites.php new file mode 100644 index 0000000..5285543 --- /dev/null +++ b/local/modules/jinove.vinoteca/lib/catalog/favorites.php @@ -0,0 +1,88 @@ +SetTitle((string)Loc::getMessage("VINO_FAVORITES_H1")); + $APPLICATION->SetPageProperty("title", (string)Loc::getMessage("VINO_FAVORITES_H1")); + $APPLICATION->SetPageProperty("robots", "noindex, follow"); + $APPLICATION->SetPageProperty("vino_alternates", "N"); + Asset::getInstance()->addCss(SITE_TEMPLATE_PATH . "/catalog-styles.css"); + Asset::getInstance()->addJs(SITE_TEMPLATE_PATH . "/assets/js/vino-favorites.js"); + } + + public static function ids(): array + { + if (!Loader::includeModule("sale")) { + return []; + } + + return FavoriteTable::productIds((int)Fuser::getId(true)); + } + + public static function params(array $ids): array + { + $GLOBALS[self::FILTER] = ["ID" => $ids ?: [0]]; + $catalog = Listing::catalogParams(); + + return [ + "IBLOCK_TYPE" => $catalog["IBLOCK_TYPE"], + "IBLOCK_ID" => $catalog["IBLOCK_ID"], + "SECTION_ID" => 0, + "SHOW_ALL_WO_SECTION" => "Y", + "FILTER_NAME" => self::FILTER, + "PRICE_CODE" => $catalog["PRICE_CODE"], + "BASKET_URL" => $catalog["BASKET_URL"], + "PAGE_ELEMENT_COUNT" => "24", + "LINE_ELEMENT_COUNT" => "4", + "INCLUDE_SUBSECTIONS" => "Y", + "ELEMENT_SORT_FIELD" => "SORT", + "ELEMENT_SORT_ORDER" => "ASC", + "ELEMENT_SORT_FIELD2" => "ID", + "ELEMENT_SORT_ORDER2" => "DESC", + "PROPERTY_CODE" => $catalog["LIST_PROPERTY_CODE"], + "CACHE_TYPE" => $catalog["CACHE_TYPE"], + "CACHE_TIME" => $catalog["CACHE_TIME"], + "CACHE_GROUPS" => $catalog["CACHE_GROUPS"], + "CACHE_FILTER" => "Y", + "SET_TITLE" => "N", + "SET_BROWSER_TITLE" => "N", + "SET_META_KEYWORDS" => "N", + "SET_META_DESCRIPTION" => "N", + "SET_STATUS_404" => "N", + "SHOW_404" => "N", + "ADD_SECTIONS_CHAIN" => "N", + "ACTION_VARIABLE" => $catalog["ACTION_VARIABLE"], + "PRODUCT_ID_VARIABLE" => $catalog["PRODUCT_ID_VARIABLE"], + "USE_PRODUCT_QUANTITY" => "Y", + "ADD_TO_BASKET_ACTION" => "ADD", + "SHOW_OLD_PRICE" => "Y", + "SHOW_DISCOUNT_PERCENT" => "Y", + "DISPLAY_TOP_PAGER" => "N", + "DISPLAY_BOTTOM_PAGER" => "Y", + "PAGER_TEMPLATE" => "vinoteca", + "PAGER_SHOW_ALWAYS" => "N", + "PAGER_TITLE" => (string)Loc::getMessage("VINO_FAVORITES_PAGER_TITLE"), + "SECTION_URL" => $catalog["SEF_FOLDER"] . $catalog["SEF_URL_TEMPLATES"]["section"], + "DETAIL_URL" => $catalog["SEF_FOLDER"] . $catalog["SEF_URL_TEMPLATES"]["element"], + "HIDE_NOT_AVAILABLE" => "N", + "VINO_TITLE_TAG" => "h2", + "VINO_GRID_FULL" => "Y", + ]; + } +} diff --git a/local/modules/jinove.vinoteca/lib/catalog/listing.php b/local/modules/jinove.vinoteca/lib/catalog/listing.php new file mode 100644 index 0000000..d57c6c1 --- /dev/null +++ b/local/modules/jinove.vinoteca/lib/catalog/listing.php @@ -0,0 +1,186 @@ + "catalog", + "IBLOCK_ID" => VINO_CATALOG_IBLOCK, + "SEF_MODE" => "Y", + "SEF_FOLDER" => SITE_DIR . "catalog/", + "SEF_URL_TEMPLATES" => [ + "sections" => "", + "section" => "#SECTION_CODE#/", + "element" => "#SECTION_CODE#/#ELEMENT_CODE#/", + "smart_filter" => "#SECTION_CODE#/filter/#SMART_FILTER_PATH#/apply/", + ], + "PRICE_CODE" => ["BASE"], + "BASKET_URL" => SITE_DIR . "personal/cart/", + "ACTION_VARIABLE" => "action", + "PRODUCT_ID_VARIABLE" => "id", + "CACHE_TYPE" => "A", + "CACHE_TIME" => "3600", + "CACHE_GROUPS" => "N", + "SET_STATUS_404" => "Y", + "SHOW_404" => "Y", + "MESSAGE_404" => "", + "FILE_404" => "", + "LIST_PROPERTY_CODE" => ["WINE_COLOR", "SUGAR", "VOLUME", "REGION", "COUNTRY"], + "DETAIL_PROPERTY_CODE" => ["WINE_COLOR", "SUGAR", "GRAPE", "VOLUME", "ABV", "REGION", "COUNTRY", "BRAND", "ARTNUMBER", "VINTAGE", "AGING", "SERVE_TEMP", "FOOD_PAIRING", "TASTE_COLOR", "AROMA", "TASTE", "MORE_PHOTO"], + ]; + } + + public static function sectionTilesParams(): array + { + $catalog = self::catalogParams(); + + return [ + "IBLOCK_TYPE" => $catalog["IBLOCK_TYPE"], + "IBLOCK_ID" => $catalog["IBLOCK_ID"], + "SECTION_ID" => "", + "SECTION_CODE" => "", + "TOP_DEPTH" => "1", + "COUNT_ELEMENTS" => "Y", + "COUNT_ELEMENTS_FILTER" => "CNT_ACTIVE", + "HIDE_SECTIONS_WITH_ZERO_COUNT_ELEMENTS" => "Y", + "SECTION_FIELDS" => ["CODE", "PICTURE"], + "SECTION_USER_FIELDS" => [], + "ADD_SECTIONS_CHAIN" => "N", + "CACHE_TYPE" => $catalog["CACHE_TYPE"], + "CACHE_TIME" => $catalog["CACHE_TIME"], + "CACHE_GROUPS" => $catalog["CACHE_GROUPS"], + ]; + } + + public static function prepareBestsellers(): array + { + $GLOBALS["bestsellersFilter"] = ["!PROPERTY_SALELEADER" => false]; + $catalog = self::catalogParams(); + + return [ + "IBLOCK_TYPE" => $catalog["IBLOCK_TYPE"], + "IBLOCK_ID" => $catalog["IBLOCK_ID"], + "ELEMENT_COUNT" => "12", + "FILTER_NAME" => "bestsellersFilter", + "ELEMENT_SORT_FIELD" => "SORT", + "ELEMENT_SORT_ORDER" => "asc", + "ELEMENT_SORT_FIELD2" => "PROPERTY_RATING", + "ELEMENT_SORT_ORDER2" => "desc", + "PROPERTY_CODE" => $catalog["LIST_PROPERTY_CODE"], + "PRICE_CODE" => $catalog["PRICE_CODE"], + "PRICE_VAT_INCLUDE" => "Y", + "USE_PRICE_COUNT" => "N", + "SHOW_PRICE_COUNT" => "1", + "CONVERT_CURRENCY" => "N", + "HIDE_NOT_AVAILABLE" => "N", + "DETAIL_URL" => SITE_DIR . "catalog/#SECTION_CODE#/#ELEMENT_CODE#/", + "SECTION_URL" => SITE_DIR . "catalog/#SECTION_CODE#/", + "CACHE_TYPE" => $catalog["CACHE_TYPE"], + "CACHE_TIME" => $catalog["CACHE_TIME"], + "CACHE_GROUPS" => $catalog["CACHE_GROUPS"], + "CACHE_FILTER" => "Y", + ]; + } + + public static function filterParams(string $sectionCode, string $filterPath): array + { + $catalog = self::catalogParams(); + + return [ + "IBLOCK_TYPE" => $catalog["IBLOCK_TYPE"], + "IBLOCK_ID" => $catalog["IBLOCK_ID"], + "SECTION_CODE" => $sectionCode, + "FILTER_NAME" => "wineFilter", + "PRICE_CODE" => $catalog["PRICE_CODE"], + "CACHE_TYPE" => $catalog["CACHE_TYPE"], + "CACHE_TIME" => $catalog["CACHE_TIME"], + "CACHE_GROUPS" => $catalog["CACHE_GROUPS"], + "SAVE_IN_SESSION" => "N", + "XML_EXPORT" => "N", + "SEF_MODE" => "Y", + "SEF_RULE" => $catalog["SEF_FOLDER"] . $catalog["SEF_URL_TEMPLATES"]["smart_filter"], + "SMART_FILTER_PATH" => $filterPath, + "INSTANT_RELOAD" => "N", + "TEMPLATE_THEME" => "", + "CONVERT_CURRENCY" => "N", + ]; + } + + public static function countryCodeFromRoute(array $variables): ?string + { + $code = (string)($variables["ELEMENT_CODE"] ?? ""); + + return ($variables["SECTION_CODE"] ?? "") === "country" && $code !== "" ? $code : null; + } + + public static function countryPath(string $countryCode): string + { + return self::catalogParams()["SEF_FOLDER"] . "country/" . rawurlencode($countryCode) . "/"; + } + + public static function sectionPath(string $sectionCode): string + { + return self::catalogParams()["SEF_FOLDER"] . $sectionCode . "/"; + } + + public static function basePath(string $sectionCode, string $filterPath): string + { + $sectionPath = self::sectionPath($sectionCode); + + return $filterPath !== "" ? $sectionPath . "filter/" . $filterPath . "/apply/" : $sectionPath; + } + + public static function pagePath(string $sectionCode, string $filterPath, string $sort, int $page): string + { + $sectionPath = self::sectionPath($sectionCode); + if ($filterPath === "" && $sort === "" && $page > 1) { + return $sectionPath . "?PAGEN_1=" . $page; + } + + return $sectionPath; + } + + public static function filterPathIsValid(string $sectionCode, string $filterPath): bool + { + if ($filterPath === "") { + return true; + } + global $APPLICATION; + ob_start(); + try { + $result = $APPLICATION->IncludeComponent("bitrix:catalog.smart.filter", "", self::filterParams($sectionCode, $filterPath), null, [], true); + } finally { + ob_end_clean(); + } + + return (string)($result["JS_FILTER_PARAMS"]["SEF_SET_FILTER_URL"] ?? "") === self::basePath($sectionCode, $filterPath); + } + + public static function parsePath(string $path): ?array + { + $catalog = self::catalogParams(); + $variables = []; + $engine = new \CComponentEngine(); + $engine->addGreedyPart("#SMART_FILTER_PATH#"); + $page = $engine->guessComponentPath($catalog["SEF_FOLDER"], $catalog["SEF_URL_TEMPLATES"], $variables, str_ends_with($path, "/") ? $path . "index.php" : $path); + if ($page !== "section" && $page !== "smart_filter") { + return null; + } + $sectionCode = (string)($variables["SECTION_CODE"] ?? ""); + if ($sectionCode === "" || $sectionCode !== strtolower($sectionCode) || Sections::byCode($sectionCode) === []) { + return null; + } + + return [ + "SECTION_CODE" => $sectionCode, + "FILTER_PATH" => (string)($variables["SMART_FILTER_PATH"] ?? ""), + ]; + } +} diff --git a/local/modules/jinove.vinoteca/lib/catalog/localizedtext.php b/local/modules/jinove.vinoteca/lib/catalog/localizedtext.php new file mode 100644 index 0000000..8ae22ba --- /dev/null +++ b/local/modules/jinove.vinoteca/lib/catalog/localizedtext.php @@ -0,0 +1,79 @@ + ["ID", "PREVIEW_PICTURE", "DETAIL_PICTURE"], "filter" => ["=ID" => $productIds]]); + while ($row = $rows->fetch()) { + $fileId = (int)($row["DETAIL_PICTURE"] ?: $row["PREVIEW_PICTURE"]); + if ($fileId > 0) { + $resized = \CFile::ResizeImageGet($fileId, ["width" => $width, "height" => $height], BX_RESIZE_IMAGE_PROPORTIONAL, false); + if (!empty($resized["src"])) { + $images[(int)$row["ID"]] = (string)$resized["src"]; + } + } + } + + return $images; + } +} diff --git a/local/modules/jinove.vinoteca/lib/catalog/megamenu.php b/local/modules/jinove.vinoteca/lib/catalog/megamenu.php new file mode 100644 index 0000000..00e897c --- /dev/null +++ b/local/modules/jinove.vinoteca/lib/catalog/megamenu.php @@ -0,0 +1,130 @@ + [], "COUNTRIES" => [], "BRANDS" => [], "TOTAL" => 0]; + if (!Loader::includeModule("iblock")) { + return $result; + } + $result["TYPES"] = self::types($iblockId); + $result["COUNTRIES"] = self::countries($iblockId); + $result["BRANDS"] = array_slice(self::brands($iblockId), 0, $brandsLimit); + $result["TOTAL"] = ServiceLocator::getInstance()->get("jinove.vinoteca.wineStats")->getActiveCount(); + + return $result; + } + + public static function types(int $iblockId): array + { + $counts = []; + $rows = SectionElementTable::getList([ + "select" => ["IBLOCK_SECTION_ID", "CNT"], + "runtime" => [new ExpressionField("CNT", "COUNT(DISTINCT %s)", "IBLOCK_ELEMENT_ID")], + "filter" => ["=IBLOCK_ELEMENT.IBLOCK_ID" => $iblockId, "=IBLOCK_ELEMENT.ACTIVE" => "Y"], + "group" => ["IBLOCK_SECTION_ID"], + ]); + while ($row = $rows->fetch()) { + $counts[(int)$row["IBLOCK_SECTION_ID"]] = (int)$row["CNT"]; + } + $types = []; + foreach (Sections::all() as $code => $section) { + $count = $counts[$section["ID"]] ?? 0; + if ($section["ACTIVE"] && $section["DEPTH_LEVEL"] === 1 && $count > 0) { + $types[] = ["NAME" => $section["NAME"], "URL" => SITE_DIR . "catalog/" . $code . "/", "COUNT" => $count]; + } + } + + return $types; + } + + private static function countries(int $iblockId): array + { + $propertyId = self::propertyId($iblockId, "COUNTRY"); + if ($propertyId <= 0) { + return []; + } + $xmlIds = []; + $rows = PropertyEnumerationTable::getList(["select" => ["ID", "XML_ID"], "filter" => ["=PROPERTY_ID" => $propertyId]]); + while ($row = $rows->fetch()) { + $xmlIds[(int)$row["ID"]] = (string)$row["XML_ID"]; + } + $names = Countries::names(); + $countries = []; + foreach (self::counts($iblockId, $propertyId, "VALUE_ENUM") as $enumId => $count) { + $code = $xmlIds[$enumId] ?? ""; + if ($code !== "" && isset($names[$code])) { + $countries[] = ["NAME" => EnumNames::name("COUNTRY", $code, $names[$code]), "URL" => Listing::countryPath($code), "COUNT" => $count]; + } + } + usort($countries, static fn(array $a, array $b): int => $b["COUNT"] <=> $a["COUNT"]); + + return $countries; + } + + private static function brands(int $iblockId): array + { + $propertyId = self::propertyId($iblockId, "BRAND"); + if ($propertyId <= 0) { + return []; + } + $counts = self::counts($iblockId, $propertyId, "VALUE_NUM"); + if (!$counts) { + return []; + } + $brands = []; + $rows = ElementTable::getList([ + "select" => ["ID", "NAME", "CODE"], + "filter" => ["=ID" => array_keys($counts), "=ACTIVE" => "Y"], + ]); + while ($row = $rows->fetch()) { + $brands[] = ["NAME" => (string)$row["NAME"], "URL" => SITE_DIR . "brands/" . $row["CODE"] . "/", "COUNT" => $counts[(int)$row["ID"]]]; + } + usort($brands, static fn(array $a, array $b): int => $b["COUNT"] <=> $a["COUNT"]); + + return $brands; + } + + private static function counts(int $iblockId, int $propertyId, string $valueField): array + { + $counts = []; + $rows = ElementPropertyTable::getList([ + "select" => [$valueField, "CNT"], + "runtime" => [new ExpressionField("CNT", "COUNT(DISTINCT %s)", "IBLOCK_ELEMENT_ID")], + "filter" => ["=IBLOCK_PROPERTY_ID" => $propertyId, "=ELEMENT.IBLOCK_ID" => $iblockId, "=ELEMENT.ACTIVE" => "Y", ">" . $valueField => 0], + "group" => [$valueField], + ]); + while ($row = $rows->fetch()) { + $counts[(int)$row[$valueField]] = (int)$row["CNT"]; + } + + return $counts; + } + + private static function propertyId(int $iblockId, string $code): int + { + $row = PropertyTable::getRow(["select" => ["ID"], "filter" => ["=IBLOCK_ID" => $iblockId, "=CODE" => $code]]); + + return (int)($row["ID"] ?? 0); + } +} diff --git a/local/modules/jinove.vinoteca/lib/catalog/photosort.php b/local/modules/jinove.vinoteca/lib/catalog/photosort.php new file mode 100644 index 0000000..49c854b --- /dev/null +++ b/local/modules/jinove.vinoteca/lib/catalog/photosort.php @@ -0,0 +1,44 @@ + ["DETAIL_PICTURE", "SORT", "IBLOCK_ID"], + "filter" => ["=ID" => $id], + ]); + if (!$row) { + return; + } + $sort = (int)$row["DETAIL_PICTURE"] > 0 ? self::WITH_PHOTO : self::WITHOUT_PHOTO; + if ((int)$row["SORT"] === $sort) { + return; + } + self::$busy = true; + (new \CIBlockElement())->Update($id, ["SORT" => $sort], false, false, false); + self::$busy = false; + } +} diff --git a/local/modules/jinove.vinoteca/lib/catalog/pricepresets.php b/local/modules/jinove.vinoteca/lib/catalog/pricepresets.php new file mode 100644 index 0000000..2ae7ed7 --- /dev/null +++ b/local/modules/jinove.vinoteca/lib/catalog/pricepresets.php @@ -0,0 +1,65 @@ + self::collect($iblockId, $sectionCode, $priceCode)); + } + + public static function groupId(string $priceCode): int + { + if (!Loader::includeModule("catalog")) { + return 0; + } + $group = GroupTable::getRow([ + "select" => ["ID"], + "filter" => ["=NAME" => $priceCode], + "cache" => ["ttl" => self::CACHE_TTL], + ]); + + return $group === null ? 0 : (int)$group["ID"]; + } + + private static function collect(int $iblockId, string $sectionCode, string $priceCode): array + { + if (!Loader::includeModule("iblock")) { + return []; + } + $groupId = self::groupId($priceCode); + if ($groupId === 0) { + return []; + } + + $filter = [ + "IBLOCK_ID" => $iblockId, + "ACTIVE" => "Y", + "SECTION_CODE" => $sectionCode, + "INCLUDE_SUBSECTIONS" => "Y", + ]; + $total = (int)\CIBlockElement::GetList([], $filter, []); + $limits = []; + $previous = 0; + foreach (self::LIMITS as $limit) { + $count = (int)\CIBlockElement::GetList([], $filter + ["<=CATALOG_PRICE_" . $groupId => $limit], []); + if ($count > $previous && $count < $total) { + $limits[] = $limit; + $previous = $count; + } + } + + return $limits; + } +} diff --git a/local/modules/jinove.vinoteca/lib/catalog/pricerange.php b/local/modules/jinove.vinoteca/lib/catalog/pricerange.php new file mode 100644 index 0000000..9b1e9d0 --- /dev/null +++ b/local/modules/jinove.vinoteca/lib/catalog/pricerange.php @@ -0,0 +1,48 @@ + self::collect($priceCode)); + } + + private static function collect(string $priceCode): string + { + if (!Loader::includeModule("catalog") || !Loader::includeModule("currency")) { + return ""; + } + $groupId = PricePresets::groupId($priceCode); + if ($groupId === 0) { + return ""; + } + $row = PriceTable::getList([ + "select" => ["MIN_PRICE", "MAX_PRICE"], + "filter" => ["=CATALOG_GROUP_ID" => $groupId, ">PRICE" => 0], + "runtime" => [ + new ExpressionField("MIN_PRICE", "MIN(%s)", "PRICE"), + new ExpressionField("MAX_PRICE", "MAX(%s)", "PRICE"), + ], + ])->fetch(); + if (!$row || $row["MIN_PRICE"] <= 0) { + return ""; + } + + return (int)round((float)$row["MIN_PRICE"]) . "-" . (int)round((float)$row["MAX_PRICE"]) . " " . CurrencyManager::getBaseCurrency(); + } +} diff --git a/local/modules/jinove.vinoteca/lib/catalog/prices.php b/local/modules/jinove.vinoteca/lib/catalog/prices.php new file mode 100644 index 0000000..8a54fb4 --- /dev/null +++ b/local/modules/jinove.vinoteca/lib/catalog/prices.php @@ -0,0 +1,35 @@ +getUserGroups(); + $prices = []; + foreach ($productIds as $productId) { + $optimal = \CCatalogProduct::GetOptimalPrice($productId, 1, $groups, "N", [], $siteId); + $price = $optimal["RESULT_PRICE"] ?? null; + if (!$price || (float)$price["DISCOUNT_PRICE"] <= 0) { + continue; + } + $prices[$productId] = [ + "price" => (float)$price["DISCOUNT_PRICE"], + "base" => max((float)$price["DISCOUNT_PRICE"], (float)$price["BASE_PRICE"]), + "currency" => (string)$price["CURRENCY"], + ]; + } + + return $prices; + } +} diff --git a/local/modules/jinove.vinoteca/lib/catalog/related.php b/local/modules/jinove.vinoteca/lib/catalog/related.php new file mode 100644 index 0000000..74b2f67 --- /dev/null +++ b/local/modules/jinove.vinoteca/lib/catalog/related.php @@ -0,0 +1,110 @@ + ["ID"], "filter" => ["=IBLOCK_ID" => $iblockId, "=CODE" => "RECOMMEND"]]); + if ($property === null) { + return []; + } + $linked = []; + $rows = ElementPropertyTable::getList([ + "select" => ["VALUE"], + "filter" => ["=IBLOCK_ELEMENT_ID" => $elementId, "=IBLOCK_PROPERTY_ID" => (int)$property["ID"]], + "order" => ["ID" => "ASC"], + ]); + while ($row = $rows->fetch()) { + $linked[] = (int)$row["VALUE"]; + } + $linked = array_values(array_filter(array_unique($linked))); + if (!$linked) { + return []; + } + $active = []; + $items = ElementTable::getList(["select" => ["ID"], "filter" => ["=ID" => $linked, "=IBLOCK_ID" => $iblockId, "=ACTIVE" => "Y"]]); + while ($item = $items->fetch()) { + $active[(int)$item["ID"]] = true; + } + + return array_values(array_filter($linked, fn(int $id): bool => isset($active[$id]))); + } + + public static function summaries(array $ids): array + { + $found = self::summariesById($ids); + + return array_values(array_filter(array_map(static fn(int $id): ?array => $found[$id] ?? null, $ids))); + } + + public static function summariesById(array $ids): array + { + $ids = array_values(array_unique(array_filter(array_map("intval", $ids)))); + if (!$ids) { + return []; + } + + return array_intersect_key(self::all(), array_flip($ids)); + } + + private static function all(): array + { + $iblockId = Config::iblockId("catalog"); + if ($iblockId <= 0 || !Loader::includeModule("iblock")) { + return []; + } + return (array)Cached::remember(self::CACHE_DIR, "summaries-" . $iblockId . "-" . SITE_DIR, self::CACHE_TTL, ["iblock_id_" . $iblockId], static fn(): array => self::collect($iblockId)); + } + + private static function collect(int $iblockId): array + { + $template = (string)(IblockTable::getRowById($iblockId)["DETAIL_PAGE_URL"] ?? ""); + $elements = ElementTable::getList([ + "select" => ["ID", "NAME", "CODE", "IBLOCK_SECTION_ID"], + "filter" => ["=IBLOCK_ID" => $iblockId, "=ACTIVE" => "Y"], + ])->fetchAll(); + $sectionIds = array_values(array_unique(array_filter(array_map(static fn(array $row): int => (int)$row["IBLOCK_SECTION_ID"], $elements)))); + $sectionCodes = []; + if ($sectionIds) { + $sections = SectionTable::getList(["select" => ["ID", "CODE"], "filter" => ["=ID" => $sectionIds]]); + while ($section = $sections->fetch()) { + $sectionCodes[(int)$section["ID"]] = (string)$section["CODE"]; + } + } + $found = []; + foreach ($elements as $row) { + $found[(int)$row["ID"]] = [ + "name" => (string)$row["NAME"], + "url" => (string)preg_replace('#/{2,}#', "/", strtr($template, [ + "#SITE_DIR#" => SITE_DIR, + "#SECTION_CODE#" => $sectionCodes[(int)$row["IBLOCK_SECTION_ID"]] ?? "", + "#ELEMENT_CODE#" => (string)$row["CODE"], + "#CODE#" => (string)$row["CODE"], + "#ID#" => (string)$row["ID"], + "#ELEMENT_ID#" => (string)$row["ID"], + ])), + ]; + } + + return $found; + } +} diff --git a/local/modules/jinove.vinoteca/lib/catalog/reviewstats.php b/local/modules/jinove.vinoteca/lib/catalog/reviewstats.php new file mode 100644 index 0000000..ce022cc --- /dev/null +++ b/local/modules/jinove.vinoteca/lib/catalog/reviewstats.php @@ -0,0 +1,150 @@ + ["ID"], + "filter" => ["=IBLOCK_TYPE_ID" => self::IBLOCK_TYPE, "=CODE" => $code], + ]); + self::$iblockIds[$code] = (int)($row["ID"] ?? 0); + } + + return self::$iblockIds[$code]; + } + + public static function onElementChange(array &$fields): void + { + $id = (int)($fields["ID"] ?? 0); + if ($id <= 0 || (int)($fields["IBLOCK_ID"] ?? 0) !== self::iblockId(self::REVIEWS_CODE)) { + return; + } + self::recalc(self::productOf($id)); + } + + public static function onBeforeDelete(int $id): void + { + $row = ElementTable::getRow(["select" => ["IBLOCK_ID"], "filter" => ["=ID" => $id]]); + if ((int)($row["IBLOCK_ID"] ?? 0) === self::iblockId(self::REVIEWS_CODE)) { + self::$deleting[$id] = self::productOf($id); + } + } + + public static function onAfterDelete(array $fields): void + { + $id = (int)($fields["ID"] ?? 0); + if (isset(self::$deleting[$id])) { + self::recalc(self::$deleting[$id]); + unset(self::$deleting[$id]); + } + } + + public static function summary(int $productId): ?array + { + $catalogId = self::iblockId(self::CATALOG_CODE); + if ($productId <= 0 || $catalogId <= 0) { + return null; + } + $values = []; + foreach (["REVIEW_COUNT", "REVIEW_RATING"] as $code) { + $property = PropertyTable::getRow(["select" => ["ID"], "filter" => ["=IBLOCK_ID" => $catalogId, "=CODE" => $code]]); + $row = $property === null ? null : ElementPropertyTable::getRow([ + "select" => ["VALUE"], + "filter" => ["=IBLOCK_ELEMENT_ID" => $productId, "=IBLOCK_PROPERTY_ID" => (int)$property["ID"]], + ]); + $values[$code] = $row === null ? 0.0 : (float)$row["VALUE"]; + } + + return ["count" => (int)$values["REVIEW_COUNT"], "avg" => round($values["REVIEW_RATING"], 1)]; + } + + public static function items(int $productId, int $limit = 50): array + { + $reviewsId = self::iblockId(self::REVIEWS_CODE); + if ($productId <= 0 || $reviewsId <= 0) { + return []; + } + $items = []; + $rows = \CIBlockElement::GetList( + ["ACTIVE_FROM" => "DESC", "ID" => "DESC"], + ["IBLOCK_ID" => $reviewsId, "ACTIVE" => "Y", "PROPERTY_PRODUCT" => $productId], + false, + ["nTopCount" => $limit], + ["ID", "PREVIEW_TEXT", "ACTIVE_FROM", "DATE_CREATE", "PROPERTY_AUTHOR", "PROPERTY_RATING"] + ); + while ($row = $rows->Fetch()) { + $rating = (int)$row["PROPERTY_RATING_VALUE"]; + $author = trim((string)$row["PROPERTY_AUTHOR_VALUE"]); + $text = trim((string)preg_replace('/\s+/u', " ", strip_tags((string)$row["PREVIEW_TEXT"]))); + if ($rating < 1 || $rating > 5 || $author === "" || $text === "") { + continue; + } + $items[] = [ + "author" => $author, + "rating" => $rating, + "text" => $text, + "date" => date("Y-m-d", MakeTimeStamp((string)($row["ACTIVE_FROM"] ?: $row["DATE_CREATE"]))), + ]; + } + + return $items; + } + + public static function recalc(int $productId): void + { + $catalogId = self::iblockId(self::CATALOG_CODE); + if ($productId <= 0 || $catalogId <= 0) { + return; + } + $sum = 0; + $count = 0; + $rows = \CIBlockElement::GetList( + [], + ["IBLOCK_ID" => self::iblockId(self::REVIEWS_CODE), "ACTIVE" => "Y", "PROPERTY_PRODUCT" => $productId], + false, + false, + ["ID", "PROPERTY_RATING"] + ); + while ($row = $rows->Fetch()) { + $rating = (int)$row["PROPERTY_RATING_VALUE"]; + if ($rating >= 1 && $rating <= 5) { + $sum += $rating; + $count++; + } + } + \CIBlockElement::SetPropertyValuesEx($productId, $catalogId, [ + "REVIEW_COUNT" => $count, + "REVIEW_RATING" => $count > 0 ? round($sum / $count, 1) : false, + ]); + \CIBlock::clearIblockTagCache($catalogId); + } + + private static function productOf(int $reviewId): int + { + $value = \CIBlockElement::GetProperty(self::iblockId(self::REVIEWS_CODE), $reviewId, [], ["CODE" => "PRODUCT"])->Fetch(); + + return (int)($value["VALUE"] ?? 0); + } +} diff --git a/local/modules/jinove.vinoteca/lib/catalog/searchmeta.php b/local/modules/jinove.vinoteca/lib/catalog/searchmeta.php new file mode 100644 index 0000000..3fa5a49 --- /dev/null +++ b/local/modules/jinove.vinoteca/lib/catalog/searchmeta.php @@ -0,0 +1,105 @@ + self::collect($catalogId)); + } + + private static function collect(int $catalogId): array + { + if ($catalogId <= 0 || !Loader::includeModule("iblock")) { + return []; + } + $propertyCodes = []; + $rows = PropertyTable::getList(["select" => ["ID", "CODE"], "filter" => ["=IBLOCK_ID" => $catalogId, "=CODE" => self::PROPERTIES]]); + while ($row = $rows->fetch()) { + $propertyCodes[(int)$row["ID"]] = (string)$row["CODE"]; + } + $enums = []; + if ($propertyCodes) { + $rows = PropertyEnumerationTable::getList(["select" => ["ID", "XML_ID", "VALUE"], "filter" => ["@PROPERTY_ID" => array_keys($propertyCodes)]]); + while ($row = $rows->fetch()) { + $enums[(int)$row["ID"]] = ["XML_ID" => (string)$row["XML_ID"], "VALUE" => (string)$row["VALUE"]]; + } + } + $parts = []; + if ($propertyCodes) { + $rows = ElementPropertyTable::getList([ + "select" => ["IBLOCK_ELEMENT_ID", "IBLOCK_PROPERTY_ID", "VALUE_ENUM"], + "filter" => ["@IBLOCK_PROPERTY_ID" => array_keys($propertyCodes), ">VALUE_ENUM" => 0], + ]); + while ($row = $rows->fetch()) { + $enum = $enums[(int)$row["VALUE_ENUM"]] ?? null; + if ($enum !== null) { + $code = $propertyCodes[(int)$row["IBLOCK_PROPERTY_ID"]]; + $parts[(int)$row["IBLOCK_ELEMENT_ID"]][$code] = EnumNames::name($code, $enum["XML_ID"], $enum["VALUE"]); + } + } + } + $brands = self::brands($catalogId); + $meta = []; + $rows = ElementTable::getList(["select" => ["ID", "NAME"], "filter" => ["=IBLOCK_ID" => $catalogId]]); + while ($row = $rows->fetch()) { + $id = (int)$row["ID"]; + $meta[$id] = [ + "NAME" => (string)$row["NAME"], + "META" => implode(", ", array_filter([$parts[$id]["REGION"] ?? "", $parts[$id]["COUNTRY"] ?? ""])), + "BRAND" => $brands[$id] ?? "", + ]; + } + + return $meta; + } + + private static function brands(int $catalogId): array + { + $property = PropertyTable::getRow(["select" => ["ID"], "filter" => ["=IBLOCK_ID" => $catalogId, "=CODE" => "BRAND"]]); + if ($property === null) { + return []; + } + $links = []; + $rows = ElementPropertyTable::getList([ + "select" => ["IBLOCK_ELEMENT_ID", "VALUE"], + "filter" => ["=IBLOCK_PROPERTY_ID" => (int)$property["ID"]], + ]); + while ($row = $rows->fetch()) { + if ((int)$row["VALUE"] > 0) { + $links[(int)$row["IBLOCK_ELEMENT_ID"]] = (int)$row["VALUE"]; + } + } + if (!$links) { + return []; + } + $names = []; + $rows = ElementTable::getList(["select" => ["ID", "NAME"], "filter" => ["=ID" => array_values(array_unique($links))]]); + while ($row = $rows->fetch()) { + $names[(int)$row["ID"]] = (string)$row["NAME"]; + } + + return array_filter(array_map(static fn(int $brandId): string => $names[$brandId] ?? "", $links)); + } +} diff --git a/local/modules/jinove.vinoteca/lib/catalog/sections.php b/local/modules/jinove.vinoteca/lib/catalog/sections.php new file mode 100644 index 0000000..af357c0 --- /dev/null +++ b/local/modules/jinove.vinoteca/lib/catalog/sections.php @@ -0,0 +1,89 @@ + $section) { + if (!$section["ACTIVE"] || $section["DEPTH_LEVEL"] !== 1) { + continue; + } + $links[] = [$section["NAME"], SITE_DIR . "catalog/" . $code . "/", [], [], ""]; + } + + return $links; + } + + public static function all(): array + { + $catalogId = Config::iblockId("catalog"); + $language = LANGUAGE_ID; + return (array)Cached::remember(self::CACHE_DIR, "sections-" . $catalogId . "-" . $language, self::CACHE_TTL, ["iblock_id_" . $catalogId], static fn(): array => self::collect($catalogId, $language)); + } + + private static function collect(int $catalogId, string $language): array + { + if (!Loader::includeModule("iblock")) { + return []; + } + $suffix = "_" . strtoupper($language); + $select = ["ID", "CODE", "NAME", "DESCRIPTION", "ACTIVE", "DEPTH_LEVEL"]; + if ($language !== self::BASE_LANGUAGE) { + foreach (self::FIELDS as $field) { + $select[] = "UF_" . $field . $suffix; + } + } + $sections = []; + $rows = \CIBlockSection::GetList(["SORT" => "ASC"], ["IBLOCK_ID" => $catalogId], false, $select); + while ($row = $rows->Fetch()) { + $seo = (new SectionValues($catalogId, (int)$row["ID"]))->getValues(); + $base = [ + "NAME" => (string)$row["NAME"], + "DESCRIPTION" => (string)$row["DESCRIPTION"], + "META_TITLE" => (string)($seo["SECTION_META_TITLE"] ?? ""), + "META_DESCRIPTION" => (string)($seo["SECTION_META_DESCRIPTION"] ?? ""), + "PAGE_TITLE" => (string)($seo["SECTION_PAGE_TITLE"] ?? ""), + ]; + if ($language !== self::BASE_LANGUAGE) { + foreach (self::FIELDS as $field) { + $value = trim((string)($row["UF_" . $field . $suffix] ?? "")); + if ($value !== "") { + $base[$field] = $value; + } + } + } + $sections[(string)$row["CODE"]] = [ + "ID" => (int)$row["ID"], + "ACTIVE" => $row["ACTIVE"] === "Y", + "DEPTH_LEVEL" => (int)$row["DEPTH_LEVEL"], + ] + $base; + } + + return $sections; + } +} diff --git a/local/modules/jinove.vinoteca/lib/catalog/wineschema.php b/local/modules/jinove.vinoteca/lib/catalog/wineschema.php new file mode 100644 index 0000000..c2f6d94 --- /dev/null +++ b/local/modules/jinove.vinoteca/lib/catalog/wineschema.php @@ -0,0 +1,151 @@ + (string)$in["host"] . "/#store"]; + $images = []; + foreach ((array)$in["images"] as $index => $image) { + $node = [ + "@type" => "ImageObject", + "@id" => $url . "#image-" . ($index + 1), + "url" => $image["src"], + "contentUrl" => $image["src"], + "caption" => $image["alt"], + "inLanguage" => $in["language"], + ]; + if ($image["width"] > 0 && $image["height"] > 0) { + $node["width"] = ["@type" => "QuantitativeValue", "value" => $image["width"], "unitCode" => "E37"]; + $node["height"] = ["@type" => "QuantitativeValue", "value" => $image["height"], "unitCode" => "E37"]; + } + $images[] = $node; + } + + $product = [ + "@type" => "Product", + "@id" => $url . "#product", + "name" => $in["name"], + "url" => $url, + ]; + if ($in["description"] !== "") { + $product["description"] = $in["description"]; + } + if ($images) { + $product["image"] = $images; + } + if ($in["sku"] !== "") { + $product["sku"] = $in["sku"]; + } + if ($in["category"] !== "") { + $product["category"] = $in["category"]; + } + if ($in["country"] !== "") { + $product["countryOfOrigin"] = ["@type" => "Country", "name" => $in["country"]]; + } + if ($in["vintage"] !== "") { + $product["productionDate"] = $in["vintage"]; + } + if (!empty($in["brand"]["name"])) { + $brand = ["@type" => "Brand", "name" => $in["brand"]["name"]]; + if ($in["brand"]["url"] !== "") { + $brand["@id"] = $in["brand"]["url"] . "#brand"; + $brand["url"] = $in["brand"]["url"]; + } + $product["brand"] = $brand; + } + $properties = []; + foreach ((array)$in["properties"] as $row) { + $node = ["@type" => "PropertyValue", "name" => $row["name"], "value" => $row["value"]]; + if (!empty($row["unitCode"])) { + $node["unitCode"] = $row["unitCode"]; + } + $properties[] = $node; + } + if ($properties) { + $product["additionalProperty"] = $properties; + } + if ($in["price"] > 0 && $in["currency"] !== "") { + $offer = [ + "@type" => "Offer", + "@id" => $url . "#offer", + "url" => $url, + "price" => $in["price"], + "priceCurrency" => $in["currency"], + "availability" => $in["canBuy"] ? "https://schema.org/InStock" : "https://schema.org/OutOfStock", + "itemCondition" => "https://schema.org/NewCondition", + "seller" => $store, + ]; + if ($in["listPrice"] > $in["price"]) { + $offer["priceSpecification"] = [ + "@type" => "UnitPriceSpecification", + "priceType" => "https://schema.org/ListPrice", + "price" => $in["listPrice"], + "priceCurrency" => $in["currency"], + ]; + } + $product["offers"] = $offer; + } + if ($in["reviewCount"] > 0 && $in["reviewRating"] > 0) { + $product["aggregateRating"] = [ + "@type" => "AggregateRating", + "ratingValue" => $in["reviewRating"], + "reviewCount" => $in["reviewCount"], + "bestRating" => 5, + "worstRating" => 1, + ]; + } + $reviews = []; + foreach ((array)$in["reviews"] as $review) { + $reviews[] = [ + "@type" => "Review", + "author" => ["@type" => "Person", "name" => $review["author"]], + "datePublished" => $review["date"], + "reviewRating" => ["@type" => "Rating", "ratingValue" => $review["rating"], "bestRating" => 5, "worstRating" => 1], + "reviewBody" => $review["text"], + "inLanguage" => $review["language"], + ]; + } + if ($reviews) { + $product["review"] = $reviews; + } + $related = []; + foreach ((array)$in["related"] as $item) { + $related[] = ["@type" => "Product", "@id" => $item["url"] . "#product", "name" => $item["name"], "url" => $item["url"]]; + } + if ($related) { + $product["isRelatedTo"] = $related; + } + + $page = [ + "@type" => "ItemPage", + "@id" => $url . "#webpage", + "url" => $url, + "name" => $in["name"], + "description" => $in["pageDescription"], + "inLanguage" => $in["language"], + "mainEntity" => ["@id" => $url . "#product"], + "datePublished" => $in["created"], + "dateModified" => $in["modified"], + ]; + if ($images) { + $page["primaryImageOfPage"] = ["@id" => $images[0]["@id"]]; + } + $translations = []; + foreach ((array)$in["translations"] as $language => $translationUrl) { + $translations[] = ["@type" => "ItemPage", "@id" => $translationUrl . "#webpage", "url" => $translationUrl, "inLanguage" => $language]; + } + if ($translations) { + $page["workTranslation"] = $translations; + } + + return ["@context" => self::CONTEXT, "@graph" => [$page, $product]]; + } +} diff --git a/local/modules/jinove.vinoteca/lib/catalog/winestats.php b/local/modules/jinove.vinoteca/lib/catalog/winestats.php new file mode 100644 index 0000000..368234c --- /dev/null +++ b/local/modules/jinove.vinoteca/lib/catalog/winestats.php @@ -0,0 +1,75 @@ +activeCount !== null) { + return $this->activeCount; + } + + $cache = Cache::createInstance(); + $cacheId = "active-count-" . $this->iblockType . "-" . $this->iblockCode; + if ($cache->initCache(self::CACHE_TTL, $cacheId, self::CACHE_DIR)) { + return $this->activeCount = (int)$cache->getVars()["count"]; + } + + $cache->startDataCache(); + $taggedCache = Application::getInstance()->getTaggedCache(); + $taggedCache->startTagCache(self::CACHE_DIR); + try { + $iblockId = $this->getIblockId(); + $count = ElementTable::getCount([ + "=IBLOCK_ID" => $iblockId, + "=ACTIVE" => "Y", + ]); + $taggedCache->registerTag("iblock_id_" . $iblockId); + } catch (\Throwable $e) { + $taggedCache->abortTagCache(); + $cache->abortDataCache(); + throw $e; + } + $taggedCache->endTagCache(); + $cache->endDataCache(["count" => $count]); + + return $this->activeCount = $count; + } + + private function getIblockId(): int + { + if (!Loader::includeModule("iblock")) { + throw new SystemException("Module iblock is not installed"); + } + $iblock = IblockTable::getRow([ + "select" => ["ID"], + "filter" => ["=IBLOCK_TYPE_ID" => $this->iblockType, "=CODE" => $this->iblockCode], + ]); + if ($iblock === null) { + throw new SystemException("Iblock " . $this->iblockType . "/" . $this->iblockCode . " not found"); + } + + return (int)$iblock["ID"]; + } +} diff --git a/local/modules/jinove.vinoteca/lib/checkout.php b/local/modules/jinove.vinoteca/lib/checkout.php new file mode 100644 index 0000000..a0524a8 --- /dev/null +++ b/local/modules/jinove.vinoteca/lib/checkout.php @@ -0,0 +1,351 @@ + ["=ACTIVE" => "Y", "=ENTITY_REGISTRY_TYPE" => "ORDER"], "order" => ["SORT" => "ASC", "ID" => "ASC"]]); + while ($row = $rows->fetch()) { + $code = self::methodCode((string)$row["ACTION_FILE"]); + if ($code === "") { + continue; + } + $methods[] = [ + "id" => (int)$row["ID"], + "code" => $code, + "name" => (string)Loc::getMessage("VINO_PAY_" . strtoupper($code)), + "hint" => (string)Loc::getMessage("VINO_PAY_" . strtoupper($code) . "_HINT"), + ]; + } + + return $methods; + } + + public static function create(BasketBase $basket, array $contacts, int $paySystemId, string $consentProof): array + { + $methods = array_column(self::methods(), null, "id"); + if (!isset($methods[$paySystemId])) { + return ["error" => "pay"]; + } + $person = PersonTypeTable::getRow(["filter" => ["=CODE" => self::PERSON_CODE, "=ACTIVE" => "Y"], "select" => ["ID"]]); + $delivery = \Bitrix\Sale\Delivery\Services\Table::getRow(["filter" => ["=CODE" => self::DELIVERY_CODE, "=ACTIVE" => "Y"], "select" => ["ID"]]); + if ($person === null || $delivery === null) { + return ["error" => "shop"]; + } + $basket->refresh(RefreshFactory::create(RefreshFactory::TYPE_FULL)); + $items = $basket->getOrderableItems(); + if ($items->isEmpty()) { + return ["error" => "empty"]; + } + $siteId = Config::basketSiteId(); + $userId = (int)CurrentUser::get()->getId(); + $order = Order::create($siteId, $userId > 0 ? $userId : (int)\CSaleUser::GetAnonymousUserID()); + $order->setPersonTypeId((int)$person["ID"]); + $order->setBasket($items); + + $shipments = $order->getShipmentCollection(); + $shipment = $shipments->createItem(DeliveryManager::getObjectById((int)$delivery["ID"])); + $shipment->setField("CURRENCY", $order->getCurrency()); + $shipmentItems = $shipment->getShipmentItemCollection(); + foreach ($order->getBasket() as $basketItem) { + $shipmentItems->createItem($basketItem)->setQuantity($basketItem->getQuantity()); + } + $shipments->calculateDelivery(); + + $properties = $order->getPropertyCollection(); + $proof = $properties->getItemByOrderPropertyCode("CONSENT_PROOF"); + if ($proof === null) { + return ["error" => "shop"]; + } + $proof->setValue($consentProof); + foreach (self::PROPERTIES as $code) { + $property = $properties->getItemByOrderPropertyCode($code); + if ($property !== null) { + $property->setValue((string)($contacts[strtolower($code)] ?? "")); + } + } + $comment = (string)($contacts["comment"] ?? ""); + if ($comment !== "") { + $order->setField("USER_DESCRIPTION", $comment); + } + + $payment = $order->getPaymentCollection()->createItem(PaySystemManager::getObjectById($paySystemId)); + $order->doFinalAction(true); + $payment->setField("SUM", $order->getPrice()); + $payment->setField("CURRENCY", $order->getCurrency()); + $result = $order->save(); + if (!$result->isSuccess()) { + return ["error" => "save", "messages" => $result->getErrorMessages()]; + } + + return [ + "order" => $order, + "payment" => $order->getPaymentCollection()->current(), + "method" => $methods[$paySystemId], + ]; + } + + public static function token(Order $order): string + { + return (new Signer())->getSignature($order->getId() . ":" . $order->getField("ACCOUNT_NUMBER"), self::TOKEN_SALT); + } + + public static function find(int $orderId, string $hash): ?Order + { + if ($orderId <= 0 || $hash === "" || !Loader::includeModule("sale")) { + return null; + } + $order = Order::load($orderId); + if ($order === null || !hash_equals(self::token($order), $hash)) { + return null; + } + + return $order; + } + + public static function doneUrl(Order $order, string $dir, array $extra = []): string + { + return Config::host() . $dir . "personal/order/done/?" . http_build_query(["id" => $order->getId(), "hash" => self::token($order)] + $extra); + } + + public static function startPayment(Order $order, string $dir): array + { + $payment = $order->getPaymentCollection()->current(); + if ($payment === null || $payment->isPaid()) { + return ["url" => ""]; + } + $service = $payment->getPaySystem(); + $code = $service !== null ? self::methodCode((string)$service->getField("ACTION_FILE")) : ""; + if ($code === "" || $code === "cash") { + return ["url" => ""]; + } + if ((string)$payment->getField("PS_INVOICE_ID") !== "" && self::finishPayment($order, [])) { + return ["url" => self::doneUrl($order, $dir)]; + } + $order = Order::load($order->getId()); + $payment = $order->getPaymentCollection()->current(); + $service = $payment->getPaySystem(); + $returnUrl = self::doneUrl($order, $dir, ["payment" => $payment->getId()]); + if ($code === "yookassa") { + $service->getContext()->setUrl($returnUrl); + } + $request = new HttpRequest( + Context::getCurrent()->getServer(), + ["return_url" => $returnUrl, "cancel_url" => self::doneUrl($order, $dir, ["payment" => $payment->getId(), "cancel" => "Y"])], + [], + [], + [] + ); + $result = $service->initiatePay($payment, $request, BaseServiceHandler::STRING); + $widget = $result->getData()["widget"] ?? null; + if (!$result->isSuccess() || ($result->getPaymentUrl() === "" && !is_array($widget))) { + return ["url" => ""]; + } + if (!$order->save()->isSuccess()) { + return ["url" => ""]; + } + + return ["url" => $result->getPaymentUrl(), "widget" => is_array($widget) ? $widget : null]; + } + + public static function finishPayment(Order $order, array $query): bool + { + $connection = Application::getConnection(); + $key = "vino_pay_" . $order->getId(); + if (!$connection->lock($key, self::LOCK_SECONDS)) { + return false; + } + try { + $fresh = Order::load($order->getId()); + + return $fresh !== null && self::verify($fresh, $query); + } finally { + $connection->unlock($key); + } + } + + public static function methodOf(Order $order): string + { + $payment = $order->getPaymentCollection()->current(); + $service = $payment !== null ? $payment->getPaySystem() : null; + + return $service !== null ? self::methodCode((string)$service->getField("ACTION_FILE")) : ""; + } + + public static function cancelUnpaid(): string + { + if (!Loader::includeModule("sale")) { + return __METHOD__ . "();"; + } + $online = []; + foreach (self::methods() as $method) { + if ($method["code"] !== "cash") { + $online[] = $method["id"]; + } + } + if (!$online) { + return __METHOD__ . "();"; + } + $border = new DateTime(); + $border->add("-" . self::UNPAID_HOURS . " hours"); + $rows = PaymentTable::getList([ + "filter" => ["=PAID" => "N", "@PAY_SYSTEM_ID" => $online, "=ORDER.CANCELED" => "N", " $border], + "select" => ["ORDER_ID"], + "order" => ["ID" => "ASC"], + "limit" => 200, + ]); + while ($row = $rows->fetch()) { + $order = Order::load((int)$row["ORDER_ID"]); + if ($order === null || $order->isPaid() || $order->isCanceled()) { + continue; + } + $payment = $order->getPaymentCollection()->current(); + if ($payment !== null && (string)$payment->getField("PS_INVOICE_ID") !== "" && self::finishPayment($order, [])) { + continue; + } + $order = Order::load($order->getId()); + $order->setField("CANCELED", "Y"); + $order->setField("REASON_CANCELED", self::UNPAID_REASON); + $order->save(); + } + + return __METHOD__ . "();"; + } + + public static function consentProof(string $page): string + { + return "consent=Y; version=" . Consent::VERSION . "; policy=" . Consent::POLICY_VERSION . "; page=" . $page . "; at=" . new DateTime(); + } + + public static function dir(string $requested): string + { + foreach (Config::languages() as $language) { + if ((string)($language["dir"] ?? "") === $requested) { + return $requested; + } + } + + return "/"; + } + + private static function verify(Order $order, array $query): bool + { + $payment = $order->getPaymentCollection()->current(); + if ($payment === null) { + return false; + } + if ($payment->isPaid()) { + return true; + } + $service = $payment->getPaySystem(); + $code = $service !== null ? self::methodCode((string)$service->getField("ACTION_FILE")) : ""; + if ($code === "yookassa") { + return self::finishYookassa($order, $payment, $service); + } + $token = (string)($query["token"] ?? ""); + if ($code === "paypal" && $token === "") { + $token = (string)$payment->getField("PS_INVOICE_ID"); + } + if ($code !== "halyk" && ($code !== "paypal" || $token === "")) { + return false; + } + $request = new HttpRequest(Context::getCurrent()->getServer(), ["payment" => $payment->getId(), "token" => $token], [], [], []); + $result = $service->processRequest($request); + + return $result->isSuccess() && Order::load($order->getId())->getPaymentCollection()->current()->isPaid(); + } + + private static function finishYookassa(Order $order, Payment $payment, Service $service): bool + { + $invoice = (string)$payment->getField("PS_INVOICE_ID"); + if ($invoice === "") { + return false; + } + $consumer = "PAYSYSTEM_" . (int)$service->getField("ID"); + $client = new HttpClient(["socketTimeout" => 10, "streamTimeout" => 10]); + $client->setHeader("Authorization", "Basic " . base64_encode(trim((string)BusinessValue::get("YANDEX_CHECKOUT_SHOP_ID", $consumer)) . ":" . trim((string)BusinessValue::get("YANDEX_CHECKOUT_SECRET_KEY", $consumer)))); + $body = $client->get(self::YOOKASSA_API . rawurlencode($invoice)); + if ($body === false || $client->getStatus() !== 200) { + Logger::addError(__METHOD__ . ": status request failed, HTTP " . $client->getStatus()); + + return false; + } + try { + $data = Json::decode((string)$body); + } catch (\Throwable $exception) { + return false; + } + $amount = (float)($data["amount"]["value"] ?? 0); + $currency = (string)($data["amount"]["currency"] ?? ""); + if (($data["status"] ?? "") !== "succeeded" || empty($data["paid"]) || $currency !== $payment->getCurrency() || abs($amount - (float)$payment->getSum()) > 0.01) { + return false; + } + $paid = $payment->setPaid("Y"); + if (!$paid->isSuccess()) { + return false; + } + $payment->setFields(["PS_STATUS" => "Y", "PS_STATUS_CODE" => "succeeded", "PS_SUM" => $amount, "PS_CURRENCY" => $currency, "PS_RESPONSE_DATE" => new DateTime()]); + + return $order->save()->isSuccess(); + } + + private static function methodCode(string $action): string + { + if ($action === self::PAYPAL_ACTION) { + return "paypal"; + } + if ($action === self::YOOKASSA_ACTION) { + return "yookassa"; + } + if ($action === self::HALYK_ACTION) { + return "halyk"; + } + + return $action === "cashondelivery" ? "cash" : ""; + } +} diff --git a/local/modules/jinove.vinoteca/lib/config.php b/local/modules/jinove.vinoteca/lib/config.php new file mode 100644 index 0000000..4551c34 --- /dev/null +++ b/local/modules/jinove.vinoteca/lib/config.php @@ -0,0 +1,53 @@ +get($name); + } +} diff --git a/local/modules/jinove.vinoteca/lib/consent.php b/local/modules/jinove.vinoteca/lib/consent.php new file mode 100644 index 0000000..f4d7b37 --- /dev/null +++ b/local/modules/jinove.vinoteca/lib/consent.php @@ -0,0 +1,18 @@ +getTimestamp() : 0; + } +} diff --git a/local/modules/jinove.vinoteca/lib/controller/auth.php b/local/modules/jinove.vinoteca/lib/controller/auth.php new file mode 100644 index 0000000..25f5401 --- /dev/null +++ b/local/modules/jinove.vinoteca/lib/controller/auth.php @@ -0,0 +1,82 @@ + [ + "prefilters" => [new HttpMethod([HttpMethod::METHOD_POST]), new Csrf(), new FormGuard(FormGuard::TIMING_ELAPSED)], + ], + ]; + } + + public function loginAction( + string $email, + string $password, + string $remember = "", + string $consent = "", + string $back = "", + string $lang = "en", + string $website = "", + int $elapsed = 0, + string $altcha = "" + ): ?array { + $lang = Redirect::language($lang); + if ($website !== "") { + return ["ok" => true, "redirect" => Redirect::home($lang)]; + } + $session = Application::getInstance()->getSession(); + if ((int)($session->get("vino_login_block") ?? 0) > time()) { + $this->addError(new Error("Too many attempts", "too_often")); + + return null; + } + $email = mb_strtolower(trim($email)); + if ($consent !== "1" || !check_email($email) || $password === "" || mb_strlen($password) > 200) { + $this->addError(new Error("Invalid credentials", "invalid")); + + return null; + } + $user = UserTable::getRow([ + "select" => ["LOGIN"], + "filter" => ["=EMAIL" => $email, "=ACTIVE" => "Y"], + ]); + $logged = false; + if ($user !== null) { + global $USER; + $logged = $USER->Login((string)$user["LOGIN"], $password, $remember === "1" ? "Y" : "N") === true; + } + if (!$logged) { + $fails = (int)($session->get("vino_login_fails") ?? 0) + 1; + if ($fails >= self::MAX_FAILS) { + $session->set("vino_login_block", time() + self::BLOCK_SECONDS); + $fails = 0; + } + $session->set("vino_login_fails", $fails); + $this->addError(new Error("Invalid credentials", "invalid")); + + return null; + } + $session->remove("vino_login_fails"); + $session->remove("vino_login_block"); + + return ["ok" => true, "redirect" => Redirect::back($back, $lang)]; + } +} diff --git a/local/modules/jinove.vinoteca/lib/controller/basket.php b/local/modules/jinove.vinoteca/lib/controller/basket.php new file mode 100644 index 0000000..bc63a6d --- /dev/null +++ b/local/modules/jinove.vinoteca/lib/controller/basket.php @@ -0,0 +1,168 @@ + [new HttpMethod([HttpMethod::METHOD_GET])]]; + $write = ["prefilters" => [new HttpMethod([HttpMethod::METHOD_POST]), new Csrf()]]; + + return [ + "state" => $read, + "cart" => $read, + "set" => $write, + "update" => $write, + "clear" => $write, + "coupon" => $write, + "couponRemove" => $write, + "addShared" => $write, + ]; + } + + public function addSharedAction(string $code): ?array + { + $items = Cart::parseShare(trim($code)); + if (!$items) { + $this->addError(new Error("Wrong share code", "share")); + + return null; + } + $basket = $this->loadBasket(); + if ($basket === null) { + return null; + } + $ok = Cart::addMany($basket, $items); + $basket = $this->loadBasket(); + + return $basket === null ? null : ["ok" => $ok] + Cart::state($basket); + } + + public function stateAction(): ?array + { + $basket = $this->loadBasket(); + + return $basket === null ? null : ["ok" => true] + Cart::state($basket); + } + + public function setAction(int $id, int $qty): ?array + { + $basket = $this->loadBasket(); + if ($basket === null || !$this->validId($id)) { + return null; + } + $ok = Cart::setQuantity($basket, $id, $qty); + $basket = $this->loadBasket(); + + return $basket === null ? null : ["ok" => $ok] + Cart::state($basket); + } + + public function cartAction(): ?array + { + $basket = $this->loadBasket(); + + return $basket === null ? null : $this->full($basket, true, true); + } + + public function updateAction(int $id, int $qty): ?array + { + $basket = $this->loadBasket(); + if ($basket === null || !$this->validId($id)) { + return null; + } + $ok = Cart::setQuantity($basket, $id, $qty); + $basket = $this->loadBasket(); + + return $basket === null ? null : $this->full($basket, $ok); + } + + public function clearAction(): ?array + { + $basket = $this->loadBasket(); + if ($basket === null) { + return null; + } + $ok = Cart::clear($basket); + $basket = $this->loadBasket(); + + return $basket === null ? null : $this->full($basket, $ok); + } + + public function couponAction(string $code): ?array + { + $code = trim($code); + if ($code === "" || mb_strlen($code) > self::COUPON_MAX_LENGTH) { + $this->addError(new Error("Wrong coupon", "coupon")); + + return null; + } + $basket = $this->loadBasket(); + if ($basket === null) { + return null; + } + if (!Cart::addCoupon($code)) { + Cart::removeCoupon($code); + $this->addError(new Error("Coupon is not applicable", "coupon")); + + return null; + } + $result = $this->full($basket, true); + foreach ($result["cart"]["coupons"] as $coupon) { + if (mb_strtolower($coupon["code"]) === mb_strtolower($code) && $coupon["applied"]) { + return $result; + } + } + Cart::removeCoupon($code); + $this->addError(new Error("Coupon is not applicable", "coupon")); + + return null; + } + + public function couponRemoveAction(string $code): ?array + { + $basket = $this->loadBasket(); + if ($basket === null) { + return null; + } + Cart::removeCoupon(trim($code)); + + return $this->full($basket, true); + } + + private function full(BasketBase $basket, bool $ok, bool $refresh = false): array + { + return ["ok" => $ok, "cart" => Cart::view($basket, $refresh), "state" => Cart::state($basket)]; + } + + private function loadBasket(): ?BasketBase + { + $basket = Cart::load(); + if ($basket === null) { + $this->addError(new Error("Modules sale and catalog are required")); + } + + return $basket; + } + + private function validId(int $id): bool + { + if ($id > 0) { + return true; + } + $this->addError(new Error("Wrong product id")); + + return false; + } +} diff --git a/local/modules/jinove.vinoteca/lib/controller/catalog.php b/local/modules/jinove.vinoteca/lib/controller/catalog.php new file mode 100644 index 0000000..19e2247 --- /dev/null +++ b/local/modules/jinove.vinoteca/lib/controller/catalog.php @@ -0,0 +1,94 @@ + [ + "prefilters" => [new HttpMethod([HttpMethod::METHOD_GET])], + ], + "filter" => [ + "prefilters" => [new HttpMethod([HttpMethod::METHOD_GET])], + ], + ]; + } + + public function listingAction(string $path): ?Component + { + $route = Listing::parsePath($path); + if ($route === null) { + $this->addError(new Error("Wrong path")); + + return null; + } + if (!Listing::filterPathIsValid($route["SECTION_CODE"], $route["FILTER_PATH"])) { + $this->addError(new Error("Wrong filter")); + + return null; + } + + return new Component( + "jinove:catalog.listing", + "", + [ + "SECTION_CODE" => $route["SECTION_CODE"], + "FILTER_PATH" => $route["FILTER_PATH"], + "AJAX" => "Y", + ], + [], + static function (): array { + global $APPLICATION; + + return ["title" => (string)($APPLICATION->GetPageProperty("title") ?: $APPLICATION->GetTitle())]; + } + ); + } + + public function filterAction(string $section): ?array + { + $route = Listing::parsePath(Listing::sectionPath($section)); + if ($route === null) { + $this->addError(new Error("Wrong section")); + + return null; + } + + global $APPLICATION; + ob_start(); + $result = $APPLICATION->IncludeComponent( + "bitrix:catalog.smart.filter", + "", + Listing::filterParams($route["SECTION_CODE"], ""), + null, + [], + true + ); + ob_end_clean(); + + $disabled = []; + foreach ((array)($result["ITEMS"] ?? []) as $item) { + if (!empty($item["PRICE"])) { + continue; + } + foreach ((array)($item["VALUES"] ?? []) as $value) { + $disabled[$value["CONTROL_NAME"]] = !empty($value["DISABLED"]); + } + } + + return [ + "url" => (string)($result["JS_FILTER_PARAMS"]["SEF_SET_FILTER_URL"] ?? Listing::sectionPath($route["SECTION_CODE"])), + "disabled" => $disabled, + ]; + } +} diff --git a/local/modules/jinove.vinoteca/lib/controller/compare.php b/local/modules/jinove.vinoteca/lib/controller/compare.php new file mode 100644 index 0000000..0108c0d --- /dev/null +++ b/local/modules/jinove.vinoteca/lib/controller/compare.php @@ -0,0 +1,118 @@ + [ + "prefilters" => [new HttpMethod([HttpMethod::METHOD_GET])], + ], + "set" => [ + "prefilters" => [new HttpMethod([HttpMethod::METHOD_POST]), new Csrf()], + ], + "clear" => [ + "prefilters" => [new HttpMethod([HttpMethod::METHOD_POST]), new Csrf()], + ], + ]; + } + + public function stateAction(): array + { + return $this->describe(Comparison::prune(), false); + } + + public function clearAction(): array + { + Comparison::write([]); + + return $this->describe([], false); + } + + public function setAction(int $id, string $on): ?array + { + $items = Comparison::read(); + if ($on !== "Y") { + unset($items[$id]); + Comparison::write($items); + + return $this->describe($items, false); + } + if (isset($items[$id])) { + return $this->describe($items, false); + } + if (count($items) >= Comparison::MAX) { + return $this->describe($items, true); + } + + $item = $this->loadItem($id); + if ($item === null) { + $this->addError(new Error("Wrong product id")); + + return null; + } + $items[$id] = $item; + Comparison::write($items); + + return $this->describe($items, false); + } + + private function describe(array $items, bool $full): array + { + return ["items" => array_map("intval", array_keys($items)), "full" => $full]; + } + + private function loadItem(int $id): ?array + { + if ($id <= 0 || !Loader::includeModule("iblock")) { + return null; + } + $element = ElementTable::getRow([ + "select" => ["ID", "IBLOCK_ID", "IBLOCK_SECTION_ID", "NAME", "CODE", "SECTION_CODE" => "IBLOCK_SECTION.CODE", "DETAIL_PAGE_URL" => "IBLOCK.DETAIL_PAGE_URL"], + "filter" => ["=ID" => $id, "=IBLOCK_ID" => Config::iblockId("catalog"), "=ACTIVE" => "Y"], + ]); + if ($element === null) { + return null; + } + $url = \CIBlock::ReplaceDetailUrl((string)$element["DETAIL_PAGE_URL"], [ + "ID" => $element["ID"], + "CODE" => $element["CODE"], + "IBLOCK_ID" => $element["IBLOCK_ID"], + "IBLOCK_SECTION_ID" => $element["IBLOCK_SECTION_ID"], + "SECTION_CODE" => $element["SECTION_CODE"], + ], false, "E"); + $sections = array_map("intval", array_column(SectionElementTable::getList([ + "select" => ["IBLOCK_SECTION_ID"], + "filter" => ["=IBLOCK_ELEMENT_ID" => $id, "=ADDITIONAL_PROPERTY_ID" => null], + ])->fetchAll(), "IBLOCK_SECTION_ID")); + + return [ + "ID" => (int)$element["ID"], + "~ID" => (int)$element["ID"], + "IBLOCK_ID" => (int)$element["IBLOCK_ID"], + "~IBLOCK_ID" => (int)$element["IBLOCK_ID"], + "IBLOCK_SECTION_ID" => (int)$element["IBLOCK_SECTION_ID"], + "~IBLOCK_SECTION_ID" => (int)$element["IBLOCK_SECTION_ID"], + "NAME" => htmlspecialcharsbx($element["NAME"]), + "~NAME" => $element["NAME"], + "DETAIL_PAGE_URL" => htmlspecialcharsbx($url), + "~DETAIL_PAGE_URL" => $url, + "SECTIONS_LIST" => array_combine($sections, $sections), + "PARENT_ID" => (int)$element["ID"], + ]; + } +} diff --git a/local/modules/jinove.vinoteca/lib/controller/favorite.php b/local/modules/jinove.vinoteca/lib/controller/favorite.php new file mode 100644 index 0000000..cff6a90 --- /dev/null +++ b/local/modules/jinove.vinoteca/lib/controller/favorite.php @@ -0,0 +1,94 @@ + [ + "prefilters" => [new HttpMethod([HttpMethod::METHOD_GET])], + ], + "set" => [ + "prefilters" => [new HttpMethod([HttpMethod::METHOD_POST]), new Csrf()], + ], + ]; + } + + public function stateAction(): ?array + { + if (!$this->loadModules()) { + return null; + } + + return ["items" => FavoriteTable::productIds((int)Fuser::getId(true))]; + } + + public function setAction(int $id, string $on): ?array + { + if (!$this->loadModules()) { + return null; + } + if ($on === "Y" && !$this->isProduct($id)) { + $this->addError(new Error("Wrong product id")); + + return null; + } + + $fuserId = (int)Fuser::getId(); + $row = FavoriteTable::getRow([ + "select" => ["ID"], + "filter" => ["=FUSER_ID" => $fuserId, "=PRODUCT_ID" => $id], + ]); + $result = null; + if ($on === "Y" && !$row) { + try { + $result = FavoriteTable::add(["FUSER_ID" => $fuserId, "PRODUCT_ID" => $id]); + } catch (SqlQueryException $exception) { + $result = null; + } + } elseif ($on !== "Y" && $row) { + $result = FavoriteTable::delete($row["ID"]); + } + if ($result !== null && !$result->isSuccess()) { + $this->addErrors($result->getErrors()); + + return null; + } + + return ["items" => FavoriteTable::productIds($fuserId)]; + } + + private function loadModules(): bool + { + if (!Loader::includeModule("sale") || !Loader::includeModule("iblock")) { + $this->addError(new Error("Modules sale and iblock are required")); + + return false; + } + + return true; + } + + private function isProduct(int $id): bool + { + return $id > 0 && ElementTable::getCount([ + "=ID" => $id, + "=IBLOCK_ID" => VINO_CATALOG_IBLOCK, + "=ACTIVE" => "Y", + ]) > 0; + } +} diff --git a/local/modules/jinove.vinoteca/lib/controller/filter/formguard.php b/local/modules/jinove.vinoteca/lib/controller/filter/formguard.php new file mode 100644 index 0000000..d8e6c60 --- /dev/null +++ b/local/modules/jinove.vinoteca/lib/controller/filter/formguard.php @@ -0,0 +1,66 @@ +getAction()->getArguments(); + } catch (\Throwable) { + return null; + } + if ((string)($arguments["website"] ?? "") !== "") { + return null; + } + if ($this->timing === self::TIMING_STARTED && self::startedTooEarly((int)($arguments["started"] ?? 0), $this->minFillMs)) { + return null; + } + if ($this->timing === self::TIMING_ELAPSED && (int)($arguments["elapsed"] ?? 0) < $this->minFillMs) { + return $this->reject("Too fast", "retry"); + } + if (!Origin::allowed($this->getAction()->getController()->getRequest())) { + return $this->reject("Wrong origin", "origin"); + } + if ($this->altcha && !Altcha::verify((string)($arguments["altcha"] ?? ""))) { + return $this->reject("Verification failed", "altcha"); + } + + return null; + } + + private function reject(string $message, string $code): EventResult + { + $this->addError(new Error($message, $code)); + + return new EventResult(EventResult::ERROR, null, null, $this); + } +} diff --git a/local/modules/jinove.vinoteca/lib/controller/lead.php b/local/modules/jinove.vinoteca/lib/controller/lead.php new file mode 100644 index 0000000..f25ca12 --- /dev/null +++ b/local/modules/jinove.vinoteca/lib/controller/lead.php @@ -0,0 +1,208 @@ + [ + "prefilters" => [new HttpMethod([HttpMethod::METHOD_GET])], + ], + "question" => [ + "prefilters" => [new HttpMethod([HttpMethod::METHOD_POST]), new Csrf(), new FormGuard()], + ], + "subscribe" => [ + "prefilters" => [new HttpMethod([HttpMethod::METHOD_POST]), new Csrf(), new FormGuard()], + ], + ]; + } + + public function challengeAction(): ?Json + { + $challenge = Altcha::challenge(); + if ($challenge === null) { + $this->addError(new Error("Challenge is not available", "altcha")); + + return null; + } + $response = new Json($challenge); + $response->addHeader("Cache-Control", "no-store"); + + return $response; + } + + public function questionAction(string $name, string $phone, string $message, string $consent = "", string $website = "", string $altcha = "", string $page = ""): ?array + { + if ($website !== "") { + return ["ok" => true]; + } + $name = trim((string)preg_replace('/\s+/u', " ", $name)); + $message = trim($message); + $phone = Phone::format($phone); + if ($consent === "" || $name === "" || $message === "" || $phone === "" || mb_strlen($name) > 100 || mb_strlen($message) > 2000) { + $this->addError(new Error("Invalid fields", "fields")); + + return null; + } + $pageUrl = $this->pageUrl($page); + $consentUrl = $this->siteUrl() . "consent/"; + $sentAt = (string)new DateTime(); + $leadId = $this->save(self::QUESTIONS_CODE, $name . ", " . $phone, $message, [ + "PERSON_NAME" => $name, + "PHONE" => $phone, + "LANG" => LANGUAGE_ID, + "PAGE" => $pageUrl, + "CONSENT" => "Y", + "CONSENT_VERSION" => Consent::VERSION, + "CONSENT_URL" => $consentUrl, + "SENT_AT" => $sentAt, + ], $sentAt); + if ($leadId <= 0) { + $this->addError(new Error("Save failed", "save")); + + return null; + } + Event::send([ + "EVENT_NAME" => "VINO_SOMMELIER_QUESTION", + "LID" => SITE_ID, + "C_FIELDS" => [ + "LEAD_ID" => $leadId, + "NAME" => $name, + "PHONE" => $phone, + "MESSAGE" => $message, + "PAGE" => $pageUrl, + "SENT_AT" => $sentAt, + "CONSENT_VERSION" => Consent::VERSION, + "CONSENT_URL" => $consentUrl, + ], + ]); + + return ["ok" => true]; + } + + public function subscribeAction(string $email, string $consent = "", string $website = "", string $altcha = "", string $page = ""): ?array + { + if ($website !== "") { + return ["ok" => true]; + } + $email = mb_strtolower(trim($email)); + if (!check_email($email) || mb_strlen($email) > 254) { + $this->addError(new Error("Invalid e-mail", "email")); + + return null; + } + if ($consent === "") { + $this->addError(new Error("Consent is required", "consent")); + + return null; + } + $session = Application::getInstance()->getSession(); + if (time() - (int)$session->get("vino_subscribe_last") < self::SUBSCRIBE_RETRY_SECONDS) { + return ["ok" => true]; + } + $session->set("vino_subscribe_last", time()); + if ($this->exists(self::SUBSCRIBERS_CODE, $email)) { + return ["ok" => true]; + } + $sentAt = (string)new DateTime(); + $consentUrl = $this->siteUrl() . "consent/"; + $id = $this->save(self::SUBSCRIBERS_CODE, $email, "", [ + "LANG" => LANGUAGE_ID, + "PAGE" => $this->pageUrl($page), + "CONSENT" => "Y", + "CONSENT_VERSION" => Consent::VERSION, + "CONSENT_URL" => $consentUrl, + "SENT_AT" => $sentAt, + ], $sentAt); + if ($id <= 0) { + $this->addError(new Error("Save failed", "save")); + + return null; + } + Event::send([ + "EVENT_NAME" => "VINO_SUBSCRIBE", + "LID" => SITE_ID, + "C_FIELDS" => [ + "EMAIL" => $email, + "CONSENT_VERSION" => Consent::VERSION, + "CONSENT_URL" => $consentUrl, + ], + ]); + + return ["ok" => true]; + } + + private function iblockId(string $code): int + { + if (!Loader::includeModule("iblock")) { + return 0; + } + $iblock = \CIBlock::GetList([], ["CODE" => $code, "CHECK_PERMISSIONS" => "N"])->Fetch(); + + return $iblock ? (int)$iblock["ID"] : 0; + } + + private function exists(string $code, string $name): bool + { + $iblockId = $this->iblockId($code); + if ($iblockId <= 0) { + return false; + } + + return (bool)\CIBlockElement::GetList([], ["IBLOCK_ID" => $iblockId, "=NAME" => $name], false, ["nTopCount" => 1], ["ID"])->Fetch(); + } + + private function save(string $code, string $name, string $text, array $properties, string $sentAt): int + { + $iblockId = $this->iblockId($code); + if ($iblockId <= 0) { + return 0; + } + $element = new \CIBlockElement(); + + return (int)$element->Add([ + "IBLOCK_ID" => $iblockId, + "NAME" => $name, + "ACTIVE" => "Y", + "DATE_ACTIVE_FROM" => $sentAt, + "DETAIL_TEXT" => $text, + "DETAIL_TEXT_TYPE" => "text", + "PROPERTY_VALUES" => $properties, + ], false, false, false); + } + + private function siteUrl(): string + { + return Config::host() . SITE_DIR; + } + + private function pageUrl(string $page): string + { + $path = (string)parse_url($page, PHP_URL_PATH); + + return Config::host() . ($path !== "" && str_starts_with($path, "/") ? $path : SITE_DIR); + } +} diff --git a/local/modules/jinove.vinoteca/lib/controller/news.php b/local/modules/jinove.vinoteca/lib/controller/news.php new file mode 100644 index 0000000..2844ba6 --- /dev/null +++ b/local/modules/jinove.vinoteca/lib/controller/news.php @@ -0,0 +1,42 @@ + [ + "prefilters" => [new HttpMethod([HttpMethod::METHOD_GET])], + ], + ]; + } + + public function pageAction(): ?Component + { + $page = (string)$this->getRequest()->getQuery("PAGEN_1"); + if (!ctype_digit($page) || (int)$page < 1 || (int)$page > NewsList::pageCount()) { + $this->addError(new Error("Wrong page")); + + return null; + } + $meta = NewsList::pageMeta((int)$page); + + return new Component( + "bitrix:news.list", + NewsList::LIST_TEMPLATE, + NewsList::listParams(true), + [], + static fn(): array => ["title" => $meta["title"]] + ); + } +} diff --git a/local/modules/jinove.vinoteca/lib/controller/order.php b/local/modules/jinove.vinoteca/lib/controller/order.php new file mode 100644 index 0000000..e805463 --- /dev/null +++ b/local/modules/jinove.vinoteca/lib/controller/order.php @@ -0,0 +1,97 @@ + ["prefilters" => [new HttpMethod([HttpMethod::METHOD_POST]), new Csrf(), new FormGuard()]], + "pay" => ["prefilters" => [new HttpMethod([HttpMethod::METHOD_POST]), new Csrf(), new FormGuard(FormGuard::TIMING_NONE, FormGuard::MIN_FILL_MS, false)]], + ]; + } + + public function createAction(string $name, string $phone, string $email, string $pay, string $consent = "", string $comment = "", string $website = "", string $altcha = "", string $page = "", string $base = "/"): ?array + { + if ($website !== "") { + return ["ok" => true, "redirect" => ""]; + } + $name = trim((string)preg_replace('/\s+/u', " ", $name)); + $email = mb_strtolower(trim($email)); + $comment = trim($comment); + $phone = Phone::format($phone); + if ($consent !== "Y" || preg_match('/^\/[\w\-\/]{0,198}$/', $page) !== 1 || mb_strlen($name) < 2 || mb_strlen($name) > 100 || $phone === "" || !check_email($email) || mb_strlen($email) > 254 || mb_strlen($comment) > 500 || (int)$pay <= 0) { + return $this->fail("Invalid fields", "fields"); + } + $session = Application::getInstance()->getSession(); + if (time() - (int)$session->get("vino_order_last") < self::RETRY_SECONDS) { + return $this->fail("Too many orders", "rate"); + } + $session->set("vino_order_last", time()); + $basket = Cart::load(); + if ($basket === null) { + $session->set("vino_order_last", 0); + + return $this->fail("Cart is unavailable", "cart"); + } + DiscountCouponsManager::init(); + $created = Checkout::create($basket, ["name" => $name, "phone" => $phone, "email" => $email, "comment" => $comment], (int)$pay, Checkout::consentProof($page)); + if (isset($created["error"])) { + $session->set("vino_order_last", 0); + + return $this->fail("Order was not created", (string)$created["error"]); + } + $dir = Checkout::dir($base); + $order = $created["order"]; + $redirect = Checkout::doneUrl($order, $dir); + if ($created["method"]["code"] === "halyk") { + $redirect = Checkout::doneUrl($order, $dir, ["autopay" => "Y"]); + } elseif ($created["method"]["code"] !== "cash") { + $started = Checkout::startPayment($order, $dir); + $redirect = $started["url"] !== "" ? $started["url"] : Checkout::doneUrl($order, $dir, ["pay" => "failed"]); + } + + return ["ok" => true, "redirect" => $redirect]; + } + + public function payAction(int $id, string $hash, string $base = "/"): ?array + { + $order = Checkout::find($id, $hash); + if ($order === null || $order->isCanceled()) { + return $this->fail("Order not found", "order"); + } + $dir = Checkout::dir($base); + $started = Checkout::startPayment($order, $dir); + if (is_array($started["widget"] ?? null)) { + return ["ok" => true, "widget" => $started["widget"]]; + } + if ($started["url"] === "") { + return $this->fail("Payment is unavailable", "pay"); + } + + return ["ok" => true, "redirect" => $started["url"]]; + } + + private function fail(string $message, string $code): ?array + { + $this->addError(new Error($message, $code)); + + return null; + } +} diff --git a/local/modules/jinove.vinoteca/lib/controller/password.php b/local/modules/jinove.vinoteca/lib/controller/password.php new file mode 100644 index 0000000..64b57af --- /dev/null +++ b/local/modules/jinove.vinoteca/lib/controller/password.php @@ -0,0 +1,125 @@ + [new HttpMethod([HttpMethod::METHOD_POST]), new Csrf(), new FormGuard(FormGuard::TIMING_ELAPSED)]]; + + return ["request" => $filters, "reset" => $filters]; + } + + public function requestAction(string $email, string $website = "", int $elapsed = 0, string $altcha = ""): ?array + { + $started = microtime(true); + if ($website !== "") { + return ["ok" => true]; + } + if (!$this->limit("vino_password_request_log")) { + return null; + } + $email = mb_strtolower(trim($email)); + if (!check_email($email) || mb_strlen($email) > 254) { + $this->addError(new Error("Invalid e-mail", "email")); + + return null; + } + $row = UserTable::getRow([ + "select" => ["ID"], + "filter" => ["=EMAIL" => $email, "=ACTIVE" => "Y"], + ]); + if ($row !== null && $this->mayMail((int)$row["ID"])) { + \CUser::SendUserInfo((int)$row["ID"], SITE_ID, "", false, self::EVENT); + } + $left = self::RESPONSE_MS * 1000 - (int)((microtime(true) - $started) * 1000000); + if ($left > 0) { + usleep($left); + } + + return ["ok" => true]; + } + + public function resetAction(string $login, string $checkword, string $password, string $website = "", int $elapsed = 0, string $altcha = ""): ?array + { + if ($website !== "") { + $this->addError(new Error("Reset failed", "failed")); + + return null; + } + if (!$this->limit("vino_password_reset_log")) { + return null; + } + $length = mb_strlen($password); + if ( + $login === "" + || mb_strlen($login) > 254 + || !preg_match('/^[A-Za-z0-9]{32}$/', $checkword) + ) { + $this->addError(new Error("Invalid link", "link")); + + return null; + } + if ($length < self::PASSWORD_MIN || $length > self::PASSWORD_MAX || mb_strtolower($password) === mb_strtolower($login)) { + $this->addError(new Error("Weak password", "password")); + + return null; + } + $result = (new \CUser())->ChangePassword($login, $checkword, $password, $password, SITE_ID, "", 0, false); + if (($result["TYPE"] ?? "") !== "OK") { + $this->addError(new Error("Reset failed", (string)($result["FIELD"] ?? "") === "PASSWORD" ? "password" : "link")); + + return null; + } + + return ["ok" => true]; + } + + private function limit(string $sessionKey): bool + { + $session = Application::getInstance()->getSession(); + $now = time(); + $log = array_values(array_filter((array)($session->get($sessionKey) ?? []), static fn($at): bool => (int)$at > $now - self::WINDOW_SECONDS)); + if (count($log) >= self::MAX_PER_WINDOW) { + $this->addError(new Error("Too many attempts", "too_often")); + + return false; + } + $log[] = $now; + $session->set($sessionKey, $log); + + return true; + } + + private function mayMail(int $userId): bool + { + $cache = Cache::createInstance(); + if ($cache->initCache(self::MAIL_PAUSE_SECONDS, "vino_pass_mail_" . $userId, "/vino/password")) { + return false; + } + $cache->startDataCache(); + $cache->endDataCache(["sent" => true]); + + return true; + } +} diff --git a/local/modules/jinove.vinoteca/lib/controller/profile.php b/local/modules/jinove.vinoteca/lib/controller/profile.php new file mode 100644 index 0000000..9d581bb --- /dev/null +++ b/local/modules/jinove.vinoteca/lib/controller/profile.php @@ -0,0 +1,152 @@ + [new HttpMethod([HttpMethod::METHOD_POST]), new Csrf()]]; + + return ["save" => $filters, "password" => $filters, "logout" => $filters]; + } + + public function saveAction(string $name, string $phone = ""): ?array + { + $userId = $this->userId(); + if ($userId <= 0) { + $this->addError(new Error("Not authorized", "auth")); + + return null; + } + $name = trim((string)preg_replace('/\s+/u', " ", $name)); + if ($name === "" || mb_strlen($name) > self::NAME_MAX) { + $this->addError(new Error("Invalid name", "name")); + + return null; + } + if (!mb_check_encoding($name, "UTF-8") || preg_match('/[<>\x00-\x1f\x7f]/', $name)) { + $this->addError(new Error("Invalid name characters", "name_chars")); + + return null; + } + $phone = trim($phone); + if ($phone !== "" && !preg_match('/^\+\d{8,15}$/', $phone)) { + $this->addError(new Error("Invalid phone", "phone")); + + return null; + } + $user = new \CUser(); + if (!$user->Update($userId, ["NAME" => $name, "PERSONAL_PHONE" => $phone])) { + $this->addError(new Error("Save failed", "failed")); + + return null; + } + + return ["ok" => true]; + } + + public function passwordAction(string $current, string $password): ?array + { + $userId = $this->userId(); + if ($userId <= 0) { + $this->addError(new Error("Not authorized", "auth")); + + return null; + } + $session = Application::getInstance()->getSession(); + $now = time(); + $log = array_values(array_filter((array)($session->get("vino_profile_password_log") ?? []), static fn($at): bool => (int)$at > $now - self::WINDOW_SECONDS)); + if (count($log) >= self::MAX_PER_WINDOW) { + $this->addError(new Error("Too many attempts", "too_often")); + + return null; + } + $log[] = $now; + $session->set("vino_profile_password_log", $log); + if (!$this->mayTryPassword($userId)) { + $this->addError(new Error("Too many attempts", "too_often")); + + return null; + } + + $row = UserTable::query()->setSelect(["PASSWORD", "EMAIL"])->setFilter(["=ID" => $userId])->enablePrivateFields()->fetch() ?: null; + if ($row === null || $current === "" || !Password::equals((string)$row["PASSWORD"], $current)) { + $this->addError(new Error("Wrong current password", "current")); + + return null; + } + $length = mb_strlen($password); + if ($length < self::PASSWORD_MIN || $length > self::PASSWORD_MAX || mb_strtolower($password) === mb_strtolower((string)$row["EMAIL"])) { + $this->addError(new Error("Weak password", "password")); + + return null; + } + if ($password === $current) { + $this->addError(new Error("Same password", "same")); + + return null; + } + $user = new \CUser(); + if (!$user->Update($userId, ["PASSWORD" => $password, "CONFIRM_PASSWORD" => $password])) { + $this->addError(new Error("Password rejected", "policy")); + + return null; + } + + return ["ok" => true]; + } + + public function logoutAction(string $lang = "en"): array + { + global $USER; + $USER->Logout(); + + return ["ok" => true, "redirect" => Redirect::home($lang)]; + } + + private function mayTryPassword(int $userId): bool + { + $cache = Cache::createInstance(); + $key = "vino_profile_password_" . $userId; + $attempts = []; + if ($cache->initCache(self::WINDOW_SECONDS, $key, "/vino/profile")) { + $attempts = (array)($cache->getVars()["attempts"] ?? []); + } + $now = time(); + $attempts = array_values(array_filter($attempts, static fn($at): bool => (int)$at > $now - self::WINDOW_SECONDS)); + if (count($attempts) >= self::MAX_PER_WINDOW) { + return false; + } + $attempts[] = $now; + $cache->clean($key, "/vino/profile"); + $cache->startDataCache(self::WINDOW_SECONDS, $key, "/vino/profile"); + $cache->endDataCache(["attempts" => $attempts]); + + return true; + } + + private function userId(): int + { + return (int)CurrentUser::get()->getId(); + } +} diff --git a/local/modules/jinove.vinoteca/lib/controller/register.php b/local/modules/jinove.vinoteca/lib/controller/register.php new file mode 100644 index 0000000..ee50fdd --- /dev/null +++ b/local/modules/jinove.vinoteca/lib/controller/register.php @@ -0,0 +1,124 @@ + [ + "prefilters" => [new HttpMethod([HttpMethod::METHOD_POST]), new Csrf(), new FormGuard(FormGuard::TIMING_ELAPSED)], + ], + ]; + } + + public function createAction( + string $name, + string $email, + string $password, + string $consent = "", + string $back = "", + string $lang = "en", + string $website = "", + int $elapsed = 0, + string $altcha = "" + ): ?array { + $lang = Redirect::language($lang); + if ($website !== "") { + return ["ok" => true, "redirect" => Redirect::home($lang)]; + } + $session = Application::getInstance()->getSession(); + $now = time(); + $log = array_values(array_filter((array)($session->get("vino_register_log") ?? []), static fn($at): bool => (int)$at > $now - self::WINDOW_SECONDS)); + if (count($log) >= self::MAX_PER_WINDOW) { + $this->addError(new Error("Too many attempts", "too_often")); + + return null; + } + $log[] = $now; + $session->set("vino_register_log", $log); + + $name = trim((string)preg_replace('/\s+/u', " ", $name)); + $email = mb_strtolower(trim($email)); + $length = mb_strlen($password); + if ( + $consent !== "1" + || $name === "" + || mb_strlen($name) > self::NAME_MAX + || !mb_check_encoding($name, "UTF-8") + || preg_match('/[<>\x00-\x1f\x7f]/', $name) + || !check_email($email) + || mb_strlen($email) > 254 + || $length < self::PASSWORD_MIN + || $length > self::PASSWORD_MAX + || mb_strtolower($password) === $email + ) { + $this->addError(new Error("Registration failed", "failed")); + + return null; + } + $exists = UserTable::getRow([ + "select" => ["ID"], + "filter" => ["LOGIC" => "OR", "=EMAIL" => $email, "=LOGIN" => $email], + ]); + if ($exists !== null) { + $this->addError(new Error("Registration failed", "failed")); + + return null; + } + $groups = array_values(array_filter(array_map("intval", explode(",", (string)Option::get("main", "new_user_registration_def_group", ""))))); + $user = new \CUser(); + $id = (int)$user->Add([ + "LOGIN" => $email, + "EMAIL" => $email, + "NAME" => $name, + "PASSWORD" => $password, + "CONFIRM_PASSWORD" => $password, + "ACTIVE" => "Y", + "LID" => SITE_ID, + "GROUP_ID" => $groups, + "UF_CONSENT_TIME" => (string)new DateTime(), + "UF_CONSENT_VERSION" => Consent::VERSION, + "UF_CONSENT_PAGE" => $this->consentPage(), + "UF_CONSENT_URL" => Config::host() . SITE_DIR . "consent/", + ]); + if ($id <= 0) { + $this->addError(new Error("Registration failed", "failed")); + + return null; + } + global $USER; + $USER->Authorize($id); + + return ["ok" => true, "redirect" => Redirect::back($back, $lang)]; + } + + private function consentPage(): string + { + $path = (string)parse_url((string)($this->getRequest()->getHeader("Referer") ?? ""), PHP_URL_PATH); + + return mb_check_encoding($path, "UTF-8") && !preg_match('/[\x00-\x1f\x7f]/', $path) ? mb_substr($path, 0, 200) : ""; + } +} diff --git a/local/modules/jinove.vinoteca/lib/controller/review.php b/local/modules/jinove.vinoteca/lib/controller/review.php new file mode 100644 index 0000000..b7acf8a --- /dev/null +++ b/local/modules/jinove.vinoteca/lib/controller/review.php @@ -0,0 +1,130 @@ + "", "ru" => "/ru", "pl" => "/pl"]; + + public function configureActions(): array + { + return [ + "add" => [ + "prefilters" => [new Authentication(), new HttpMethod([HttpMethod::METHOD_POST]), new Csrf(), new FormGuard(FormGuard::TIMING_STARTED, self::MIN_FILL_MS)], + ], + ]; + } + + public function addAction( + int $productId, + int $rating, + string $text, + string $consent = "", + string $website = "", + int $started = 0, + string $altcha = "", + string $lang = "en", + string $page = "" + ): ?array { + if ($website !== "" || FormGuard::startedTooEarly($started, self::MIN_FILL_MS)) { + return ["ok" => true]; + } + $user = CurrentUser::get(); + $author = trim((string)$user->getFullName()); + if ($author === "") { + $author = trim((string)$user->getLogin()); + } + $author = mb_substr($author, 0, 60); + if (!mb_check_encoding($author, "UTF-8") || !mb_check_encoding($text, "UTF-8")) { + $this->addError(new Error("Wrong encoding", "text")); + + return null; + } + $author = trim((string)preg_replace('/\s+/u', " ", $author)); + $text = trim($text); + $lang = isset(self::LANGS[$lang]) ? $lang : "en"; + if ($rating < 1 || $rating > 5) { + $this->addError(new Error("Rating is required", "rating")); + } + if (mb_strlen($text) < 10 || mb_strlen($text) > 2000) { + $this->addError(new Error("Text is required", "text")); + } + if ($consent !== "1") { + $this->addError(new Error("Consent is required", "consent")); + } + if ($this->getErrors()) { + return null; + } + + $session = Application::getInstance()->getSession(); + if (time() - (int)($session->get("vino_review_last") ?? 0) < self::RETRY_SECONDS) { + $this->addError(new Error("Too often", "too_often")); + + return null; + } + + if (!Loader::includeModule("iblock")) { + $this->addError(new Error("Iblock module is required", "internal")); + + return null; + } + $product = ElementTable::getRow([ + "select" => ["ID", "NAME"], + "filter" => ["=ID" => $productId, "=IBLOCK_ID" => Config::iblockId("catalog"), "=ACTIVE" => "Y"], + ]); + if ($product === null) { + $this->addError(new Error("Wine not found", "not_found")); + + return null; + } + + $pagePath = (string)parse_url($page, PHP_URL_PATH); + $element = new \CIBlockElement(); + $id = $element->Add([ + "IBLOCK_ID" => ReviewStats::iblockId(ReviewStats::REVIEWS_CODE), + "ACTIVE" => "N", + "NAME" => mb_substr($author . ": " . $product["NAME"], 0, 255), + "ACTIVE_FROM" => ConvertTimeStamp(time(), "FULL"), + "PREVIEW_TEXT" => $text, + "PREVIEW_TEXT_TYPE" => "text", + "PROPERTY_VALUES" => [ + "PRODUCT" => (int)$product["ID"], + "RATING" => $rating, + "AUTHOR" => $author, + "USER_ID" => (int)$user->getId(), + "LANG" => $lang, + "PAGE" => self::SITE_URL . ($pagePath !== "" ? $pagePath : "/"), + "CONSENT" => "Y", + "CONSENT_VERSION" => Consent::VERSION, + "CONSENT_URL" => self::SITE_URL . self::LANGS[$lang] . "/consent/", + ], + ]); + if (!$id) { + $this->addError(new Error("Review was not saved", "internal")); + + return null; + } + $session->set("vino_review_last", time()); + + return ["ok" => true]; + } +} diff --git a/local/modules/jinove.vinoteca/lib/controller/state.php b/local/modules/jinove.vinoteca/lib/controller/state.php new file mode 100644 index 0000000..6cb17e3 --- /dev/null +++ b/local/modules/jinove.vinoteca/lib/controller/state.php @@ -0,0 +1,29 @@ + [ + "prefilters" => [new HttpMethod([HttpMethod::METHOD_GET])], + ], + ]; + } + + public function allAction(): array + { + return [ + "favorite" => (new Favorite())->stateAction(), + "basket" => (new Basket())->stateAction(), + "compare" => (new Compare())->stateAction(), + ]; + } +} diff --git a/local/modules/jinove.vinoteca/lib/dateformat.php b/local/modules/jinove.vinoteca/lib/dateformat.php new file mode 100644 index 0000000..474c8cd --- /dev/null +++ b/local/modules/jinove.vinoteca/lib/dateformat.php @@ -0,0 +1,19 @@ + date("j", $timestamp), + "#MONTH#" => Loc::getMessage("JINOVE_VINOTECA_MONTH_" . date("n", $timestamp), null, $languageId), + "#YEAR#" => date("Y", $timestamp), + ], $languageId); + } +} diff --git a/local/modules/jinove.vinoteca/lib/language.php b/local/modules/jinove.vinoteca/lib/language.php new file mode 100644 index 0000000..99fd783 --- /dev/null +++ b/local/modules/jinove.vinoteca/lib/language.php @@ -0,0 +1,21 @@ +GetCurPage(false); + if (SITE_DIR !== "/" && str_starts_with($path, SITE_DIR)) { + $path = "/" . substr($path, strlen(SITE_DIR)); + } + + return Config::host() . rtrim((string)($languages[$language]["dir"] ?? "/"), "/") . $path; + } +} diff --git a/local/modules/jinove.vinoteca/lib/money.php b/local/modules/jinove.vinoteca/lib/money.php new file mode 100644 index 0000000..9980f62 --- /dev/null +++ b/local/modules/jinove.vinoteca/lib/money.php @@ -0,0 +1,19 @@ +getContext()->getRequest()->getRequestUri(); + $path = (string)parse_url($uri, PHP_URL_PATH); + if (SITE_DIR !== "/" && str_starts_with($path, SITE_DIR)) { + $path = "/" . substr($path, strlen(SITE_DIR)); + } + if (str_ends_with($path, "index.php")) { + $path = substr($path, 0, -9); + } + + return $path === "" ? "/" : $path; + } +} diff --git a/local/modules/jinove.vinoteca/lib/news.php b/local/modules/jinove.vinoteca/lib/news.php new file mode 100644 index 0000000..cb07521 --- /dev/null +++ b/local/modules/jinove.vinoteca/lib/news.php @@ -0,0 +1,162 @@ + "Y", + "PAGER_TEMPLATE" => "vinoteca", + "PAGER_TITLE" => (string)Loc::getMessage("VINO_NEWS_PAGER_TITLE"), + "PAGER_SHOW_ALWAYS" => "N", + "PAGER_SHOW_ALL" => "N", + "PAGER_DESC_NUMBERING" => "N", + "PAGER_BASE_LINK_ENABLE" => "Y", + "PAGER_BASE_LINK" => self::folder(), + "VINO_AJAX" => $ajax ? "Y" : "N", + ]); + } + + public static function homeParams(): array + { + return self::baseParams(3); + } + + public static function otherParams(int $excludeId): array + { + $GLOBALS[self::FILTER_OTHER] = ["!ID" => $excludeId]; + + return array_merge(self::baseParams(3), [ + "FILTER_NAME" => self::FILTER_OTHER, + "CACHE_FILTER" => "Y", + ]); + } + + public static function pageCount(): int + { + $iblockId = self::iblockId(); + if ($iblockId <= 0) { + return 1; + } + return (int)Cached::remember("/jinove/vinoteca/news", "pages_" . $iblockId, 3600, ["iblock_id_" . $iblockId], static function () use ($iblockId): int { + $now = new DateTime(); + $count = ElementTable::getCount([ + "=IBLOCK_ID" => $iblockId, + "=ACTIVE" => "Y", + ["LOGIC" => "OR", ["=ACTIVE_FROM" => false], ["<=ACTIVE_FROM" => $now]], + ["LOGIC" => "OR", ["=ACTIVE_TO" => false], [">=ACTIVE_TO" => $now]], + ]); + + return max(1, (int)ceil($count / self::PAGE_SIZE)); + }); + } + + public static function pageMeta(int $page): array + { + if ($page > 1) { + return [ + "title" => (string)Loc::getMessage("VINO_NEWS_PAGE_TITLE_N", ["#PAGE#" => $page]), + "description" => (string)Loc::getMessage("VINO_NEWS_DESCRIPTION_N", ["#PAGE#" => $page]), + "canonical" => self::folder() . "?PAGEN_1=" . $page, + ]; + } + + return [ + "title" => (string)Loc::getMessage("VINO_NEWS_PAGE_TITLE"), + "description" => (string)Loc::getMessage("VINO_NEWS_DESCRIPTION"), + "canonical" => self::folder(), + ]; + } + + public static function card(array $item, array $widths = [480, 800]): array + { + $item = LocalizedText::localizeItem($item, ["NAME", "PREVIEW_TEXT", "DETAIL_TEXT"], []); + $picture = $item["DETAIL_PICTURE"] ?? null; + $picture = $item["PREVIEW_PICTURE"] ?: $picture; + $item["VINO_PICTURE"] = []; + if (!empty($picture["ID"])) { + $srcset = []; + foreach ($widths as $width) { + if ((int)$picture["WIDTH"] > $width) { + $resized = \CFile::ResizeImageGet((int)$picture["ID"], ["width" => $width, "height" => 9999], BX_RESIZE_IMAGE_PROPORTIONAL, false); + if (!empty($resized["src"])) { + $srcset[] = $resized["src"] . " " . $width . "w"; + } + } + } + $srcset[] = $picture["SRC"] . " " . (int)$picture["WIDTH"] . "w"; + $item["VINO_PICTURE"] = [ + "ID" => (int)$picture["ID"], + "SRC" => (string)$picture["SRC"], + "SRCSET" => implode(", ", $srcset), + "WIDTH" => (int)$picture["WIDTH"], + "HEIGHT" => (int)$picture["HEIGHT"], + "ALT" => (string)$item["~NAME"], + ]; + } + $published = $item["ACTIVE_FROM"] ? DateTime::createFromUserTime((string)$item["ACTIVE_FROM"])->getTimestamp() : 0; + $item["VINO_TIMESTAMP"] = $published; + $item["VINO_DATE"] = $published ? ["ISO" => date("Y-m-d", $published), "TEXT" => DateFormat::long($published, LANGUAGE_ID)] : []; + + return $item; + } + + private static function baseParams(int $count): array + { + return [ + "IBLOCK_TYPE" => "news", + "IBLOCK_ID" => self::iblockId(), + "NEWS_COUNT" => (string)$count, + "SORT_BY1" => "ACTIVE_FROM", + "SORT_ORDER1" => "DESC", + "SORT_BY2" => "ID", + "SORT_ORDER2" => "DESC", + "FIELD_CODE" => self::LIST_FIELDS, + "PROPERTY_CODE" => self::LIST_PROPERTIES, + "DETAIL_URL" => self::folder() . "#ELEMENT_CODE#/", + "CHECK_DATES" => "Y", + "CACHE_TYPE" => "A", + "CACHE_TIME" => "36000000", + "CACHE_GROUPS" => "N", + "CACHE_FILTER" => "N", + "SET_TITLE" => "N", + "SET_BROWSER_TITLE" => "N", + "SET_META_KEYWORDS" => "N", + "SET_META_DESCRIPTION" => "N", + "SET_LAST_MODIFIED" => "N", + "SET_STATUS_404" => "N", + "SHOW_404" => "N", + "INCLUDE_IBLOCK_INTO_CHAIN" => "N", + "ADD_SECTIONS_CHAIN" => "N", + "DISPLAY_TOP_PAGER" => "N", + "DISPLAY_BOTTOM_PAGER" => "N", + ]; + } +} diff --git a/local/modules/jinove.vinoteca/lib/offers.php b/local/modules/jinove.vinoteca/lib/offers.php new file mode 100644 index 0000000..335da1e --- /dev/null +++ b/local/modules/jinove.vinoteca/lib/offers.php @@ -0,0 +1,339 @@ +initCache(3600, $cacheId, self::CACHE_DIR)) { + $vars = (array)$cache->getVars(); + if ((int)($vars["expires"] ?? 0) === 0 || (int)$vars["expires"] > time()) { + return (array)($vars["rules"] ?? []); + } + $cache->clean($cacheId, self::CACHE_DIR); + } + self::clearCache(); + $cache->startDataCache(); + $taggedCache = Application::getInstance()->getTaggedCache(); + $taggedCache->startTagCache(self::CACHE_DIR); + try { + $taggedCache->registerTag(self::CACHE_TAG); + $vars = self::loadDiscounts(); + } catch (\Throwable $exception) { + $taggedCache->abortTagCache(); + $cache->abortDataCache(); + throw $exception; + } + $taggedCache->endTagCache(); + $cache->endDataCache($vars); + + return $vars["rules"]; + } + + private static function loadDiscounts(): array + { + $time = time(); + $expires = 0; + $boundary = static function ($date) use ($time, &$expires): void { + if ($date instanceof DateTime && $date->getTimestamp() > $time) { + $expires = $expires === 0 ? $date->getTimestamp() : min($expires, $date->getTimestamp()); + } + }; + $current = static function ($from, $to) use ($time): bool { + return !($from instanceof DateTime && $from->getTimestamp() > $time) && !($to instanceof DateTime && $to->getTimestamp() < $time); + }; + $public = []; + $groups = DiscountGroupTable::getList([ + "select" => ["DISCOUNT_ID"], + "filter" => ["=GROUP_ID" => 2, "=ACTIVE" => "Y"], + ]); + while ($group = $groups->fetch()) { + $public[(int)$group["DISCOUNT_ID"]] = true; + } + $rules = []; + $rows = DiscountTable::getList([ + "select" => ["ID", "USE_COUPONS", "ACTIVE_FROM", "ACTIVE_TO", "CONDITIONS_LIST", "ACTIONS_LIST"], + "filter" => ["=ACTIVE" => "Y", "=LID" => Config::basketSiteId()], + ]); + while ($row = $rows->fetch()) { + $boundary($row["ACTIVE_FROM"]); + $boundary($row["ACTIVE_TO"]); + if (!$current($row["ACTIVE_FROM"], $row["ACTIVE_TO"]) || !isset($public[(int)$row["ID"]]) || !empty($row["CONDITIONS_LIST"]["CHILDREN"])) { + continue; + } + $rule = self::parseActions((array)$row["ACTIONS_LIST"]); + if ($rule === null) { + continue; + } + if ($row["USE_COUPONS"] === "Y") { + $coupons = DiscountCouponTable::getList([ + "select" => ["COUPON", "ACTIVE_FROM", "ACTIVE_TO"], + "filter" => [ + "=DISCOUNT_ID" => (int)$row["ID"], + "=ACTIVE" => "Y", + "=TYPE" => DiscountCouponTable::TYPE_MULTI_ORDER, + "=MAX_USE" => 0, + ], + ]); + while ($coupon = $coupons->fetch()) { + $boundary($coupon["ACTIVE_FROM"]); + $boundary($coupon["ACTIVE_TO"]); + if ($current($coupon["ACTIVE_FROM"], $coupon["ACTIVE_TO"])) { + $rule["coupons"][] = (string)$coupon["COUPON"]; + } + } + if (!$rule["coupons"]) { + continue; + } + } + $rules[(int)$row["ID"]] = $rule; + } + + return ["rules" => $rules, "expires" => $expires]; + } + + private static function parseActions(array $actions): ?array + { + $rule = ["percent" => 0, "products" => [], "sections" => [], "coupons" => []]; + foreach ((array)($actions["CHILDREN"] ?? []) as $action) { + $data = (array)($action["DATA"] ?? []); + if (($action["CLASS_ID"] ?? "") !== "ActSaleBsktGrp" || ($data["Type"] ?? "") !== "Discount" || ($data["Unit"] ?? "") !== "Perc" || ($data["True"] ?? "True") !== "True") { + return null; + } + $conditions = (array)($action["CHILDREN"] ?? []); + if (!$conditions || (count($conditions) > 1 && ($data["All"] ?? "") !== "OR")) { + return null; + } + foreach ($conditions as $condition) { + $class = (string)($condition["CLASS_ID"] ?? ""); + if (!in_array($class, ["CondIBElement", "CondIBSection"], true) || ($condition["DATA"]["logic"] ?? "") !== "Equal" || !empty($condition["CHILDREN"])) { + return null; + } + $key = $class === "CondIBElement" ? "products" : "sections"; + $rule[$key] = array_merge($rule[$key], array_map("intval", (array)($condition["DATA"]["value"] ?? []))); + } + $rule["percent"] = max($rule["percent"], (int)$data["Value"]); + } + + return $rule["percent"] > 0 && ($rule["products"] || $rule["sections"]) ? $rule : null; + } + + public static function summary(array $discountIds): array + { + $rules = array_intersect_key(self::discounts(), array_flip(array_map("intval", $discountIds))); + $percents = array_column($rules, "percent"); + $coupons = array_merge([], ...array_column($rules, "coupons")); + $products = array_values(array_unique(array_merge([], ...array_column($rules, "products")))); + $sections = array_values(array_unique(array_merge([], ...array_column($rules, "sections")))); + $badge = ""; + if ($percents) { + $max = max($percents); + $badge = (string)Loc::getMessage(count(array_unique($percents)) > 1 ? "VINO_OFFERS_BADGE_UPTO" : "VINO_OFFERS_BADGE", ["#PERCENT#" => $max]); + } + + return [ + "active" => (bool)$rules, + "badge" => $badge, + "coupons" => array_values(array_unique($coupons)), + "products" => $products, + "sections" => $sections, + ]; + } + + public static function automatic(): array + { + $products = []; + $sections = []; + foreach (self::discounts() as $rule) { + if (!$rule["coupons"]) { + $products = array_merge($products, $rule["products"]); + $sections = array_merge($sections, $rule["sections"]); + } + } + + return ["products" => array_values(array_unique($products)), "sections" => array_values(array_unique($sections))]; + } + + public static function wineParams(array $products, array $sections, string $baseLink, string $listId): array + { + $filter = []; + if ($products && $sections) { + $filter[] = ["LOGIC" => "OR", ["ID" => $products], ["SECTION_ID" => $sections, "INCLUDE_SUBSECTIONS" => "Y"]]; + } elseif ($products) { + $filter["ID"] = $products; + } elseif ($sections) { + $filter["SECTION_ID"] = $sections; + $filter["INCLUDE_SUBSECTIONS"] = "Y"; + } else { + $filter["ID"] = [0]; + } + $GLOBALS[self::FILTER] = $filter; + $catalog = Listing::catalogParams(); + + return [ + "IBLOCK_TYPE" => $catalog["IBLOCK_TYPE"], + "IBLOCK_ID" => $catalog["IBLOCK_ID"], + "SECTION_ID" => 0, + "SHOW_ALL_WO_SECTION" => "Y", + "FILTER_NAME" => self::FILTER, + "PRICE_CODE" => $catalog["PRICE_CODE"], + "BASKET_URL" => $catalog["BASKET_URL"], + "PAGE_ELEMENT_COUNT" => "12", + "LINE_ELEMENT_COUNT" => "3", + "INCLUDE_SUBSECTIONS" => "Y", + "ELEMENT_SORT_FIELD" => "SORT", + "ELEMENT_SORT_ORDER" => "ASC", + "ELEMENT_SORT_FIELD2" => "ID", + "ELEMENT_SORT_ORDER2" => "DESC", + "PROPERTY_CODE" => $catalog["LIST_PROPERTY_CODE"], + "CACHE_TYPE" => $catalog["CACHE_TYPE"], + "CACHE_TIME" => $catalog["CACHE_TIME"], + "CACHE_GROUPS" => $catalog["CACHE_GROUPS"], + "CACHE_FILTER" => "Y", + "SET_TITLE" => "N", + "SET_BROWSER_TITLE" => "N", + "SET_META_KEYWORDS" => "N", + "SET_META_DESCRIPTION" => "N", + "SET_STATUS_404" => "N", + "SHOW_404" => "N", + "ADD_SECTIONS_CHAIN" => "N", + "ACTION_VARIABLE" => $catalog["ACTION_VARIABLE"], + "PRODUCT_ID_VARIABLE" => $catalog["PRODUCT_ID_VARIABLE"], + "USE_PRODUCT_QUANTITY" => "Y", + "ADD_TO_BASKET_ACTION" => "ADD", + "SHOW_OLD_PRICE" => "Y", + "SHOW_DISCOUNT_PERCENT" => "Y", + "DISPLAY_TOP_PAGER" => "N", + "DISPLAY_BOTTOM_PAGER" => "Y", + "PAGER_TEMPLATE" => "vinoteca", + "PAGER_SHOW_ALWAYS" => "N", + "PAGER_TITLE" => (string)Loc::getMessage("VINO_OFFERS_PAGER_TITLE"), + "PAGER_BASE_LINK_ENABLE" => "Y", + "PAGER_BASE_LINK" => $baseLink, + "SECTION_URL" => $catalog["SEF_FOLDER"] . $catalog["SEF_URL_TEMPLATES"]["section"], + "DETAIL_URL" => $catalog["SEF_FOLDER"] . $catalog["SEF_URL_TEMPLATES"]["element"], + "HIDE_NOT_AVAILABLE" => "N", + "VINO_TITLE_TAG" => "h3", + "VINO_GRID_FULL" => "Y", + "VINO_LIST_ID" => VINO_HOST . $listId . "#items", + ]; + } + + public static function card(array $item): array + { + $item = News::card($item, [480, 800, 1200]); + $ids = array_map("intval", (array)($item["PROPERTIES"]["DISCOUNT_ID"]["VALUE"] ?? [])); + $item["VINO_OFFER"] = self::summary($ids); + Application::getInstance()->getTaggedCache()->registerTag(self::CACHE_TAG); + $until = (string)($item["DATE_ACTIVE_TO"] ?? $item["ACTIVE_TO"] ?? ""); + $item["VINO_UNTIL"] = $until !== "" ? (string)Loc::getMessage("VINO_OFFERS_UNTIL", ["#DATE#" => DateFormat::long(DateTime::createFromUserTime($until)->getTimestamp(), LANGUAGE_ID)]) : (string)Loc::getMessage("VINO_OFFERS_ALWAYS"); + + return $item; + } + + public static function listParams(): array + { + return [ + "IBLOCK_TYPE" => "content", + "IBLOCK_ID" => self::iblockId(), + "NEWS_COUNT" => "20", + "SORT_BY1" => "SORT", + "SORT_ORDER1" => "ASC", + "SORT_BY2" => "ACTIVE_FROM", + "SORT_ORDER2" => "DESC", + "FIELD_CODE" => ["PREVIEW_PICTURE", "PREVIEW_TEXT", "ACTIVE_FROM", "DATE_ACTIVE_TO"], + "PROPERTY_CODE" => ["DISCOUNT_ID", "NAME_EN", "NAME_PL", "PREVIEW_TEXT_EN", "PREVIEW_TEXT_PL"], + "DETAIL_URL" => self::folder() . "#ELEMENT_CODE#/", + "CHECK_DATES" => "Y", + "CACHE_TYPE" => "A", + "CACHE_TIME" => "3600", + "CACHE_GROUPS" => "N", + "SET_TITLE" => "N", + "SET_BROWSER_TITLE" => "N", + "SET_META_KEYWORDS" => "N", + "SET_META_DESCRIPTION" => "N", + "SET_LAST_MODIFIED" => "N", + "SET_STATUS_404" => "N", + "SHOW_404" => "N", + "INCLUDE_IBLOCK_INTO_CHAIN" => "N", + "ADD_SECTIONS_CHAIN" => "N", + "DISPLAY_TOP_PAGER" => "N", + "DISPLAY_BOTTOM_PAGER" => "N", + ]; + } + + public static function discountIdsOf(int $elementId): array + { + $iblockId = self::iblockId(); + if ($elementId <= 0 || $iblockId <= 0 || !Loader::includeModule("iblock")) { + return []; + } + return (array)Cached::remember(self::CACHE_DIR, "discount_ids_" . $elementId, 86400, ["iblock_id_" . $iblockId], static function () use ($iblockId, $elementId): array { + $ids = []; + $element = Iblock::wakeUp($iblockId)->getEntityDataClass()::getByPrimary($elementId, ["select" => ["ID", "DISCOUNT_ID"]])->fetchObject(); + if ($element) { + foreach ($element->getDiscountId()->getAll() as $value) { + if ((int)$value->getValue() > 0) { + $ids[] = (int)$value->getValue(); + } + } + } + + return $ids; + }); + } + + public static function refresh(): void + { + self::discounts(); + } + + public static function canonical(string $path): void + { + $navNum = (int)($GLOBALS["NavNum"] ?? 0); + $page = $navNum > 0 ? Application::getInstance()->getContext()->getRequest()->getQuery("PAGEN_" . $navNum) : null; + if ($page !== null && (int)$page > 1) { + $GLOBALS["APPLICATION"]->SetPageProperty("vino_canonical", $path . "?PAGEN_" . $navNum . "=" . (int)$page); + } + } + + public static function clearCache(): void + { + Application::getInstance()->getTaggedCache()->clearByTag(self::CACHE_TAG); + } +} diff --git a/local/modules/jinove.vinoteca/lib/offerschema.php b/local/modules/jinove.vinoteca/lib/offerschema.php new file mode 100644 index 0000000..229de5f --- /dev/null +++ b/local/modules/jinove.vinoteca/lib/offerschema.php @@ -0,0 +1,89 @@ + $item) { + $list[] = ["@type" => "ListItem", "position" => $index + 1, "url" => $item["url"], "name" => $item["name"]]; + } + + return [ + "@context" => self::CONTEXT, + "@graph" => [ + [ + "@type" => "CollectionPage", + "@id" => $url . "#webpage", + "url" => $url, + "name" => $name, + "description" => $description, + "inLanguage" => LANGUAGE_ID, + "about" => ["@id" => Config::host() . "/#store"], + "mainEntity" => ["@id" => $url . "#offers"], + "workTranslation" => PageSchema::translations($path, "CollectionPage"), + ], + [ + "@type" => "ItemList", + "@id" => $url . "#offers", + "url" => $url, + "numberOfItems" => count($list), + "itemListElement" => $list, + ], + ], + ]; + } + + public static function detail(array $offer): array + { + $url = Config::host() . $offer["path"]; + $store = ["@id" => Config::host() . "/#store"]; + $event = [ + "@type" => "SaleEvent", + "@id" => $url . "#event", + "url" => $url, + "name" => $offer["name"], + "description" => $offer["description"], + "inLanguage" => LANGUAGE_ID, + "eventStatus" => "https://schema.org/EventScheduled", + "eventAttendanceMode" => "https://schema.org/MixedEventAttendanceMode", + "location" => $store, + "organizer" => $store, + ]; + foreach (["startDate" => "start", "endDate" => "end"] as $property => $key) { + if ($offer[$key] !== "") { + $event[$property] = $offer[$key]; + } + } + $page = [ + "@type" => "WebPage", + "@id" => $url . "#webpage", + "url" => $url, + "name" => $offer["name"], + "description" => $offer["description"], + "inLanguage" => LANGUAGE_ID, + "mainEntity" => ["@id" => $url . "#event"], + "workTranslation" => PageSchema::translations($offer["path"], "WebPage"), + ]; + if ($offer["image"]) { + $event["image"] = PageSchema::image($url . "#image", $offer["image"]["url"], $offer["image"]["width"], $offer["image"]["height"]); + $page["primaryImageOfPage"] = ["@id" => $url . "#image"]; + } + + return ["@context" => self::CONTEXT, "@graph" => [$page, $event]]; + } + + public static function date(string $value): string + { + return $value !== "" ? date(DATE_ATOM, DateTime::createFromUserTime($value)->getTimestamp()) : ""; + } +} diff --git a/local/modules/jinove.vinoteca/lib/origin.php b/local/modules/jinove.vinoteca/lib/origin.php new file mode 100644 index 0000000..feaa0a5 --- /dev/null +++ b/local/modules/jinove.vinoteca/lib/origin.php @@ -0,0 +1,17 @@ +getHeader("Origin") ?? ""); + + return $origin === "" || $origin === Config::host(); + } +} diff --git a/local/modules/jinove.vinoteca/lib/pageschema.php b/local/modules/jinove.vinoteca/lib/pageschema.php new file mode 100644 index 0000000..0fcfd3c --- /dev/null +++ b/local/modules/jinove.vinoteca/lib/pageschema.php @@ -0,0 +1,70 @@ + $settings) { + if ($language === LANGUAGE_ID) { + continue; + } + $url = Config::host() . rtrim((string)$settings["dir"], "/") . $relative; + $nodes[] = ["@type" => $pageType, "@id" => $url . "#webpage", "url" => $url, "inLanguage" => $language]; + } + + return $nodes; + } + + public static function legalPage(string $path, string $name, string $description, string $modified): array + { + $url = Config::host() . $path; + + return [ + "@context" => "https://schema.org", + "@type" => "WebPage", + "@id" => $url . "#webpage", + "url" => $url, + "name" => $name, + "description" => $description, + "inLanguage" => LANGUAGE_ID, + "dateModified" => $modified, + "workTranslation" => self::translations($path, "WebPage"), + ]; + } + + public static function aboutPage(string $path, string $name, string $description, array $image): array + { + $url = Config::host() . $path; + + return [ + "@context" => "https://schema.org", + "@type" => "AboutPage", + "@id" => $url . "#webpage", + "url" => $url, + "name" => $name, + "description" => $description, + "inLanguage" => LANGUAGE_ID, + "mainEntity" => ["@id" => Config::host() . "/#store"], + "primaryImageOfPage" => $image, + "workTranslation" => self::translations($path, "AboutPage"), + ]; + } + + public static function image(string $id, string $url, int $width, int $height): array + { + return [ + "@type" => "ImageObject", + "@id" => $id, + "url" => $url, + "contentUrl" => $url, + "width" => ["@type" => "QuantitativeValue", "value" => $width, "unitCode" => "E37"], + "height" => ["@type" => "QuantitativeValue", "value" => $height, "unitCode" => "E37"], + ]; + } +} diff --git a/local/modules/jinove.vinoteca/lib/personal/orders.php b/local/modules/jinove.vinoteca/lib/personal/orders.php new file mode 100644 index 0000000..848ba67 --- /dev/null +++ b/local/modules/jinove.vinoteca/lib/personal/orders.php @@ -0,0 +1,73 @@ + [], "more" => false]; + } + $statuses = OrderStatus::getAllStatusesNames(LANGUAGE_ID); + $filter = $completed + ? ["=USER_ID" => $userId, ["LOGIC" => "OR", ["=STATUS_ID" => self::FINAL_STATUS], ["=CANCELED" => "Y"]]] + : ["=USER_ID" => $userId, "!=STATUS_ID" => self::FINAL_STATUS, "=CANCELED" => "N"]; + $orders = []; + $rows = Order::getList([ + "select" => ["ID", "ACCOUNT_NUMBER", "DATE_INSERT", "STATUS_ID", "PRICE", "CURRENCY", "CANCELED"], + "filter" => $filter, + "order" => ["ID" => "DESC"], + "limit" => self::PER_PAGE + 1, + "offset" => (max(1, $page) - 1) * self::PER_PAGE, + ]); + while ($row = $rows->fetch()) { + $orders[(int)$row["ID"]] = [ + "number" => (string)$row["ACCOUNT_NUMBER"], + "date" => $row["DATE_INSERT"]->getTimestamp(), + "statusId" => (string)$row["STATUS_ID"], + "status" => $row["CANCELED"] === "Y" ? "" : (string)($statuses[$row["STATUS_ID"]] ?? ""), + "canceled" => $row["CANCELED"] === "Y", + "total" => Money::format((float)$row["PRICE"], (string)$row["CURRENCY"]), + "items" => [], + ]; + } + $more = count($orders) > self::PER_PAGE; + $orders = array_slice($orders, 0, self::PER_PAGE, true); + if (!$orders) { + return ["orders" => [], "more" => false]; + } + $lines = BasketTable::getList([ + "select" => ["ORDER_ID", "PRODUCT_ID", "NAME", "QUANTITY", "PRICE", "CURRENCY"], + "filter" => ["@ORDER_ID" => array_keys($orders)], + "order" => ["ID" => "ASC"], + ])->fetchAll(); + $productIds = array_map(static fn(array $line): int => (int)$line["PRODUCT_ID"], $lines); + $images = Media::thumbs($productIds, 120, 120); + $products = Related::summariesById($productIds); + foreach ($lines as $line) { + $orders[(int)$line["ORDER_ID"]]["items"][] = [ + "name" => (string)$line["NAME"], + "url" => (string)($products[(int)$line["PRODUCT_ID"]]["url"] ?? ""), + "quantity" => (float)$line["QUANTITY"], + "price" => Money::format((float)$line["PRICE"], (string)$line["CURRENCY"]), + "image" => $images[(int)$line["PRODUCT_ID"]] ?? "", + ]; + } + + return ["orders" => array_values($orders), "more" => $more]; + } +} diff --git a/local/modules/jinove.vinoteca/lib/personal/reviews.php b/local/modules/jinove.vinoteca/lib/personal/reviews.php new file mode 100644 index 0000000..3068f5f --- /dev/null +++ b/local/modules/jinove.vinoteca/lib/personal/reviews.php @@ -0,0 +1,51 @@ +getEntityDataClass(); + if ($table === null) { + return []; + } + $rows = $table::getList([ + "select" => ["ID", "ACTIVE", "PREVIEW_TEXT", "ACTIVE_FROM", "DATE_CREATE", "PRODUCT_" => "PRODUCT", "RATING_" => "RATING"], + "filter" => ["=USER_ID.VALUE" => $userId], + "order" => ["ACTIVE_FROM" => "DESC", "ID" => "DESC"], + "limit" => self::LIMIT, + ])->fetchAll(); + $items = []; + foreach ($rows as $row) { + $date = $row["ACTIVE_FROM"] ?: $row["DATE_CREATE"]; + $items[] = [ + "product" => (int)$row["PRODUCT_VALUE"], + "rating" => max(0, min(5, (int)$row["RATING_VALUE"])), + "text" => trim((string)preg_replace('/\s+/u', " ", strip_tags((string)$row["PREVIEW_TEXT"]))), + "date" => $date instanceof \Bitrix\Main\Type\DateTime ? $date->getTimestamp() : 0, + "published" => $row["ACTIVE"] === "Y", + ]; + } + $products = Related::summariesById(array_column($items, "product")); + foreach ($items as $key => $item) { + $items[$key]["name"] = $products[$item["product"]]["name"] ?? ""; + $items[$key]["url"] = $products[$item["product"]]["url"] ?? ""; + } + + return $items; + } +} diff --git a/local/modules/jinove.vinoteca/lib/phone.php b/local/modules/jinove.vinoteca/lib/phone.php new file mode 100644 index 0000000..9f43600 --- /dev/null +++ b/local/modules/jinove.vinoteca/lib/phone.php @@ -0,0 +1,21 @@ + "/", "ru" => "/ru/", "pl" => "/pl/"]; + + public static function safe(string $back): string + { + $path = (string)parse_url($back, PHP_URL_PATH); + if ( + $path === "" + || preg_match('/[\x00-\x1f\x7f\\\\]/', $back) + || strlen($back) > 300 + || $path[0] !== "/" + || str_starts_with($path, "//") + || preg_match('#(^|/)\.\.?(/|$)#', $path) + || preg_match('#^(/(ru|pl))?/(bitrix|upload|local|login|register|forgot-password|reset-password)(/|$)#', $path) + ) { + return ""; + } + $query = (string)parse_url($back, PHP_URL_QUERY); + + return $path . ($query !== "" ? "?" . $query : ""); + } + + public static function language(string $language): string + { + return isset(self::HOMES[$language]) ? $language : "en"; + } + + public static function home(string $language): string + { + return self::HOMES[self::language($language)]; + } + + public static function back(string $back, string $language): string + { + $safe = self::safe($back); + + return $safe !== "" ? $safe : self::home($language); + } +} diff --git a/local/modules/jinove.vinoteca/lib/retention.php b/local/modules/jinove.vinoteca/lib/retention.php new file mode 100644 index 0000000..1b02faa --- /dev/null +++ b/local/modules/jinove.vinoteca/lib/retention.php @@ -0,0 +1,38 @@ + ["ID"], "filter" => ["=CODE" => self::QUESTIONS_CODE]]); + if ($iblock !== null) { + $before = new DateTime(); + $before->add("-" . self::MONTHS . " months"); + $rows = ElementTable::getList([ + "select" => ["ID"], + "filter" => ["=IBLOCK_ID" => (int)$iblock["ID"], " $before], + "limit" => self::BATCH, + ]); + while ($row = $rows->fetch()) { + \CIBlockElement::Delete((int)$row["ID"]); + } + } + } + + return __METHOD__ . "();"; + } +} diff --git a/local/modules/jinove.vinoteca/lib/routing.php b/local/modules/jinove.vinoteca/lib/routing.php new file mode 100644 index 0000000..d0f92c7 --- /dev/null +++ b/local/modules/jinove.vinoteca/lib/routing.php @@ -0,0 +1,36 @@ + "articles"]; + + public static function onPageStart(): void + { + if (defined("ADMIN_SECTION") || PHP_SAPI === "cli" || !in_array($_SERVER["REQUEST_METHOD"] ?? "", ["GET", "HEAD"], true)) { + return; + } + $uri = (string)($_SERVER["REQUEST_URI"] ?? ""); + $path = (string)parse_url($uri, PHP_URL_PATH); + $query = (string)parse_url($uri, PHP_URL_QUERY); + if ($path === "" || preg_match('#^/(bitrix|upload|local|include)/#', $path)) { + return; + } + if (str_contains(basename($path), ".")) { + return; + } + $target = str_contains($path, "%") ? $path : mb_strtolower($path); + if (preg_match('#^(/(?:ru|pl))?/(' . implode("|", array_keys(self::MOVED)) . ')(/.*)?$#', $target, $match)) { + $target = $match[1] . "/" . self::MOVED[$match[2]] . ($match[3] ?? "/"); + } + if (!str_ends_with($target, "/")) { + $target .= "/"; + } + if ($target !== $path) { + LocalRedirect(Config::host() . $target . ($query !== "" ? "?" . $query : ""), true, "301 Moved permanently"); + } + } +} diff --git a/local/modules/jinove.vinoteca/lib/search.php b/local/modules/jinove.vinoteca/lib/search.php new file mode 100644 index 0000000..a6b5671 --- /dev/null +++ b/local/modules/jinove.vinoteca/lib/search.php @@ -0,0 +1,320 @@ +Fetch()) { + $code = (string)$property["CODE"]; + if (preg_match('/_(EN|PL)$/', $code)) { + $value = is_array($property["VALUE"]) ? (string)($property["VALUE"]["TEXT"] ?? "") : (string)$property["VALUE"]; + $words[] = strip_tags($value); + if (str_starts_with($code, "NAME_")) { + $titles[] = $value; + } + } elseif (in_array($code, self::ENUMS, true) && (string)$property["VALUE_XML_ID"] !== "") { + $names = []; + foreach (self::LANGUAGES as $language) { + $names[] = EnumNames::name($code, (string)$property["VALUE_XML_ID"], "", $language); + } + $words = array_merge($words, $names); + if (in_array($code, self::TITLE_ENUMS, true)) { + $titles = array_merge($titles, $names, [(string)$property["VALUE_ENUM"]]); + } + } + } + $words = array_filter(array_map("trim", $words)); + if ($words) { + $fields["BODY"] = trim((string)($fields["BODY"] ?? "") . " " . implode(" ", array_unique($words))); + } + $titles = array_diff(array_unique(array_filter(array_map("trim", $titles))), [trim((string)($fields["TITLE"] ?? ""))]); + if ($titles) { + $fields["TITLE"] = trim((string)($fields["TITLE"] ?? "") . " " . implode(" ", $titles)); + } + + return $fields; + } + + public static function folder(): string + { + return SITE_DIR . "search/"; + } + + public static function preparePage(): void + { + global $APPLICATION; + $query = trim((string)Context::getCurrent()->getRequest()->getQuery("q")); + $APPLICATION->SetTitle((string)Loc::getMessage("VINO_SEARCH_PAGE_H1")); + $APPLICATION->SetPageProperty("title", $query !== "" ? (string)Loc::getMessage("VINO_SEARCH_PAGE_TITLE_QUERY", ["#QUERY#" => htmlspecialcharsbx(mb_substr($query, 0, 60))]) : (string)Loc::getMessage("VINO_SEARCH_PAGE_H1")); + $APPLICATION->SetPageProperty("robots", "noindex, follow"); + $APPLICATION->SetPageProperty("vino_alternates", "N"); + } + + public static function titleParams(): array + { + $kinds = self::kinds(); + $params = [ + "NUM_CATEGORIES" => "3", + "TOP_COUNT" => "6", + "ORDER" => "rank", + "USE_LANGUAGE_GUESS" => "N", + "CHECK_DATES" => "Y", + "SHOW_OTHERS" => "N", + "SHOW_INPUT" => "Y", + "PAGE" => "#SITE_DIR#search/", + "INPUT_ID" => self::INPUT_ID, + "CONTAINER_ID" => "vino-search-field", + ]; + $groups = [["wine"], ["brand"], ["article", "offer"]]; + foreach ($groups as $index => $group) { + $types = []; + foreach ($group as $kind) { + $types[self::iblockType($kind)][] = (string)$kinds[$kind]; + } + $params["CATEGORY_" . $index] = array_map(static fn(string $type): string => "iblock_" . $type, array_keys($types)); + foreach ($types as $type => $ids) { + $params["CATEGORY_" . $index . "_iblock_" . $type] = $ids; + } + } + + return $params; + } + + public static function pageParams(): array + { + $params = [ + "RESTART" => "Y", + "NO_WORD_LOGIC" => "N", + "CHECK_DATES" => "Y", + "USE_TITLE_RANK" => "Y", + "DEFAULT_SORT" => "rank", + "FILTER_NAME" => "", + "SHOW_WHERE" => "N", + "SHOW_WHEN" => "N", + "PAGE_RESULT_COUNT" => "12", + "AJAX_MODE" => "N", + "CACHE_TYPE" => "A", + "CACHE_TIME" => "3600", + "DISPLAY_TOP_PAGER" => "N", + "DISPLAY_BOTTOM_PAGER" => "Y", + "PAGER_TITLE" => (string)Loc::getMessage("VINO_SEARCH_PAGER_TITLE"), + "PAGER_SHOW_ALWAYS" => "N", + "PAGER_TEMPLATE" => "vinoteca", + "USE_LANGUAGE_GUESS" => "N", + "USE_SUGGEST" => "N", + "arrFILTER" => ["main"], + "arrFILTER_main" => [SITE_DIR . "about/", SITE_DIR . "privacy/", SITE_DIR . "consent/"], + ]; + foreach (self::kinds() as $kind => $iblockId) { + $type = self::iblockType($kind); + if (!in_array("iblock_" . $type, $params["arrFILTER"], true)) { + $params["arrFILTER"][] = "iblock_" . $type; + } + $params["arrFILTER_iblock_" . $type][] = (string)$iblockId; + } + + return $params; + } + + public static function suggest(array $categories): array + { + $hits = []; + foreach ($categories as $code => $category) { + if ($code === "all") { + continue; + } + foreach ((array)($category["ITEMS"] ?? []) as $item) { + if (($item["MODULE_ID"] ?? "") !== "") { + $hits[] = $item; + } + } + } + + return self::describe($hits); + } + + public static function describe(array $hits): array + { + $keys = []; + foreach ($hits as $index => $hit) { + $hits[$index]["URL"] = rtrim((string)preg_replace('/([?&])sphrase_id=[^&]*&?/', '$1', (string)($hit["URL"] ?? "")), "?&"); + $keys[] = [$hit["MODULE_ID"] ?? "", $hit["PARAM2"] ?? "", $hit["ITEM_ID"] ?? "", $hits[$index]["URL"], $hit["TITLE"] ?? "", $hit["BODY"] ?? ""]; + } + return (array)Cached::remember(self::CACHE_DIR, "describe_" . SITE_ID . "_" . md5(serialize($keys)), 3600, array_merge(array_map(static fn(int $iblockId): string => "iblock_id_" . $iblockId, self::kinds()), [Offers::CACHE_TAG]), static fn(): array => self::build($hits)); + } + + private static function build(array $hits): array + { + $kindsById = array_flip(self::kinds()); + $elementIds = []; + $sectionIds = []; + foreach ($hits as $hit) { + if (($hit["MODULE_ID"] ?? "") !== "iblock") { + continue; + } + $itemId = (string)($hit["ITEM_ID"] ?? ""); + if (ctype_digit($itemId) && isset($kindsById[(int)($hit["PARAM2"] ?? 0)])) { + $elementIds[] = (int)$itemId; + } elseif (preg_match('/^S(\d+)$/', $itemId, $match)) { + $sectionIds[] = (int)$match[1]; + } + } + $elements = self::elements($elementIds); + $wineIds = array_keys(array_filter($elements, static fn(array $element): bool => $element["kind"] === "wine")); + $wines = Related::summariesById($wineIds); + $meta = SearchMeta::get($wineIds); + $prices = Prices::optimal($wineIds); + $sections = []; + if ($sectionIds) { + foreach (Sections::all() as $code => $section) { + if (in_array($section["ID"], $sectionIds, true)) { + $sections[$section["ID"]] = ["name" => (string)$section["NAME"], "url" => SITE_DIR . "catalog/" . $code . "/", "text" => (string)$section["DESCRIPTION"]]; + } + } + } + $items = []; + foreach ($hits as $hit) { + $itemId = (string)($hit["ITEM_ID"] ?? ""); + if (($hit["MODULE_ID"] ?? "") === "main") { + $items[] = self::item("page", (string)$hit["TITLE"], (string)$hit["URL"], self::snippet((string)($hit["BODY"] ?? ""))); + continue; + } + if (preg_match('/^S(\d+)$/', $itemId, $match)) { + $section = $sections[(int)$match[1]] ?? null; + if ($section) { + $items[] = self::item("section", $section["name"], $section["url"], self::snippet($section["text"])); + } + continue; + } + $element = $elements[(int)$itemId] ?? null; + if ($element === null) { + continue; + } + if ($element["kind"] === "wine") { + $wine = $wines[(int)$itemId] ?? null; + if ($wine === null) { + continue; + } + $item = self::item("wine", (string)$wine["name"], (string)$wine["url"], (string)($meta[(int)$itemId]["META"] ?? "")); + $price = $prices[(int)$itemId] ?? null; + $item["price"] = $price ? Money::format((float)$price["price"], (string)$price["currency"]) : ""; + } else { + $item = self::item($element["kind"], $element["name"], (string)$hit["URL"], self::snippet($element["text"])); + } + $item["image"] = $element["image"]; + $items[] = $item; + } + + return $items; + } + + private static function item(string $kind, string $name, string $url, string $text): array + { + return [ + "kind" => $kind, + "label" => (string)Loc::getMessage("VINO_SEARCH_KIND_" . strtoupper($kind)), + "name" => $name, + "url" => $url, + "meta" => $text, + "image" => "", + "price" => "", + ]; + } + + private static function elements(array $ids): array + { + if (!$ids || !Loader::includeModule("iblock")) { + return []; + } + $kindsById = array_flip(self::kinds()); + $found = []; + $rows = \CIBlockElement::GetList([], ["ID" => array_values(array_unique($ids))], false, false, ["ID", "IBLOCK_ID", "NAME", "PREVIEW_TEXT", "PREVIEW_PICTURE", "DETAIL_PICTURE"]); + while ($row = $rows->GetNextElement()) { + $element = $row->GetFields(); + $element["PROPERTIES"] = $row->GetProperties(); + $kind = $kindsById[(int)$element["IBLOCK_ID"]] ?? ""; + $found[(int)$element["ID"]] = [ + "kind" => $kind, + "name" => LocalizedText::field($element, "NAME"), + "text" => LocalizedText::field($element, "PREVIEW_TEXT"), + "image" => self::thumb((int)($element["PREVIEW_PICTURE"] ?: $element["DETAIL_PICTURE"])), + ]; + } + + return $found; + } + + private static function thumb(int $fileId): string + { + if ($fileId <= 0) { + return ""; + } + $file = \CFile::ResizeImageGet($fileId, ["width" => self::THUMB_WIDTH, "height" => self::THUMB_HEIGHT], BX_RESIZE_IMAGE_EXACT, false); + + return (string)($file["src"] ?? ""); + } + + private static function snippet(string $text): string + { + $text = trim((string)preg_replace('/\s+/u', " ", strip_tags(str_replace(["

", "
", "
"], " ", $text)))); + if (mb_strlen($text) <= self::SNIPPET_LENGTH) { + return $text; + } + $cut = mb_substr($text, 0, self::SNIPPET_LENGTH); + $space = mb_strrpos($cut, " "); + + return rtrim(mb_substr($cut, 0, $space ?: self::SNIPPET_LENGTH), " ,.;:") . "…"; + } + + private static function kinds(): array + { + return [ + "wine" => Config::iblockId("catalog"), + "brand" => Config::iblockId("brands"), + "article" => Config::iblockId("news"), + "offer" => Config::iblockId("offers"), + ]; + } + + private static function iblockType(string $kind): string + { + $iblock = Loader::includeModule("iblock") ? \CIBlock::GetArrayByID(self::kinds()[$kind]) : false; + + return is_array($iblock) ? (string)$iblock["IBLOCK_TYPE_ID"] : ""; + } +} diff --git a/local/modules/jinove.vinoteca/lib/seo.php b/local/modules/jinove.vinoteca/lib/seo.php new file mode 100644 index 0000000..240e360 --- /dev/null +++ b/local/modules/jinove.vinoteca/lib/seo.php @@ -0,0 +1,122 @@ +GetCurPage(false); + if (substr($path, -9) === "index.php") { + $path = substr($path, 0, -9); + } + + return $path === "" ? "/" : $path; + } + + public static function description(string $text, int $limit = 155): string + { + $text = trim((string)preg_replace('/\s+/u', " ", $text)); + if (mb_strlen($text) <= $limit) { + return $text; + } + $cut = mb_substr($text, 0, $limit + 1); + $sentence = max((int)mb_strrpos($cut, ". "), (int)mb_strrpos($cut, "! "), (int)mb_strrpos($cut, "? ")); + if ($sentence >= 60) { + return mb_substr($cut, 0, $sentence + 1); + } + $space = (int)mb_strrpos($cut, " "); + + return rtrim(mb_substr($cut, 0, $space > 0 ? $space : $limit), " ,;:-"); + } + + public static function fitTitle(array $candidates, int $limit = 60): string + { + foreach ($candidates as $candidate) { + if (mb_strlen($candidate) <= $limit) { + return $candidate; + } + } + + return (string)end($candidates); + } + + public static function fitDescription(string $base, array $tails, int $min = 120, int $max = 160): string + { + $base = trim($base); + if (mb_strlen($base) >= $min) { + return $base; + } + foreach ($tails as $tail) { + $candidate = $base . " " . $tail; + if (mb_strlen($candidate) >= $min && mb_strlen($candidate) <= $max) { + return $candidate; + } + } + + return $base; + } + + public static function openGraph(string $canonical): string + { + global $APPLICATION; + if ((string)$APPLICATION->GetPageProperty("vino_alternates") === "N") { + return ""; + } + $tag = static fn(string $attribute, string $name, string $value): string => ' ' . "\n"; + $languages = Config::languages(); + $html = $tag("property", "og:site_name", "Vinoteca") . $tag("property", "og:locale", (string)$languages[LANGUAGE_ID]["locale"]); + foreach ($languages as $code => $language) { + if ($code !== LANGUAGE_ID) { + $html .= $tag("property", "og:locale:alternate", (string)$language["locale"]); + } + } + $image = (string)$APPLICATION->GetProperty("og_image"); + + return $html + . $tag("property", "og:type", (string)$APPLICATION->GetProperty("og_type") ?: "website") + . $tag("property", "og:url", Config::host() . self::canonicalPath($canonical)) + . $tag("property", "og:title", (string)$APPLICATION->GetTitle(false)) + . $tag("property", "og:description", (string)$APPLICATION->GetProperty("description")) + . $tag("property", "og:image", $image !== "" ? $image : Config::host() . SITE_TEMPLATE_PATH . "/assets/media/og-home.jpg") + . $tag("name", "twitter:card", "summary_large_image"); + } + + public static function canonicalPath(string $default): string + { + global $APPLICATION; + $path = (string)$APPLICATION->GetPageProperty("vino_canonical"); + + return $path !== "" ? $path : $default; + } + + public static function headLinks(string $default, string $host, array $languages, string $defaultLanguage): string + { + if (defined("ERROR_404") && ERROR_404 === "Y") { + return ""; + } + $path = self::canonicalPath($default); + $relative = $path; + if (SITE_DIR !== "/" && strpos($path, SITE_DIR) === 0) { + $relative = "/" . substr($path, strlen(SITE_DIR)); + } + $ready = array_values(array_filter(array_map("trim", explode(",", (string)$GLOBALS["APPLICATION"]->GetPageProperty("vino_langs"))))); + if ($ready) { + $languages = array_intersect_key($languages, array_flip($ready)); + $defaultLanguage = isset($languages[$defaultLanguage]) ? $defaultLanguage : (string)array_key_first($languages); + } + $html = '' . "\n"; + if ((string)$GLOBALS["APPLICATION"]->GetPageProperty("vino_alternates") === "N") { + return $html; + } + foreach ($languages as $language => $settings) { + $html .= ' ' . "\n"; + } + $html .= ' ' . "\n"; + + return $html; + } +} diff --git a/local/modules/jinove.vinoteca/lib/sitemap.php b/local/modules/jinove.vinoteca/lib/sitemap.php new file mode 100644 index 0000000..22f843d --- /dev/null +++ b/local/modules/jinove.vinoteca/lib/sitemap.php @@ -0,0 +1,164 @@ +' . "\n" . '' . "\n"; + $count = 0; + foreach ($pages as $page) { + $alternates = ""; + foreach ($languages as $code => $language) { + $alternates .= ' ' . "\n"; + } + $alternates .= ' ' . "\n"; + foreach ($languages as $language) { + if (++$count > self::LIMIT) { + break 2; + } + $xml .= " \n " . self::escape($host . self::url($language["dir"], $page["path"])) . "\n"; + if ($page["lastmod"] !== "") { + $xml .= " " . $page["lastmod"] . "\n"; + } + $xml .= $alternates . " \n"; + } + } + + return $xml . "\n"; + } + + private static function pages(): array + { + $catalogId = Config::iblockId("catalog"); + $pages = []; + if ($catalogId <= 0 || !Loader::includeModule("iblock")) { + return $pages; + } + $sectionCodes = []; + foreach (Sections::all() as $code => $section) { + $sectionCodes[$section["ID"]] = $code; + } + $now = new DateTime(); + $wines = []; + $latest = 0; + $rows = ElementTable::getList([ + "select" => ["CODE", "IBLOCK_SECTION_ID", "TIMESTAMP_X"], + "filter" => [ + "=IBLOCK_ID" => $catalogId, + "=ACTIVE" => "Y", + ["LOGIC" => "OR", ["=ACTIVE_FROM" => false], ["<=ACTIVE_FROM" => $now]], + ["LOGIC" => "OR", ["=ACTIVE_TO" => false], [">=ACTIVE_TO" => $now]], + ], + "order" => ["ID" => "ASC"], + ]); + while ($row = $rows->fetch()) { + $section = $sectionCodes[(int)$row["IBLOCK_SECTION_ID"]] ?? ""; + if ($section === "" || (string)$row["CODE"] === "") { + continue; + } + $time = $row["TIMESTAMP_X"] instanceof DateTime ? $row["TIMESTAMP_X"]->getTimestamp() : 0; + $latest = max($latest, $time); + $wines[] = ["path" => "catalog/" . $section . "/" . rawurlencode((string)$row["CODE"]) . "/", "lastmod" => self::date($time)]; + } + $menu = MegaMenu::collect($catalogId, 1000); + $lastmod = self::date($latest); + $pages[] = ["path" => "", "lastmod" => $lastmod]; + $pages[] = ["path" => "catalog/", "lastmod" => $lastmod]; + foreach (["TYPES", "COUNTRIES", "BRANDS"] as $group) { + foreach ($menu[$group] as $item) { + $pages[] = ["path" => ltrim(self::relative((string)$item["URL"]), "/"), "lastmod" => $lastmod]; + } + } + $pages[] = ["path" => "brands/", "lastmod" => $lastmod]; + $pages[] = ["path" => "about/", "lastmod" => $lastmod]; + $pages = array_merge($pages, self::section("news", "articles/", $now)); + $pages = array_merge($pages, self::section("offers", "offers/", $now, static fn(int $id): bool => Offers::summary(Offers::discountIdsOf($id))["active"])); + $pages = array_merge($pages, $wines); + $pages[] = ["path" => "privacy/", "lastmod" => self::date(Consent::timestamp(Consent::POLICY_VERSION))]; + $pages[] = ["path" => "consent/", "lastmod" => self::date(Consent::timestamp(Consent::VERSION))]; + + return $pages; + } + + private static function section(string $iblock, string $folder, DateTime $now, ?callable $keep = null): array + { + $iblockId = Config::iblockId($iblock); + if ($iblockId <= 0) { + return []; + } + $items = []; + $latest = 0; + $rows = ElementTable::getList([ + "select" => ["ID", "CODE", "TIMESTAMP_X"], + "filter" => [ + "=IBLOCK_ID" => $iblockId, + "=ACTIVE" => "Y", + ["LOGIC" => "OR", ["=ACTIVE_FROM" => false], ["<=ACTIVE_FROM" => $now]], + ["LOGIC" => "OR", ["=ACTIVE_TO" => false], [">=ACTIVE_TO" => $now]], + ], + "order" => ["ACTIVE_FROM" => "DESC", "ID" => "DESC"], + ]); + while ($row = $rows->fetch()) { + if ((string)$row["CODE"] === "" || ($keep !== null && !$keep((int)$row["ID"]))) { + continue; + } + $time = $row["TIMESTAMP_X"] instanceof DateTime ? $row["TIMESTAMP_X"]->getTimestamp() : 0; + $latest = max($latest, $time); + $items[] = ["path" => $folder . rawurlencode((string)$row["CODE"]) . "/", "lastmod" => self::date($time)]; + } + return array_merge([["path" => $folder, "lastmod" => self::date($latest)]], $items); + } + + private static function write(string $xml): void + { + $file = Application::getDocumentRoot() . self::FILE; + $temporary = $file . ".tmp"; + if (file_put_contents($temporary, $xml, LOCK_EX) !== false) { + rename($temporary, $file); + } + } + + private static function relative(string $url): string + { + return SITE_DIR !== "/" && str_starts_with($url, SITE_DIR) ? "/" . substr($url, strlen(SITE_DIR)) : $url; + } + + private static function url(string $directory, string $path): string + { + return rtrim($directory, "/") . "/" . $path; + } + + private static function date(int $timestamp): string + { + return $timestamp > 0 ? date("Y-m-d", $timestamp) : ""; + } + + private static function escape(string $value): string + { + return htmlspecialchars($value, ENT_XML1 | ENT_QUOTES, "UTF-8"); + } +} diff --git a/local/modules/jinove.vinoteca/lib/storeschema.php b/local/modules/jinove.vinoteca/lib/storeschema.php new file mode 100644 index 0000000..345dd6c --- /dev/null +++ b/local/modules/jinove.vinoteca/lib/storeschema.php @@ -0,0 +1,61 @@ + "https://schema.org", + "@graph" => [ + [ + "@type" => "LiquorStore", + "@id" => $store, + "name" => "Vinoteca", + "description" => $description, + "url" => $host . SITE_DIR, + "logo" => $host . SITE_TEMPLATE_PATH . "/assets/brand/vinoteca-icon-512.png", + "image" => $host . SITE_TEMPLATE_PATH . "/assets/media/og-home.jpg", + "telephone" => $contacts["phone"], + "email" => $contacts["email"], + "address" => [ + "@type" => "PostalAddress", + "streetAddress" => $street, + "addressLocality" => $city, + "addressCountry" => self::COUNTRY, + ], + "openingHoursSpecification" => [[ + "@type" => "OpeningHoursSpecification", + "dayOfWeek" => array_map(static fn(string $day): string => "https://schema.org/" . $day, self::DAYS), + "opens" => self::OPENS, + "closes" => self::CLOSES, + ]], + "currenciesAccepted" => self::CURRENCY, + "priceRange" => PriceRange::get(), + "sameAs" => [$contacts["telegram"]], + ], + [ + "@type" => "WebSite", + "@id" => $host . SITE_DIR . "#website", + "url" => $host . SITE_DIR, + "name" => "Vinoteca", + "inLanguage" => LANGUAGE_ID, + ], + ], + ]; + } +} diff --git a/local/php_interface/include/sale_payment/jinove_halyk/.description.php b/local/php_interface/include/sale_payment/jinove_halyk/.description.php new file mode 100644 index 0000000..c50eb39 --- /dev/null +++ b/local/php_interface/include/sale_payment/jinove_halyk/.description.php @@ -0,0 +1,45 @@ + Loc::getMessage("JINOVE_HALYK_NAME"), + "SORT" => 500, + "CODES" => [ + "HALYK_CLIENT_ID" => [ + "NAME" => Loc::getMessage("JINOVE_HALYK_CLIENT_ID"), + "SORT" => 100, + "GROUP" => "CONNECT_SETTINGS_HALYK", + ], + "HALYK_SECRET" => [ + "NAME" => Loc::getMessage("JINOVE_HALYK_SECRET"), + "SORT" => 200, + "GROUP" => "CONNECT_SETTINGS_HALYK", + ], + "HALYK_TERMINAL" => [ + "NAME" => Loc::getMessage("JINOVE_HALYK_TERMINAL"), + "SORT" => 300, + "GROUP" => "CONNECT_SETTINGS_HALYK", + ], + "HALYK_TEST" => [ + "NAME" => Loc::getMessage("JINOVE_HALYK_TEST"), + "SORT" => 400, + "GROUP" => "CONNECT_SETTINGS_HALYK", + "INPUT" => ["TYPE" => "Y/N"], + "DEFAULT" => ["PROVIDER_KEY" => "INPUT", "PROVIDER_VALUE" => "Y"], + ], + "HALYK_RATE" => [ + "NAME" => Loc::getMessage("JINOVE_HALYK_RATE"), + "DESCRIPTION" => Loc::getMessage("JINOVE_HALYK_RATE_DESC"), + "SORT" => 500, + "GROUP" => "CONNECT_SETTINGS_HALYK", + "DEFAULT" => ["PROVIDER_KEY" => "VALUE", "PROVIDER_VALUE" => "6.5"], + ], + ], +]; diff --git a/local/php_interface/include/sale_payment/jinove_halyk/handler.php b/local/php_interface/include/sale_payment/jinove_halyk/handler.php new file mode 100644 index 0000000..a716c0f --- /dev/null +++ b/local/php_interface/include/sale_payment/jinove_halyk/handler.php @@ -0,0 +1,186 @@ + "https://test-epay-oauth.epayment.kz/oauth2/token", + "status" => "https://test-epay-api.epayment.kz/check-status/payment/transaction/", + "script" => "https://test-epay.epayment.kz/payform/payment-api.js", + ]; + private const LIVE = [ + "oauth" => "https://epay-oauth.homebank.kz/oauth2/token", + "status" => "https://epay-api.homebank.kz/check-status/payment/transaction/", + "script" => "https://epay.homebank.kz/payform/payment-api.js", + ]; + private const LANGUAGES = ["ru" => "rus", "kz" => "kaz"]; + + public function getCurrencyList() + { + return ["RUB", "KZT"]; + } + + public function getPaymentIdFromRequest(Request $request) + { + return (int)$request->get("payment"); + } + + public function initiatePay(Payment $payment, Request $request = null) + { + $result = new ServiceResult(); + $returnUrl = (string)($request ? $request->get("return_url") : ""); + $cancelUrl = (string)($request ? $request->get("cancel_url") : ""); + if ($returnUrl === "" || $cancelUrl === "") { + $result->addError(new Error("Halyk ePay return addresses are missing")); + + return $result; + } + $invoice = "7" . str_pad((string)$payment->getId(), 5, "0", STR_PAD_LEFT) . str_pad((string)(time() % 1000000), 6, "0", STR_PAD_LEFT); + $amount = $this->amount($payment); + if ($amount === null) { + $result->addError(new Error("Halyk ePay exchange rate is not set")); + + return $result; + } + $terminal = trim((string)$this->getBusinessValue($payment, "HALYK_TERMINAL")); + $secret = trim((string)$this->getBusinessValue($payment, "HALYK_SECRET")); + $token = $this->token($payment, [ + "scope" => "payment", + "invoiceID" => $invoice, + "secret_hash" => hash_hmac("sha256", $invoice, $secret), + "amount" => $amount, + "currency" => self::CURRENCY, + "terminal" => $terminal, + ]); + if ($token === null) { + $result->addError(new Error("Halyk ePay authorization failed")); + + return $result; + } + $payment->setField("PS_INVOICE_ID", $invoice); + $payment->setField("PS_SUM", $amount); + $payment->setField("PS_CURRENCY", self::CURRENCY); + $result->setData([ + "widget" => [ + "script" => $this->urls($payment)["script"], + "payment" => [ + "invoiceId" => $invoice, + "backLink" => $returnUrl, + "failureBackLink" => $cancelUrl, + "language" => self::LANGUAGES[defined("LANGUAGE_ID") ? LANGUAGE_ID : "en"] ?? "eng", + "description" => "Order " . (string)$payment->getOrder()->getField("ACCOUNT_NUMBER"), + "terminal" => $terminal, + "amount" => $amount, + "currency" => self::CURRENCY, + "auth" => $token, + ], + ], + ]); + + return $result; + } + + public function processRequest(Payment $payment, Request $request) + { + $result = new ServiceResult(); + if ($payment->isPaid()) { + return $result; + } + $invoice = (string)$payment->getField("PS_INVOICE_ID"); + if ($invoice === "") { + $result->addError(new Error("Halyk ePay payment was not started")); + + return $result; + } + $token = $this->token($payment, [ + "scope" => "webapi usermanagement email_send verification statement statistics payment", + "terminal" => trim((string)$this->getBusinessValue($payment, "HALYK_TERMINAL")), + ]); + if ($token === null) { + $result->addError(new Error("Halyk ePay authorization failed")); + + return $result; + } + $client = new HttpClient(["socketTimeout" => 15, "streamTimeout" => 25]); + $client->setHeader("Authorization", "Bearer " . (string)$token["access_token"]); + $body = $client->get($this->urls($payment)["status"] . rawurlencode($invoice)); + $data = is_string($body) && $body !== "" ? json_decode($body, true) : null; + $transaction = is_array($data) ? ($data["transaction"] ?? null) : null; + if (!is_array($transaction) || (string)($data["resultCode"] ?? "") !== "100") { + $result->addError(new Error("Halyk ePay payment is not found yet")); + + return $result; + } + if (($transaction["statusName"] ?? "") !== "CHARGE") { + $result->addError(new Error("Halyk ePay payment is not completed: " . (string)($transaction["statusName"] ?? ""))); + + return $result; + } + $expected = (float)$payment->getField("PS_SUM"); + if ($expected <= 0 || $payment->getField("PS_CURRENCY") !== self::CURRENCY || (string)($transaction["invoiceID"] ?? "") !== $invoice || ($transaction["currency"] ?? "") !== self::CURRENCY || abs((float)($transaction["amount"] ?? 0) - $expected) > 0.01) { + $result->addError(new Error("Halyk ePay amount does not match the order")); + + return $result; + } + $result->setPsData([ + "PS_INVOICE_ID" => $invoice, + "PS_STATUS" => "Y", + "PS_STATUS_CODE" => "CHARGE", + "PS_STATUS_DESCRIPTION" => "Halyk ePay " . (string)($transaction["reference"] ?? ""), + "PS_SUM" => $expected, + "PS_CURRENCY" => self::CURRENCY, + "PS_RESPONSE_DATE" => new DateTime(), + ]); + $result->setOperationType(ServiceResult::MONEY_COMING); + + return $result; + } + + private function amount(Payment $payment): ?float + { + $sum = PriceMaths::roundByFormatCurrency($payment->getSum(), $payment->getCurrency()); + if ($payment->getCurrency() === self::CURRENCY) { + return round($sum); + } + $rate = (float)str_replace(",", ".", (string)$this->getBusinessValue($payment, "HALYK_RATE")); + if ($rate <= 0) { + return null; + } + + return max(1.0, round($sum * $rate)); + } + + private function urls(Payment $payment): array + { + return $this->getBusinessValue($payment, "HALYK_TEST") === "N" ? self::LIVE : self::TEST; + } + + private function token(Payment $payment, array $fields): ?array + { + $client = new HttpClient(["socketTimeout" => 15, "streamTimeout" => 25]); + $body = $client->post($this->urls($payment)["oauth"], [ + "grant_type" => "client_credentials", + "client_id" => trim((string)$this->getBusinessValue($payment, "HALYK_CLIENT_ID")), + "client_secret" => trim((string)$this->getBusinessValue($payment, "HALYK_SECRET")), + ] + $fields); + $data = is_string($body) && $body !== "" ? json_decode($body, true) : null; + if (!is_array($data) || empty($data["access_token"])) { + PaySystem\Logger::addError(__CLASS__ . ": token request failed, HTTP " . $client->getStatus()); + + return null; + } + + return $data; + } +} diff --git a/local/php_interface/include/sale_payment/jinove_halyk/lang/en/.description.php b/local/php_interface/include/sale_payment/jinove_halyk/lang/en/.description.php new file mode 100644 index 0000000..2f61f66 --- /dev/null +++ b/local/php_interface/include/sale_payment/jinove_halyk/lang/en/.description.php @@ -0,0 +1,8 @@ + Loc::getMessage("JINOVE_PAYPAL_NAME"), + "SORT" => 500, + "CODES" => [ + "PAYPAL_CLIENT_ID" => [ + "NAME" => Loc::getMessage("JINOVE_PAYPAL_CLIENT_ID"), + "SORT" => 100, + "GROUP" => "CONNECT_SETTINGS_PAYPAL", + ], + "PAYPAL_SECRET" => [ + "NAME" => Loc::getMessage("JINOVE_PAYPAL_SECRET"), + "SORT" => 200, + "GROUP" => "CONNECT_SETTINGS_PAYPAL", + ], + "PAYPAL_TEST" => [ + "NAME" => Loc::getMessage("JINOVE_PAYPAL_TEST"), + "SORT" => 300, + "GROUP" => "CONNECT_SETTINGS_PAYPAL", + "INPUT" => ["TYPE" => "Y/N"], + "DEFAULT" => ["PROVIDER_KEY" => "INPUT", "PROVIDER_VALUE" => "Y"], + ], + "PAYPAL_CURRENCY" => [ + "NAME" => Loc::getMessage("JINOVE_PAYPAL_CURRENCY"), + "DESCRIPTION" => Loc::getMessage("JINOVE_PAYPAL_CURRENCY_DESC"), + "SORT" => 400, + "GROUP" => "CONNECT_SETTINGS_PAYPAL", + "DEFAULT" => ["PROVIDER_KEY" => "VALUE", "PROVIDER_VALUE" => "RUB"], + ], + "PAYPAL_RATE" => [ + "NAME" => Loc::getMessage("JINOVE_PAYPAL_RATE"), + "DESCRIPTION" => Loc::getMessage("JINOVE_PAYPAL_RATE_DESC"), + "SORT" => 500, + "GROUP" => "CONNECT_SETTINGS_PAYPAL", + "DEFAULT" => ["PROVIDER_KEY" => "VALUE", "PROVIDER_VALUE" => "1"], + ], + "PAYPAL_BRAND" => [ + "NAME" => Loc::getMessage("JINOVE_PAYPAL_BRAND"), + "SORT" => 600, + "GROUP" => "CONNECT_SETTINGS_PAYPAL", + "DEFAULT" => ["PROVIDER_KEY" => "VALUE", "PROVIDER_VALUE" => "Vinoteca"], + ], + ], +]; diff --git a/local/php_interface/include/sale_payment/jinove_paypal/handler.php b/local/php_interface/include/sale_payment/jinove_paypal/handler.php new file mode 100644 index 0000000..2d41b9b --- /dev/null +++ b/local/php_interface/include/sale_payment/jinove_paypal/handler.php @@ -0,0 +1,229 @@ +get("payment"); + } + + public function initiatePay(Payment $payment, Request $request = null) + { + $result = new ServiceResult(); + $returnUrl = (string)($request ? $request->get("return_url") : ""); + $cancelUrl = (string)($request ? $request->get("cancel_url") : ""); + if ($returnUrl === "" || $cancelUrl === "") { + $result->addError(new Error("PayPal return addresses are missing")); + + return $result; + } + $amount = $this->amount($payment); + if ($amount === null) { + $result->addError(new Error("PayPal exchange rate is not set")); + + return $result; + } + [$currency, $value] = $amount; + $order = $payment->getOrder(); + $response = $this->call( + $payment, + "POST", + "/v2/checkout/orders", + [ + "intent" => "CAPTURE", + "purchase_units" => [[ + "reference_id" => (string)$payment->getId(), + "custom_id" => (string)$order->getField("ACCOUNT_NUMBER"), + "description" => (string)$order->getField("ACCOUNT_NUMBER"), + "amount" => ["currency_code" => $currency, "value" => $value], + ]], + "payment_source" => ["paypal" => ["experience_context" => [ + "brand_name" => (string)$this->getBusinessValue($payment, "PAYPAL_BRAND"), + "shipping_preference" => "NO_SHIPPING", + "user_action" => "PAY_NOW", + "return_url" => $returnUrl, + "cancel_url" => $cancelUrl, + ]]], + ], + "create-" . $payment->getId() . "-" . $value . "-" . time() + ); + if (isset($response["error"])) { + $result->addError(new Error($response["error"])); + + return $result; + } + $link = ""; + foreach ((array)($response["links"] ?? []) as $item) { + if (in_array($item["rel"] ?? "", ["payer-action", "approve"], true)) { + $link = (string)$item["href"]; + break; + } + } + if ($link === "" || empty($response["id"])) { + $result->addError(new Error("PayPal did not return an approval address")); + + return $result; + } + $payment->setField("PS_INVOICE_ID", (string)$response["id"]); + $payment->setField("PS_SUM", (float)$value); + $payment->setField("PS_CURRENCY", $currency); + $result->setPaymentUrl($link); + + return $result; + } + + public function processRequest(Payment $payment, Request $request) + { + $result = new ServiceResult(); + if ($payment->isPaid()) { + return $result; + } + $token = (string)$request->get("token"); + if ($token === "" || $token !== (string)$payment->getField("PS_INVOICE_ID")) { + $result->addError(new Error("PayPal order does not match the payment")); + + return $result; + } + $currency = (string)$payment->getField("PS_CURRENCY"); + $expected = (float)$payment->getField("PS_SUM"); + if ($currency === "" || $expected <= 0) { + $result->addError(new Error("PayPal payment was not started")); + + return $result; + } + $response = $this->call($payment, "GET", "/v2/checkout/orders/" . rawurlencode($token)); + if (isset($response["error"])) { + $result->addError(new Error($response["error"])); + + return $result; + } + if (($response["status"] ?? "") === "APPROVED") { + $unit = $response["purchase_units"][0]["amount"] ?? []; + if (($unit["currency_code"] ?? "") !== $currency || abs((float)($unit["value"] ?? 0) - $expected) > 0.01) { + $result->addError(new Error("PayPal amount does not match the order")); + + return $result; + } + $response = $this->call($payment, "POST", "/v2/checkout/orders/" . rawurlencode($token) . "/capture", new \stdClass(), "capture-" . $token); + if (isset($response["error"]) && ($response["issue"] ?? "") === "ORDER_ALREADY_CAPTURED") { + $response = $this->call($payment, "GET", "/v2/checkout/orders/" . rawurlencode($token)); + } + if (isset($response["error"])) { + $result->addError(new Error($response["error"])); + + return $result; + } + } + $capture = $response["purchase_units"][0]["payments"]["captures"][0] ?? null; + if (($response["status"] ?? "") !== "COMPLETED" || !is_array($capture) || ($capture["status"] ?? "") !== "COMPLETED") { + $result->addError(new Error("PayPal payment is not completed: " . (string)($response["status"] ?? ""))); + + return $result; + } + if (($capture["amount"]["currency_code"] ?? "") !== $currency || abs((float)($capture["amount"]["value"] ?? 0) - $expected) > 0.01) { + $result->addError(new Error("PayPal amount does not match the order")); + + return $result; + } + $result->setPsData([ + "PS_INVOICE_ID" => $token, + "PS_STATUS" => "Y", + "PS_STATUS_CODE" => (string)$capture["status"], + "PS_STATUS_DESCRIPTION" => "PayPal capture " . (string)($capture["id"] ?? ""), + "PS_SUM" => $expected, + "PS_CURRENCY" => $currency, + "PS_RESPONSE_DATE" => new DateTime(), + ]); + $result->setOperationType(ServiceResult::MONEY_COMING); + + return $result; + } + + private function amount(Payment $payment): ?array + { + $sum = PriceMaths::roundByFormatCurrency($payment->getSum(), $payment->getCurrency()); + $currency = trim((string)$this->getBusinessValue($payment, "PAYPAL_CURRENCY")); + if ($currency === "" || $currency === $payment->getCurrency()) { + return [$payment->getCurrency(), number_format($sum, 2, ".", "")]; + } + $rate = (float)str_replace(",", ".", (string)$this->getBusinessValue($payment, "PAYPAL_RATE")); + if ($rate <= 0) { + return null; + } + + return [$currency, number_format($sum / $rate, 2, ".", "")]; + } + + private function base(Payment $payment): string + { + return $this->getBusinessValue($payment, "PAYPAL_TEST") === "N" ? self::LIVE : self::SANDBOX; + } + + private function token(Payment $payment): ?string + { + if ($this->accessToken !== null) { + return $this->accessToken; + } + $client = new HttpClient(["socketTimeout" => 15, "streamTimeout" => 25]); + $client->setAuthorization((string)$this->getBusinessValue($payment, "PAYPAL_CLIENT_ID"), (string)$this->getBusinessValue($payment, "PAYPAL_SECRET")); + $client->setHeader("Content-Type", "application/x-www-form-urlencoded"); + $body = $client->post($this->base($payment) . "/v1/oauth2/token", "grant_type=client_credentials"); + $data = is_string($body) && $body !== "" ? json_decode($body, true) : null; + if (!is_array($data) || empty($data["access_token"])) { + PaySystem\Logger::addError(__CLASS__ . ": token request failed, HTTP " . $client->getStatus()); + + return null; + } + + return $this->accessToken = (string)$data["access_token"]; + } + + private function call(Payment $payment, string $method, string $path, mixed $payload = null, string $requestId = ""): array + { + $token = $this->token($payment); + if ($token === null) { + return ["error" => "PayPal authorization failed"]; + } + $client = new HttpClient(["socketTimeout" => 15, "streamTimeout" => 30]); + $client->setHeader("Authorization", "Bearer " . $token); + $client->setHeader("Content-Type", "application/json"); + if ($requestId !== "") { + $client->setHeader("PayPal-Request-Id", $requestId); + } + $url = $this->base($payment) . $path; + $body = $method === "GET" ? $client->get($url) : $client->post($url, Json::encode($payload)); + $status = $client->getStatus(); + $data = is_string($body) && $body !== "" ? json_decode($body, true) : []; + $data = is_array($data) ? $data : []; + if ($status < 200 || $status >= 300) { + $issue = (string)($data["details"][0]["issue"] ?? $data["name"] ?? ""); + PaySystem\Logger::addError(__CLASS__ . ": " . $method . " " . $path . " HTTP " . $status . " " . $issue); + + return ["error" => "PayPal HTTP " . $status . " " . $issue, "issue" => $issue]; + } + + return $data; + } +} diff --git a/local/php_interface/include/sale_payment/jinove_paypal/lang/en/.description.php b/local/php_interface/include/sale_payment/jinove_paypal/lang/en/.description.php new file mode 100644 index 0000000..263ef55 --- /dev/null +++ b/local/php_interface/include/sale_payment/jinove_paypal/lang/en/.description.php @@ -0,0 +1,10 @@ +addEventHandler("main", "OnPageStart", array(\Jinove\Vinoteca\Routing::class, "onPageStart")); +$vinoEvents->addEventHandler("search", "BeforeIndex", array(\Jinove\Vinoteca\Search::class, "beforeIndex")); +$vinoEvents->addEventHandler("iblock", "OnAfterIBlockElementAdd", array(\Jinove\Vinoteca\Catalog\ReviewStats::class, "onElementChange")); +$vinoEvents->addEventHandler("iblock", "OnAfterIBlockElementUpdate", array(\Jinove\Vinoteca\Catalog\ReviewStats::class, "onElementChange")); +$vinoEvents->addEventHandler("iblock", "OnAfterIBlockElementAdd", array(\Jinove\Vinoteca\Catalog\PhotoSort::class, "onElementChange")); +$vinoEvents->addEventHandler("iblock", "OnAfterIBlockElementUpdate", array(\Jinove\Vinoteca\Catalog\PhotoSort::class, "onElementChange")); +$vinoEvents->addEventHandler("iblock", "OnBeforeIBlockElementDelete", array(\Jinove\Vinoteca\Catalog\ReviewStats::class, "onBeforeDelete")); +$vinoEvents->addEventHandler("iblock", "OnAfterIBlockElementDelete", array(\Jinove\Vinoteca\Catalog\ReviewStats::class, "onAfterDelete")); +$vinoEvents->addEventHandler("iblock", "OnAfterIBlockElementDelete", array(\Jinove\Vinoteca\Catalog\FavoriteTable::class, "onElementDelete")); +$vinoEvents->addEventHandler("main", "OnBeforeUserLogin", array(\Jinove\Vinoteca\Catalog\FavoriteTable::class, "rememberGuest")); +$vinoEvents->addEventHandler("main", "OnAfterUserLogin", array(\Jinove\Vinoteca\Catalog\FavoriteTable::class, "mergeGuest")); +foreach (array("Discount", "DiscountCoupon") as $vinoEntity) { + foreach (array("OnAfterAdd", "OnAfterUpdate", "OnAfterDelete") as $vinoEvent) { + $vinoEvents->addEventHandler("sale", "\Bitrix\Sale\Internals\\" . $vinoEntity . "::" . $vinoEvent, array(\Jinove\Vinoteca\Offers::class, "clearCache")); + } +} diff --git a/local/templates/jinove_wine/.description.php b/local/templates/jinove_wine/.description.php new file mode 100644 index 0000000..ecf49c9 --- /dev/null +++ b/local/templates/jinove_wine/.description.php @@ -0,0 +1,8 @@ + "Vinoteca (jinove_wine)", + "DESCRIPTION" => "Тёмная винная тема Vinoteca: бордо + золото, Cormorant Garamond + Manrope.", + "SORT" => 1, +); diff --git a/local/templates/jinove_wine/assets/brand/vinoteca-icon-512.png b/local/templates/jinove_wine/assets/brand/vinoteca-icon-512.png new file mode 100644 index 0000000..bfab1a6 Binary files /dev/null and b/local/templates/jinove_wine/assets/brand/vinoteca-icon-512.png differ diff --git a/local/templates/jinove_wine/assets/brand/vinoteca-icon.svg b/local/templates/jinove_wine/assets/brand/vinoteca-icon.svg new file mode 100644 index 0000000..745c3e1 --- /dev/null +++ b/local/templates/jinove_wine/assets/brand/vinoteca-icon.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/local/templates/jinove_wine/assets/fonts/f0.woff2 b/local/templates/jinove_wine/assets/fonts/f0.woff2 new file mode 100644 index 0000000..3cfa50b Binary files /dev/null and b/local/templates/jinove_wine/assets/fonts/f0.woff2 differ diff --git a/local/templates/jinove_wine/assets/fonts/f1.woff2 b/local/templates/jinove_wine/assets/fonts/f1.woff2 new file mode 100644 index 0000000..a54fd00 Binary files /dev/null and b/local/templates/jinove_wine/assets/fonts/f1.woff2 differ diff --git a/local/templates/jinove_wine/assets/fonts/f10.woff2 b/local/templates/jinove_wine/assets/fonts/f10.woff2 new file mode 100644 index 0000000..1e4b7a4 Binary files /dev/null and b/local/templates/jinove_wine/assets/fonts/f10.woff2 differ diff --git a/local/templates/jinove_wine/assets/fonts/f11.woff2 b/local/templates/jinove_wine/assets/fonts/f11.woff2 new file mode 100644 index 0000000..bd24140 Binary files /dev/null and b/local/templates/jinove_wine/assets/fonts/f11.woff2 differ diff --git a/local/templates/jinove_wine/assets/fonts/f12.woff2 b/local/templates/jinove_wine/assets/fonts/f12.woff2 new file mode 100644 index 0000000..57c7c0e Binary files /dev/null and b/local/templates/jinove_wine/assets/fonts/f12.woff2 differ diff --git a/local/templates/jinove_wine/assets/fonts/f2.woff2 b/local/templates/jinove_wine/assets/fonts/f2.woff2 new file mode 100644 index 0000000..e90a82d Binary files /dev/null and b/local/templates/jinove_wine/assets/fonts/f2.woff2 differ diff --git a/local/templates/jinove_wine/assets/fonts/f3.woff2 b/local/templates/jinove_wine/assets/fonts/f3.woff2 new file mode 100644 index 0000000..c56f179 Binary files /dev/null and b/local/templates/jinove_wine/assets/fonts/f3.woff2 differ diff --git a/local/templates/jinove_wine/assets/fonts/f4.woff2 b/local/templates/jinove_wine/assets/fonts/f4.woff2 new file mode 100644 index 0000000..5c747e5 Binary files /dev/null and b/local/templates/jinove_wine/assets/fonts/f4.woff2 differ diff --git a/local/templates/jinove_wine/assets/fonts/f5.woff2 b/local/templates/jinove_wine/assets/fonts/f5.woff2 new file mode 100644 index 0000000..a1828a8 Binary files /dev/null and b/local/templates/jinove_wine/assets/fonts/f5.woff2 differ diff --git a/local/templates/jinove_wine/assets/fonts/f6.woff2 b/local/templates/jinove_wine/assets/fonts/f6.woff2 new file mode 100644 index 0000000..20114e2 Binary files /dev/null and b/local/templates/jinove_wine/assets/fonts/f6.woff2 differ diff --git a/local/templates/jinove_wine/assets/fonts/f7.woff2 b/local/templates/jinove_wine/assets/fonts/f7.woff2 new file mode 100644 index 0000000..3a06229 Binary files /dev/null and b/local/templates/jinove_wine/assets/fonts/f7.woff2 differ diff --git a/local/templates/jinove_wine/assets/fonts/f8.woff2 b/local/templates/jinove_wine/assets/fonts/f8.woff2 new file mode 100644 index 0000000..e74e718 Binary files /dev/null and b/local/templates/jinove_wine/assets/fonts/f8.woff2 differ diff --git a/local/templates/jinove_wine/assets/fonts/f9.woff2 b/local/templates/jinove_wine/assets/fonts/f9.woff2 new file mode 100644 index 0000000..71eb731 Binary files /dev/null and b/local/templates/jinove_wine/assets/fonts/f9.woff2 differ diff --git a/local/templates/jinove_wine/assets/js/vino-altcha.js b/local/templates/jinove_wine/assets/js/vino-altcha.js new file mode 100644 index 0000000..39f441e --- /dev/null +++ b/local/templates/jinove_wine/assets/js/vino-altcha.js @@ -0,0 +1,46 @@ +(function () { + function config() { + try { + return JSON.parse(document.getElementById('vino-config').textContent) || {}; + } catch (e) { + return {}; + } + } + + function arm(guard) { + var cfg = config(); + if (!guard || !cfg.altcha) return; + if (!document.querySelector('script[data-altcha]')) { + var script = document.createElement('script'); + script.type = 'module'; + script.src = cfg.altcha; + script.setAttribute('data-altcha', ''); + document.head.appendChild(script); + return; + } + if (typeof guard.getState === 'function' && ['verified', 'verifying'].indexOf(guard.getState()) < 0) guard.verify(); + } + + function armed(guard) { + return new Promise(function (resolve) { + var tick = 0; + (function poll() { + var state = guard && typeof guard.getState === 'function' ? guard.getState() : ''; + if (state === 'verified') return resolve(true); + var failed = state === 'error' || state === 'expired'; + var idle = state === 'unverified' && tick >= 30; + if ((failed || idle) && tick % 30 === 0) guard.verify(); + if (++tick > 150) return resolve(false); + setTimeout(poll, 100); + })(); + }); + } + + function reset(guard) { + if (!guard) return; + if (typeof guard.reset === 'function') guard.reset(); + if (typeof guard.verify === 'function') guard.verify(); + } + + window.VinoAltcha = { arm: arm, armed: armed, reset: reset }; +})(); diff --git a/local/templates/jinove_wine/assets/js/vino-busy.js b/local/templates/jinove_wine/assets/js/vino-busy.js new file mode 100644 index 0000000..c8eb349 --- /dev/null +++ b/local/templates/jinove_wine/assets/js/vino-busy.js @@ -0,0 +1,34 @@ +(function () { + var layer = null; + var label = null; + + function build() { + layer = document.createElement('div'); + layer.className = 'vino-busy'; + layer.hidden = true; + layer.setAttribute('role', 'status'); + layer.setAttribute('aria-live', 'polite'); + var spinner = document.createElement('span'); + spinner.className = 'vino-busy__spinner'; + label = document.createElement('p'); + label.className = 'vino-busy__text'; + layer.appendChild(spinner); + layer.appendChild(label); + document.body.appendChild(layer); + } + + window.addEventListener('pageshow', function (e) { + if (e.persisted && layer) layer.hidden = true; + }); + + window.VinoBusy = { + show: function (text) { + if (!layer) build(); + label.textContent = text || ''; + layer.hidden = false; + }, + hide: function () { + if (layer) layer.hidden = true; + } + }; +})(); diff --git a/local/templates/jinove_wine/assets/js/vino-cart.js b/local/templates/jinove_wine/assets/js/vino-cart.js new file mode 100644 index 0000000..c0f0e6a --- /dev/null +++ b/local/templates/jinove_wine/assets/js/vino-cart.js @@ -0,0 +1,97 @@ +(function () { + if (!window.BX || !BX.ajax || !BX.ajax.runAction) return; + var items = {}; + var timers = {}; + var version = 0; + var cfg = {}; + try { cfg = JSON.parse(document.getElementById('vino-config').textContent); } catch (e) {} + var max = cfg.cartMax; + + function total() { + return Object.keys(items).reduce(function (sum, id) { return sum + items[id]; }, 0); + } + + function counters(count) { + document.querySelectorAll('[data-cart-count]').forEach(function (c) { + c.textContent = count > 99 ? '99+' : count; + c.hidden = !count; + }); + } + + function render() { + document.querySelectorAll('[data-qty]').forEach(function (box) { + var qty = items[box.getAttribute('data-qty')] || 0; + box.classList.toggle('vino-card__qty--active', qty > 0); + var out = box.querySelector('.vino-card__count'); + if (out) out.textContent = qty || 1; + }); + counters(total()); + } + + function apply(data, sent) { + if (!data || !data.items || sent !== version) return; + items = {}; + Object.keys(data.items).forEach(function (id) { items[id] = data.items[id]; }); + render(); + } + + function load() { + var sent = version; + BX.ajax.runAction('jinove:vinoteca.basket.state', { method: 'GET' }) + .then(function (res) { apply(res.data, sent); }, function () {}); + } + + function send(id) { + var sent = version; + BX.ajax.runAction('jinove:vinoteca.basket.set', { data: { id: id, qty: items[id] || 0 } }) + .then(function (res) { apply(res.data, sent); }, function () { if (sent === version) load(); }); + } + + document.addEventListener('click', function (e) { + var step = e.target.closest('[data-qty-step]'); + if (!step) return; + var box = step.closest('[data-qty]'); + if (!box) return; + e.preventDefault(); + var id = box.getAttribute('data-qty'); + var qty = Math.max(0, Math.min(max, (items[id] || 0) + parseInt(step.getAttribute('data-qty-step'), 10))); + if (qty) items[id] = qty; else delete items[id]; + version++; + render(); + clearTimeout(timers[id]); + timers[id] = setTimeout(function () { send(id); }, 350); + }); + + document.addEventListener('click', function (e) { + var b = e.target.closest('[data-add-cart]'); + if (!b) return; + e.preventDefault(); + var id = b.getAttribute('data-add-cart'); + if (!id || b.disabled) return; + var qty = 1; + var box = b.closest('.vino-pdp__buy') || b.closest('.vino-pdp__cart') || document; + var out = box.querySelector('[data-stepper] output'); + if (out) { + var q = parseInt(out.textContent, 10); + if (q > 0) qty = q; + } + items[id] = Math.min(max, (items[id] || 0) + qty); + version++; + render(); + clearTimeout(timers[id]); + timers[id] = setTimeout(function () { send(id); }, 350); + }); + + function boot() { + if (!window.VinoState) return load(); + var sent = version; + VinoState.first('basket').then(function (res) { apply(res.data, sent); }, load); + } + + boot(); + document.addEventListener('vino:content', render); + document.addEventListener('vino:basket', function (e) { + version++; + apply(e.detail, version); + }); +})(); diff --git a/local/templates/jinove_wine/assets/js/vino-compare.js b/local/templates/jinove_wine/assets/js/vino-compare.js new file mode 100644 index 0000000..0931ed9 --- /dev/null +++ b/local/templates/jinove_wine/assets/js/vino-compare.js @@ -0,0 +1,103 @@ +(function () { + if (!window.BX || !BX.ajax || !BX.ajax.runAction) return; + var cfg = {}; + try { cfg = JSON.parse(document.getElementById('vino-config').textContent); } catch (e) {} + var text = cfg.text || {}; + var MAX = cfg.compareLimit; + var items = []; + var timers = {}; + var version = 0; + var toast = null; + + function render() { + document.querySelectorAll('[data-compare-count]').forEach(function (counter) { + counter.textContent = items.length; + counter.hidden = !items.length; + }); + document.querySelectorAll('[data-compare-toggle]').forEach(function (button) { + var on = items.indexOf(Number(button.getAttribute('data-compare-toggle'))) >= 0; + var label = on ? text.compareRemove : text.compareAdd; + button.classList.toggle(button.classList[0] + '--active', on); + button.setAttribute('aria-pressed', on ? 'true' : 'false'); + button.setAttribute('aria-label', label || ''); + button.title = label || ''; + }); + } + + function say(message, link) { + if (!toast) { + toast = document.createElement('div'); + toast.className = 'vino-toast'; + toast.setAttribute('role', 'status'); + document.body.appendChild(toast); + } + toast.textContent = message; + var anchor = document.createElement('a'); + anchor.className = 'vino-toast__link'; + anchor.href = link.href; + anchor.textContent = link.label; + toast.appendChild(anchor); + toast.classList.add('vino-toast--on'); + clearTimeout(toast.timer); + toast.timer = setTimeout(function () { toast.classList.remove('vino-toast--on'); }, 3500); + } + + function warnFull() { + say((text.compareMax || '').replace('#N#', MAX), { href: (cfg.siteDir || '/') + 'compare/', label: text.compareOpen || '' }); + } + + function apply(response, sent) { + if (sent !== version) return; + var data = response.data || {}; + items = data.items || []; + render(); + if (data.full) warnFull(); + } + + function load() { + var sent = version; + BX.ajax.runAction('jinove:vinoteca.compare.state', { method: 'GET' }).then(function (response) { apply(response, sent); }, function () {}); + } + + function send(id) { + var sent = ++version; + var on = items.indexOf(id) >= 0; + BX.ajax.runAction('jinove:vinoteca.compare.set', { data: { id: id, on: on ? 'Y' : 'N' } }) + .then(function (response) { apply(response, sent); }, function () { if (sent === version) load(); }); + } + + function boot() { + if (!window.VinoState) return load(); + var sent = version; + VinoState.first('compare').then(function (response) { apply(response, sent); }, load); + } + + boot(); + document.addEventListener('vino:content', render); + document.addEventListener('vino:compare', function (event) { + version++; + items = (event.detail && event.detail.items) || []; + render(); + }); + + document.addEventListener('click', function (event) { + var button = event.target.closest('[data-compare-toggle]'); + if (!button) return; + event.preventDefault(); + var id = Number(button.getAttribute('data-compare-toggle')); + var index = items.indexOf(id); + if (index >= 0) { + items.splice(index, 1); + } else { + if (items.length >= MAX) { + warnFull(); + return; + } + items.push(id); + } + version++; + render(); + clearTimeout(timers[id]); + timers[id] = setTimeout(function () { send(id); }, 350); + }); +})(); diff --git a/local/templates/jinove_wine/assets/js/vino-fav.js b/local/templates/jinove_wine/assets/js/vino-fav.js new file mode 100644 index 0000000..95b673c --- /dev/null +++ b/local/templates/jinove_wine/assets/js/vino-fav.js @@ -0,0 +1,63 @@ +(function () { + if (!window.BX || !BX.ajax || !BX.ajax.runAction) return; + var items = []; + var timers = {}; + var version = 0; + + function render() { + document.querySelectorAll('[data-fav-count]').forEach(function (counter) { + counter.textContent = items.length > 99 ? '99+' : items.length; + counter.hidden = !items.length; + }); + document.querySelectorAll('[data-fav-toggle]').forEach(function (button) { + var on = items.indexOf(Number(button.getAttribute('data-fav-toggle'))) >= 0; + button.classList.toggle(button.classList[0] + '--active', on); + button.setAttribute('aria-pressed', on ? 'true' : 'false'); + }); + } + + function apply(response, sent) { + if (sent !== version) return; + items = (response.data && response.data.items) || []; + render(); + } + + function load() { + var sent = version; + BX.ajax.runAction('jinove:vinoteca.favorite.state', { method: 'GET' }).then(function (response) { apply(response, sent); }, function () {}); + } + + function send(id) { + var sent = ++version; + var on = items.indexOf(id) >= 0; + BX.ajax.runAction('jinove:vinoteca.favorite.set', { data: { id: id, on: on ? 'Y' : 'N' } }) + .then(function (response) { apply(response, sent); }, function () { if (sent === version) load(); }); + } + + function boot() { + if (!window.VinoState) return load(); + var sent = version; + VinoState.first('favorite').then(function (response) { apply(response, sent); }, load); + } + + boot(); + document.addEventListener('vino:content', render); + document.addEventListener('vino:favorite', function (event) { + version++; + items = (event.detail && event.detail.items) || []; + render(); + }); + + document.addEventListener('click', function (event) { + var button = event.target.closest('[data-fav-toggle]'); + if (!button) return; + event.preventDefault(); + var id = Number(button.getAttribute('data-fav-toggle')); + var index = items.indexOf(id); + if (index >= 0) items.splice(index, 1); else items.push(id); + version++; + render(); + clearTimeout(timers[id]); + timers[id] = setTimeout(function () { send(id); }, 350); + }); +})(); diff --git a/local/templates/jinove_wine/assets/js/vino-favorites.js b/local/templates/jinove_wine/assets/js/vino-favorites.js new file mode 100644 index 0000000..9681ca5 --- /dev/null +++ b/local/templates/jinove_wine/assets/js/vino-favorites.js @@ -0,0 +1,33 @@ +(function (run) { + if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', run); + else run(); +})(function () { + var root = document.querySelector('[data-favorites]'); + if (!root || !window.BX || !BX.ajax || !BX.ajax.runAction) return; + var status = root.querySelector('[data-favorites-status]'); + document.addEventListener('click', function (event) { + var button = event.target.closest('[data-favorites] [data-fav-toggle]'); + if (!button) return; + event.preventDefault(); + event.stopImmediatePropagation(); + var card = button.closest('.vino-card'); + if (!card) return; + var parent = card.parentNode; + var next = card.nextSibling; + var neighbour = card.nextElementSibling || card.previousElementSibling; + card.remove(); + if (status) status.textContent = root.getAttribute('data-favorites-removed') || ''; + var focus = (neighbour && neighbour.querySelector('.vino-card__link')) || document.querySelector('h1'); + if (focus) { + if (focus.tagName === 'H1') focus.setAttribute('tabindex', '-1'); + focus.focus(); + } + BX.ajax.runAction('jinove:vinoteca.favorite.set', { data: { id: button.getAttribute('data-fav-toggle'), on: 'N' } }).then(function (response) { + document.dispatchEvent(new CustomEvent('vino:favorite', { detail: response.data })); + if (!root.querySelector('.vino-card')) window.location.href = window.location.pathname; + }, function () { + parent.insertBefore(card, next); + if (status) status.textContent = ''; + }); + }, true); +}); diff --git a/local/templates/jinove_wine/assets/js/vino-gate.js b/local/templates/jinove_wine/assets/js/vino-gate.js new file mode 100644 index 0000000..44ad68e --- /dev/null +++ b/local/templates/jinove_wine/assets/js/vino-gate.js @@ -0,0 +1,104 @@ +(function (run) { + if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', run); + else run(); +})(function () { +(function () { + var AGE_KEY = 'vino-age-ok'; + var BAR_KEY = 'vino-cookie-ok'; + var bar = document.querySelector('[data-cookie-bar]'); + var gate = document.querySelector('[data-age-gate]'); + + function stored(key) { + try { return localStorage.getItem(key) === '1'; } catch (e) { return false; } + } + function store(key) { + try { localStorage.setItem(key, '1'); } catch (e) {} + } + function choice() { + try { return localStorage.getItem(BAR_KEY) || ''; } catch (e) { return ''; } + } + function choose(value) { + try { localStorage.setItem(BAR_KEY, value); } catch (e) {} + } + + function notify() { + document.dispatchEvent(new CustomEvent('vino:consent')); + } + + window.VinoConsent = { + allowed: function () { + var value = choice(); + return value === 'accept' || value === '1'; + }, + accept: function () { + if (bar) answer('accept'); + else { + choose('accept'); + notify(); + } + } + }; + + function showBar() { + if (!bar || choice()) return; + bar.hidden = false; + void bar.offsetWidth; + bar.classList.add('vino-cookie--on'); + } + + function answer(value) { + choose(value); + notify(); + bar.classList.remove('vino-cookie--on'); + setTimeout(function () { bar.hidden = true; }, 300); + } + + if (bar) { + var ok = bar.querySelector('[data-cookie-ok]'); + var decline = bar.querySelector('[data-cookie-decline]'); + if (ok) ok.addEventListener('click', function () { answer('accept'); }); + if (decline) decline.addEventListener('click', function () { answer('decline'); }); + document.addEventListener('click', function (e) { + if (!e.target.closest('[data-cookie-settings]')) return; + try { localStorage.removeItem(BAR_KEY); } catch (err) {} + showBar(); + }); + } + + if (!gate || stored(AGE_KEY)) { + if (gate) gate.remove(); + showBar(); + return; + } + + gate.hidden = false; + document.documentElement.style.overflow = 'hidden'; + var yes = gate.querySelector('[data-age-yes]'); + var no = gate.querySelector('[data-age-no]'); + var card = gate.querySelector('.vino-age__card'); + if (card) card.focus(); + function trap(event) { + if (event.key !== 'Tab' || !yes || !no) return; + var active = document.activeElement; + if (event.shiftKey && (active === yes || active === card)) { + event.preventDefault(); + no.focus(); + } else if (!event.shiftKey && (active === no || !gate.contains(active))) { + event.preventDefault(); + yes.focus(); + } + } + document.addEventListener('keydown', trap); + if (yes) yes.addEventListener('click', function () { + store(AGE_KEY); + document.removeEventListener('keydown', trap); + document.documentElement.style.overflow = ''; + gate.classList.add('vino-age--leaving'); + setTimeout(function () { gate.remove(); }, 400); + setTimeout(showBar, 500); + }); + if (no) no.addEventListener('click', function () { + window.location.href = gate.getAttribute('data-exit') || '/'; + }); +})(); +}); diff --git a/local/templates/jinove_wine/assets/js/vino-header.js b/local/templates/jinove_wine/assets/js/vino-header.js new file mode 100644 index 0000000..f7e43f0 --- /dev/null +++ b/local/templates/jinove_wine/assets/js/vino-header.js @@ -0,0 +1,107 @@ +(function (run) { + if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', run); + else run(); +})(function () { +(function () { + var header = document.querySelector('[data-header]'); + if (header) { + var onScroll = function () { header.classList.toggle('vino-header--scrolled', window.scrollY > 20); }; + onScroll(); + window.addEventListener('scroll', onScroll, { passive: true }); + } + var toggle = document.querySelector('[data-menu-toggle]'); + var menu = document.querySelector('[data-menu]'); + if (toggle && menu) { + var setMenu = function (open) { + menu.classList.toggle('vino-nav--open', open); + toggle.setAttribute('aria-expanded', open ? 'true' : 'false'); + }; + toggle.addEventListener('click', function (e) { + e.stopPropagation(); + setMenu(!menu.classList.contains('vino-nav--open')); + }); + menu.addEventListener('click', function (e) { if (e.target.closest('a, button')) setMenu(false); }); + document.addEventListener('click', function (e) { if (!menu.contains(e.target)) setMenu(false); }); + document.addEventListener('keydown', function (e) { + if (e.key !== 'Escape' || !menu.classList.contains('vino-nav--open')) return; + setMenu(false); + toggle.focus(); + }); + } +})(); + +(function () { + var box = document.querySelector('[data-lang]'); + if (!box) return; + var btn = box.querySelector('[data-lang-toggle]'); + function set(open) { + box.setAttribute('data-open', open ? 'true' : 'false'); + btn.setAttribute('aria-expanded', open ? 'true' : 'false'); + } + btn.addEventListener('click', function (e) { + e.stopPropagation(); + set(box.getAttribute('data-open') !== 'true'); + }); + document.addEventListener('click', function (e) { if (!box.contains(e.target)) set(false); }); + document.addEventListener('keydown', function (e) { + if (e.key !== 'Escape' || box.getAttribute('data-open') !== 'true') return; + set(false); + btn.focus(); + }); +})(); + +(function () { + var root = document.querySelector('[data-search]'); + if (!root) return; + var input = root.querySelector('[data-search-input]'); + var hideTimer = 0; + var opener = null; + var openers = document.querySelectorAll('[data-search-open]'); + function focusable() { + return Array.prototype.filter.call(root.querySelectorAll('a[href], button:not([disabled]), input:not([disabled])'), function (el) { return el.offsetParent !== null; }); + } + function open(e) { + if (e) e.preventDefault(); + opener = e && e.currentTarget ? e.currentTarget : document.activeElement; + openers.forEach(function (o) { o.setAttribute('aria-expanded', 'true'); }); + clearTimeout(hideTimer); + root.hidden = false; + void root.offsetWidth; + root.classList.add('vino-search--open'); + if (input) input.focus(); + document.documentElement.style.overflow = 'hidden'; + } + function close() { + root.classList.remove('vino-search--open'); + if (input) input.value = ''; + document.dispatchEvent(new CustomEvent('vino:search-close')); + hideTimer = setTimeout(function () { root.hidden = true; }, 280); + document.documentElement.style.overflow = ''; + openers.forEach(function (o) { o.setAttribute('aria-expanded', 'false'); }); + if (opener && opener.focus) opener.focus(); + } + document.querySelectorAll('[data-search-open]').forEach(function (o) { o.addEventListener('click', open); }); + root.querySelectorAll('[data-search-close]').forEach(function (b) { b.addEventListener('click', close); }); + document.addEventListener('keydown', function (e) { + if (root.hidden) return; + if (e.key === 'Escape') { + close(); + return; + } + if (e.key !== 'Tab') return; + var items = focusable(); + if (!items.length) return; + var first = items[0], last = items[items.length - 1]; + if (e.shiftKey && document.activeElement === first) { + e.preventDefault(); + last.focus(); + } else if (!e.shiftKey && document.activeElement === last) { + e.preventDefault(); + first.focus(); + } else if (!root.contains(document.activeElement)) { + e.preventDefault(); + first.focus(); + } + }); +})(); +}); diff --git a/local/templates/jinove_wine/assets/js/vino-password.js b/local/templates/jinove_wine/assets/js/vino-password.js new file mode 100644 index 0000000..f8edd0e --- /dev/null +++ b/local/templates/jinove_wine/assets/js/vino-password.js @@ -0,0 +1,37 @@ +(function () { + function init() { + document.querySelectorAll('[data-password-toggle]').forEach(function (toggle) { + var input = document.getElementById(toggle.getAttribute('aria-controls')); + var form = toggle.closest('form'); + if (!input || !form) return; + + function sync() { + var empty = input.value === ''; + toggle.hidden = empty; + if (empty && input.type === 'text') { + input.type = 'password'; + toggle.textContent = form.dataset.labelShow; + toggle.setAttribute('aria-pressed', 'false'); + } + } + + toggle.addEventListener('click', function () { + var show = input.type === 'password'; + input.type = show ? 'text' : 'password'; + toggle.textContent = show ? form.dataset.labelHide : form.dataset.labelShow; + toggle.setAttribute('aria-pressed', show ? 'true' : 'false'); + input.focus(); + }); + ['input', 'change', 'focus'].forEach(function (name) { + input.addEventListener(name, sync); + }); + sync(); + }); + } + + if (document.readyState === 'loading') { + document.addEventListener('DOMContentLoaded', init); + } else { + init(); + } +})(); diff --git a/local/templates/jinove_wine/assets/js/vino-phone.js b/local/templates/jinove_wine/assets/js/vino-phone.js new file mode 100644 index 0000000..08dd41a --- /dev/null +++ b/local/templates/jinove_wine/assets/js/vino-phone.js @@ -0,0 +1,165 @@ +(function (run) { + if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', run); + else run(); +})(function () { +(function () { + function setup(input) { + var code = input.getAttribute('data-phone-code'); + var length = Number(input.getAttribute('data-phone-digits')); + var prefix = '+' + code + ' '; + var error = input.getAttribute('data-phone-error'); + var groups = (input.getAttribute('data-phone-groups') || '').split(',').map(Number).filter(Boolean); + var bounds = [0]; + while (bounds[bounds.length - 1] < length) { + var size = groups[bounds.length - 1] || groups[groups.length - 1] || 3; + bounds.push(Math.min(length, bounds[bounds.length - 1] + size)); + } + + function digitsOf(value) { + return value.slice(prefix.length).replace(/\D/g, ''); + } + + function validate() { + if (!error) return; + var count = digitsOf(input.value).length; + input.setCustomValidity(count !== length && (count || input.required) ? error : ''); + } + + function format(digits) { + var parts = []; + for (var i = 1; i < bounds.length && bounds[i - 1] < digits.length; i++) { + parts.push(digits.slice(bounds[i - 1], bounds[i])); + } + return prefix + parts.join(' '); + } + + function before(index) { + return bounds.filter(function (b) { return b > 0 && b < index; }).length; + } + + function positionOf(index) { + return index <= 0 ? prefix.length : prefix.length + index + before(index); + } + + function indexOf(position) { + return input.value.slice(prefix.length, Math.max(position, prefix.length)).replace(/\D/g, '').length; + } + + function render(digits, caret) { + if (caret === undefined) caret = digits.length; + input.value = format(digits); + var position = positionOf(caret); + input.setSelectionRange(position, position); + validate(); + } + + function normalize(raw) { + var digits = raw.replace(/\D/g, ''); + if (digits.length > length) { + if (digits.indexOf('00' + code) === 0) digits = digits.slice(code.length + 2); + else if (digits.indexOf(code) === 0) digits = digits.slice(code.length); + else if (code === '7' && digits.length === length + 1 && digits.charAt(0) === '8') digits = digits.slice(1); + } + return digits; + } + + function replace(text, isPaste) { + var current = digitsOf(input.value); + var start = indexOf(input.selectionStart); + var end = indexOf(input.selectionEnd); + var whole = start === 0 && end === current.length; + var room = length - current.length + (end - start); + var clean = isPaste && whole ? normalize(text) : text.replace(/\D/g, ''); + if (!isPaste && clean.length > room) { + var fixed = normalize(current.slice(0, start) + clean + current.slice(end)); + if (fixed.length <= length) { + render(fixed); + return; + } + } + if (isPaste && clean.length > room) return; + var inserted = clean.slice(0, room); + if (!inserted) return; + render(current.slice(0, start) + inserted + current.slice(end), start + inserted.length); + } + + function lower(index) { + return bounds.filter(function (b) { return b < index; }).pop() || 0; + } + + function upper(index, max) { + var next = bounds.filter(function (b) { return b > index; })[0]; + return Math.min(max, next === undefined ? max : next); + } + + function remove(type) { + var current = digitsOf(input.value); + var start = indexOf(input.selectionStart); + var end = indexOf(input.selectionEnd); + if (start === end) { + if (type.indexOf('Backward') >= 0) { + if (type.indexOf('Line') >= 0) start = 0; + else if (type.indexOf('Word') >= 0) start = lower(start); + else start = Math.max(0, start - 1); + } else if (type.indexOf('Line') >= 0) { + end = current.length; + } else if (type.indexOf('Word') >= 0) { + end = upper(end, current.length); + } else { + end = Math.min(current.length, end + 1); + } + } + render(current.slice(0, start) + current.slice(end), start); + } + + function keepCaret() { + setTimeout(function () { + if (document.activeElement !== input) return; + if (input.value.indexOf(prefix) !== 0) { + render(normalize(input.value).slice(0, length)); + return; + } + if (input.selectionStart === input.selectionEnd && input.selectionStart < prefix.length) { + input.setSelectionRange(prefix.length, prefix.length); + } + }, 0); + } + + input.addEventListener('beforeinput', function (e) { + e.preventDefault(); + if (e.inputType.indexOf('delete') === 0) remove(e.inputType); + else if (e.inputType === 'insertFromPaste' || e.inputType === 'insertFromDrop') replace(e.dataTransfer ? e.dataTransfer.getData('text/plain') : (e.data || ''), true); + else if (e.inputType.indexOf('insert') === 0 && e.data) replace(e.data, e.inputType === 'insertReplacementText'); + }); + + input.addEventListener('input', function () { + render(normalize(input.value.indexOf(prefix) === 0 ? digitsOf(input.value) : input.value).slice(0, length)); + }); + + input.addEventListener('focus', function () { + if (!input.value) render(''); + keepCaret(); + }); + + input.addEventListener('blur', function () { + if (!digitsOf(input.value)) input.value = ''; + validate(); + }); + + ['click', 'keyup', 'select'].forEach(function (type) { input.addEventListener(type, keepCaret); }); + + validate(); + + input.vinoPhone = { + value: function () { + var digits = digitsOf(input.value); + return digits ? '+' + code + digits : ''; + }, + filled: function () { return digitsOf(input.value).length > 0; }, + complete: function () { return digitsOf(input.value).length === length; } + }; + } + + document.querySelectorAll('[data-phone-code]').forEach(setup); +})(); +}); diff --git a/local/templates/jinove_wine/assets/js/vino-reveal-init.js b/local/templates/jinove_wine/assets/js/vino-reveal-init.js new file mode 100644 index 0000000..8f2a632 --- /dev/null +++ b/local/templates/jinove_wine/assets/js/vino-reveal-init.js @@ -0,0 +1,3 @@ +if ('IntersectionObserver' in window && !window.matchMedia('(prefers-reduced-motion: reduce)').matches) { + document.documentElement.classList.add('vino-reveal'); +} diff --git a/local/templates/jinove_wine/assets/js/vino-reveal.js b/local/templates/jinove_wine/assets/js/vino-reveal.js new file mode 100644 index 0000000..3d9700a --- /dev/null +++ b/local/templates/jinove_wine/assets/js/vino-reveal.js @@ -0,0 +1,28 @@ +(function (run) { + if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', run); + else run(); +})(function () { +(function () { + var root = document.documentElement; + if (!root.classList.contains('vino-reveal')) return; + var els = document.querySelectorAll('.vino-section, .vino-story, .vino-sales, .vino-footer, .vino-pdp, .vino-reviews, .vino-pdp-related, .vino-auth:not(.vino-auth--embed), .vino-cab, .vino-cart, .vino-order, .vino-done, .vino-about__panel, .vino-brand-detail, .vino-article, .vino-news-feed, .vino-offers, .vino-offer, .vino-offers-wines, .vino-showcase, .vino-showcase-shots'); + els.forEach(function (el) { + el.classList.add('vino-reveal__item'); + if (el.classList.contains('vino-section') || el.classList.contains('vino-news-feed') || el.classList.contains('vino-offers-wines')) el.classList.add('vino-reveal__item--deep'); + }); + var seen = false; + var io = new IntersectionObserver(function (list) { + seen = true; + list.forEach(function (e) { + if (e.isIntersecting) { + e.target.classList.add('vino-reveal__item--visible'); + io.unobserve(e.target); + } + }); + }, { rootMargin: '0px 0px -12% 0px' }); + els.forEach(function (el) { io.observe(el); }); + setTimeout(function () { + if (!seen) els.forEach(function (el) { el.classList.add('vino-reveal__item--visible'); }); + }, 3000); +})(); +}); diff --git a/local/templates/jinove_wine/assets/js/vino-review.js b/local/templates/jinove_wine/assets/js/vino-review.js new file mode 100644 index 0000000..4f22ff1 --- /dev/null +++ b/local/templates/jinove_wine/assets/js/vino-review.js @@ -0,0 +1,139 @@ +(function () { + var modal = document.querySelector('[data-review-modal]'); + if (!modal || !window.BX || !BX.ajax || !BX.ajax.runAction) return; + var body = modal.querySelector('[data-review-body]'); + var form = modal.querySelector('[data-review-form]'); + var done = modal.querySelector('[data-review-done]'); + var err = modal.querySelector('[data-review-err]'); + var submit = form.querySelector('[type="submit"]'); + var guard = form.querySelector('altcha-widget'); + var started = 0; + var codes = { rating: 'rating', author: 'author', text: 'text', consent: 'consent', too_often: 'tooOften', altcha: 'altcha' }; + + function visible(el) { + return !!el && el.offsetParent !== null; + } + + function focusable() { + return Array.prototype.filter.call(modal.querySelectorAll('a[href], button:not([disabled]), input:not([disabled]):not([type="hidden"]), textarea:not([disabled]), select:not([disabled])'), function (el) { + return el.tabIndex >= 0 && visible(el); + }); + } + + function say(message) { + err.textContent = message || ''; + err.hidden = !message; + } + + function mark(field, bad) { + if (!field) return; + field.classList.toggle('vino-inp--invalid', bad); + if (bad) field.setAttribute('aria-invalid', 'true'); + else field.removeAttribute('aria-invalid'); + } + + function open() { + body.hidden = false; + done.hidden = true; + say(''); + started = Date.now(); + VinoAltcha.arm(guard); + modal.showModal(); + var heading = visible(modal.querySelector('.vino-review-user')) ? modal.querySelector('#vino-review-title') : modal.querySelector('.vino-auth__title'); + if (heading) { + if (!heading.id) heading.id = 'vino-auth-title'; + modal.setAttribute('aria-labelledby', heading.id); + } + setTimeout(function () { + var list = focusable(); + var first = form.querySelector('.vino-rate__input:checked'); + if (!first || !visible(first)) first = list[0]; + if (first) first.focus(); + }, 30); + } + + function close() { + modal.close(); + } + + function check() { + var f = form.elements; + var problems = []; + var rated = !!form.querySelector('.vino-rate__input:checked'); + form.querySelector('.vino-rate').classList.toggle('vino-rate--invalid', !rated); + if (!rated) problems.push('rating'); + var text = f.text.value.trim(); + mark(f.text, text.length < 10); + if (text.length < 10) problems.push('text'); + mark(f.consent, !f.consent.checked); + if (!f.consent.checked) problems.push('consent'); + return problems; + } + + function message(code) { + var key = codes[code] || 'error'; + return form.dataset['msg' + key.charAt(0).toUpperCase() + key.slice(1)] || form.dataset.msgError; + } + + form.addEventListener('submit', function (event) { + event.preventDefault(); + var problems = check(); + if (problems.length) { + say(message(problems[0])); + return; + } + say(''); + submit.disabled = true; + var f = form.elements; + var data = { + productId: form.dataset.product, + rating: form.querySelector('.vino-rate__input:checked').value, + text: f.text.value.trim(), + consent: f.consent.checked ? '1' : '', + website: f.website.value, + started: String(started), + lang: document.documentElement.lang || 'en', + page: window.location.href + }; + VinoAltcha.armed(guard) + .then(function (ok) { + if (!ok) return Promise.reject({ errors: [{ code: 'altcha' }] }); + data.altcha = f.altcha ? f.altcha.value : ''; + return BX.ajax.runAction('jinove:vinoteca.review.add', { data: data }); + }) + .then(function () { + submit.disabled = false; + form.reset(); + if (guard && typeof guard.reset === 'function') guard.reset(); + body.hidden = true; + done.hidden = false; + done.focus(); + }, function (res) { + submit.disabled = false; + VinoAltcha.reset(guard); + var code = res && res.errors && res.errors[0] ? res.errors[0].code : ''; + say(message(code)); + }); + }); + + form.addEventListener('input', function (event) { + if (event.target.classList.contains('vino-inp--invalid')) mark(event.target, false); + if (event.target.classList.contains('vino-rate__input')) form.querySelector('.vino-rate').classList.remove('vino-rate--invalid'); + }); + + document.addEventListener('click', function (event) { + if (event.target.closest('[data-review-open]')) { + event.preventDefault(); + open(); + return; + } + if (modal.open && (event.target === modal || event.target.closest('[data-review-close]'))) close(); + }); + + try { + if (sessionStorage.getItem('vinoOpenReview') === '1') { + sessionStorage.removeItem('vinoOpenReview'); + open(); + } + } catch (e) {} +})(); diff --git a/local/templates/jinove_wine/assets/js/vino-shots.js b/local/templates/jinove_wine/assets/js/vino-shots.js new file mode 100644 index 0000000..9024881 --- /dev/null +++ b/local/templates/jinove_wine/assets/js/vino-shots.js @@ -0,0 +1,36 @@ +(function () { + function init() { + var list = document.querySelector('[data-shots]'); + if (!list || !window.PhotoSwipe) return; + var texts = {}; + try { texts = JSON.parse(list.getAttribute('data-viewer') || '{}'); } catch (e) {} + var links = Array.prototype.slice.call(list.querySelectorAll('[data-shots-item]')); + var items = links.map(function (link) { + var img = link.querySelector('img'); + return { + src: link.getAttribute('href'), + width: Number(link.getAttribute('data-width')), + height: Number(link.getAttribute('data-height')), + alt: img ? img.alt : '' + }; + }); + links.forEach(function (link, index) { + link.addEventListener('click', function (event) { + if (event.ctrlKey || event.metaKey || event.shiftKey || event.button !== 0) return; + event.preventDefault(); + new window.PhotoSwipe(Object.assign({ + dataSource: items, + index: index, + bgOpacity: 0.94, + wheelToZoom: true, + paddingFn: function (viewport) { + var side = viewport.x < 760 ? 0 : 88; + return { top: 64, bottom: viewport.x < 760 ? 16 : 40, left: side, right: side }; + } + }, texts)).init(); + }); + }); + } + if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', init); + else init(); +})(); diff --git a/local/templates/jinove_wine/assets/js/vino-slider.js b/local/templates/jinove_wine/assets/js/vino-slider.js new file mode 100644 index 0000000..14c0b8d --- /dev/null +++ b/local/templates/jinove_wine/assets/js/vino-slider.js @@ -0,0 +1,86 @@ +(function (run) { + if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', run); + else run(); +})(function () { +(function () { + function dots(track, box) { + var items = box.querySelectorAll('.vino-dots__dot'), cur = 0; + if (!items.length) return null; + items.forEach(function (dot, i) { + dot.addEventListener('click', function () { + track.scrollTo({ left: i * track.clientWidth, behavior: 'smooth' }); + }); + }); + return function () { + var w = track.clientWidth; + if (!w) return; + var i = Math.max(0, Math.min(items.length - 1, Math.round(track.scrollLeft / w))); + if (i === cur) return; + items[cur].classList.remove('vino-dots__dot--active'); + items[cur].removeAttribute('aria-current'); + items[i].classList.add('vino-dots__dot--active'); + items[i].setAttribute('aria-current', 'true'); + cur = i; + }; + } + function progress(track, box) { + var bar = box.querySelector('.vino-progress__bar'); + if (!bar) return null; + return function () { + var total = track.scrollWidth, view = track.clientWidth; + if (!total || !view) return; + var size = Math.min(1, view / total), max = total - view; + bar.style.setProperty('--vino-progress-width', (size * 100) + '%'); + bar.style.setProperty('--vino-progress-shift', (max > 0 ? (track.scrollLeft / max) * (1 / size - 1) * 100 : 0) + '%'); + }; + } + function init(track) { + var name = track.getAttribute('data-slider'), handlers = []; + var dotsBox = document.querySelector('[data-slider-dots="' + name + '"]'); + var barBox = document.querySelector('[data-slider-progress="' + name + '"]'); + if (dotsBox) handlers.push(dots(track, dotsBox)); + if (barBox) handlers.push(progress(track, barBox)); + handlers = handlers.filter(Boolean); + if (!handlers.length) return; + function update() { handlers.forEach(function (fn) { fn(); }); } + track.addEventListener('scroll', update, { passive: true }); + window.addEventListener('resize', update); + update(); + } + function arrows(viewport, prev, next) { + if (!viewport) return; + function step() { + var card = viewport.querySelector('.vino-card'); + if (!card) return 300; + var gap = parseFloat(getComputedStyle(card.parentElement).columnGap) || 0; + return (card.getBoundingClientRect().width + gap) * 2; + } + function update() { + var max = viewport.scrollWidth - viewport.clientWidth - 2; + var fits = max <= 0; + if (prev) { + prev.hidden = fits; + prev.disabled = viewport.scrollLeft <= 2; + } + if (next) { + next.hidden = fits; + next.disabled = viewport.scrollLeft >= max; + } + } + if (prev) prev.addEventListener('click', function () { viewport.scrollBy({ left: -step(), behavior: 'smooth' }); }); + if (next) next.addEventListener('click', function () { viewport.scrollBy({ left: step(), behavior: 'smooth' }); }); + viewport.addEventListener('scroll', update, { passive: true }); + window.addEventListener('resize', update); + update(); + } + document.querySelectorAll('[data-slider]').forEach(init); + document.querySelectorAll('[data-slider]').forEach(function (viewport) { + var name = viewport.getAttribute('data-slider'); + var prev = document.querySelector('[data-slider-prev="' + name + '"]'); + var next = document.querySelector('[data-slider-next="' + name + '"]'); + if (prev || next) arrows(viewport, prev, next); + }); + arrows(document.querySelector('.vino-bestsellers .vino-slider__viewport'), document.querySelector('.vino-bestsellers [data-slide-prev]'), document.querySelector('.vino-bestsellers [data-slide-next]')); + arrows(document.querySelector('.vino-new-arrivals .vino-slider__viewport'), document.querySelector('.vino-new-arrivals [data-arrivals-prev]'), document.querySelector('.vino-new-arrivals [data-arrivals-next]')); +})(); +}); diff --git a/local/templates/jinove_wine/assets/js/vino-sommelier.js b/local/templates/jinove_wine/assets/js/vino-sommelier.js new file mode 100644 index 0000000..9a924fe --- /dev/null +++ b/local/templates/jinove_wine/assets/js/vino-sommelier.js @@ -0,0 +1,118 @@ +(function (run) { + if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', run); + else run(); +})(function () { +(function () { + var m = document.querySelector('[data-sommelier]'); + if (!m) return; + var cfg = {}; + try { cfg = JSON.parse(document.getElementById('vino-config').textContent); } catch (e) {} + var text = cfg.text || {}; + var body = m.querySelector('[data-sommelier-body]'); + var form = m.querySelector('[data-sommelier-form]'); + var done = m.querySelector('[data-sommelier-done]'); + var err = m.querySelector('[data-sommelier-err]'); + var guard = form.querySelector('altcha-widget'); + + function clear(el) { + el.classList.remove('vino-inp--invalid'); + el.removeAttribute('aria-invalid'); + } + + function open() { + body.hidden = false; + done.hidden = true; + err.hidden = true; + VinoAltcha.arm(guard); + var nav = document.querySelector('[data-menu]'); + if (nav) nav.classList.remove('vino-nav--open'); + var menuToggle = document.querySelector('[data-menu-toggle]'); + if (menuToggle) menuToggle.setAttribute('aria-expanded', 'false'); + form.querySelectorAll('.vino-inp--invalid').forEach(clear); + m.showModal(); + setTimeout(function () { + var f = form.querySelector('[name="name"]'); + if (f) f.focus(); + }, 30); + } + + function close() { + m.close(); + } + + function say(msg) { + err.textContent = msg; + err.hidden = !msg; + } + + function check() { + var f = form.elements, first = '', focus = null, mask = 0; + function bad(el, msg) { + el.classList.add('vino-inp--invalid'); + el.setAttribute('aria-invalid', 'true'); + if (!focus) focus = el; + if (msg && !first) first = msg; + } + [f.name, f.phone, f.message, f.consent].forEach(clear); + var phone = f.phone.vinoPhone; + if (!f.name.value.trim()) { bad(f.name, ''); mask += 1; } + if (!phone.filled()) { bad(f.phone, ''); mask += 2; } + if (!f.message.value.trim()) { bad(f.message, ''); mask += 4; } + if (mask) first = (text.empty || [])[mask] || ''; + if (phone.filled() && !phone.complete()) bad(f.phone, text.phone); + if (!f.consent.checked) bad(f.consent, text.consent); + say(first); + if (focus) focus.focus(); + return !focus; + } + + document.addEventListener('click', function (e) { + var opener = e.target.closest('[data-sommelier-open]'); + if (opener) { + e.preventDefault(); + open(); + var note = opener.getAttribute('data-sommelier-note'); + if (note && !form.elements.message.value.trim()) form.elements.message.value = note; + return; + } + if (m.open && (e.target === m || e.target.closest('[data-sommelier-close]'))) close(); + }); + form.addEventListener('input', function (e) { clear(e.target); }); + form.addEventListener('change', function (e) { clear(e.target); }); + form.addEventListener('submit', function (e) { + e.preventDefault(); + if (!check()) return; + var b = form.querySelector('[type="submit"]'); + b.disabled = true; + VinoAltcha.armed(guard) + .then(function (ok) { + if (!ok) throw new Error('guard'); + var f = form.elements; + return BX.ajax.runAction('jinove:vinoteca.lead.question', { + data: { + name: f.name.value, + phone: f.phone.vinoPhone.value(), + message: f.message.value, + consent: f.consent.checked ? 'Y' : '', + website: f.website.value, + altcha: f.altcha ? f.altcha.value : '', + page: window.location.pathname + } + }); + }) + .then(function (res) { + if (res && res.data && res.data.ok) { + done.querySelector('[data-sommelier-phone]').textContent = form.elements.phone.value.trim(); + form.reset(); + body.hidden = true; + done.hidden = false; + done.focus(); + } else { + say(text.fail); + } + }) + .catch(function () { VinoAltcha.reset(guard); say(text.fail); }) + .then(function () { b.disabled = false; }); + }); +})(); +}); diff --git a/local/templates/jinove_wine/assets/js/vino-state.js b/local/templates/jinove_wine/assets/js/vino-state.js new file mode 100644 index 0000000..5c6d05a --- /dev/null +++ b/local/templates/jinove_wine/assets/js/vino-state.js @@ -0,0 +1,20 @@ +(function () { + if (!window.BX || !BX.ajax || !BX.ajax.runAction) return; + var pending = null; + window.VinoState = { + first: function (name) { + if (!pending) { + pending = new Promise(function (resolve) { + BX.ajax.runAction('jinove:vinoteca.state.all', { method: 'GET' }).then( + function (response) { resolve((response && response.data) || {}); }, + function () { resolve({}); } + ); + }); + } + return pending.then(function (all) { + if (!all[name]) throw new Error('state'); + return { data: all[name] }; + }); + } + }; +})(); diff --git a/local/templates/jinove_wine/assets/js/vino-subscribe.js b/local/templates/jinove_wine/assets/js/vino-subscribe.js new file mode 100644 index 0000000..273da3d --- /dev/null +++ b/local/templates/jinove_wine/assets/js/vino-subscribe.js @@ -0,0 +1,86 @@ +(function (run) { + if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', run); + else run(); +})(function () { +(function () { + var form = document.querySelector('[data-subscribe]'); + if (!form || !window.BX || !BX.ajax || !BX.ajax.runAction) return; + var cfg = {}; + try { cfg = JSON.parse(document.getElementById('vino-config').textContent); } catch (e) {} + var text = cfg.text || {}; + var done = form.parentNode.querySelector('[data-subscribe-msg]'); + var err = form.querySelector('[data-subscribe-err]'); + var guard = form.querySelector('altcha-widget'); + + function clear(el) { + el.classList.remove('vino-inp--invalid'); + el.removeAttribute('aria-invalid'); + } + + function mark(el) { + el.classList.add('vino-inp--invalid'); + el.setAttribute('aria-invalid', 'true'); + } + + function say(msg) { + err.textContent = msg; + err.hidden = !msg; + } + + form.addEventListener('focusin', function () { VinoAltcha.arm(guard); }, { once: true }); + form.addEventListener('input', function (e) { clear(e.target); say(''); }); + form.addEventListener('change', function (e) { clear(e.target); say(''); }); + + form.addEventListener('submit', function (e) { + e.preventDefault(); + var f = form.elements, focus = null, msg = ''; + [f.email, f.consent].forEach(clear); + if (!f.email.value.trim() || !f.email.checkValidity()) { + mark(f.email); + focus = f.email; + msg = form.getAttribute('data-error'); + } + if (!f.consent.checked) { + mark(f.consent); + if (!focus) focus = f.consent; + if (!msg) msg = text.consent; + } + say(msg); + if (focus) { + focus.focus(); + return; + } + var button = form.querySelector('[type="submit"]'); + button.disabled = true; + VinoAltcha.arm(guard); + VinoAltcha.armed(guard) + .then(function (verified) { + if (!verified) throw new Error('guard'); + return BX.ajax.runAction('jinove:vinoteca.lead.subscribe', { + data: { + email: f.email.value, + consent: 'Y', + website: f.website.value, + altcha: f.altcha ? f.altcha.value : '', + page: window.location.pathname + } + }); + }) + .then(function (res) { + if (res && res.data && res.data.ok) { + form.hidden = true; + done.textContent = form.getAttribute('data-ok'); + done.hidden = false; + } else { + say(text.fail); + } + }) + .catch(function (res) { + VinoAltcha.reset(guard); + var code = res && res.errors && res.errors[0] ? res.errors[0].code : ''; + say(code === 'email' ? form.getAttribute('data-error') : code === 'consent' ? text.consent : text.fail); + }) + .then(function () { button.disabled = false; }); + }); +})(); +}); diff --git a/local/templates/jinove_wine/assets/map/vinoteca-dark.json b/local/templates/jinove_wine/assets/map/vinoteca-dark.json new file mode 100644 index 0000000..ec9b71b --- /dev/null +++ b/local/templates/jinove_wine/assets/map/vinoteca-dark.json @@ -0,0 +1 @@ +{"version":8,"sources":{"openmaptiles":{"type":"vector","url":"https://tiles.openfreemap.org/planet"}},"sprite":"https://tiles.openfreemap.org/sprites/ofm_f384/ofm","glyphs":"https://tiles.openfreemap.org/fonts/{fontstack}/{range}.pbf","layers":[{"id":"background","type":"background","paint":{"background-color":"#2a0b17"}},{"id":"water","type":"fill","source":"openmaptiles","source-layer":"water","filter":["all",["match",["geometry-type"],["MultiPolygon","Polygon"],true,false],["!=",["get","brunnel"],"tunnel"]],"paint":{"fill-antialias":false,"fill-color":"#16060d"}},{"id":"landcover_ice_shelf","type":"fill","source":"openmaptiles","source-layer":"landcover","maxzoom":8,"filter":["all",["match",["geometry-type"],["MultiPolygon","Polygon"],true,false],["==",["get","subclass"],"ice_shelf"]],"paint":{"fill-color":"#2a0b17","fill-opacity":0.7}},{"id":"landcover_glacier","type":"fill","source":"openmaptiles","source-layer":"landcover","maxzoom":8,"filter":["all",["match",["geometry-type"],["MultiPolygon","Polygon"],true,false],["==",["get","subclass"],"glacier"]],"paint":{"fill-color":"#2a0b17","fill-opacity":["interpolate",["linear"],["zoom"],0,1,8,0.5]}},{"id":"landuse_residential","type":"fill","source":"openmaptiles","source-layer":"landuse","maxzoom":9,"filter":["all",["match",["geometry-type"],["MultiPolygon","Polygon"],true,false],["==",["get","class"],"residential"]],"paint":{"fill-color":"#2f0f1c","fill-opacity":0.4}},{"id":"landcover_wood","type":"fill","source":"openmaptiles","source-layer":"landcover","minzoom":10,"filter":["all",["match",["geometry-type"],["MultiPolygon","Polygon"],true,false],["==",["get","class"],"wood"]],"paint":{"fill-color":"#361322","fill-opacity":["interpolate",["exponential",0.3],["zoom"],8,0,10,0.8,13,0.4],"fill-pattern":"wood-pattern","fill-translate":[0,0]}},{"id":"landuse_park","type":"fill","source":"openmaptiles","source-layer":"landuse","filter":["all",["match",["geometry-type"],["MultiPolygon","Polygon"],true,false],["==",["get","class"],"park"]],"paint":{"fill-color":"#361322"}},{"id":"waterway","type":"line","source":"openmaptiles","source-layer":"waterway","filter":["match",["geometry-type"],["LineString","MultiLineString"],true,false],"paint":{"line-color":"#16060d"}},{"id":"water_name","type":"symbol","source":"openmaptiles","source-layer":"water_name","filter":["match",["geometry-type"],["LineString","MultiLineString"],true,false],"layout":{"symbol-placement":"line","symbol-spacing":500,"text-field":["case",["has","name:nonlatin"],["concat",["get","name:latin"],"\n",["get","name:nonlatin"]],["coalesce",["get","name_en"],["get","name"]]],"text-font":["Noto Sans Regular"],"text-rotation-alignment":"map","text-size":12},"paint":{"text-color":"#dcc3b4","text-halo-color":"#2a0b17","text-halo-width":1.2}},{"id":"building","type":"fill","source":"openmaptiles","source-layer":"building","minzoom":12,"filter":["match",["geometry-type"],["MultiPolygon","Polygon"],true,false],"paint":{"fill-antialias":true,"fill-color":"#401829","fill-outline-color":"rgb(27 ,27 ,29)"}},{"id":"road_area_pier","type":"fill","source":"openmaptiles","source-layer":"transportation","filter":["all",["match",["geometry-type"],["MultiPolygon","Polygon"],true,false],["==",["get","class"],"pier"]],"paint":{"fill-antialias":true,"fill-color":"#2a0b17"}},{"id":"road_pier","type":"line","source":"openmaptiles","source-layer":"transportation","filter":["all",["match",["geometry-type"],["LineString","MultiLineString"],true,false],["match",["get","class"],["pier"],true,false]],"layout":{"line-cap":"round","line-join":"round"},"paint":{"line-width":["interpolate",["exponential",1.2],["zoom"],15,1,17,4],"line-color":"#2a0b17"}},{"id":"highway_path","type":"line","source":"openmaptiles","source-layer":"transportation","filter":["all",["match",["geometry-type"],["LineString","MultiLineString"],true,false],["==",["get","class"],"path"]],"layout":{"line-cap":"round","line-join":"round"},"paint":{"line-dasharray":[1.5,1.5],"line-opacity":0.9,"line-width":["interpolate",["exponential",1.2],["zoom"],13,1,20,10],"line-color":"#4d2133"}},{"id":"highway_minor","type":"line","source":"openmaptiles","source-layer":"transportation","minzoom":8,"filter":["all",["match",["geometry-type"],["LineString","MultiLineString"],true,false],["match",["get","class"],["minor","service","track"],true,false]],"layout":{"line-cap":"round","line-join":"round"},"paint":{"line-opacity":0.9,"line-width":["interpolate",["exponential",1.55],["zoom"],13,1.8,20,20],"line-color":"#4d2133"}},{"id":"highway_major_casing","type":"line","source":"openmaptiles","source-layer":"transportation","minzoom":11,"filter":["all",["match",["geometry-type"],["LineString","MultiLineString"],true,false],["match",["get","class"],["primary","secondary","tertiary","trunk"],true,false]],"layout":{"line-cap":"butt","line-join":"miter"},"paint":{"line-dasharray":[12,0],"line-width":["interpolate",["exponential",1.3],["zoom"],10,3,20,23],"line-color":"rgba(10,3,6,0.55)"}},{"id":"highway_major_inner","type":"line","source":"openmaptiles","source-layer":"transportation","minzoom":11,"filter":["all",["match",["geometry-type"],["LineString","MultiLineString"],true,false],["match",["get","class"],["primary","secondary","tertiary","trunk"],true,false]],"layout":{"line-cap":"round","line-join":"round"},"paint":{"line-width":["interpolate",["exponential",1.3],["zoom"],10,2,20,20],"line-color":"#9a7360"}},{"id":"highway_major_subtle","type":"line","source":"openmaptiles","source-layer":"transportation","minzoom":6,"maxzoom":11,"filter":["all",["match",["geometry-type"],["LineString","MultiLineString"],true,false],["match",["get","class"],["primary","secondary","tertiary","trunk"],true,false]],"layout":{"line-cap":"round","line-join":"round"},"paint":{"line-width":["interpolate",["linear"],["zoom"],6,0,8,2],"line-color":"#9a7360"}},{"id":"highway_motorway_casing","type":"line","source":"openmaptiles","source-layer":"transportation","minzoom":6,"filter":["all",["match",["geometry-type"],["LineString","MultiLineString"],true,false],["==",["get","class"],"motorway"]],"layout":{"line-cap":"butt","line-join":"miter"},"paint":{"line-dasharray":[2,0],"line-opacity":1,"line-width":["interpolate",["exponential",1.4],["zoom"],5.8,0,6,3,20,40],"line-color":"rgba(10,3,6,0.55)"}},{"id":"highway_motorway_inner","type":"line","source":"openmaptiles","source-layer":"transportation","minzoom":6,"filter":["all",["match",["geometry-type"],["LineString","MultiLineString"],true,false],["==",["get","class"],"motorway"]],"layout":{"line-cap":"round","line-join":"round"},"paint":{"line-width":["interpolate",["exponential",1.4],["zoom"],4,2,6,1.3,20,30],"line-color":"#c9a96a"}},{"id":"road_oneway","type":"symbol","source":"openmaptiles","source-layer":"transportation","minzoom":15,"filter":["==",["get","oneway"],1],"layout":{"icon-image":"oneway","icon-padding":2,"icon-rotate":0,"icon-rotation-alignment":"map","icon-size":["interpolate",["linear"],["zoom"],15,0.5,19,1],"symbol-placement":"line","symbol-spacing":200},"paint":{"icon-opacity":0.5,"text-color":"#dcc3b4","text-halo-color":"#2a0b17","text-halo-width":1.2}},{"id":"road_oneway_opposite","type":"symbol","source":"openmaptiles","source-layer":"transportation","minzoom":15,"filter":["==",["get","oneway"],-1],"layout":{"icon-image":"oneway","icon-padding":2,"icon-rotate":180,"icon-rotation-alignment":"map","icon-size":["interpolate",["linear"],["zoom"],15,0.5,19,1],"symbol-placement":"line","symbol-spacing":200},"paint":{"icon-opacity":0.5,"text-color":"#dcc3b4","text-halo-color":"#2a0b17","text-halo-width":1.2}},{"id":"highway_motorway_subtle","type":"line","source":"openmaptiles","source-layer":"transportation","maxzoom":6,"filter":["all",["match",["geometry-type"],["LineString","MultiLineString"],true,false],["==",["get","class"],"motorway"]],"layout":{"line-cap":"round","line-join":"round"},"paint":{"line-width":["interpolate",["exponential",1.4],["zoom"],4,2,6,1.3],"line-color":"#4d2133"}},{"id":"railway_transit","type":"line","source":"openmaptiles","source-layer":"transportation","minzoom":16,"filter":["all",["match",["geometry-type"],["LineString","MultiLineString"],true,false],["all",["==",["get","class"],"transit"],["match",["get","brunnel"],["tunnel"],false,true]]],"layout":{"line-join":"round"},"paint":{"line-width":3,"line-color":"#4d2133"}},{"id":"railway_transit_dashline","type":"line","source":"openmaptiles","source-layer":"transportation","minzoom":16,"filter":["all",["match",["geometry-type"],["LineString","MultiLineString"],true,false],["all",["==",["get","class"],"transit"],["match",["get","brunnel"],["tunnel"],false,true]]],"layout":{"line-join":"round"},"paint":{"line-dasharray":[3,3],"line-width":2,"line-color":"#4d2133"}},{"id":"railway_minor","type":"line","source":"openmaptiles","source-layer":"transportation","minzoom":16,"filter":["all",["match",["geometry-type"],["LineString","MultiLineString"],true,false],["all",["==",["get","class"],"rail"],["has","service"]]],"layout":{"line-join":"round"},"paint":{"line-width":3,"line-color":"#4d2133"}},{"id":"railway_minor_dashline","type":"line","source":"openmaptiles","source-layer":"transportation","minzoom":16,"filter":["all",["match",["geometry-type"],["LineString","MultiLineString"],true,false],["all",["==",["get","class"],"rail"],["has","service"]]],"layout":{"line-join":"round"},"paint":{"line-dasharray":[3,3],"line-width":2,"line-color":"#4d2133"}},{"id":"railway","type":"line","source":"openmaptiles","source-layer":"transportation","minzoom":13,"filter":["all",["match",["geometry-type"],["LineString","MultiLineString"],true,false],["==",["get","class"],"rail"],["!",["has","service"]]],"layout":{"line-join":"round"},"paint":{"line-width":["interpolate",["exponential",1.3],["zoom"],16,3,20,7],"line-color":"#4d2133"}},{"id":"railway_dashline","type":"line","source":"openmaptiles","source-layer":"transportation","minzoom":13,"filter":["all",["match",["geometry-type"],["LineString","MultiLineString"],true,false],["==",["get","class"],"rail"],["!",["has","service"]]],"layout":{"line-join":"round"},"paint":{"line-dasharray":[3,3],"line-width":["interpolate",["exponential",1.3],["zoom"],16,2,20,6],"line-color":"#4d2133"}},{"id":"highway_name_other","type":"symbol","source":"openmaptiles","source-layer":"transportation_name","filter":["all",["!=",["get","class"],"motorway"],["match",["geometry-type"],["LineString","MultiLineString"],true,false]],"layout":{"symbol-placement":"line","symbol-spacing":350,"text-field":["case",["has","name:nonlatin"],["concat",["get","name:latin"]," ",["get","name:nonlatin"]],["coalesce",["get","name_en"],["get","name"]]],"text-font":["Noto Sans Regular"],"text-max-angle":30,"text-pitch-alignment":"viewport","text-rotation-alignment":"map","text-size":10,"text-transform":"uppercase"},"paint":{"text-color":"#dcc3b4","text-halo-blur":0,"text-halo-color":"#2a0b17","text-halo-width":1.2,"text-translate":[0,0]}},{"id":"highway_name_motorway","type":"symbol","source":"openmaptiles","source-layer":"transportation_name","filter":["all",["match",["geometry-type"],["LineString","MultiLineString"],true,false],["==",["get","class"],"motorway"]],"layout":{"symbol-placement":"line","symbol-spacing":350,"text-field":["to-string",["get","ref"]],"text-font":["Noto Sans Regular"],"text-pitch-alignment":"viewport","text-rotation-alignment":"viewport","text-size":10},"paint":{"text-color":"#dcc3b4","text-translate":[0,2],"text-halo-color":"#2a0b17","text-halo-width":1.2}},{"id":"boundary_state","type":"line","source":"openmaptiles","source-layer":"boundary","filter":["==",["get","admin_level"],4],"layout":{"line-cap":"round","line-join":"round"},"paint":{"line-blur":0.4,"line-dasharray":[2,2],"line-opacity":1,"line-width":["interpolate",["exponential",1.3],["zoom"],3,1,22,15],"line-color":"rgba(201,169,106,0.32)"}},{"id":"boundary_country_z0-4","type":"line","source":"openmaptiles","source-layer":"boundary","maxzoom":5,"filter":["all",["==",["get","admin_level"],2],["!",["has","claimed_by"]]],"layout":{"line-cap":"round","line-join":"round"},"paint":{"line-blur":["interpolate",["linear"],["zoom"],0,0.4,22,4],"line-opacity":1,"line-width":["interpolate",["exponential",1.1],["zoom"],3,1,22,20],"line-color":"rgba(201,169,106,0.32)"}},{"id":"boundary_country_z5-","type":"line","source":"openmaptiles","source-layer":"boundary","minzoom":5,"filter":["==",["get","admin_level"],2],"layout":{"line-cap":"round","line-join":"round"},"paint":{"line-blur":["interpolate",["linear"],["zoom"],0,0.4,22,4],"line-opacity":1,"line-width":["interpolate",["exponential",1.1],["zoom"],3,1,22,20],"line-color":"rgba(201,169,106,0.32)"}},{"id":"place_other","type":"symbol","source":"openmaptiles","source-layer":"place","maxzoom":14,"filter":["all",["match",["geometry-type"],["MultiPoint","Point"],true,false],["match",["get","class"],["hamlet","isolated_dwelling","neighbourhood"],true,false]],"layout":{"text-anchor":"center","text-field":["case",["has","name:nonlatin"],["concat",["get","name:latin"],"\n",["get","name:nonlatin"]],["coalesce",["get","name_en"],["get","name"]]],"text-font":["Noto Sans Regular"],"text-justify":"center","text-offset":[0.5,0],"text-size":10,"text-transform":"uppercase"},"paint":{"text-color":"#f3e6d2","text-halo-blur":1,"text-halo-color":"#2a0b17","text-halo-width":1.2}},{"id":"place_suburb","type":"symbol","source":"openmaptiles","source-layer":"place","maxzoom":15,"filter":["all",["match",["geometry-type"],["MultiPoint","Point"],true,false],["==",["get","class"],"suburb"]],"layout":{"text-anchor":"center","text-field":["case",["has","name:nonlatin"],["concat",["get","name:latin"],"\n",["get","name:nonlatin"]],["coalesce",["get","name_en"],["get","name"]]],"text-font":["Noto Sans Regular"],"text-justify":"center","text-offset":[0.5,0],"text-size":10,"text-transform":"uppercase"},"paint":{"text-color":"#f3e6d2","text-halo-blur":1,"text-halo-color":"#2a0b17","text-halo-width":1.2}},{"id":"place_village","type":"symbol","source":"openmaptiles","source-layer":"place","maxzoom":14,"filter":["all",["match",["geometry-type"],["MultiPoint","Point"],true,false],["==",["get","class"],"village"]],"layout":{"icon-size":0.4,"text-anchor":"left","text-field":["case",["has","name:nonlatin"],["concat",["get","name:latin"],"\n",["get","name:nonlatin"]],["coalesce",["get","name_en"],["get","name"]]],"text-font":["Noto Sans Regular"],"text-justify":"left","text-offset":[0.5,0.2],"text-size":10,"text-transform":"uppercase"},"paint":{"icon-opacity":0.7,"text-color":"#f3e6d2","text-halo-blur":1,"text-halo-color":"#2a0b17","text-halo-width":1.2}},{"id":"place_town","type":"symbol","source":"openmaptiles","source-layer":"place","maxzoom":15,"filter":["all",["match",["geometry-type"],["MultiPoint","Point"],true,false],["==",["get","class"],"town"]],"layout":{"icon-image":["step",["zoom"],"circle-11",9,""],"icon-size":0.4,"text-anchor":["step",["zoom"],"left",8,"center"],"text-field":["case",["has","name:nonlatin"],["concat",["get","name:latin"],"\n",["get","name:nonlatin"]],["coalesce",["get","name_en"],["get","name"]]],"text-font":["Noto Sans Regular"],"text-justify":"left","text-offset":[0.5,0.2],"text-size":10,"text-transform":"uppercase"},"paint":{"icon-opacity":0.7,"text-color":"#f3e6d2","text-halo-blur":1,"text-halo-color":"#2a0b17","text-halo-width":1.2}},{"id":"place_city","type":"symbol","source":"openmaptiles","source-layer":"place","maxzoom":14,"filter":["all",["match",["geometry-type"],["MultiPoint","Point"],true,false],["==",["get","class"],"city"],[">",["get","rank"],3]],"layout":{"icon-image":["step",["zoom"],"circle-11",9,""],"icon-size":0.4,"text-anchor":["step",["zoom"],"left",8,"center"],"text-field":["case",["has","name:nonlatin"],["concat",["get","name:latin"],"\n",["get","name:nonlatin"]],["coalesce",["get","name_en"],["get","name"]]],"text-font":["Noto Sans Regular"],"text-justify":"left","text-offset":[0.5,0.2],"text-size":10,"text-transform":"uppercase"},"paint":{"icon-opacity":0.7,"text-color":"#f3e6d2","text-halo-blur":1,"text-halo-color":"#2a0b17","text-halo-width":1.2}},{"id":"place_city_large","type":"symbol","source":"openmaptiles","source-layer":"place","maxzoom":12,"filter":["all",["match",["geometry-type"],["MultiPoint","Point"],true,false],["<=",["get","rank"],3],["==",["get","class"],"city"]],"layout":{"icon-image":["step",["zoom"],"circle-11",9,""],"icon-size":0.4,"text-anchor":["step",["zoom"],"left",8,"center"],"text-field":["case",["has","name:nonlatin"],["concat",["get","name:latin"],"\n",["get","name:nonlatin"]],["coalesce",["get","name_en"],["get","name"]]],"text-font":["Noto Sans Regular"],"text-justify":"left","text-offset":[0.5,0.2],"text-size":14,"text-transform":"uppercase"},"paint":{"icon-opacity":0.7,"text-color":"#f3e6d2","text-halo-blur":1,"text-halo-color":"#2a0b17","text-halo-width":1.2}},{"id":"place_state","type":"symbol","source":"openmaptiles","source-layer":"place","maxzoom":12,"filter":["all",["match",["geometry-type"],["MultiPoint","Point"],true,false],["==",["get","class"],"state"]],"layout":{"text-field":["case",["has","name:nonlatin"],["concat",["get","name:latin"],"\n",["get","name:nonlatin"]],["coalesce",["get","name_en"],["get","name"]]],"text-font":["Noto Sans Regular"],"text-size":10,"text-transform":"uppercase"},"paint":{"text-color":"#f3e6d2","text-halo-blur":1,"text-halo-color":"#2a0b17","text-halo-width":1.2}},{"id":"place_country_other","type":"symbol","source":"openmaptiles","source-layer":"place","maxzoom":8,"filter":["all",["match",["geometry-type"],["MultiPoint","Point"],true,false],["==",["get","class"],"country"],["!",["has","iso_a2"]]],"layout":{"text-field":["case",["has","name:nonlatin"],["concat",["get","name:latin"],"\n",["get","name:nonlatin"]],["coalesce",["get","name_en"],["get","name"]]],"text-font":["Noto Sans Regular"],"text-size":["interpolate",["linear"],["zoom"],0,9,1,11],"text-transform":"uppercase"},"paint":{"text-color":"#f3e6d2","text-halo-color":"#2a0b17","text-halo-width":1.4}},{"id":"place_country_minor","type":"symbol","source":"openmaptiles","source-layer":"place","maxzoom":8,"filter":["all",["match",["geometry-type"],["MultiPoint","Point"],true,false],["==",["get","class"],"country"],[">=",["get","rank"],2],["has","iso_a2"]],"layout":{"text-field":["case",["has","name:nonlatin"],["concat",["get","name:latin"],"\n",["get","name:nonlatin"]],["coalesce",["get","name_en"],["get","name"]]],"text-font":["Noto Sans Regular"],"text-size":["interpolate",["linear"],["zoom"],0,10,6,12],"text-transform":"uppercase"},"paint":{"text-color":"#f3e6d2","text-halo-color":"#2a0b17","text-halo-width":1.4}},{"id":"place_country_major","type":"symbol","source":"openmaptiles","source-layer":"place","maxzoom":6,"filter":["all",["match",["geometry-type"],["MultiPoint","Point"],true,false],["<=",["get","rank"],1],["==",["get","class"],"country"],["has","iso_a2"]],"layout":{"text-anchor":"center","text-field":["case",["has","name:nonlatin"],["concat",["get","name:latin"],"\n",["get","name:nonlatin"]],["coalesce",["get","name_en"],["get","name"]]],"text-font":["Noto Sans Regular"],"text-size":["interpolate",["exponential",1.4],["zoom"],0,10,3,12,4,14],"text-transform":"uppercase"},"paint":{"text-color":"#f3e6d2","text-halo-color":"#2a0b17","text-halo-width":1.4}}],"name":"Vinoteca dark"} diff --git a/local/templates/jinove_wine/assets/media/bottle-stub.svg b/local/templates/jinove_wine/assets/media/bottle-stub.svg new file mode 100644 index 0000000..bff6410 --- /dev/null +++ b/local/templates/jinove_wine/assets/media/bottle-stub.svg @@ -0,0 +1 @@ + diff --git a/local/templates/jinove_wine/catalog-styles.css b/local/templates/jinove_wine/catalog-styles.css new file mode 100644 index 0000000..3ead672 --- /dev/null +++ b/local/templates/jinove_wine/catalog-styles.css @@ -0,0 +1,1418 @@ +.vino-catalog-layout .vino-product-grid { + grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); +} +@media (max-width:560px) { + .vino-catalog-layout .vino-product-grid { + grid-template-columns: repeat(2, minmax(0, 1fr)); + } +} +.vino-catalog-layout .vino-product-grid--list { + grid-template-columns: minmax(0, 1fr); +} +.vino-product-grid .vino-card { + opacity: 1; +} +.vino-product-grid .vino-card__image { + flex: 0 0 auto; +} +.vino-pdp-related .vino-card { + opacity: 1; + position: relative; +} +.vino-pdp-related { + padding: 0 var(--gutter) var(--space-section); + position: relative; + z-index: 42; +} +.vino-pdp-related__head { + display: flex; + align-items: baseline; + justify-content: space-between; + gap: var(--space-4); + margin-bottom: 30px; +} +.vino-pdp-related__title { + font-family: var(--font-serif); + font-weight: 500; + font-size: clamp(1.7rem,3vw,2.6rem); + margin: 0; +} +.vino-pdp-related .vino-slider__viewport { + overflow-x: auto; +} +.vino-razdel-sec { + padding: 0 var(--gutter) var(--space-section); +} +.vino-razdel-hero ~ .vino-brands { + border-top: 0; +} +.vino-razdel-hero + .vino-razdel-sec { + padding-top: var(--space-head); +} +.vino-cat-intro { + max-width: 72ch; + margin: 0 0 var(--space-6); + color: var(--color-text-muted); + font-size: var(--text-15); + line-height: var(--leading-long); +} +.vino-cat-toolbar { + display: flex; + align-items: center; + justify-content: space-between; + gap: var(--space-4); + margin-bottom: var(--space-6); + padding-bottom: var(--space-4); + border-bottom: 1px solid var(--color-line); +} +.vino-cat-toolbar__count { + color: var(--color-text-faint); + font-size: var(--text-13); + letter-spacing: .14em; + text-transform: uppercase; +} +.vino-cat-toolbar__right { + display: flex; + align-items: center; + gap: var(--space-6); +} +@media (max-width:980px) { + .vino-cat-toolbar__right { + display: flex; + align-items: center; + gap: var(--space-3); + flex-wrap: wrap; + justify-content: flex-end; + } +} +@media (max-width:560px) { + .vino-cat-toolbar { + flex-direction: column; + align-items: stretch; + gap: var(--space-3); + } + .vino-cat-toolbar__right { + display: grid; + grid-template-columns: repeat(2, minmax(0, 1fr)); + gap: var(--space-2); + } +} +.vino-sort { + position: relative; +} +.vino-sort__btn { + display: inline-flex; + align-items: center; + gap: 10px; + min-width: 190px; + justify-content: space-between; + background: transparent; + border: 1px solid var(--color-line); + color: var(--color-text); + border-radius: 0; + cursor: pointer; + font-family: var(--font-sans); + font-size: var(--text-15); + height: 44px; + padding: 0 13px; + transition: border-color var(--duration-fast) var(--ease-base); +} +@media (hover:hover) { + .vino-sort__btn:hover, .vino-sort--open .vino-sort__btn { + border-color: var(--color-accent); + } +} +.vino-sort__chev { + width: 15px; + height: 15px; + color: var(--color-accent); + flex: 0 0 auto; + transition: transform var(--duration-fast) var(--ease-base); +} +.vino-sort--open .vino-sort__chev { + transform: rotate(180deg); +} +.vino-sort__menu { + position: absolute; + top: calc(100% + 6px); + right: 0; + left: 0; + z-index: 30; + margin: 0; + padding: 6px; + list-style: none; + background: var(--color-surface); + border: 1px solid var(--color-line); + box-shadow: 0 18px 40px rgba(0,0,0,.45); + opacity: 0; + visibility: hidden; + transform: translateY(-6px); + transition: opacity var(--duration-fast) var(--ease-base), transform var(--duration-fast) var(--ease-base), visibility var(--duration-fast) var(--ease-base); +} +.vino-sort--open .vino-sort__menu { + opacity: 1; + visibility: visible; + transform: translateY(0); +} +.vino-sort__item { + color: var(--color-text-muted); + font-size: var(--text-15); + cursor: pointer; + transition: background var(--duration-fast) var(--ease-base), color var(--duration-fast) var(--ease-base); +} +.vino-sort__link { + display: block; + padding: 10px var(--space-3); + color: inherit; + text-decoration: none; +} +@media (max-width:980px) { + .vino-sort__btn { + min-height: var(--size-tap); + } +} +@media (max-width:560px) { + .vino-sort__btn { + width: 100%; + min-width: 0; + } + .vino-sort__menu { + left: auto; + width: max-content; + min-width: 100%; + } +} +@media (hover:hover) { + .vino-sort__item:hover { + background: var(--color-accent); + color: var(--color-bg); + } +} +.vino-sort__item--selected { + color: var(--color-accent); +} +@media (hover:hover) { + .vino-sort__item--selected:hover { + color: var(--color-bg); + } +} +.vino-cat-view { + display: flex; + align-items: center; + gap: 2px; + height: 44px; + padding: 3px; + border: 1px solid var(--color-line); + border-radius: 0; + background: transparent; +} +.vino-cat-view__btn { + display: flex; + align-items: center; + justify-content: center; + width: 40px; + height: 36px; + padding: 0; + border: 0; + border-radius: 0; + background: transparent; + color: color-mix(in srgb, var(--color-accent) 50%, transparent); + cursor: pointer; + transition: color var(--duration-fast) var(--ease-base), background var(--duration-fast) var(--ease-base); +} +@media (hover:hover) { + .vino-cat-view__btn:not(.vino-cat-view__btn--active):hover { + color: var(--color-accent); + } +} +.vino-cat-view__btn--active { + color: var(--color-accent); + background: color-mix(in srgb, var(--color-accent) 18%, transparent); + cursor: default; +} +.vino-cat-view__icon { + width: 16px; + height: 16px; + fill: currentColor; +} +@media (pointer:coarse) { + .vino-cat-view { + padding: 0; + } + .vino-cat-view__btn { + width: 48px; + height: 100%; + } +} +@media (max-width:560px) { + .vino-cat-view { + display: none; + } +} +.vino-presets { + display: flex; + flex-wrap: wrap; + gap: var(--space-2); + margin: 0 0 var(--space-4); +} +.vino-presets__link { + display: inline-flex; + align-items: center; + gap: var(--space-2); + height: 36px; + padding: 0 var(--space-3); + border: 1px solid var(--color-line); + color: var(--color-text); + font-family: var(--font-sans); + font-size: var(--text-15); + text-decoration: none; + white-space: nowrap; + transition: border-color var(--duration-fast) var(--ease-base), background var(--duration-fast) var(--ease-base), transform .08s; +} +.vino-presets__link--active { + border-color: color-mix(in srgb, var(--color-accent) 35%, transparent); + background: color-mix(in srgb, var(--color-accent) 12%, transparent); +} +.vino-presets__link--active::after { + content: ""; + width: 12px; + height: 12px; + background-color: currentColor; + -webkit-mask: url("data:image/svg+xml;utf8,") center / contain no-repeat; + mask: url("data:image/svg+xml;utf8,") center / contain no-repeat; + opacity: .7; +} +@media (hover:hover) { + .vino-presets__link:hover { + border-color: var(--color-accent); + background: color-mix(in srgb, var(--color-accent) 20%, transparent); + } +} +.vino-presets__link:active { + transform: scale(.97); +} +.vino-chips { + display: flex; + flex-wrap: wrap; + align-items: center; + gap: var(--space-2); + margin: 0 0 var(--space-4); +} +.vino-chips__chip { + display: inline-flex; + align-items: center; + gap: var(--space-2); + height: 36px; + padding: 0 var(--space-3); + border: 1px solid color-mix(in srgb, var(--color-accent) 35%, transparent); + border-radius: 0; + background: color-mix(in srgb, var(--color-accent) 12%, transparent); + color: var(--color-text); + font-family: var(--font-sans); + font-size: var(--text-15); + cursor: pointer; + transition: border-color var(--duration-fast) var(--ease-base), background var(--duration-fast) var(--ease-base); +} +.vino-chips__chip::after { + content: ""; + width: 12px; + height: 12px; + background-color: currentColor; + -webkit-mask: url("data:image/svg+xml;utf8,") center / contain no-repeat; + mask: url("data:image/svg+xml;utf8,") center / contain no-repeat; + opacity: .7; +} +@media (hover:hover) { + .vino-chips__chip:hover { + border-color: var(--color-accent); + background: color-mix(in srgb, var(--color-accent) 20%, transparent); + } +} +.vino-chips__reset { + height: 36px; + padding: 0 var(--space-2); + border: 0; + background: transparent; + color: var(--color-accent); + font-family: var(--font-sans); + font-size: var(--text-15); + text-decoration: underline; + text-underline-offset: 3px; + cursor: pointer; +} +@media (hover:hover) { + .vino-chips__reset:hover { + color: var(--color-accent-hover); + } +} +@media (pointer:coarse) { + .vino-chips__chip, .vino-chips__reset, .vino-presets__link { + height: 44px; + } +} +.vino-razdel-content { + min-width: 0; + position: relative; + z-index: 42; + transition: opacity var(--duration-fast) var(--ease-base); +} +.vino-razdel-content:focus { + outline: none; +} +.vino-razdel-content--loading { + opacity: .45; + pointer-events: none; +} +.vino-stars { + display: inline-flex; + gap: 2px; + color: var(--color-accent); +} +.vino-stars__star { + width: 16px; + height: 16px; + background-color: color-mix(in srgb, var(--color-white) 20%, transparent); + -webkit-mask: var(--icon-star) center / contain no-repeat; + mask: var(--icon-star) center / contain no-repeat; +} +.vino-stars__star--full { + background-color: currentColor; +} +.vino-stars--sm .vino-stars__star { + width: 13px; + height: 13px; +} +.vino-pdp__rating-star { + width: 14px; + height: 14px; + flex: 0 0 auto; + background-color: currentColor; + -webkit-mask: var(--icon-star) center / contain no-repeat; + mask: var(--icon-star) center / contain no-repeat; +} +.vino-pdp__rating-count { + color: var(--color-text-faint); + font-weight: 400; +} +.vino-pdp { + padding: var(--space-head) var(--gutter) var(--space-section); + position: relative; + z-index: 42; +} +.vino-pdp__main { + display: grid; + grid-template-columns: minmax(0,6fr) minmax(0,5fr); + gap: clamp(28px,4vw,60px); + align-items: start; +} +@media (max-width:980px) { + .vino-pdp__main { + grid-template-columns: 1fr; + } +} +.vino-pdp__gallery { + display: grid; + grid-template-columns: 1fr; + gap: var(--space-4); + align-items: start; +} +.vino-pdp__image { + width: 100%; + height: 100%; + object-fit: cover; + display: block; + transition: opacity var(--duration-base) var(--ease-base); +} +.vino-pdp__zoom { + position: absolute; + inset: 0; + width: 100%; + height: 100%; + padding: 0; + border: 0; + background: transparent; + cursor: zoom-in; +} +.vino-pdp__zoom:focus-visible { + outline: 2px solid var(--color-accent); + outline-offset: -4px; +} +.vino-pdp__thumbs { + display: grid; + grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); + gap: var(--space-3); + margin-top: var(--space-4); +} +.vino-pdp__thumb { + aspect-ratio: 3 / 2; + padding: 0; + overflow: hidden; + border: 1px solid var(--color-line); + border-radius: var(--radius-sm); + background: var(--color-bg-soft); + cursor: pointer; + transition: border-color var(--duration-fast) var(--ease-base), box-shadow var(--duration-fast) var(--ease-base); +} +.vino-pdp__thumb-img { + display: block; + width: 100%; + height: 100%; + object-fit: cover; +} +.vino-pdp__thumb--active { + border-color: var(--color-accent); + box-shadow: var(--shadow-focus); +} +@media (hover:hover) { + .vino-pdp__thumb:hover { + border-color: var(--color-accent); + box-shadow: var(--shadow-focus); + } +} +.vino-pdp__thumb:focus-visible { + outline: 2px solid var(--color-accent); + outline-offset: 2px; +} +@media (max-width:560px) { + .vino-pdp__thumbs { + grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); + gap: var(--space-2); + } +} +.vino-pdp__kicker { + margin: 0 0 var(--space-3); + color: var(--color-accent); + font-size: var(--text-13); + letter-spacing: var(--tracking-wide); + text-transform: uppercase; +} +.vino-pdp__title { + margin: 0 0 var(--space-4); + font-family: var(--font-serif); + font-weight: 500; + font-size: clamp(2rem,3.4vw,3rem); + line-height: 1.08; +} +.vino-pdp__sub { + display: flex; + flex-wrap: wrap; + align-items: center; + gap: var(--space-4) var(--space-5); + margin-bottom: var(--space-5-5); + padding-bottom: var(--space-5-5); + border-bottom: 1px solid var(--color-line); +} +.vino-pdp__rating { + display: inline-flex; + align-items: center; + gap: 9px; + margin-right: var(--space-4); + color: var(--color-text-muted); + font-size: var(--text-15); + font-weight: 600; + text-decoration: underline; + text-underline-offset: 3px; +} +@media (hover:hover) { + .vino-pdp__rating:hover { + color: var(--color-accent); + } +} +.vino-pdp__chips { + list-style: none; + display: flex; + flex-wrap: wrap; + gap: 10px; + margin: 0 0 26px; + padding: 0; +} +.vino-pdp__chip { + font-size: var(--text-13); + letter-spacing: .08em; + text-transform: uppercase; + color: var(--color-text-muted); + border: 1px solid var(--color-line); + padding: var(--space-2) 13px; +} +.vino-pdp__buy { + background: var(--color-surface); + border: 1px solid var(--color-line); + padding: clamp(var(--space-5),2.4vw,28px); +} +.vino-pdp__price { + display: flex; + align-items: baseline; + gap: var(--space-3-5); + flex-wrap: wrap; +} +.vino-pdp__currency { + margin-left: .12em; + font-family: var(--font-sans); + font-size: .8em; + font-weight: 500; +} +.vino-pdp__price-now { + font-family: var(--font-serif); + font-weight: 500; + font-size: clamp(2.2rem,3.4vw,3rem); + color: var(--color-accent); + font-variant-numeric: lining-nums tabular-nums; + line-height: 1; +} +.vino-pdp__price-old { + color: var(--color-text-faint); + font-size: var(--text-19); + text-decoration-thickness: 1px; +} +.vino-pdp__percent { + padding: var(--space-1) var(--space-2); + border: 1px solid color-mix(in srgb, var(--color-accent) 50%, transparent); + border-radius: var(--radius-sm); + background: color-mix(in srgb, var(--color-accent) 12%, transparent); + color: var(--color-accent); + font-size: var(--text-13); + line-height: 1; + letter-spacing: .04em; +} +.vino-pdp__stock { + display: inline-flex; + align-items: center; + margin: var(--space-4) 0 var(--space-6); + padding: 6px var(--space-3); + border: 1px solid color-mix(in srgb, var(--color-white) 15%, transparent); + border-radius: var(--radius-sm); + background: color-mix(in srgb, var(--color-white) 4%, transparent); + color: var(--color-text); + font-size: var(--text-13); + letter-spacing: .1em; + text-transform: uppercase; +} +.vino-pdp__stock--out { + color: var(--color-text-faint); +} +.vino-pdp__price--out .vino-pdp__price-now { + color: var(--color-text-faint); +} +.vino-pdp__notify { + flex: 1 1 180px; + min-width: 160px; + min-height: 48px; + padding: 0 18px; + border: 1px solid var(--color-accent); + background: transparent; + color: var(--color-accent); + font-family: var(--font-sans); + font-weight: 600; + font-size: var(--text-15); + letter-spacing: .12em; + text-transform: uppercase; + cursor: pointer; + transition: background var(--duration-fast) var(--ease-base), color var(--duration-fast) var(--ease-base); +} +@media (hover:hover) { + .vino-pdp__notify:hover { + background: var(--color-accent); + color: var(--color-on-accent); + } +} +.vino-pdp__cart { + display: flex; + gap: var(--space-3); + align-items: stretch; + flex-wrap: wrap; +} +.vino-pdp__stepper { + display: inline-flex; + align-items: center; + border-bottom: 1px solid color-mix(in srgb, var(--color-accent) 55%, transparent); + border-radius: 0; + flex: 0 0 auto; +} +.vino-pdp__step { + width: 44px; + height: 49px; + border: 0; + border-radius: 0; + background: transparent; + color: var(--color-accent); + font-size: 20px; + cursor: pointer; + transition: background var(--duration-fast) var(--ease-base),color var(--duration-fast) var(--ease-base); +} +@media (hover:hover) { + .vino-pdp__step:hover { + color: var(--color-text); + } +} +.vino-pdp__qty { + display: flex; + align-items: center; + justify-content: center; + align-self: stretch; + min-width: 42px; + text-align: center; + font-weight: 600; + font-variant-numeric: tabular-nums; +} +.vino-pdp__addcart { + flex: 1 1 180px; + min-width: 160px; + min-height: 48px; + white-space: nowrap; + padding: 0 18px; + border: 0; + background: var(--color-accent); + color: var(--color-on-accent); + font-family: var(--font-sans); + font-weight: 700; + font-size: var(--text-15); + letter-spacing: .12em; + text-transform: uppercase; + cursor: pointer; + transition: background var(--duration-fast) var(--ease-base); +} +@media (hover:hover) { + .vino-pdp__addcart:hover { + background: var(--color-accent-hover); + } +} +.vino-pdp__iconbtn { + width: 48px; + min-height: 48px; + flex: 0 0 auto; + border: 1px solid color-mix(in srgb, var(--color-white) 24%, transparent); + background: transparent; + color: var(--color-text-muted); + cursor: pointer; + display: inline-flex; + align-items: center; + justify-content: center; + transition: color var(--duration-fast) var(--ease-base),border-color var(--duration-fast) var(--ease-base); +} +.vino-pdp__icon { + width: 18px; + height: 18px; +} +@media (max-width:560px) { + .vino-pdp__step { + height: 51px; + } + .vino-pdp__addcart, .vino-pdp__notify { + min-height: 52px; + } + .vino-pdp__iconbtn { + width: 52px; + min-height: 52px; + } +} +@media (hover:hover) { + .vino-pdp__iconbtn:hover { + color: var(--color-danger); + border-color: var(--color-danger); + } +} +.vino-pdp__iconbtn--active { + color: var(--color-danger); + border-color: var(--color-danger); +} +.vino-pdp__iconbtn--active .vino-pdp__icon { + fill: var(--color-danger); +} +.vino-pdp__assur { + list-style: none; + display: grid; + grid-template-columns: 1fr 1fr; + gap: var(--space-5) var(--space-6); + margin: var(--space-6) 0 0; + padding: var(--space-6) 0 0; + border-top: 1px solid var(--color-line); +} +.vino-pdp__assur-item { + display: flex; + gap: var(--space-3); + align-items: flex-start; +} +.vino-pdp__assur-icon { + width: 23px; + height: 23px; + flex: 0 0 auto; + color: var(--color-accent); + stroke-width: 1.4; +} +.vino-pdp__assur-title { + display: block; + color: var(--color-text); + font-weight: 500; + font-size: var(--text-15); + margin-bottom: var(--space-1); +} +.vino-pdp__assur-body, .vino-pdp__assur-text { + color: var(--color-text-muted); + font-size: var(--text-13); + line-height: 1.5; +} +.vino-pdp__detail { + display: grid; + grid-template-columns: minmax(0,1fr) 380px; + gap: clamp(30px,4vw,60px); + margin-top: clamp(var(--space-12),6vw,82px); + align-items: start; +} +@media (max-width:980px) { + .vino-pdp__detail { + grid-template-columns: 1fr; + } +} +.vino-pdp__heading { + font-family: var(--font-serif); + font-weight: 500; + font-size: clamp(1.6rem,2.4vw,2.1rem); + margin: 0 0 var(--space-5); +} +.vino-pdp__prose p { + color: var(--color-text-muted); + line-height: var(--leading-long); + margin: 0 0 18px; + max-width: 62ch; +} +.vino-pdp__tasting { + display: grid; + gap: 0; + margin-top: var(--space-8); + border-top: 1px solid var(--color-line); +} +.vino-pdp__tasting-row { + display: grid; + grid-template-columns: 160px 1fr; + gap: var(--space-5); + padding: 17px 0; + border-bottom: 1px solid var(--color-line); +} +@media (max-width:560px) { + .vino-pdp__tasting-row { + grid-template-columns: 1fr; + gap: 6px; + } +} +.vino-pdp__specs { + background: var(--color-bg-soft); + border: 1px solid var(--color-line); + padding: clamp(var(--space-5-5),2.4vw,30px); + position: sticky; + top: 96px; +} +.vino-pdp__heading--specs { + margin-bottom: var(--space-2); +} +.vino-pdp__list { + margin: 0; +} +.vino-pdp__row { + display: flex; + justify-content: space-between; + gap: var(--space-4); + padding: 13px 0; + border-bottom: 1px solid var(--color-line); +} +.vino-pdp__row:last-child { + border-bottom: 0; + padding-bottom: 0; +} +.vino-pdp__term { + color: var(--color-accent); + font-size: var(--text-13); + letter-spacing: .14em; + text-transform: uppercase; +} +.vino-pdp__def { + margin: 0; + color: var(--color-text); + font-size: var(--text-15); + text-align: right; + font-weight: 500; +} +.vino-pdp__stage { + position: relative; + background: var(--color-surface); + border: 1px solid var(--color-line); + overflow: hidden; + aspect-ratio: 3/2; +} +.vino-pdp__art { + flex-basis: 100%; + margin: var(--space-2) 0 0; + color: var(--color-text-faint); + font-size: var(--text-13); + letter-spacing: .06em; +} +.vino-pdp__tasting-key { + color: var(--color-accent); + font-size: var(--text-13); + letter-spacing: .14em; + text-transform: uppercase; + padding-top: 3px; +} +.vino-pdp__tasting-value { + color: var(--color-text-muted); + line-height: 1.6; +} +.vino-reviews { + padding: 0 var(--gutter) var(--space-section); +} +.vino-reviews .vino-wrap { + padding-top: var(--space-section); + border-top: 1px solid var(--color-line); +} +.vino-reviews__head { + display: flex; + flex-wrap: wrap; + align-items: center; + gap: var(--space-4) var(--space-6); + margin-bottom: var(--space-head); +} +.vino-reviews__title { + margin: 0; + font-family: var(--font-serif); + font-size: var(--fs-h2); + font-weight: 400; + line-height: var(--leading-tight); + letter-spacing: var(--tracking-tight); +} +.vino-reviews__summary { + display: flex; + align-items: center; + gap: var(--space-2); + margin: 0; + color: var(--color-text-muted); + font-size: var(--text-15); +} +.vino-reviews__avg { + color: var(--color-text); + font-size: var(--text-19); + font-weight: 600; +} +.vino-reviews__empty { + order: 1; + flex: 1 1 100%; + margin: 0; + color: var(--color-text-muted); + font-size: var(--text-15); + line-height: var(--leading-long); +} +.vino-reviews__write { + margin-left: auto; + min-height: 44px; +} +.vino-reviews__list { + display: grid; + grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); + gap: var(--space-grid-base); + margin: 0; + padding: 0; + list-style: none; +} +.vino-review { + display: flex; + flex-direction: column; + gap: var(--space-3); + padding: var(--space-card); + border: 1px solid var(--color-line); + border-radius: var(--radius-sm); + background: var(--color-bg-soft); +} +.vino-review__head { + display: flex; + justify-content: space-between; + gap: var(--space-3); +} +.vino-review__author { + color: var(--color-text); + font-weight: 600; +} +.vino-review__date { + color: var(--color-text-faint); + font-size: var(--text-13); +} +.vino-review__text { + margin: 0; + color: var(--color-text-muted); + font-size: var(--text-15); + line-height: var(--leading-long); + overflow-wrap: anywhere; +} +.vino-rate { + margin: 0 0 var(--space-3); + padding: 0; + border: 0; +} +.vino-rate__legend { + margin-bottom: var(--space-1); + padding: 0; + color: var(--color-text-muted); + font-size: var(--text-15); +} +.vino-rate--invalid .vino-rate__legend { + color: var(--color-danger-soft); +} +.vino-rate__stars { + display: inline-flex; + flex-direction: row-reverse; +} +.vino-rate__input { + position: absolute; + width: 1px; + height: 1px; + opacity: 0; +} +.vino-rate__star { + display: flex; + align-items: center; + justify-content: center; + width: 44px; + height: 44px; + color: color-mix(in srgb, var(--color-white) 25%, transparent); + cursor: pointer; + transition: color var(--duration-fast) var(--ease-base); +} +.vino-rate__star::before { + content: ""; + width: 28px; + height: 28px; + background-color: currentColor; + -webkit-mask: var(--icon-star) center / contain no-repeat; + mask: var(--icon-star) center / contain no-repeat; +} +.vino-rate__input:checked + .vino-rate__star, .vino-rate__input:checked ~ .vino-rate__star { + color: var(--color-accent); +} +@media (hover:hover) { + .vino-rate__star:hover, .vino-rate__star:hover ~ .vino-rate__star { + color: var(--color-accent-hover); + } +} +.vino-rate__input:focus-visible + .vino-rate__star { + outline: 2px solid var(--color-accent); + outline-offset: -4px; + border-radius: var(--radius-md); +} +.vino-brand-detail { + padding: 36px var(--gutter) var(--space-2); +} +.vino-brand-hero { + display: grid; + grid-template-columns: 1.05fr .95fr; + gap: var(--space-12); + align-items: center; + padding: 18px 0 var(--space-12); +} +.vino-brand-hero__title { + font-family: var(--font-serif); + font-weight: 500; + font-size: clamp(2.6rem,5.5vw,4.4rem); + line-height: 1; + margin: var(--space-3-5) 0 0; + color: var(--color-text); +} +.vino-brand-hero__meta { + display: flex; + gap: 26px; + margin: var(--space-6) 0 0; + flex-wrap: wrap; + padding: 0; +} +.vino-brand-hero__kicker { + margin: 0; + color: var(--color-accent); + font-size: var(--text-13); + letter-spacing: var(--tracking-wide); + text-transform: uppercase; +} +.vino-brand-hero__term { + font-size: var(--text-13); + letter-spacing: .22em; + text-transform: uppercase; + color: var(--color-accent); +} +.vino-brand-hero__def { + margin: 6px 0 0; + font-family: var(--font-serif); + font-size: 1.3rem; + color: var(--color-text); +} +.vino-brand-hero__body { + margin: var(--space-6) 0 0; + color: var(--color-text-muted); + line-height: 1.7; + font-size: 1.04rem; + max-width: 50ch; +} +.vino-brand-hero__media { + position: relative; + height: 420px; + border: 1px solid var(--color-line); + border-radius: 10px; + background: var(--color-bg-soft); + overflow: hidden; +} +.vino-brand-hero__img { + width: 100%; + height: 100%; + padding: var(--space-10); + object-fit: contain; + display: block; +} +@media (max-width:760px) { + .vino-brand-hero { + grid-template-columns: 1fr; + gap: 26px; + } + .vino-brand-hero__media { + height: 260px; + order: -1; + } +} +.vino-brand-wines__head { + display: flex; + align-items: baseline; + justify-content: space-between; + gap: var(--space-4); + margin-bottom: 30px; + padding-top: 30px; + border-top: 1px solid var(--color-line); +} +.vino-brand-wines__title { + margin: 0; + font-family: var(--font-serif); + font-weight: 500; + font-size: clamp(1.7rem,3vw,2.3rem); + color: var(--color-text); +} +.vino-brand-wines .vino-slider__viewport { + overflow-x: auto; +} +.vino-brand-wines .vino-card { + opacity: 1; + position: relative; +} +.vino-filter-btn { + display: none; +} +@media (max-width:560px) { + .vino-filter-btn { + justify-content: center; + } +} +@media (max-width:980px) { + .vino-filter-btn { + display: inline-flex; + align-items: center; + gap: var(--space-2); + background: var(--color-bg-soft); + border: 1px solid var(--color-line); + color: var(--color-text); + border-radius: 0; + padding: var(--space-2) var(--space-3); + font: inherit; + font-size: var(--text-15); + cursor: pointer; + white-space: nowrap; + min-height: var(--size-tap); + } + .vino-filter-btn__icon { + width: 18px; + height: 18px; + } + @media (hover:hover) { + .vino-filter-btn:hover { + border-color: var(--color-accent); + color: var(--color-accent); + } + } +} +.vino-filter-head { + display: none; +} +@media (max-width:980px) { + .vino-filter-head { + display: flex; + align-items: center; + justify-content: space-between; + position: sticky; + top: 0; + background: var(--color-bg); + padding: var(--space-4) 0; + border-bottom: 1px solid var(--color-line); + margin-bottom: var(--space-4); + z-index: 1; + } + .vino-filter-head__title { + font-family: var(--font-serif); + font-size: 1.35rem; + color: var(--color-text); + } +} +.vino-filter-overlay { + position: fixed; + inset: 0; + background: rgba(0,0,0,.55); + z-index: 999; + opacity: 0; + transition: opacity .28s ease; +} +.vino-filter-overlay--on { + opacity: 1; +} +@media (max-width:980px) { + .vino-catalog-sidebar { + position: fixed; + top: 0; + left: 0; + height: 100dvh; + width: min(88vw,360px); + max-width: none; + margin: 0; + z-index: 1000; + background: var(--color-bg); + border-right: 1px solid var(--color-line); + transform: translateX(-100%); + visibility: hidden; + transition: transform .28s ease, visibility 0s linear .28s; + overflow-y: auto; + overscroll-behavior: contain; + scrollbar-width: thin; + padding: 0 var(--gutter) calc(var(--space-6) + env(safe-area-inset-bottom)); + box-shadow: 20px 0 60px rgba(0,0,0,.6); + } + .vino-catalog-sidebar--open { + transform: none; + visibility: visible; + transition: transform .28s ease; + } +} +@media (max-width:980px) { + .vino-filter-close { + background: none; + border: none; + color: var(--color-text-muted); + cursor: pointer; + padding: 0; + width: 44px; + height: 44px; + display: inline-flex; + align-items: center; + justify-content: center; + flex: 0 0 auto; + margin-right: -10px; + } +} +.vino-filter-close__icon { + width: 20px; + height: 20px; +} +@media (max-width:980px) { + @media (hover:hover) { + .vino-filter-close:hover { + color: var(--color-text); + } + } +} +.vino-filter { + display: grid; + gap: var(--space-6); +} +.vino-filter__groups { + display: grid; +} +.vino-filter__group { + min-width: 0; + margin: 0; + padding: var(--space-4) 0; + border: 0; + border-bottom: 1px solid var(--color-line); +} +.vino-filter__group:first-child { + padding-top: 0; +} +.vino-filter__legend { + float: left; + width: 100%; + padding: 0; +} +.vino-filter__toggle { + display: flex; + align-items: center; + justify-content: space-between; + gap: var(--space-3); + width: 100%; + padding: 0; + border: 0; + background: none; + color: var(--color-text); + font: inherit; + font-size: var(--text-17); + font-weight: 600; + text-align: left; + cursor: pointer; +} +.vino-filter__toggle:focus-visible { + outline: 2px solid var(--color-accent); + outline-offset: 4px; +} +.vino-filter__chevron { + flex: none; + width: 14px; + height: 14px; + color: var(--color-text-muted); + transition: transform var(--duration-fast) var(--ease-base); +} +.vino-filter__group--collapsed .vino-filter__chevron { + transform: rotate(180deg); +} +.vino-filter__body { + clear: both; + padding-top: var(--space-3); +} +.vino-filter__group--collapsed .vino-filter__body { + display: none; +} +.vino-filter__options { + display: grid; + gap: var(--space-2); +} +.vino-filter__option { + display: flex; + align-items: flex-start; + gap: var(--space-3); + color: color-mix(in srgb, var(--color-white) 78%, transparent); + font-size: var(--text-15); + line-height: 1.4; + cursor: pointer; + transition: color var(--duration-fast) var(--ease-base); +} +.vino-filter__option--extra { + display: none; +} +.vino-filter__group--expanded .vino-filter__option--extra { + display: flex; +} +.vino-filter__option--disabled { + opacity: .4; + cursor: default; +} +.vino-filter__checkbox { + display: grid; + place-content: center; + flex: none; + width: 18px; + height: 18px; + margin: 1px 0 0; + border: 1px solid color-mix(in srgb, var(--color-white) 30%, transparent); + border-radius: var(--radius-sm); + background: transparent; + cursor: pointer; + appearance: none; + transition: border-color var(--duration-fast) var(--ease-base), background var(--duration-fast) var(--ease-base); +} +.vino-filter__checkbox::after { + content: ""; + width: 9px; + height: 5px; + border-bottom: 2px solid var(--color-bg); + border-left: 2px solid var(--color-bg); + opacity: 0; + transform: translate(0, -1px) rotate(-45deg); +} +.vino-filter__checkbox:checked { + border-color: var(--color-accent); + background: var(--color-accent); +} +.vino-filter__checkbox:checked::after { + opacity: 1; +} +.vino-filter__checkbox:focus-visible { + outline: 2px solid var(--color-accent); + outline-offset: 2px; +} +.vino-filter__name { + min-width: 0; + overflow-wrap: anywhere; +} +.vino-filter__more { + margin-top: var(--space-3); + padding: 0; + border: 0; + border-bottom: 1px dashed currentColor; + background: none; + color: var(--color-accent); + font: inherit; + font-size: var(--text-15); + cursor: pointer; +} +.vino-filter__price { + display: grid; + grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); + align-items: center; + gap: var(--space-2); +} +.vino-filter__input { + width: 100%; + min-height: 40px; + padding: var(--space-2) var(--space-3); + border: 1px solid var(--color-line); + border-radius: 0; + background: transparent; + color: var(--color-text); + font: inherit; + font-size: var(--text-15); + appearance: textfield; + transition: border-color var(--duration-fast) var(--ease-base); +} +.vino-filter__input::-webkit-outer-spin-button, .vino-filter__input::-webkit-inner-spin-button { + margin: 0; + appearance: none; +} +.vino-filter__input:focus { + border-color: var(--color-accent); + outline: none; +} +.vino-filter__dash { + color: var(--color-text-faint); +} +.vino-filter__actions { + display: grid; + gap: var(--space-3); +} +.vino-filter__submit { + justify-content: center; + width: 100%; +} +.vino-filter__reset { + padding: var(--space-2) 0; + border: 0; + background: none; + color: var(--color-text-muted); + font: inherit; + font-size: var(--text-15); + cursor: pointer; + transition: color var(--duration-fast) var(--ease-base); +} +@media (max-width:980px) { + .vino-filter__option, .vino-filter__toggle { + min-height: var(--size-tap); + align-items: center; + } +} +@media (hover:hover) { + .vino-filter__option:hover { + color: var(--color-text); + } + .vino-filter__option:hover .vino-filter__checkbox { + border-color: var(--color-accent); + } + .vino-filter__option--disabled:hover { + color: color-mix(in srgb, var(--color-white) 78%, transparent); + } + .vino-filter__more:hover, .vino-filter__reset:hover { + color: var(--color-text); + } +} diff --git a/local/templates/jinove_wine/components/bitrix/breadcrumb/vinoteca/lang/en/template.php b/local/templates/jinove_wine/components/bitrix/breadcrumb/vinoteca/lang/en/template.php new file mode 100644 index 0000000..611bcc7 --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/breadcrumb/vinoteca/lang/en/template.php @@ -0,0 +1,2 @@ +GetPageProperty("vino_canonical"); +$self = VINO_HOST . strtok($self !== "" ? $self : $APPLICATION->GetCurPage(false), "?"); +$last = count($arResult) - 1; +$strReturn = ''; +if ($APPLICATION->GetPageProperty("vino_schema") !== "N") { + $strReturn .= ''; +} +return $strReturn; diff --git a/local/templates/jinove_wine/components/bitrix/catalog.compare.result/vinoteca/lang/en/template.php b/local/templates/jinove_wine/components/bitrix/catalog.compare.result/vinoteca/lang/en/template.php new file mode 100644 index 0000000..49d91db --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/catalog.compare.result/vinoteca/lang/en/template.php @@ -0,0 +1,6 @@ + 1 && values.every(function (value) { return value === values[0]; }); + row.classList.toggle('vino-compare__row--same', same); + var caption = row.previousElementSibling; + if (caption && caption.classList.contains('vino-compare__caption-row')) { + caption.classList.toggle('vino-compare__caption-row--same', same); + caption.cells[0].colSpan = count + 1; + } + }); + } + + function removeColumn(cell) { + var index = cell.cellIndex; + Array.prototype.forEach.call(table.rows, function (row) { + if (!row.classList.contains('vino-compare__caption-row') && row.cells.length > index) row.deleteCell(index); + }); + } + + try { if (localStorage.getItem(KEY) === '1') setDiff(true); } catch (e) {} + + document.addEventListener('click', function (event) { + var one = event.target.closest('.vino-compare__table [data-compare-toggle]'); + if (one) { + event.preventDefault(); + event.stopImmediatePropagation(); + if (one.disabled) return; + one.disabled = true; + BX.ajax.runAction('jinove:vinoteca.compare.set', { data: { id: one.getAttribute('data-compare-toggle'), on: 'N' } }).then(function (response) { + document.dispatchEvent(new CustomEvent('vino:compare', { detail: response.data })); + removeColumn(one.closest('td')); + if (!table.querySelector('.vino-compare__card')) { + window.location.reload(); + return; + } + recompute(); + }, function () { one.disabled = false; }); + return; + } + var diff = event.target.closest('[data-compare-diff]'); + if (diff) { + setDiff(diff.getAttribute('aria-checked') !== 'true'); + return; + } + var all = event.target.closest('[data-compare-clear]'); + if (all) { + all.disabled = true; + BX.ajax.runAction('jinove:vinoteca.compare.clear', { data: {} }).then(function () { window.location.reload(); }, function () { all.disabled = false; }); + } + }, true); +}); diff --git a/local/templates/jinove_wine/components/bitrix/catalog.compare.result/vinoteca/style.css b/local/templates/jinove_wine/components/bitrix/catalog.compare.result/vinoteca/style.css new file mode 100644 index 0000000..02a783c --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/catalog.compare.result/vinoteca/style.css @@ -0,0 +1,203 @@ +.vino-compare { + --vino-compare-label-width: 220px; + --vino-compare-column-width: 260px; + padding: var(--space-head) var(--gutter) var(--space-section); +} +.vino-compare__bar { + display: none; +} +.vino-compare__table .vino-compare__tools { + padding-top: 0; + vertical-align: top; +} +.vino-compare__table thead .vino-compare__corner, .vino-compare__table thead .vino-compare__head { + height: 0; + padding: 0; +} +.vino-compare__tools .vino-compare__clear { + display: block; + margin-top: var(--space-2); + padding: 0; +} +.vino-compare__switch { + display: inline-flex; + align-items: center; + gap: var(--space-3); + min-height: var(--size-tap); + padding: 0; + border: 0; + background: none; + color: var(--color-text); + font: inherit; + font-size: var(--text-13); + letter-spacing: var(--tracking-ui); + text-transform: uppercase; + cursor: pointer; +} +.vino-compare__track { + position: relative; + flex: none; + width: 40px; + height: 22px; + border: 1px solid var(--color-line); + border-radius: var(--radius-full); + background: var(--color-bg-soft); + transition: background var(--duration-fast) var(--ease-base), border-color var(--duration-fast) var(--ease-base); +} +.vino-compare__track::after { + content: ""; + position: absolute; + top: 2px; + left: 2px; + width: 16px; + height: 16px; + border-radius: 50%; + background: var(--color-text-muted); + transition: transform var(--duration-fast) var(--ease-base), background var(--duration-fast) var(--ease-base); +} +.vino-compare__switch[aria-checked="true"] .vino-compare__track { + border-color: var(--color-accent); + background: var(--color-accent); +} +.vino-compare__switch[aria-checked="true"] .vino-compare__track::after { + background: var(--color-brown-950); + transform: translateX(18px); +} +.vino-compare__clear { + min-height: var(--size-tap); + padding: 0 var(--space-2); + border: 0; + background: none; + color: var(--color-text-muted); + font: inherit; + font-size: var(--text-13); + letter-spacing: var(--tracking-ui); + text-transform: uppercase; + text-decoration: underline; + text-underline-offset: 4px; + cursor: pointer; + transition: color var(--duration-fast) var(--ease-base); +} +.vino-compare__scroll { + position: relative; + overflow-x: auto; + overscroll-behavior-x: contain; +} +.vino-compare__table { + width: max-content; + border-collapse: collapse; + table-layout: fixed; +} +.vino-compare__corner, .vino-compare__label { + position: sticky; + left: 0; + z-index: 1; + width: var(--vino-compare-label-width); + padding: var(--space-4) var(--space-4) var(--space-4) 0; + background: var(--color-bg); + color: var(--color-text-faint); + font-size: var(--text-13); + font-weight: 400; + letter-spacing: var(--tracking-ui); + text-align: left; + text-transform: uppercase; +} +.vino-compare__corner { + vertical-align: bottom; +} +.vino-compare__head { + width: var(--vino-compare-column-width); + padding: 0 var(--space-3); + font-weight: 400; + text-align: left; + vertical-align: top; +} +.vino-compare__card { + padding: 0 var(--space-3) var(--space-6); + vertical-align: top; +} +.vino-compare__row { + border-top: 1px solid var(--color-line); +} +.vino-compare__caption-row { + display: none; +} +.vino-compare__caption { + padding: var(--space-3) 0 0; + color: var(--color-text-faint); + font-size: var(--fs-caption); + font-weight: 400; + letter-spacing: var(--tracking-ui); + text-align: left; + text-transform: uppercase; +} +.vino-compare__caption-text { + position: sticky; + left: 0; +} +.vino-compare__value { + padding: var(--space-4) var(--space-3); + color: var(--color-text); + font-size: var(--text-15); + line-height: var(--leading-text); + vertical-align: top; +} +.vino-compare--diff .vino-compare__row--same, .vino-compare--diff .vino-compare__caption-row--same { + display: none; +} +.vino-compare__row--same .vino-compare__value { + color: var(--color-text-muted); +} +@media (hover:hover) { + .vino-compare__switch:hover, .vino-compare__clear:hover { + color: var(--color-accent); + } +} +@media (max-width:760px) { + .vino-compare { + --vino-compare-label-width: 170px; + --vino-compare-column-width: 200px; + } +} +@media (max-width:560px) { + .vino-compare { + --vino-compare-column-width: 50cqw; + } + .vino-compare__scroll { + container-type: inline-size; + } + .vino-compare__bar { + display: flex; + flex-wrap: wrap; + align-items: center; + justify-content: space-between; + gap: var(--space-3); + margin-bottom: var(--space-4); + } + .vino-compare__tools > * { + display: none; + } + .vino-compare__corner, .vino-compare__label { + position: absolute; + width: 1px; + height: 1px; + overflow: hidden; + clip: rect(0, 0, 0, 0); + padding: 0; + white-space: nowrap; + } + .vino-compare__caption-row { + display: table-row; + border-top: 1px solid var(--color-line); + } + .vino-compare__row { + border-top: 0; + } + .vino-compare__value { + padding: var(--space-1) var(--space-2) var(--space-3) 0; + } + .vino-compare__head, .vino-compare__card { + padding-right: var(--space-2); + padding-left: 0; + } +} diff --git a/local/templates/jinove_wine/components/bitrix/catalog.compare.result/vinoteca/template.php b/local/templates/jinove_wine/components/bitrix/catalog.compare.result/vinoteca/template.php new file mode 100644 index 0000000..5d835d9 --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/catalog.compare.result/vinoteca/template.php @@ -0,0 +1,50 @@ + +
+
+ +
+
"> + + + + + + + + + + + + + + + + + + " aria-hidden="true"> + + + "> + + + + + + + +
+ IncludeComponent("bitrix:catalog.item", "vinoteca", array("RESULT" => array("ITEM" => $item, "AREA_ID" => "vino-compare-" . $item["ID"], "TYPE" => "CARD", "TITLE_TAG" => "h2", "COMPARE_ALWAYS" => "Y")), $component, array("HIDE_ICONS" => "Y")); ?> +
+
+ +
+
diff --git a/local/templates/jinove_wine/components/bitrix/catalog.compare.result/vinoteca/tools.php b/local/templates/jinove_wine/components/bitrix/catalog.compare.result/vinoteca/tools.php new file mode 100644 index 0000000..964292e --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/catalog.compare.result/vinoteca/tools.php @@ -0,0 +1,12 @@ + + + diff --git a/local/templates/jinove_wine/components/bitrix/catalog.element/.default/component_epilog.php b/local/templates/jinove_wine/components/bitrix/catalog.element/.default/component_epilog.php new file mode 100644 index 0000000..3f9d7f9 --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/catalog.element/.default/component_epilog.php @@ -0,0 +1,15 @@ +SetPageProperty("og_type", "product"); +if (!empty($arResult["VINO_SEO"]["IMAGE"])) { + $APPLICATION->SetPageProperty("og_image", $arResult["VINO_SEO"]["IMAGE"]); +} +if (!empty($arResult["VINO_SEO"]["TITLE"])) { + $APPLICATION->SetPageProperty("title", $arResult["VINO_SEO"]["TITLE"]); +} +if (!empty($arResult["VINO_SEO"]["DESCRIPTION"])) { + $APPLICATION->SetPageProperty("description", $arResult["VINO_SEO"]["DESCRIPTION"]); +} diff --git a/local/templates/jinove_wine/components/bitrix/catalog.element/.default/lang/en/template.php b/local/templates/jinove_wine/components/bitrix/catalog.element/.default/lang/en/template.php new file mode 100644 index 0000000..9d479d5 --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/catalog.element/.default/lang/en/template.php @@ -0,0 +1,63 @@ + EnumNames::fromProperty($properties[$code] ?? []); +$text = fn(string $code): string => LocalizedText::property($properties, $code); +$number = fn(string $value): string => LANGUAGE_ID === "en" ? $value : str_replace(".", ",", $value); +$label = fn(string $code): string => (string)Loc::getMessage("VINO_PDP_SPEC_" . $code); + +$colorCode = (string)($properties["WINE_COLOR"]["VALUE_XML_ID"] ?? ""); +$color = $enum("WINE_COLOR"); +$sugar = $enum("SUGAR"); +$grape = $enum("GRAPE"); +$region = $enum("REGION"); +$country = $enum("COUNTRY"); +$brand = current($arResult["DISPLAY_PROPERTIES"]["BRAND"]["LINK_ELEMENT_VALUE"] ?? []) ?: []; +$producer = trim((string)($brand["~NAME"] ?? "")); +$volume = $plain("VOLUME") !== "" ? (string)Loc::getMessage("VINO_PDP_VOLUME_VALUE", ["#VALUE#" => $number($plain("VOLUME"))]) : ""; +$alcohol = $plain("ABV") !== "" ? $number($plain("ABV")) . "%" : ""; +$aging = $text("AGING"); +$serve = $plain("SERVE_TEMP"); +$vintage = $plain("VINTAGE"); +$detail = LocalizedText::detailText($arResult); + +$srcset = function (int $fileId, string $src, int $width): string { + $parts = []; + foreach ([480, 800] as $target) { + if ($width <= $target) { + continue; + } + $resized = CFile::ResizeImageGet($fileId, ["width" => $target, "height" => 9999], BX_RESIZE_IMAGE_PROPORTIONAL, false); + if (!empty($resized["src"])) { + $parts[] = $resized["src"] . " " . $target . "w"; + } + } + if (!$parts) { + return ""; + } + $parts[] = $src . " " . $width . "w"; + + return implode(", ", $parts); +}; +$thumb = function (int $fileId, string $src): string { + $resized = CFile::ResizeImageGet($fileId, ["width" => 180, "height" => 120], BX_RESIZE_IMAGE_PROPORTIONAL, false); + + return (string)($resized["src"] ?? $src); +}; +$gallery = []; +$mainPicture = $arResult["DETAIL_PICTURE"] ?: ($arResult["PREVIEW_PICTURE"] ?? null); +if (is_array($mainPicture) && !empty($mainPicture["SRC"])) { + $gallery[] = ["SRC" => $mainPicture["SRC"], "SRCSET" => $srcset((int)($mainPicture["ID"] ?? 0), $mainPicture["SRC"], (int)($mainPicture["WIDTH"] ?? 0)), "THUMB" => $thumb((int)($mainPicture["ID"] ?? 0), $mainPicture["SRC"]), "ALT" => $arResult["~NAME"], "WIDTH" => (int)($mainPicture["WIDTH"] ?? 0), "HEIGHT" => (int)($mainPicture["HEIGHT"] ?? 0)]; +} +$photos = (array)($properties["MORE_PHOTO"]["VALUE"] ?? []); +$descriptions = (array)($properties["MORE_PHOTO"]["DESCRIPTION"] ?? []); +foreach (array_filter($photos) as $index => $fileId) { + $file = CFile::GetFileArray((int)$fileId); + $src = (string)($file["SRC"] ?? ""); + if ($src === "") { + continue; + } + $description = trim((string)($descriptions[$index] ?? "")); + $gallery[] = [ + "SRC" => $src, + "SRCSET" => $srcset((int)$fileId, $src, (int)($file["WIDTH"] ?? 0)), + "THUMB" => $thumb((int)$fileId, $src), + "WIDTH" => (int)($file["WIDTH"] ?? 0), + "HEIGHT" => (int)($file["HEIGHT"] ?? 0), + "ALT" => $description !== "" ? $arResult["~NAME"] . ", " . $description : (string)Loc::getMessage("VINO_PDP_PHOTO_ALT", ["#NAME#" => $arResult["~NAME"]]), + ]; +} + +$price = reset($arResult["ITEM_PRICES"]) ?: []; +$printPrice = (string)($price["PRINT_RATIO_PRICE"] ?? $price["PRINT_PRICE"] ?? ""); +$hasDiscount = (float)($price["RATIO_BASE_PRICE"] ?? 0) > (float)($price["RATIO_PRICE"] ?? 0); +$printOldPrice = $hasDiscount ? (string)($price["PRINT_RATIO_BASE_PRICE"] ?? "") : ""; +$discountPercent = $hasDiscount ? (int)round((float)($price["PERCENT"] ?? 0)) : 0; +$priceValue = (float)($price["RATIO_PRICE"] ?? $price["PRICE"] ?? 0); +$currency = (string)($price["CURRENCY"] ?? ""); + +$kind = $colorCode !== "" ? (string)Loc::getMessage("VINO_PDP_KIND_" . strtoupper($colorCode)) : ""; +$kicker = trim(($kind !== "" ? $kind : (string)Loc::getMessage("VINO_PDP_KIND")) . ($country !== "" ? " · " . $country : ""), " ·,"); + +$specs = [[$label("TYPE"), $text("WINE_CATEGORY")], [$label("COUNTRY"), $country], [$label("REGION"), $region], [$label("PRODUCER"), $producer], [$label("GRAPE"), $grape]]; +if ($colorCode === "sparkling") { + $specs = array_merge($specs, [ + [$label("METHOD"), $text("WINE_METHOD")], [$label("PRESSURE"), $text("PRESSURE")], + [$label("DOSAGE"), $sugar], [$label("RESIDUAL_SUGAR"), $text("RESIDUAL_SUGAR")], + [$label("ABV"), $alcohol], [$label("VOLUME"), $volume], [$label("VINTAGE"), $vintage], + [$label("AGING_LEES"), $aging], [$label("SERVE"), $serve], + ]); +} elseif ($colorCode === "dessert") { + $specs = array_merge($specs, [ + [$label("SUGAR"), $sugar], [$label("RESIDUAL_SUGAR"), $text("RESIDUAL_SUGAR")], + [$label("ABV"), $alcohol], [$label("VOLUME"), $volume], [$label("VINTAGE"), $vintage], + [$label("AGING"), $aging], [$label("SERVE"), $serve], [$label("AFTER_OPEN"), $text("AFTER_OPEN")], + ]); +} else { + $specs = array_merge($specs, [ + [$label("COLOR"), $color], [$label("SUGAR"), $sugar], + [$label("ABV"), $alcohol], [$label("VOLUME"), $volume], [$label("VINTAGE"), $vintage], + [$label("AGING"), $aging], [$label("DECANT"), $text("DECANT")], [$label("SERVE"), $serve], + [$label("POTENTIAL"), $text("AGING_POTENTIAL")], + ]); +} +$tasting = [[$label("TASTE_COLOR"), $text("TASTE_COLOR")], [$label("AROMA"), $text("AROMA")], [$label("TASTE"), $text("TASTE")], [$label("FOOD"), $text("FOOD_PAIRING")]]; + +$reviewCount = (int)($properties["REVIEW_COUNT"]["VALUE"] ?? 0); +$reviewRating = (float)($properties["REVIEW_RATING"]["VALUE"] ?? 0); +$plainDetail = trim((string)preg_replace('/\s+/u', " ", strip_tags(str_replace("

", "

", $detail)))); +$url = VINO_HOST . $arResult["DETAIL_PAGE_URL"]; + +$canBuy = !empty($arResult["CAN_BUY"]); +$seoDescription = \Jinove\Vinoteca\Seo::fitDescription(\Jinove\Vinoteca\Seo::description($plainDetail), [(string)Loc::getMessage("VINO_PDP_META_TAIL_LONG"), (string)Loc::getMessage("VINO_PDP_META_TAIL_MEDIUM"), (string)Loc::getMessage("VINO_PDP_META_TAIL_SHORT")]); +$pathRelative = SITE_DIR !== "/" && str_starts_with($arResult["DETAIL_PAGE_URL"], SITE_DIR) ? "/" . substr($arResult["DETAIL_PAGE_URL"], strlen(SITE_DIR)) : $arResult["DETAIL_PAGE_URL"]; +$translations = []; +foreach (\Jinove\Vinoteca\Config::languages() as $language => $settings) { + if ($language !== LANGUAGE_ID) { + $translations[$language] = VINO_HOST . rtrim((string)$settings["dir"], "/") . $pathRelative; + } +} +$dates = \Bitrix\Iblock\ElementTable::getRow(["select" => ["DATE_CREATE", "TIMESTAMP_X"], "filter" => ["=ID" => (int)$arResult["ID"]]]); +$schemaProperties = []; +foreach (array_merge($specs, $tasting) as $row) { + if ($row[1] === "" || in_array($row[0], [$label("COUNTRY"), $label("PRODUCER")], true)) { + continue; + } + $entry = ["name" => $row[0], "value" => $row[1]]; + if ($row[0] === $label("ABV") && is_numeric($plain("ABV"))) { + $entry["value"] = (float)$plain("ABV"); + $entry["unitCode"] = "P1"; + } elseif ($row[0] === $label("VOLUME") && is_numeric($plain("VOLUME"))) { + $entry["value"] = (float)$plain("VOLUME"); + $entry["unitCode"] = "LTR"; + } + $schemaProperties[] = $entry; +} +$schemaImages = array_map(fn($item) => ["src" => VINO_HOST . $item["SRC"], "width" => $item["WIDTH"], "height" => $item["HEIGHT"], "alt" => $item["ALT"]], $gallery); +$schemaReviews = array_map(fn($item) => $item + ["language" => preg_match("/\p{Cyrillic}/u", $item["text"]) ? "ru" : LANGUAGE_ID], \Jinove\Vinoteca\Catalog\ReviewStats::items((int)$arResult["ID"])); +$schemaRelated = array_map(fn($item) => ["name" => $item["name"], "url" => VINO_HOST . $item["url"]], \Jinove\Vinoteca\Catalog\Related::summaries(\Jinove\Vinoteca\Catalog\Related::ids((int)VINO_CATALOG_IBLOCK, (int)$arResult["ID"]))); +$structured = \Jinove\Vinoteca\Catalog\WineSchema::card([ + "host" => VINO_HOST, + "language" => LANGUAGE_ID, + "url" => $url, + "name" => $arResult["~NAME"], + "description" => $plainDetail, + "pageDescription" => $seoDescription, + "images" => $schemaImages, + "sku" => $plain("ARTNUMBER"), + "category" => $text("WINE_CATEGORY") !== "" ? $text("WINE_CATEGORY") : $kind, + "country" => $country, + "vintage" => preg_match('/^\d{4}$/', $vintage) ? $vintage : "", + "brand" => ["name" => $producer, "url" => !empty($brand["DETAIL_PAGE_URL"]) ? VINO_HOST . $brand["DETAIL_PAGE_URL"] : ""], + "properties" => $schemaProperties, + "price" => $priceValue, + "currency" => $currency, + "listPrice" => $hasDiscount ? (float)($price["RATIO_BASE_PRICE"] ?? 0) : 0.0, + "canBuy" => $canBuy, + "reviewCount" => $reviewCount, + "reviewRating" => $reviewRating, + "reviews" => $schemaReviews, + "related" => $schemaRelated, + "translations" => $translations, + "created" => $dates ? $dates["DATE_CREATE"]->format("c") : date("c"), + "modified" => $dates ? $dates["TIMESTAMP_X"]->format("c") : date("c"), +]); + +$chips = array_values(array_filter([$color, $sugar, $grape, $volume, $alcohol])); +$chipKeys = array_map(fn($chip) => mb_strtolower((string)$chip), $chips); +$detailView = LANGUAGE_ID === "ru" ? (string)preg_replace(['~^\s*

[^<]*Регион [^<]*

\s*~u', '~^\s*

Произведено домом [^<]*

\s*~u'], "", $detail, 1) : $detail; + +$arResult["VINO"] = [ + "CAN_BUY" => $canBuy, + "KICKER" => $kicker, + "BRAND" => $producer, + "ARTICLE" => $plain("ARTNUMBER"), + "OLD_PRICE" => $printOldPrice, + "PERCENT" => $discountPercent, + "CHIPS" => $chips, + "PRICE" => strtr($printPrice, ["₽" => '₽', "₽" => '₽']), + "GALLERY" => $gallery, + "DETAIL" => $detailView, + "SPECS" => array_values(array_filter($specs, fn($row) => $row[1] !== "" && !in_array(mb_strtolower((string)$row[1]), $chipKeys, true))), + "TASTING" => array_values(array_filter($tasting, fn($row) => $row[1] !== "")), + "REVIEW_COUNT" => $reviewCount, + "REVIEW_RATING" => number_format($reviewRating, 1, LANGUAGE_ID === "en" ? "." : ",", ""), + "STRUCTURED" => $structured, +]; +$arResult["VINO_SEO"] = [ + "IMAGE" => isset($gallery[0]) ? VINO_HOST . $gallery[0]["SRC"] : "", + "DESCRIPTION" => $seoDescription, + "TITLE" => \Jinove\Vinoteca\Seo::fitTitle([(string)Loc::getMessage("VINO_PDP_META_TITLE", ["#NAME#" => $arResult["~NAME"]]), (string)Loc::getMessage("VINO_PDP_META_TITLE_SHORT", ["#NAME#" => $arResult["~NAME"]])]), +]; +$this->__component->SetResultCacheKeys(["VINO_SEO"]); diff --git a/local/templates/jinove_wine/components/bitrix/catalog.element/.default/script.js b/local/templates/jinove_wine/components/bitrix/catalog.element/.default/script.js new file mode 100644 index 0000000..4821e81 --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/catalog.element/.default/script.js @@ -0,0 +1,95 @@ +(function () { + function initGallery() { + var gallery = document.querySelector('[data-gallery]'); + if (!gallery) return; + var main = gallery.querySelector('[data-gallery-main]'); + var thumbs = gallery.querySelectorAll('[data-gallery-thumb]'); + if (!main || !thumbs.length) return; + thumbs.forEach(function (thumb) { + thumb.addEventListener('click', function () { + main.srcset = thumb.getAttribute('data-gallery-srcset') || ''; + main.src = thumb.getAttribute('data-gallery-src'); + main.alt = thumb.getAttribute('data-gallery-alt'); + thumbs.forEach(function (item) { + var active = item === thumb; + item.classList.toggle('vino-pdp__thumb--active', active); + item.setAttribute('aria-pressed', active ? 'true' : 'false'); + }); + }); + }); + } + + function initLightbox() { + var gallery = document.querySelector('[data-gallery]'); + if (!gallery || !window.PhotoSwipe) return; + var main = gallery.querySelector('[data-gallery-main]'); + var opener = gallery.querySelector('[data-gallery-open]'); + var thumbs = Array.prototype.slice.call(gallery.querySelectorAll('[data-gallery-thumb]')); + if (!main || !opener) return; + function items() { + if (!thumbs.length) { + return [{ src: main.getAttribute('src'), width: Number(main.getAttribute('width')) || main.naturalWidth, height: Number(main.getAttribute('height')) || main.naturalHeight, alt: main.alt }]; + } + return thumbs.map(function (thumb) { + return { + src: thumb.getAttribute('data-gallery-src'), + width: Number(thumb.getAttribute('data-gallery-width')) || 1536, + height: Number(thumb.getAttribute('data-gallery-height')) || 1024, + alt: thumb.getAttribute('data-gallery-alt') || '' + }; + }); + } + opener.addEventListener('click', function () { + var index = 0; + thumbs.forEach(function (thumb, position) { + if (thumb.classList.contains('vino-pdp__thumb--active')) index = position; + }); + var pswp = new window.PhotoSwipe({ dataSource: items(), index: index, bgOpacity: 0.94, wheelToZoom: true }); + pswp.on('change', function () { + if (thumbs[pswp.currIndex]) thumbs[pswp.currIndex].click(); + }); + pswp.init(); + }); + } + + function initStepper() { + var stepper = document.querySelector('[data-stepper]'); + if (!stepper) return; + var output = stepper.querySelector('output'); + var value = 1; + stepper.querySelectorAll('[data-stepper-step]').forEach(function (button) { + button.addEventListener('click', function () { + value = Math.min(99, Math.max(1, value + Number(button.getAttribute('data-stepper-step')))); + output.textContent = value; + }); + }); + } + + function initRelated() { + var viewport = document.querySelector('[data-related-viewport]'); + var nav = document.querySelector('[data-related-nav]'); + if (!viewport || !nav) return; + function step() { + var card = viewport.querySelector('.vino-card'); + return card ? (card.getBoundingClientRect().width + 22) * 2 : 300; + } + nav.querySelectorAll('[data-dir]').forEach(function (button) { + button.addEventListener('click', function () { + viewport.scrollBy({ left: (Number(button.getAttribute('data-dir')) || 1) * step(), behavior: 'smooth' }); + }); + }); + } + + function init() { + initGallery(); + initLightbox(); + initStepper(); + initRelated(); + } + + if (document.readyState === 'loading') { + document.addEventListener('DOMContentLoaded', init); + } else { + init(); + } +})(); diff --git a/local/templates/jinove_wine/components/bitrix/catalog.element/.default/template.php b/local/templates/jinove_wine/components/bitrix/catalog.element/.default/template.php new file mode 100644 index 0000000..87187b0 --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/catalog.element/.default/template.php @@ -0,0 +1,91 @@ +addExternalCss(SITE_TEMPLATE_PATH . "/assets/vendor/photoswipe/photoswipe.css?v=5.4.4"); + $this->addExternalJs(SITE_TEMPLATE_PATH . "/assets/vendor/photoswipe/photoswipe.umd.min.js?v=5.4.4"); +} +?> + +
+
+
+ + +
+

+

+ + + + +
+ + +
+
">−% $vino["ARTICLE"]))) ?>
+

">

+
+ +
+ + 1 + +
+ + + + + + +
+
    +
  • +
  • +
  • +
  • +
+
+
+
+ +
+
+

+ + +
+
+
+ +
+ +
+
+
diff --git a/local/templates/jinove_wine/components/bitrix/catalog.item/vinoteca/card/template.php b/local/templates/jinove_wine/components/bitrix/catalog.item/vinoteca/card/template.php new file mode 100644 index 0000000..cb51c72 --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/catalog.item/vinoteca/card/template.php @@ -0,0 +1,24 @@ + + diff --git a/local/templates/jinove_wine/components/bitrix/catalog.item/vinoteca/lang/en/card/template.php b/local/templates/jinove_wine/components/bitrix/catalog.item/vinoteca/lang/en/card/template.php new file mode 100644 index 0000000..b3d9bbc --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/catalog.item/vinoteca/lang/en/card/template.php @@ -0,0 +1 @@ + + diff --git a/local/templates/jinove_wine/components/bitrix/catalog.item/vinoteca/parts/buy.php b/local/templates/jinove_wine/components/bitrix/catalog.item/vinoteca/parts/buy.php new file mode 100644 index 0000000..eb7650d --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/catalog.item/vinoteca/parts/buy.php @@ -0,0 +1,22 @@ + +
+ −% + +
"> + + 1 + +
+ + + + +
diff --git a/local/templates/jinove_wine/components/bitrix/catalog.item/vinoteca/parts/rating.php b/local/templates/jinove_wine/components/bitrix/catalog.item/vinoteca/parts/rating.php new file mode 100644 index 0000000..44124a2 --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/catalog.item/vinoteca/parts/rating.php @@ -0,0 +1,10 @@ + + 0): ?> $card["RATING_TEXT"], "#COUNT#" => $card["REVIEWS"])) ?>"> () diff --git a/local/templates/jinove_wine/components/bitrix/catalog.item/vinoteca/parts/tools.php b/local/templates/jinove_wine/components/bitrix/catalog.item/vinoteca/parts/tools.php new file mode 100644 index 0000000..820457c --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/catalog.item/vinoteca/parts/tools.php @@ -0,0 +1,13 @@ + +
+ + +
diff --git a/local/templates/jinove_wine/components/bitrix/catalog.item/vinoteca/result_modifier.php b/local/templates/jinove_wine/components/bitrix/catalog.item/vinoteca/result_modifier.php new file mode 100644 index 0000000..d570283 --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/catalog.item/vinoteca/result_modifier.php @@ -0,0 +1,86 @@ + 0) { + $GLOBALS["VINO_BRAND_NAMES"] = $GLOBALS["VINO_BRAND_NAMES"] ?? array(); + if (!isset($GLOBALS["VINO_BRAND_NAMES"][$brandId])) { + $brandRow = \Bitrix\Iblock\ElementTable::getRow(array("select" => array("NAME"), "filter" => array("=ID" => $brandId))); + $GLOBALS["VINO_BRAND_NAMES"][$brandId] = (string)($brandRow["NAME"] ?? ""); + } + $brandName = $GLOBALS["VINO_BRAND_NAMES"][$brandId]; +} + +$image = null; +$pictureId = (int)($item["PREVIEW_PICTURE"]["ID"] ?? 0) ?: (int)($item["DETAIL_PICTURE"]["ID"] ?? 0); +if ($pictureId > 0) { + $resized = CFile::ResizeImageGet($pictureId, array("width" => 420, "height" => 520), BX_RESIZE_IMAGE_PROPORTIONAL, true); + if (!empty($resized["src"])) { + $image = array("SRC" => $resized["src"], "WIDTH" => (int)($resized["width"] ?? 0), "HEIGHT" => (int)($resized["height"] ?? 0)); + } +} + +$price = ""; +$prices = $item["ITEM_PRICES"] ?? array(); +$oldPrice = ""; +$percent = 0; +if ($prices) { + $selected = $prices[$item["ITEM_PRICE_SELECTED"] ?? 0] ?? reset($prices); + if ((float)($selected["RATIO_PRICE"] ?? 0) > 0) { + $price = (string)$selected["PRINT_RATIO_PRICE"]; + } + if ((float)($selected["RATIO_BASE_PRICE"] ?? 0) > (float)($selected["RATIO_PRICE"] ?? 0)) { + $oldPrice = (string)$selected["PRINT_RATIO_BASE_PRICE"]; + $percent = (int)round((float)($selected["PERCENT"] ?? 0)); + } +} + +$volume = $value("VOLUME"); +$enum = fn(string $code): string => EnumNames::fromProperty($item["PROPERTIES"][$code] ?? array()); +$abv = $value("ABV"); +$grapes = array_values(array_filter(array_map("trim", explode(",", $enum("GRAPE"))))); +$details = array_values(array_filter(array( + $abv !== "" ? str_replace(".", LANGUAGE_ID === "en" ? "." : ",", (string)(float)$abv) . "%" : "", + $value("VINTAGE"), +))); +$arResult["CARD"] = array( + "ID" => (int)$item["ID"], + "NAME" => $item["~NAME"] ?? $item["NAME"], + "URL" => $item["DETAIL_PAGE_URL"], + "IMG" => $image, + "BRAND" => $brandName, + "PLACE" => array_values(array_filter(array($enum("REGION"), $enum("COUNTRY")))), + "SPEC" => array_values(array_filter(array( + $enum("WINE_COLOR"), + $enum("SUGAR"), + $volume !== "" ? Loc::getMessage("VINO_ITEM_VOLUME", array("#VALUE#" => LANGUAGE_ID === "en" ? $volume : str_replace(".", ",", $volume))) : "", + ))), + "PRICE" => $price, + "OLD_PRICE" => $oldPrice, + "PERCENT" => $percent, + "CAN_BUY" => !empty($item["CAN_BUY"]), + "COMPARE" => !empty($item["CAN_BUY"]) || ($arResult["COMPARE_ALWAYS"] ?? "") === "Y", + "COMPARE_REMOVE" => ($arResult["COMPARE_ALWAYS"] ?? "") === "Y", + "DETAILS" => $details, + "GRAPES" => $grapes, + "RATING" => (float)$value("REVIEW_RATING"), + "REVIEWS" => (int)$value("REVIEW_COUNT"), +); +$arResult["CARD"]["RATING_TEXT"] = number_format($arResult["CARD"]["RATING"], 1, LANGUAGE_ID === "en" ? "." : ",", ""); diff --git a/local/templates/jinove_wine/components/bitrix/catalog.item/vinoteca/template.php b/local/templates/jinove_wine/components/bitrix/catalog.item/vinoteca/template.php new file mode 100644 index 0000000..656e935 --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/catalog.item/vinoteca/template.php @@ -0,0 +1,10 @@ + $section) { + $pictureId = (int)($section["PICTURE"]["ID"] ?? 0); + if ($pictureId <= 0) { + continue; + } + $small = CFile::ResizeImageGet($pictureId, array("width" => 480, "height" => 270), BX_RESIZE_IMAGE_EXACT, true); + $resized = CFile::ResizeImageGet($pictureId, array("width" => 800, "height" => 450), BX_RESIZE_IMAGE_EXACT, true); + if (!empty($resized["src"])) { + $arResult["SECTIONS"][$index]["VINO_IMG"] = array( + "SRC" => $resized["src"], + "SRCSET" => (!empty($small["src"]) ? $small["src"] . " 480w, " : "") . $resized["src"] . " 800w", + "WIDTH" => (int)$resized["width"], + "HEIGHT" => (int)$resized["height"], + ); + } +} diff --git a/local/templates/jinove_wine/components/bitrix/catalog.section.list/vinoteca-tiles/template.php b/local/templates/jinove_wine/components/bitrix/catalog.section.list/vinoteca-tiles/template.php new file mode 100644 index 0000000..810636c --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/catalog.section.list/vinoteca-tiles/template.php @@ -0,0 +1,31 @@ + +
+ $section): + $this->AddEditAction($section["ID"], $section["EDIT_LINK"], $editLink); + $count = (int)$section["ELEMENT_CNT"]; + $name = \Jinove\Vinoteca\Catalog\Sections::name((string)$section["CODE"], (string)$section["~NAME"]); + $list[] = array("@type" => "ListItem", "position" => $i + 1, "name" => $name, "url" => $base . $section["CODE"] . "/"); +?> + " href="catalog//"> + " srcset="" sizes="(max-width: 760px) calc(100vw - 32px), 50vw" width="" height="" alt=""> + $count)) ?> + + +
+ + + diff --git a/local/templates/jinove_wine/components/bitrix/catalog.section/vinoteca/component_epilog.php b/local/templates/jinove_wine/components/bitrix/catalog.section/vinoteca/component_epilog.php new file mode 100644 index 0000000..340a346 --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/catalog.section/vinoteca/component_epilog.php @@ -0,0 +1,23 @@ +SetTitle($vinoSection["PAGE_TITLE"] ?: $vinoSection["NAME"]); + if ($vinoSection["META_TITLE"] !== "") { + $APPLICATION->SetPageProperty("title", $vinoSection["META_TITLE"]); + } + if ($vinoSection["META_DESCRIPTION"] !== "") { + $APPLICATION->SetPageProperty("description", $vinoSection["META_DESCRIPTION"]); + } +} + +$requested = $_GET["PAGEN_" . (int)($arResult["VINO_NAV_NUM"] ?? 1)] ?? null; +if ($requested !== null && ($arParams["VINO_AJAX"] ?? "N") !== "Y") { + $requested = (string)$requested; + if (!ctype_digit($requested) || (int)$requested < 1 || (int)$requested > max(1, (int)($arResult["VINO_NAV_PAGES"] ?? 1))) { + \Bitrix\Iblock\Component\Tools::process404("", true, true, true); + } +} diff --git a/local/templates/jinove_wine/components/bitrix/catalog.section/vinoteca/lang/en/template.php b/local/templates/jinove_wine/components/bitrix/catalog.section/vinoteca/lang/en/template.php new file mode 100644 index 0000000..311bb21 --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/catalog.section/vinoteca/lang/en/template.php @@ -0,0 +1,17 @@ + $item) { + if (isset($vinoUrls[(int)$item["ID"]])) { + $arResult["ITEMS"][$key]["DETAIL_PAGE_URL"] = $vinoUrls[(int)$item["ID"]]["url"]; + } +} +$nav = $arResult["NAV_RESULT"] ?? null; +$arResult["VINO_NAV_NUM"] = $nav ? (int)$nav->NavNum : 1; +$arResult["VINO_NAV_PAGES"] = $nav ? (int)$nav->NavPageCount : 1; +$this->__component->SetResultCacheKeys(array("VINO_NAV_NUM", "VINO_NAV_PAGES")); diff --git a/local/templates/jinove_wine/components/bitrix/catalog.section/vinoteca/template.php b/local/templates/jinove_wine/components/bitrix/catalog.section/vinoteca/template.php new file mode 100644 index 0000000..5f90ee7 --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/catalog.section/vinoteca/template.php @@ -0,0 +1,91 @@ +NavRecordCount : count($items); + $sort = (string)($arParams["VINO_SORT"] ?? ""); + $sortUrls = (array)($arParams["VINO_SORT_URLS"] ?? array()); + $sortLabel = $sort !== "" ? Loc::getMessage("VINO_SECTION_SORT_" . $sort) : Loc::getMessage("VINO_SECTION_SORT_DEFAULT"); + $intro = (string)(\Jinove\Vinoteca\Catalog\Sections::byCode((string)($arParams["SECTION_CODE"] ?? ""))["DESCRIPTION"] ?? ""); + if ($intro !== ""): + ?>

+ + + +
+ $count)) ?> +
+ +
+ +
    "> + $url): $code = (string)$code; ?> +
  • ">>
  • + +
+
+
"> + + +
+
+
+

+
" id="catalog-grid"> +AddEditAction($item["ID"], $item["EDIT_LINK"], $editLink); + $APPLICATION->IncludeComponent("bitrix:catalog.item", "vinoteca", array( + "RESULT" => array("ITEM" => $item, "AREA_ID" => $this->GetEditAreaId($item["ID"]), "TYPE" => $view === "list" ? "LINE" : "CARD", "TITLE_TAG" => ($arParams["VINO_TITLE_TAG"] ?? "") === "h2" ? "h2" : "h3"), + ), $component, array("HIDE_ICONS" => "Y")); +endforeach; ?> +
+ + +NavPageNomer - 1) * (int)$nav->NavPageSize) : 0; + $listItems = array(); + foreach ($items as $i => $item) { + $listItem = array("@type" => "ListItem", "position" => $offset + $i + 1, "url" => VINO_HOST . $item["DETAIL_PAGE_URL"], "name" => $item["~NAME"]); + $picture = $item["PREVIEW_PICTURE"]["SRC"] ?? $item["DETAIL_PICTURE"]["SRC"] ?? ""; + if ($picture !== "") { + $listItem["image"] = VINO_HOST . $picture; + } + $listItems[] = $listItem; + } + ?> + + diff --git a/local/templates/jinove_wine/components/bitrix/catalog.smart.filter/.default/lang/en/template.php b/local/templates/jinove_wine/components/bitrix/catalog.smart.filter/.default/lang/en/template.php new file mode 100644 index 0000000..3629e76 --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/catalog.smart.filter/.default/lang/en/template.php @@ -0,0 +1,18 @@ + +
_form" action="" method="get" data-catalog-filter data-clear-url=""> +
+ +
+ + + +
+ " value="" placeholder=" (int)$min["VALUE"])) ?>" aria-label=""> + + " value="" placeholder=" (int)$max["VALUE"])) ?>" aria-label=""> +
+
+ +
+ + + +
+
+ = $visibleLimit && empty($value["CHECKED"]); + if ($isHidden) { + $hiddenCount++; + } + $position++; + $optionClass = "vino-filter__option"; + if ($isHidden) { + $optionClass .= " vino-filter__option--extra"; + } + if (!empty($value["DISABLED"])) { + $optionClass .= " vino-filter__option--disabled"; + } + ?> + + +
+ 0): ?> + + +
+
+ +
+ +
+ + +
+
diff --git a/local/templates/jinove_wine/components/bitrix/catalog.top/vinoteca-row/template.php b/local/templates/jinove_wine/components/bitrix/catalog.top/vinoteca-row/template.php new file mode 100644 index 0000000..0081eb5 --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/catalog.top/vinoteca-row/template.php @@ -0,0 +1,15 @@ +AddEditAction($item["ID"], $item["EDIT_LINK"], $editLink); + $APPLICATION->IncludeComponent("bitrix:catalog.item", "vinoteca", array( + "RESULT" => array("ITEM" => $item, "AREA_ID" => $this->GetEditAreaId($item["ID"]), "TYPE" => "CARD"), + ), $component, array("HIDE_ICONS" => "Y")); +} diff --git a/local/templates/jinove_wine/components/bitrix/catalog/vinoteca/country.php b/local/templates/jinove_wine/components/bitrix/catalog/vinoteca/country.php new file mode 100644 index 0000000..8d3f20c --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/catalog/vinoteca/country.php @@ -0,0 +1,6 @@ +IncludeComponent("jinove:catalog.listing", "", array("COUNTRY_CODE" => (string)$arResult["VARIABLES"]["COUNTRY_CODE"]), $component); diff --git a/local/templates/jinove_wine/components/bitrix/catalog/vinoteca/element.php b/local/templates/jinove_wine/components/bitrix/catalog/vinoteca/element.php new file mode 100644 index 0000000..4a91792 --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/catalog/vinoteca/element.php @@ -0,0 +1,129 @@ + +
+
+ +
+
+IncludeComponent("bitrix:catalog.element", ".default", array( + "IBLOCK_TYPE" => $arParams["IBLOCK_TYPE"], + "IBLOCK_ID" => $arParams["IBLOCK_ID"], + "ELEMENT_CODE" => $arResult["VARIABLES"]["ELEMENT_CODE"], + "SECTION_CODE" => $arResult["VARIABLES"]["SECTION_CODE"], + "SET_TITLE" => "Y", + "SET_BROWSER_TITLE" => "N", + "SET_CANONICAL_URL" => "Y", + "STRICT_SECTION_CHECK" => "Y", + "SET_STATUS_404" => $arParams["SET_STATUS_404"], + "SHOW_404" => $arParams["SHOW_404"], + "FILE_404" => $arParams["FILE_404"], + "MESSAGE_404" => $arParams["MESSAGE_404"], + "ADD_SECTIONS_CHAIN" => "N", + "ADD_ELEMENT_CHAIN" => "Y", + "PRICE_CODE" => $arParams["PRICE_CODE"], + "BASKET_URL" => $arParams["BASKET_URL"], + "ACTION_VARIABLE" => $arParams["ACTION_VARIABLE"], + "PRODUCT_ID_VARIABLE" => $arParams["PRODUCT_ID_VARIABLE"], + "CACHE_TYPE" => $arParams["CACHE_TYPE"], + "CACHE_TIME" => $arParams["CACHE_TIME"], + "PROPERTY_CODE" => $arParams["DETAIL_PROPERTY_CODE"], + "USE_PRODUCT_QUANTITY" => "Y", + "ADD_TO_BASKET_ACTION" => "ADD", + "SECTION_URL" => $arResult["FOLDER"] . $arResult["URL_TEMPLATES"]["section"], + "DETAIL_URL" => $arResult["FOLDER"] . $arResult["URL_TEMPLATES"]["element"], +), $component); +$relatedIds = $elementId ? \Jinove\Vinoteca\Catalog\Related::ids((int)VINO_CATALOG_IBLOCK, (int)$elementId) : array(); +if ($relatedIds) { + $GLOBALS["vinoRelatedFilter"] = array("ID" => $relatedIds); + ?> + +addJs(SITE_TEMPLATE_PATH . "/assets/js/vino-review.js"); + $GLOBALS["vinoReviewsFilter"] = array("PROPERTY_PRODUCT" => (int)$elementId); + $APPLICATION->IncludeComponent("bitrix:news.list", "vinoteca-reviews", array( + "IBLOCK_TYPE" => "catalog", + "IBLOCK_ID" => "reviews", + "NEWS_COUNT" => "50", + "SORT_BY1" => "ACTIVE_FROM", + "SORT_ORDER1" => "DESC", + "SORT_BY2" => "ID", + "SORT_ORDER2" => "DESC", + "FILTER_NAME" => "vinoReviewsFilter", + "FIELD_CODE" => array("PREVIEW_TEXT", "ACTIVE_FROM", "DATE_CREATE"), + "PROPERTY_CODE" => array("RATING", "AUTHOR"), + "CHECK_DATES" => "Y", + "SET_TITLE" => "N", + "SET_BROWSER_TITLE" => "N", + "SET_META_KEYWORDS" => "N", + "SET_META_DESCRIPTION" => "N", + "SET_LAST_MODIFIED" => "N", + "SET_STATUS_404" => "N", + "INCLUDE_IBLOCK_INTO_CHAIN" => "N", + "ADD_SECTIONS_CHAIN" => "N", + "DISPLAY_TOP_PAGER" => "N", + "DISPLAY_BOTTOM_PAGER" => "N", + "CACHE_TYPE" => $arParams["CACHE_TYPE"], + "CACHE_TIME" => $arParams["CACHE_TIME"], + "CACHE_FILTER" => "Y", + "CACHE_GROUPS" => "N", + "VINO_PRODUCT_ID" => (int)$elementId, + "VINO_PRODUCT_NAME" => $APPLICATION->GetTitle(false), + ), $component); +} diff --git a/local/templates/jinove_wine/components/bitrix/catalog/vinoteca/lang/en/element.php b/local/templates/jinove_wine/components/bitrix/catalog/vinoteca/lang/en/element.php new file mode 100644 index 0000000..dc02fb4 --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/catalog/vinoteca/lang/en/element.php @@ -0,0 +1,5 @@ +getContext()->getRequest(); +$sort = (string)$request->getQuery("sort"); +if (!in_array($sort, Listing::SORTS, true)) { + $sort = ""; +} +$sectionCode = (string)$arResult["VARIABLES"]["SECTION_CODE"]; +if ($sectionCode !== strtolower($sectionCode)) { + $query = (string)($_SERVER["QUERY_STRING"] ?? ""); + LocalRedirect(VINO_HOST . strtolower($APPLICATION->GetCurPage(false)) . ($query !== "" ? "?" . $query : ""), true, "301 Moved permanently"); +} +$filterPath = (string)($arResult["VARIABLES"]["SMART_FILTER_PATH"] ?? ""); +if (!Listing::filterPathIsValid($sectionCode, $filterPath)) { + \Bitrix\Iblock\Component\Tools::process404("", true, true, true); + + return; +} +$sectionPath = Listing::sectionPath($sectionCode); +$pagePath = Listing::pagePath($sectionCode, $filterPath, $sort, max(1, (int)$request->getQuery("PAGEN_1"))); +if ($filterPath !== "" || $sort !== "") { + $APPLICATION->SetPageProperty("robots", "noindex, follow"); +} +$APPLICATION->SetPageProperty("vino_canonical", $pagePath); +$APPLICATION->SetPageProperty("og_image", VINO_HOST . SITE_TEMPLATE_PATH . "/assets/media/og-catalog.jpg"); +?> +
+
+ +

ShowTitle(false); ?>

+
+
+ +
+
+ IncludeComponent("jinove:catalog.listing", "", array( + "SECTION_CODE" => $sectionCode, + "FILTER_PATH" => $filterPath, + ), $component); ?> +
+
+ "https://schema.org", + "@type" => "CollectionPage", + "@id" => $pageUrl . "#webpage", + "url" => $pageUrl, + "name" => $APPLICATION->GetTitle(false), + "description" => $APPLICATION->GetPageProperty("description"), + "inLanguage" => LANGUAGE_ID, + "about" => array("@id" => VINO_HOST . "/#store"), + "mainEntity" => array("@id" => $pageUrl . "#items"), + "workTranslation" => \Jinove\Vinoteca\PageSchema::translations($pagePath, "CollectionPage"), +); +?> + diff --git a/local/templates/jinove_wine/components/bitrix/catalog/vinoteca/sections.php b/local/templates/jinove_wine/components/bitrix/catalog/vinoteca/sections.php new file mode 100644 index 0000000..fff09a8 --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/catalog/vinoteca/sections.php @@ -0,0 +1,64 @@ +getContext()->getRequest()->getQuery("country")); +if ($legacyCountry !== "") { + LocalRedirect(VINO_HOST . Listing::countryPath($legacyCountry), true, "301 Moved permanently"); +} + +$site = VINO_HOST . SITE_DIR; +$page = $site . "catalog/"; +$ogImage = VINO_HOST . SITE_TEMPLATE_PATH . "/assets/media/og-catalog.jpg"; +$APPLICATION->SetPageProperty("og_image", $ogImage); +$ld = array( + "@context" => "https://schema.org", + "@graph" => array( + array( + "@type" => "CollectionPage", + "@id" => $page . "#webpage", + "url" => $page, + "name" => Loc::getMessage("VINO_CATALOG_H1"), + "description" => $APPLICATION->GetPageProperty("description"), + "inLanguage" => LANGUAGE_ID, + "about" => array("@id" => VINO_HOST . "/#store"), + "mainEntity" => array("@id" => $page . "#sections"), + "primaryImageOfPage" => \Jinove\Vinoteca\PageSchema::image($page . "#image", $ogImage, 1200, 630), + "workTranslation" => \Jinove\Vinoteca\PageSchema::translations(SITE_DIR . "catalog/", "CollectionPage"), + ), + ), +); +?> + +
+
+ +

+
+ + + + +
+ +

+

+
+
+ + +
+
+
+
+
+
+
+ IncludeComponent("bitrix:catalog.section.list", "vinoteca-tiles", \Jinove\Vinoteca\Catalog\Listing::sectionTilesParams(), $component); ?> +
+
+
diff --git a/local/templates/jinove_wine/components/bitrix/menu/vinoteca_footer/template.php b/local/templates/jinove_wine/components/bitrix/menu/vinoteca_footer/template.php new file mode 100644 index 0000000..736b134 --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/menu/vinoteca_footer/template.php @@ -0,0 +1,11 @@ + + diff --git a/local/templates/jinove_wine/components/bitrix/menu/vinoteca_top/lang/en/template.php b/local/templates/jinove_wine/components/bitrix/menu/vinoteca_top/lang/en/template.php new file mode 100644 index 0000000..8a22ebd --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/menu/vinoteca_top/lang/en/template.php @@ -0,0 +1,8 @@ + +
+ + +
diff --git a/local/templates/jinove_wine/components/bitrix/news.list/vhero/component_epilog.php b/local/templates/jinove_wine/components/bitrix/news.list/vhero/component_epilog.php new file mode 100644 index 0000000..983ec37 --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/news.list/vhero/component_epilog.php @@ -0,0 +1,9 @@ +AddHeadString(''); +} +$APPLICATION->AddHeadString(''); diff --git a/local/templates/jinove_wine/components/bitrix/news.list/vhero/lang/en/template.php b/local/templates/jinove_wine/components/bitrix/news.list/vhero/lang/en/template.php new file mode 100644 index 0000000..d4c447d --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/news.list/vhero/lang/en/template.php @@ -0,0 +1,3 @@ + $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")); diff --git a/local/templates/jinove_wine/components/bitrix/news.list/vhero/script.js b/local/templates/jinove_wine/components/bitrix/news.list/vhero/script.js new file mode 100644 index 0000000..915b015 --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/news.list/vhero/script.js @@ -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(); +})(); diff --git a/local/templates/jinove_wine/components/bitrix/news.list/vhero/template.php b/local/templates/jinove_wine/components/bitrix/news.list/vhero/template.php new file mode 100644 index 0000000..0862c4c --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/news.list/vhero/template.php @@ -0,0 +1,36 @@ + +
+ +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"] ?? "")); +?> + " href=""> + ')"> + + + + + + + + + + + +
+ 1): ?> +
+ $arItem): ?> + + +
+ diff --git a/local/templates/jinove_wine/components/bitrix/news.list/vinoteca-brands/lang/en/template.php b/local/templates/jinove_wine/components/bitrix/news.list/vinoteca-brands/lang/en/template.php new file mode 100644 index 0000000..642dce5 --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/news.list/vinoteca-brands/lang/en/template.php @@ -0,0 +1,4 @@ + $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")); diff --git a/local/templates/jinove_wine/components/bitrix/news.list/vinoteca-brands/template.php b/local/templates/jinove_wine/components/bitrix/news.list/vinoteca-brands/template.php new file mode 100644 index 0000000..654e6f9 --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/news.list/vinoteca-brands/template.php @@ -0,0 +1,49 @@ + +
+
+
+
+

+

+
+
+ "> +
+
+
+
+ +
+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"] ?? ""))); + ?> + " id="GetEditAreaId($item["ID"]) ?>" href="">" width="" height="" alt="" loading="lazy" decoding="async"> + +
+ +
+ 1): ?> +
+ $page): ?> + + +
+ +
+
+
diff --git a/local/templates/jinove_wine/components/bitrix/news.list/vinoteca-news-list/result_modifier.php b/local/templates/jinove_wine/components/bitrix/news.list/vinoteca-news-list/result_modifier.php new file mode 100644 index 0000000..8a6212e --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/news.list/vinoteca-news-list/result_modifier.php @@ -0,0 +1,17 @@ + $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") +); diff --git a/local/templates/jinove_wine/components/bitrix/news.list/vinoteca-news-list/script.js b/local/templates/jinove_wine/components/bitrix/news.list/vinoteca-news-list/script.js new file mode 100644 index 0000000..abc7c73 --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/news.list/vinoteca-news-list/script.js @@ -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); + } +}); diff --git a/local/templates/jinove_wine/components/bitrix/news.list/vinoteca-news-list/style.css b/local/templates/jinove_wine/components/bitrix/news.list/vinoteca-news-list/style.css new file mode 100644 index 0000000..7ec4d61 --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/news.list/vinoteca-news-list/style.css @@ -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); + } +} diff --git a/local/templates/jinove_wine/components/bitrix/news.list/vinoteca-news-list/template.php b/local/templates/jinove_wine/components/bitrix/news.list/vinoteca-news-list/template.php new file mode 100644 index 0000000..83805d1 --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/news.list/vinoteca-news-list/template.php @@ -0,0 +1,26 @@ + +
+
+ $item): + $this->AddEditAction($item["ID"], $item["EDIT_LINK"], $editLink); + $this->AddDeleteAction($item["ID"], $item["DELETE_LINK"], $deleteLink); + $picture = $item["VINO_PICTURE"]; + ?> + + +
+ +
+ diff --git a/local/templates/jinove_wine/components/bitrix/news.list/vinoteca-news/result_modifier.php b/local/templates/jinove_wine/components/bitrix/news.list/vinoteca-news/result_modifier.php new file mode 100644 index 0000000..f5f214f --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/news.list/vinoteca-news/result_modifier.php @@ -0,0 +1,8 @@ + $item) { + $arResult["ITEMS"][$index] = \Jinove\Vinoteca\News::card($item); +} diff --git a/local/templates/jinove_wine/components/bitrix/news.list/vinoteca-news/template.php b/local/templates/jinove_wine/components/bitrix/news.list/vinoteca-news/template.php new file mode 100644 index 0000000..cd855a4 --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/news.list/vinoteca-news/template.php @@ -0,0 +1,19 @@ + +
+ $arItem): + $this->AddEditAction($arItem["ID"], $arItem["EDIT_LINK"], $editLink); + $this->AddDeleteAction($arItem["ID"], $arItem["DELETE_LINK"], $deleteLink); + $pic = $arItem["VINO_PICTURE"]; +?> + + +
diff --git a/local/templates/jinove_wine/components/bitrix/news.list/vinoteca-offers/lang/en/template.php b/local/templates/jinove_wine/components/bitrix/news.list/vinoteca-offers/lang/en/template.php new file mode 100644 index 0000000..73b8643 --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/news.list/vinoteca-offers/lang/en/template.php @@ -0,0 +1,2 @@ + $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") +); diff --git a/local/templates/jinove_wine/components/bitrix/news.list/vinoteca-offers/style.css b/local/templates/jinove_wine/components/bitrix/news.list/vinoteca-offers/style.css new file mode 100644 index 0000000..09b0712 --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/news.list/vinoteca-offers/style.css @@ -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; + } +} diff --git a/local/templates/jinove_wine/components/bitrix/news.list/vinoteca-offers/template.php b/local/templates/jinove_wine/components/bitrix/news.list/vinoteca-offers/template.php new file mode 100644 index 0000000..b108b62 --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/news.list/vinoteca-offers/template.php @@ -0,0 +1,39 @@ + +
+ $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"]; +?> + + +
+ diff --git a/local/templates/jinove_wine/components/bitrix/news.list/vinoteca-reviews/lang/en/template.php b/local/templates/jinove_wine/components/bitrix/news.list/vinoteca-reviews/lang/en/template.php new file mode 100644 index 0000000..00e8c6a --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/news.list/vinoteca-reviews/lang/en/template.php @@ -0,0 +1,27 @@ +personal data on the terms and for the purposes set out in the Privacy Policy.'; +$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.'; diff --git a/local/templates/jinove_wine/components/bitrix/news.list/vinoteca-reviews/lang/pl/template.php b/local/templates/jinove_wine/components/bitrix/news.list/vinoteca-reviews/lang/pl/template.php new file mode 100644 index 0000000..c83cf3b --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/news.list/vinoteca-reviews/lang/pl/template.php @@ -0,0 +1,28 @@ +danych osobowych na warunkach i w celach określonych w Polityce prywatności.'; +$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.'; diff --git a/local/templates/jinove_wine/components/bitrix/news.list/vinoteca-reviews/lang/ru/template.php b/local/templates/jinove_wine/components/bitrix/news.list/vinoteca-reviews/lang/ru/template.php new file mode 100644 index 0000000..9136ae7 --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/news.list/vinoteca-reviews/lang/ru/template.php @@ -0,0 +1,28 @@ +персональных данных на условиях и для целей, определённых Политикой конфиденциальности.'; +$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"] = 'Проверка не пройдена. Повторите попытку.'; diff --git a/local/templates/jinove_wine/components/bitrix/news.list/vinoteca-reviews/result_modifier.php b/local/templates/jinove_wine/components/bitrix/news.list/vinoteca-reviews/result_modifier.php new file mode 100644 index 0000000..c49c227 --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/news.list/vinoteca-reviews/result_modifier.php @@ -0,0 +1,23 @@ + $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"]; +} diff --git a/local/templates/jinove_wine/components/bitrix/news.list/vinoteca-reviews/template.php b/local/templates/jinove_wine/components/bitrix/news.list/vinoteca-reviews/template.php new file mode 100644 index 0000000..df50dbe --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/news.list/vinoteca-reviews/template.php @@ -0,0 +1,105 @@ +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 .= ''; + } + + return $out; +}; +$editLink = CIBlock::GetArrayByID($arResult["ID"], "ELEMENT_EDIT"); +$deleteLink = CIBlock::GetArrayByID($arResult["ID"], "ELEMENT_DELETE"); +?> +
+
+
+

+ 0): ?> +

+ $number($avg))) ?>"> + + $count)) ?> +

+ +

+ + +
+ 0): ?> +
    + AddEditAction($item["ID"], $item["EDIT_LINK"], $editLink); + $this->AddDeleteAction($item["ID"], $item["DELETE_LINK"], $deleteLink); + ?> + +
  • "> +
    + + +
    + $item["VINO_RATING"])) ?>"> +

    +
  • + +
+ +
+
+ + +
+ +
+ IncludeComponent("jinove:auth.login", ".default", array("EMBED" => "Y", "TITLE" => Loc::getMessage("VINO_REVIEWS_LOGIN_TITLE"), "LEAD" => Loc::getMessage("VINO_REVIEWS_LOGIN_LEAD")), false); ?> +
+
+
+

+

+
" + data-msg-rating="" + data-msg-author="" + data-msg-text="" + data-msg-consent="" + data-msg-altcha="" + data-msg-too-often="" + data-msg-error=""> + +
+ +
+ = 1; $i--): ?> + + + +
+
+ + + + + +
+
+ +
+
+
diff --git a/local/templates/jinove_wine/components/bitrix/news/vinoteca-brands/bitrix/news.detail/.default/component_epilog.php b/local/templates/jinove_wine/components/bitrix/news/vinoteca-brands/bitrix/news.detail/.default/component_epilog.php new file mode 100644 index 0000000..4183683 --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/news/vinoteca-brands/bitrix/news.detail/.default/component_epilog.php @@ -0,0 +1,11 @@ +SetPageProperty("description", $arResult["VINO_DESCRIPTION"]); +} +if (!empty($arResult["VINO_IMAGE"])) { + $GLOBALS["APPLICATION"]->SetPageProperty("og_image", $arResult["VINO_IMAGE"]); +} diff --git a/local/templates/jinove_wine/components/bitrix/news/vinoteca-brands/bitrix/news.detail/.default/lang/en/template.php b/local/templates/jinove_wine/components/bitrix/news/vinoteca-brands/bitrix/news.detail/.default/lang/en/template.php new file mode 100644 index 0000000..da6b308 --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/news/vinoteca-brands/bitrix/news.detail/.default/lang/en/template.php @@ -0,0 +1,8 @@ + trim((string)($arResult["PROPERTIES"][$code]["VALUE"] ?? "")); +$picture = $arResult["DETAIL_PICTURE"]; +$wines = \Jinove\Vinoteca\Catalog\BrandSchema::wines((int)$arResult["ID"]); +$place = implode(", ", array_filter([$propertyValue("COUNTRY"), $propertyValue("REGION")])); +$facts = (string)\Bitrix\Main\Localization\Loc::getMessage("VINO_BRAND_FACTS", ["#COUNT#" => $wines["total"]]); +$realText = $plainText; +if ($plainText === "") { + $arResult["~PREVIEW_TEXT"] = $facts; + $arResult["PREVIEW_TEXT"] = htmlspecialcharsbx($facts); + $plainText = (string)$arResult["~NAME"] . ": " . $place . ". " . $facts; +} elseif (mb_strlen($plainText) < 120) { + $plainText = rtrim($plainText, ".") . ". " . $facts; +} +if (mb_strlen($plainText) < 120) { + $candidate = $plainText . " " . (string)\Bitrix\Main\Localization\Loc::getMessage($realText === "" ? "VINO_BRAND_META_TAIL" : "VINO_BRAND_META_TAIL_SHORT"); + $plainText = mb_strlen($candidate) <= 160 ? $candidate : $plainText; +} +if (mb_strlen($plainText) < 120 && $place !== "") { + $candidate = $plainText . " " . $place . "."; + $plainText = mb_strlen($candidate) <= 160 ? $candidate : $plainText; +} +$arResult["VINO_DESCRIPTION"] = \Jinove\Vinoteca\Seo::description($plainText, 160); +$arResult["VINO_IMAGE"] = VINO_HOST . SITE_TEMPLATE_PATH . "/assets/media/og-catalog.jpg"; +$preview = $arResult["PREVIEW_PICTURE"]; +$arResult["VINO_SRCSET"] = !empty($preview["SRC"]) && !empty($picture["SRC"]) + ? $preview["SRC"] . " " . (int)$preview["WIDTH"] . "w, " . $picture["SRC"] . " " . (int)$picture["WIDTH"] . "w" + : ""; +$arResult["VINO_SCHEMA"] = \Jinove\Vinoteca\Catalog\BrandSchema::detail([ + "name" => (string)$arResult["~NAME"], + "url" => $brandUrl, + "path" => (string)$arResult["DETAIL_PAGE_URL"], + "description" => $realText, + "pageDescription" => $arResult["VINO_DESCRIPTION"], + "logo" => !empty($picture["SRC"]) ? VINO_HOST . $picture["SRC"] : "", + "logoWidth" => (int)($picture["WIDTH"] ?? 0), + "logoHeight" => (int)($picture["HEIGHT"] ?? 0), + "country" => \Jinove\Vinoteca\Catalog\BrandSchema::countryCode((string)($arResult["PROPERTIES"]["COUNTRY_EN"]["VALUE"] ?? "")) ?: $propertyValue("COUNTRY"), + "region" => $propertyValue("REGION"), + "founded" => $propertyValue("FOUNDED"), +], $wines["items"], $wines["total"]); +$this->__component->SetResultCacheKeys(["VINO_DESCRIPTION", "VINO_IMAGE"]); diff --git a/local/templates/jinove_wine/components/bitrix/news/vinoteca-brands/bitrix/news.detail/.default/template.php b/local/templates/jinove_wine/components/bitrix/news/vinoteca-brands/bitrix/news.detail/.default/template.php new file mode 100644 index 0000000..296a8e0 --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/news/vinoteca-brands/bitrix/news.detail/.default/template.php @@ -0,0 +1,37 @@ + $founded)) : "")); +$pic = $arResult["DETAIL_PICTURE"]; +$this->AddEditAction($arResult["ID"], $arResult["EDIT_LINK"], CIBlock::GetArrayByID($arResult["IBLOCK_ID"], "ELEMENT_EDIT")); +?> + +
"> +
+
+
+

+

+
+
+
+
+
+

+
+
" fetchpriority="high" width="" height="" alt="" decoding="async">
+
+
+
diff --git a/local/templates/jinove_wine/components/bitrix/news/vinoteca-brands/bitrix/news.list/.default/lang/en/template.php b/local/templates/jinove_wine/components/bitrix/news/vinoteca-brands/bitrix/news.list/.default/lang/en/template.php new file mode 100644 index 0000000..d428cda --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/news/vinoteca-brands/bitrix/news.list/.default/lang/en/template.php @@ -0,0 +1,7 @@ + $item) { + $arResult["ITEMS"][$index] = \Jinove\Vinoteca\Catalog\LocalizedText::localizeItem($item, array("PREVIEW_TEXT"), array("COUNTRY", "REGION", "GRAPE")); +} + +$schemaItems = []; +foreach ($arResult["ITEMS"] as $item) { + $schemaItems[] = ["name" => (string)$item["~NAME"], "url" => VINO_HOST . $item["DETAIL_PAGE_URL"]]; +} +$arResult["VINO_SCHEMA"] = \Jinove\Vinoteca\Catalog\BrandSchema::list($schemaItems, (string)$GLOBALS["APPLICATION"]->GetTitle(false), (string)$GLOBALS["APPLICATION"]->GetPageProperty("description")); + +$letters = []; +$countries = []; +foreach ($arResult["ITEMS"] as $index => $item) { + $first = mb_strtoupper(mb_substr(trim((string)$item["~NAME"]), 0, 1)); + $letter = preg_match('/^\p{L}$/u', $first) ? $first : "0-9"; + $country = trim((string)($item["PROPERTIES"]["COUNTRY"]["~VALUE"] ?? "")); + $arResult["ITEMS"][$index]["VINO_LETTER"] = $letter; + $arResult["ITEMS"][$index]["VINO_COUNTRY"] = $country; + $letters[$letter] = true; + if ($country !== "") { + $countries[$country] = ($countries[$country] ?? 0) + 1; + } +} +ksort($letters); +ksort($countries); +$arResult["VINO_LETTERS"] = array_keys($letters); +$arResult["VINO_COUNTRIES"] = $countries; diff --git a/local/templates/jinove_wine/components/bitrix/news/vinoteca-brands/bitrix/news.list/.default/script.js b/local/templates/jinove_wine/components/bitrix/news/vinoteca-brands/bitrix/news.list/.default/script.js new file mode 100644 index 0000000..7727bd6 --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/news/vinoteca-brands/bitrix/news.list/.default/script.js @@ -0,0 +1,82 @@ +(function () { + function init() { + var root = document.querySelector('[data-brands-filter]'); + var grid = document.querySelector('[data-brands-grid]'); + if (!root || !grid) return; + var items = [].slice.call(grid.querySelectorAll('[data-brand-letter]')); + var countries = [].slice.call(root.querySelectorAll('[data-filter-country]')); + var letters = [].slice.call(root.querySelectorAll('[data-filter-letter]')); + var found = root.querySelector('[data-brands-found]'); + var empty = document.querySelector('[data-brands-empty]'); + var more = document.querySelector('[data-brands-more]'); + var mobile = window.matchMedia('(max-width: 760px)'); + var step = 8; + var state = { country: '', letter: '', limit: step }; + + function matches(item, country, letter) { + return (!country || item.getAttribute('data-brand-country') === country) && (!letter || item.getAttribute('data-brand-letter') === letter); + } + + function count(country, letter) { + return items.filter(function (item) { return matches(item, country, letter); }).length; + } + + function render() { + var matched = items.filter(function (item) { return matches(item, state.country, state.letter); }); + var shown = matched.length; + var limit = mobile.matches ? state.limit : shown; + items.forEach(function (item) { + var index = matched.indexOf(item); + item.hidden = index < 0 || index >= limit; + }); + more.hidden = shown <= limit; + countries.forEach(function (button) { + var value = button.getAttribute('data-filter-country'); + var active = value === state.country; + button.classList.toggle('vino-brands__chip--active', active); + button.setAttribute('aria-pressed', active ? 'true' : 'false'); + button.disabled = !active && count(value, state.letter) === 0; + }); + letters.forEach(function (button) { + var value = button.getAttribute('data-filter-letter'); + var active = value === state.letter; + button.classList.toggle('vino-brands__letter--active', active); + button.setAttribute('aria-pressed', active ? 'true' : 'false'); + button.disabled = !active && count(state.country, value) === 0; + }); + found.textContent = (state.country || state.letter) ? found.getAttribute('data-template').replace('#COUNT#', String(shown)) : ''; + empty.hidden = shown !== 0; + } + + countries.forEach(function (button) { + button.addEventListener('click', function () { + state.country = button.getAttribute('data-filter-country'); + state.limit = step; + render(); + }); + }); + letters.forEach(function (button) { + button.addEventListener('click', function () { + var value = button.getAttribute('data-filter-letter'); + state.letter = state.letter === value ? '' : value; + state.limit = step; + render(); + }); + }); + more.addEventListener('click', function () { + var from = state.limit; + state.limit += step; + render(); + var next = items.filter(function (item) { return matches(item, state.country, state.letter); })[from]; + if (next) next.focus({ preventScroll: true }); + }); + mobile.addEventListener('change', render); + render(); + } + + if (document.readyState === 'loading') { + document.addEventListener('DOMContentLoaded', init); + } else { + init(); + } +})(); diff --git a/local/templates/jinove_wine/components/bitrix/news/vinoteca-brands/bitrix/news.list/.default/style.css b/local/templates/jinove_wine/components/bitrix/news/vinoteca-brands/bitrix/news.list/.default/style.css new file mode 100644 index 0000000..693769a --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/news/vinoteca-brands/bitrix/news.list/.default/style.css @@ -0,0 +1,76 @@ +.vino-brands__filter { + display: grid; + gap: var(--space-4); + margin: 0 0 var(--space-8); +} +.vino-brands__chips, +.vino-brands__letters { + display: flex; + flex-wrap: wrap; + gap: var(--space-2); +} +.vino-brands__chip, +.vino-brands__letter { + min-height: 44px; + padding: 0 var(--space-4); + border: 1px solid var(--color-line); + border-radius: var(--radius-sm); + background: transparent; + color: var(--color-text-muted); + font: inherit; + font-size: var(--text-15); + cursor: pointer; + transition: color var(--duration-fast) var(--ease-base), border-color var(--duration-fast) var(--ease-base), background-color var(--duration-fast) var(--ease-base), transform var(--duration-fast) var(--ease-base); +} +.vino-brands__letter { + min-width: 44px; + padding: 0; + text-align: center; +} +.vino-brands__chip--active, +.vino-brands__letter--active { + border-color: var(--color-accent); + background: var(--color-accent); + color: var(--color-bg); +} +.vino-brands__chip:disabled, +.vino-brands__letter:disabled { + opacity: .35; + cursor: default; +} +.vino-brands__chip:active:not(:disabled), +.vino-brands__letter:active:not(:disabled) { + transform: scale(.97); +} +.vino-brands__chip:focus-visible, +.vino-brands__letter:focus-visible { + outline: 2px solid var(--color-accent); + outline-offset: 2px; +} +.vino-brands__count { + margin-left: var(--space-1); + opacity: .7; +} +.vino-brands__found { + margin: 0; + min-height: calc(1em * var(--leading-ui)); + color: var(--color-text-muted); + font-size: var(--text-15); + line-height: var(--leading-ui); +} +.vino-brands__item[hidden], +.vino-brands__empty[hidden] { + display: none; +} +.vino-brands__empty { + margin: var(--space-8) 0; + color: var(--color-text-muted); + font-size: var(--text-base); +} +@media (hover: hover) { + .vino-brands__chip:hover:not(:disabled):not(.vino-brands__chip--active), + .vino-brands__letter:hover:not(:disabled):not(.vino-brands__letter--active) { + border-color: var(--color-accent); + color: var(--color-text); + } +} diff --git a/local/templates/jinove_wine/components/bitrix/news/vinoteca-brands/bitrix/news.list/.default/template.php b/local/templates/jinove_wine/components/bitrix/news/vinoteca-brands/bitrix/news.list/.default/template.php new file mode 100644 index 0000000..36c5bf4 --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/news/vinoteca-brands/bitrix/news.list/.default/template.php @@ -0,0 +1,46 @@ + + +
+
+
+
+
"> + + $count): ?> + + +
+
"> + + + +
+

">

+
+
+ $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"] ?? ""))); + ?> + " data-brand-letter="" data-brand-country="" id="GetEditAreaId($item["ID"]) ?>" href="">" width="" height="" alt="" loading="" decoding="async"> + +
+ + +
+
+
diff --git a/local/templates/jinove_wine/components/bitrix/news/vinoteca-brands/detail.php b/local/templates/jinove_wine/components/bitrix/news/vinoteca-brands/detail.php new file mode 100644 index 0000000..09877b0 --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/news/vinoteca-brands/detail.php @@ -0,0 +1,87 @@ + +
+
+ +
+
+IncludeComponent("bitrix:news.detail", "", array( + "IBLOCK_TYPE" => $arParams["IBLOCK_TYPE"], + "IBLOCK_ID" => $arParams["IBLOCK_ID"], + "ELEMENT_ID" => $arResult["VARIABLES"]["ELEMENT_ID"] ?? "", + "ELEMENT_CODE" => $arResult["VARIABLES"]["ELEMENT_CODE"] ?? "", + "FIELD_CODE" => $arParams["DETAIL_FIELD_CODE"], + "PROPERTY_CODE" => $arParams["DETAIL_PROPERTY_CODE"], + "DETAIL_URL" => $arResult["FOLDER"] . $arResult["URL_TEMPLATES"]["detail"], + "CHECK_DATES" => $arParams["CHECK_DATES"], + "CACHE_TYPE" => $arParams["CACHE_TYPE"], + "CACHE_TIME" => $arParams["CACHE_TIME"], + "CACHE_GROUPS" => $arParams["CACHE_GROUPS"], + "SET_TITLE" => "Y", + "SET_BROWSER_TITLE" => "N", + "SET_META_KEYWORDS" => "N", + "SET_META_DESCRIPTION" => "N", + "SET_LAST_MODIFIED" => "N", + "INCLUDE_IBLOCK_INTO_CHAIN" => "N", + "ADD_SECTIONS_CHAIN" => "N", + "ADD_ELEMENT_CHAIN" => "Y", + "SET_CANONICAL_URL" => "N", + "SET_STATUS_404" => $arParams["SET_STATUS_404"], + "SHOW_404" => $arParams["SHOW_404"], + "FILE_404" => $arParams["FILE_404"], + "MESSAGE_404" => $arParams["MESSAGE_404"], + "USE_PERMISSIONS" => "N", + "DISPLAY_TOP_PAGER" => "N", + "DISPLAY_BOTTOM_PAGER" => "N", +), $component); +if (!$brandId) { + return; +} +$brandName = $APPLICATION->GetTitle(false); +$APPLICATION->SetPageProperty("title", Loc::getMessage("VINO_BRAND_META_TITLE", array("#NAME#" => htmlspecialcharsbx($brandName)))); +$GLOBALS["brandFilter"] = array("PROPERTY_BRAND" => (int)$brandId); +?> +addJs(SITE_TEMPLATE_PATH . "/assets/js/vino-slider.js"); ?> +
+
+
+

htmlspecialcharsbx($brandName))) ?>

+
+ + +
+
+
+
+ IncludeComponent("bitrix:catalog.top", "vinoteca-row", array( + "IBLOCK_TYPE" => "catalog", + "IBLOCK_ID" => VINO_CATALOG_IBLOCK, + "ELEMENT_COUNT" => "24", + "ELEMENT_SORT_FIELD" => "SORT", + "ELEMENT_SORT_ORDER" => "ASC", + "ELEMENT_SORT_FIELD2" => "ID", + "ELEMENT_SORT_ORDER2" => "DESC", + "FILTER_NAME" => "brandFilter", + "PROPERTY_CODE" => array("WINE_COLOR", "SUGAR", "VOLUME", "REGION", "COUNTRY"), + "PRICE_CODE" => array("BASE"), + "PRICE_VAT_INCLUDE" => "Y", + "CONVERT_CURRENCY" => "N", + "HIDE_NOT_AVAILABLE" => "N", + "DETAIL_URL" => SITE_DIR . "catalog/#SECTION_CODE#/#ELEMENT_CODE#/", + "SECTION_URL" => SITE_DIR . "catalog/#SECTION_CODE#/", + "CACHE_TYPE" => $arParams["CACHE_TYPE"], + "CACHE_TIME" => "3600", + "CACHE_GROUPS" => "Y", + "CACHE_FILTER" => "Y", + ), $component); ?> +
+
+
+
+
diff --git a/local/templates/jinove_wine/components/bitrix/news/vinoteca-brands/lang/en/detail.php b/local/templates/jinove_wine/components/bitrix/news/vinoteca-brands/lang/en/detail.php new file mode 100644 index 0000000..fa79548 --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/news/vinoteca-brands/lang/en/detail.php @@ -0,0 +1,7 @@ + 1) { + \Bitrix\Iblock\Component\Tools::process404("", true, true, true); +} +$APPLICATION->SetTitle(Loc::getMessage("VINO_BRANDS_H1")); +$APPLICATION->SetPageProperty("title", Loc::getMessage("VINO_BRANDS_PAGE_TITLE")); +$APPLICATION->SetPageProperty("description", Loc::getMessage("VINO_BRANDS_DESCRIPTION")); +?> +
+
+ +

+
+
+IncludeComponent("bitrix:news.list", "", array( + "IBLOCK_TYPE" => $arParams["IBLOCK_TYPE"], + "IBLOCK_ID" => $arParams["IBLOCK_ID"], + "NEWS_COUNT" => $arParams["NEWS_COUNT"], + "SORT_BY1" => $arParams["SORT_BY1"], + "SORT_ORDER1" => $arParams["SORT_ORDER1"], + "SORT_BY2" => $arParams["SORT_BY2"], + "SORT_ORDER2" => $arParams["SORT_ORDER2"], + "FIELD_CODE" => $arParams["LIST_FIELD_CODE"], + "PROPERTY_CODE" => $arParams["LIST_PROPERTY_CODE"], + "DETAIL_URL" => $arResult["FOLDER"] . $arResult["URL_TEMPLATES"]["detail"], + "CHECK_DATES" => $arParams["CHECK_DATES"], + "CACHE_TYPE" => $arParams["CACHE_TYPE"], + "CACHE_TIME" => $arParams["CACHE_TIME"], + "CACHE_GROUPS" => $arParams["CACHE_GROUPS"], + "SET_TITLE" => "N", + "SET_BROWSER_TITLE" => "N", + "SET_META_KEYWORDS" => "N", + "SET_META_DESCRIPTION" => "N", + "SET_LAST_MODIFIED" => "N", + "SET_STATUS_404" => "N", + "INCLUDE_IBLOCK_INTO_CHAIN" => "N", + "ADD_SECTIONS_CHAIN" => "N", + "DISPLAY_TOP_PAGER" => "N", + "DISPLAY_BOTTOM_PAGER" => "N", +), $component); ?> diff --git a/local/templates/jinove_wine/components/bitrix/news/vinoteca-news/bitrix/news.detail/.default/component_epilog.php b/local/templates/jinove_wine/components/bitrix/news/vinoteca-news/bitrix/news.detail/.default/component_epilog.php new file mode 100644 index 0000000..6ddb31f --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/news/vinoteca-news/bitrix/news.detail/.default/component_epilog.php @@ -0,0 +1,17 @@ +SetPageProperty("description", $arResult["VINO_DESCRIPTION"]); +} +if (!empty($arResult["VINO_TITLE"])) { + $GLOBALS["APPLICATION"]->SetTitle($arResult["VINO_TITLE"]); + $GLOBALS["APPLICATION"]->SetPageProperty("title", $arResult["VINO_TITLE"]); + $GLOBALS["APPLICATION"]->AddChainItem($arResult["VINO_TITLE"], $arResult["DETAIL_PAGE_URL"]); +} +$GLOBALS["APPLICATION"]->SetPageProperty("og_type", "article"); +if (!empty($arResult["VINO_OG_IMAGE"])) { + $GLOBALS["APPLICATION"]->SetPageProperty("og_image", $arResult["VINO_OG_IMAGE"]); +} diff --git a/local/templates/jinove_wine/components/bitrix/news/vinoteca-news/bitrix/news.detail/.default/result_modifier.php b/local/templates/jinove_wine/components/bitrix/news/vinoteca-news/bitrix/news.detail/.default/result_modifier.php new file mode 100644 index 0000000..05f5506 --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/news/vinoteca-news/bitrix/news.detail/.default/result_modifier.php @@ -0,0 +1,26 @@ + 1200, "height" => 630), BX_RESIZE_IMAGE_EXACT, false); + $arResult["VINO_OG_IMAGE"] = !empty($og["src"]) ? VINO_HOST . $og["src"] : ""; +} +$published = $arResult["VINO_TIMESTAMP"]; +$modified = $arResult["TIMESTAMP_X"] ? \Bitrix\Main\Type\DateTime::createFromUserTime((string)$arResult["TIMESTAMP_X"])->getTimestamp() : 0; +$arResult["VINO_SCHEMA"] = \Jinove\Vinoteca\ArticleSchema::detail(array( + "path" => (string)$arResult["DETAIL_PAGE_URL"], + "name" => (string)$arResult["~NAME"], + "description" => $arResult["VINO_DESCRIPTION"], + "published" => $published ? date(DATE_ATOM, $published) : "", + "modified" => date(DATE_ATOM, max($modified, $published)), + "words" => count(preg_split('/\s+/u', trim(strip_tags((string)$arResult["~DETAIL_TEXT"])), -1, PREG_SPLIT_NO_EMPTY)), + "image" => $picture ? array("url" => VINO_HOST . $picture["SRC"], "width" => $picture["WIDTH"], "height" => $picture["HEIGHT"]) : array(), +)); +$arResult["VINO_TITLE"] = (string)$arResult["~NAME"]; +$this->getComponent()->setResultCacheKeys(array("VINO_DESCRIPTION", "VINO_OG_IMAGE", "VINO_TITLE", "DETAIL_PAGE_URL")); diff --git a/local/templates/jinove_wine/components/bitrix/news/vinoteca-news/bitrix/news.detail/.default/style.css b/local/templates/jinove_wine/components/bitrix/news/vinoteca-news/bitrix/news.detail/.default/style.css new file mode 100644 index 0000000..f11945c --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/news/vinoteca-news/bitrix/news.detail/.default/style.css @@ -0,0 +1,99 @@ +.vino-article { + --vino-article-measure: 46rem; + --vino-article-h2-size: clamp(1.375rem, 2.2vw, 1.75rem); + --vino-article-media-ratio: 16 / 9; + padding: var(--space-12) var(--gutter) var(--space-16); +} +.vino-article__head { + max-width: var(--vino-article-measure); + margin: 0 0 var(--space-10); +} +.vino-article__date { + display: block; + margin-bottom: var(--space-4); + color: var(--color-text-faint); + font-size: var(--text-13); + letter-spacing: var(--tracking-ui); + text-transform: uppercase; +} +.vino-article__title { + margin: 0; + color: var(--color-text); + font-family: var(--font-serif); + font-size: var(--fs-h2); + font-weight: 400; + line-height: var(--leading-tight); + letter-spacing: var(--tracking-tight); +} +.vino-article__lead { + margin: var(--space-6) 0 0; + color: var(--color-text-muted); + font-size: var(--text-19); + line-height: var(--leading-text); +} +.vino-article__media { + max-width: var(--vino-article-measure); + margin: 0 0 var(--space-12); + aspect-ratio: var(--vino-article-media-ratio); + overflow: hidden; +} +.vino-article__img { + display: block; + width: 100%; + height: 100%; + object-fit: cover; + object-position: 50% 10%; +} +.vino-article__body { + max-width: var(--vino-article-measure); + margin: 0; + color: color-mix(in srgb, var(--color-white) 82%, transparent); + font-size: var(--text-17); + line-height: var(--leading-long); +} +.vino-article__body p, .vino-article__body ul, .vino-article__body ol { + margin: 0 0 var(--space-5); +} +.vino-article__body ul, .vino-article__body ol { + padding-left: var(--space-6); +} +.vino-article__body li + li { + margin-top: var(--space-2); +} +.vino-article__body h2 { + margin: var(--space-10) 0 var(--space-4); + color: var(--color-text); + font-family: var(--font-serif); + font-size: var(--vino-article-h2-size); + font-weight: 400; + line-height: var(--leading-title); +} +.vino-article__body a { + color: var(--color-accent); + text-decoration: underline; + text-decoration-color: color-mix(in srgb, var(--color-accent) 45%, transparent); + text-underline-offset: 3px; +} +.vino-article__body > :last-child { + margin-bottom: 0; +} +@media (hover:hover) { + .vino-article__body a:hover { + text-decoration-color: var(--color-accent); + } +} +@media (max-width:760px) { + .vino-article { + --vino-article-media-ratio: 4 / 3; + padding-bottom: var(--space-12); + } + .vino-article__head { + margin-bottom: var(--space-6); + } + .vino-article__lead { + font-size: var(--text-17); + } + .vino-article__media { + margin-bottom: var(--space-8); + } +} diff --git a/local/templates/jinove_wine/components/bitrix/news/vinoteca-news/bitrix/news.detail/.default/template.php b/local/templates/jinove_wine/components/bitrix/news/vinoteca-news/bitrix/news.detail/.default/template.php new file mode 100644 index 0000000..9044012 --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/news/vinoteca-news/bitrix/news.detail/.default/template.php @@ -0,0 +1,24 @@ +AddEditAction($arResult["ID"], $arResult["EDIT_LINK"], CIBlock::GetArrayByID($arResult["IBLOCK_ID"], "ELEMENT_EDIT")); +$picture = $arResult["VINO_PICTURE"]; +?> + +
"> +
+
+ +

+

+
+ +
+ " srcset="" sizes="(max-width: 760px) calc((100vw - 32px) * 1.34), min(100vw, 1280px)" width="" height="" alt="" decoding="async" fetchpriority="high"> +
+ +
+
+
diff --git a/local/templates/jinove_wine/components/bitrix/news/vinoteca-news/detail.php b/local/templates/jinove_wine/components/bitrix/news/vinoteca-news/detail.php new file mode 100644 index 0000000..63b83c2 --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/news/vinoteca-news/detail.php @@ -0,0 +1,57 @@ + +
+
+ +
+
+IncludeComponent("bitrix:news.detail", "", array( + "IBLOCK_TYPE" => $arParams["IBLOCK_TYPE"], + "IBLOCK_ID" => $arParams["IBLOCK_ID"], + "ELEMENT_ID" => $arResult["VARIABLES"]["ELEMENT_ID"] ?? "", + "ELEMENT_CODE" => $arResult["VARIABLES"]["ELEMENT_CODE"] ?? "", + "FIELD_CODE" => $arParams["DETAIL_FIELD_CODE"], + "PROPERTY_CODE" => $arParams["DETAIL_PROPERTY_CODE"], + "DETAIL_URL" => $arResult["FOLDER"] . $arResult["URL_TEMPLATES"]["detail"], + "CHECK_DATES" => $arParams["CHECK_DATES"], + "CACHE_TYPE" => $arParams["CACHE_TYPE"], + "CACHE_TIME" => $arParams["CACHE_TIME"], + "CACHE_GROUPS" => $arParams["CACHE_GROUPS"], + "SET_TITLE" => "N", + "SET_BROWSER_TITLE" => "N", + "SET_META_KEYWORDS" => "N", + "SET_META_DESCRIPTION" => "N", + "SET_LAST_MODIFIED" => "N", + "INCLUDE_IBLOCK_INTO_CHAIN" => "N", + "ADD_SECTIONS_CHAIN" => "N", + "ADD_ELEMENT_CHAIN" => "N", + "SET_CANONICAL_URL" => "N", + "SET_STATUS_404" => $arParams["SET_STATUS_404"], + "SHOW_404" => $arParams["SHOW_404"], + "FILE_404" => $arParams["FILE_404"], + "MESSAGE_404" => $arParams["MESSAGE_404"], + "USE_PERMISSIONS" => "N", + "DISPLAY_TOP_PAGER" => "N", + "DISPLAY_BOTTOM_PAGER" => "N", +), $component); +if (!$newsId) { + return; +} +?> +
+
+
+

+ "> +
+
+ IncludeComponent("bitrix:news.list", "vinoteca-news", \Jinove\Vinoteca\News::otherParams((int)$newsId), $component); ?> +
+
+
diff --git a/local/templates/jinove_wine/components/bitrix/news/vinoteca-news/lang/en/detail.php b/local/templates/jinove_wine/components/bitrix/news/vinoteca-news/lang/en/detail.php new file mode 100644 index 0000000..81d8efc --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/news/vinoteca-news/lang/en/detail.php @@ -0,0 +1,4 @@ +getRequest()->getQuery("PAGEN_1"); +$page = 1; +if ($requested !== null) { + if ($requested === "1") { + LocalRedirect(VINO_HOST . \Jinove\Vinoteca\News::folder(), true, "301 Moved Permanently"); + } + if (!is_string($requested) || !ctype_digit($requested) || (int)$requested < 2 || (int)$requested > \Jinove\Vinoteca\News::pageCount()) { + \Bitrix\Iblock\Component\Tools::process404("", true, true, true); + + return; + } + $page = (int)$requested; +} +$meta = \Jinove\Vinoteca\News::pageMeta($page); +$APPLICATION->SetTitle(Loc::getMessage("VINO_NEWS_HEADING")); +$APPLICATION->SetPageProperty("title", $meta["title"]); +$APPLICATION->SetPageProperty("description", $meta["description"]); +if ($page > 1) { + $APPLICATION->SetPageProperty("vino_canonical", $meta["canonical"]); +} +?> +
+
+ +

+
+
+
+
+ IncludeComponent("bitrix:news.list", \Jinove\Vinoteca\News::LIST_TEMPLATE, \Jinove\Vinoteca\News::listParams(), $component); ?> +
+
diff --git a/local/templates/jinove_wine/components/bitrix/news/vinoteca-news/style.css b/local/templates/jinove_wine/components/bitrix/news/vinoteca-news/style.css new file mode 100644 index 0000000..16d2e03 --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/news/vinoteca-news/style.css @@ -0,0 +1,9 @@ +.vino-news-feed { + --vino-news-feed-title-size: 1.875rem; + padding: var(--space-head) var(--gutter) var(--space-16); +} +@media (max-width:760px) { + .vino-news-feed { + padding-bottom: var(--space-12); + } +} diff --git a/local/templates/jinove_wine/components/bitrix/news/vinoteca-offers/bitrix/news.detail/.default/component_epilog.php b/local/templates/jinove_wine/components/bitrix/news/vinoteca-offers/bitrix/news.detail/.default/component_epilog.php new file mode 100644 index 0000000..be81b7f --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/news/vinoteca-offers/bitrix/news.detail/.default/component_epilog.php @@ -0,0 +1,16 @@ +SetTitle($arResult["VINO_TITLE"]); + $GLOBALS["APPLICATION"]->SetPageProperty("title", $arResult["VINO_TITLE"]); + $GLOBALS["APPLICATION"]->AddChainItem($arResult["VINO_TITLE"], $arResult["DETAIL_PAGE_URL"]); +} +if (!empty($arResult["VINO_DESCRIPTION"])) { + $GLOBALS["APPLICATION"]->SetPageProperty("description", $arResult["VINO_DESCRIPTION"]); +} +if (!empty($arResult["VINO_OG_IMAGE"])) { + $GLOBALS["APPLICATION"]->SetPageProperty("og_image", $arResult["VINO_OG_IMAGE"]); +} diff --git a/local/templates/jinove_wine/components/bitrix/news/vinoteca-offers/bitrix/news.detail/.default/lang/en/template.php b/local/templates/jinove_wine/components/bitrix/news/vinoteca-offers/bitrix/news.detail/.default/lang/en/template.php new file mode 100644 index 0000000..2ad9fb3 --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/news/vinoteca-offers/bitrix/news.detail/.default/lang/en/template.php @@ -0,0 +1,6 @@ + 1200, "height" => 630), BX_RESIZE_IMAGE_EXACT, false); + $arResult["VINO_OG_IMAGE"] = !empty($og["src"]) ? VINO_HOST . $og["src"] : ""; +} +$picture = $arResult["VINO_PICTURE"]; +$arResult["VINO_SIZES_FACTOR"] = $picture && $picture["HEIGHT"] > 0 ? round(max(1, ($picture["WIDTH"] / $picture["HEIGHT"]) / (4 / 3)), 2) : 1; +$arResult["VINO_SCHEMA"] = \Jinove\Vinoteca\OfferSchema::detail(array( + "path" => (string)$arResult["DETAIL_PAGE_URL"], + "name" => (string)$arResult["~NAME"], + "description" => $arResult["VINO_DESCRIPTION"], + "start" => \Jinove\Vinoteca\OfferSchema::date((string)($arResult["ACTIVE_FROM"] ?? "")), + "end" => \Jinove\Vinoteca\OfferSchema::date((string)($arResult["DATE_ACTIVE_TO"] ?? $arResult["ACTIVE_TO"] ?? "")), + "image" => $picture ? array("url" => VINO_HOST . $picture["SRC"], "width" => $picture["WIDTH"], "height" => $picture["HEIGHT"]) : array(), +)); +$arResult["VINO_TITLE"] = (string)$arResult["~NAME"]; +$this->getComponent()->setResultCacheKeys(array("VINO_DESCRIPTION", "VINO_OG_IMAGE", "VINO_TITLE", "DETAIL_PAGE_URL")); diff --git a/local/templates/jinove_wine/components/bitrix/news/vinoteca-offers/bitrix/news.detail/.default/script.js b/local/templates/jinove_wine/components/bitrix/news/vinoteca-offers/bitrix/news.detail/.default/script.js new file mode 100644 index 0000000..2e543f8 --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/news/vinoteca-offers/bitrix/news.detail/.default/script.js @@ -0,0 +1,36 @@ +(function (run) { + if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', run); + else run(); +})(function () { + document.addEventListener('click', function (event) { + var button = event.target.closest('[data-offer-copy]'); + if (!button) return; + var box = button.parentNode; + var code = box.querySelector('.vino-offer__code-value'); + var status = box.querySelector('[data-offer-status]'); + var done = function () { + clearTimeout(button.vinoTimer); + button.textContent = button.getAttribute('data-copied'); + button.classList.add('vino-offer__copy--done'); + if (status) status.textContent = button.getAttribute('data-copied'); + button.vinoTimer = setTimeout(function () { + button.textContent = button.getAttribute('data-copy-label'); + button.classList.remove('vino-offer__copy--done'); + if (status) status.textContent = ''; + }, 2000); + }; + var select = function () { + if (!code) return; + var range = document.createRange(); + range.selectNodeContents(code); + var selection = window.getSelection(); + selection.removeAllRanges(); + selection.addRange(range); + }; + if (!navigator.clipboard) { + select(); + return; + } + navigator.clipboard.writeText(button.getAttribute('data-offer-copy')).then(done, select); + }); +}); diff --git a/local/templates/jinove_wine/components/bitrix/news/vinoteca-offers/bitrix/news.detail/.default/style.css b/local/templates/jinove_wine/components/bitrix/news/vinoteca-offers/bitrix/news.detail/.default/style.css new file mode 100644 index 0000000..8e21d7d --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/news/vinoteca-offers/bitrix/news.detail/.default/style.css @@ -0,0 +1,133 @@ +.vino-offer { + --vino-offer-gap: var(--space-12); + padding: var(--space-12) var(--gutter) 0; +} +.vino-offer__inner { + display: grid; + grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); + gap: var(--vino-offer-gap); + align-items: start; +} +.vino-offer__media { + margin: 0; + aspect-ratio: 4 / 3; + overflow: hidden; +} +.vino-offer__img { + display: block; + width: 100%; + height: 100%; + object-fit: cover; +} +.vino-offer__body { + display: flex; + flex-direction: column; + align-items: flex-start; + gap: var(--space-5); +} +.vino-offer__title { + margin: 0; + font-family: var(--font-serif); + font-size: var(--fs-h2); + font-weight: 400; + line-height: var(--leading-tight); + letter-spacing: var(--tracking-tight); +} +.vino-offer__until { + margin: 0; + color: var(--color-text-faint); + font-size: var(--text-13); + letter-spacing: var(--tracking-ui); + text-transform: uppercase; +} +.vino-offer__lead { + margin: 0; + color: var(--color-text-muted); + font-size: var(--text-19); + line-height: var(--leading-text); +} +.vino-offer__code { + display: flex; + flex-wrap: wrap; + align-items: center; + gap: var(--space-3) var(--space-4); + padding: var(--space-4) var(--space-5); + border: 1px dashed color-mix(in srgb, var(--color-accent) 55%, transparent); +} +.vino-offer__code-label { + color: var(--color-text-faint); + font-size: var(--text-13); + letter-spacing: var(--tracking-ui); + text-transform: uppercase; +} +.vino-offer__code-value { + color: var(--color-accent); + font-family: var(--font-sans); + font-size: var(--text-19); + font-weight: 600; + letter-spacing: var(--tracking-sm); +} +.vino-offer__copy { + min-height: var(--size-tap); + padding: 0 var(--space-4); + border: 1px solid var(--color-line); + background: transparent; + color: var(--color-text); + font: inherit; + font-size: var(--text-13); + letter-spacing: var(--tracking-sm); + text-transform: uppercase; + cursor: pointer; + transition: border-color var(--duration-fast) var(--ease-base), color var(--duration-fast) var(--ease-base); +} +.vino-offer__copy--done { + border-color: var(--color-accent); + color: var(--color-accent); +} +.vino-offer__terms { + width: 100%; + padding-top: var(--space-5); + border-top: 1px solid var(--color-line); +} +.vino-offer__terms-title { + margin: 0 0 var(--space-3); + font-family: var(--font-serif); + font-size: var(--fs-h4); + font-weight: 400; +} +.vino-offer__terms-text { + color: var(--color-text-muted); + font-size: var(--text-base); + line-height: var(--leading-long); +} +.vino-offer__terms-text p, .vino-offer__terms-text ul { + margin: 0 0 var(--space-3); +} +.vino-offer__terms-text ul { + padding-left: var(--space-5); +} +.vino-offer__terms-text > :last-child { + margin-bottom: 0; +} +@media (hover:hover) { + .vino-offer__copy:hover { + border-color: var(--color-accent); + color: var(--color-accent); + } +} +@media (max-width:980px) { + .vino-offer { + --vino-offer-gap: var(--space-8); + } + .vino-offer__inner { + grid-template-columns: 1fr; + } +} +@media (max-width:760px) { + .vino-offer { + padding-top: var(--space-8); + } + .vino-offer__lead { + font-size: var(--text-base); + } +} diff --git a/local/templates/jinove_wine/components/bitrix/news/vinoteca-offers/bitrix/news.detail/.default/template.php b/local/templates/jinove_wine/components/bitrix/news/vinoteca-offers/bitrix/news.detail/.default/template.php new file mode 100644 index 0000000..dc3aa4e --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/news/vinoteca-offers/bitrix/news.detail/.default/template.php @@ -0,0 +1,42 @@ +AddEditAction($arResult["ID"], $arResult["EDIT_LINK"], CIBlock::GetArrayByID($arResult["IBLOCK_ID"], "ELEMENT_EDIT")); +$picture = $arResult["VINO_PICTURE"]; +$offer = $arResult["VINO_OFFER"]; +?> + +
"> +
+ +
+ " srcset="" sizes="(max-width: 980px) calc((100vw - 32px) * ), calc(50vw * )" width="" height="" alt="" fetchpriority="high" decoding="async"> +
+ +
+ +

+

+

+ +
+ + + + +
+ + +
+

+
+
+ + +
+
+
diff --git a/local/templates/jinove_wine/components/bitrix/news/vinoteca-offers/detail.php b/local/templates/jinove_wine/components/bitrix/news/vinoteca-offers/detail.php new file mode 100644 index 0000000..80b6ffd --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/news/vinoteca-offers/detail.php @@ -0,0 +1,60 @@ + +
+
+ +
+
+IncludeComponent("bitrix:news.detail", "", array( + "IBLOCK_TYPE" => $arParams["IBLOCK_TYPE"], + "IBLOCK_ID" => $arParams["IBLOCK_ID"], + "ELEMENT_ID" => $arResult["VARIABLES"]["ELEMENT_ID"] ?? "", + "ELEMENT_CODE" => $arResult["VARIABLES"]["ELEMENT_CODE"] ?? "", + "FIELD_CODE" => $arParams["DETAIL_FIELD_CODE"], + "PROPERTY_CODE" => $arParams["DETAIL_PROPERTY_CODE"], + "DETAIL_URL" => $arResult["FOLDER"] . $arResult["URL_TEMPLATES"]["detail"], + "CHECK_DATES" => $arParams["CHECK_DATES"], + "CACHE_TYPE" => $arParams["CACHE_TYPE"], + "CACHE_TIME" => $arParams["CACHE_TIME"], + "CACHE_GROUPS" => $arParams["CACHE_GROUPS"], + "SET_TITLE" => "N", + "SET_BROWSER_TITLE" => "N", + "SET_META_KEYWORDS" => "N", + "SET_META_DESCRIPTION" => "N", + "SET_LAST_MODIFIED" => "N", + "INCLUDE_IBLOCK_INTO_CHAIN" => "N", + "ADD_SECTIONS_CHAIN" => "N", + "ADD_ELEMENT_CHAIN" => "N", + "SET_CANONICAL_URL" => "N", + "SET_STATUS_404" => $arParams["SET_STATUS_404"], + "SHOW_404" => $arParams["SHOW_404"], + "FILE_404" => $arParams["FILE_404"], + "MESSAGE_404" => $arParams["MESSAGE_404"], + "USE_PERMISSIONS" => "N", + "DISPLAY_TOP_PAGER" => "N", + "DISPLAY_BOTTOM_PAGER" => "N", +), $component); +if (!$offerId) { + return; +} +$offer = \Jinove\Vinoteca\Offers::summary(\Jinove\Vinoteca\Offers::discountIdsOf((int)$offerId)); +$offerPath = $arResult["FOLDER"] . $arResult["VARIABLES"]["ELEMENT_CODE"] . "/"; +?> +
+
+

+ + IncludeComponent("bitrix:catalog.section", "vinoteca", \Jinove\Vinoteca\Offers::wineParams($offer["products"], $offer["sections"], $offerPath, $offerPath), $component); ?> + +

+ +
+
+ diff --git a/local/templates/jinove_wine/components/bitrix/news/vinoteca-offers/lang/en/detail.php b/local/templates/jinove_wine/components/bitrix/news/vinoteca-offers/lang/en/detail.php new file mode 100644 index 0000000..6db2761 --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/news/vinoteca-offers/lang/en/detail.php @@ -0,0 +1,4 @@ +SetTitle(Loc::getMessage("VINO_OFFERS_H1")); +$APPLICATION->SetPageProperty("title", Loc::getMessage("VINO_OFFERS_PAGE_TITLE")); +$APPLICATION->SetPageProperty("description", Loc::getMessage("VINO_OFFERS_DESCRIPTION")); +$automatic = \Jinove\Vinoteca\Offers::automatic(); +?> +
+
+ +

+

+
+
+
+
+ IncludeComponent("bitrix:news.list", "vinoteca-offers", \Jinove\Vinoteca\Offers::listParams(), $component); ?> +
+
+
+
+

+ IncludeComponent("bitrix:catalog.section", "vinoteca", \Jinove\Vinoteca\Offers::wineParams($automatic["products"], $automatic["sections"], \Jinove\Vinoteca\Offers::folder(), \Jinove\Vinoteca\Offers::folder()), $component); ?> +
+
+ diff --git a/local/templates/jinove_wine/components/bitrix/news/vinoteca-offers/style.css b/local/templates/jinove_wine/components/bitrix/news/vinoteca-offers/style.css new file mode 100644 index 0000000..7e1d553 --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/news/vinoteca-offers/style.css @@ -0,0 +1,22 @@ +.vino-offers-page { + padding: var(--space-head) var(--gutter) 0; +} +.vino-offers-wines { + padding-top: var(--space-16); +} +.vino-offers-wines__title { + margin: 0 0 var(--space-head); + font-family: var(--font-serif); + font-size: var(--fs-h2); + font-weight: 400; + line-height: var(--leading-tight); +} +.vino-offers-wines__empty { + margin: 0; + color: var(--color-text-muted); +} +@media (max-width:760px) { + .vino-offers-wines { + padding-top: var(--space-12); + } +} diff --git a/local/templates/jinove_wine/components/bitrix/search.page/.default/lang/en/template.php b/local/templates/jinove_wine/components/bitrix/search.page/.default/lang/en/template.php new file mode 100644 index 0000000..1d12d30 --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/search.page/.default/lang/en/template.php @@ -0,0 +1,11 @@ +NavRecordCount : count($arResult["VINO_ITEMS"]); diff --git a/local/templates/jinove_wine/components/bitrix/search.page/.default/style.css b/local/templates/jinove_wine/components/bitrix/search.page/.default/style.css new file mode 100644 index 0000000..f0249df --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/search.page/.default/style.css @@ -0,0 +1,111 @@ +.vino-search-page__form { + display: flex; + max-width: var(--measure); + margin-top: var(--space-6); +} +.vino-search-page { + --vino-search-page-pic-width: 72px; + --vino-search-page-pic-height: 90px; + --vino-pager-gap: 0; + padding: var(--space-head) var(--gutter) var(--space-section); +} +.vino-search-page__status { + margin: 0 0 var(--space-6); + color: var(--color-text-muted); + font-size: var(--text-base); + line-height: var(--leading-long); +} +.vino-search-page__list { + display: grid; + margin: 0; + padding: 0; + border-top: 1px solid var(--color-line); + list-style: none; +} +.vino-search-page__item { + position: relative; + display: flex; + align-items: center; + gap: var(--space-5); + padding: var(--space-5) 0; + border-bottom: 1px solid var(--color-line); +} +.vino-search-page__item:last-child { + border-bottom: 0; +} +.vino-search-page__pic { + display: flex; + flex: none; + align-items: center; + justify-content: center; + width: var(--vino-search-page-pic-width); + height: var(--vino-search-page-pic-height); + overflow: hidden; + background: var(--color-bg-soft); +} +.vino-search-page__img { + width: 100%; + height: 100%; + object-fit: cover; +} +.vino-search-page__body { + display: flex; + flex: 1; + flex-direction: column; + gap: var(--space-1); + min-width: 0; +} +.vino-search-page__kind { + color: var(--color-text-faint); + font-size: var(--fs-caption); + letter-spacing: var(--tracking-ui); + text-transform: uppercase; +} +.vino-search-page__link { + color: var(--color-text); + font-family: var(--font-serif); + font-size: var(--fs-h4); + line-height: var(--leading-title); + transition: color var(--duration-fast) var(--ease-base); +} +.vino-search-page__link::after { + content: ""; + position: absolute; + inset: 0; +} +.vino-search-page__text { + display: -webkit-box; + overflow: hidden; + color: var(--color-text-muted); + font-size: var(--text-15); + line-height: var(--leading-text); + -webkit-box-orient: vertical; + -webkit-line-clamp: 2; +} +.vino-search-page__price { + flex: none; + color: var(--color-accent); + font-family: var(--font-sans); + font-size: var(--text-19); + font-weight: 600; +} +@media (hover:hover) { + .vino-search-page__item:hover .vino-search-page__link { + color: var(--color-accent); + } +} +@media (max-width:560px) { + .vino-search-page { + --vino-search-page-pic-width: 56px; + --vino-search-page-pic-height: 70px; + } + .vino-search-page__item { + flex-wrap: wrap; + gap: var(--space-4); + } + .vino-search-page__price { + width: 100%; + padding-left: calc(var(--vino-search-page-pic-width) + var(--space-4)); + font-size: var(--text-17); + } +} diff --git a/local/templates/jinove_wine/components/bitrix/search.page/.default/template.php b/local/templates/jinove_wine/components/bitrix/search.page/.default/template.php new file mode 100644 index 0000000..c86eec2 --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/search.page/.default/template.php @@ -0,0 +1,54 @@ + +
+
+ +

+ +
+
+
+
+ +

+ +

+ +

htmlspecialcharsbx($query))) ?>

+ + +

$arResult["VINO_TOTAL"], "#QUERY#" => htmlspecialcharsbx($query))) ?>

+
    + +
  • + + " alt="" loading="lazy" decoding="async"> + + + + "> + + + +
  • + +
+ + +
+
diff --git a/local/templates/jinove_wine/components/bitrix/search.title/vinoteca/ajax.php b/local/templates/jinove_wine/components/bitrix/search.title/vinoteca/ajax.php new file mode 100644 index 0000000..269ceb6 --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/search.title/vinoteca/ajax.php @@ -0,0 +1,10 @@ + $arResult["VINO_ITEMS"] ?? array(), + "all" => \Jinove\Vinoteca\Search::folder() . "?q=" . rawurlencode((string)($arResult["query"] ?? "")), +), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); diff --git a/local/templates/jinove_wine/components/bitrix/search.title/vinoteca/lang/en/template.php b/local/templates/jinove_wine/components/bitrix/search.title/vinoteca/lang/en/template.php new file mode 100644 index 0000000..3bda194 --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/search.title/vinoteca/lang/en/template.php @@ -0,0 +1,12 @@ += 0) { + options[active].classList.remove('vino-suggest__item--active'); + options[active].setAttribute('aria-selected', 'false'); + } + active = (active + step + options.length) % options.length; + options[active].classList.add('vino-suggest__item--active'); + options[active].setAttribute('aria-selected', 'true'); + options[active].scrollIntoView({ block: 'nearest' }); + input.setAttribute('aria-activedescendant', options[active].id); + } + + function find() { + var query = input.value.trim(); + if (query.length < MIN) { + reset(); + return; + } + var mine = ++serial; + BX.ajax({ + url: form.getAttribute('action'), + method: 'POST', + dataType: 'json', + data: { ajax_call: 'y', INPUT_ID: input.id, q: query, l: MIN }, + onsuccess: function (data) { if (mine === serial) render(data, query); }, + onfailure: function () { if (mine === serial) reset(); } + }); + } + + input.addEventListener('input', function () { + clearTimeout(timer); + timer = setTimeout(find, 200); + }); + input.addEventListener('keydown', function (e) { + if (root.hidden) return; + if (e.key === 'ArrowDown') { + e.preventDefault(); + move(1); + } else if (e.key === 'ArrowUp') { + e.preventDefault(); + move(-1); + } else if (e.key === 'Enter' && active >= 0) { + e.preventDefault(); + window.location.href = options[active].href; + } + }); + document.addEventListener('vino:search-close', reset); +})(); +}); diff --git a/local/templates/jinove_wine/components/bitrix/search.title/vinoteca/template.php b/local/templates/jinove_wine/components/bitrix/search.title/vinoteca/template.php new file mode 100644 index 0000000..1374c52 --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/search.title/vinoteca/template.php @@ -0,0 +1,31 @@ +setFrameMode(true); +?> + + +

(string)Loc::getMessage("VINO_SEARCH_TITLE_COUNT_ONE"), + "few" => (string)Loc::getMessage("VINO_SEARCH_TITLE_COUNT_FEW"), + "many" => (string)Loc::getMessage("VINO_SEARCH_TITLE_COUNT_MANY"), + "other" => (string)Loc::getMessage("VINO_SEARCH_TITLE_COUNT_OTHER"), + "none" => (string)Loc::getMessage("VINO_SEARCH_TITLE_COUNT_NONE"), +), JSON_UNESCAPED_UNICODE)) ?>">

diff --git a/local/templates/jinove_wine/components/bitrix/system.pagenavigation/vinoteca/lang/en/template.php b/local/templates/jinove_wine/components/bitrix/system.pagenavigation/vinoteca/lang/en/template.php new file mode 100644 index 0000000..ba1b330 --- /dev/null +++ b/local/templates/jinove_wine/components/bitrix/system.pagenavigation/vinoteca/lang/en/template.php @@ -0,0 +1,5 @@ + + diff --git a/local/templates/jinove_wine/footer.php b/local/templates/jinove_wine/footer.php new file mode 100644 index 0000000..f73635c --- /dev/null +++ b/local/templates/jinove_wine/footer.php @@ -0,0 +1,185 @@ +' + . Loc::getMessage("VINO_FOOTER_CONSENT", array("#BUTTON#" => Loc::getMessage($buttonKey), "#URL#" => SITE_DIR . "consent/", "#PRIVACY_URL#" => SITE_DIR . "privacy/")) + . ''; +}; +?> + + + + + + + +
+ +
+

+

+

+
+ " aria-hidden="true"> + " aria-label="" autocomplete="name" maxlength="100" required> + " autocomplete="tel" inputmode="tel" required data-phone-code="7" data-phone-digits="10" data-phone-groups="3,3,2,2"> + + + + + +
+
+ +
+
+ + + +
+ + + + + +
+ + +GetPageProperty("vino_schema") !== "N") : ?> + + + + diff --git a/local/templates/jinove_wine/header.php b/local/templates/jinove_wine/header.php new file mode 100644 index 0000000..dfdeb56 --- /dev/null +++ b/local/templates/jinove_wine/header.php @@ -0,0 +1,91 @@ +addJs(SITE_TEMPLATE_PATH . "/assets/js/" . $jwScript . ".js"); +} +$jwLang = LANGUAGE_ID; +$jwDemoMail = htmlspecialcharsbx(\Jinove\Vinoteca\Config::contacts()["demoMail"]); +?> + + + + + + <?php $APPLICATION->ShowTitle() ?> + + + + AddBufferContent(array(\Jinove\Vinoteca\Seo::class, "headLinks"), $jwCanon, VINO_HOST, VINO_LANGS, "en"); + ?> + AddBufferContent(array(\Jinove\Vinoteca\Seo::class, "openGraph"), $jwCanon); ?> + ShowHead(); + ?> + +"> + +ShowPanel(); ?> +

'jimagie', + "#MAIL#" => '' . $jwDemoMail . '', +)) ?>

+
+
+ + IncludeComponent( + "bitrix:menu", "vinoteca_top", array( + "ROOT_MENU_TYPE" => "top", + "MENU_CACHE_TYPE" => "A", + "MENU_CACHE_TIME" => "3600", + "MENU_CACHE_USE_GROUPS" => "Y", + "MENU_CACHE_GET_VARS" => array(), + "MAX_LEVEL" => "1", + "USE_EXT" => "N", + "DELAY" => "N", + "ALLOW_MULTI_SELECT" => "N", + ), + false + ); ?> +
+
+ + +
+ + + " title=""> + " title=""> + " title=""> + +
+
+ IncludeComponent("jinove:catalog.megamenu", "", array( + "IBLOCK_ID" => VINO_CATALOG_IBLOCK, + "BRANDS_LIMIT" => 6, + "CACHE_TYPE" => "A", + "CACHE_TIME" => 86400, + ), false, array("HIDE_ICONS" => "Y")); ?> +
+ + +
diff --git a/local/templates/jinove_wine/lang/en/footer.php b/local/templates/jinove_wine/lang/en/footer.php new file mode 100644 index 0000000..70f53b4 --- /dev/null +++ b/local/templates/jinove_wine/lang/en/footer.php @@ -0,0 +1,62 @@ +personal data on the terms and for the purposes set out in the Privacy Policy.'; +$MESS["VINO_FOOTER_SEND"] = "Send"; +$MESS["VINO_FOOTER_SOMMELIER_SENT"] = "Question sent"; +$MESS["VINO_FOOTER_THANKS"] = "Thank you!"; +$MESS["VINO_FOOTER_SOMMELIER_DONE"] = "The sommelier will call back at #PHONE#"; +$MESS["VINO_FOOTER_COOKIE"] = "The site uses cookies and third-party services. Learn more in the #LINK#."; +$MESS["VINO_FOOTER_ACCEPT"] = "Accept"; +$MESS["VINO_FOOTER_DECLINE"] = "Decline"; +$MESS["VINO_FOOTER_CONSENT_SETTINGS"] = "Consent settings"; +$MESS["VINO_FOOTER_NEWS_TITLE"] = "New arrivals"; +$MESS["VINO_FOOTER_NEWS_TEXT"] = "News about new wines in the catalogue."; +$MESS["VINO_FOOTER_SUBSCRIBED"] = "Thank you! You are subscribed to new arrivals."; +$MESS["VINO_FOOTER_EMAIL"] = "Your e-mail"; +$MESS["VINO_FOOTER_SUBSCRIBE"] = "Subscribe"; +$MESS["VINO_FOOTER_EMAIL_ERROR"] = "Please check the e-mail address."; +$MESS["VINO_FOOTER_ABOUT"] = "Importer of fine wines from the best wine regions of the Old and New World."; +$MESS["VINO_FOOTER_CATALOG"] = "Catalogue"; +$MESS["VINO_FOOTER_VINOTECA"] = "Vinoteca"; +$MESS["VINO_FOOTER_CONTACTS"] = "Contacts"; +$MESS["VINO_FOOTER_ADDRESS_FORMAT"] = "#STREET#, #CITY#"; +$MESS["VINO_FOOTER_DOCUMENTS"] = "Documents"; +$MESS["VINO_FOOTER_PRIVACY"] = "Privacy policy"; +$MESS["VINO_FOOTER_CONSENT_DOC"] = "Consent to data processing"; +$MESS["VINO_FOOTER_JS_COMPARE_ADD"] = "Add to comparison"; +$MESS["VINO_FOOTER_JS_COMPARE_REMOVE"] = "Remove from comparison"; +$MESS["VINO_FOOTER_JS_COMPARE_MAX"] = "Comparison is full: #N# wines."; +$MESS["VINO_FOOTER_JS_COMPARE_OPEN"] = "Open comparison"; +$MESS["VINO_FOOTER_JS_FAIL"] = "Could not send. Please try again."; +$MESS["VINO_FOOTER_JS_PHONE"] = "Please check the phone number."; +$MESS["VINO_FOOTER_JS_CONSENT"] = "Consent to personal data processing is required."; +$MESS["VINO_FOOTER_JS_EMPTY_1"] = "Please enter your name."; +$MESS["VINO_FOOTER_JS_EMPTY_2"] = "Please enter your phone number."; +$MESS["VINO_FOOTER_JS_EMPTY_3"] = "Please enter your name and phone number."; +$MESS["VINO_FOOTER_JS_EMPTY_4"] = "Please write your question."; +$MESS["VINO_FOOTER_JS_EMPTY_5"] = "Please enter your name and write your question."; +$MESS["VINO_FOOTER_JS_EMPTY_6"] = "Please enter your phone number and write your question."; +$MESS["VINO_FOOTER_JS_EMPTY_7"] = "Please fill in your name, phone number and question."; +$MESS["VINO_FOOTER_LD_DESCRIPTION"] = "A wine shop with fine wines from the world’s best regions: sommelier help and pickup from the warehouse."; +$MESS["VINO_FOOTER_LD_STREET"] = "251 Krasnaya St."; +$MESS["VINO_FOOTER_LD_CITY"] = "Krasnodar"; +$MESS["VINO_FOOTER_TAB_LOGIN"] = "Sign in"; +$MESS["VINO_FOOTER_PRIVACY_LINK"] = "privacy policy"; +$MESS["VINO_FOOTER_HONEYPOT"] = "Leave this field empty"; diff --git a/local/templates/jinove_wine/lang/en/header.php b/local/templates/jinove_wine/lang/en/header.php new file mode 100644 index 0000000..d0e6bf1 --- /dev/null +++ b/local/templates/jinove_wine/lang/en/header.php @@ -0,0 +1,10 @@ +danych osobowych na warunkach i w celach określonych w Polityce prywatności.'; +$MESS["VINO_FOOTER_SEND"] = "Wyślij"; +$MESS["VINO_FOOTER_SOMMELIER_SENT"] = "Pytanie wysłane"; +$MESS["VINO_FOOTER_THANKS"] = "Dziękujemy!"; +$MESS["VINO_FOOTER_SOMMELIER_DONE"] = "Sommelier oddzwoni pod numer #PHONE#"; +$MESS["VINO_FOOTER_COOKIE"] = "Strona korzysta z plików cookie i usług zewnętrznych. Więcej w #LINK#."; +$MESS["VINO_FOOTER_ACCEPT"] = "Akceptuję"; +$MESS["VINO_FOOTER_DECLINE"] = "Odrzucam"; +$MESS["VINO_FOOTER_CONSENT_SETTINGS"] = "Ustawienia zgody"; +$MESS["VINO_FOOTER_NEWS_TITLE"] = "Nowości"; +$MESS["VINO_FOOTER_NEWS_TEXT"] = "Informacje o nowych winach w katalogu."; +$MESS["VINO_FOOTER_SUBSCRIBED"] = "Dziękujemy! Subskrypcja nowości jest aktywna."; +$MESS["VINO_FOOTER_EMAIL"] = "Twój e-mail"; +$MESS["VINO_FOOTER_SUBSCRIBE"] = "Subskrybuj"; +$MESS["VINO_FOOTER_EMAIL_ERROR"] = "Sprawdź adres e-mail."; +$MESS["VINO_FOOTER_ABOUT"] = "Importer win autorskich z najlepszych regionów winiarskich Starego i Nowego Świata."; +$MESS["VINO_FOOTER_CATALOG"] = "Katalog"; +$MESS["VINO_FOOTER_VINOTECA"] = "Vinoteca"; +$MESS["VINO_FOOTER_CONTACTS"] = "Kontakt"; +$MESS["VINO_FOOTER_ADDRESS_FORMAT"] = "#CITY#, #STREET#"; +$MESS["VINO_FOOTER_DOCUMENTS"] = "Dokumenty"; +$MESS["VINO_FOOTER_PRIVACY"] = "Polityka prywatności"; +$MESS["VINO_FOOTER_CONSENT_DOC"] = "Zgoda na przetwarzanie danych"; +$MESS["VINO_FOOTER_JS_COMPARE_ADD"] = "Dodaj do porównania"; +$MESS["VINO_FOOTER_JS_COMPARE_REMOVE"] = "Usuń z porównania"; +$MESS["VINO_FOOTER_JS_COMPARE_MAX"] = "Porównanie jest pełne: #N# wina."; +$MESS["VINO_FOOTER_JS_COMPARE_OPEN"] = "Otwórz porównanie"; +$MESS["VINO_FOOTER_JS_FAIL"] = "Nie udało się wysłać. Spróbuj ponownie."; +$MESS["VINO_FOOTER_JS_PHONE"] = "Sprawdź numer telefonu."; +$MESS["VINO_FOOTER_JS_CONSENT"] = "Wymagana jest zgoda na przetwarzanie danych osobowych."; +$MESS["VINO_FOOTER_JS_EMPTY_1"] = "Podaj imię."; +$MESS["VINO_FOOTER_JS_EMPTY_2"] = "Podaj numer telefonu."; +$MESS["VINO_FOOTER_JS_EMPTY_3"] = "Podaj imię i numer telefonu."; +$MESS["VINO_FOOTER_JS_EMPTY_4"] = "Wpisz pytanie."; +$MESS["VINO_FOOTER_JS_EMPTY_5"] = "Podaj imię i wpisz pytanie."; +$MESS["VINO_FOOTER_JS_EMPTY_6"] = "Podaj numer telefonu i wpisz pytanie."; +$MESS["VINO_FOOTER_JS_EMPTY_7"] = "Uzupełnij imię, numer telefonu i pytanie."; +$MESS["VINO_FOOTER_LD_DESCRIPTION"] = "Winoteka z winami autorskimi z najlepszych regionów świata: pomoc sommeliera i odbiór osobisty z magazynu."; +$MESS["VINO_FOOTER_LD_STREET"] = "ul. Krasnaja 251"; +$MESS["VINO_FOOTER_LD_CITY"] = "Krasnodar"; +$MESS["VINO_FOOTER_TAB_LOGIN"] = "Zaloguj się"; +$MESS["VINO_FOOTER_PRIVACY_LINK"] = "polityce prywatności"; +$MESS["VINO_FOOTER_HONEYPOT"] = "Nie wypełniaj tego pola"; diff --git a/local/templates/jinove_wine/lang/pl/header.php b/local/templates/jinove_wine/lang/pl/header.php new file mode 100644 index 0000000..fb6fafd --- /dev/null +++ b/local/templates/jinove_wine/lang/pl/header.php @@ -0,0 +1,10 @@ +персональных данных на условиях и для целей, определённых Политикой конфиденциальности.'; +$MESS["VINO_FOOTER_SEND"] = "Отправить"; +$MESS["VINO_FOOTER_SOMMELIER_SENT"] = "Вопрос отправлен"; +$MESS["VINO_FOOTER_THANKS"] = "Спасибо!"; +$MESS["VINO_FOOTER_SOMMELIER_DONE"] = "Сомелье перезвонит по номеру #PHONE#"; +$MESS["VINO_FOOTER_COOKIE"] = "Сайт использует cookie и сторонние сервисы. Подробнее в #LINK#."; +$MESS["VINO_FOOTER_ACCEPT"] = "Принять"; +$MESS["VINO_FOOTER_DECLINE"] = "Отклонить"; +$MESS["VINO_FOOTER_CONSENT_SETTINGS"] = "Настройки согласия"; +$MESS["VINO_FOOTER_NEWS_TITLE"] = "Новинки"; +$MESS["VINO_FOOTER_NEWS_TEXT"] = "Новости о новых винах в каталоге."; +$MESS["VINO_FOOTER_SUBSCRIBED"] = "Спасибо! Вы подписаны на новинки."; +$MESS["VINO_FOOTER_EMAIL"] = "Ваш e-mail"; +$MESS["VINO_FOOTER_SUBSCRIBE"] = "Подписаться"; +$MESS["VINO_FOOTER_EMAIL_ERROR"] = "Проверьте e-mail."; +$MESS["VINO_FOOTER_ABOUT"] = "Импортёр авторских вин из лучших винодельческих регионов Старого и Нового Света."; +$MESS["VINO_FOOTER_CATALOG"] = "Каталог"; +$MESS["VINO_FOOTER_VINOTECA"] = "Винотека"; +$MESS["VINO_FOOTER_CONTACTS"] = "Контакты"; +$MESS["VINO_FOOTER_ADDRESS_FORMAT"] = "г. #CITY#, #STREET#"; +$MESS["VINO_FOOTER_DOCUMENTS"] = "Документы"; +$MESS["VINO_FOOTER_PRIVACY"] = "Политика конфиденциальности"; +$MESS["VINO_FOOTER_CONSENT_DOC"] = "Согласие на обработку данных"; +$MESS["VINO_FOOTER_JS_COMPARE_ADD"] = "Добавить к сравнению"; +$MESS["VINO_FOOTER_JS_COMPARE_REMOVE"] = "Убрать из сравнения"; +$MESS["VINO_FOOTER_JS_COMPARE_MAX"] = "В сравнении уже #N# вина."; +$MESS["VINO_FOOTER_JS_COMPARE_OPEN"] = "Открыть сравнение"; +$MESS["VINO_FOOTER_JS_FAIL"] = "Не получилось отправить. Попробуйте ещё раз."; +$MESS["VINO_FOOTER_JS_PHONE"] = "Проверьте номер телефона."; +$MESS["VINO_FOOTER_JS_CONSENT"] = "Нужно согласие на обработку персональных данных."; +$MESS["VINO_FOOTER_JS_EMPTY_1"] = "Укажите имя."; +$MESS["VINO_FOOTER_JS_EMPTY_2"] = "Укажите телефон."; +$MESS["VINO_FOOTER_JS_EMPTY_3"] = "Укажите имя и телефон."; +$MESS["VINO_FOOTER_JS_EMPTY_4"] = "Напишите вопрос."; +$MESS["VINO_FOOTER_JS_EMPTY_5"] = "Укажите имя и напишите вопрос."; +$MESS["VINO_FOOTER_JS_EMPTY_6"] = "Укажите телефон и напишите вопрос."; +$MESS["VINO_FOOTER_JS_EMPTY_7"] = "Заполните имя, телефон и вопрос."; +$MESS["VINO_FOOTER_LD_DESCRIPTION"] = "Винотека авторских вин из лучших регионов мира: помощь сомелье и самовывоз со склада."; +$MESS["VINO_FOOTER_LD_STREET"] = "ул. Красная, 251"; +$MESS["VINO_FOOTER_LD_CITY"] = "Краснодар"; +$MESS["VINO_FOOTER_PRIVACY_LINK"] = "политике конфиденциальности"; +$MESS["VINO_FOOTER_HONEYPOT"] = "Не заполняйте это поле"; diff --git a/local/templates/jinove_wine/lang/ru/header.php b/local/templates/jinove_wine/lang/ru/header.php new file mode 100644 index 0000000..b233930 --- /dev/null +++ b/local/templates/jinove_wine/lang/ru/header.php @@ -0,0 +1,10 @@ +"); +} +.vino-section__head { + display: flex; + align-items: flex-end; + justify-content: space-between; + gap: var(--space-6); + margin-bottom: var(--space-head); + flex-wrap: wrap; +} +.vino-section { + border-top: 1px solid var(--color-line); + background: var(--color-bg); + color: var(--color-text); +} +.vino-section__link-icon { + width: 16px; + height: 16px; + transition: transform var(--duration-fast) var(--ease-base); +} +.vino-section__title { + font-family: var(--font-serif); + font-weight: 400; + font-size: var(--fs-h2); + line-height: var(--leading-tight); + letter-spacing: var(--tracking-tight); + margin: 0; +} +.vino-section__link { + display: inline-flex; + align-items: center; + gap: var(--space-2); + color: var(--color-accent); + border-bottom: 1px solid color-mix(in srgb, var(--color-accent) 35%, transparent); + padding-bottom: var(--space-1); + font-family: var(--font-sans); + font-size: var(--text-13); + font-weight: 500; + letter-spacing: var(--tracking-ui); + text-transform: uppercase; + transition: border-color var(--duration-fast) var(--ease-base), color var(--duration-fast) var(--ease-base); +} +@media (hover:hover) { + .vino-section__link:hover { + color: var(--color-text); + border-bottom-color: var(--color-accent); + } +} +.vino-section__more { + position: relative; + color: var(--color-accent); + font-family: var(--font-sans); + font-size: var(--text-13); + font-weight: 500; + letter-spacing: var(--tracking-ui); + text-transform: uppercase; + text-decoration: none; + padding-bottom: var(--space-1); + white-space: nowrap; + border-bottom: 1px solid color-mix(in srgb, var(--color-accent) 28%, transparent); +} +.vino-section__count { + opacity: .62; + font-variant-numeric: tabular-nums; +} +.vino-section__count::before { + content: " · "; +} +.vino-section__more::after { + content: ""; + position: absolute; + left: 0; + right: 100%; + bottom: -1px; + height: 1px; + background: var(--color-accent); + transition: right var(--duration-base) var(--ease-base); +} +@media (hover:hover) { + .vino-section__more:hover::after { + right: 0; + } +} +@media (max-width:760px) { + .vino-section__inner { + display: flex; + flex-direction: column; + } + .vino-section__inner > .vino-section__head { + display: contents; + } + .vino-section__intro { + order: 1; + margin-bottom: var(--space-head); + } + .vino-section__body { + order: 2; + } + .vino-section__all { + order: 3; + align-self: flex-start; + margin-top: var(--space-5); + } + .vino-section__count { + display: inline; + } +} +.vino-razdel-hero:has(.vino-showcase-banner--catalog) + .vino-section { + border-top: 0; +} +.vino-razdel-hero__actions { + display: flex; + flex-wrap: wrap; + gap: var(--space-3); + margin-top: var(--space-6); +} +.vino-razdel-hero__note { + margin: var(--space-3) 0 0; + color: var(--color-text-muted); + font-size: var(--text-15); +} +.vino-razdel-hero__mark { + color: var(--color-accent); +} +.vino-razdel-hero__title { + margin: var(--space-4) 0 0; + color: var(--color-text); + font-family: var(--font-serif); + font-size: var(--fs-h2); + font-weight: 400; + line-height: var(--leading-tight); + letter-spacing: var(--tracking-tight); +} +.vino-razdel-hero__lead { + max-width: var(--measure); + margin: var(--space-4) 0 0; + color: var(--color-text-muted); + font-size: var(--text-base); + line-height: var(--leading-long); +} +.vino-razdel-hero { + padding-right: var(--gutter); + padding-left: var(--gutter); + padding-top: var(--space-8); + padding-bottom: 0; +} +.vino-news__grid { + display: grid; + grid-template-columns: 1fr; + gap: var(--space-6); +} +@media (min-width:761px) { + .vino-news__grid { + grid-template-columns: repeat(3, minmax(0, 1fr)); + } +} +.vino-news__card { + position: relative; + transition: transform var(--duration-base) var(--ease-base); +} +.vino-news__media { + display: block; + aspect-ratio: 16 / 9; + overflow: hidden; + margin-bottom: var(--space-8); +} +.vino-news__img { + display: block; + width: 100%; + height: 100%; + object-fit: cover; + opacity: .8; + transition: opacity var(--duration-fast) var(--ease-base), transform var(--duration-soft) var(--ease-base); +} +.vino-news__date { + display: block; + margin: 0 0 var(--space-4); + color: var(--color-text-faint); + font-size: var(--text-13); + letter-spacing: var(--tracking-xs); + text-transform: uppercase; +} +.vino-news__title { + margin: 0 0 var(--space-4); + font-family: var(--font-serif); + font-size: var(--fs-h4); + font-weight: 400; + line-height: var(--leading-title); + transition: color var(--duration-fast) var(--ease-base); +} +.vino-news__link { + color: inherit; +} +.vino-news__link::after { + content: ""; + position: absolute; + inset: 0; +} +.vino-news__text { + display: -webkit-box; + overflow: hidden; + margin: 0; + color: color-mix(in srgb, var(--color-white) 60%, transparent); + font-size: 1rem; + line-height: var(--leading-long); + -webkit-box-orient: vertical; + -webkit-line-clamp: 2; +} +@media (hover:hover) { + .vino-news__card:hover { + transform: translateY(-3px); + } + .vino-news__card:hover .vino-news__img { + opacity: 1; + transform: scale(1.05); + } + .vino-news__card:hover .vino-news__title { + color: var(--color-accent); + } +} +@media (max-width:760px) { + .vino-news__grid { + gap: var(--space-5); + } + .vino-news__title { + font-size: 1.375rem; + } + .vino-news__date { + font-size: var(--fs-caption); + letter-spacing: 0; + text-transform: none; + } + .vino-news__card--compact { + display: grid; + grid-template-columns: 112px minmax(0, 1fr); + grid-template-rows: auto 1fr; + column-gap: var(--space-4); + padding-top: var(--space-5); + border-top: 1px solid var(--color-line); + } + .vino-news__card--compact .vino-news__media { + grid-row: span 2; + aspect-ratio: 4 / 3; + margin: 0; + } + .vino-news__card--compact .vino-news__date { + margin-bottom: var(--space-1); + } + .vino-news__card--compact .vino-news__title { + margin: 0; + font-size: var(--text-17); + } + .vino-news__card--compact .vino-news__text { + display: none; + } +} +.vino-news { + background: var(--color-bg); +} +@media (min-width:981px) { + .vino-news .vino-news__grid { + gap: var(--space-12); + } +} +* { + box-sizing: border-box; +} +html { + margin: 0; + background: var(--color-bg); + scrollbar-color: color-mix(in srgb, var(--color-accent) 40%, transparent) var(--color-bg); + scroll-padding-top: calc(var(--size-header) + var(--space-4)); + -webkit-tap-highlight-color: transparent; +} +@media (prefers-reduced-motion: no-preference) { + html { + scroll-behavior: smooth; + } +} +button, input { + font: inherit; +} +img { + display: block; + width: 100%; + height: 100%; + object-fit: cover; +} +.vino-wrap, .vino-header__inner, .vino-footer__grid { + max-width: var(--container); + margin: 0 auto; +} +.vino-icon { + width: 20px; + height: 20px; + flex: 0 0 auto; +} +.vino-icon--search { + stroke-width: 1.4; +} +.vino-btn .vino-icon { + width: 16px; + height: 16px; +} +@media (hover:hover) { + .vino-btn:hover { + background: var(--color-white); + box-shadow: 0 18px 44px color-mix(in srgb, var(--color-accent) 20%, transparent); + transform: translateY(-2px); + } + .vino-btn--outline:hover { + background: var(--color-accent); + color: var(--color-bg); + } +} +.vino-btn { + display: inline-flex; + align-items: center; + gap: var(--space-3); + background: var(--color-accent); + color: var(--color-bg); + font-size: var(--text-13); + letter-spacing: var(--tracking-ui); + padding: var(--space-3) var(--space-6); + text-transform: uppercase; + box-shadow: 0 12px 32px color-mix(in srgb, var(--color-accent) 12%, transparent); + transition: background var(--duration-fast) var(--ease-base), box-shadow var(--duration-fast) var(--ease-base), color var(--duration-fast) var(--ease-base), transform var(--duration-fast) var(--ease-base); + border: 0; + font-family: var(--font-sans); + font-weight: 600; + line-height: var(--leading-title); + text-decoration: none; + cursor: pointer; +} +@media (pointer:coarse) { + .vino-btn { + min-height: var(--size-tap); + } +} +.vino-btn--sm { + padding: 11px var(--space-4); + white-space: nowrap; +} +.vino-btn--outline { + background: transparent; + color: var(--color-accent); + border: 1px solid var(--color-accent); +} +.vino-btn:disabled { + opacity: .6; + cursor: default; + pointer-events: none; +} +.vino-btn--loading { + position: relative; +} +.vino-btn--loading::after { + content: ""; + position: absolute; + top: 50%; + right: var(--space-1); + width: 14px; + height: 14px; + margin-top: -7px; + border: 2px solid color-mix(in srgb, currentColor 25%, transparent); + border-top-color: currentColor; + border-radius: 50%; + animation: vinoBtnSpin .7s linear infinite; +} +@media (max-width:760px) { + .vino-tabbar__item .vino-icon { + width: var(--icon-md); + height: var(--icon-md); + } +} +.vino-tabbar { + display: none; +} +.vino-footer .vino-logo--footer { + gap: var(--space-3); + margin-top: -18px; + margin-bottom: var(--space-5); + text-decoration: none; +} +@media (max-width:980px) { + .vino-footer .vino-logo--footer { + margin-top: 0; + } +} +.vino-footer .vino-subscribe__row .vino-btn { + box-shadow: none; +} +.vino-footer { + padding: var(--space-16) var(--space-6) var(--space-6); + border-top: 1px solid var(--color-line); + background: var(--color-bg); + color: var(--color-text-muted); +} +.vino-footer__news { + display: flex; + flex-wrap: wrap; + align-items: center; + justify-content: space-between; + gap: var(--space-6) var(--space-12); + max-width: var(--container); + margin: 0 auto var(--space-12); + padding-bottom: var(--space-12); + border-bottom: 1px solid var(--color-line); +} +.vino-footer__news-form { + flex: 0 1 520px; +} +.vino-footer__title { + margin: 0 0 var(--space-5); + color: var(--color-text); + font-size: var(--text-13); + font-weight: 400; + letter-spacing: var(--tracking-ui); + text-transform: uppercase; + font-family: var(--font-sans); + line-height: var(--leading-ui); +} +.vino-footer__title--news { + margin-bottom: var(--space-2); + font-family: var(--font-serif); + font-size: var(--fs-h3); + letter-spacing: 0; + line-height: var(--leading-title); + text-transform: none; +} +.vino-footer__lead, .vino-footer__about, .vino-footer__item, .vino-footer__link { + color: var(--color-text-muted); + font-size: var(--text-15); + line-height: var(--leading-text); +} +.vino-footer__lead { + margin: 0; +} +.vino-footer__grid { + display: grid; + grid-template-columns: 1fr; + gap: var(--space-10); + align-items: start; +} +.vino-footer__col { + min-width: 0; +} +.vino-footer__about { + max-width: 320px; + margin: 0; +} +.vino-footer__list { + display: flex; + flex-direction: column; + gap: var(--space-3); + margin: 0; + padding: 0; + list-style: none; +} +.vino-footer__phone { + color: var(--color-text); + font-size: var(--text-17); + line-height: var(--leading-text); + font-variant-numeric: tabular-nums; +} +.vino-footer__tg { + display: inline-flex; + margin-top: var(--space-5); + color: var(--color-text); + font-size: var(--text-15); + line-height: var(--leading-text); + text-decoration: none; + transition: color var(--duration-fast) var(--ease-base); +} +.vino-footer__tg-icon { + width: 24px; + height: 24px; +} +.vino-footer__bottom { + max-width: var(--container); + margin: 0 auto; + display: flex; + flex-direction: column; + align-items: center; + gap: var(--space-2); + margin-top: var(--space-12); + padding-top: var(--space-6); + border-top: 1px solid var(--color-line); + color: var(--color-text-faint); + font-size: var(--text-13); +} +.vino-footer__legal, .vino-footer__docs { + display: flex; + flex-wrap: wrap; + align-items: center; + gap: var(--space-2) var(--space-6); +} +.vino-footer__doc { + color: var(--color-text-faint); + font-size: var(--text-13); + line-height: var(--leading-text); + text-decoration: none; +} +.vino-footer__doc--button { + padding: 0; + border: 0; + background: none; + font-family: inherit; + text-align: left; + cursor: pointer; +} +.vino-footer__age { + margin-right: var(--space-2); + padding: 0 var(--space-1); + border: 1px solid var(--color-line); + border-radius: var(--radius-sm); + color: var(--color-text-muted); + font-weight: 600; +} +@media (hover:hover) { + .vino-footer__link:hover, .vino-footer__phone:hover, .vino-footer__tg:hover, .vino-footer__doc:hover { + color: var(--color-accent); + } +} +@media (pointer:coarse) { + .vino-footer__tg::after { + content: ""; + position: absolute; + inset: -10px; + } + .vino-footer__doc { + position: relative; + } + .vino-footer__doc::before { + content: ""; + position: absolute; + inset: -11px 0; + } +} +@media (max-width:760px) { + .vino-footer__grid { + grid-template-columns: repeat(2, minmax(0,1fr)); + gap: var(--space-10) var(--space-6); + } + .vino-footer__col--wide { + grid-column: 1 / -1; + } +} +@media (min-width:761px) { + .vino-footer { + padding-right: var(--space-12); + padding-left: var(--space-12); + } + .vino-footer__bottom { + flex-direction: row; + justify-content: space-between; + } +} +@media (min-width:761px) and (max-width:980px) { + .vino-footer__grid { + grid-template-columns: repeat(2, minmax(0, 1fr)); + } +} +@media (min-width:981px) { + .vino-footer__grid { + grid-template-columns: minmax(0,1.4fr) minmax(0,1fr) minmax(0,.8fr) minmax(0,1fr); + column-gap: var(--space-12); + } +} +@media (min-width:981px) and (max-width:1179px) { + .vino-footer__grid { + column-gap: var(--space-10); + } +} +.vino-footer .vino-subscribe { + display: block; + max-width: none; + margin: 0; +} +.vino-footer .vino-subscribe .vino-consent { + margin: var(--space-3) 0 0; +} +.vino-footer .vino-consent--sm .vino-consent__text { + font-size: var(--text-13); +} +.vino-footer .vino-consent__link { + color: var(--color-accent); + font-size: inherit; + line-height: inherit; +} +@media (hover:hover) { + .vino-footer .vino-consent__link:hover { + color: var(--color-accent-hover); + } +} +.vino-age .vino-age__logo .vino-logo__icon { + width: 56px; + height: 56px; +} +.vino-age .vino-age__logo .vino-logo__name { + color: var(--color-accent); + font-size: var(--fs-h4); +} +.vino-age { + position: fixed; + inset: 0; + z-index: var(--z-age); + display: flex; + align-items: center; + justify-content: center; + padding: var(--space-6); + background: color-mix(in srgb, var(--color-bg-deep) 80%, transparent); + backdrop-filter: blur(var(--blur-md)) saturate(120%); + -webkit-backdrop-filter: blur(var(--blur-md)) saturate(120%); + animation: vinoAgeFade .5s ease both; +} +.vino-age[hidden] { + display: none; +} +.vino-age__card { + position: relative; + width: 100%; + max-width: 460px; + padding: var(--space-12) 44px var(--space-10); + text-align: center; + background: radial-gradient(130% 120% at 50% 0%, color-mix(in srgb, var(--color-accent) 8%, transparent), transparent 55%), var(--color-surface); + border: 1px solid color-mix(in srgb, var(--color-accent) 28%, transparent); + border-radius: 6px; + box-shadow: 0 40px 120px color-mix(in srgb, var(--color-black) 60%, transparent); + animation: vinoAgeRise .6s cubic-bezier(.2, .72, .2, 1) both; +} +.vino-age__card:focus { + outline: none; +} +.vino-age__title { + margin: 0 0 var(--space-4); + color: var(--color-text); + font-family: var(--font-serif); + font-weight: 500; + font-size: var(--fs-h3); + line-height: var(--leading-tight); + font-variant-numeric: lining-nums; +} +.vino-age__text { + margin: 0 auto 30px; + max-width: 340px; + color: color-mix(in srgb, var(--color-white) 60%, transparent); + font-family: var(--font-sans); + font-size: var(--text-15); + line-height: var(--leading-text); +} +.vino-age__actions { + display: flex; + flex-direction: column; + gap: var(--space-3); +} +.vino-age__btn { + display: flex; + align-items: center; + justify-content: center; + padding: 15px 28px; + border: 1px solid transparent; + border-radius: var(--radius-sm); + font-family: var(--font-sans); + font-size: var(--text-13); + font-weight: 600; + letter-spacing: var(--tracking-sm); + text-transform: uppercase; + cursor: pointer; + transition: background var(--duration-base) var(--ease-base), color var(--duration-base) var(--ease-base), border-color var(--duration-base) var(--ease-base); +} +.vino-age__btn--yes { + background: var(--color-accent); + color: var(--color-on-accent); +} +@media (hover:hover) { + .vino-age__btn--yes:hover { + background: var(--color-accent-hover); + } +} +.vino-age__btn--no { + background: transparent; + color: color-mix(in srgb, var(--color-white) 65%, transparent); + border-color: color-mix(in srgb, var(--color-white) 18%, transparent); +} +@media (hover:hover) { + .vino-age__btn--no:hover { + color: var(--color-text); + border-color: color-mix(in srgb, var(--color-white) 40%, transparent); + } +} +.vino-age__legal { + margin: var(--space-6) 0 0; + color: color-mix(in srgb, var(--color-white) 60%, transparent); + font-family: var(--font-sans); + font-size: var(--text-xs); + line-height: var(--leading-ui); +} +.vino-age--leaving { + opacity: 0; + transition: opacity .4s; +} +.vino-age .vino-age__logo { + flex-direction: column; + gap: var(--space-3); + width: auto; + height: auto; + margin: 0 auto var(--space-6); +} +.vino-subscribe .vino-btn { + flex: 0 0 auto; +} +.vino-subscribe__row .vino-btn { + flex: 0 0 auto; + height: 48px; + padding: 0 var(--space-5); + border-radius: 0 var(--radius-sm) var(--radius-sm) 0; +} +@media (hover:hover) { + .vino-subscribe__row .vino-btn:hover { + transform: none; + } +} +.vino-subscribe .vino-inp { + flex: 1 1 100%; + min-width: 0; + margin: 0; +} +.vino-subscribe__row .vino-inp { + flex: 1 1 auto; + height: 48px; + margin: 0; + border-right: 0; + border-radius: var(--radius-sm) 0 0 var(--radius-sm); +} +.vino-subscribe__row .vino-inp:focus { + border-color: color-mix(in srgb, var(--color-accent) 60%, transparent); + outline: 0; +} +.vino-subscribe { + display: flex; + flex-wrap: wrap; + align-items: flex-start; + gap: var(--space-2); + margin: var(--space-3-5) 0 0; + max-width: 340px; +} +.vino-subscribe__row { + display: flex; +} +.vino-subscribe .vino-consent { + flex: 1 0 100%; + margin: 2px 0 0; +} +.vino-subscribe .vino-sub-msg { + min-height: calc(1em * var(--leading-ui)); + margin: var(--space-2) 0 0; + line-height: var(--leading-ui); +} +.vino-subscribe .vino-sub-msg[hidden] { + display: block; + visibility: hidden; +} +.vino-footer .vino-subscribe__row .vino-inp { + border-color: color-mix(in srgb, var(--color-white) 20%, transparent); + background: transparent; +} +.vino-sub-msg { + margin: var(--space-3-5) 0 0; + color: var(--color-success-soft); + font-size: var(--text-13); +} +.vino-sub-msg--err { + color: var(--color-danger-soft); +} +.vino-cookie[hidden] { + display: none; +} +.vino-cookie--on { + transform: none; +} +.vino-cookie__link { + color: var(--color-accent); + text-decoration: underline; + text-underline-offset: 2px; +} +.vino-cookie__actions { + display: flex; + flex: 0 0 auto; + gap: var(--space-2); +} +.vino-cookie { + position: fixed; + z-index: var(--z-cookie); + background: var(--color-surface); + transform: translateY(100%); + transition: transform var(--duration-base) var(--ease-base); + left: auto; + right: clamp(12px,3vw,32px); + bottom: clamp(12px,3vw,28px); + width: min(720px,calc(100vw - 24px)); + border: 1px solid var(--color-line); + border-radius: var(--radius-lg); + overflow: hidden; + box-shadow: 0 18px 70px color-mix(in srgb, var(--color-black) 48%, transparent); +} +.vino-cookie__inner { + max-width: var(--container); + margin: 0 auto; + display: flex; + align-items: center; + padding: var(--space-3) var(--space-3-5); + gap: var(--space-3-5); +} +.vino-cookie__text { + flex: 1; + margin: 0; + color: var(--color-text-muted); + font-size: var(--text-xs); + line-height: var(--leading-ui); +} +.vino-cookie__ok { + flex: 0 0 auto; + white-space: nowrap; +} +@media (max-width:560px) { + .vino-cookie { + right: 10px; + width: calc(100vw - 20px); + border-radius: var(--radius-md); + } + .vino-cookie__inner { + flex-direction: column; + display: grid; + grid-template-columns: 1fr auto; + align-items: center; + gap: 10px; + padding: 10px 10px 10px var(--space-3); + } + .vino-cookie__text { + font-size: var(--text-xs); + line-height: var(--leading-ui); + } + .vino-cookie__ok { + width: auto; + min-height: 34px; + padding: var(--space-2) var(--space-3); + } + .vino-cookie__actions { + flex-direction: column; + } +} +@media (pointer:coarse) { + .vino-cookie__ok { + min-height: 44px; + } +} +@media (min-width:561px) { + .vino-cookie { + left: var(--space-8); + right: auto; + bottom: var(--space-8); + width: 460px; + border: 1px solid color-mix(in srgb, var(--color-accent) 25%, transparent); + border-radius: var(--radius-md); + background: var(--color-bg-soft); + transform: translateY(calc(100% + var(--space-12))); + } + .vino-cookie--on { + transform: none; + } + .vino-cookie__inner { + display: grid; + gap: var(--space-5); + padding: var(--space-6); + } + .vino-cookie__text { + font-size: var(--text-15); + line-height: var(--leading-text); + } + .vino-cookie__ok { + justify-self: start; + } +} +.vino-header__inner { + position: relative; + display: flex; + align-items: center; + justify-content: space-between; +} +.vino-header { + position: sticky; + top: 0; + z-index: var(--z-header); + padding: var(--space-3-5) var(--gutter); + border-bottom: 1px solid color-mix(in srgb, var(--color-white) 5%, transparent); + background: color-mix(in srgb, var(--color-bg) 40%, transparent); + backdrop-filter: blur(4px); + transition: background var(--duration-fast) var(--ease-base), border-color var(--duration-fast) var(--ease-base), box-shadow var(--duration-fast) var(--ease-base), backdrop-filter var(--duration-fast) var(--ease-base); +} +.vino-header--scrolled { + border-bottom-color: var(--color-line); + background: color-mix(in srgb, var(--color-bg) 80%, transparent); + box-shadow: 0 8px 30px color-mix(in srgb, var(--color-black) 35%, transparent); + backdrop-filter: blur(12px); +} +@media (max-width:560px) { + .vino-header__inner { + gap: 10px; + } +} +.vino-header__main { + display: flex; + flex: 1; + align-items: center; + gap: var(--space-10); + min-width: 0; + margin-left: var(--space-8); +} +.vino-header.vino-header--mega { + background: color-mix(in srgb, var(--color-bg) 97%, transparent); +} +@media (min-width:981px) { + .vino-header .vino-header__main { + justify-content: center; + margin-left: var(--space-10); + margin-right: var(--space-10); + } +} +@media (min-width:981px) and (max-width:1279px) { + .vino-header .vino-header__main { + gap: var(--space-4); + margin-left: var(--space-5); + margin-right: var(--space-5); + } +} +@media (max-width:980px) { + .vino-header .vino-header__main { + margin-right: 0; + margin-left: 0; + } +} +@media (min-width:981px) and (max-width:1279px) { + .vino-header .vino-actions { + gap: var(--space-3); + } +} +.vino-logo { + display: flex; + align-items: center; + gap: var(--space-2); + border: 0; + background: transparent; + color: var(--color-text); +} +.vino-logo__icon { + display: block; + object-fit: contain; + width: 24px; + height: 24px; + color: var(--color-accent); + filter: drop-shadow(0 0 18px color-mix(in srgb, var(--color-accent) 18%, transparent)); + transition: filter var(--duration-header) var(--ease-base), color var(--duration-header) var(--ease-base); +} +@media (hover:hover) { + .vino-logo:hover .vino-logo__icon { + filter: drop-shadow(0 0 20px color-mix(in srgb, var(--color-accent) 50%, transparent)); + color: var(--color-accent-hover); + } +} +.vino-logo__name { + text-transform: uppercase; + font-family: var(--font-caps); + font-weight: 500; + font-size: var(--text-19); + letter-spacing: var(--tracking-md); +} +.vino-logo--header { + gap: var(--space-3); +} +.vino-logo--header .vino-logo__icon { + width: 56px; + height: 56px; +} +.vino-logo--header .vino-logo__name { + color: var(--color-accent); + font-size: var(--fs-h4); + white-space: nowrap; +} +@media (min-width:981px) and (max-width:1279px) { + .vino-logo--header .vino-logo__icon { + width: 48px; + height: 48px; + } +} +@media (max-width:400px) { + .vino-logo--header { + gap: var(--space-2); + } + .vino-logo--header .vino-logo__icon { + width: 48px; + height: 48px; + } + .vino-logo--header .vino-logo__name { + font-size: var(--text-15); + } +} +.vino-logo--footer .vino-logo__icon { + width: 56px; + height: 56px; +} +.vino-logo--footer .vino-logo__name { + color: var(--color-accent); + font-size: var(--fs-h4); + white-space: nowrap; +} +@media (min-width:981px) and (max-width:1179px) { + .vino-logo--header .vino-logo__name { + display: none; + } +} +@media (max-width:340px) { + .vino-logo--header .vino-logo__name { + display: none; + } +} +.vino-logo--footer { + margin-bottom: var(--space-4); + color: var(--color-text-muted); + font-size: var(--text-15); + line-height: var(--leading-text); +} +.vino-nav { + display: none; + align-items: center; + gap: var(--space-10); + font-size: var(--text-13); +} +.vino-nav__link { + color: color-mix(in srgb, var(--color-white) 80%, transparent); + transition: color var(--duration-fast) var(--ease-base); + font-family: var(--font-sans); + font-size: var(--text-13); + font-weight: 600; + letter-spacing: var(--tracking-ui); + text-transform: uppercase; +} +.vino-nav__link--extra, .vino-nav__ask { + display: none; +} +.vino-nav__link--active { + color: var(--color-accent); +} +@media (hover:hover) { + .vino-nav__link:hover { + color: var(--color-accent); + } +} +@media (max-width:980px) { + .vino-nav--open { + position: absolute; + top: calc(100% + 16px); + right: 0; + left: 0; + display: grid; + gap: 0; + border: 1px solid var(--color-line); + background: var(--color-bg); + padding: 10px 0; + box-shadow: 0 18px 40px color-mix(in srgb, var(--color-black) 34%, transparent); + backdrop-filter: blur(var(--blur-md)); + } + .vino-nav--open .vino-nav__link { + padding: var(--space-3-5) var(--space-5-5); + } + .vino-nav--open .vino-nav__ask { + display: block; + padding: var(--space-4) var(--space-6); + border: 0; + border-top: 1px solid var(--color-line); + background: none; + color: var(--color-accent); + font-family: var(--font-serif); + font-size: var(--text-19); + letter-spacing: var(--tracking-ui); + text-align: left; + text-transform: uppercase; + cursor: pointer; + } +} +@media (max-width:760px) { + .vino-nav--open .vino-nav__link--extra { + display: block; + } +} +@media (min-width:981px) { + .vino-nav { + display: flex; + flex: 0 1 auto; + justify-content: center; + } + .vino-nav__link { + font-weight: 500; + white-space: nowrap; + } + .vino-nav__link:not(.vino-nav__link--active) { + color: color-mix(in srgb, var(--color-white) 70%, transparent); + } + .vino-nav__link--catalog { + display: none; + } +} +@media (min-width:981px) and (hover:hover) { + .vino-nav__link:not(.vino-nav__link--active):hover { + color: var(--color-text); + } +} +@media (min-width:981px) and (max-width:1279px) { + .vino-nav { + gap: var(--space-4); + } +} +@media (min-width:981px) { + .vino-catalog-btn::after { + content: ""; + position: absolute; + right: 0; + bottom: calc(var(--space-3) - 6px); + left: 0; + height: 1px; + background: currentColor; + transform: scaleX(.3); + transform-origin: left center; + transition: transform .35s ease; + } + .vino-catalog-btn--open::after { + transform: scaleX(1); + } +} +@media (min-width:981px) and (hover:hover) { + .vino-catalog-btn:hover::after { + transform: scaleX(1); + } +} +.vino-catalog-btn { + position: relative; + display: none; + align-items: center; + padding: var(--space-3) 0; + border: 0; + background: transparent; + color: color-mix(in srgb, var(--color-white) 80%, transparent); + font-family: var(--font-sans); + font-size: var(--text-13); + font-weight: 600; + line-height: var(--leading-ui); + letter-spacing: var(--tracking-ui); + text-decoration: none; + text-transform: uppercase; + white-space: nowrap; + cursor: pointer; + transition: color var(--duration-fast) var(--ease-base); +} +.vino-catalog-btn--open { + color: var(--color-accent); +} +.vino-catalog-btn:focus-visible { + outline: 2px solid var(--color-accent); + outline-offset: 4px; +} +@media (min-width:981px) { + .vino-catalog-btn { + display: inline-flex; + } +} +@media (min-width:981px) and (hover:hover) { + .vino-catalog-btn:hover { + color: var(--color-text); + } +} +.vino-actions { + display: flex; + align-items: center; + gap: var(--space-5); + color: color-mix(in srgb, var(--color-white) 80%, transparent); +} +@media (max-width:760px) { + .vino-actions .vino-act--account, .vino-actions .vino-act--fav, .vino-actions .vino-act--compare { + display: none; + } + .vino-actions .vino-act--cart { + display: none; + } +} +.vino-actions .vino-lang__current { + display: inline-flex; + align-items: center; + justify-content: center; + gap: var(--space-1); + width: auto; + height: 40px; + padding: 0; + border: 0; + background: transparent; + color: color-mix(in srgb, var(--color-white) 70%, transparent); + font-family: var(--font-sans); + font-size: var(--text-13); + font-weight: 500; + letter-spacing: var(--tracking-ui); + cursor: pointer; + transition: color var(--duration-fast) var(--ease-base); +} +.vino-actions .vino-lang__option { + display: block; + width: auto; + height: auto; + padding: var(--space-2) var(--space-3); + color: var(--color-text-muted); + font-size: var(--text-13); + font-weight: 500; + letter-spacing: var(--tracking-ui); + text-align: center; + text-decoration: none; +} +@media (hover:hover) { + .vino-actions .vino-lang__option:hover { + color: var(--color-text); + } +} +.vino-actions .vino-lang__option--active { + color: var(--color-accent); +} +.vino-act { + position: relative; + display: flex; + width: var(--icon-md); + height: var(--icon-md); + overflow: visible; + align-items: center; + justify-content: center; + border: 0; + background: transparent; + color: inherit; + cursor: pointer; + padding: 0; + transition: color var(--duration-fast) var(--ease-base); +} +@media (hover:hover) { + .vino-act:hover { + color: var(--color-accent); + } +} +@media (min-width:981px) { + .vino-act--menu { + display: none; + } +} +@media (pointer:coarse), (max-width:760px) { + .vino-act::before { + content: ""; + position: absolute; + inset: -12px; + } +} +.vino-act__count { + position: absolute; + top: calc(var(--space-2) * -1); + right: calc(var(--space-2) * -1); + min-width: 16px; + height: 16px; + padding: 0 var(--space-1); + border-radius: var(--radius-full); + background: var(--color-accent); + color: var(--color-on-accent); + font-family: var(--font-sans); + font-size: var(--fs-caption); + font-weight: 700; + line-height: 16px; + letter-spacing: 0; + text-align: center; + pointer-events: none; +} +.vino-demo-bar { + margin: 0; + padding: var(--space-2) var(--space-4); + border-bottom: 1px solid var(--color-line); + background: var(--color-bg-deep); + color: var(--color-text-muted); + font-family: var(--font-sans); + font-size: var(--text-13); + line-height: var(--leading-ui); + text-align: center; +} +.vino-demo-bar__link { + color: var(--color-accent); + text-decoration: none; +} +@media (hover:hover) { + .vino-demo-bar__link:hover { + text-decoration: underline; + } +} +.vino-mega { + position: absolute; + top: 100%; + left: 0; + right: 0; + background: var(--color-bg); + border-top: 1px solid var(--color-line); + border-bottom: 1px solid color-mix(in srgb, var(--color-accent) 25%, transparent); + box-shadow: 0 30px 60px color-mix(in srgb, var(--color-black) 45%, transparent); + animation: vino-mega-in var(--duration-base) var(--ease-base); +} +.vino-mega::after { + content: ""; + position: absolute; + top: 100%; + right: 0; + left: 0; + height: 100vh; + background: color-mix(in srgb, var(--color-bg-deep) 62%, transparent); + pointer-events: none; +} +.vino-mega[hidden] { + display: none; +} +.vino-mega__inner { + display: grid; + grid-template-columns: 1fr 1fr 1fr 300px; + gap: var(--space-12); + max-width: var(--container); + margin: 0 auto; + padding: var(--space-10) var(--space-12) var(--space-8); +} +.vino-mega__title { + margin: 0 0 var(--space-5); + color: var(--color-accent); + font-family: var(--font-sans); + font-size: var(--text-xs); + font-weight: 600; + letter-spacing: var(--tracking-wide); + text-transform: uppercase; +} +.vino-mega__list { + display: grid; + gap: var(--space-1); + margin: 0; + padding: 0; + list-style: none; +} +.vino-mega__link { + display: flex; + align-items: baseline; + justify-content: space-between; + gap: var(--space-3); + padding: var(--space-1) 0; + color: color-mix(in srgb, var(--color-white) 80%, transparent); + font-family: var(--font-serif); + font-size: var(--text-19); + line-height: var(--leading-title); + text-decoration: none; + transition: color var(--duration-fast) var(--ease-base); +} +.vino-mega__count { + color: var(--color-text-faint); + font-family: var(--font-sans); + font-size: var(--text-xs); + font-style: normal; + letter-spacing: var(--tracking-xs); + transition: color var(--duration-fast) var(--ease-base); +} +@media (hover:hover) { + .vino-mega__link:hover, .vino-mega__link:hover .vino-mega__count { + color: var(--color-accent); + } +} +.vino-mega__more { + display: inline-block; + margin-top: var(--space-4); + color: var(--color-accent); + font-family: var(--font-sans); + font-size: var(--text-xs); + font-weight: 600; + letter-spacing: var(--tracking-ui); + text-transform: uppercase; + text-decoration: none; + transition: color var(--duration-fast) var(--ease-base); +} +@media (hover:hover) { + .vino-mega__more:hover { + color: var(--color-accent-hover); + } +} +.vino-mega__card { + position: relative; + display: block; + min-height: 320px; + overflow: hidden; + border: 1px solid color-mix(in srgb, var(--color-accent) 20%, transparent); + border-radius: var(--radius-sm); + text-decoration: none; +} +.vino-mega__card-img { + position: absolute; + inset: 0; + width: 100%; + height: 100%; + object-fit: cover; + object-position: 50% 0; + transition: transform var(--duration-soft) var(--ease-base); +} +@media (hover:hover) { + .vino-mega__card:hover .vino-mega__card-img { + transform: scale(1.04); + } +} +.vino-mega__card-body { + position: absolute; + left: 0; + right: 0; + bottom: 0; + display: grid; + gap: var(--space-2); + padding: var(--space-6); + background: linear-gradient(to top, color-mix(in srgb, var(--color-bg) 92%, transparent), transparent); +} +.vino-mega__card-kicker { + color: var(--color-accent); + font-family: var(--font-sans); + font-size: var(--text-xs); + font-weight: 600; + letter-spacing: var(--tracking-ui); + text-transform: uppercase; +} +.vino-mega__card-title { + color: var(--color-text); + font-family: var(--font-serif); + font-size: var(--fs-h4); + line-height: var(--leading-title); +} +@media (max-width:1279px) { + .vino-mega__inner { + grid-template-columns: 1fr 1fr 1fr 200px; + gap: var(--space-8); + padding-right: var(--space-8); + padding-left: var(--space-8); + } +} +@media (max-width:980px) { + .vino-mega { + display: none; + } +} +.vino-mega__card-link { + color: color-mix(in srgb, var(--color-white) 80%, transparent); + font-family: var(--font-sans); + font-size: var(--text-13); + justify-self: start; +} +@media (pointer:coarse) { + .vino-lang__current::after { + content: ""; + position: absolute; + inset: -2px -4px; + } +} +.vino-lang { + position: relative; +} +.vino-lang[data-open="true"] .vino-lang__current { + color: var(--color-text); +} +.vino-lang__label { + display: inline-grid; +} +.vino-lang__text { + grid-area: 1 / 1; +} +.vino-lang__text--ghost { + visibility: hidden; +} +.vino-lang__chev { + width: 10px; + height: 6px; + transition: transform var(--duration-fast) var(--ease-base); +} +.vino-lang[data-open="true"] .vino-lang__chev { + transform: rotate(180deg); +} +.vino-lang__menu { + position: absolute; + top: 100%; + left: 50%; + z-index: var(--z-lang); + display: flex; + flex-direction: column; + min-width: 64px; + padding: var(--space-1); + border: 1px solid var(--color-line); + border-radius: var(--radius-sm); + background: var(--color-bg); + opacity: 0; + visibility: hidden; + transform: translateX(-50%); + transition: opacity var(--duration-fast) var(--ease-base), visibility var(--duration-fast) var(--ease-base); +} +.vino-lang[data-open="true"] .vino-lang__menu { + opacity: 1; + visibility: visible; +} +@media (hover:hover) { + .vino-actions .vino-lang__current:hover { + color: var(--color-text); + } +} +.vino-skip { + position: fixed; + top: -80px; + left: var(--space-4); + z-index: var(--z-skip); + padding: var(--space-3) var(--space-4); + background: var(--color-accent); + color: var(--color-bg); + font-size: var(--text-13); + letter-spacing: var(--tracking-ui); + text-transform: uppercase; +} +.vino-skip:focus { + top: var(--space-4); +} +@media (max-width:760px) { + .vino-kicker { + display: none; + } +} +.vino-kicker { + margin: 0 0 var(--space-3); + color: var(--color-accent); + font-family: var(--font-sans); + font-size: var(--text-13); + font-weight: 600; + letter-spacing: var(--tracking-wide); + text-transform: uppercase; +} +.vino-badge { + position: absolute; + top: -7px; + right: -8px; + min-width: 15px; + height: 15px; + padding: 0 var(--space-1); + border-radius: var(--radius-full); + background: var(--color-accent); + color: var(--color-on-accent); + font-family: var(--font-sans); + font-size: var(--fs-caption); + font-weight: 700; + letter-spacing: var(--tracking-xs); + line-height: 15px; + text-align: center; + box-shadow: 0 0 0 2px var(--color-brown-950); + pointer-events: none; +} +.vino-busy { + position: fixed; + inset: 0; + z-index: 1100; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + gap: var(--space-4); + background: color-mix(in srgb, var(--color-bg) 85%, transparent); +} +.vino-busy[hidden] { + display: none; +} +.vino-busy__spinner { + width: 40px; + height: 40px; + border: 3px solid color-mix(in srgb, var(--color-accent) 25%, transparent); + border-top-color: var(--color-accent); + border-radius: 50%; + animation: vinoBtnSpin .8s linear infinite; +} +.vino-busy__text { + margin: 0; + color: var(--color-text); + font-size: var(--text-15); + letter-spacing: var(--tracking-ui); +} +@keyframes vinoBtnSpin { + to { + transform: rotate(360deg); + } +} +@media (prefers-reduced-motion: reduce) { + .vino-btn--loading::after, + .vino-busy__spinner { + animation-duration: 2s; + } +} +.vino-modal__form .vino-btn { + justify-content: center; + width: 100%; + height: 48px; + margin-top: var(--space-3); + border-radius: var(--radius-sm); + box-shadow: none; +} +.vino-modal__form .vino-inp { + display: block; + height: 48px; + margin: 0 0 var(--space-3); + border-radius: var(--radius-sm); +} +.vino-modal__form .vino-txt { + height: auto; +} +.vino-modal__form .vino-consent { + margin: var(--space-4) 0 0; +} +.vino-modal__form .vino-consent--sm .vino-consent__text { + font-size: var(--text-13); +} +.vino-modal { + width: 100%; + height: 100%; + max-width: none; + max-height: none; + margin: 0; + padding: var(--space-6); + border: 0; + background: transparent; + color: inherit; + overflow: hidden; + align-items: center; + justify-content: center; +} +.vino-modal[open] { + display: flex; +} +.vino-modal::backdrop { + background: color-mix(in srgb, var(--color-black) 72%, transparent); +} +.vino-modal__dialog { + position: relative; + width: 100%; + max-width: 480px; + max-height: calc(100vh - var(--space-12)); + overflow: auto; + padding: var(--space-10); + border: 1px solid color-mix(in srgb, var(--color-accent) 20%, transparent); + border-radius: var(--radius-sm); + background: var(--color-bg); +} +.vino-modal__close { + position: absolute; + top: var(--space-3); + right: var(--space-3); + width: 40px; + height: 40px; + border: 0; + background: transparent; + color: var(--color-text-muted); + display: flex; + align-items: center; + justify-content: center; + padding: 0; + cursor: pointer; + transition: color var(--duration-fast) var(--ease-base); +} +@media (pointer:coarse) { + .vino-modal__close { + width: var(--size-tap); + height: var(--size-tap); + } +} +.vino-modal__close-icon { + width: 20px; + height: 20px; +} +.vino-modal__kicker { + margin: 0 0 var(--space-2); + color: var(--color-accent); + font-family: var(--font-sans); + font-size: var(--text-13); + font-weight: 600; + letter-spacing: var(--tracking-ui); + text-transform: uppercase; +} +.vino-modal__title { + margin: 0; + color: var(--color-text); + font-family: var(--font-serif); + font-size: var(--fs-h3); + font-weight: 500; + line-height: var(--leading-title); +} +.vino-modal__lead { + margin: var(--space-3) 0 var(--space-6); + color: var(--color-text-muted); + font-size: var(--text-15); + line-height: var(--leading-text); +} +.vino-modal__err { + min-height: calc(2em * var(--leading-ui)); + margin: var(--space-3) 0 0; + color: var(--color-danger-soft); + font-size: var(--text-13); + line-height: var(--leading-ui); +} +.vino-modal__err[hidden] { + display: block; + visibility: hidden; +} +@media (max-width:560px) { + .vino-modal { + align-items: stretch; + padding: 0; + } + .vino-modal__dialog { + max-width: none; + max-height: none; + height: 100%; + padding: var(--space-12) var(--space-6) var(--space-8); + border: 0; + border-radius: 0; + } +} +.vino-modal__done:focus { + outline: none; +} +.vino-modal__contact { + color: var(--color-text); + overflow-wrap: anywhere; +} +.vino-showcase-banner--catalog .vino-btn--outline { + background: color-mix(in srgb, var(--color-bg) 60%, transparent); + -webkit-backdrop-filter: blur(6px); + backdrop-filter: blur(6px); +} +@media (max-width:560px) { + .vino-showcase-banner__actions .vino-btn { + justify-content: center; + } +} +@media (hover:hover) { + .vino-showcase-banner--catalog .vino-btn--outline:hover { + border-color: color-mix(in srgb, var(--color-accent), var(--color-white) 75%); + background: color-mix(in srgb, var(--color-bg) 60%, transparent); + color: color-mix(in srgb, var(--color-accent), var(--color-text) 75%); + } +} +.vino-showcase-banner { + margin-top: var(--space-head); + display: grid; + grid-template-columns: minmax(0,1fr) auto; + gap: var(--space-6); + align-items: end; + padding: clamp(var(--space-6),4vw,var(--space-10)); + border: 1px solid color-mix(in srgb, var(--color-accent) 28%, transparent); + background: radial-gradient(720px 260px at 88% 14%, color-mix(in srgb, var(--color-accent) 8%, transparent), transparent 62%), linear-gradient(135deg, rgba(26,16,14,.96), rgba(14,9,8,.98)); + box-shadow: 0 22px 70px color-mix(in srgb, var(--color-black) 24%, transparent); +} +.vino-showcase-banner__eyebrow { + display: block; + margin-bottom: var(--space-3); + color: var(--color-accent); + font-size: var(--text-13); + font-weight: 600; + letter-spacing: var(--tracking-sm); + text-transform: uppercase; +} +@media (max-width:760px) { + .vino-showcase-banner__eyebrow { + display: none; + } +} +.vino-showcase-banner__title { + margin: 0; + max-width: 760px; + color: var(--color-text); + font-family: var(--font-serif); + font-size: var(--fs-h3); + font-weight: 400; + line-height: var(--leading-tight); + text-wrap: balance; +} +.vino-showcase-banner__text { + max-width: 720px; + margin: var(--space-4) 0 0; + text-wrap: pretty; + color: var(--color-text-muted); + line-height: var(--leading-text); +} +.vino-showcase-banner__actions { + display: flex; + gap: var(--space-3); + flex-wrap: wrap; + justify-content: flex-end; +} +@media (max-width:760px) { + .vino-showcase-banner { + padding: var(--space-6); + } +} +.vino-showcase-banner--catalog { + position: relative; + isolation: isolate; + overflow: hidden; +} +.vino-showcase-banner__media { + position: absolute; + top: 0; + right: 0; + bottom: 0; + z-index: -1; + width: 62%; + pointer-events: none; +} +.vino-showcase-banner__img { + display: block; + width: 100%; + height: 100%; + object-fit: cover; + opacity: .45; + filter: brightness(.6) saturate(.72); + -webkit-mask-image: linear-gradient(90deg, transparent 15%, #000 70%); + mask-image: linear-gradient(90deg, transparent 15%, #000 70%); +} +@media (max-width:980px) { + .vino-showcase-banner { + grid-template-columns: minmax(0,1fr); + align-items: start; + } + .vino-showcase-banner__actions { + justify-content: flex-start; + } + .vino-showcase-banner__media { + width: 100%; + } + .vino-showcase-banner__img { + opacity: .25; + } +} +@media (max-width:560px) { + .vino-showcase-banner__actions { + display: grid; + grid-template-columns: minmax(0,1fr); + } +} +@media (hover:hover) { + .vino-btn:hover .vino-icon, .vino-section__link:hover .vino-section__link-icon { + transform: translateX(4px); + } +} +.vino-brands__grid { + display: grid; + grid-template-columns: repeat(2, minmax(0, 1fr)); + border-top: 1px solid var(--color-line); + border-left: 1px solid var(--color-line); +} +@media (min-width:761px) { + .vino-brands__grid { + grid-template-columns: repeat(4, minmax(0, 1fr)); + } +} +.vino-brands__more { + display: flex; + justify-content: center; + width: 100%; + margin-top: var(--space-6); +} +.vino-brands__more[hidden] { + display: none; +} +@media (hover:hover) { + .vino-brands__item:hover { + background: var(--color-bg-soft); + transform: translateY(-2px); + } + .vino-brands__item:hover .vino-brands__name { + color: var(--color-text); + } +} +.vino-brands__item { + --vino-brands-item-height: 140px; + min-height: var(--vino-brands-item-height); + display: flex; + align-items: center; + justify-content: center; + flex-direction: column; + border-right: 1px solid var(--color-line); + border-bottom: 1px solid var(--color-line); + text-align: center; + transition: background var(--duration-fast) var(--ease-base), transform var(--duration-base) var(--ease-base); + padding: var(--space-10) var(--space-6); + gap: var(--space-2); +} +.vino-brands__logo { + --vino-brands-logo-height: 88px; + display: block; + width: 100%; + height: var(--vino-brands-logo-height); + margin-bottom: var(--space-2); + object-fit: contain; +} +.vino-brands__item--logo .vino-brands__name { + position: absolute; + width: 1px; + height: 1px; + margin: -1px; + overflow: hidden; + clip: rect(0,0,0,0); + white-space: nowrap; +} +.vino-brands__name { + color: var(--color-accent); + text-transform: uppercase; + transition: color var(--duration-fast) var(--ease-base); + font-family: var(--font-serif); + font-size: clamp(1rem, 1.4vw, 1.25rem); + letter-spacing: var(--tracking-ui); + margin-bottom: var(--space-3); + font-weight: 500; +} +.vino-brands__meta { + color: var(--color-text-faint); + font-family: var(--font-sans); + font-size: var(--text-13); + letter-spacing: var(--tracking-wide); + text-transform: uppercase; +} +.vino-brands { + background: var(--color-bg); +} +.vino-brands__page { + display: contents; +} +@media (max-width:760px) { + .vino-brands__grid--slider { + display: grid; + grid-template-columns: none; + grid-template-rows: auto auto; + grid-auto-columns: 100%; + grid-auto-flow: column; + overflow-x: auto; + overscroll-behavior-x: contain; + scroll-snap-type: x mandatory; + scrollbar-width: none; + border: 0; + } + .vino-brands__grid--slider::-webkit-scrollbar { + display: none; + } + .vino-brands__page { + display: grid; + grid-row: span 2; + grid-template-rows: subgrid; + grid-template-columns: repeat(2, minmax(0, 1fr)); + border-top: 1px solid var(--color-line); + border-left: 1px solid var(--color-line); + scroll-snap-align: start; + scroll-snap-stop: always; + } + .vino-brands__grid--slider .vino-brands__item { + height: auto; + min-height: 96px; + padding: var(--space-4) var(--space-3); + } + .vino-brands__grid--slider .vino-brands__name { + margin-bottom: var(--space-1); + letter-spacing: var(--tracking-sm); + } + .vino-brands__grid--slider .vino-brands__meta { + color: color-mix(in srgb, var(--color-white) 70%, transparent); + font-size: var(--text-13); + letter-spacing: 0; + text-transform: none; + } + .vino-brands__dots { + margin-top: var(--space-3); + } +} +.vino-sections { + display: grid; + grid-template-columns: minmax(0, 1fr); + gap: var(--space-3); +} +.vino-sections__item { + position: relative; + display: block; + overflow: hidden; + border: 1px solid var(--color-line); + border-radius: var(--radius-sm); + background: var(--color-surface); +} +.vino-sections__media { + display: block; + aspect-ratio: 16 / 9; + background: var(--color-bg-soft); +} +.vino-sections__img { + width: 100%; + height: 100%; + object-fit: cover; + transition: transform var(--duration-soft) var(--ease-base); +} +.vino-sections__body { + position: absolute; + right: 0; + bottom: 0; + left: 0; + display: flex; + flex-direction: column; + gap: var(--space-1); + padding: var(--space-12) var(--space-6) var(--space-5); + background: linear-gradient(to top, color-mix(in srgb, var(--color-bg) 92%, transparent), transparent); +} +.vino-sections__name { + color: var(--color-text); + font-family: var(--font-serif); + font-size: 1.5rem; + font-weight: 500; + line-height: var(--leading-tight); + transition: color var(--duration-fast) var(--ease-base); +} +.vino-sections__meta { + color: var(--color-accent); + font-family: var(--font-sans); + font-size: var(--text-13); + letter-spacing: .08em; + text-transform: uppercase; +} +@media (min-width:561px) { + .vino-sections { + grid-template-columns: repeat(2, minmax(0, 1fr)); + gap: var(--space-4); + } + .vino-sections__name { + font-size: var(--fs-h3); + } +} +@media (min-width:561px) and (max-width:760px) { + .vino-sections__item:last-child:nth-child(odd) { + grid-column: 1 / -1; + } +} +@media (min-width:761px) { + .vino-sections { + grid-template-columns: repeat(6, minmax(0, 1fr)); + } + .vino-sections__item { + grid-column: span 2; + } + .vino-sections__item:nth-child(4):nth-last-child(2), .vino-sections__item:nth-child(5):nth-last-child(1) { + grid-column: span 3; + } +} +@media (hover:hover) { + .vino-sections__item:hover .vino-sections__img { + transform: scale(1.04); + } + .vino-sections__item:hover .vino-sections__name { + color: var(--color-accent); + } +} +.vino-product-grid { + display: grid; + grid-template-columns: repeat(4, minmax(0, 1fr)); + gap: var(--space-grid-base); +} +@media (max-width:980px) and (min-width:761px) { + .vino-product-grid--full { + grid-template-columns: repeat(3, minmax(0, 1fr)); + } +} +@media (max-width:760px) { + .vino-product-grid { + grid-template-columns: repeat(2, minmax(0, 1fr)); + } +} +@media (max-width:560px) { + .vino-product-grid { + grid-template-columns: 1fr; + } + .vino-product-grid--full { + grid-template-columns: repeat(2, minmax(0, 1fr)); + } +} +.vino-card__img { + transition: transform var(--duration-soft) var(--ease-base); +} +@media (hover:hover) { + .vino-card:hover .vino-card__img { + transform: scale(1.05); + } + .vino-card:hover .vino-card__title { + color: var(--color-accent); + } +} +.vino-card__image { + --vino-card-image-height: 260px; + --vino-card-image-ratio: 25 / 22; + height: var(--vino-card-image-height); + display: block; + overflow: hidden; + background: var(--color-surface); + margin-bottom: var(--space-5); + position: relative; +} +@media (max-width:560px) { + .vino-card__image { + height: auto; + aspect-ratio: var(--vino-card-image-ratio); + } +} +.vino-card__title { + color: var(--color-text); + transition: color var(--duration-fast) var(--ease-base); + font-family: var(--font-serif); + font-size: var(--fs-h4); + font-weight: 500; + line-height: var(--leading-title); + margin: 0 0 var(--space-1); + margin-bottom: 10px; +} +.vino-card__place { + font-family: var(--font-sans); + font-size: var(--text-13); + font-style: normal; + display: block; + margin: 0 0 10px; + color: var(--color-text-muted); +} +.vino-card__cart { + display: inline-flex; + align-items: center; + border: 1px solid var(--color-accent); + color: var(--color-accent); + font-family: var(--font-sans); + font-weight: 600; + text-transform: uppercase; + background: transparent; + cursor: pointer; + white-space: nowrap; + gap: 0; + width: 40px; + min-width: 40px; + height: 40px; + padding: 0; + justify-content: center; + font-size: 0; + letter-spacing: 0; + border-radius: var(--radius-sm); + transition: background var(--duration-fast) var(--ease-base), color var(--duration-fast) var(--ease-base), border-color var(--duration-fast) var(--ease-base); + margin-left: auto; + flex: none; +} +.vino-card__cart::before { + content: ""; + flex: 0 0 auto; + background-color: currentColor; + width: 19px; + height: 19px; + -webkit-mask-size: contain; + mask-size: contain; + -webkit-mask-repeat: no-repeat; + mask-repeat: no-repeat; + -webkit-mask-position: center; + mask-position: center; + -webkit-mask-image: url("data:image/svg+xml;utf8,"); + mask-image: url("data:image/svg+xml;utf8,"); +} +@media (hover:hover) { + .vino-card__cart:hover { + background: var(--color-accent); + color: var(--color-bg); + border-color: var(--color-accent); + } +} +@media (pointer:coarse) { + .vino-card__cart { + width: 44px; + min-width: 44px; + height: 44px; + } +} +.vino-card__image--shot .vino-card__img { + object-fit: cover; +} +.vino-card__price { + font-family: var(--font-sans); + font-weight: 600; + font-size: var(--fs-h4); + letter-spacing: 0; + line-height: 1; + white-space: nowrap; + font-variant-numeric: tabular-nums; + font-feature-settings: "tnum" 1; + color: var(--color-accent); +} +.vino-card__old { + display: block; + margin-bottom: var(--space-1); + color: var(--color-text-faint); + font-size: var(--text-13); + font-weight: 400; +} +.vino-card__old s { + text-decoration-thickness: 1px; +} +.vino-card__percent { + margin-left: var(--space-2); + color: var(--color-accent); + font-weight: 600; +} +.vino-card__qty { + display: none; + align-items: center; + margin-left: auto; + height: 40px; + border-bottom: 1px solid color-mix(in srgb, var(--color-accent) 55%, transparent); + border-radius: 0; + overflow: hidden; +} +.vino-card__qty--active { + display: inline-flex; +} +.vino-card__qty--active + .vino-card__cart { + display: none; +} +.vino-card__step { + width: 38px; + min-width: 38px; + height: 100%; + padding: 0; + border: 0; + border-radius: 0; + background: transparent; + color: var(--color-accent); + font-family: var(--font-sans); + font-size: var(--text-19); + line-height: 1; + font-weight: 500; + cursor: pointer; + display: inline-flex; + align-items: center; + justify-content: center; + transition: background var(--duration-fast) var(--ease-base), color var(--duration-fast) var(--ease-base); +} +@media (hover:hover) { + .vino-card__step:hover { + color: var(--color-text); + } +} +.vino-card__count { + display: flex; + align-items: center; + justify-content: center; + align-self: stretch; + min-width: 30px; + text-align: center; + font-family: var(--font-sans); + font-size: var(--text-15); + font-weight: 600; + color: var(--color-text); + font-variant-numeric: tabular-nums; +} +.vino-card__tools { + position: absolute; + top: 14px; + right: 14px; + z-index: 4; + display: inline-flex; + align-items: center; + gap: var(--space-3); +} +.vino-card .vino-card__tool { + display: inline-flex; + align-items: center; + justify-content: center; + width: 34px; + height: 34px; + min-width: 0; + padding: 0; + margin: -5px; + border: 0; + border-radius: 50%; + background: transparent; + color: color-mix(in srgb, var(--color-white) 78%, transparent); + letter-spacing: 0; + text-transform: none; + cursor: pointer; + transition: color var(--duration-fast) var(--ease-base), background var(--duration-fast) var(--ease-base), transform var(--duration-fast) var(--ease-base); +} +.vino-card__tool-icon { + width: 21px; + height: 21px; + flex-shrink: 0; + display: block; + transition: fill var(--duration-fast) var(--ease-base), stroke var(--duration-fast) var(--ease-base); +} +.vino-card:where(:has(.vino-card__image--shot)) .vino-card__tool { + color: rgba(38,22,18,.82); +} +.vino-card:has(.vino-photo-stub) .vino-card__tool { + color: color-mix(in srgb, var(--color-white) 78%, transparent); +} +@media (hover:hover) { + .vino-card .vino-card__tool:not(.vino-card__tool--active):hover { + color: var(--color-danger); + background: transparent; + } +} +.vino-card .vino-card__tool--active { + color: var(--color-danger); +} +.vino-card__tool--active .vino-card__tool-icon { + fill: var(--color-danger); +} +@media (pointer:coarse) { + .vino-card__tool::after { + content: ""; + position: absolute; + inset: -5px; + } + .vino-card__qty { + height: var(--size-tap); + } + .vino-card__step { + width: var(--size-tap); + min-width: var(--size-tap); + } +} +.vino-card { + color: var(--color-text); + cursor: pointer; + position: relative; + display: flex; + flex-direction: column; + overflow: hidden; + border: 1px solid var(--color-line); + border-radius: var(--radius-sm); + background: var(--color-bg-soft); + transition: border-color var(--duration-fast) var(--ease-base); +} +@media (hover:hover) { + .vino-card:hover { + border-color: color-mix(in srgb, var(--color-accent) 35%, transparent); + } +} +.vino-card__body { + display: flex; + flex-direction: column; + flex: 1 1 auto; + padding: var(--space-card); +} +.vino-card__rating { + display: inline-flex; + align-items: center; + gap: var(--space-1); + margin: 0 0 var(--space-1); + color: var(--color-accent); + font-size: var(--text-13); + font-weight: 600; + font-variant-numeric: tabular-nums; +} +.vino-card__rating-star { + width: 12px; + height: 12px; + flex: 0 0 auto; + background-color: currentColor; + -webkit-mask: var(--icon-star) center / contain no-repeat; + mask: var(--icon-star) center / contain no-repeat; +} +.vino-card__rating-count { + color: var(--color-text-faint); + font-weight: 400; +} +.vino-card--line { + display: grid; + grid-template-columns: 200px minmax(0, 1fr) auto; + align-items: stretch; +} +.vino-card--line .vino-card__image { + height: 240px; + margin-bottom: 0; +} +.vino-card--line .vino-card__buy { + flex-direction: column; + align-items: flex-end; + justify-content: center; + gap: var(--space-3); + min-width: 200px; + margin-top: 0; + padding: var(--space-card); + border-top: 0; +} +.vino-card--line .vino-card__tool { + color: var(--color-text-faint); +} +.vino-card__grapes { + display: block; + color: var(--color-text-faint); + font-size: var(--text-13); +} +.vino-card__unavailable { + margin-left: auto; + color: var(--color-text-faint); + font-size: var(--text-13); + text-transform: uppercase; + letter-spacing: var(--tracking-ui); +} +.vino-card__buy { + justify-content: space-between; + gap: var(--space-3); + position: relative; + display: flex; + align-items: center; + margin-top: auto; + padding-top: var(--space-4); + border-top: 1px solid var(--color-line); +} +.vino-card__spec { + display: block; + margin-top: 0; + font-family: var(--font-sans); + font-size: var(--text-xs); + font-weight: 600; + letter-spacing: var(--tracking-sm); + text-transform: uppercase; + color: color-mix(in srgb, var(--color-white) 42%, transparent); + margin-bottom: var(--space-4); +} +.vino-photo-stub { + position: absolute; + inset: 0; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + gap: var(--space-3); + padding: var(--space-4); + text-align: center; +} +.vino-photo-stub__brand { + font-family: var(--font-serif); + font-size: clamp(1.4rem, 2.2vw, 2rem); + letter-spacing: .08em; + line-height: 1.15; + text-transform: uppercase; + color: var(--color-accent); + opacity: .6; +} +.vino-photo-stub--sm { + padding: 2px; +} +.vino-photo-stub--sm .vino-photo-stub__brand { + font-size: .625rem; + letter-spacing: 0; + overflow-wrap: anywhere; +} +.vino-photo-stub__text { + color: var(--color-text-faint); + font-size: var(--text-13); + letter-spacing: .08em; + text-transform: uppercase; +} +.vino-slider__track .vino-card { + flex: 0 0 calc((100% - var(--vino-slider-gap) * (var(--vino-slider-cols) - 1)) / var(--vino-slider-cols)); + scroll-snap-align: start; +} +.vino-slider__nav { + display: inline-flex; + align-items: center; + gap: 10px; +} +.vino-slider__viewport { + overflow-x: auto; + overflow-y: visible; + scroll-snap-type: x mandatory; + -ms-overflow-style: none; + scrollbar-width: none; +} +.vino-slider__track { + --vino-slider-gap: clamp(16px, 1.8vw, 24px); + --vino-slider-cols: 4; + display: flex; + gap: var(--vino-slider-gap); + padding: 2px 0 6px; +} +@media (min-width:761px) and (max-width:980px) { + .vino-slider__track { + --vino-slider-cols: 3; + } +} +@media (max-width:760px) { + .vino-slider__nav { + display: none; + } +} +.vino-slider__head-actions { + display: inline-flex; + align-items: center; + gap: var(--space-5-5); +} +@media (max-width:760px) { + .vino-slider__viewport { + margin-inline: calc(var(--gutter) * -1); + padding-inline: var(--gutter); + scroll-padding-inline: var(--gutter); + } + .vino-slider__track { + gap: var(--space-3); + } +} +@media (max-width:760px) { + .vino-slider__track .vino-card { + flex-basis: calc((100vw - var(--gutter) - var(--space-3) * 2) / 2.3); + } + .vino-slider__track .vino-card__tools { + top: var(--space-2); + right: var(--space-2); + gap: var(--space-1); + } + .vino-slider__track .vino-card__tool-icon { + width: 18px; + height: 18px; + } + .vino-slider__track .vino-card__body { + padding: var(--space-3); + } + .vino-slider__track .vino-card__title { + display: -webkit-box; + overflow: hidden; + margin-bottom: var(--space-1); + font-size: var(--text-15); + line-height: 1.25; + -webkit-box-orient: vertical; + -webkit-line-clamp: 2; + } + .vino-slider__track .vino-card__place, .vino-slider__track .vino-card__spec { + overflow: hidden; + margin-bottom: var(--space-1); + font-size: var(--text-13); + letter-spacing: 0; + text-overflow: ellipsis; + white-space: nowrap; + } + .vino-slider__track .vino-card__spec { + margin-bottom: var(--space-3); + font-weight: 400; + text-transform: none; + } + .vino-slider__track .vino-card__buy { + padding-top: var(--space-3); + } + .vino-slider__track .vino-card__price { + font-size: var(--text-17); + } + .vino-card__buy { + flex-wrap: wrap; + } + .vino-card__buy .vino-card__cart, .vino-card__buy .vino-card__qty { + flex: 1 0 100%; + height: var(--size-tap); + margin: 0; + } + .vino-card__buy .vino-card__cart { + gap: var(--space-1); + width: auto; + min-width: 0; + font-size: var(--fs-caption); + letter-spacing: var(--tracking-xs); + text-transform: uppercase; + } + .vino-card__buy .vino-card__cart::before { + width: 16px; + height: 16px; + } + .vino-card__buy .vino-card__qty { + justify-content: space-between; + } + .vino-card__buy .vino-card__unavailable { + display: flex; + flex: 1 0 100%; + align-items: center; + min-height: var(--size-tap); + margin-left: 0; + } +} +.vino-card--line .vino-card__body { + justify-content: center; + padding: var(--space-card) var(--space-6); +} +.vino-card--line .vino-card__place { + margin-bottom: var(--space-2); + font-size: var(--text-15); +} +.vino-card--line .vino-card__spec { + margin-bottom: var(--space-1); +} +.vino-card--line .vino-card__cart { + width: auto; + min-width: 0; + height: 44px; + margin-left: 0; + padding: 0 var(--space-5); + gap: var(--space-2); + font-size: var(--text-13); + letter-spacing: var(--tracking-ui); +} +@media (max-width:560px) { + .vino-card--line { + grid-template-columns: 96px minmax(0, 1fr); + } + .vino-card--line .vino-card__image { + grid-row: span 2; + height: 100%; + min-height: 160px; + } + .vino-card--line .vino-card__body { + padding: var(--space-3) var(--space-3) 0; + } + .vino-card--line .vino-card__buy { + align-items: stretch; + min-width: 0; + padding: var(--space-3); + border-left: 0; + } +} +.vino-card .vino-card__spec { + color: var(--color-text-faint); + font-size: var(--text-13); + font-weight: 400; + letter-spacing: 0; + text-transform: none; +} +.vino-story, .vino-sales { + color: var(--color-text); +} +@media (min-width:761px) { + .vino-story__grid { + grid-template-columns: repeat(2, minmax(0, 1fr)); + } +} +.vino-story__image { + --vino-story-image-height: 480px; + --vino-story-image-ratio: auto; + height: var(--vino-story-image-height); + aspect-ratio: var(--vino-story-image-ratio); + overflow: hidden; +} +.vino-story__img { + transform: scale(1.01); + transition: transform var(--duration-slow) var(--ease-base); +} +@media (hover:hover) { + .vino-story__image:hover .vino-story__img { + transform: scale(1.045); + } +} +.vino-story__text { + max-width: 50ch; + margin: 0 0 var(--space-8); + color: var(--color-text-muted); + font-size: var(--text-15); + line-height: var(--leading-long); +} +.vino-story__grid { + display: grid; + align-items: center; + gap: var(--space-10); +} +@media (min-width:981px) { + .vino-story__grid { + gap: var(--space-20); + } +} +.vino-story__title { + font-family: var(--font-serif); + font-weight: 400; + font-size: var(--fs-h2); + line-height: var(--leading-tight); + letter-spacing: var(--tracking-tight); + margin: 0; + margin-bottom: var(--space-6); +} +.vino-story { + background: var(--color-bg-soft); + border-top: 1px solid var(--color-line); +} +.vino-sales { + border-top: 1px solid var(--color-line); + background: var(--color-bg); +} +@media (prefers-reduced-motion:no-preference) { + .vino-section, .vino-story, .vino-sales, .vino-footer, .vino-pdp, .vino-reviews, .vino-pdp-related, .vino-auth:not(.vino-auth--embed) { + animation: vinoSectionIn var(--duration-soft) var(--ease-out) both; + } + .vino-brands__item, .vino-section .vino-card, .vino-news__card { + animation: vinoItemIn var(--duration-mid) var(--ease-out) both; + } + .vino-brands__item:nth-child(2), .vino-section .vino-card:nth-child(2), .vino-news__card:nth-child(2) { + animation-delay: .06s; + } + .vino-brands__item:nth-child(3), .vino-section .vino-card:nth-child(3), .vino-news__card:nth-child(3) { + animation-delay: .12s; + } + .vino-brands__item:nth-child(4), .vino-section .vino-card:nth-child(4), .vino-news__card:nth-child(4) { + animation-delay: .18s; + } +} +@keyframes vinoSectionIn { + from { + opacity: 0; + transform: translateY(16px); + } + to { + opacity: 1; + transform: translateY(0); + } +} +@keyframes vinoItemIn { + from { + opacity: 0; + transform: translateY(14px); + } + to { + opacity: 1; + transform: translateY(0); + } +} +@media (prefers-reduced-motion:reduce) { + *, *::before, *::after { + animation-duration: .001ms !important; + animation-iteration-count: 1 !important; + scroll-behavior: auto !important; + transition-duration: .001ms !important; + } +} +.vino-section, .vino-story, .vino-sales { + padding: var(--space-section) var(--gutter); +} +a:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible { + outline: 2px solid var(--color-accent); + outline-offset: 3px; + box-shadow: none; +} +.vino-catalog-layout { + display: grid; + gap: var(--space-8); +} +@media (min-width:981px) { + .vino-catalog-layout { + grid-template-columns: minmax(260px, 300px) minmax(0, 1fr); + align-items: start; + } +} +.vino-hero { + position: relative; + display: grid; + grid-template-columns: repeat(4,1fr); + height: 82vh; + min-height: 520px; + max-height: 800px; + overflow: hidden; + background: #000; + border-bottom: 1px solid var(--color-line); +} +.vino-hero__video { + position: absolute; + inset: 0; + width: 100%; + height: 100%; + object-fit: cover; + object-position: center center; + z-index: 0; + filter: brightness(1.08) contrast(1.04) saturate(1.08); +} +.vino-hero__panel { + position: relative; + z-index: 1; + cursor: pointer; + overflow: hidden; + display: block; + text-decoration: none; + color: var(--color-text); +} +.vino-hero__img { + position: absolute; + inset: 0; + background-image: var(--img); + background-size: cover; + background-position: center; + opacity: 0; + filter: grayscale(.25) brightness(.5) saturate(.85); + transition: opacity var(--duration-mid) var(--ease-base), filter var(--duration-mid) var(--ease-base); +} +@media (hover:hover) { + .vino-hero__panel:hover .vino-hero__img { + opacity: 1; + filter: grayscale(0) brightness(.92) saturate(1.05); + } +} +.vino-hero__veil { + position: absolute; + inset: 0; + z-index: 1; + background: linear-gradient(0deg, color-mix(in srgb, var(--color-bg-deep) 72%, transparent) 0%, color-mix(in srgb, var(--color-bg-deep) 12%, transparent) 32%, transparent 58%); + transition: background var(--duration-mid) var(--ease-base); +} +@media (hover:hover) { + .vino-hero__panel:hover .vino-hero__veil { + background: linear-gradient(0deg, color-mix(in srgb, var(--color-bg-deep) 72%, transparent) 0%, color-mix(in srgb, var(--color-bg-deep) 10%, transparent) 40%, transparent 64%); + } + .vino-hero:hover .vino-hero__panel:not(:hover) .vino-hero__veil { + background: linear-gradient(0deg, color-mix(in srgb, var(--color-bg-deep) 86%, transparent) 0%, color-mix(in srgb, var(--color-bg-deep) 50%, transparent) 45%, color-mix(in srgb, var(--color-bg-deep) 32%, transparent) 100%); + } + .vino-hero:hover .vino-hero__panel:not(:hover) .vino-hero__img { + opacity: 0; + filter: grayscale(.4) brightness(.4) saturate(.7); + } +} +.vino-hero__panel + .vino-hero__panel::before { + content: ""; + position: absolute; + left: 0; + top: 0; + bottom: 0; + width: 1px; + z-index: 3; + background: linear-gradient(180deg, transparent, color-mix(in srgb, var(--color-accent) 45%, transparent), transparent); +} +.vino-hero__content { + position: absolute; + inset: 0; + z-index: 2; + display: flex; + flex-direction: column; + justify-content: flex-end; + padding: 44px 34px; +} +.vino-hero__kicker { + font-family: var(--font-sans); + font-size: var(--text-xs); + font-weight: 600; + letter-spacing: var(--tracking-ui); + text-transform: uppercase; + color: var(--color-accent,var(--color-accent)); + margin: 0 0 10px; +} +.vino-hero__title { + margin: 0; + font-family: var(--font-serif); + font-weight: 500; + line-height: var(--leading-tight); + font-size: var(--fs-h3); + color: var(--color-text); +} +.vino-hero__rule { + height: 1px; + width: 46px; + background: var(--color-accent,var(--color-accent)); + margin: var(--space-4) 0 0; + transform: scaleX(.35); + transform-origin: left; + opacity: .55; + transition: transform .55s cubic-bezier(.2,.72,.2,1), opacity var(--duration-mid) var(--ease-base); +} +.vino-hero__desc { + margin: var(--space-3-5) 0 0; + color: color-mix(in srgb, var(--color-white) 84%, transparent); + font-size: var(--text-15); + line-height: var(--leading-text); + max-height: 0; + opacity: 0; + overflow: hidden; + transition: max-height .55s cubic-bezier(.2,.72,.2,1), opacity var(--duration-mid) var(--ease-base), margin var(--duration-mid) var(--ease-base); +} +.vino-hero__cta { + display: inline-flex; + align-items: center; + gap: var(--space-2); + align-self: flex-start; + margin-top: 0; + color: var(--color-accent,var(--color-accent)); + font-family: var(--font-sans); + font-weight: 600; + font-size: var(--text-xs); + letter-spacing: var(--tracking-sm); + text-transform: uppercase; + max-height: 0; + opacity: 0; + overflow: hidden; + transition: max-height var(--duration-mid) var(--ease-base), opacity var(--duration-mid) var(--ease-base), margin var(--duration-mid) var(--ease-base); +} +@media (hover:hover) { + .vino-hero__panel:hover .vino-hero__rule { + transform: scaleX(1); + opacity: 1; + } + .vino-hero__panel:hover .vino-hero__desc { + max-height: 90px; + opacity: 1; + } + .vino-hero__panel:hover .vino-hero__cta { + max-height: 40px; + opacity: 1; + margin-top: 18px; + } +} +.vino-hero__grain { + position: absolute; + inset: 0; + z-index: 4; + pointer-events: none; + opacity: .06; + mix-blend-mode: overlay; + background-image: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); +} +@media (max-width:760px) { + .vino-hero__img { + opacity: 1; + } + .vino-hero__desc, .vino-hero__cta { + display: none; + } +} +.vino-hero__cta.vino-link { + transition: max-height var(--duration-mid) var(--ease-base), opacity var(--duration-mid) var(--ease-base), margin var(--duration-mid) var(--ease-base), background-size var(--duration-base) var(--ease-base); +} +@media (max-width:760px) { + .vino-hero__panel + .vino-hero__panel::before { + top: 0; + right: 0; + bottom: auto; + left: 0; + width: auto; + height: 1px; + background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--color-accent) 45%, transparent), transparent); + } +} +@media (min-width:761px) and (max-width:980px) { + .vino-hero { + grid-template-columns: 1fr 1fr; + height: auto; + min-height: 0; + } + .vino-hero__panel { + height: auto; + } + .vino-hero__content { + position: relative; + inset: auto; + min-height: 320px; + padding: var(--space-10) var(--space-8); + } + .vino-hero__img { + opacity: 1; + } + .vino-hero__desc, .vino-hero__cta { + max-height: none; + opacity: 1; + overflow: visible; + } + .vino-hero__cta { + margin-top: var(--space-4); + } + .vino-hero__panel:nth-child(4)::before { + display: none; + } +} +@media (max-width:760px) { + .vino-hero { + height: auto; + grid-template-columns: 1fr; + min-height: 0; + display: flex; + overflow-x: auto; + overscroll-behavior-x: contain; + scroll-snap-type: x mandatory; + scrollbar-width: none; + } + .vino-hero::-webkit-scrollbar { + display: none; + } + .vino-hero__panel { + height: auto; + flex: 0 0 100%; + scroll-snap-align: start; + scroll-snap-stop: always; + } + .vino-hero__content { + position: relative; + inset: auto; + padding: var(--space-8) var(--space-6); + justify-content: flex-end; + min-height: 320px; + padding-bottom: var(--space-12); + } + .vino-hero__panel + .vino-hero__panel::before, .vino-hero__grain { + display: none; + } +} +@media (max-width:980px) { + .vino-hero .vino-hero__video, .vino-hero__rule { + display: none; + } + @media (hover:hover) { + .vino-hero:hover .vino-hero__panel:not(:hover) .vino-hero__img { + opacity: 1; + filter: grayscale(.25) brightness(.5) saturate(.85); + } + .vino-hero:hover .vino-hero__panel:not(:hover) .vino-hero__veil { + background: linear-gradient(0deg, color-mix(in srgb, var(--color-bg-deep) 72%, transparent) 0%, color-mix(in srgb, var(--color-bg-deep) 12%, transparent) 32%, transparent 58%); + } + } +} +.vino-age__icon { + width: 34px; + height: 34px; + margin: 0 auto var(--space-5-5); + color: var(--color-accent); +} +@keyframes vinoAgeFade { + from { + opacity: 0; + } + to { + opacity: 1; + } +} +@keyframes vinoAgeRise { + from { + opacity: 0; + transform: translateY(18px); + } + to { + opacity: 1; + transform: none; + } +} +body { + background: var(--color-bg); + color: var(--color-text); + font-family: var(--font-sans); + font-size: var(--text-17); + line-height: var(--leading-ui); + text-rendering: geometricPrecision; + -webkit-font-smoothing: antialiased; + font-synthesis-weight: none; + margin: 0; +} +a { + text-decoration: none; + color: inherit; +} +.vino-slider__viewport::-webkit-scrollbar { + display: none; +} +.vino-bestsellers { + background: var(--color-bg-soft); +} +.vino-arrow { + width: 44px; + height: 44px; + padding: 0; + display: inline-flex; + align-items: center; + justify-content: center; + border: 1px solid var(--color-line); + border-radius: var(--radius-full); + background: transparent; + color: var(--color-text); + cursor: pointer; + transition: border-color var(--duration-fast) var(--ease-base), color var(--duration-fast) var(--ease-base), background var(--duration-fast) var(--ease-base), opacity var(--duration-fast) var(--ease-base); +} +.vino-arrow__icon { + width: 19px; + height: 19px; + display: block; +} +@media (hover:hover) { + .vino-arrow:hover { + border-color: var(--color-accent); + color: var(--color-accent); + } +} +.vino-arrow[hidden] { + display: none; +} +.vino-arrow[disabled] { + opacity: .32; + cursor: default; + pointer-events: none; +} +.vino-new-arrivals { + background: var(--color-bg); +} +.vino-progress { + display: none; +} +@media (max-width:760px) { + .vino-progress { + display: block; + position: relative; + height: 2px; + margin-top: var(--space-5); + overflow: hidden; + background: color-mix(in srgb, var(--color-white) 15%, transparent); + } + .vino-progress__bar { + display: block; + width: var(--vino-progress-width, 30%); + height: 100%; + background: var(--color-accent); + transform: translateX(var(--vino-progress-shift, 0%)); + } +} +.vino-inp { + width: 100%; + background: var(--color-bg-soft,#0a0605); + border: 1px solid var(--color-line-field); + border-radius: var(--radius-sm); + color: var(--color-text); + padding: var(--space-3) var(--space-3-5); + margin: 0 0 var(--space-3); + font: inherit; + font-size: var(--text-15); +} +.vino-inp:focus { + outline: none; + border-color: var(--color-accent); + box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-accent) 15%, transparent); +} +.vino-inp::placeholder { + color: var(--color-text-faint); +} +.vino-inp:-webkit-autofill, +.vino-inp:-webkit-autofill:hover, +.vino-inp:-webkit-autofill:focus { + background-clip: padding-box; + -webkit-text-fill-color: var(--color-text); + caret-color: var(--color-text); + box-shadow: 0 0 0 1000px var(--color-bg-soft, #0a0605) inset; + transition: background-color 600000s 0s; +} +.vino-modal__form .vino-inp--invalid { + border-color: var(--color-danger-soft); + box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-danger) 25%, transparent); +} +.vino-txt { + min-height: 96px; + max-height: 240px; + resize: vertical; +} +.vino-hp { + position: absolute !important; + left: -9999px !important; + width: 1px; + height: 1px; + opacity: 0; +} +.vino-consent { + display: flex; + align-items: flex-start; + gap: 10px; + margin: var(--space-3-5) 0 var(--space-1); + cursor: pointer; + line-height: var(--leading-ui); +} +.vino-consent__checkbox { + flex: 0 0 auto; + margin-top: 2px; + width: 16px; + height: 16px; + border: 1px solid var(--color-accent); + border-radius: 3px; + background: transparent center / 14px 14px no-repeat; + cursor: pointer; + appearance: none; +} +.vino-consent__checkbox:checked { + background-color: var(--color-accent); + background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.75 8.25l2.75 2.75 5.75-6.25' fill='none' stroke='%230e0908' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); +} +.vino-consent__checkbox:focus-visible { + outline: 2px solid var(--color-accent); + outline-offset: 2px; +} +.vino-consent__text { + color: var(--color-text-muted); + font-size: var(--text-15); +} +.vino-consent__link { + color: var(--color-accent); + text-decoration: underline; + text-underline-offset: 2px; +} +@media (hover:hover) { + .vino-consent__link:hover { + color: var(--color-accent-hover); + } +} +.vino-consent--sm .vino-consent__text { + font-size: var(--text-xs); + line-height: var(--leading-ui); +} +.vino-search { + position: fixed; + inset: 0; + z-index: var(--z-search); +} +.vino-search[hidden] { + display: none; +} +.vino-search__backdrop { + position: absolute; + inset: 0; + background: color-mix(in srgb, var(--color-black) 62%, transparent); + opacity: 0; + transition: opacity var(--duration-base) var(--ease-base); +} +.vino-search--open .vino-search__backdrop { + opacity: 1; +} +.vino-search__bar { + position: relative; + background: var(--color-bg); + border-bottom: 1px solid var(--color-line); + box-shadow: 0 24px 60px color-mix(in srgb, var(--color-black) 50%, transparent); + transform: translateY(-100%); + transition: transform var(--duration-base) var(--ease-base); +} +.vino-search--open .vino-search__bar { + transform: none; +} +.vino-search__panel { + max-width: calc(var(--container) + var(--gutter) * 2); + margin: 0 auto; + display: flex; + align-items: center; + gap: 0; + padding: var(--space-5-5) var(--gutter); +} +.vino-search__close { + display: flex; + flex: 0 0 auto; + align-items: center; + justify-content: center; + width: 44px; + height: 44px; + margin: 0 -11px 0 var(--space-6); + padding: 0; + border: 0; + background: none; + color: color-mix(in srgb, var(--color-white) 80%, transparent); + cursor: pointer; + transition: color var(--duration-fast) var(--ease-base); +} +.vino-search__close-icon { + width: 20px; + height: 20px; +} +@media (hover:hover) { + .vino-search__close:hover { + color: var(--color-accent); + } +} +.vino-query__field { + flex: 1; + display: flex; + align-items: center; + gap: var(--space-3); + min-width: 0; + background: var(--color-bg-soft); + border: 1px solid var(--color-line); + border-radius: var(--radius-sm) 0 0 var(--radius-sm); + padding: var(--space-3) var(--space-5); + transition: border-color var(--duration-fast) var(--ease-base); +} +.vino-query__field:focus-within { + border-color: var(--color-accent); +} +.vino-query__icon { + width: 20px; + height: 20px; + flex: 0 0 auto; + color: var(--color-accent); +} +.vino-query__input { + flex: 1; + min-width: 0; + background: none; + border: none; + outline: none; + color: var(--color-text); + font: inherit; + font-size: var(--text-19); +} +.vino-query__input:focus-visible { + outline: none; +} +.vino-query__input::placeholder { + color: var(--color-text-faint); +} +.vino-query__submit { + align-self: stretch; + padding-right: var(--space-8); + padding-left: var(--space-8); + border-radius: 0 var(--radius-sm) var(--radius-sm) 0; + box-shadow: none; +} +@media (hover:hover) { + .vino-query__submit:hover { + transform: none; + border-color: var(--color-white); + background: var(--color-white); + box-shadow: none; + } +} +.vino-query__input::-webkit-search-cancel-button { + -webkit-appearance: none; + appearance: none; + width: 16px; + height: 16px; + margin-left: var(--space-2); + background-color: color-mix(in srgb, var(--color-white) 60%, transparent); + -webkit-mask: url("data:image/svg+xml;utf8,") center / contain no-repeat; + mask: url("data:image/svg+xml;utf8,") center / contain no-repeat; + cursor: pointer; + transition: background-color var(--duration-fast) var(--ease-base); +} +@media (hover:hover) { + .vino-query__input::-webkit-search-cancel-button:hover { + background-color: var(--color-accent); + } +} +.vino-suggest { + --vino-suggest-pic-width: 48px; + --vino-suggest-pic-height: 60px; + position: absolute; + top: 100%; + right: 0; + left: 0; + max-width: calc(var(--container) + var(--gutter) * 2); + margin: 0 auto; + padding: 0 var(--gutter); +} +.vino-suggest[hidden] { + display: none; +} +.vino-suggest__box { + border: 1px solid var(--color-line); + border-top: 0; + border-radius: 0 0 var(--radius-sm) var(--radius-sm); + background: var(--color-bg); + box-shadow: 0 24px 60px color-mix(in srgb, var(--color-black) 50%, transparent); +} +.vino-suggest__list { + overflow-y: auto; + max-height: calc(100vh - 190px); + max-height: calc(100dvh - 190px); + overscroll-behavior: contain; +} +.vino-suggest__item { + display: flex; + align-items: center; + gap: var(--space-4); + padding: var(--space-2) var(--space-4); + color: var(--color-text); + transition: background var(--duration-fast) var(--ease-base); +} +.vino-suggest__item--active, .vino-suggest__item:active, .vino-suggest__all:active { + background: var(--color-bg-soft); +} +@media (hover:hover) { + .vino-suggest__item:hover, .vino-suggest__all:hover { + background: var(--color-bg-soft); + } +} +.vino-suggest__pic { + display: flex; + flex: none; + align-items: center; + justify-content: center; + width: var(--vino-suggest-pic-width); + height: var(--vino-suggest-pic-height); + overflow: hidden; + border-radius: var(--radius-sm); + background: var(--vino-shot); +} +.vino-suggest__img { + width: 100%; + height: 100%; + object-fit: cover; +} +.vino-suggest__kind { + color: var(--color-text-faint); + font-size: var(--fs-caption); + letter-spacing: var(--tracking-ui); + text-transform: uppercase; +} +.vino-suggest__text { + display: flex; + flex: 1; + flex-direction: column; + gap: var(--space-1); + min-width: 0; +} +.vino-suggest__name { + display: -webkit-box; + overflow: hidden; + font-family: var(--font-serif); + font-size: var(--text-19); + line-height: var(--leading-title); + -webkit-box-orient: vertical; + -webkit-line-clamp: 2; +} +.vino-suggest__mark { + background: none; + color: var(--color-accent); + font-weight: inherit; +} +.vino-suggest__meta { + color: var(--color-text-muted); + font-size: var(--text-13); +} +.vino-suggest__price { + flex: none; + color: var(--color-accent); + font-weight: 600; +} +.vino-suggest__all { + display: block; + padding: var(--space-4); + border-top: 1px solid var(--color-line); + color: var(--color-accent); + font-size: var(--text-13); + font-weight: 600; + letter-spacing: var(--tracking-sm); + text-align: center; + text-transform: uppercase; +} +@media (max-width:560px) { + .vino-suggest__item { + gap: var(--space-3); + padding: var(--space-2) var(--space-3); + } + .vino-suggest__name { + font-size: var(--text-17); + } +} +@media (max-width:560px) { + .vino-search__panel { + padding-top: var(--space-4); + padding-bottom: var(--space-4); + } + .vino-query--compact .vino-query__field { + border-radius: var(--radius-sm); + } + .vino-query--compact .vino-query__submit { + display: none; + } + .vino-search__close { + margin-left: var(--space-2); + } +} +.vino-sr-only { + position: absolute; + width: 1px; + height: 1px; + padding: 0; + margin: -1px; + overflow: hidden; + clip: rect(0,0,0,0); + white-space: nowrap; + border: 0; +} +.vino-showcase-banner__media::after { + content: ""; + position: absolute; + inset: 0; + background: linear-gradient(270deg, color-mix(in srgb, var(--color-bg) 55%, transparent), transparent 45%); +} +.vino-empty-state { + display: grid; + grid-template-columns: 88px minmax(0,1fr); + gap: var(--space-6); + align-items: center; + padding: clamp(26px,5vw,46px); + border: 1px solid color-mix(in srgb, var(--color-accent) 26%, transparent); + background: radial-gradient(420px 220px at 94% 0%,color-mix(in srgb, var(--color-accent) 16%, transparent),transparent 64%),var(--color-surface); +} +.vino-empty-state__svg { + width: 32px; + height: 32px; +} +.vino-empty-state--plain { + grid-template-columns: minmax(0, 1fr); +} +.vino-empty-state--inline { + margin-top: 18px; +} +.vino-empty-state__icon { + width: 72px; + height: 72px; + display: flex; + align-items: center; + justify-content: center; + border-radius: 50%; + border: 1px solid color-mix(in srgb, var(--color-accent) 50%, transparent); + color: var(--color-accent); + font-family: var(--font-serif); + font-size: 34px; +} +.vino-empty-state__actions { + display: flex; + gap: var(--space-3); + flex-wrap: wrap; + margin-top: var(--space-5); +} +@media (max-width:760px) { + .vino-empty-state { + grid-template-columns: minmax(0, 1fr); + gap: var(--space-4); + padding: var(--space-6); + } + .vino-empty-state__icon { + width: 58px; + height: 58px; + font-size: 28px; + } +} +.vino-empty-page { + padding: var(--space-head) var(--gutter) var(--space-section); +} +.vino-showcase { + padding: var(--space-head) var(--gutter) var(--space-section); +} +.vino-showcase__list { + margin: 0; + padding: 0; + border-top: 1px solid var(--color-line); + list-style: none; +} +.vino-showcase__item { + display: flex; + align-items: center; + justify-content: space-between; + gap: var(--space-6); + padding: var(--space-5) 0; + border-bottom: 1px solid var(--color-line); +} +.vino-showcase__body { + display: flex; + flex-direction: column; + gap: var(--space-2); + min-width: 0; +} +.vino-showcase__name { + font-family: var(--font-serif); + font-size: var(--fs-h4); +} +.vino-showcase__checks { + display: flex; + flex-wrap: wrap; + gap: var(--space-2) var(--space-5); +} +.vino-showcase__check { + position: relative; + color: var(--color-accent); + font-size: var(--text-15); + text-decoration: none; + transition: color var(--duration-fast) var(--ease-base); +} +@media (pointer:coarse) { + .vino-showcase__checks { + row-gap: var(--space-6); + } + .vino-showcase__check::before { + content: ""; + position: absolute; + inset: -12px -8px; + } +} +@media (hover:hover) { + .vino-showcase__check:hover { + color: var(--color-text); + } +} +.vino-showcase__open { + flex: none; +} +.vino-showcase-shots { + padding: var(--space-section) var(--gutter); + background: linear-gradient(var(--color-bg), var(--color-bg-soft) var(--space-section)); +} +.vino-showcase-shots__list { + display: grid; + grid-template-columns: repeat(2, minmax(0, 1fr)); + gap: var(--space-12) var(--space-8); + margin: 0; + padding: 0; + list-style: none; +} +.vino-showcase-shots__title { + margin: 0 0 var(--space-4); + font-family: var(--font-serif); + font-size: var(--fs-h4); + font-weight: 400; +} +.vino-showcase-shots__link { + display: block; + border: 1px solid var(--color-line); + transition: border-color var(--duration-fast) var(--ease-base); +} +.vino-showcase-shots__img { + display: block; + width: 100%; + height: auto; +} +@media (hover:hover) { + .vino-showcase-shots__link:hover { + border-color: var(--color-accent); + } +} +@media (max-width:760px) { + .vino-showcase-shots__list { + grid-template-columns: minmax(0, 1fr); + gap: var(--space-8); + } +} +.vino-404 { + padding: var(--space-12) var(--gutter) var(--space-section); + text-align: center; +} +.vino-404__code { + margin: 0; + color: var(--color-accent); + font-family: var(--font-serif); + font-size: clamp(6rem, 16vw, 12rem); + line-height: .9; +} +.vino-404__title { + margin: var(--space-6) 0 0; + font-family: var(--font-serif); + font-size: var(--fs-h2); + font-weight: 400; + line-height: var(--leading-tight); +} +.vino-404__text { + max-width: var(--measure); + margin: var(--space-4) auto var(--space-6); + color: var(--color-text-muted); + line-height: var(--leading-long); +} +.vino-404__heading { + margin: 0 0 var(--space-head); +} +.vino-empty-state h1, .vino-empty-state h2 { + margin: 0; + color: var(--color-text); + font-family: var(--font-serif); + font-size: var(--fs-h3); +} +.vino-empty-state p { + max-width: 620px; + margin: 10px 0 0; + color: var(--color-text-muted); + line-height: var(--leading-text); +} +button.vino-mega__card { + width: 100%; + padding: 0; + background: none; + color: inherit; + font: inherit; + text-align: left; + cursor: pointer; +} +@keyframes vino-mega-in { + from { + opacity: 0; + transform: translateY(-8px); + } + to { + opacity: 1; + transform: none; + } +} +.vino-link { + padding-bottom: var(--space-1); + background: linear-gradient(var(--color-accent), var(--color-accent)) left bottom / 0 1px no-repeat, linear-gradient(color-mix(in srgb, var(--color-accent) 28%, transparent), color-mix(in srgb, var(--color-accent) 28%, transparent)) left bottom / 100% 1px no-repeat; + text-decoration: none; + transition: background-size var(--duration-base) var(--ease-base), color var(--duration-fast) var(--ease-base); +} +@media (hover:hover) { + .vino-link:hover, a:hover .vino-link { + background-size: 100% 1px, 100% 1px; + } +} +@media (pointer:coarse) { + .vino-lang__current, .vino-footer__tg, .vino-card__tool { + position: relative; + } +} +.vino-page-lead { + max-width: 680px; + margin: var(--space-5) 0 0; + color: var(--color-text-muted); + line-height: var(--leading-text); +} +.vino-card__tool--compare.vino-card__tool--active .vino-card__tool-icon, .vino-pdp__iconbtn--compare.vino-pdp__iconbtn--active .vino-pdp__icon { + fill: none; +} +.vino-toast { + position: fixed; + left: 50%; + bottom: var(--space-8); + z-index: var(--z-toast); + padding: var(--space-4) var(--space-6); + border: 1px solid color-mix(in srgb, var(--color-accent) 35%, transparent); + border-radius: var(--radius-sm); + background: var(--color-bg-soft); + color: var(--color-text); + font-family: var(--font-sans); + font-size: var(--text-15); + box-shadow: 0 18px 50px color-mix(in srgb, var(--color-black) 50%, transparent); + opacity: 0; + pointer-events: none; + transform: translate(-50%, var(--space-5)); + transition: opacity var(--duration-base) var(--ease-base), transform var(--duration-base) var(--ease-base); +} +.vino-toast--on { + opacity: 1; + pointer-events: auto; + transform: translate(-50%, 0); +} +.vino-toast__link { + margin-left: var(--space-3); + color: var(--color-accent); +} +.vino-reveal .vino-reveal__item { + animation: none; +} +.vino-reveal .vino-reveal__item:not(.vino-reveal__item--visible) > *, .vino-reveal .vino-reveal__item--deep:not(.vino-reveal__item--visible) .vino-brands__item, .vino-reveal .vino-reveal__item--deep:not(.vino-reveal__item--visible) .vino-card, .vino-reveal .vino-reveal__item--deep:not(.vino-reveal__item--visible) .vino-news__card { + animation: none; + opacity: 0; +} +.vino-reveal .vino-reveal__item--visible > * { + animation: vinoSectionIn var(--duration-soft) var(--ease-out) both; +} +@media (hover:hover) { + .vino-modal__close:hover { + color: var(--color-accent); + } +} +html[data-auth="1"] .vino-review-guest, +html[data-auth="0"] .vino-review-user { + display: none; +} +html:has(.vino-modal[open]) { + overflow: hidden; +} +.vino-breadcrumbs { + color: color-mix(in srgb, var(--color-white) 44%, transparent); + font-size: var(--text-13); + letter-spacing: var(--tracking-sm); + text-transform: uppercase; +} +.vino-breadcrumbs__list { + display: flex; + flex-wrap: wrap; + align-items: center; + margin: 0; + padding: 0; + list-style: none; + gap: var(--space-3); +} +.vino-breadcrumbs__item { + display: flex; + align-items: center; + gap: var(--space-3); +} +.vino-breadcrumbs__link { + margin-right: calc(var(--tracking-sm) * -1); + color: color-mix(in srgb, var(--color-white) 54%, transparent); + transition: color var(--duration-fast) var(--ease-base); +} +@media (hover:hover) { + .vino-breadcrumbs__link:hover { + color: var(--color-accent); + } +} +.vino-breadcrumbs__current { + margin-right: calc(var(--tracking-sm) * -1); + color: var(--color-accent); +} +.vino-breadcrumbs__sep { + flex: none; + width: 5px; + height: 5px; + border-top: 1px solid color-mix(in srgb, var(--color-white) 40%, transparent); + border-right: 1px solid color-mix(in srgb, var(--color-white) 40%, transparent); + transform: translateX(-2px) rotate(45deg); +} +@media (max-width:980px) { + :root { + --gutter: var(--space-8); + --space-section: var(--space-16); + --space-head: var(--space-8); + --space-grid-wide: var(--space-8); + } +} +a:active:not(.vino-card__image, .vino-hero__panel, .vino-cart__pic, .vino-news__link, .vino-offers__link, .vino-search-page__link, .vino-suggest__item, .vino-suggest__all, .vino-showcase-shots__link, .vino-brands__item), button:active, [role="button"]:active { + filter: brightness(.85); +} +.vino-dots { + display: none; +} +@media (max-width:760px) { + .vino-dots { + display: flex; + justify-content: center; + align-items: center; + gap: var(--space-1); + } + .vino-dots--overlay { + position: relative; + z-index: 5; + height: var(--space-12); + margin-top: calc(var(--space-12) * -1); + padding-bottom: var(--space-2); + pointer-events: none; + } + .vino-dots--overlay .vino-dots__dot { + pointer-events: auto; + } + .vino-dots__dot { + display: flex; + align-items: center; + justify-content: center; + width: 44px; + height: 44px; + padding: 0; + border: 0; + background: transparent; + cursor: pointer; + margin: -10px; + } + .vino-dots__dot::before { + content: ""; + width: 8px; + height: 8px; + border-radius: 4px; + background: color-mix(in srgb, var(--color-white) 30%, transparent); + transition: width var(--duration-fast) var(--ease-base), background var(--duration-fast) var(--ease-base); + } + .vino-dots__dot--active::before { + width: 20px; + background: var(--color-accent); + } + .vino-dots--lines { + gap: var(--space-2); + } + .vino-dots--lines .vino-dots__dot { + width: 44px; + margin: -10px -8px; + } + .vino-dots--lines .vino-dots__dot::before, .vino-dots--lines .vino-dots__dot--active::before { + width: 28px; + height: 2px; + border-radius: 0; + } +} +@media (max-width:760px) { + .vino-tabbar { + position: fixed; + right: 0; + bottom: 0; + left: 0; + z-index: var(--z-tabbar); + display: grid; + grid-template-columns: repeat(4, minmax(0, 1fr)); + height: calc(var(--size-tabbar) + env(safe-area-inset-bottom)); + padding-bottom: env(safe-area-inset-bottom); + border-top: 1px solid var(--color-line); + background: color-mix(in srgb, var(--color-bg) 94%, transparent); + -webkit-backdrop-filter: blur(12px); + backdrop-filter: blur(12px); + } + .vino-tabbar__item { + position: relative; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + gap: var(--space-1); + color: var(--color-text-muted); + font-size: var(--fs-caption); + line-height: 1; + transition: color var(--duration-fast) var(--ease-base); + } + .vino-tabbar__item--active { + color: var(--color-accent); + } + .vino-tabbar__count { + top: var(--space-1); + right: auto; + left: calc(50% + var(--space-1)); + } +} +@media (max-width:760px) { + :root { + --space-head: var(--space-6); + --fs-caption: .75rem; + --size-tabbar: 60px; + --gutter: var(--space-6); + --space-grid-base: var(--space-4); + --space-grid-tight: var(--space-3); + --space-grid-wide: var(--space-6); + --space-card: var(--space-4); + } + .vino-brands__logo { + --vino-brands-logo-height: var(--space-16); + } + .vino-story__image { + --vino-story-image-height: auto; + --vino-story-image-ratio: 3 / 2; + } + .vino-brands__item { + padding: var(--space-6) var(--space-3); + } +} +@media (max-width:560px) { + :root { + --gutter: var(--space-4); + --space-section: var(--space-12); + } +} +@media (max-width:760px) { + body { + padding-bottom: calc(var(--size-tabbar) + env(safe-area-inset-bottom)); + } + .vino-cookie, .vino-toast { + bottom: calc(var(--size-tabbar) + env(safe-area-inset-bottom) + var(--space-2)); + } +} +@media (max-width:760px) { + .vino-pdp__rating, .vino-breadcrumbs__link, .vino-card .vino-card__tool, .vino-card__link, .vino-footer__link, .vino-consent__link, .vino-lang__current, .vino-demo-bar__link, .vino-section__link { + position: relative; + } + .vino-actions { + gap: var(--space-5-5); + } + .vino-pdp__rating::before { + content: ""; + position: absolute; + inset: -11px; + } + .vino-breadcrumbs__link::before, .vino-card__link::before, .vino-footer__link::before, .vino-consent__link::before, .vino-lang__current::before, .vino-demo-bar__link::before, .vino-section__link::before { + content: ""; + position: absolute; + inset: -13px -4px; + } + .vino-card .vino-card__tool { + width: 40px; + height: 40px; + margin: 0; + } + .vino-card .vino-card__tool::before { + content: ""; + position: absolute; + inset: -2px; + } + .vino-actions .vino-lang__option { + min-height: 44px; + } +} +.vino-main:focus { + outline: 0; +} +.vino-subscribe .vino-inp--invalid { + border-color: var(--color-danger-soft); + box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-danger) 25%, transparent); +} diff --git a/login/index.php b/login/index.php new file mode 100644 index 0000000..4693fe8 --- /dev/null +++ b/login/index.php @@ -0,0 +1,4 @@ +IncludeComponent("jinove:auth.login", ".default", array()); +require($_SERVER["DOCUMENT_ROOT"] . "/bitrix/footer.php"); diff --git a/offers/index.php b/offers/index.php new file mode 100644 index 0000000..956a6ec --- /dev/null +++ b/offers/index.php @@ -0,0 +1,33 @@ +addCss(SITE_TEMPLATE_PATH . "/catalog-styles.css"); +$APPLICATION->IncludeComponent("bitrix:news", "vinoteca-offers", array( + "IBLOCK_TYPE" => "content", + "IBLOCK_ID" => \Jinove\Vinoteca\Offers::iblockId(), + "CHECK_DATES" => "Y", + "SEF_MODE" => "Y", + "SEF_FOLDER" => \Jinove\Vinoteca\Offers::folder(), + "SEF_URL_TEMPLATES" => array( + "news" => "", + "section" => "", + "detail" => "#ELEMENT_CODE#/", + ), + "DETAIL_FIELD_CODE" => array("PREVIEW_PICTURE", "PREVIEW_TEXT", "DETAIL_TEXT", "DETAIL_PICTURE", "ACTIVE_FROM", "DATE_ACTIVE_TO"), + "DETAIL_PROPERTY_CODE" => array("DISCOUNT_ID", "NAME_EN", "NAME_PL", "PREVIEW_TEXT_EN", "PREVIEW_TEXT_PL", "DETAIL_TEXT_EN", "DETAIL_TEXT_PL"), + "USE_SEARCH" => "N", + "USE_RSS" => "N", + "USE_RATING" => "N", + "USE_CATEGORIES" => "N", + "USE_FILTER" => "N", + "USE_REVIEW" => "N", + "USE_PERMISSIONS" => "N", + "AJAX_MODE" => "N", + "CACHE_TYPE" => "A", + "CACHE_TIME" => "3600", + "CACHE_GROUPS" => "N", + "SET_STATUS_404" => "Y", + "SHOW_404" => "Y", + "FILE_404" => "", + "MESSAGE_404" => "", +), false); +require($_SERVER["DOCUMENT_ROOT"] . "/bitrix/footer.php"); diff --git a/personal/cart/index.php b/personal/cart/index.php new file mode 100644 index 0000000..9fdda20 --- /dev/null +++ b/personal/cart/index.php @@ -0,0 +1,4 @@ +IncludeComponent("jinove:cart", ".default", array()); +require($_SERVER["DOCUMENT_ROOT"] . "/bitrix/footer.php"); diff --git a/personal/favorites/index.php b/personal/favorites/index.php new file mode 100644 index 0000000..04700ae --- /dev/null +++ b/personal/favorites/index.php @@ -0,0 +1,32 @@ + +
+
+ GetTitle()))); ?> +

ShowTitle(false); ?>

+
+
+ +
+
+
+
+

+

+
+
+
+
+
+ +
"> +

+
+ IncludeComponent("bitrix:catalog.section", "vinoteca", \Jinove\Vinoteca\Catalog\Favorites::params($favoriteIds), false); ?> +
+
+ + diff --git a/personal/index.php b/personal/index.php new file mode 100644 index 0000000..04c4020 --- /dev/null +++ b/personal/index.php @@ -0,0 +1,4 @@ +IncludeComponent("jinove:personal.profile", ".default", array()); +require($_SERVER["DOCUMENT_ROOT"] . "/bitrix/footer.php"); diff --git a/personal/order/done/index.php b/personal/order/done/index.php new file mode 100644 index 0000000..1b96a96 --- /dev/null +++ b/personal/order/done/index.php @@ -0,0 +1,4 @@ +IncludeComponent("jinove:order.done", ".default", array()); +require($_SERVER["DOCUMENT_ROOT"] . "/bitrix/footer.php"); diff --git a/personal/order/index.php b/personal/order/index.php new file mode 100644 index 0000000..4890add --- /dev/null +++ b/personal/order/index.php @@ -0,0 +1,4 @@ +IncludeComponent("jinove:order", ".default", array()); +require($_SERVER["DOCUMENT_ROOT"] . "/bitrix/footer.php"); diff --git a/personal/orders/index.php b/personal/orders/index.php new file mode 100644 index 0000000..b55c3d2 --- /dev/null +++ b/personal/orders/index.php @@ -0,0 +1,4 @@ +IncludeComponent("jinove:personal.orders", ".default", array()); +require($_SERVER["DOCUMENT_ROOT"] . "/bitrix/footer.php"); diff --git a/personal/reviews/index.php b/personal/reviews/index.php new file mode 100644 index 0000000..7a55739 --- /dev/null +++ b/personal/reviews/index.php @@ -0,0 +1,4 @@ +IncludeComponent("jinove:personal.reviews", ".default", array()); +require($_SERVER["DOCUMENT_ROOT"] . "/bitrix/footer.php"); diff --git a/pl/.bottom.menu.php b/pl/.bottom.menu.php new file mode 100644 index 0000000..3a3bc03 --- /dev/null +++ b/pl/.bottom.menu.php @@ -0,0 +1,9 @@ + 'Vinoteca: autorska winoteka. Wina z najlepszych regionów świata, uczciwe ceny i pomoc sommeliera w wyborze.', + 'robots' => 'index, follow', +]; diff --git a/pl/.top.menu.php b/pl/.top.menu.php new file mode 100644 index 0000000..c31fc44 --- /dev/null +++ b/pl/.top.menu.php @@ -0,0 +1,8 @@ + +

Winoteka, a nie zwykły sklep

+

Nasza kolekcja obejmuje Stary i Nowy Świat: klasykę Włoch i Francji, słoneczne wina Hiszpanii i Portugalii, Kalifornię, Argentynę, Nową Zelandię i węgierski Tokaj. Nasz sommelier podpowie, co podać do steku lub ryby, jakie wino wybrać na prezent, a które warto odłożyć na kilka lat. Pytanie można zadać bezpośrednio na stronie.

diff --git a/pl/index.php b/pl/index.php new file mode 100644 index 0000000..3800f42 --- /dev/null +++ b/pl/index.php @@ -0,0 +1,2 @@ +addCss(SITE_TEMPLATE_PATH . "/legal-styles.css"); +$email = \Jinove\Vinoteca\Config::contacts()["email"]; +$mail = '' . htmlspecialcharsbx($email) . ''; +$host = htmlspecialcharsbx((string)parse_url(\Jinove\Vinoteca\Config::host(), PHP_URL_HOST)); +$version = \Jinove\Vinoteca\Consent::POLICY_VERSION; +$date = \Jinove\Vinoteca\DateFormat::long(\Jinove\Vinoteca\Consent::timestamp($version), LANGUAGE_ID); +$APPLICATION->SetTitle(Loc::getMessage("VINO_PRIVACY_H1")); +$APPLICATION->SetPageProperty("title", Loc::getMessage("VINO_PRIVACY_TITLE")); +$APPLICATION->SetPageProperty("description", Loc::getMessage("VINO_PRIVACY_DESCRIPTION")); +$APPLICATION->SetPageProperty("og_image", VINO_HOST . SITE_TEMPLATE_PATH . "/assets/media/og-home.jpg"); +?> +
+
+ +

+

$date)) ?>

+
+
+ + + +IncludeComponent("jinove:auth.register", ".default", array()); +require($_SERVER["DOCUMENT_ROOT"] . "/bitrix/footer.php"); diff --git a/reset-password/index.php b/reset-password/index.php new file mode 100644 index 0000000..23b020f --- /dev/null +++ b/reset-password/index.php @@ -0,0 +1,4 @@ +IncludeComponent("jinove:auth.reset", ".default", array()); +require($_SERVER["DOCUMENT_ROOT"] . "/bitrix/footer.php"); diff --git a/ru/.bottom.menu.php b/ru/.bottom.menu.php new file mode 100644 index 0000000..5253182 --- /dev/null +++ b/ru/.bottom.menu.php @@ -0,0 +1,9 @@ + 'Vinoteca: авторская винотека. Вина из лучших регионов мира, честные цены и помощь сомелье в выборе.', + 'robots' => 'index, follow', +]; diff --git a/ru/.top.menu.php b/ru/.top.menu.php new file mode 100644 index 0000000..bda87f8 --- /dev/null +++ b/ru/.top.menu.php @@ -0,0 +1,8 @@ + +

Винотека, а не просто магазин

+

Мы собираем коллекцию от Старого Света до Нового: классика Италии и Франции, солнечные вина Испании и Португалии, Калифорния, Аргентина, Новая Зеландия и венгерский Токай. Наш сомелье подскажет, что подать к стейку или рыбе, какое вино выбрать в подарок и какое стоит отложить на несколько лет. Вопрос можно задать прямо на сайте.

diff --git a/ru/index.php b/ru/index.php new file mode 100644 index 0000000..3800f42 --- /dev/null +++ b/ru/index.php @@ -0,0 +1,2 @@ +IncludeComponent("bitrix:search.page", ".default", \Jinove\Vinoteca\Search::pageParams(), false); +require($_SERVER["DOCUMENT_ROOT"] . "/bitrix/footer.php"); diff --git a/urlrewrite.php b/urlrewrite.php new file mode 100644 index 0000000..e0dda34 --- /dev/null +++ b/urlrewrite.php @@ -0,0 +1,123 @@ + + array ( + 'CONDITION' => '#^\\/?\\/mobileapp/jn\\/(.*)\\/.*#', + 'RULE' => 'componentName=$1', + 'ID' => NULL, + 'PATH' => '/bitrix/services/mobileapp/jn.php', + 'SORT' => 100, + ), + 2 => + array ( + 'CONDITION' => '#^/bitrix/services/ymarket/#', + 'RULE' => '', + 'ID' => '', + 'PATH' => '/bitrix/services/ymarket/index.php', + 'SORT' => 100, + ), + 9 => + array ( + 'CONDITION' => '#^/ru/catalog/#', + 'RULE' => '', + 'ID' => 'bitrix:catalog', + 'PATH' => '/ru/catalog/index.php', + 'SORT' => 100, + ), + 13 => + array ( + 'CONDITION' => '#^/pl/catalog/#', + 'RULE' => '', + 'ID' => 'bitrix:catalog', + 'PATH' => '/pl/catalog/index.php', + 'SORT' => 100, + ), + 11 => + array ( + 'CONDITION' => '#^/ru/brands/#', + 'RULE' => '', + 'ID' => '', + 'PATH' => '/ru/brands/index.php', + 'SORT' => 100, + ), + 15 => + array ( + 'CONDITION' => '#^/pl/brands/#', + 'RULE' => '', + 'ID' => '', + 'PATH' => '/pl/brands/index.php', + 'SORT' => 100, + ), + 4 => + array ( + 'CONDITION' => '#^/catalog/#', + 'RULE' => '', + 'ID' => 'bitrix:catalog', + 'PATH' => '/catalog/index.php', + 'SORT' => 100, + ), + 8 => + array ( + 'CONDITION' => '#^/brands/#', + 'RULE' => NULL, + 'ID' => '', + 'PATH' => '/brands/index.php', + 'SORT' => 100, + ), + 1 => + array ( + 'CONDITION' => '#^/rest/#', + 'RULE' => '', + 'ID' => NULL, + 'PATH' => '/bitrix/services/rest/index.php', + 'SORT' => 100, + ), + 40 => + array ( + 'CONDITION' => '#^/ru/offers/#', + 'RULE' => '', + 'ID' => '', + 'PATH' => '/ru/offers/index.php', + 'SORT' => 100, + ), + 41 => + array ( + 'CONDITION' => '#^/pl/offers/#', + 'RULE' => '', + 'ID' => '', + 'PATH' => '/pl/offers/index.php', + 'SORT' => 100, + ), + 42 => + array ( + 'CONDITION' => '#^/offers/#', + 'RULE' => '', + 'ID' => '', + 'PATH' => '/offers/index.php', + 'SORT' => 100, + ), + 30 => + array ( + 'CONDITION' => '#^/ru/articles/#', + 'RULE' => '', + 'ID' => '', + 'PATH' => '/ru/articles/index.php', + 'SORT' => 100, + ), + 32 => + array ( + 'CONDITION' => '#^/pl/articles/#', + 'RULE' => '', + 'ID' => '', + 'PATH' => '/pl/articles/index.php', + 'SORT' => 100, + ), + 31 => + array ( + 'CONDITION' => '#^/articles/#', + 'RULE' => '', + 'ID' => '', + 'PATH' => '/articles/index.php', + 'SORT' => 100, + ), +);