diff options
author | daita <maxence@pontapreta.net> | 2016-11-07 16:48:39 +0300 |
---|---|---|
committer | daita <maxence@pontapreta.net> | 2016-11-07 16:48:39 +0300 |
commit | c53fe710ff1c58571f011acb8992136094ee340f (patch) | |
tree | 7a3f724a03920608554d2875ebe93fa245a6bb82 | |
parent | a9e27a42d104473d85d386f002d590e6b36d3e76 (diff) |
#59 pre-integration suggestion in sharelink
-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 + ); + } } |