diff options
-rw-r--r-- | appinfo/routes.php | 8 | ||||
-rw-r--r-- | lib/Controller/SearchController.php | 26 |
2 files changed, 33 insertions, 1 deletions
diff --git a/appinfo/routes.php b/appinfo/routes.php index 1c75b84..084629e 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -69,9 +69,15 @@ return [ 'name' => 'search#searchRequestShareLink', 'url' => 'ajax/search_sharelink.php', 'verb' => 'POST' + ], + [ + 'name' => 'search#getSuggestionsShareLink', + 'url' => 'ajax/suggest_sharelink.php', + 'verb' => 'POST' ] ] -]; +] +; /* * This route is now useless. It was used with navigate.js + SearchController diff --git a/lib/Controller/SearchController.php b/lib/Controller/SearchController.php index 521fde5..1279b59 100644 --- a/lib/Controller/SearchController.php +++ b/lib/Controller/SearchController.php @@ -269,4 +269,30 @@ class SearchController extends Controller return $results; } + + /** + * @NoCSRFRequired + * @PublicPage + */ + public function getSuggestionsShareLink($query) + { + if (! $this->solrService) + return false; + + if ($this->configService->getAppValue('index_files_sharelink') !== '1') + return array(); + + if ($query == null || $query === '') + return array(); + + $ierror = null; + $suggest = $this->solrService->suggest($query, $ierror); + + $err = ($ierror == null) ? 0 : $ierror->getCode(); + + return array( + 'status' => $err, + 'result' => $suggest + ); + } } |