@@ -26,9 +26,9 @@ |
||
| 26 | 26 | |
| 27 | 27 | namespace OCA\FullTextSearch_ElasticSearch\AppInfo; |
| 28 | 28 | |
| 29 | -$composerDir = __DIR__ . '/../vendor/'; |
|
| 29 | +$composerDir = __DIR__.'/../vendor/'; |
|
| 30 | 30 | |
| 31 | -if (is_dir($composerDir) && file_exists($composerDir . 'autoload.php')) { |
|
| 32 | - require_once $composerDir . 'autoload.php'; |
|
| 31 | +if (is_dir($composerDir) && file_exists($composerDir.'autoload.php')) { |
|
| 32 | + require_once $composerDir.'autoload.php'; |
|
| 33 | 33 | } |
| 34 | 34 | |
@@ -26,6 +26,6 @@ |
||
| 26 | 26 | |
| 27 | 27 | namespace OCA\FullTextSearch_ElasticSearch\AppInfo; |
| 28 | 28 | |
| 29 | -require_once __DIR__ . '/autoload.php'; |
|
| 29 | +require_once __DIR__.'/autoload.php'; |
|
| 30 | 30 | |
| 31 | 31 | new Application(); |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | 'index' => |
| 76 | 76 | [ |
| 77 | 77 | 'index' => $this->configService->getElasticIndex(), |
| 78 | - 'id' => $document->getProviderId() . ':' . $document->getId(), |
|
| 78 | + 'id' => $document->getProviderId().':'.$document->getId(), |
|
| 79 | 79 | 'type' => 'standard', |
| 80 | 80 | 'body' => $this->generateIndexBody($document) |
| 81 | 81 | ] |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | 'index' => |
| 106 | 106 | [ |
| 107 | 107 | 'index' => $this->configService->getElasticIndex(), |
| 108 | - 'id' => $document->getProviderId() . ':' . $document->getId(), |
|
| 108 | + 'id' => $document->getProviderId().':'.$document->getId(), |
|
| 109 | 109 | 'type' => 'standard', |
| 110 | 110 | 'body' => ['doc' => $this->generateIndexBody($document)] |
| 111 | 111 | ] |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | 'index' => |
| 134 | 134 | [ |
| 135 | 135 | 'index' => $this->configService->getElasticIndex(), |
| 136 | - 'id' => $providerId . ':' . $documentId, |
|
| 136 | + 'id' => $providerId.':'.$documentId, |
|
| 137 | 137 | 'type' => 'standard' |
| 138 | 138 | ] |
| 139 | 139 | ]; |
@@ -189,7 +189,7 @@ |
||
| 189 | 189 | |
| 190 | 190 | /** |
| 191 | 191 | * @param ISearchResult $searchResult |
| 192 | - * @param array $result |
|
| 192 | + * @param callable $result |
|
| 193 | 193 | */ |
| 194 | 194 | private function updateSearchResult(ISearchResult $searchResult, array $result) { |
| 195 | 195 | $searchResult->setRawResult(json_encode($result)); |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | Client $client, ISearchResult $searchResult, IDocumentAccess $access |
| 86 | 86 | ) { |
| 87 | 87 | try { |
| 88 | - $this->miscService->log('New Search Request; SearchResult Model: ' . json_encode($searchResult), 0); |
|
| 88 | + $this->miscService->log('New Search Request; SearchResult Model: '.json_encode($searchResult), 0); |
|
| 89 | 89 | $query = $this->searchMappingService->generateSearchQuery( |
| 90 | 90 | $searchResult->getRequest(), $access, $searchResult->getProvider() |
| 91 | 91 | ->getId() |
@@ -95,25 +95,25 @@ discard block |
||
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | try { |
| 98 | - $this->miscService->log('Searching ES: ' . json_encode($query['params']), 0); |
|
| 98 | + $this->miscService->log('Searching ES: '.json_encode($query['params']), 0); |
|
| 99 | 99 | |
| 100 | 100 | $result = $client->search($query['params']); |
| 101 | 101 | } catch (Exception $e) { |
| 102 | 102 | $this->miscService->log( |
| 103 | - 'debug - request: ' . json_encode($searchResult->getRequest()) . ' - query: ' |
|
| 103 | + 'debug - request: '.json_encode($searchResult->getRequest()).' - query: ' |
|
| 104 | 104 | . json_encode($query) |
| 105 | 105 | ); |
| 106 | 106 | throw $e; |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - $this->miscService->log('Result from ES: ' . json_encode($result), 0); |
|
| 109 | + $this->miscService->log('Result from ES: '.json_encode($result), 0); |
|
| 110 | 110 | $this->updateSearchResult($searchResult, $result); |
| 111 | 111 | |
| 112 | 112 | foreach ($result['hits']['hits'] as $entry) { |
| 113 | 113 | $searchResult->addDocument($this->parseSearchEntry($entry, $access->getViewerId())); |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | - $this->miscService->log('Filled SearchResult Model: ' . json_encode($searchResult), 0); |
|
| 116 | + $this->miscService->log('Filled SearchResult Model: '.json_encode($searchResult), 0); |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | |
@@ -126,12 +126,12 @@ |
||
| 126 | 126 | $hosts = $this->configService->getElasticHost(); |
| 127 | 127 | foreach ($hosts as $host) { |
| 128 | 128 | $parsedHost = parse_url($host); |
| 129 | - $safeHost = $parsedHost['scheme'] . '://'; |
|
| 129 | + $safeHost = $parsedHost['scheme'].'://'; |
|
| 130 | 130 | if (array_key_exists('user', $parsedHost)) { |
| 131 | - $safeHost .= $parsedHost['user'] . ':' . '********' . '@'; |
|
| 131 | + $safeHost .= $parsedHost['user'].':'.'********'.'@'; |
|
| 132 | 132 | } |
| 133 | 133 | $safeHost .= $parsedHost['host']; |
| 134 | - $safeHost .= ':' . $parsedHost['port']; |
|
| 134 | + $safeHost .= ':'.$parsedHost['port']; |
|
| 135 | 135 | |
| 136 | 136 | $sanitizedHosts[] = $safeHost; |
| 137 | 137 | } |
@@ -36,19 +36,19 @@ discard block |
||
| 36 | 36 | */ |
| 37 | 37 | class UserStoragesService implements IUserStoragesService { |
| 38 | 38 | |
| 39 | - /** @var UserGlobalStoragesService */ |
|
| 40 | - private $userGlobalStoragesService; |
|
| 39 | + /** @var UserGlobalStoragesService */ |
|
| 40 | + private $userGlobalStoragesService; |
|
| 41 | 41 | |
| 42 | - function __construct(UserGlobalStoragesService $userGlobalStoragesService) { |
|
| 43 | - $this->userGlobalStoragesService = $userGlobalStoragesService; |
|
| 44 | - } |
|
| 42 | + function __construct(UserGlobalStoragesService $userGlobalStoragesService) { |
|
| 43 | + $this->userGlobalStoragesService = $userGlobalStoragesService; |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | 46 | /** |
| 47 | - * Returns an array of strings with all external mountpoints of the current user |
|
| 48 | - * @return array |
|
| 49 | - */ |
|
| 50 | - function getAllStoragesForUser() { |
|
| 51 | - $userStorages = $this->userGlobalStoragesService->getAllStoragesForUser(); |
|
| 47 | + * Returns an array of strings with all external mountpoints of the current user |
|
| 48 | + * @return array |
|
| 49 | + */ |
|
| 50 | + function getAllStoragesForUser() { |
|
| 51 | + $userStorages = $this->userGlobalStoragesService->getAllStoragesForUser(); |
|
| 52 | 52 | $mountPoints = []; |
| 53 | 53 | foreach($userStorages as $userStorage){ |
| 54 | 54 | /** @var $userStorage OCA\Files_External\Lib\StorageConfig */ |
@@ -62,5 +62,5 @@ discard block |
||
| 62 | 62 | $mountPoints[] = $mountPoint; |
| 63 | 63 | } |
| 64 | 64 | return $mountPoints; |
| 65 | - } |
|
| 65 | + } |
|
| 66 | 66 | } |
| 67 | 67 | \ No newline at end of file |
@@ -50,13 +50,13 @@ |
||
| 50 | 50 | function getAllStoragesForUser() { |
| 51 | 51 | $userStorages = $this->userGlobalStoragesService->getAllStoragesForUser(); |
| 52 | 52 | $mountPoints = []; |
| 53 | - foreach($userStorages as $userStorage){ |
|
| 53 | + foreach ($userStorages as $userStorage) { |
|
| 54 | 54 | /** @var $userStorage OCA\Files_External\Lib\StorageConfig */ |
| 55 | 55 | $mountPoint = $userStorage->getMountPoint(); |
| 56 | - if (substr($mountPoint, 0, 1) === '/'){ |
|
| 56 | + if (substr($mountPoint, 0, 1) === '/') { |
|
| 57 | 57 | $mountPoint = substr($mountPoint, 1, strlen($mountPoint) - 1); |
| 58 | 58 | } |
| 59 | - if (substr($mountPoint, strlen($mountPoint) - 1, 1) !== '/'){ |
|
| 59 | + if (substr($mountPoint, strlen($mountPoint) - 1, 1) !== '/') { |
|
| 60 | 60 | $mountPoint .= '/'; |
| 61 | 61 | } |
| 62 | 62 | $mountPoints[] = $mountPoint; |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | |
| 291 | 291 | foreach ($request->getWildcardFields() as $field) { |
| 292 | 292 | if (!$this->fieldIsOutLimit($request, $field)) { |
| 293 | - $queryFields[] = ['wildcard' => [$field => '*' . $content->getWord() . '*']]; |
|
| 293 | + $queryFields[] = ['wildcard' => [$field => '*'.$content->getWord().'*']]; |
|
| 294 | 294 | } |
| 295 | 295 | } |
| 296 | 296 | |
@@ -338,9 +338,9 @@ discard block |
||
| 338 | 338 | // external files with "$request->getOption('files_external', '1') === '1'" |
| 339 | 339 | $externalFileShares = $this->getExternalFileShares(); |
| 340 | 340 | |
| 341 | - if ($externalFileShares){ |
|
| 341 | + if ($externalFileShares) { |
|
| 342 | 342 | $allowedExternalShares = []; |
| 343 | - foreach($externalFileShares as $fileShare){ |
|
| 343 | + foreach ($externalFileShares as $fileShare) { |
|
| 344 | 344 | $allowedExternalShares[] = ['prefix' => ['title' => $fileShare]]; |
| 345 | 345 | } |
| 346 | 346 | $externalFilesConditions = []; |
@@ -484,7 +484,7 @@ discard block |
||
| 484 | 484 | return [ |
| 485 | 485 | 'index' => $this->configService->getElasticIndex(), |
| 486 | 486 | 'type' => 'standard', |
| 487 | - 'id' => $providerId . ':' . $documentId |
|
| 487 | + 'id' => $providerId.':'.$documentId |
|
| 488 | 488 | ]; |
| 489 | 489 | } |
| 490 | 490 | |
@@ -497,7 +497,7 @@ discard block |
||
| 497 | 497 | private function getPartsFields(ISearchRequest $request) { |
| 498 | 498 | return array_map( |
| 499 | 499 | function($value) { |
| 500 | - return 'parts.' . $value; |
|
| 500 | + return 'parts.'.$value; |
|
| 501 | 501 | }, $request->getParts() |
| 502 | 502 | ); |
| 503 | 503 | } |
@@ -30,9 +30,9 @@ |
||
| 30 | 30 | namespace OCA\FullTextSearch_ElasticSearch\Service; |
| 31 | 31 | |
| 32 | 32 | interface IUserStoragesService { |
| 33 | - /** |
|
| 34 | - * Returns an array of strings with all external mountpoints of the current user |
|
| 35 | - * @return array |
|
| 36 | - */ |
|
| 37 | - function getAllStoragesForUser(); |
|
| 33 | + /** |
|
| 34 | + * Returns an array of strings with all external mountpoints of the current user |
|
| 35 | + * @return array |
|
| 36 | + */ |
|
| 37 | + function getAllStoragesForUser(); |
|
| 38 | 38 | } |
| 39 | 39 | \ No newline at end of file |
@@ -57,13 +57,13 @@ |
||
| 57 | 57 | $this->registerServices(); |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - private function registerServices(){ |
|
| 60 | + private function registerServices() { |
|
| 61 | 61 | $container = $this->getContainer(); |
| 62 | 62 | |
| 63 | 63 | // Make SearchMappingService also work without external storage |
| 64 | 64 | // if app is inactive or not installed. |
| 65 | 65 | $container->registerService(SearchMappingService::class, function($c) { |
| 66 | - try{ |
|
| 66 | + try { |
|
| 67 | 67 | $userStoragesService = $c->query(\OCA\Files_External\Service\UserGlobalStoragesService::class); |
| 68 | 68 | return new SearchMappingService( |
| 69 | 69 | $c->query(ConfigService::class), |
@@ -70,8 +70,7 @@ |
||
| 70 | 70 | $c->query(MiscService::class), |
| 71 | 71 | new UserStoragesService($userStoragesService) |
| 72 | 72 | ); |
| 73 | - } |
|
| 74 | - catch (\OCP\AppFramework\QueryException $e) { |
|
| 73 | + } catch (\OCP\AppFramework\QueryException $e) { |
|
| 75 | 74 | return new SearchMappingService( |
| 76 | 75 | $c->query(ConfigService::class), |
| 77 | 76 | $c->query(MiscService::class) |