- Модуль: main
- Путь к файлу: ~/bitrix/modules/main/lib/urlrewriter.php
- Класс: BitrixMainUrlRewriter
- Вызов: UrlRewriter::recursiveReindex
static function recursiveReindex($rootPath, $path, $arSites, $maxExecutionTime, &$ns)
{
$pathAbs = IOPath::combine($rootPath, $path);
$siteId = "";
foreach ($arSites as $site)
{
if (mb_substr($pathAbs."/", 0, mb_strlen($site["path"]."/")) == $site["path"]."/")
{
$siteId = $site["site_id"];
break;
}
}
if (empty($siteId))
return 0;
$dir = new IODirectory($pathAbs, $siteId);
if (!$dir->isExists())
return 0;
$arChildren = $dir->getChildren();
foreach ($arChildren as $child)
{
if ($child->isDirectory())
{
if ($child->isSystem())
continue;
//this is not first step and we had stopped here, so go on to reindex
if ($maxExecutionTime <= 0
|| $ns["FLG"] == ''
|| mb_substr($ns["ID"]."/", 0, mb_strlen($child->getPath()."/")) == $child->getPath()."/"
)
{
if (static::recursiveReindex($rootPath, mb_substr($child->getPath(), mb_strlen($rootPath)), $arSites, $maxExecutionTime, $ns) === false)
return false;
}
else //all done
{
continue;
}
}
else
{
//not the first step and we found last file from previos one
if ($maxExecutionTime > 0 && $ns["FLG"] <> ''
&& $ns["ID"] == $child->getPath())
{
$ns["FLG"] = "";
}
elseif (empty($ns["FLG"]))
{
$ID = static::reindexFile($siteId, $rootPath, mb_substr($child->getPath(), mb_strlen($rootPath)), $ns["max_file_size"]);
if ($ID)
$ns["CNT"] = intval($ns["CNT"]) + 1;
}
if ($maxExecutionTime > 0
&& (getmicrotime() - START_EXEC_TIME > $maxExecutionTime))
{
$ns["FLG"] = "Y";
$ns["ID"] = $child->getPath();
return false;
}
}
}
return true;
}