51 if (isset($filter, $filter->path))
53 $relPath =
'/'. \trim($filter->path,
'/');
54 $relPath = Translate\IO\Path::replaceLangId($relPath,
'#LANG_ID#');
56 $topPathRes = Index\Internals\PathIndexTable::getList([
58 'filter' => [
'=PATH' => $relPath]
60 if (!($topPath = $topPathRes->fetch()))
68 '=%PATH' => $relPath.
'%#LANG_ID#%',
69 '=DESCENDANTS.PARENT_ID' => $topPath[
'ID'],
72 $totalItems = (int)Index\Internals\PathIndexTable::getCount($pathFilter);
76 $totalItems = (int)Index\Internals\PathIndexTable::getCount();
96 if (isset($filter, $filter->path))
98 $relPath = $filter->path;
102 $relPath = Translate\Config::getDefaultPath();
105 $relPath =
'/'. \trim($relPath,
'/');
106 $relPath = Translate\IO\Path::replaceLangId($relPath,
'#LANG_ID#');
108 $this->checkLanguages = self::$enabledLanguages;
109 if (isset($filter, $filter->langId))
111 $this->checkLanguages = \array_intersect($filter->langId, $this->checkLanguages);
115 $topPathRes = Index\Internals\PathIndexTable::getList([
117 'filter' => [
'=PATH' => $relPath]
119 if (!($topPath = $topPathRes->fetch()))
127 '=%PATH' => $relPath.
'%#LANG_ID#%',
128 '=DESCENDANTS.PARENT_ID' => $topPath[
'ID'],
131 if (isset($seek, $seek->pathId))
133 $pathFilter[
'>ID'] = $seek->pathId;
137 $pathListRes = Index\Internals\PathIndexTable::getList([
138 'select' => [
'ID',
'PATH'],
139 'filter' => $pathFilter,
140 'order' => [
'ID' =>
'ASC'],
144 $processedItemCount = 0;
151 while ($pathRow = $pathListRes->fetch())
153 $pathIdPortion[] = $lastPathId = (int)$pathRow[
'ID'];
154 $pathPortion[$lastPathId] = $pathRow[
'PATH'];
155 if (\count($pathIdPortion) >= 100)
160 if (empty($pathIdPortion))
165 $indexFileCacheRes = Index\Internals\FileIndexTable::getList([
166 'select' => [
'ID',
'PATH_ID',
'LANG_ID'],
168 '=PATH_ID' => $pathIdPortion,
169 '=LANG_ID' => $this->checkLanguages,
172 $indexFileCache = [];
173 while ($indexFile = $indexFileCacheRes->fetch())
175 if (!isset($indexFileCache[(
int)$indexFile[
'PATH_ID']]))
177 $indexFileCache[(int)$indexFile[
'PATH_ID']] = [];
179 $indexFileCache[(int)$indexFile[
'PATH_ID']][$indexFile[
'LANG_ID']] = (
int)$indexFile[
'ID'];
181 unset($indexFileCacheRes, $indexFile);
183 $nonexistentFiles = [];
186 foreach ($pathPortion as $pathId => $path)
188 foreach ($this->checkLanguages as $langId)
190 $fullPath = self::$documentRoot. \str_replace(
'#LANG_ID#', $langId, $path);
191 $fullPath = Main\Localization\Translation::convertLangPath($fullPath, $langId);
195 echo
"Lang file: {$fullPath}\n";
198 if (!\file_exists($fullPath))
200 if (isset($indexFileCache[$pathId][$langId]))
203 $nonexistentFiles[] = $indexFileCache[$pathId][$langId];
208 if (!isset($indexFileCache[$pathId][$langId]))
211 'PATH_ID' => $pathId,
212 'LANG_ID' => $langId,
213 'FULL_PATH' => $fullPath,
218 if (\count($fileData) > 0)
220 Index\Internals\FileIndexTable::bulkAdd($fileData);
223 if (\count($nonexistentFiles) > 0)
225 Index\Internals\FileIndexTable::purge(
new Translate\
Filter([
'fileId' => $nonexistentFiles]));
228 $processedItemCount += \count($pathIdPortion);
230 if ($timer !==
null && $timer->hasTimeLimitReached())
234 $seek->nextPathId = $lastPathId;
240 return $processedItemCount;