Vinoteca: модуль, шаблон и компоненты интернет-магазина вина на 1С-Битрикс
This commit is contained in:
commit
f6ba0d2174
470 files changed
+26454
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;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user