Beispiel #1
0
 public static function checkIndexesValid()
 {
     if (!Finder::checkIndexValid()) {
         static::showSearchNotification();
     }
     $cnt = static::getCounter();
     if ($cnt > static::HITS_BETWEEN_RECHECKS || !static::checkIndexValid()) {
         $allOk = true;
         $map = ImportProcess::getIndexMap();
         if (is_array($map)) {
             foreach ($map as $ixName => $ixInfo) {
                 if (!$ixInfo['DROP_ONLY'] && !DB\Helper::checkIndexNameExists($ixName, $ixInfo['TABLE'])) {
                     $allOk = false;
                     break;
                 }
             }
         } else {
             $allOk = false;
         }
         if ($allOk) {
             static::setIndexValid();
         } else {
             static::setIndexInvalid();
         }
         static::setCounter(0);
     } else {
         static::setCounter($cnt + 1);
     }
     if (!static::checkIndexValid()) {
         static::showDBIndexNotification();
     }
 }
Beispiel #2
0
 /**
  * @deprecated
  */
 public static function getListFast($parameters = array())
 {
     // here $parameters conversion required
     if (isset($parameters['filter']['NAME'])) {
         $parameters['filter']['PHRASE'] = $parameters['filter']['NAME'];
         unset($parameters['filter']['NAME']);
     }
     if (isset($parameters['filter']['LANGUAGE_ID'])) {
         $parameters['filter']['NAME.LANGUAGE_ID'] = $parameters['filter']['LANGUAGE_ID'];
         unset($parameters['filter']['LANGUAGE_ID']);
     }
     return \Bitrix\Sale\Location\Search\Finder::find($parameters, array('USE_INDEX' => false, 'USE_ORM' => false));
 }
Beispiel #3
0
 public static function doAjaxStuff($parameters = array())
 {
     $errors = static::checkAccessPermissions(array('CHECK_CSRF' => true));
     $data = array();
     if (count($errors) == 0) {
         $import = static::getImportInstance($parameters);
         $request = static::getRequest();
         // action: restore indexes
         if (isset($request['POST']['RESTORE_INDEXES'])) {
             $import->restoreIndexes();
             $import->unLockProcess();
         }
         // action: process ajax
         if (isset($request['POST']['AJAX_CALL'])) {
             $data = array();
             if ($request['POST']['step'] == 0) {
                 $import->reset();
             }
             @set_time_limit(0);
             $data['PERCENT'] = $import->performStage();
             $data['NEXT_STAGE'] = $import->getStageCode();
             if ($data['PERCENT'] == 100) {
                 $import->logFinalResult();
                 $data['STAT'] = array_values($import->getStatisticsAll());
                 // to force to [] in json
                 Finder::setIndexInvalid();
                 // drop search index
                 LocationHelper::deleteInformer('SALE_LOCATIONPRO_DATABASE_FAILURE');
                 // delete database failure messages, if any
                 $GLOBALS['CACHE_MANAGER']->ClearByTag('sale-location-data');
                 if ($request['POST']['OPTIONS']['DROP_ALL'] == 1 || $request['POST']['ONLY_DELETE_ALL'] == 1) {
                     Main\Config\Option::set('sale', self::LOC2_IMPORT_PERFORMED_OPTION, 'Y');
                 }
             }
         }
     }
     return array('ERRORS' => $errors, 'DATA' => $data);
 }
Beispiel #4
0
 /**
  * Do smth when called over ajax
  * @return mixed[]
  */
 public static function doAjaxStuff($parameters = array())
 {
     $errors = static::checkAccessPermissions(array('CHECK_CSRF' => true));
     $data = array();
     if (count($errors) == 0) {
         $request = static::getRequest();
         // action: process ajax
         if (isset($request['POST']['AJAX_CALL'])) {
             if ($request['POST']['ACT'] == 'REINDEX') {
                 $process = new Search\ReindexProcess($request['POST']['ACT_DATA']);
             }
             if ($request['POST']['step'] == 0) {
                 if (is_array($request['POST']['ACT_DATA']['TYPES'])) {
                     $all = false;
                     foreach ($request['POST']['ACT_DATA']['TYPES'] as $k => $type) {
                         if ($type == '') {
                             $all = true;
                             break;
                         }
                         $request['POST']['ACT_DATA']['TYPES'][$k] = intval($type);
                     }
                     $optValue = array();
                     if (!$all) {
                         $optValue = array_unique($request['POST']['ACT_DATA']['TYPES']);
                     }
                     Search\Finder::setIndexedTypes($optValue);
                 }
                 if (is_array($request['POST']['ACT_DATA']['LANG'])) {
                     $langs = TypeHelper::getLanguageList();
                     $all = false;
                     foreach ($request['POST']['ACT_DATA']['LANG'] as $k => $lang) {
                         if ($lang == '') {
                             $all = true;
                             break;
                         }
                         if (!isset($langs[$lang])) {
                             unset($request['POST']['ACT_DATA']['LANG'][$k]);
                         }
                     }
                     $optValue = array();
                     if (!$all) {
                         $optValue = array_unique($request['POST']['ACT_DATA']['LANG']);
                     }
                     Search\Finder::setIndexedLanguages($optValue);
                 }
                 $process->reset();
             }
             try {
                 @set_time_limit(0);
                 $data['PERCENT'] = $process->performStage();
                 $data['NEXT_STAGE'] = $process->getStageCode();
             } catch (Main\SystemException $e) {
                 $errors[] = $e->getMessage();
             }
             if ($data['PERCENT'] == 100) {
                 //$GLOBALS['CACHE_MANAGER']->ClearByTag('sale-location-data');
             }
         }
     }
     return array('ERRORS' => $errors, 'DATA' => $data);
 }
 public static function processSearchRequestV2($parameters)
 {
     static::checkRequiredModules();
     $parameters = static::processSearchRequestV2CheckQuery($parameters);
     // map page & page_size => limit & offset
     if ($pageSize = intval($parameters['PAGE_SIZE'])) {
         $page = intval($parameters['PAGE']);
         $parameters['limit'] = $pageSize;
         $parameters['offset'] = $page ? $page * $pageSize : 0;
     }
     unset($parameters['PAGE_SIZE']);
     unset($parameters['PAGE']);
     // do request
     $data = array('ITEMS' => array(), 'ETC' => array());
     $result = Location\Search\Finder::find(static::processSearchRequestV2ModifyParameters($parameters), static::processSearchRequestV2GetFinderBehaviour());
     while ($item = $result->fetch()) {
         // hack to repair ORM
         if (!isset($item['ID'])) {
             $item['ID'] = $item['VALUE'];
         }
         $data['ITEMS'][] = $item;
     }
     static::processSearchRequestV2GetAdditional($data, $parameters);
     static::processSearchRequestV2AfterSearchFormatResult($data, $parameters);
     return $data;
 }
Beispiel #6
0
 protected function getSubpercentForStageCreateSearchIndex()
 {
     if ($this->getStep() == 0) {
         $this->data['OFFSET'] = 0;
     }
     if (!isset($this->data['INDEX_LOCATION_COUNT'])) {
         $item = Location\LocationTable::getList(array('select' => array('CNT'), 'filter' => ChainTable::getFilterForInitData(array('TYPES' => Finder::getIndexedTypes()))))->fetch();
         $this->data['INDEX_LOCATION_COUNT'] = intval($item['CNT']);
     }
     return $this->getSubPercentByTotalAndDone($this->data['INDEX_LOCATION_COUNT'], $this->data['OFFSET']);
 }