161 static::createTables();
168 $res = Location\TypeTable::getList(array(
'select' => array(
'ID',
'CODE',
'SORT')));
170 $allowedTypes = array(
'REGION',
'SUBREGION',
'CITY',
'VILLAGE',
'STREET');
172 while($item = $res->fetch())
174 if(in_array($item[
'CODE'], $allowedTypes))
175 $types[$item[
'CODE']] = $item[
'ID'];
177 $typeSort[$item[
'ID']] = $item[
'SORT'];
180 $typesBack = array_flip($types);
185 $wordChain = array();
186 $pathChain = array();
193 $res = Location\LocationTable::getList(array(
197 'LNAME' =>
'NAME.NAME',
202 '=TYPE_ID' => array_values($types),
203 '=NAME.LANGUAGE_ID' => LANGUAGE_ID
206 'LEFT_MARGIN' =>
'asc'
208 'limit' => self::STEP_SIZE,
213 while($item = $res->fetch())
215 if($item[
'DEPTH_LEVEL'] < $prevDepth)
222 foreach($wordChain as $dl => $name)
224 if($dl >= $item[
'DEPTH_LEVEL'])
232 foreach($pathChain as $dl => $id)
234 if($dl >= $item[
'DEPTH_LEVEL'])
243 $wordChain[$item[
'DEPTH_LEVEL']] = $item[
'LNAME'];
244 $pathChain[$item[
'DEPTH_LEVEL']] = array(
'TYPE' => $item[
'TYPE_ID'],
'ID' => $item[
'ID']);
246 $prevDepth = $item[
'DEPTH_LEVEL'];
253 foreach($parsed as $word)
255 $wordMap[
'W_'.$i] = $word;
259 foreach($pathChain as $elem)
260 $pathMap[$typesBack[$elem[
'TYPE']].
'_ID'] = $elem[
'ID'];
262 $data = array_merge($wordMap, $pathMap, array(
263 'LOCATION_ID' => $item[
'ID'],
264 'TYPE_ID' => $item[
'TYPE_ID'],
265 'TYPE_SORT' => $typeSort[$item[
'TYPE_ID']],
266 'SORT' => $item[
'SORT'],
267 'WORD_COUNT' => count($wordMap)
279 _dump_r(
'Cant add '.implode(
' ', $wordChain).
' ('.count($wordMap).
')<br />');