108 lines
3.9 KiB
PHP
108 lines
3.9 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Jinove\Vinoteca;
|
|
|
|
use Bitrix\Main\Localization\Loc;
|
|
use Bitrix\Main\Page\Asset;
|
|
|
|
Loc::loadMessages(__FILE__);
|
|
|
|
final class Showcase
|
|
{
|
|
private const PAGES = [
|
|
["HOME", "", true],
|
|
["SECTION", "catalog/red/", true],
|
|
["WINE", "catalog/red/altovesca-signature-sangiovese-2022/", true],
|
|
["BRANDS", "brands/", true],
|
|
["BRAND", "brands/bodega-cerrovento/", true],
|
|
["OFFERS", "offers/", true],
|
|
["OFFER", "offers/promo-vino10/", true],
|
|
["ARTICLES", "articles/", true],
|
|
["ARTICLE", "articles/wine-glass-guide/", true],
|
|
["ABOUT", "about/", true],
|
|
["SEARCH", "search/?q=merlot", false],
|
|
["COMPARE", "compare/", false],
|
|
["FAVORITES", "personal/favorites/", false],
|
|
["CART", "personal/cart/", false],
|
|
["LOGIN", "login/", false],
|
|
["PRIVACY", "privacy/", true],
|
|
["NOT_FOUND", "page-not-found/", false],
|
|
];
|
|
|
|
private const SHOTS = [
|
|
["01", "WINES", 383],
|
|
["02", "WINE_PROPS", 383],
|
|
["03", "WINE_TEXT", 383],
|
|
["04", "WINE_SEO", 383],
|
|
["05", "BRAND", 383],
|
|
["06", "OFFER", 383],
|
|
["07", "DISCOUNT", 383],
|
|
["08", "ORDERS", 383],
|
|
["09", "ORDER", 383],
|
|
["10", "ORDER_ITEMS", 383],
|
|
["11", "ARTICLE", 383],
|
|
["12", "BANNER", 383],
|
|
["13", "SITES", 172],
|
|
];
|
|
|
|
public static function preparePage(): void
|
|
{
|
|
global $APPLICATION;
|
|
$APPLICATION->SetTitle((string)Loc::getMessage("VINO_SHOWCASE_H1"));
|
|
$APPLICATION->SetPageProperty("title", (string)Loc::getMessage("VINO_SHOWCASE_TITLE"));
|
|
$APPLICATION->SetPageProperty("description", (string)Loc::getMessage("VINO_SHOWCASE_DESCRIPTION"));
|
|
$APPLICATION->SetPageProperty("vino_alternates", "N");
|
|
$asset = Asset::getInstance();
|
|
$asset->addCss(SITE_TEMPLATE_PATH . "/assets/vendor/photoswipe/photoswipe.css?v=5.4.4");
|
|
$asset->addJs(SITE_TEMPLATE_PATH . "/assets/vendor/photoswipe/photoswipe.umd.min.js?v=5.4.4");
|
|
$asset->addJs(SITE_TEMPLATE_PATH . "/assets/js/vino-shots.js?v=3");
|
|
}
|
|
|
|
public static function pages(): array
|
|
{
|
|
$pages = [];
|
|
foreach (self::PAGES as [$code, $path, $checks]) {
|
|
$url = Config::host() . SITE_DIR . $path;
|
|
$pages[] = [
|
|
"NAME" => (string)Loc::getMessage("VINO_SHOWCASE_PAGE_" . $code),
|
|
"URL" => SITE_DIR . $path,
|
|
"SCHEMA" => $checks ? "https://validator.schema.org/#url=" . rawurlencode($url) : "",
|
|
"SPEED" => $checks ? "https://pagespeed.web.dev/analysis?url=" . rawurlencode($url) : "",
|
|
];
|
|
}
|
|
|
|
return $pages;
|
|
}
|
|
|
|
public static function viewer(): array
|
|
{
|
|
return [
|
|
"closeTitle" => (string)Loc::getMessage("VINO_SHOWCASE_VIEWER_CLOSE"),
|
|
"zoomTitle" => (string)Loc::getMessage("VINO_SHOWCASE_VIEWER_ZOOM"),
|
|
"arrowPrevTitle" => (string)Loc::getMessage("VINO_SHOWCASE_VIEWER_PREV"),
|
|
"arrowNextTitle" => (string)Loc::getMessage("VINO_SHOWCASE_VIEWER_NEXT"),
|
|
"errorMsg" => (string)Loc::getMessage("VINO_SHOWCASE_VIEWER_ERROR"),
|
|
];
|
|
}
|
|
|
|
public static function shots(): array
|
|
{
|
|
$dir = SITE_TEMPLATE_PATH . "/assets/media/admin/admin-" . (LANGUAGE_ID === "ru" ? "" : "en-");
|
|
$shots = [];
|
|
foreach (self::SHOTS as [$number, $code, $height]) {
|
|
$shots[] = [
|
|
"NAME" => (string)Loc::getMessage("VINO_SHOWCASE_SHOT_" . $code),
|
|
"ALT" => (string)Loc::getMessage("VINO_SHOWCASE_SHOT_ALT", ["#NAME#" => (string)Loc::getMessage("VINO_SHOWCASE_SHOT_" . $code)]),
|
|
"SRC" => $dir . $number . "-800.webp?v=4",
|
|
"FULL" => $dir . $number . "-1920.webp?v=4",
|
|
"HEIGHT" => $height,
|
|
"FULL_HEIGHT" => (int)round($height * 1920 / 800),
|
|
];
|
|
}
|
|
|
|
return $shots;
|
|
}
|
|
}
|