diff --git a/appinfo/info.xml b/appinfo/info.xml index 37457af..a1221e5 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -16,21 +16,10 @@ - - OCA\Radio\Command\Search - Radio radio.page.index - - - OCA\Radio\Activity\Setting - - - OCA\Radio\Activity\Provider - - diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 57075e0..3fecbeb 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace OCA\Radio\AppInfo; +use OCA\Radio\Search\SearchProvider; use OCP\AppFramework\App; use OCP\AppFramework\Bootstrap\IBootContext; use OCP\AppFramework\Bootstrap\IBootstrap; @@ -20,6 +21,7 @@ class Application extends App implements IBootstrap { public function register(IRegistrationContext $context): void { + $context->registerSearchProvider(SearchProvider::class); $context->registerService('request', static function ($c) { return $c->get(IRequest::class); }); diff --git a/lib/Search/SearchProvider.php b/lib/Search/SearchProvider.php new file mode 100644 index 0000000..e3be9f7 --- /dev/null +++ b/lib/Search/SearchProvider.php @@ -0,0 +1,59 @@ +url = $url; + } + + public function getId(): string { + return Application::APP_ID; + } + + public function getName(): string { + return 'Radio'; + } + + public function getOrder(string $route, array $routeParameters): int { + if (strpos($route, 'files' . '.') === 0) { + return 25; + } elseif (strpos($route, Application::APP_ID . '.') === 0) { + return -1; + } + return 4; + } + + public function search(IUser $user, ISearchQuery $query): SearchResult { + // create SearchResultEntry from Note + $result = [new SearchResultEntry( + '', + 'SRF Virus', + 'alternative, youth', + $this->url->linkToRouteAbsolute('radio.page.index') . 'search/' . urlencode($query->getTerm()), // FIXME: urlencode working? + 'icon-notes-trans' + )]; + return SearchResult::complete( + $this->getName(), + $result + ); + } +}