From 6bece265ad87ad89810f7708dfc49887fbc7aeea Mon Sep 17 00:00:00 2001 From: hipot Date: Thu, 11 Jan 2024 18:00:27 +0200 Subject: [PATCH] Add directory checking method to ContextUtils class A new method, 'siteIdDirs', has been added to the ContextUtils class. This method checks whether the current directory is in the list of directories for the current site, returning a boolean result. This change has been replicated across two different project directories, ensuring consistent functionality throughout the application. --- lib/classes/Hipot/Utils/ContextUtils.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/classes/Hipot/Utils/ContextUtils.php b/lib/classes/Hipot/Utils/ContextUtils.php index a62d38d..508a6cd 100644 --- a/lib/classes/Hipot/Utils/ContextUtils.php +++ b/lib/classes/Hipot/Utils/ContextUtils.php @@ -279,4 +279,20 @@ public static function setStatusNotFound(bool $showPage = false): void } } } + + /** + * Проверяет, находится ли текущая директория в списке директорий для текущего сайта. + * @param array $dirs Массив директорий для проверки + * @return bool Возвращает true, если текущая директория находится в списке директорий, иначе возвращает false. + * @see \CSite::InDir() + */ + public static function siteIdDirs(array $dirs): bool + { + foreach ($dirs as $dir) { + if (\CSite::InDir($dir)) { + return true; + } + } + return false; + } } \ No newline at end of file