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

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

No files matched your search

@@ -0,0 +1,34 @@
<?php
declare(strict_types=1);
namespace Jinove\Vinoteca;
use Bitrix\Main\Application;
final class Navigation
{
public static function isActive(string $path, bool $exact = false): bool
{
if (defined("ERROR_404")) {
return false;
}
$current = self::current();
return $exact ? $current === $path : str_starts_with($current, $path);
}
private static function current(): string
{
$uri = (string)Application::getInstance()->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;
}
}