Beispiel #1
0
 /**
  * Search re-index handler.
  * @param array  $nextStepData Array with data about step.
  * @param null   $searchObject Search object.
  * @param string $method Method.
  * @return array|bool
  */
 public static function onSearchReindex($nextStepData = array(), $searchObject = null, $method = "")
 {
     $result = array();
     $filter = array('TYPE' => ObjectTable::TYPE_FILE);
     if (isset($nextStepData['MODULE']) && $nextStepData['MODULE'] === 'disk' && !empty($nextStepData['ID'])) {
         $filter['>ID'] = self::getObjectIdFromItemId($nextStepData['ID']);
     } else {
         $filter['>ID'] = 0;
     }
     static $self = null;
     if ($self === null) {
         $self = Driver::getInstance()->getIndexManager();
     }
     $query = File::getList(array('filter' => $filter, 'order' => array('ID' => 'ASC')));
     while ($fileData = $query->fetch()) {
         /** @var File $file */
         $file = File::buildFromArray($fileData);
         $detailUrl = Driver::getInstance()->getUrlManager()->getPathFileDetail($file);
         $searchData = array('ID' => self::getItemId($file), 'LAST_MODIFIED' => $file->getUpdateTime() ?: $file->getCreateTime(), 'TITLE' => $file->getName(), 'PARAM1' => $file->getStorageId(), 'PARAM2' => $file->getParentId(), 'SITE_ID' => $file->getStorage()->getSiteId() ?: SITE_ID, 'URL' => $detailUrl, 'PERMISSIONS' => $self->getSimpleRights($file), 'BODY' => $self->getFileContent($file));
         if ($searchObject) {
             $indexResult = call_user_func(array($searchObject, $method), $searchData);
             if (!$indexResult) {
                 return $searchData["ID"];
             }
         } else {
             $result[] = $searchData;
         }
     }
     if ($searchObject) {
         return false;
     }
     return $result;
 }