1 | <?php |
||
33 | trait Files { |
||
34 | |||
35 | use PathManipulation; |
||
36 | |||
37 | /** @var SearchFolderService */ |
||
38 | private $searchFolderService; |
||
39 | /** @var ConfigService */ |
||
40 | private $configService; |
||
41 | /** @var SearchMediaService */ |
||
42 | private $searchMediaService; |
||
43 | /** @var DownloadService */ |
||
44 | private $downloadService; |
||
45 | /** @var ILogger */ |
||
46 | private $logger; |
||
47 | |||
48 | /** |
||
49 | * @NoAdminRequired |
||
50 | * |
||
51 | * Returns a list of all media files and albums available to the authenticated user |
||
52 | * |
||
53 | * * Authentication can be via a login/password or a token/(password) |
||
54 | * * For private galleries, it returns all media files, with the full path from the root |
||
55 | * folder For public galleries, the path starts from the folder the link gives access to |
||
56 | * (virtual root) |
||
57 | * * An exception is only caught in case something really wrong happens. As we don't test |
||
58 | * files before including them in the list, we may return some bad apples |
||
59 | * |
||
60 | * @param string $location a path representing the current album in the app |
||
61 | * @param array $features the list of supported features |
||
62 | * @param string $etag the last known etag in the client |
||
63 | * @param array $mediatypes the list of supported media types |
||
64 | * |
||
65 | * @return array <string,array<string,string|int>>|Http\JSONResponse |
||
|
|||
66 | */ |
||
67 | 15 | private function getFilesAndAlbums($location, $features, $etag, $mediatypes) { |
|
86 | |||
87 | /** |
||
88 | * Generates shortened paths to the media files |
||
89 | * |
||
90 | * We only want to keep one folder between the current folder and the found media file |
||
91 | * /root/folder/sub1/sub2/file.ext |
||
92 | * becomes |
||
93 | * /root/folder/file.ext |
||
94 | * |
||
95 | * @param array $files |
||
96 | * @param string $folderPathFromRoot |
||
97 | * |
||
98 | * @return array |
||
99 | */ |
||
100 | 11 | private function fixPaths($files, $folderPathFromRoot) { |
|
101 | 11 | if (!empty($files)) { |
|
102 | 7 | foreach ($files as &$file) { |
|
103 | 7 | $file['path'] = $this->getReducedPath($file['path'], $folderPathFromRoot); |
|
104 | } |
||
105 | } |
||
106 | |||
107 | 11 | return $files; |
|
108 | } |
||
109 | |||
110 | /** |
||
111 | * Simply builds and returns an array containing the list of files, the album information and |
||
112 | * whether the location has changed or not |
||
113 | * |
||
114 | * @param array $files |
||
115 | * @param array $albums |
||
116 | * @param array $albumConfig |
||
117 | * @param string $folderPathFromRoot |
||
118 | * @param bool $updated |
||
119 | * |
||
120 | * @return array |
||
121 | * @internal param $array <string,string|int> $files |
||
122 | */ |
||
123 | 11 | private function formatResults($files, $albums, $albumConfig, $folderPathFromRoot, $updated) { |
|
132 | |||
133 | /** |
||
134 | * Generates the download data |
||
135 | * |
||
136 | * @param int $fileId the ID of the file of which we need a large preview of |
||
137 | * @param string|null $filename |
||
138 | * |
||
139 | * @return array|false |
||
140 | */ |
||
141 | 12 | private function getDownload($fileId, $filename) { |
|
153 | |||
154 | } |
||
155 |
This check looks for the generic type
array
as a return type and suggests a more specific type. This type is inferred from the actual code.