1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
collectfileindex.php
См. документацию.
1<?php
3
7
14{
17
19 private $seekPathId = '';
20
22 private $languages = [];
23
32 {
33 $this->keepField(['seekPathId', 'languages']);
34
35 parent::__construct($name, $controller, $config);
36 }
37
45 public function run($path = '')
46 {
47 if (empty($path))
48 {
50 }
51
52 if (\preg_match("#(.+\/lang)(\/?\w*)#", $path, $matches))
53 {
54 $path = $matches[1];
55 }
56
57 $path = '/'. \trim($path, '/.\\');
58
59 // skip indexing if index exists
60 if (Main\Context::getCurrent()->getRequest()->get('checkIndexExists') === 'Y')
61 {
62 $indexPath = Translate\Index\PathIndex::loadByPath($path);
63 if ($indexPath instanceof Translate\Index\PathIndex)
64 {
65 if ($indexPath->getIndexed())
66 {
67 return [
69 ];
70 }
71 }
72 }
73
74 if ($this->isNewProcess)
75 {
76 $languages = $this->controller->getRequest()->get('languages');
77 if (\is_array($languages) && !\in_array('all', $languages))
78 {
79 $languages = \array_intersect($languages, Translate\Config::getEnabledLanguages());
80 if (!empty($languages))
81 {
82 $this->languages = $languages;
83 }
84 }
85
86 $filter = new Translate\Filter(['path' => $path]);
87 if (!empty($this->languages))
88 {
89 $filter->langId = $this->languages;
90 }
91
92 $this->totalItems = (new Index\FileIndexCollection())->countItemsToProcess($filter);
93
95
96 $this->instanceTimer()->setTimeLimit(5);
97 $this->isNewProcess = false;
98 }
99 else
100 {
101 $progressParams = $this->getProgressParameters();
102
103 if (isset($progressParams['totalItems']) && (int)$progressParams['totalItems'] > 0)
104 {
105 $this->totalItems = (int)$progressParams['totalItems'];
106 $this->processedItems = (int)$progressParams['processedItems'];
107 }
108
109 if (isset($progressParams['seekPathId']))
110 {
111 $this->seekPathId = $progressParams['seekPathId'];
112 }
113 }
114
115 return $this->performStep('runIndexing', ['path' => $path]);
116 }
117
125 private function runIndexing(array $params): array
126 {
127 $path = \rtrim($params['path'], '/');
128
129 $seek = new Translate\Filter();
130 if (!empty($this->seekPathId))
131 {
132 $seek->pathId = $this->seekPathId;
133 }
134
135 $filter = new Translate\Filter(['path' => $path]);
136 if (!empty($this->languages))
137 {
138 $filter->langId = $this->languages;
139 }
140
141 $indexer = new Index\FileIndexCollection();
142
143 $processedItemCount = $indexer->collect($filter, $this->instanceTimer(), $seek);
144
145 $this->processedItems += $processedItemCount;
146
147 if ($this->processedItems >= $this->totalItems)
148 {
149 $this->declareAccomplishment();
151 }
152 else
153 {
154 $this->seekPathId = $seek->nextPathId;
155 }
156
157 return [
158 'PROCESSED_ITEMS' => $this->processedItems,
159 'TOTAL_ITEMS' => $this->totalItems,
160 ];
161 }
162}
$path
Определения access_edit.php:21
$controller
Определения action.php:23
static getDefaultPath()
Определения config.php:376
__construct($name, Main\Engine\Controller $controller, array $config=[])
Определения collectfileindex.php:31
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$filter
Определения iblock_catalog_list.php:54
Определения action.php:3
trait ProcessParams
Определения processparams.php:12
const STATUS_COMPLETED
Определения controller.php:6
instanceTimer()
Определения stepper.php:172
int $processedItems
Определения stepper.php:20
int $totalItems
Определения stepper.php:22
performStep($action, array $params=[])
Определения stepper.php:75
declareAccomplishment(bool $flag=true)
Определения stepper.php:136
trait Stepper
Определения stepper.php:13
Определения autoload.php:3
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения template.php:799
$matches
Определения index.php:22