- Модуль: translate
- Путь к файлу: ~/bitrix/modules/translate/lib/controller/editor/wipeempty.php
- Класс: BitrixTranslateControllerEditorWipeEmpty
- Вызов: WipeEmpty::runWiping
private function runWiping(): array
{
$processedItemCount = 0;
for ($pos = ((int)$this->seekOffset > 0 ? (int)$this->seekOffset : 0), $total = count($this->pathList); $pos < $total; $pos ++)
{
$testPath = $this->pathList[$pos];
$isOk = true;
// file
if (TranslateIOPath::isPhpFile($testPath))
{
$testPath = TranslateIOPath::replaceLangId($testPath, '#LANG_ID#');
foreach (self::$enabledLanguagesList as $langId)
{
$langRelPath = TranslateIOPath::replaceLangId($testPath, $langId);
$langFullPath = TranslateIOPath::tidy(self::$documentRoot.'/'.$langRelPath);
$langFullPath = MainLocalizationTranslation::convertLangPath($langFullPath, $langId);
if ($this->removeEmptyParents($langFullPath))
{
TranslateIndexInternalsFileIndexTable::purge(new TranslateFilter(['path' => $testPath, 'langId' => $langId]));
}
else
{
$isOk = false;
}
}
}
// folder
else
{
if (mb_substr($testPath, -5) === '/lang')
{
$testPath .= '/#LANG_ID#';
}
else
{
$testPath = TranslateIOPath::replaceLangId($testPath, '#LANG_ID#');
}
foreach (self::$enabledLanguagesList as $langId)
{
$langRelPath = TranslateIOPath::replaceLangId($testPath. '/.nonExistentTestFile.php', $langId);
$langFullPath = TranslateIOPath::tidy(self::$documentRoot.'/'.$langRelPath);
$langFullPath = MainLocalizationTranslation::convertLangPath($langFullPath, $langId);
if ($this->removeEmptyParents($langFullPath))
{
TranslateIndexInternalsFileIndexTable::purge(new TranslateFilter(['path' => $testPath, 'langId' => $langId]));
}
else
{
$isOk = false;
}
}
}
if ($isOk)
{
TranslateIndexInternalsPathIndexTable::purge(new TranslateFilter(['path' => $testPath]), false);
}
$processedItemCount ++;
if (isset($this->pathList[$pos + 1]))
{
$this->seekOffset = $pos + 1;//next
}
else
{
$this->seekOffset = null;
$this->declareAccomplishment();
$this->clearProgressParameters();
}
if ($this->instanceTimer()->hasTimeLimitReached())
{
break;
}
}
$this->processedItems += $processedItemCount;
if ($this->instanceTimer()->hasTimeLimitReached() !== true)
{
$this->declareAccomplishment();
$this->clearProgressParameters();
}
return [
'PROCESSED_ITEMS' => $this->processedItems,
'TOTAL_ITEMS' => $this->totalItems,
];
}