@@ -39,158 +39,158 @@ |
||
| 39 | 39 | |
| 40 | 40 | class PreviewController extends Controller { |
| 41 | 41 | |
| 42 | - /** @var string */ |
|
| 43 | - private $userId; |
|
| 44 | - |
|
| 45 | - /** @var IRootFolder */ |
|
| 46 | - private $root; |
|
| 47 | - |
|
| 48 | - /** @var IPreview */ |
|
| 49 | - private $preview; |
|
| 50 | - |
|
| 51 | - /** @var ITimeFactory */ |
|
| 52 | - private $timeFactory; |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * PreviewController constructor. |
|
| 56 | - * |
|
| 57 | - * @param string $appName |
|
| 58 | - * @param IRequest $request |
|
| 59 | - * @param IPreview $preview |
|
| 60 | - * @param IRootFolder $root |
|
| 61 | - * @param string $userId |
|
| 62 | - * @param ITimeFactory $timeFactory |
|
| 63 | - */ |
|
| 64 | - public function __construct(string $appName, |
|
| 65 | - IRequest $request, |
|
| 66 | - IPreview $preview, |
|
| 67 | - IRootFolder $root, |
|
| 68 | - string $userId, |
|
| 69 | - ITimeFactory $timeFactory |
|
| 70 | - ) { |
|
| 71 | - parent::__construct($appName, $request); |
|
| 72 | - |
|
| 73 | - $this->preview = $preview; |
|
| 74 | - $this->root = $root; |
|
| 75 | - $this->userId = $userId; |
|
| 76 | - $this->timeFactory = $timeFactory; |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - /** |
|
| 80 | - * @NoAdminRequired |
|
| 81 | - * @NoCSRFRequired |
|
| 82 | - * |
|
| 83 | - * @param string $file |
|
| 84 | - * @param int $x |
|
| 85 | - * @param int $y |
|
| 86 | - * @param bool $a |
|
| 87 | - * @param bool $forceIcon |
|
| 88 | - * @param string $mode |
|
| 89 | - * @return DataResponse|FileDisplayResponse |
|
| 90 | - */ |
|
| 91 | - public function getPreview ( |
|
| 92 | - string $file = '', |
|
| 93 | - int $x = 32, |
|
| 94 | - int $y = 32, |
|
| 95 | - bool $a = false, |
|
| 96 | - bool $forceIcon = true, |
|
| 97 | - string $mode = 'fill'): Http\Response { |
|
| 98 | - |
|
| 99 | - if ($file === '' || $x === 0 || $y === 0) { |
|
| 100 | - return new DataResponse([], Http::STATUS_BAD_REQUEST); |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - try { |
|
| 104 | - $userFolder = $this->root->getUserFolder($this->userId); |
|
| 105 | - $node = $userFolder->get($file); |
|
| 106 | - } catch (NotFoundException $e) { |
|
| 107 | - return new DataResponse([], Http::STATUS_NOT_FOUND); |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - return $this->fetchPreview($node, $x, $y, $a, $forceIcon, $mode); |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - /** |
|
| 114 | - * @NoAdminRequired |
|
| 115 | - * @NoCSRFRequired |
|
| 116 | - * |
|
| 117 | - * @param int $fileId |
|
| 118 | - * @param int $x |
|
| 119 | - * @param int $y |
|
| 120 | - * @param bool $a |
|
| 121 | - * @param bool $forceIcon |
|
| 122 | - * @param string $mode |
|
| 123 | - * |
|
| 124 | - * @return DataResponse|FileDisplayResponse |
|
| 125 | - */ |
|
| 126 | - public function getPreviewByFileId( |
|
| 127 | - int $fileId = -1, |
|
| 128 | - int $x = 32, |
|
| 129 | - int $y = 32, |
|
| 130 | - bool $a = false, |
|
| 131 | - bool $forceIcon = true, |
|
| 132 | - string $mode = 'fill') { |
|
| 133 | - |
|
| 134 | - if ($fileId === -1 || $x === 0 || $y === 0) { |
|
| 135 | - return new DataResponse([], Http::STATUS_BAD_REQUEST); |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - $userFolder = $this->root->getUserFolder($this->userId); |
|
| 139 | - $nodes = $userFolder->getById($fileId); |
|
| 140 | - |
|
| 141 | - if (\count($nodes) === 0) { |
|
| 142 | - return new DataResponse([], Http::STATUS_NOT_FOUND); |
|
| 143 | - } |
|
| 144 | - |
|
| 145 | - $node = array_pop($nodes); |
|
| 146 | - |
|
| 147 | - return $this->fetchPreview($node, $x, $y, $a, $forceIcon, $mode); |
|
| 148 | - } |
|
| 149 | - |
|
| 150 | - /** |
|
| 151 | - * @param Node $node |
|
| 152 | - * @param int $x |
|
| 153 | - * @param int $y |
|
| 154 | - * @param bool $a |
|
| 155 | - * @param bool $forceIcon |
|
| 156 | - * @param string $mode |
|
| 157 | - * @return DataResponse|FileDisplayResponse |
|
| 158 | - */ |
|
| 159 | - private function fetchPreview( |
|
| 160 | - Node $node, |
|
| 161 | - int $x, |
|
| 162 | - int $y, |
|
| 163 | - bool $a = false, |
|
| 164 | - bool $forceIcon = true, |
|
| 165 | - string $mode) : Http\Response { |
|
| 166 | - |
|
| 167 | - if (!($node instanceof File) || (!$forceIcon && !$this->preview->isAvailable($node))) { |
|
| 168 | - return new DataResponse([], Http::STATUS_NOT_FOUND); |
|
| 169 | - } |
|
| 170 | - if (!$node->isReadable()) { |
|
| 171 | - return new DataResponse([], Http::STATUS_FORBIDDEN); |
|
| 172 | - } |
|
| 173 | - |
|
| 174 | - try { |
|
| 175 | - $f = $this->preview->getPreview($node, $x, $y, !$a, $mode); |
|
| 176 | - $response = new FileDisplayResponse($f, Http::STATUS_OK, ['Content-Type' => $f->getMimeType()]); |
|
| 177 | - |
|
| 178 | - // Let cache this! |
|
| 179 | - $response->addHeader('Pragma', 'public'); |
|
| 180 | - |
|
| 181 | - // Cache previews for 24H |
|
| 182 | - $response->cacheFor(3600 * 24); |
|
| 183 | - $expires = new \DateTime(); |
|
| 184 | - $expires->setTimestamp($this->timeFactory->getTime()); |
|
| 185 | - $expires->add(new \DateInterval('P1D')); |
|
| 186 | - $response->addHeader('Expires', $expires->format(\DateTime::RFC2822)); |
|
| 187 | - |
|
| 188 | - return $response; |
|
| 189 | - } catch (NotFoundException $e) { |
|
| 190 | - return new DataResponse([], Http::STATUS_NOT_FOUND); |
|
| 191 | - } catch (\InvalidArgumentException $e) { |
|
| 192 | - return new DataResponse([], Http::STATUS_BAD_REQUEST); |
|
| 193 | - } |
|
| 194 | - |
|
| 195 | - } |
|
| 42 | + /** @var string */ |
|
| 43 | + private $userId; |
|
| 44 | + |
|
| 45 | + /** @var IRootFolder */ |
|
| 46 | + private $root; |
|
| 47 | + |
|
| 48 | + /** @var IPreview */ |
|
| 49 | + private $preview; |
|
| 50 | + |
|
| 51 | + /** @var ITimeFactory */ |
|
| 52 | + private $timeFactory; |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * PreviewController constructor. |
|
| 56 | + * |
|
| 57 | + * @param string $appName |
|
| 58 | + * @param IRequest $request |
|
| 59 | + * @param IPreview $preview |
|
| 60 | + * @param IRootFolder $root |
|
| 61 | + * @param string $userId |
|
| 62 | + * @param ITimeFactory $timeFactory |
|
| 63 | + */ |
|
| 64 | + public function __construct(string $appName, |
|
| 65 | + IRequest $request, |
|
| 66 | + IPreview $preview, |
|
| 67 | + IRootFolder $root, |
|
| 68 | + string $userId, |
|
| 69 | + ITimeFactory $timeFactory |
|
| 70 | + ) { |
|
| 71 | + parent::__construct($appName, $request); |
|
| 72 | + |
|
| 73 | + $this->preview = $preview; |
|
| 74 | + $this->root = $root; |
|
| 75 | + $this->userId = $userId; |
|
| 76 | + $this->timeFactory = $timeFactory; |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * @NoAdminRequired |
|
| 81 | + * @NoCSRFRequired |
|
| 82 | + * |
|
| 83 | + * @param string $file |
|
| 84 | + * @param int $x |
|
| 85 | + * @param int $y |
|
| 86 | + * @param bool $a |
|
| 87 | + * @param bool $forceIcon |
|
| 88 | + * @param string $mode |
|
| 89 | + * @return DataResponse|FileDisplayResponse |
|
| 90 | + */ |
|
| 91 | + public function getPreview ( |
|
| 92 | + string $file = '', |
|
| 93 | + int $x = 32, |
|
| 94 | + int $y = 32, |
|
| 95 | + bool $a = false, |
|
| 96 | + bool $forceIcon = true, |
|
| 97 | + string $mode = 'fill'): Http\Response { |
|
| 98 | + |
|
| 99 | + if ($file === '' || $x === 0 || $y === 0) { |
|
| 100 | + return new DataResponse([], Http::STATUS_BAD_REQUEST); |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + try { |
|
| 104 | + $userFolder = $this->root->getUserFolder($this->userId); |
|
| 105 | + $node = $userFolder->get($file); |
|
| 106 | + } catch (NotFoundException $e) { |
|
| 107 | + return new DataResponse([], Http::STATUS_NOT_FOUND); |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + return $this->fetchPreview($node, $x, $y, $a, $forceIcon, $mode); |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + /** |
|
| 114 | + * @NoAdminRequired |
|
| 115 | + * @NoCSRFRequired |
|
| 116 | + * |
|
| 117 | + * @param int $fileId |
|
| 118 | + * @param int $x |
|
| 119 | + * @param int $y |
|
| 120 | + * @param bool $a |
|
| 121 | + * @param bool $forceIcon |
|
| 122 | + * @param string $mode |
|
| 123 | + * |
|
| 124 | + * @return DataResponse|FileDisplayResponse |
|
| 125 | + */ |
|
| 126 | + public function getPreviewByFileId( |
|
| 127 | + int $fileId = -1, |
|
| 128 | + int $x = 32, |
|
| 129 | + int $y = 32, |
|
| 130 | + bool $a = false, |
|
| 131 | + bool $forceIcon = true, |
|
| 132 | + string $mode = 'fill') { |
|
| 133 | + |
|
| 134 | + if ($fileId === -1 || $x === 0 || $y === 0) { |
|
| 135 | + return new DataResponse([], Http::STATUS_BAD_REQUEST); |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + $userFolder = $this->root->getUserFolder($this->userId); |
|
| 139 | + $nodes = $userFolder->getById($fileId); |
|
| 140 | + |
|
| 141 | + if (\count($nodes) === 0) { |
|
| 142 | + return new DataResponse([], Http::STATUS_NOT_FOUND); |
|
| 143 | + } |
|
| 144 | + |
|
| 145 | + $node = array_pop($nodes); |
|
| 146 | + |
|
| 147 | + return $this->fetchPreview($node, $x, $y, $a, $forceIcon, $mode); |
|
| 148 | + } |
|
| 149 | + |
|
| 150 | + /** |
|
| 151 | + * @param Node $node |
|
| 152 | + * @param int $x |
|
| 153 | + * @param int $y |
|
| 154 | + * @param bool $a |
|
| 155 | + * @param bool $forceIcon |
|
| 156 | + * @param string $mode |
|
| 157 | + * @return DataResponse|FileDisplayResponse |
|
| 158 | + */ |
|
| 159 | + private function fetchPreview( |
|
| 160 | + Node $node, |
|
| 161 | + int $x, |
|
| 162 | + int $y, |
|
| 163 | + bool $a = false, |
|
| 164 | + bool $forceIcon = true, |
|
| 165 | + string $mode) : Http\Response { |
|
| 166 | + |
|
| 167 | + if (!($node instanceof File) || (!$forceIcon && !$this->preview->isAvailable($node))) { |
|
| 168 | + return new DataResponse([], Http::STATUS_NOT_FOUND); |
|
| 169 | + } |
|
| 170 | + if (!$node->isReadable()) { |
|
| 171 | + return new DataResponse([], Http::STATUS_FORBIDDEN); |
|
| 172 | + } |
|
| 173 | + |
|
| 174 | + try { |
|
| 175 | + $f = $this->preview->getPreview($node, $x, $y, !$a, $mode); |
|
| 176 | + $response = new FileDisplayResponse($f, Http::STATUS_OK, ['Content-Type' => $f->getMimeType()]); |
|
| 177 | + |
|
| 178 | + // Let cache this! |
|
| 179 | + $response->addHeader('Pragma', 'public'); |
|
| 180 | + |
|
| 181 | + // Cache previews for 24H |
|
| 182 | + $response->cacheFor(3600 * 24); |
|
| 183 | + $expires = new \DateTime(); |
|
| 184 | + $expires->setTimestamp($this->timeFactory->getTime()); |
|
| 185 | + $expires->add(new \DateInterval('P1D')); |
|
| 186 | + $response->addHeader('Expires', $expires->format(\DateTime::RFC2822)); |
|
| 187 | + |
|
| 188 | + return $response; |
|
| 189 | + } catch (NotFoundException $e) { |
|
| 190 | + return new DataResponse([], Http::STATUS_NOT_FOUND); |
|
| 191 | + } catch (\InvalidArgumentException $e) { |
|
| 192 | + return new DataResponse([], Http::STATUS_BAD_REQUEST); |
|
| 193 | + } |
|
| 194 | + |
|
| 195 | + } |
|
| 196 | 196 | } |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | /** |
| 4 | 4 | * @copyright Copyright (c) 2016, Roeland Jago Douma <[email protected]> |
| 5 | 5 | * |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | * @param string $mode |
| 89 | 89 | * @return DataResponse|FileDisplayResponse |
| 90 | 90 | */ |
| 91 | - public function getPreview ( |
|
| 91 | + public function getPreview( |
|
| 92 | 92 | string $file = '', |
| 93 | 93 | int $x = 32, |
| 94 | 94 | int $y = 32, |
@@ -36,42 +36,42 @@ discard block |
||
| 36 | 36 | |
| 37 | 37 | $application = new Application(); |
| 38 | 38 | $application->registerRoutes($this, [ |
| 39 | - 'routes' => [ |
|
| 40 | - ['name' => 'lost#email', 'url' => '/lostpassword/email', 'verb' => 'POST'], |
|
| 41 | - ['name' => 'lost#resetform', 'url' => '/lostpassword/reset/form/{token}/{userId}', 'verb' => 'GET'], |
|
| 42 | - ['name' => 'lost#setPassword', 'url' => '/lostpassword/set/{token}/{userId}', 'verb' => 'POST'], |
|
| 43 | - ['name' => 'user#getDisplayNames', 'url' => '/displaynames', 'verb' => 'POST'], |
|
| 44 | - ['name' => 'avatar#getAvatar', 'url' => '/avatar/{userId}/{size}', 'verb' => 'GET'], |
|
| 45 | - ['name' => 'avatar#deleteAvatar', 'url' => '/avatar/', 'verb' => 'DELETE'], |
|
| 46 | - ['name' => 'avatar#postCroppedAvatar', 'url' => '/avatar/cropped', 'verb' => 'POST'], |
|
| 47 | - ['name' => 'avatar#getTmpAvatar', 'url' => '/avatar/tmp', 'verb' => 'GET'], |
|
| 48 | - ['name' => 'avatar#postAvatar', 'url' => '/avatar/', 'verb' => 'POST'], |
|
| 49 | - ['name' => 'login#tryLogin', 'url' => '/login', 'verb' => 'POST'], |
|
| 50 | - ['name' => 'login#confirmPassword', 'url' => '/login/confirm', 'verb' => 'POST'], |
|
| 51 | - ['name' => 'login#showLoginForm', 'url' => '/login', 'verb' => 'GET'], |
|
| 52 | - ['name' => 'login#logout', 'url' => '/logout', 'verb' => 'GET'], |
|
| 53 | - ['name' => 'ClientFlowLogin#showAuthPickerPage', 'url' => '/login/flow', 'verb' => 'GET'], |
|
| 54 | - ['name' => 'ClientFlowLogin#redirectPage', 'url' => '/login/flow/redirect', 'verb' => 'GET'], |
|
| 55 | - ['name' => 'ClientFlowLogin#generateAppPassword', 'url' => '/login/flow', 'verb' => 'POST'], |
|
| 56 | - ['name' => 'TwoFactorChallenge#selectChallenge', 'url' => '/login/selectchallenge', 'verb' => 'GET'], |
|
| 57 | - ['name' => 'TwoFactorChallenge#showChallenge', 'url' => '/login/challenge/{challengeProviderId}', 'verb' => 'GET'], |
|
| 58 | - ['name' => 'TwoFactorChallenge#solveChallenge', 'url' => '/login/challenge/{challengeProviderId}', 'verb' => 'POST'], |
|
| 59 | - ['name' => 'OCJS#getConfig', 'url' => '/core/js/oc.js', 'verb' => 'GET'], |
|
| 60 | - ['name' => 'Preview#getPreviewByFileId', 'url' => '/core/preview', 'verb' => 'GET'], |
|
| 61 | - ['name' => 'Preview#getPreview', 'url' => '/core/preview.png', 'verb' => 'GET'], |
|
| 62 | - ['name' => 'Css#getCss', 'url' => '/css/{appName}/{fileName}', 'verb' => 'GET'], |
|
| 63 | - ['name' => 'Js#getJs', 'url' => '/js/{appName}/{fileName}', 'verb' => 'GET'], |
|
| 64 | - ['name' => 'contactsMenu#index', 'url' => '/contactsmenu/contacts', 'verb' => 'POST'], |
|
| 65 | - ['name' => 'contactsMenu#findOne', 'url' => '/contactsmenu/findOne', 'verb' => 'POST'], |
|
| 66 | - ['name' => 'AutoComplete#get', 'url' => 'autocomplete/get', 'verb' => 'GET'], |
|
| 67 | - ['name' => 'WalledGarden#get', 'url' => '/204', 'verb' => 'GET'], |
|
| 68 | - ], |
|
| 69 | - 'ocs' => [ |
|
| 70 | - ['root' => '/cloud', 'name' => 'OCS#getCapabilities', 'url' => '/capabilities', 'verb' => 'GET'], |
|
| 71 | - ['root' => '', 'name' => 'OCS#getConfig', 'url' => '/config', 'verb' => 'GET'], |
|
| 72 | - ['root' => '/person', 'name' => 'OCS#personCheck', 'url' => '/check', 'verb' => 'POST'], |
|
| 73 | - ['root' => '/identityproof', 'name' => 'OCS#getIdentityProof', 'url' => '/key/{cloudId}', 'verb' => 'GET'], |
|
| 74 | - ], |
|
| 39 | + 'routes' => [ |
|
| 40 | + ['name' => 'lost#email', 'url' => '/lostpassword/email', 'verb' => 'POST'], |
|
| 41 | + ['name' => 'lost#resetform', 'url' => '/lostpassword/reset/form/{token}/{userId}', 'verb' => 'GET'], |
|
| 42 | + ['name' => 'lost#setPassword', 'url' => '/lostpassword/set/{token}/{userId}', 'verb' => 'POST'], |
|
| 43 | + ['name' => 'user#getDisplayNames', 'url' => '/displaynames', 'verb' => 'POST'], |
|
| 44 | + ['name' => 'avatar#getAvatar', 'url' => '/avatar/{userId}/{size}', 'verb' => 'GET'], |
|
| 45 | + ['name' => 'avatar#deleteAvatar', 'url' => '/avatar/', 'verb' => 'DELETE'], |
|
| 46 | + ['name' => 'avatar#postCroppedAvatar', 'url' => '/avatar/cropped', 'verb' => 'POST'], |
|
| 47 | + ['name' => 'avatar#getTmpAvatar', 'url' => '/avatar/tmp', 'verb' => 'GET'], |
|
| 48 | + ['name' => 'avatar#postAvatar', 'url' => '/avatar/', 'verb' => 'POST'], |
|
| 49 | + ['name' => 'login#tryLogin', 'url' => '/login', 'verb' => 'POST'], |
|
| 50 | + ['name' => 'login#confirmPassword', 'url' => '/login/confirm', 'verb' => 'POST'], |
|
| 51 | + ['name' => 'login#showLoginForm', 'url' => '/login', 'verb' => 'GET'], |
|
| 52 | + ['name' => 'login#logout', 'url' => '/logout', 'verb' => 'GET'], |
|
| 53 | + ['name' => 'ClientFlowLogin#showAuthPickerPage', 'url' => '/login/flow', 'verb' => 'GET'], |
|
| 54 | + ['name' => 'ClientFlowLogin#redirectPage', 'url' => '/login/flow/redirect', 'verb' => 'GET'], |
|
| 55 | + ['name' => 'ClientFlowLogin#generateAppPassword', 'url' => '/login/flow', 'verb' => 'POST'], |
|
| 56 | + ['name' => 'TwoFactorChallenge#selectChallenge', 'url' => '/login/selectchallenge', 'verb' => 'GET'], |
|
| 57 | + ['name' => 'TwoFactorChallenge#showChallenge', 'url' => '/login/challenge/{challengeProviderId}', 'verb' => 'GET'], |
|
| 58 | + ['name' => 'TwoFactorChallenge#solveChallenge', 'url' => '/login/challenge/{challengeProviderId}', 'verb' => 'POST'], |
|
| 59 | + ['name' => 'OCJS#getConfig', 'url' => '/core/js/oc.js', 'verb' => 'GET'], |
|
| 60 | + ['name' => 'Preview#getPreviewByFileId', 'url' => '/core/preview', 'verb' => 'GET'], |
|
| 61 | + ['name' => 'Preview#getPreview', 'url' => '/core/preview.png', 'verb' => 'GET'], |
|
| 62 | + ['name' => 'Css#getCss', 'url' => '/css/{appName}/{fileName}', 'verb' => 'GET'], |
|
| 63 | + ['name' => 'Js#getJs', 'url' => '/js/{appName}/{fileName}', 'verb' => 'GET'], |
|
| 64 | + ['name' => 'contactsMenu#index', 'url' => '/contactsmenu/contacts', 'verb' => 'POST'], |
|
| 65 | + ['name' => 'contactsMenu#findOne', 'url' => '/contactsmenu/findOne', 'verb' => 'POST'], |
|
| 66 | + ['name' => 'AutoComplete#get', 'url' => 'autocomplete/get', 'verb' => 'GET'], |
|
| 67 | + ['name' => 'WalledGarden#get', 'url' => '/204', 'verb' => 'GET'], |
|
| 68 | + ], |
|
| 69 | + 'ocs' => [ |
|
| 70 | + ['root' => '/cloud', 'name' => 'OCS#getCapabilities', 'url' => '/capabilities', 'verb' => 'GET'], |
|
| 71 | + ['root' => '', 'name' => 'OCS#getConfig', 'url' => '/config', 'verb' => 'GET'], |
|
| 72 | + ['root' => '/person', 'name' => 'OCS#personCheck', 'url' => '/check', 'verb' => 'POST'], |
|
| 73 | + ['root' => '/identityproof', 'name' => 'OCS#getIdentityProof', 'url' => '/key/{cloudId}', 'verb' => 'GET'], |
|
| 74 | + ], |
|
| 75 | 75 | ]); |
| 76 | 76 | |
| 77 | 77 | // Post installation check |
@@ -80,15 +80,15 @@ discard block |
||
| 80 | 80 | // Core ajax actions |
| 81 | 81 | // Search |
| 82 | 82 | $this->create('search_ajax_search', '/core/search') |
| 83 | - ->actionInclude('core/search/ajax/search.php'); |
|
| 83 | + ->actionInclude('core/search/ajax/search.php'); |
|
| 84 | 84 | // Routing |
| 85 | 85 | $this->create('core_ajax_update', '/core/ajax/update.php') |
| 86 | - ->actionInclude('core/ajax/update.php'); |
|
| 86 | + ->actionInclude('core/ajax/update.php'); |
|
| 87 | 87 | |
| 88 | 88 | // File routes |
| 89 | 89 | $this->create('files.viewcontroller.showFile', '/f/{fileid}')->action(function($urlParams) { |
| 90 | - $app = new \OCA\Files\AppInfo\Application($urlParams); |
|
| 91 | - $app->dispatch('ViewController', 'index'); |
|
| 90 | + $app = new \OCA\Files\AppInfo\Application($urlParams); |
|
| 91 | + $app->dispatch('ViewController', 'index'); |
|
| 92 | 92 | }); |
| 93 | 93 | |
| 94 | 94 | // Call routes |
@@ -97,57 +97,57 @@ discard block |
||
| 97 | 97 | * @suppress PhanUndeclaredClassMethod |
| 98 | 98 | */ |
| 99 | 99 | $this->create('spreed.pagecontroller.showCall', '/call/{token}')->action(function($urlParams) { |
| 100 | - if (class_exists(\OCA\Spreed\AppInfo\Application::class, false)) { |
|
| 101 | - $app = new \OCA\Spreed\AppInfo\Application($urlParams); |
|
| 102 | - $app->dispatch('PageController', 'index'); |
|
| 103 | - } else { |
|
| 104 | - throw new \OC\HintException('App spreed is not enabled'); |
|
| 105 | - } |
|
| 100 | + if (class_exists(\OCA\Spreed\AppInfo\Application::class, false)) { |
|
| 101 | + $app = new \OCA\Spreed\AppInfo\Application($urlParams); |
|
| 102 | + $app->dispatch('PageController', 'index'); |
|
| 103 | + } else { |
|
| 104 | + throw new \OC\HintException('App spreed is not enabled'); |
|
| 105 | + } |
|
| 106 | 106 | }); |
| 107 | 107 | |
| 108 | 108 | // Sharing routes |
| 109 | 109 | $this->create('files_sharing.sharecontroller.showShare', '/s/{token}')->action(function($urlParams) { |
| 110 | - if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) { |
|
| 111 | - $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); |
|
| 112 | - $app->dispatch('ShareController', 'showShare'); |
|
| 113 | - } else { |
|
| 114 | - throw new \OC\HintException('App file sharing is not enabled'); |
|
| 115 | - } |
|
| 110 | + if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) { |
|
| 111 | + $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); |
|
| 112 | + $app->dispatch('ShareController', 'showShare'); |
|
| 113 | + } else { |
|
| 114 | + throw new \OC\HintException('App file sharing is not enabled'); |
|
| 115 | + } |
|
| 116 | 116 | }); |
| 117 | 117 | $this->create('files_sharing.sharecontroller.authenticate', '/s/{token}/authenticate')->post()->action(function($urlParams) { |
| 118 | - if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) { |
|
| 119 | - $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); |
|
| 120 | - $app->dispatch('ShareController', 'authenticate'); |
|
| 121 | - } else { |
|
| 122 | - throw new \OC\HintException('App file sharing is not enabled'); |
|
| 123 | - } |
|
| 118 | + if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) { |
|
| 119 | + $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); |
|
| 120 | + $app->dispatch('ShareController', 'authenticate'); |
|
| 121 | + } else { |
|
| 122 | + throw new \OC\HintException('App file sharing is not enabled'); |
|
| 123 | + } |
|
| 124 | 124 | }); |
| 125 | 125 | $this->create('files_sharing.sharecontroller.showAuthenticate', '/s/{token}/authenticate')->get()->action(function($urlParams) { |
| 126 | - if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) { |
|
| 127 | - $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); |
|
| 128 | - $app->dispatch('ShareController', 'showAuthenticate'); |
|
| 129 | - } else { |
|
| 130 | - throw new \OC\HintException('App file sharing is not enabled'); |
|
| 131 | - } |
|
| 126 | + if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) { |
|
| 127 | + $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); |
|
| 128 | + $app->dispatch('ShareController', 'showAuthenticate'); |
|
| 129 | + } else { |
|
| 130 | + throw new \OC\HintException('App file sharing is not enabled'); |
|
| 131 | + } |
|
| 132 | 132 | }); |
| 133 | 133 | $this->create('files_sharing.sharecontroller.downloadShare', '/s/{token}/download')->get()->action(function($urlParams) { |
| 134 | - if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) { |
|
| 135 | - $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); |
|
| 136 | - $app->dispatch('ShareController', 'downloadShare'); |
|
| 137 | - } else { |
|
| 138 | - throw new \OC\HintException('App file sharing is not enabled'); |
|
| 139 | - } |
|
| 134 | + if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) { |
|
| 135 | + $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); |
|
| 136 | + $app->dispatch('ShareController', 'downloadShare'); |
|
| 137 | + } else { |
|
| 138 | + throw new \OC\HintException('App file sharing is not enabled'); |
|
| 139 | + } |
|
| 140 | 140 | }); |
| 141 | 141 | $this->create('files_sharing.publicpreview.directLink', '/s/{token}/preview')->get()->action(function($urlParams) { |
| 142 | - if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) { |
|
| 143 | - $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); |
|
| 144 | - $app->dispatch('PublicPreviewController', 'directLink'); |
|
| 145 | - } else { |
|
| 146 | - throw new \OC\HintException('App file sharing is not enabled'); |
|
| 147 | - } |
|
| 142 | + if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) { |
|
| 143 | + $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); |
|
| 144 | + $app->dispatch('PublicPreviewController', 'directLink'); |
|
| 145 | + } else { |
|
| 146 | + throw new \OC\HintException('App file sharing is not enabled'); |
|
| 147 | + } |
|
| 148 | 148 | }); |
| 149 | 149 | |
| 150 | 150 | // used for heartbeat |
| 151 | 151 | $this->create('heartbeat', '/heartbeat')->action(function(){ |
| 152 | - // do nothing |
|
| 152 | + // do nothing |
|
| 153 | 153 | }); |