- Модуль: seo
- Путь к файлу: ~/bitrix/modules/seo/lib/Sitemap/Generator.php
- Класс: BitrixSeoSitemapGenerator
- Вызов: Generator::runFiles
protected function runFiles(): bool
{
$sitemapFile =
new FileRuntime(
$this->sitemapId,
$this->sitemapData['SETTINGS']['FILENAME_FILES'],
$this->getSitemapSettings()
);
$timeFinish = self::getTimeFinish();
$isFinished = false;
$isCheckFinished = false;
$dbRes = null;
while (!$isFinished && microtime(true) <= $timeFinish)
{
if (!$dbRes)
{
$dbRes = RuntimeTable::getList([
'order' => ['ITEM_PATH' => 'ASC'],
'filter' => [
'PID' => $this->sitemapId,
'ITEM_TYPE' => RuntimeTable::ITEM_TYPE_DIR,
'PROCESSED' => RuntimeTable::UNPROCESSED,
],
'limit' => 1000,
]);
}
if ($dirData = $dbRes->Fetch())
{
$this->processDirectory($dirData, $sitemapFile);
$this->statusMessage = Loc::getMessage('SITEMAP_RUN_FILES', ['#PATH#' => $dirData['ITEM_PATH']]);
$isCheckFinished = false;
}
elseif (!$isCheckFinished)
{
$dbRes = null;
$isCheckFinished = true;
}
else
{
$isFinished = true;
}
}
if (!$isFinished)
{
if ($this->step < Step::STEPS[Step::STEP_FILES] - 1)
{
$this->step++;
}
}
else
{
// todo: check state by whitelist
if (!is_array($this->state['XML_FILES']))
{
$this->state['XML_FILES'] = [];
}
if ($sitemapFile->isNotEmpty())
{
if ($sitemapFile->isCurrentPartNotEmpty())
{
$sitemapFile->finish();
}
else
{
$sitemapFile->delete();
}
$xmlFiles = $sitemapFile->getNameList();
$directory = $sitemapFile->getPathDirectory();
foreach ($xmlFiles as &$xmlFile)
{
$xmlFile = $directory . $xmlFile;
}
$this->state['XML_FILES'] = array_unique(array_merge($this->state['XML_FILES'], $xmlFiles));
}
else
{
$sitemapFile->delete();
}
$this->step = Step::STEPS[Step::STEP_FILES];
$this->statusMessage = Loc::getMessage(
'SITEMAP_RUN_FILE_COMPLETE',
['#FILE#' => $this->sitemapData['SETTINGS']['FILENAME_FILES']]
);
}
return true;
}