- Модуль: translate
- Путь к файлу: ~/bitrix/modules/translate/lib/ui/panel.php
- Класс: BitrixTranslateUiPanel
- Вызов: Panel::showLoadedFiles
static function showLoadedFiles()
{
/**
* @global CUser $USER
* @global CMain $APPLICATION
*/
global $APPLICATION, $USER;
if (!$USER instanceof CUser || !$USER->isAuthorized())
{
return;
}
if (!TranslatePermission::canView($USER))
{
return;
}
if (($_SESSION["SHOW_LANG_FILES"] ?? '') !== 'Y')
{
return;
}
$request = MainContext::getCurrent()->getRequest();
// ajax
if ($request->isAjaxRequest() || $request->get('AJAX_CALL') !== null)
{
return;
}
$searchString = $request->get('srchlngfil');
CJSCore::init('admin_interface');
if (!defined("ADMIN_SECTION"))
{
$APPLICATION->setAdditionalCSS('/bitrix/themes/.default/pubstyles.css');
}
$popup = new CJSPopupOnPage();
$popup->jsPopup = self::DIALOG_ID;
?>
$popup->startDescription('bx-translate-search');
$popup->startContent(array('buffer' => true));
if(!defined('BX_PUBLIC_MODE'))
{
?>
}
?>
$includedLangFiles = Loc::getIncludedFiles();
if (!empty($includedLangFiles))
{
$includedLangFiles = array_values($includedLangFiles);
}
$lowPriorityLangFiles = array();
$highPriorityLangFiles = array();
foreach ($includedLangFiles as $langFile)
{
$langFile = MainIOPath::normalize($langFile);
if (LocalizationTranslation::useTranslationRepository() && in_array(LANGUAGE_ID, TranslateConfig::getTranslationRepositoryLanguages()))
{
if (mb_strpos($langFile, LocalizationTranslation::getTranslationRepositoryPath()) === 0)
{
$langFile = str_replace(
LocalizationTranslation::getTranslationRepositoryPath().'/'.LANGUAGE_ID.'/',
'/bitrix/modules/',
$langFile
);
}
}
if (LocalizationTranslation::getDeveloperRepositoryPath() !== null)
{
if (mb_strpos($langFile, LocalizationTranslation::getDeveloperRepositoryPath()) === 0)
{
$langFile = str_replace(
LocalizationTranslation::getDeveloperRepositoryPath(). '/',
'/bitrix/modules/',
$langFile
);
}
}
if (mb_strpos($langFile, MainApplication::getDocumentRoot()) === 0)
{
$langFile = str_replace(
MainApplication::getDocumentRoot(). '/',
'/',
$langFile
);
}
if (empty($langFile))
{
continue;
}
if(
(mb_strpos($langFile, "/menu") !== false) ||
(mb_strpos($langFile, "/classes") !== false) ||
(mb_strpos($langFile, "tools.") !== false) ||
(mb_strpos($langFile, "/include.") !== false) ||
(mb_strpos($langFile, "menu_template.php") !== false) ||
(mb_strpos($langFile, ".menu.") !== false) ||
(mb_strpos($langFile, "/top_panel.php") !== false) ||
(mb_strpos($langFile, "prolog_main_admin.php") !== false) ||
(mb_strpos($_SERVER["REQUEST_URI"], "/iblock_") === false && mb_strpos($langFile, "/modules/iblock/lang/")!==false)
)
{
$lowPriorityLangFiles[] = $langFile;
}
else
{
$highPriorityLangFiles[] = $langFile;
}
}
$lowPriorityLangFiles = array_unique($lowPriorityLangFiles);
$highPriorityLangFiles = array_unique($highPriorityLangFiles);
asort($lowPriorityLangFiles);
reset($lowPriorityLangFiles);
$highPriorityLangFiles = array_reverse($highPriorityLangFiles, true);
$includedLangFiles = array_merge($highPriorityLangFiles, $lowPriorityLangFiles);
if ($searchString !== null)
{
$lookForCode = preg_match("/[a-z1-9_]+/i", $searchString);
}
foreach ($includedLangFiles as $langFile)
{
$stf = '';
if ($searchString !== null)
{
$found = false;
$filePath = LocalizationTranslation::convertLangPath($_SERVER["DOCUMENT_ROOT"]. $langFile, LANGUAGE_ID);
if (file_exists($filePath))
{
$filePath = str_replace('/lang/'.LANGUAGE_ID.'/', '/', $langFile);
$messages = Loc::loadLanguageFile($_SERVER["DOCUMENT_ROOT"]. $filePath, LANGUAGE_ID);
$stf = "";
foreach ($messages as $code => $phrase)
{
if (
$lookForCode && mb_strpos($code, $searchString) !== false ||
mb_strpos($phrase, $searchString) !== false
)
{
$found = true;
$highlight = "&highlight=". preg_replace("/[^a-z1-9_]+/i", '', $code);
$stf .= ''.
htmlspecialcharsbx($phrase).
'
';
}
}
}
if (!$found)
{
continue;
}
}
?>
= $langFile ?>
= $stf ?>
}
?>
$popup->endContent();
$popup->startButtons();
$popup->showStandardButtons(array('close'));
if ($searchString !== null)
{
?>
}
if (defined("ADMIN_SECTION"))
{
?>
}
?>
= Loc::getMessage("TRANSLATE_COUNT_LOADED_LANG_FILES") ?>: = count($includedLangFiles) ?>
" href="javascript:= self::DIALOG_ID ?>.Show();">
= Loc::getMessage("TRANSLATE_SHOW_LOADED_LANG_FILES_TEXT") ?>
}