1 | <?php |
||
35 | trait Preview { |
||
36 | |||
37 | use HttpError; |
||
38 | |||
39 | /** @var IURLGenerator */ |
||
40 | private $urlGenerator; |
||
41 | /** @var ConfigService */ |
||
42 | private $configService; |
||
43 | /** @var ThumbnailService */ |
||
44 | private $thumbnailService; |
||
45 | /** @var PreviewService */ |
||
46 | private $previewService; |
||
47 | /** @var DownloadService */ |
||
48 | private $downloadService; |
||
49 | /** @var ILogger */ |
||
50 | private $logger; |
||
51 | /** @type bool */ |
||
52 | private $download = false; |
||
53 | |||
54 | /** |
||
55 | * Exits the controller in a live environment and throws an exception when testing |
||
56 | */ |
||
57 | 8 | protected function exitController() { |
|
66 | |||
67 | /** |
||
68 | * Retrieves the thumbnail to send back to the browser |
||
69 | * |
||
70 | * The thumbnail is either a resized preview of the file or the original file |
||
71 | * Thumbnails are base64encoded before getting sent back |
||
72 | * |
||
73 | * |
||
74 | * @param int $fileId the ID of the file of which we need a thumbnail preview of |
||
75 | * @param bool $square whether the thumbnail should be square |
||
76 | * @param double $scale whether we're allowed to scale the preview up |
||
77 | * |
||
78 | * @return array<string,array|string> |
||
79 | */ |
||
80 | 17 | private function getThumbnail($fileId, $square, $scale) { |
|
99 | |||
100 | /** |
||
101 | * Returns either a generated preview, the file as-is or an empty object |
||
102 | * |
||
103 | * @param int $fileId |
||
104 | * @param int $width |
||
105 | * @param int $height |
||
106 | * @param bool $keepAspect |
||
107 | * @param bool $animatedPreview |
||
108 | * @param bool $base64Encode |
||
109 | * |
||
110 | * @return array<string,\OC_Image|string> |
||
111 | * |
||
112 | * @throws NotFoundServiceException |
||
113 | */ |
||
114 | 33 | private function getData( |
|
134 | |||
135 | /** |
||
136 | * Returns the file of which a preview will be generated |
||
137 | * |
||
138 | * @param int $fileId |
||
139 | * |
||
140 | * @return array<File|int|null> |
||
141 | */ |
||
142 | 33 | private function getFile($fileId) { |
|
155 | |||
156 | /** |
||
157 | * @param File $file |
||
158 | * @param bool $animatedPreview |
||
159 | * @param int $width |
||
160 | * @param int $height |
||
161 | * @param bool $keepAspect |
||
162 | * @param bool $base64Encode |
||
163 | * |
||
164 | * @return array |
||
165 | */ |
||
166 | 28 | private function getPreviewData( |
|
185 | |||
186 | /** |
||
187 | * Returns an error array |
||
188 | * |
||
189 | * @param $status |
||
190 | * |
||
191 | * @return array<null|int|string> |
||
192 | */ |
||
193 | 19 | private function getErrorData($status = Http::STATUS_INTERNAL_SERVER_ERROR) { |
|
196 | |||
197 | /** |
||
198 | * Returns an error array |
||
199 | * |
||
200 | * @param ServiceException $exception |
||
201 | * |
||
202 | * @return array<null|int|string> |
||
203 | */ |
||
204 | 6 | private function getExceptionData($exception) { |
|
209 | |||
210 | /** |
||
211 | * Prepares an empty Thumbnail array to send back |
||
212 | * |
||
213 | * When we can't even get the file information, we send an empty mimeType |
||
214 | * |
||
215 | * @param File $file |
||
216 | * @param int $status |
||
217 | * |
||
218 | * @return array<string,null|string> |
||
219 | */ |
||
220 | 11 | private function prepareEmptyThumbnail($file, $status) { |
|
232 | |||
233 | } |
||
234 |