84 if(is_array($parameters[
'TYPES']) && !empty($parameters[
'TYPES']))
86 $this->procData[
'ALLOWED_TYPES'] = array_unique($parameters[
'TYPES']);
90 $res = Location\TypeTable::getList(array(
'select' => array(
'ID',
'CODE',
'DISPLAY_SORT')));
92 $this->procData[
'TYPES'] = array();
93 $this->procData[
'TYPE_SORT'] = array();
95 while($item = $res->fetch())
97 if(!is_array($this->procData[
'ALLOWED_TYPES']) || (is_array($this->procData[
'ALLOWED_TYPES']) && in_array($item[
'ID'], $this->procData[
'ALLOWED_TYPES'])))
98 $this->procData[
'TYPES'][$item[
'CODE']] = $item[
'ID'];
100 $this->procData[
'TYPE_SORT'][$item[
'ID']] = $item[
'DISPLAY_SORT'];
103 $this->procData[
'TYPES_BACK'] = array_flip($this->procData[
'TYPES']);
137 Helper::dropTable(static::getTableName());
139 Main\HttpApplication::getConnection()->query(
"create table ".static::getTableName().
" (
141 LOCATION_ID ".Helper::getSqlForDataType(
'int').
",
142 RELEVANCY ".Helper::getSqlForDataType(
'int').
" default '0',
143 POSITION ".Helper::getSqlForDataType(
'int').
" default '0',
145 primary key (POSITION, LOCATION_ID)
186 $dbConnection = Main\HttpApplication::getConnection();
188 $res = Location\LocationTable::getList(array(
197 'LEFT_MARGIN' =>
'asc'
199 'limit' => self::STEP_SIZE,
200 'offset' => $this->procData[
'OFFSET']
203 $this->procData[
'TYPE_SORT'] = $this->
rarefact($this->procData[
'TYPE_SORT']);
206 while($item = $res->fetch())
211 if($item[
'DEPTH_LEVEL'] < $this->procData[
'DEPTH'])
215 foreach($this->procData[
'PATH'] as $dl => $id)
217 if($dl >= $item[
'DEPTH_LEVEL'])
223 $this->procData[
'PATH'] = $newPC;
226 $this->procData[
'PATH'][$item[
'DEPTH_LEVEL']] = array(
227 'TYPE' => $item[
'TYPE_ID'],
231 if(is_array($this->procData[
'ALLOWED_TYPES']) && in_array($item[
'TYPE_ID'], $this->procData[
'ALLOWED_TYPES']))
234 'LOCATION_ID' => $item[
'ID'],
235 'RELEVANCY' => $this->procData[
'TYPE_SORT'][$item[
'TYPE_ID']] + $item[
'SORT'],
237 $wordsAdded = array();
247 $this->procData[
'DEPTH'] = $item[
'DEPTH_LEVEL'];
251 foreach($this->procData[
'PATH'] as &$pathItem)
253 if(!isset($pathItem[
'WORDS']))
256 select WS.POSITION from ".WordTable::getTableNameWord2Location().
" WL
259 WL.LOCATION_ID = '".intval($pathItem[
'ID']).
"'
262 $wordRes = $dbConnection->query($sql);
264 $pathItem[
'WORDS'] = array();
265 while($wordItem = $wordRes->fetch())
267 $pathItem[
'WORDS'][] = $wordItem[
'POSITION'];
269 $pathItem[
'WORDS'] = array_unique($pathItem[
'WORDS']);
272 $wordCount += count($pathItem[
'WORDS']);
279 foreach($this->procData[
'PATH'] as &$pathItem)
281 foreach($pathItem[
'WORDS'] as $i => $position)
283 $wordWeight = $wordCount - $wOffset;
286 $tmpData[
'RELEVANCY'] += $wordWeight;
290 if(!isset($wordsAdded[$position]))
292 $this->indexInserter->insert(array_merge(array(
'POSITION' => $position), $tmpData));
293 $wordsAdded[$position] =
true;
306 $this->indexInserter->flush();