@@ -36,78 +36,78 @@ |
||
36 | 36 | |
37 | 37 | class LegacyProvider extends Provider { |
38 | 38 | |
39 | - /** |
|
40 | - * Search for $query |
|
41 | - * |
|
42 | - * @param string $query |
|
43 | - * @return array An array of OCP\Search\Result's |
|
44 | - * @since 7.0.0 |
|
45 | - */ |
|
46 | - public function search($query): array { |
|
47 | - $cm = \OC::$server->getCommentsManager(); |
|
48 | - $us = \OC::$server->getUserSession(); |
|
49 | - |
|
50 | - $user = $us->getUser(); |
|
51 | - if (!$user instanceof IUser) { |
|
52 | - return []; |
|
53 | - } |
|
54 | - $uf = \OC::$server->getUserFolder($user->getUID()); |
|
55 | - |
|
56 | - if ($uf === null) { |
|
57 | - return []; |
|
58 | - } |
|
59 | - |
|
60 | - $result = []; |
|
61 | - $numComments = 50; |
|
62 | - $offset = 0; |
|
63 | - |
|
64 | - while (count($result) < $numComments) { |
|
65 | - /** @var IComment[] $comments */ |
|
66 | - $comments = $cm->search($query, 'files', '', 'comment', $offset, $numComments); |
|
67 | - |
|
68 | - foreach ($comments as $comment) { |
|
69 | - if ($comment->getActorType() !== 'users') { |
|
70 | - continue; |
|
71 | - } |
|
72 | - |
|
73 | - $displayName = $cm->resolveDisplayName('user', $comment->getActorId()); |
|
74 | - |
|
75 | - try { |
|
76 | - $file = $this->getFileForComment($uf, $comment); |
|
77 | - $result[] = new Result($query, |
|
78 | - $comment, |
|
79 | - $displayName, |
|
80 | - $file->getPath() |
|
81 | - ); |
|
82 | - } catch (NotFoundException $e) { |
|
83 | - continue; |
|
84 | - } |
|
85 | - } |
|
86 | - |
|
87 | - if (count($comments) < $numComments) { |
|
88 | - // Didn't find more comments when we tried to get, so there are no more comments. |
|
89 | - return $result; |
|
90 | - } |
|
91 | - |
|
92 | - $offset += $numComments; |
|
93 | - $numComments = 50 - count($result); |
|
94 | - } |
|
95 | - |
|
96 | - return $result; |
|
97 | - } |
|
98 | - |
|
99 | - /** |
|
100 | - * @param Folder $userFolder |
|
101 | - * @param IComment $comment |
|
102 | - * @return Node |
|
103 | - * @throws NotFoundException |
|
104 | - */ |
|
105 | - protected function getFileForComment(Folder $userFolder, IComment $comment): Node { |
|
106 | - $nodes = $userFolder->getById((int) $comment->getObjectId()); |
|
107 | - if (empty($nodes)) { |
|
108 | - throw new NotFoundException('File not found'); |
|
109 | - } |
|
110 | - |
|
111 | - return array_shift($nodes); |
|
112 | - } |
|
39 | + /** |
|
40 | + * Search for $query |
|
41 | + * |
|
42 | + * @param string $query |
|
43 | + * @return array An array of OCP\Search\Result's |
|
44 | + * @since 7.0.0 |
|
45 | + */ |
|
46 | + public function search($query): array { |
|
47 | + $cm = \OC::$server->getCommentsManager(); |
|
48 | + $us = \OC::$server->getUserSession(); |
|
49 | + |
|
50 | + $user = $us->getUser(); |
|
51 | + if (!$user instanceof IUser) { |
|
52 | + return []; |
|
53 | + } |
|
54 | + $uf = \OC::$server->getUserFolder($user->getUID()); |
|
55 | + |
|
56 | + if ($uf === null) { |
|
57 | + return []; |
|
58 | + } |
|
59 | + |
|
60 | + $result = []; |
|
61 | + $numComments = 50; |
|
62 | + $offset = 0; |
|
63 | + |
|
64 | + while (count($result) < $numComments) { |
|
65 | + /** @var IComment[] $comments */ |
|
66 | + $comments = $cm->search($query, 'files', '', 'comment', $offset, $numComments); |
|
67 | + |
|
68 | + foreach ($comments as $comment) { |
|
69 | + if ($comment->getActorType() !== 'users') { |
|
70 | + continue; |
|
71 | + } |
|
72 | + |
|
73 | + $displayName = $cm->resolveDisplayName('user', $comment->getActorId()); |
|
74 | + |
|
75 | + try { |
|
76 | + $file = $this->getFileForComment($uf, $comment); |
|
77 | + $result[] = new Result($query, |
|
78 | + $comment, |
|
79 | + $displayName, |
|
80 | + $file->getPath() |
|
81 | + ); |
|
82 | + } catch (NotFoundException $e) { |
|
83 | + continue; |
|
84 | + } |
|
85 | + } |
|
86 | + |
|
87 | + if (count($comments) < $numComments) { |
|
88 | + // Didn't find more comments when we tried to get, so there are no more comments. |
|
89 | + return $result; |
|
90 | + } |
|
91 | + |
|
92 | + $offset += $numComments; |
|
93 | + $numComments = 50 - count($result); |
|
94 | + } |
|
95 | + |
|
96 | + return $result; |
|
97 | + } |
|
98 | + |
|
99 | + /** |
|
100 | + * @param Folder $userFolder |
|
101 | + * @param IComment $comment |
|
102 | + * @return Node |
|
103 | + * @throws NotFoundException |
|
104 | + */ |
|
105 | + protected function getFileForComment(Folder $userFolder, IComment $comment): Node { |
|
106 | + $nodes = $userFolder->getById((int) $comment->getObjectId()); |
|
107 | + if (empty($nodes)) { |
|
108 | + throw new NotFoundException('File not found'); |
|
109 | + } |
|
110 | + |
|
111 | + return array_shift($nodes); |
|
112 | + } |
|
113 | 113 | } |
@@ -32,101 +32,101 @@ |
||
32 | 32 | * @deprecated 20.0.0 |
33 | 33 | */ |
34 | 34 | class Result extends BaseResult { |
35 | - /** |
|
36 | - * @deprecated 20.0.0 |
|
37 | - */ |
|
38 | - public $type = 'comment'; |
|
39 | - /** |
|
40 | - * @deprecated 20.0.0 |
|
41 | - */ |
|
42 | - public $comment; |
|
43 | - /** |
|
44 | - * @deprecated 20.0.0 |
|
45 | - */ |
|
46 | - public $authorId; |
|
47 | - /** |
|
48 | - * @deprecated 20.0.0 |
|
49 | - */ |
|
50 | - public $authorName; |
|
51 | - /** |
|
52 | - * @deprecated 20.0.0 |
|
53 | - */ |
|
54 | - public $path; |
|
55 | - /** |
|
56 | - * @deprecated 20.0.0 |
|
57 | - */ |
|
58 | - public $fileName; |
|
35 | + /** |
|
36 | + * @deprecated 20.0.0 |
|
37 | + */ |
|
38 | + public $type = 'comment'; |
|
39 | + /** |
|
40 | + * @deprecated 20.0.0 |
|
41 | + */ |
|
42 | + public $comment; |
|
43 | + /** |
|
44 | + * @deprecated 20.0.0 |
|
45 | + */ |
|
46 | + public $authorId; |
|
47 | + /** |
|
48 | + * @deprecated 20.0.0 |
|
49 | + */ |
|
50 | + public $authorName; |
|
51 | + /** |
|
52 | + * @deprecated 20.0.0 |
|
53 | + */ |
|
54 | + public $path; |
|
55 | + /** |
|
56 | + * @deprecated 20.0.0 |
|
57 | + */ |
|
58 | + public $fileName; |
|
59 | 59 | |
60 | - /** |
|
61 | - * @param string $search |
|
62 | - * @param IComment $comment |
|
63 | - * @param string $authorName |
|
64 | - * @param string $path |
|
65 | - * @throws NotFoundException |
|
66 | - * @deprecated 20.0.0 |
|
67 | - */ |
|
68 | - public function __construct(string $search, |
|
69 | - IComment $comment, |
|
70 | - string $authorName, |
|
71 | - string $path) { |
|
72 | - parent::__construct( |
|
73 | - (int) $comment->getId(), |
|
74 | - $comment->getMessage() |
|
75 | - /* @todo , [link to file] */ |
|
76 | - ); |
|
60 | + /** |
|
61 | + * @param string $search |
|
62 | + * @param IComment $comment |
|
63 | + * @param string $authorName |
|
64 | + * @param string $path |
|
65 | + * @throws NotFoundException |
|
66 | + * @deprecated 20.0.0 |
|
67 | + */ |
|
68 | + public function __construct(string $search, |
|
69 | + IComment $comment, |
|
70 | + string $authorName, |
|
71 | + string $path) { |
|
72 | + parent::__construct( |
|
73 | + (int) $comment->getId(), |
|
74 | + $comment->getMessage() |
|
75 | + /* @todo , [link to file] */ |
|
76 | + ); |
|
77 | 77 | |
78 | - $this->comment = $this->getRelevantMessagePart($comment->getMessage(), $search); |
|
79 | - $this->authorId = $comment->getActorId(); |
|
80 | - $this->authorName = $authorName; |
|
81 | - $this->fileName = basename($path); |
|
82 | - $this->path = $this->getVisiblePath($path); |
|
83 | - } |
|
78 | + $this->comment = $this->getRelevantMessagePart($comment->getMessage(), $search); |
|
79 | + $this->authorId = $comment->getActorId(); |
|
80 | + $this->authorName = $authorName; |
|
81 | + $this->fileName = basename($path); |
|
82 | + $this->path = $this->getVisiblePath($path); |
|
83 | + } |
|
84 | 84 | |
85 | - /** |
|
86 | - * @param string $path |
|
87 | - * @return string |
|
88 | - * @throws NotFoundException |
|
89 | - */ |
|
90 | - protected function getVisiblePath(string $path): string { |
|
91 | - $segments = explode('/', trim($path, '/'), 3); |
|
85 | + /** |
|
86 | + * @param string $path |
|
87 | + * @return string |
|
88 | + * @throws NotFoundException |
|
89 | + */ |
|
90 | + protected function getVisiblePath(string $path): string { |
|
91 | + $segments = explode('/', trim($path, '/'), 3); |
|
92 | 92 | |
93 | - if (!isset($segments[2])) { |
|
94 | - throw new NotFoundException('Path not inside visible section'); |
|
95 | - } |
|
93 | + if (!isset($segments[2])) { |
|
94 | + throw new NotFoundException('Path not inside visible section'); |
|
95 | + } |
|
96 | 96 | |
97 | - return $segments[2]; |
|
98 | - } |
|
97 | + return $segments[2]; |
|
98 | + } |
|
99 | 99 | |
100 | - /** |
|
101 | - * @param string $message |
|
102 | - * @param string $search |
|
103 | - * @return string |
|
104 | - * @throws NotFoundException |
|
105 | - */ |
|
106 | - protected function getRelevantMessagePart(string $message, string $search): string { |
|
107 | - $start = mb_stripos($message, $search); |
|
108 | - if ($start === false) { |
|
109 | - throw new NotFoundException('Comment section not found'); |
|
110 | - } |
|
100 | + /** |
|
101 | + * @param string $message |
|
102 | + * @param string $search |
|
103 | + * @return string |
|
104 | + * @throws NotFoundException |
|
105 | + */ |
|
106 | + protected function getRelevantMessagePart(string $message, string $search): string { |
|
107 | + $start = mb_stripos($message, $search); |
|
108 | + if ($start === false) { |
|
109 | + throw new NotFoundException('Comment section not found'); |
|
110 | + } |
|
111 | 111 | |
112 | - $end = $start + mb_strlen($search); |
|
112 | + $end = $start + mb_strlen($search); |
|
113 | 113 | |
114 | - if ($start <= 25) { |
|
115 | - $start = 0; |
|
116 | - $prefix = ''; |
|
117 | - } else { |
|
118 | - $start -= 25; |
|
119 | - $prefix = '…'; |
|
120 | - } |
|
114 | + if ($start <= 25) { |
|
115 | + $start = 0; |
|
116 | + $prefix = ''; |
|
117 | + } else { |
|
118 | + $start -= 25; |
|
119 | + $prefix = '…'; |
|
120 | + } |
|
121 | 121 | |
122 | - if ((mb_strlen($message) - $end) <= 25) { |
|
123 | - $end = mb_strlen($message); |
|
124 | - $suffix = ''; |
|
125 | - } else { |
|
126 | - $end += 25; |
|
127 | - $suffix = '…'; |
|
128 | - } |
|
122 | + if ((mb_strlen($message) - $end) <= 25) { |
|
123 | + $end = mb_strlen($message); |
|
124 | + $suffix = ''; |
|
125 | + } else { |
|
126 | + $end += 25; |
|
127 | + $suffix = '…'; |
|
128 | + } |
|
129 | 129 | |
130 | - return $prefix . mb_substr($message, $start, $end - $start) . $suffix; |
|
131 | - } |
|
130 | + return $prefix . mb_substr($message, $start, $end - $start) . $suffix; |
|
131 | + } |
|
132 | 132 | } |
@@ -36,46 +36,46 @@ |
||
36 | 36 | |
37 | 37 | class Provider implements IProvider { |
38 | 38 | |
39 | - /** @var IL10N */ |
|
40 | - private $l10n; |
|
39 | + /** @var IL10N */ |
|
40 | + private $l10n; |
|
41 | 41 | |
42 | - /** @var IURLGenerator */ |
|
43 | - private $urlGenerator; |
|
42 | + /** @var IURLGenerator */ |
|
43 | + private $urlGenerator; |
|
44 | 44 | |
45 | - /** @var LegacyProvider */ |
|
46 | - private $legacyProvider; |
|
45 | + /** @var LegacyProvider */ |
|
46 | + private $legacyProvider; |
|
47 | 47 | |
48 | - public function __construct(IL10N $l10n, |
|
49 | - IURLGenerator $urlGenerator, |
|
50 | - LegacyProvider $legacyProvider) { |
|
51 | - $this->l10n = $l10n; |
|
52 | - $this->urlGenerator = $urlGenerator; |
|
53 | - $this->legacyProvider = $legacyProvider; |
|
54 | - } |
|
48 | + public function __construct(IL10N $l10n, |
|
49 | + IURLGenerator $urlGenerator, |
|
50 | + LegacyProvider $legacyProvider) { |
|
51 | + $this->l10n = $l10n; |
|
52 | + $this->urlGenerator = $urlGenerator; |
|
53 | + $this->legacyProvider = $legacyProvider; |
|
54 | + } |
|
55 | 55 | |
56 | - public function getId(): string { |
|
57 | - return 'comments'; |
|
58 | - } |
|
56 | + public function getId(): string { |
|
57 | + return 'comments'; |
|
58 | + } |
|
59 | 59 | |
60 | - public function search(IUser $user, ISearchQuery $query): SearchResult { |
|
61 | - return SearchResult::complete( |
|
62 | - $this->l10n->t('Comments'), |
|
63 | - array_map(function (Result $result) { |
|
64 | - $path = $result->path; |
|
65 | - $pathInfo = pathinfo($path); |
|
66 | - return new CommentsSearchResultEntry( |
|
67 | - $this->urlGenerator->linkToRoute('core.Preview.getPreviewByFileId', ['x' => 32, 'y' => 32, 'fileId' => $result->id]), |
|
68 | - $result->name, |
|
69 | - $path, |
|
70 | - $this->urlGenerator->linkToRoute( |
|
71 | - 'files.view.index', |
|
72 | - [ |
|
73 | - 'dir' => $pathInfo['dirname'], |
|
74 | - 'scrollto' => $pathInfo['basename'], |
|
75 | - ] |
|
76 | - ) |
|
77 | - ); |
|
78 | - }, $this->legacyProvider->search($query->getTerm())) |
|
79 | - ); |
|
80 | - } |
|
60 | + public function search(IUser $user, ISearchQuery $query): SearchResult { |
|
61 | + return SearchResult::complete( |
|
62 | + $this->l10n->t('Comments'), |
|
63 | + array_map(function (Result $result) { |
|
64 | + $path = $result->path; |
|
65 | + $pathInfo = pathinfo($path); |
|
66 | + return new CommentsSearchResultEntry( |
|
67 | + $this->urlGenerator->linkToRoute('core.Preview.getPreviewByFileId', ['x' => 32, 'y' => 32, 'fileId' => $result->id]), |
|
68 | + $result->name, |
|
69 | + $path, |
|
70 | + $this->urlGenerator->linkToRoute( |
|
71 | + 'files.view.index', |
|
72 | + [ |
|
73 | + 'dir' => $pathInfo['dirname'], |
|
74 | + 'scrollto' => $pathInfo['basename'], |
|
75 | + ] |
|
76 | + ) |
|
77 | + ); |
|
78 | + }, $this->legacyProvider->search($query->getTerm())) |
|
79 | + ); |
|
80 | + } |
|
81 | 81 | } |
@@ -58,126 +58,126 @@ |
||
58 | 58 | use OCP\Util; |
59 | 59 | |
60 | 60 | class Application extends App implements IBootstrap { |
61 | - public const APP_ID = 'files'; |
|
62 | - |
|
63 | - public function __construct(array $urlParams=[]) { |
|
64 | - parent::__construct(self::APP_ID, $urlParams); |
|
65 | - } |
|
66 | - |
|
67 | - public function register(IRegistrationContext $context): void { |
|
68 | - /** |
|
69 | - * Controllers |
|
70 | - */ |
|
71 | - $context->registerService('APIController', function (IContainer $c) { |
|
72 | - /** @var IServerContainer $server */ |
|
73 | - $server = $c->query(IServerContainer::class); |
|
74 | - |
|
75 | - return new ApiController( |
|
76 | - $c->query('AppName'), |
|
77 | - $c->query('Request'), |
|
78 | - $server->getUserSession(), |
|
79 | - $c->query('TagService'), |
|
80 | - $server->getPreviewManager(), |
|
81 | - $server->getShareManager(), |
|
82 | - $server->getConfig(), |
|
83 | - $server->getUserFolder() |
|
84 | - ); |
|
85 | - }); |
|
86 | - |
|
87 | - /** |
|
88 | - * Services |
|
89 | - */ |
|
90 | - $context->registerService('TagService', function (IContainer $c) { |
|
91 | - /** @var IServerContainer $server */ |
|
92 | - $server = $c->query(IServerContainer::class); |
|
93 | - |
|
94 | - return new TagService( |
|
95 | - $server->getUserSession(), |
|
96 | - $server->getActivityManager(), |
|
97 | - $server->getTagManager()->load(self::APP_ID), |
|
98 | - $server->getUserFolder(), |
|
99 | - $server->getEventDispatcher() |
|
100 | - ); |
|
101 | - }); |
|
102 | - |
|
103 | - /* |
|
61 | + public const APP_ID = 'files'; |
|
62 | + |
|
63 | + public function __construct(array $urlParams=[]) { |
|
64 | + parent::__construct(self::APP_ID, $urlParams); |
|
65 | + } |
|
66 | + |
|
67 | + public function register(IRegistrationContext $context): void { |
|
68 | + /** |
|
69 | + * Controllers |
|
70 | + */ |
|
71 | + $context->registerService('APIController', function (IContainer $c) { |
|
72 | + /** @var IServerContainer $server */ |
|
73 | + $server = $c->query(IServerContainer::class); |
|
74 | + |
|
75 | + return new ApiController( |
|
76 | + $c->query('AppName'), |
|
77 | + $c->query('Request'), |
|
78 | + $server->getUserSession(), |
|
79 | + $c->query('TagService'), |
|
80 | + $server->getPreviewManager(), |
|
81 | + $server->getShareManager(), |
|
82 | + $server->getConfig(), |
|
83 | + $server->getUserFolder() |
|
84 | + ); |
|
85 | + }); |
|
86 | + |
|
87 | + /** |
|
88 | + * Services |
|
89 | + */ |
|
90 | + $context->registerService('TagService', function (IContainer $c) { |
|
91 | + /** @var IServerContainer $server */ |
|
92 | + $server = $c->query(IServerContainer::class); |
|
93 | + |
|
94 | + return new TagService( |
|
95 | + $server->getUserSession(), |
|
96 | + $server->getActivityManager(), |
|
97 | + $server->getTagManager()->load(self::APP_ID), |
|
98 | + $server->getUserFolder(), |
|
99 | + $server->getEventDispatcher() |
|
100 | + ); |
|
101 | + }); |
|
102 | + |
|
103 | + /* |
|
104 | 104 | * Register capabilities |
105 | 105 | */ |
106 | - $context->registerCapability(Capabilities::class); |
|
107 | - |
|
108 | - $context->registerEventListener(LoadAdditionalScriptsEvent::class, LegacyLoadAdditionalScriptsAdapter::class); |
|
109 | - $context->registerEventListener(LoadSidebar::class, LoadSidebarListener::class); |
|
110 | - |
|
111 | - $context->registerSearchProvider(FilesSearchProvider::class); |
|
112 | - } |
|
113 | - |
|
114 | - public function boot(IBootContext $context): void { |
|
115 | - $this->registerCollaboration($context); |
|
116 | - Listener::register($context->getServerContainer()->getEventDispatcher()); |
|
117 | - $this->registerNotification($context); |
|
118 | - $this->registerSearchProvider($context); |
|
119 | - $this->registerTemplates(); |
|
120 | - $this->registerNavigation($context); |
|
121 | - $this->registerHooks(); |
|
122 | - } |
|
123 | - |
|
124 | - /** |
|
125 | - * Register Collaboration ResourceProvider |
|
126 | - */ |
|
127 | - private function registerCollaboration(IBootContext $context): void { |
|
128 | - /** @var IProviderManager $providerManager */ |
|
129 | - $providerManager = $context->getAppContainer()->query(IProviderManager::class); |
|
130 | - $providerManager->registerResourceProvider(ResourceProvider::class); |
|
131 | - } |
|
132 | - |
|
133 | - private function registerNotification(IBootContext $context): void { |
|
134 | - /** @var IManager $notifications */ |
|
135 | - $notifications = $context->getAppContainer()->query(IManager::class); |
|
136 | - $notifications->registerNotifierService(Notifier::class); |
|
137 | - } |
|
138 | - |
|
139 | - /** |
|
140 | - * @param IBootContext $context |
|
141 | - */ |
|
142 | - private function registerSearchProvider(IBootContext $context): void { |
|
143 | - $context->getServerContainer()->getSearch()->registerProvider(File::class, ['apps' => ['files']]); |
|
144 | - } |
|
145 | - |
|
146 | - private function registerTemplates(): void { |
|
147 | - $templateManager = \OC_Helper::getFileTemplateManager(); |
|
148 | - $templateManager->registerTemplate('application/vnd.oasis.opendocument.presentation', 'core/templates/filetemplates/template.odp'); |
|
149 | - $templateManager->registerTemplate('application/vnd.oasis.opendocument.text', 'core/templates/filetemplates/template.odt'); |
|
150 | - $templateManager->registerTemplate('application/vnd.oasis.opendocument.spreadsheet', 'core/templates/filetemplates/template.ods'); |
|
151 | - } |
|
152 | - |
|
153 | - private function registerNavigation(IBootContext $context): void { |
|
154 | - /** @var IL10N $l10n */ |
|
155 | - $l10n = $context->getAppContainer()->query(IL10N::class); |
|
156 | - \OCA\Files\App::getNavigationManager()->add([ |
|
157 | - 'id' => 'files', |
|
158 | - 'appname' => 'files', |
|
159 | - 'script' => 'list.php', |
|
160 | - 'order' => 0, |
|
161 | - 'name' => $l10n->t('All files') |
|
162 | - ]); |
|
163 | - \OCA\Files\App::getNavigationManager()->add([ |
|
164 | - 'id' => 'recent', |
|
165 | - 'appname' => 'files', |
|
166 | - 'script' => 'recentlist.php', |
|
167 | - 'order' => 2, |
|
168 | - 'name' => $l10n->t('Recent') |
|
169 | - ]); |
|
170 | - \OCA\Files\App::getNavigationManager()->add([ |
|
171 | - 'id' => 'favorites', |
|
172 | - 'appname' => 'files', |
|
173 | - 'script' => 'simplelist.php', |
|
174 | - 'order' => 5, |
|
175 | - 'name' => $l10n->t('Favorites'), |
|
176 | - 'expandedState' => 'show_Quick_Access' |
|
177 | - ]); |
|
178 | - } |
|
179 | - |
|
180 | - private function registerHooks(): void { |
|
181 | - Util::connectHook('\OCP\Config', 'js', '\OCA\Files\App', 'extendJsConfig'); |
|
182 | - } |
|
106 | + $context->registerCapability(Capabilities::class); |
|
107 | + |
|
108 | + $context->registerEventListener(LoadAdditionalScriptsEvent::class, LegacyLoadAdditionalScriptsAdapter::class); |
|
109 | + $context->registerEventListener(LoadSidebar::class, LoadSidebarListener::class); |
|
110 | + |
|
111 | + $context->registerSearchProvider(FilesSearchProvider::class); |
|
112 | + } |
|
113 | + |
|
114 | + public function boot(IBootContext $context): void { |
|
115 | + $this->registerCollaboration($context); |
|
116 | + Listener::register($context->getServerContainer()->getEventDispatcher()); |
|
117 | + $this->registerNotification($context); |
|
118 | + $this->registerSearchProvider($context); |
|
119 | + $this->registerTemplates(); |
|
120 | + $this->registerNavigation($context); |
|
121 | + $this->registerHooks(); |
|
122 | + } |
|
123 | + |
|
124 | + /** |
|
125 | + * Register Collaboration ResourceProvider |
|
126 | + */ |
|
127 | + private function registerCollaboration(IBootContext $context): void { |
|
128 | + /** @var IProviderManager $providerManager */ |
|
129 | + $providerManager = $context->getAppContainer()->query(IProviderManager::class); |
|
130 | + $providerManager->registerResourceProvider(ResourceProvider::class); |
|
131 | + } |
|
132 | + |
|
133 | + private function registerNotification(IBootContext $context): void { |
|
134 | + /** @var IManager $notifications */ |
|
135 | + $notifications = $context->getAppContainer()->query(IManager::class); |
|
136 | + $notifications->registerNotifierService(Notifier::class); |
|
137 | + } |
|
138 | + |
|
139 | + /** |
|
140 | + * @param IBootContext $context |
|
141 | + */ |
|
142 | + private function registerSearchProvider(IBootContext $context): void { |
|
143 | + $context->getServerContainer()->getSearch()->registerProvider(File::class, ['apps' => ['files']]); |
|
144 | + } |
|
145 | + |
|
146 | + private function registerTemplates(): void { |
|
147 | + $templateManager = \OC_Helper::getFileTemplateManager(); |
|
148 | + $templateManager->registerTemplate('application/vnd.oasis.opendocument.presentation', 'core/templates/filetemplates/template.odp'); |
|
149 | + $templateManager->registerTemplate('application/vnd.oasis.opendocument.text', 'core/templates/filetemplates/template.odt'); |
|
150 | + $templateManager->registerTemplate('application/vnd.oasis.opendocument.spreadsheet', 'core/templates/filetemplates/template.ods'); |
|
151 | + } |
|
152 | + |
|
153 | + private function registerNavigation(IBootContext $context): void { |
|
154 | + /** @var IL10N $l10n */ |
|
155 | + $l10n = $context->getAppContainer()->query(IL10N::class); |
|
156 | + \OCA\Files\App::getNavigationManager()->add([ |
|
157 | + 'id' => 'files', |
|
158 | + 'appname' => 'files', |
|
159 | + 'script' => 'list.php', |
|
160 | + 'order' => 0, |
|
161 | + 'name' => $l10n->t('All files') |
|
162 | + ]); |
|
163 | + \OCA\Files\App::getNavigationManager()->add([ |
|
164 | + 'id' => 'recent', |
|
165 | + 'appname' => 'files', |
|
166 | + 'script' => 'recentlist.php', |
|
167 | + 'order' => 2, |
|
168 | + 'name' => $l10n->t('Recent') |
|
169 | + ]); |
|
170 | + \OCA\Files\App::getNavigationManager()->add([ |
|
171 | + 'id' => 'favorites', |
|
172 | + 'appname' => 'files', |
|
173 | + 'script' => 'simplelist.php', |
|
174 | + 'order' => 5, |
|
175 | + 'name' => $l10n->t('Favorites'), |
|
176 | + 'expandedState' => 'show_Quick_Access' |
|
177 | + ]); |
|
178 | + } |
|
179 | + |
|
180 | + private function registerHooks(): void { |
|
181 | + Util::connectHook('\OCP\Config', 'js', '\OCA\Files\App', 'extendJsConfig'); |
|
182 | + } |
|
183 | 183 | } |
@@ -28,10 +28,10 @@ |
||
28 | 28 | use OCP\Search\ASearchResultEntry; |
29 | 29 | |
30 | 30 | class FilesSearchResultEntry extends ASearchResultEntry { |
31 | - public function __construct(string $thumbnailUrl, |
|
32 | - string $filename, |
|
33 | - string $path, |
|
34 | - string $url) { |
|
35 | - parent::__construct($thumbnailUrl, $filename, $path, $url); |
|
36 | - } |
|
31 | + public function __construct(string $thumbnailUrl, |
|
32 | + string $filename, |
|
33 | + string $path, |
|
34 | + string $url) { |
|
35 | + parent::__construct($thumbnailUrl, $filename, $path, $url); |
|
36 | + } |
|
37 | 37 | } |
@@ -36,38 +36,38 @@ |
||
36 | 36 | |
37 | 37 | class FilesSearchProvider implements IProvider { |
38 | 38 | |
39 | - /** @var File */ |
|
40 | - private $fileSearch; |
|
39 | + /** @var File */ |
|
40 | + private $fileSearch; |
|
41 | 41 | |
42 | - /** @var IL10N */ |
|
43 | - private $l10n; |
|
42 | + /** @var IL10N */ |
|
43 | + private $l10n; |
|
44 | 44 | |
45 | - /** @var IURLGenerator */ |
|
46 | - private $urlGenerator; |
|
45 | + /** @var IURLGenerator */ |
|
46 | + private $urlGenerator; |
|
47 | 47 | |
48 | - public function __construct(File $fileSearch, |
|
49 | - IL10N $l10n, |
|
50 | - IURLGenerator $urlGenerator) { |
|
51 | - $this->l10n = $l10n; |
|
52 | - $this->fileSearch = $fileSearch; |
|
53 | - $this->urlGenerator = $urlGenerator; |
|
54 | - } |
|
48 | + public function __construct(File $fileSearch, |
|
49 | + IL10N $l10n, |
|
50 | + IURLGenerator $urlGenerator) { |
|
51 | + $this->l10n = $l10n; |
|
52 | + $this->fileSearch = $fileSearch; |
|
53 | + $this->urlGenerator = $urlGenerator; |
|
54 | + } |
|
55 | 55 | |
56 | - public function getId(): string { |
|
57 | - return 'files'; |
|
58 | - } |
|
56 | + public function getId(): string { |
|
57 | + return 'files'; |
|
58 | + } |
|
59 | 59 | |
60 | - public function search(IUser $user, ISearchQuery $query): SearchResult { |
|
61 | - return SearchResult::complete( |
|
62 | - $this->l10n->t('Files'), |
|
63 | - array_map(function (FileResult $result) { |
|
64 | - return new FilesSearchResultEntry( |
|
65 | - $this->urlGenerator->linkToRoute('core.Preview.getPreviewByFileId', ['x' => 32, 'y' => 32, 'fileId' => $result->id]), |
|
66 | - $result->name, |
|
67 | - $result->path, |
|
68 | - $result->link |
|
69 | - ); |
|
70 | - }, $this->fileSearch->search($query->getTerm())) |
|
71 | - ); |
|
72 | - } |
|
60 | + public function search(IUser $user, ISearchQuery $query): SearchResult { |
|
61 | + return SearchResult::complete( |
|
62 | + $this->l10n->t('Files'), |
|
63 | + array_map(function (FileResult $result) { |
|
64 | + return new FilesSearchResultEntry( |
|
65 | + $this->urlGenerator->linkToRoute('core.Preview.getPreviewByFileId', ['x' => 32, 'y' => 32, 'fileId' => $result->id]), |
|
66 | + $result->name, |
|
67 | + $result->path, |
|
68 | + $result->link |
|
69 | + ); |
|
70 | + }, $this->fileSearch->search($query->getTerm())) |
|
71 | + ); |
|
72 | + } |
|
73 | 73 | } |
@@ -37,85 +37,85 @@ discard block |
||
37 | 37 | /** @var Application $application */ |
38 | 38 | $application = \OC::$server->query(Application::class); |
39 | 39 | $application->registerRoutes($this, [ |
40 | - 'routes' => [ |
|
41 | - ['name' => 'lost#email', 'url' => '/lostpassword/email', 'verb' => 'POST'], |
|
42 | - ['name' => 'lost#resetform', 'url' => '/lostpassword/reset/form/{token}/{userId}', 'verb' => 'GET'], |
|
43 | - ['name' => 'lost#setPassword', 'url' => '/lostpassword/set/{token}/{userId}', 'verb' => 'POST'], |
|
44 | - ['name' => 'user#getDisplayNames', 'url' => '/displaynames', 'verb' => 'POST'], |
|
45 | - ['name' => 'avatar#getAvatar', 'url' => '/avatar/{userId}/{size}', 'verb' => 'GET'], |
|
46 | - ['name' => 'avatar#deleteAvatar', 'url' => '/avatar/', 'verb' => 'DELETE'], |
|
47 | - ['name' => 'avatar#postCroppedAvatar', 'url' => '/avatar/cropped', 'verb' => 'POST'], |
|
48 | - ['name' => 'avatar#getTmpAvatar', 'url' => '/avatar/tmp', 'verb' => 'GET'], |
|
49 | - ['name' => 'avatar#postAvatar', 'url' => '/avatar/', 'verb' => 'POST'], |
|
50 | - ['name' => 'GuestAvatar#getAvatar', 'url' => '/avatar/guest/{guestName}/{size}', 'verb' => 'GET'], |
|
51 | - ['name' => 'CSRFToken#index', 'url' => '/csrftoken', 'verb' => 'GET'], |
|
52 | - ['name' => 'login#tryLogin', 'url' => '/login', 'verb' => 'POST'], |
|
53 | - ['name' => 'login#confirmPassword', 'url' => '/login/confirm', 'verb' => 'POST'], |
|
54 | - ['name' => 'login#showLoginForm', 'url' => '/login', 'verb' => 'GET'], |
|
55 | - ['name' => 'login#logout', 'url' => '/logout', 'verb' => 'GET'], |
|
56 | - // Original login flow used by all clients |
|
57 | - ['name' => 'ClientFlowLogin#showAuthPickerPage', 'url' => '/login/flow', 'verb' => 'GET'], |
|
58 | - ['name' => 'ClientFlowLogin#generateAppPassword', 'url' => '/login/flow', 'verb' => 'POST'], |
|
59 | - ['name' => 'ClientFlowLogin#grantPage', 'url' => '/login/flow/grant', 'verb' => 'GET'], |
|
60 | - ['name' => 'ClientFlowLogin#apptokenRedirect', 'url' => '/login/flow/apptoken', 'verb' => 'POST'], |
|
61 | - // NG login flow used by desktop client in case of Kerberos/fancy 2fa (smart cards for example) |
|
62 | - ['name' => 'ClientFlowLoginV2#poll', 'url' => '/login/v2/poll', 'verb' => 'POST'], |
|
63 | - ['name' => 'ClientFlowLoginV2#showAuthPickerPage', 'url' => '/login/v2/flow', 'verb' => 'GET'], |
|
64 | - ['name' => 'ClientFlowLoginV2#landing', 'url' => '/login/v2/flow/{token}', 'verb' => 'GET'], |
|
65 | - ['name' => 'ClientFlowLoginV2#grantPage', 'url' => '/login/v2/grant', 'verb' => 'GET'], |
|
66 | - ['name' => 'ClientFlowLoginV2#generateAppPassword', 'url' => '/login/v2/grant', 'verb' => 'POST'], |
|
67 | - ['name' => 'ClientFlowLoginV2#init', 'url' => '/login/v2', 'verb' => 'POST'], |
|
68 | - ['name' => 'TwoFactorChallenge#selectChallenge', 'url' => '/login/selectchallenge', 'verb' => 'GET'], |
|
69 | - ['name' => 'TwoFactorChallenge#showChallenge', 'url' => '/login/challenge/{challengeProviderId}', 'verb' => 'GET'], |
|
70 | - ['name' => 'TwoFactorChallenge#solveChallenge', 'url' => '/login/challenge/{challengeProviderId}', 'verb' => 'POST'], |
|
71 | - ['name' => 'TwoFactorChallenge#setupProviders', 'url' => 'login/setupchallenge', 'verb' => 'GET'], |
|
72 | - ['name' => 'TwoFactorChallenge#setupProvider', 'url' => 'login/setupchallenge/{providerId}', 'verb' => 'GET'], |
|
73 | - ['name' => 'TwoFactorChallenge#confirmProviderSetup', 'url' => 'login/setupchallenge/{providerId}', 'verb' => 'POST'], |
|
74 | - ['name' => 'OCJS#getConfig', 'url' => '/core/js/oc.js', 'verb' => 'GET'], |
|
75 | - ['name' => 'Preview#getPreviewByFileId', 'url' => '/core/preview', 'verb' => 'GET'], |
|
76 | - ['name' => 'Preview#getPreview', 'url' => '/core/preview.png', 'verb' => 'GET'], |
|
77 | - ['name' => 'RecommendedApps#index', 'url' => '/core/apps/recommended', 'verb' => 'GET'], |
|
78 | - ['name' => 'Svg#getSvgFromCore', 'url' => '/svg/core/{folder}/{fileName}', 'verb' => 'GET'], |
|
79 | - ['name' => 'Svg#getSvgFromApp', 'url' => '/svg/{app}/{fileName}', 'verb' => 'GET'], |
|
80 | - ['name' => 'UnifiedSearch#getProviders', 'url' => '/search/providers', 'verb' => 'GET'], |
|
81 | - ['name' => 'UnifiedSearch#search', 'url' => '/search/providers/{providerId}/search', 'verb' => 'GET'], |
|
82 | - ['name' => 'Css#getCss', 'url' => '/css/{appName}/{fileName}', 'verb' => 'GET'], |
|
83 | - ['name' => 'Js#getJs', 'url' => '/js/{appName}/{fileName}', 'verb' => 'GET'], |
|
84 | - ['name' => 'contactsMenu#index', 'url' => '/contactsmenu/contacts', 'verb' => 'POST'], |
|
85 | - ['name' => 'contactsMenu#findOne', 'url' => '/contactsmenu/findOne', 'verb' => 'POST'], |
|
86 | - ['name' => 'WalledGarden#get', 'url' => '/204', 'verb' => 'GET'], |
|
87 | - ['name' => 'Search#search', 'url' => '/core/search', 'verb' => 'GET'], |
|
88 | - ['name' => 'Wipe#checkWipe', 'url' => '/core/wipe/check', 'verb' => 'POST'], |
|
89 | - ['name' => 'Wipe#wipeDone', 'url' => '/core/wipe/success', 'verb' => 'POST'], |
|
40 | + 'routes' => [ |
|
41 | + ['name' => 'lost#email', 'url' => '/lostpassword/email', 'verb' => 'POST'], |
|
42 | + ['name' => 'lost#resetform', 'url' => '/lostpassword/reset/form/{token}/{userId}', 'verb' => 'GET'], |
|
43 | + ['name' => 'lost#setPassword', 'url' => '/lostpassword/set/{token}/{userId}', 'verb' => 'POST'], |
|
44 | + ['name' => 'user#getDisplayNames', 'url' => '/displaynames', 'verb' => 'POST'], |
|
45 | + ['name' => 'avatar#getAvatar', 'url' => '/avatar/{userId}/{size}', 'verb' => 'GET'], |
|
46 | + ['name' => 'avatar#deleteAvatar', 'url' => '/avatar/', 'verb' => 'DELETE'], |
|
47 | + ['name' => 'avatar#postCroppedAvatar', 'url' => '/avatar/cropped', 'verb' => 'POST'], |
|
48 | + ['name' => 'avatar#getTmpAvatar', 'url' => '/avatar/tmp', 'verb' => 'GET'], |
|
49 | + ['name' => 'avatar#postAvatar', 'url' => '/avatar/', 'verb' => 'POST'], |
|
50 | + ['name' => 'GuestAvatar#getAvatar', 'url' => '/avatar/guest/{guestName}/{size}', 'verb' => 'GET'], |
|
51 | + ['name' => 'CSRFToken#index', 'url' => '/csrftoken', 'verb' => 'GET'], |
|
52 | + ['name' => 'login#tryLogin', 'url' => '/login', 'verb' => 'POST'], |
|
53 | + ['name' => 'login#confirmPassword', 'url' => '/login/confirm', 'verb' => 'POST'], |
|
54 | + ['name' => 'login#showLoginForm', 'url' => '/login', 'verb' => 'GET'], |
|
55 | + ['name' => 'login#logout', 'url' => '/logout', 'verb' => 'GET'], |
|
56 | + // Original login flow used by all clients |
|
57 | + ['name' => 'ClientFlowLogin#showAuthPickerPage', 'url' => '/login/flow', 'verb' => 'GET'], |
|
58 | + ['name' => 'ClientFlowLogin#generateAppPassword', 'url' => '/login/flow', 'verb' => 'POST'], |
|
59 | + ['name' => 'ClientFlowLogin#grantPage', 'url' => '/login/flow/grant', 'verb' => 'GET'], |
|
60 | + ['name' => 'ClientFlowLogin#apptokenRedirect', 'url' => '/login/flow/apptoken', 'verb' => 'POST'], |
|
61 | + // NG login flow used by desktop client in case of Kerberos/fancy 2fa (smart cards for example) |
|
62 | + ['name' => 'ClientFlowLoginV2#poll', 'url' => '/login/v2/poll', 'verb' => 'POST'], |
|
63 | + ['name' => 'ClientFlowLoginV2#showAuthPickerPage', 'url' => '/login/v2/flow', 'verb' => 'GET'], |
|
64 | + ['name' => 'ClientFlowLoginV2#landing', 'url' => '/login/v2/flow/{token}', 'verb' => 'GET'], |
|
65 | + ['name' => 'ClientFlowLoginV2#grantPage', 'url' => '/login/v2/grant', 'verb' => 'GET'], |
|
66 | + ['name' => 'ClientFlowLoginV2#generateAppPassword', 'url' => '/login/v2/grant', 'verb' => 'POST'], |
|
67 | + ['name' => 'ClientFlowLoginV2#init', 'url' => '/login/v2', 'verb' => 'POST'], |
|
68 | + ['name' => 'TwoFactorChallenge#selectChallenge', 'url' => '/login/selectchallenge', 'verb' => 'GET'], |
|
69 | + ['name' => 'TwoFactorChallenge#showChallenge', 'url' => '/login/challenge/{challengeProviderId}', 'verb' => 'GET'], |
|
70 | + ['name' => 'TwoFactorChallenge#solveChallenge', 'url' => '/login/challenge/{challengeProviderId}', 'verb' => 'POST'], |
|
71 | + ['name' => 'TwoFactorChallenge#setupProviders', 'url' => 'login/setupchallenge', 'verb' => 'GET'], |
|
72 | + ['name' => 'TwoFactorChallenge#setupProvider', 'url' => 'login/setupchallenge/{providerId}', 'verb' => 'GET'], |
|
73 | + ['name' => 'TwoFactorChallenge#confirmProviderSetup', 'url' => 'login/setupchallenge/{providerId}', 'verb' => 'POST'], |
|
74 | + ['name' => 'OCJS#getConfig', 'url' => '/core/js/oc.js', 'verb' => 'GET'], |
|
75 | + ['name' => 'Preview#getPreviewByFileId', 'url' => '/core/preview', 'verb' => 'GET'], |
|
76 | + ['name' => 'Preview#getPreview', 'url' => '/core/preview.png', 'verb' => 'GET'], |
|
77 | + ['name' => 'RecommendedApps#index', 'url' => '/core/apps/recommended', 'verb' => 'GET'], |
|
78 | + ['name' => 'Svg#getSvgFromCore', 'url' => '/svg/core/{folder}/{fileName}', 'verb' => 'GET'], |
|
79 | + ['name' => 'Svg#getSvgFromApp', 'url' => '/svg/{app}/{fileName}', 'verb' => 'GET'], |
|
80 | + ['name' => 'UnifiedSearch#getProviders', 'url' => '/search/providers', 'verb' => 'GET'], |
|
81 | + ['name' => 'UnifiedSearch#search', 'url' => '/search/providers/{providerId}/search', 'verb' => 'GET'], |
|
82 | + ['name' => 'Css#getCss', 'url' => '/css/{appName}/{fileName}', 'verb' => 'GET'], |
|
83 | + ['name' => 'Js#getJs', 'url' => '/js/{appName}/{fileName}', 'verb' => 'GET'], |
|
84 | + ['name' => 'contactsMenu#index', 'url' => '/contactsmenu/contacts', 'verb' => 'POST'], |
|
85 | + ['name' => 'contactsMenu#findOne', 'url' => '/contactsmenu/findOne', 'verb' => 'POST'], |
|
86 | + ['name' => 'WalledGarden#get', 'url' => '/204', 'verb' => 'GET'], |
|
87 | + ['name' => 'Search#search', 'url' => '/core/search', 'verb' => 'GET'], |
|
88 | + ['name' => 'Wipe#checkWipe', 'url' => '/core/wipe/check', 'verb' => 'POST'], |
|
89 | + ['name' => 'Wipe#wipeDone', 'url' => '/core/wipe/success', 'verb' => 'POST'], |
|
90 | 90 | |
91 | - // Logins for passwordless auth |
|
92 | - ['name' => 'WebAuthn#startAuthentication', 'url' => 'login/webauthn/start', 'verb' => 'POST'], |
|
93 | - ['name' => 'WebAuthn#finishAuthentication', 'url' => 'login/webauthn/finish', 'verb' => 'POST'], |
|
94 | - ], |
|
95 | - 'ocs' => [ |
|
96 | - ['root' => '/cloud', 'name' => 'OCS#getCapabilities', 'url' => '/capabilities', 'verb' => 'GET'], |
|
97 | - ['root' => '', 'name' => 'OCS#getConfig', 'url' => '/config', 'verb' => 'GET'], |
|
98 | - ['root' => '/person', 'name' => 'OCS#personCheck', 'url' => '/check', 'verb' => 'POST'], |
|
99 | - ['root' => '/identityproof', 'name' => 'OCS#getIdentityProof', 'url' => '/key/{cloudId}', 'verb' => 'GET'], |
|
100 | - ['root' => '/core', 'name' => 'Navigation#getAppsNavigation', 'url' => '/navigation/apps', 'verb' => 'GET'], |
|
101 | - ['root' => '/core', 'name' => 'Navigation#getSettingsNavigation', 'url' => '/navigation/settings', 'verb' => 'GET'], |
|
102 | - ['root' => '/core', 'name' => 'AutoComplete#get', 'url' => '/autocomplete/get', 'verb' => 'GET'], |
|
103 | - ['root' => '/core', 'name' => 'WhatsNew#get', 'url' => '/whatsnew', 'verb' => 'GET'], |
|
104 | - ['root' => '/core', 'name' => 'WhatsNew#dismiss', 'url' => '/whatsnew', 'verb' => 'POST'], |
|
105 | - ['root' => '/core', 'name' => 'AppPassword#getAppPassword', 'url' => '/getapppassword', 'verb' => 'GET'], |
|
106 | - ['root' => '/core', 'name' => 'AppPassword#rotateAppPassword', 'url' => '/apppassword/rotate', 'verb' => 'POST'], |
|
107 | - ['root' => '/core', 'name' => 'AppPassword#deleteAppPassword', 'url' => '/apppassword', 'verb' => 'DELETE'], |
|
91 | + // Logins for passwordless auth |
|
92 | + ['name' => 'WebAuthn#startAuthentication', 'url' => 'login/webauthn/start', 'verb' => 'POST'], |
|
93 | + ['name' => 'WebAuthn#finishAuthentication', 'url' => 'login/webauthn/finish', 'verb' => 'POST'], |
|
94 | + ], |
|
95 | + 'ocs' => [ |
|
96 | + ['root' => '/cloud', 'name' => 'OCS#getCapabilities', 'url' => '/capabilities', 'verb' => 'GET'], |
|
97 | + ['root' => '', 'name' => 'OCS#getConfig', 'url' => '/config', 'verb' => 'GET'], |
|
98 | + ['root' => '/person', 'name' => 'OCS#personCheck', 'url' => '/check', 'verb' => 'POST'], |
|
99 | + ['root' => '/identityproof', 'name' => 'OCS#getIdentityProof', 'url' => '/key/{cloudId}', 'verb' => 'GET'], |
|
100 | + ['root' => '/core', 'name' => 'Navigation#getAppsNavigation', 'url' => '/navigation/apps', 'verb' => 'GET'], |
|
101 | + ['root' => '/core', 'name' => 'Navigation#getSettingsNavigation', 'url' => '/navigation/settings', 'verb' => 'GET'], |
|
102 | + ['root' => '/core', 'name' => 'AutoComplete#get', 'url' => '/autocomplete/get', 'verb' => 'GET'], |
|
103 | + ['root' => '/core', 'name' => 'WhatsNew#get', 'url' => '/whatsnew', 'verb' => 'GET'], |
|
104 | + ['root' => '/core', 'name' => 'WhatsNew#dismiss', 'url' => '/whatsnew', 'verb' => 'POST'], |
|
105 | + ['root' => '/core', 'name' => 'AppPassword#getAppPassword', 'url' => '/getapppassword', 'verb' => 'GET'], |
|
106 | + ['root' => '/core', 'name' => 'AppPassword#rotateAppPassword', 'url' => '/apppassword/rotate', 'verb' => 'POST'], |
|
107 | + ['root' => '/core', 'name' => 'AppPassword#deleteAppPassword', 'url' => '/apppassword', 'verb' => 'DELETE'], |
|
108 | 108 | |
109 | - ['root' => '/collaboration', 'name' => 'CollaborationResources#searchCollections', 'url' => '/resources/collections/search/{filter}', 'verb' => 'GET'], |
|
110 | - ['root' => '/collaboration', 'name' => 'CollaborationResources#listCollection', 'url' => '/resources/collections/{collectionId}', 'verb' => 'GET'], |
|
111 | - ['root' => '/collaboration', 'name' => 'CollaborationResources#renameCollection', 'url' => '/resources/collections/{collectionId}', 'verb' => 'PUT'], |
|
112 | - ['root' => '/collaboration', 'name' => 'CollaborationResources#addResource', 'url' => '/resources/collections/{collectionId}', 'verb' => 'POST'], |
|
109 | + ['root' => '/collaboration', 'name' => 'CollaborationResources#searchCollections', 'url' => '/resources/collections/search/{filter}', 'verb' => 'GET'], |
|
110 | + ['root' => '/collaboration', 'name' => 'CollaborationResources#listCollection', 'url' => '/resources/collections/{collectionId}', 'verb' => 'GET'], |
|
111 | + ['root' => '/collaboration', 'name' => 'CollaborationResources#renameCollection', 'url' => '/resources/collections/{collectionId}', 'verb' => 'PUT'], |
|
112 | + ['root' => '/collaboration', 'name' => 'CollaborationResources#addResource', 'url' => '/resources/collections/{collectionId}', 'verb' => 'POST'], |
|
113 | 113 | |
114 | - ['root' => '/collaboration', 'name' => 'CollaborationResources#removeResource', 'url' => '/resources/collections/{collectionId}', 'verb' => 'DELETE'], |
|
115 | - ['root' => '/collaboration', 'name' => 'CollaborationResources#getCollectionsByResource', 'url' => '/resources/{resourceType}/{resourceId}', 'verb' => 'GET'], |
|
116 | - ['root' => '/collaboration', 'name' => 'CollaborationResources#createCollectionOnResource', 'url' => '/resources/{baseResourceType}/{baseResourceId}', 'verb' => 'POST'] |
|
114 | + ['root' => '/collaboration', 'name' => 'CollaborationResources#removeResource', 'url' => '/resources/collections/{collectionId}', 'verb' => 'DELETE'], |
|
115 | + ['root' => '/collaboration', 'name' => 'CollaborationResources#getCollectionsByResource', 'url' => '/resources/{resourceType}/{resourceId}', 'verb' => 'GET'], |
|
116 | + ['root' => '/collaboration', 'name' => 'CollaborationResources#createCollectionOnResource', 'url' => '/resources/{baseResourceType}/{baseResourceId}', 'verb' => 'POST'] |
|
117 | 117 | |
118 | - ], |
|
118 | + ], |
|
119 | 119 | ]); |
120 | 120 | |
121 | 121 | // Post installation check |
@@ -124,4 +124,4 @@ discard block |
||
124 | 124 | // Core ajax actions |
125 | 125 | // Routing |
126 | 126 | $this->create('core_ajax_update', '/core/ajax/update.php') |
127 | - ->actionInclude('core/ajax/update.php'); |
|
127 | + ->actionInclude('core/ajax/update.php'); |
@@ -36,63 +36,63 @@ |
||
36 | 36 | |
37 | 37 | class UnifiedSearchController extends Controller { |
38 | 38 | |
39 | - /** @var SearchComposer */ |
|
40 | - private $composer; |
|
39 | + /** @var SearchComposer */ |
|
40 | + private $composer; |
|
41 | 41 | |
42 | - /** @var IUserSession */ |
|
43 | - private $userSession; |
|
42 | + /** @var IUserSession */ |
|
43 | + private $userSession; |
|
44 | 44 | |
45 | - public function __construct(IRequest $request, |
|
46 | - IUserSession $userSession, |
|
47 | - SearchComposer $composer) { |
|
48 | - parent::__construct('core', $request); |
|
45 | + public function __construct(IRequest $request, |
|
46 | + IUserSession $userSession, |
|
47 | + SearchComposer $composer) { |
|
48 | + parent::__construct('core', $request); |
|
49 | 49 | |
50 | - $this->composer = $composer; |
|
51 | - $this->userSession = $userSession; |
|
52 | - } |
|
50 | + $this->composer = $composer; |
|
51 | + $this->userSession = $userSession; |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * @NoAdminRequired |
|
56 | - * @NoCSRFRequired |
|
57 | - */ |
|
58 | - public function getProviders(): JSONResponse { |
|
59 | - return new JSONResponse( |
|
60 | - $this->composer->getProviders() |
|
61 | - ); |
|
62 | - } |
|
54 | + /** |
|
55 | + * @NoAdminRequired |
|
56 | + * @NoCSRFRequired |
|
57 | + */ |
|
58 | + public function getProviders(): JSONResponse { |
|
59 | + return new JSONResponse( |
|
60 | + $this->composer->getProviders() |
|
61 | + ); |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * @NoAdminRequired |
|
66 | - * @NoCSRFRequired |
|
67 | - * |
|
68 | - * @param string $providerId |
|
69 | - * @param string $term |
|
70 | - * @param int|null $sortOrder |
|
71 | - * @param int|null $limit |
|
72 | - * @param int|string|null $cursor |
|
73 | - * |
|
74 | - * @return JSONResponse |
|
75 | - */ |
|
76 | - public function search(string $providerId, |
|
77 | - string $term = '', |
|
78 | - ?int $sortOrder = null, |
|
79 | - ?int $limit = null, |
|
80 | - $cursor = null): JSONResponse { |
|
81 | - if (empty($term)) { |
|
82 | - return new JSONResponse(null, Http::STATUS_BAD_REQUEST); |
|
83 | - } |
|
64 | + /** |
|
65 | + * @NoAdminRequired |
|
66 | + * @NoCSRFRequired |
|
67 | + * |
|
68 | + * @param string $providerId |
|
69 | + * @param string $term |
|
70 | + * @param int|null $sortOrder |
|
71 | + * @param int|null $limit |
|
72 | + * @param int|string|null $cursor |
|
73 | + * |
|
74 | + * @return JSONResponse |
|
75 | + */ |
|
76 | + public function search(string $providerId, |
|
77 | + string $term = '', |
|
78 | + ?int $sortOrder = null, |
|
79 | + ?int $limit = null, |
|
80 | + $cursor = null): JSONResponse { |
|
81 | + if (empty($term)) { |
|
82 | + return new JSONResponse(null, Http::STATUS_BAD_REQUEST); |
|
83 | + } |
|
84 | 84 | |
85 | - return new JSONResponse( |
|
86 | - $this->composer->search( |
|
87 | - $this->userSession->getUser(), |
|
88 | - $providerId, |
|
89 | - new SearchQuery( |
|
90 | - $term, |
|
91 | - $sortOrder ?? ISearchQuery::SORT_DATE_DESC, |
|
92 | - $limit ?? SearchQuery::LIMIT_DEFAULT, |
|
93 | - $cursor |
|
94 | - ) |
|
95 | - ) |
|
96 | - ); |
|
97 | - } |
|
85 | + return new JSONResponse( |
|
86 | + $this->composer->search( |
|
87 | + $this->userSession->getUser(), |
|
88 | + $providerId, |
|
89 | + new SearchQuery( |
|
90 | + $term, |
|
91 | + $sortOrder ?? ISearchQuery::SORT_DATE_DESC, |
|
92 | + $limit ?? SearchQuery::LIMIT_DEFAULT, |
|
93 | + $cursor |
|
94 | + ) |
|
95 | + ) |
|
96 | + ); |
|
97 | + } |
|
98 | 98 | } |