@@ -7,50 +7,50 @@ |
||
7 | 7 | |
8 | 8 | class FileStorageController extends Controller |
9 | 9 | { |
10 | - public function get(Request $request) |
|
11 | - { |
|
12 | - try { |
|
13 | - $file = Database\Models\File::get($request->get('id')); |
|
14 | - } catch (\Exception $e) { |
|
15 | - abort(404); |
|
16 | - } |
|
10 | + public function get(Request $request) |
|
11 | + { |
|
12 | + try { |
|
13 | + $file = Database\Models\File::get($request->get('id')); |
|
14 | + } catch (\Exception $e) { |
|
15 | + abort(404); |
|
16 | + } |
|
17 | 17 | |
18 | - $useThumbnail = false; |
|
19 | - $disposition = 'attachment'; |
|
20 | - switch ($request->get('action')) { |
|
21 | - case 'preview': |
|
22 | - $useThumbnail = true; |
|
23 | - // intended fallthrough |
|
24 | - case 'inline': |
|
25 | - $disposition = 'inline'; |
|
26 | - break; |
|
18 | + $useThumbnail = false; |
|
19 | + $disposition = 'attachment'; |
|
20 | + switch ($request->get('action')) { |
|
21 | + case 'preview': |
|
22 | + $useThumbnail = true; |
|
23 | + // intended fallthrough |
|
24 | + case 'inline': |
|
25 | + $disposition = 'inline'; |
|
26 | + break; |
|
27 | 27 | |
28 | - default: |
|
29 | - break; |
|
30 | - } |
|
28 | + default: |
|
29 | + break; |
|
30 | + } |
|
31 | 31 | |
32 | - if ($useThumbnail && $request->get('thumbnail', 1) && ($thumbnail = $file->thumbnail)) { |
|
33 | - $mime = $thumbnail['mime']; |
|
34 | - $filename = $thumbnail['name']; |
|
35 | - $contents = $thumbnail['contents']; |
|
36 | - } |
|
37 | - else { |
|
38 | - $mime = $file->content->type; |
|
39 | - $filename = $file->name; |
|
40 | - $contents = $file->content->data; |
|
41 | - } |
|
32 | + if ($useThumbnail && $request->get('thumbnail', 1) && ($thumbnail = $file->thumbnail)) { |
|
33 | + $mime = $thumbnail['mime']; |
|
34 | + $filename = $thumbnail['name']; |
|
35 | + $contents = $thumbnail['contents']; |
|
36 | + } |
|
37 | + else { |
|
38 | + $mime = $file->content->type; |
|
39 | + $filename = $file->name; |
|
40 | + $contents = $file->content->data; |
|
41 | + } |
|
42 | 42 | |
43 | - $headers = [ |
|
44 | - 'Content-Type' => $mime, |
|
45 | - 'Content-Length' => strlen($contents), |
|
46 | - 'Content-Disposition' => "$disposition; filename=\"$filename\"", |
|
47 | - ]; |
|
43 | + $headers = [ |
|
44 | + 'Content-Type' => $mime, |
|
45 | + 'Content-Length' => strlen($contents), |
|
46 | + 'Content-Disposition' => "$disposition; filename=\"$filename\"", |
|
47 | + ]; |
|
48 | 48 | |
49 | - if ($request->get('nocache')) { |
|
50 | - $headers['Pragma'] = 'no-cache'; |
|
51 | - $headers['Expires'] = '0'; |
|
52 | - } |
|
49 | + if ($request->get('nocache')) { |
|
50 | + $headers['Pragma'] = 'no-cache'; |
|
51 | + $headers['Expires'] = '0'; |
|
52 | + } |
|
53 | 53 | |
54 | - return response($contents, 200, $headers); |
|
55 | - } |
|
54 | + return response($contents, 200, $headers); |
|
55 | + } |
|
56 | 56 | } |
@@ -14,215 +14,215 @@ |
||
14 | 14 | { |
15 | 15 | use SoftDeletes; |
16 | 16 | |
17 | - protected $table = 'filestorage_files'; |
|
18 | - protected static $unguarded = true; |
|
17 | + protected $table = 'filestorage_files'; |
|
18 | + protected static $unguarded = true; |
|
19 | 19 | |
20 | - public function content() |
|
21 | - { |
|
22 | - return $this->belongsTo(FileContent::class, 'content_id'); |
|
23 | - } |
|
20 | + public function content() |
|
21 | + { |
|
22 | + return $this->belongsTo(FileContent::class, 'content_id'); |
|
23 | + } |
|
24 | 24 | |
25 | - public function links() |
|
26 | - { |
|
27 | - return $this->hasMany(FileRemoteAccess::class, 'file_id'); |
|
28 | - } |
|
25 | + public function links() |
|
26 | + { |
|
27 | + return $this->hasMany(FileRemoteAccess::class, 'file_id'); |
|
28 | + } |
|
29 | 29 | |
30 | - public function userActiveLinks() |
|
31 | - { |
|
32 | - return $this->links()->where('created_by', Auth::id())->where('expires_at', '>', date('Y-m-d H:i:s')); |
|
33 | - } |
|
30 | + public function userActiveLinks() |
|
31 | + { |
|
32 | + return $this->links()->where('created_by', Auth::id())->where('expires_at', '>', date('Y-m-d H:i:s')); |
|
33 | + } |
|
34 | 34 | |
35 | - /** |
|
36 | - * Retrieve the file |
|
37 | - * |
|
38 | - * @param int|string $idOrLink Filestorage ID or unique link string |
|
39 | - * @param bool $useCache Use cache or not |
|
40 | - * |
|
41 | - * @return static |
|
42 | - * |
|
43 | - * @throws FileNotFound |
|
44 | - */ |
|
45 | - public static function get($idOrLink, $useCache = true) |
|
46 | - { |
|
47 | - static $cache = []; |
|
48 | - |
|
49 | - if (is_object($idOrLink)) return $idOrLink; |
|
35 | + /** |
|
36 | + * Retrieve the file |
|
37 | + * |
|
38 | + * @param int|string $idOrLink Filestorage ID or unique link string |
|
39 | + * @param bool $useCache Use cache or not |
|
40 | + * |
|
41 | + * @return static |
|
42 | + * |
|
43 | + * @throws FileNotFound |
|
44 | + */ |
|
45 | + public static function get($idOrLink, $useCache = true) |
|
46 | + { |
|
47 | + static $cache = []; |
|
48 | + |
|
49 | + if (is_object($idOrLink)) return $idOrLink; |
|
50 | 50 | |
51 | - $id = self::getIdByLink($idOrLink, true, true); |
|
51 | + $id = self::getIdByLink($idOrLink, true, true); |
|
52 | 52 | |
53 | - if ($useCache && isset($cache[$id])) { |
|
54 | - return $cache[$id]; |
|
55 | - } |
|
53 | + if ($useCache && isset($cache[$id])) { |
|
54 | + return $cache[$id]; |
|
55 | + } |
|
56 | 56 | |
57 | - $file = self::with('content')->findOrFail($id); |
|
57 | + $file = self::with('content')->findOrFail($id); |
|
58 | 58 | |
59 | - if (empty($file->content['hash'])) { |
|
60 | - throw new FileNotFound('File object does not have corresponding content'); |
|
61 | - } |
|
59 | + if (empty($file->content['hash'])) { |
|
60 | + throw new FileNotFound('File object does not have corresponding content'); |
|
61 | + } |
|
62 | 62 | |
63 | - return $cache[$id] = $file; |
|
64 | - } |
|
63 | + return $cache[$id] = $file; |
|
64 | + } |
|
65 | 65 | |
66 | - /** |
|
67 | - * Get Filestorage ID by link |
|
68 | - * |
|
69 | - * @param string $link Unique link |
|
70 | - * @param bool $useCache Use cache or not |
|
71 | - * @param bool $throwException Throw exception if link is not found |
|
72 | - * |
|
73 | - * @return int Filestorage ID |
|
74 | - * @throws LinkNotFound |
|
75 | - */ |
|
76 | - public static function getIdByLink($link, $useCache = true, $throwException = false) |
|
77 | - { |
|
78 | - static $cache = []; |
|
79 | - |
|
80 | - if (is_numeric($link)) return $link; |
|
81 | - |
|
82 | - if (!$useCache || !isset($cache[$link])) { |
|
83 | - $cache[$link] = self::where('link', $link)->value('id'); |
|
66 | + /** |
|
67 | + * Get Filestorage ID by link |
|
68 | + * |
|
69 | + * @param string $link Unique link |
|
70 | + * @param bool $useCache Use cache or not |
|
71 | + * @param bool $throwException Throw exception if link is not found |
|
72 | + * |
|
73 | + * @return int Filestorage ID |
|
74 | + * @throws LinkNotFound |
|
75 | + */ |
|
76 | + public static function getIdByLink($link, $useCache = true, $throwException = false) |
|
77 | + { |
|
78 | + static $cache = []; |
|
79 | + |
|
80 | + if (is_numeric($link)) return $link; |
|
81 | + |
|
82 | + if (!$useCache || !isset($cache[$link])) { |
|
83 | + $cache[$link] = self::where('link', $link)->value('id'); |
|
84 | 84 | |
85 | - if (!$cache[$link] && $throwException) { |
|
86 | - throw new LinkNotFound($link); |
|
87 | - } |
|
88 | - } |
|
85 | + if (!$cache[$link] && $throwException) { |
|
86 | + throw new LinkNotFound($link); |
|
87 | + } |
|
88 | + } |
|
89 | 89 | |
90 | - return $cache[$link]; |
|
91 | - } |
|
90 | + return $cache[$link]; |
|
91 | + } |
|
92 | 92 | |
93 | - /** |
|
94 | - * Mark file as deleted. Does not remove any content! |
|
95 | - * |
|
96 | - * @param int|string $idOrLink Filestorage ID or unique link |
|
97 | - */ |
|
98 | - public static function unlink($idOrLink) |
|
99 | - { |
|
93 | + /** |
|
94 | + * Mark file as deleted. Does not remove any content! |
|
95 | + * |
|
96 | + * @param int|string $idOrLink Filestorage ID or unique link |
|
97 | + */ |
|
98 | + public static function unlink($idOrLink) |
|
99 | + { |
|
100 | 100 | if ($id = self::getIdByLink($idOrLink, false)) { |
101 | 101 | self::find($id)->delete(); |
102 | - } |
|
103 | - } |
|
102 | + } |
|
103 | + } |
|
104 | 104 | |
105 | - /** |
|
106 | - * Check if file exists |
|
107 | - * |
|
108 | - * @param int|static $idOrMeta Filestorage ID or file object |
|
109 | - * @param bool $throwException Throw exception on missing file or return false |
|
110 | - * |
|
111 | - * @return bool True if file exists, false otherwise |
|
112 | - * @throws FileNotFound May be thrown if $throwException set to true |
|
113 | - */ |
|
114 | - public static function exists($idOrMeta, $throwException = false) |
|
115 | - { |
|
116 | - try { |
|
117 | - $file = is_numeric($idOrMeta) ? self::get($idOrMeta) : $idOrMeta; |
|
105 | + /** |
|
106 | + * Check if file exists |
|
107 | + * |
|
108 | + * @param int|static $idOrMeta Filestorage ID or file object |
|
109 | + * @param bool $throwException Throw exception on missing file or return false |
|
110 | + * |
|
111 | + * @return bool True if file exists, false otherwise |
|
112 | + * @throws FileNotFound May be thrown if $throwException set to true |
|
113 | + */ |
|
114 | + public static function exists($idOrMeta, $throwException = false) |
|
115 | + { |
|
116 | + try { |
|
117 | + $file = is_numeric($idOrMeta) ? self::get($idOrMeta) : $idOrMeta; |
|
118 | 118 | |
119 | - if (! file_exists($file->content->path)) { |
|
120 | - throw new FileNotFound('Exception - file not found: ' . $file->content->path); |
|
121 | - } |
|
122 | - } catch (\Exception $exception) { |
|
123 | - if ($throwException) |
|
124 | - throw $exception; |
|
125 | - else |
|
126 | - return false; |
|
127 | - } |
|
128 | - |
|
129 | - return true; |
|
130 | - } |
|
119 | + if (! file_exists($file->content->path)) { |
|
120 | + throw new FileNotFound('Exception - file not found: ' . $file->content->path); |
|
121 | + } |
|
122 | + } catch (\Exception $exception) { |
|
123 | + if ($throwException) |
|
124 | + throw $exception; |
|
125 | + else |
|
126 | + return false; |
|
127 | + } |
|
128 | + |
|
129 | + return true; |
|
130 | + } |
|
131 | 131 | |
132 | - /** |
|
133 | - * Add multiple files, clone file if file id is provided. |
|
134 | - * May be used to update backref for all files. |
|
135 | - * |
|
136 | - * @param array $files array of existing filestorage ids or array with values for the new file |
|
137 | - * @param string|null $backref Backref for all files |
|
138 | - * @return array Newly created Meta Ids sorted in ascending order |
|
139 | - */ |
|
140 | - public static function putMany($files, $backref = null) |
|
141 | - { |
|
142 | - $ids = []; |
|
143 | - foreach ((array) $files as $filePath) { |
|
144 | - if (! is_numeric($filePath)) { |
|
145 | - $ids[] = self::put($filePath); |
|
132 | + /** |
|
133 | + * Add multiple files, clone file if file id is provided. |
|
134 | + * May be used to update backref for all files. |
|
135 | + * |
|
136 | + * @param array $files array of existing filestorage ids or array with values for the new file |
|
137 | + * @param string|null $backref Backref for all files |
|
138 | + * @return array Newly created Meta Ids sorted in ascending order |
|
139 | + */ |
|
140 | + public static function putMany($files, $backref = null) |
|
141 | + { |
|
142 | + $ids = []; |
|
143 | + foreach ((array) $files as $filePath) { |
|
144 | + if (! is_numeric($filePath)) { |
|
145 | + $ids[] = self::put($filePath); |
|
146 | 146 | |
147 | - continue; |
|
148 | - } |
|
147 | + continue; |
|
148 | + } |
|
149 | 149 | |
150 | - $file = self::get($filePath, false)->toArray(); |
|
150 | + $file = self::get($filePath, false)->toArray(); |
|
151 | 151 | |
152 | - if ($backref && $file['backref'] != $backref) { |
|
153 | - $file['backref'] = $backref; |
|
154 | - unset($file['link']); |
|
152 | + if ($backref && $file['backref'] != $backref) { |
|
153 | + $file['backref'] = $backref; |
|
154 | + unset($file['link']); |
|
155 | 155 | |
156 | - self::put($file); |
|
157 | - } |
|
156 | + self::put($file); |
|
157 | + } |
|
158 | 158 | |
159 | - $ids[] = $file; |
|
160 | - } |
|
159 | + $ids[] = $file; |
|
160 | + } |
|
161 | 161 | |
162 | - sort($ids); |
|
162 | + sort($ids); |
|
163 | 163 | |
164 | - return $ids; |
|
165 | - } |
|
164 | + return $ids; |
|
165 | + } |
|
166 | 166 | |
167 | - /** |
|
168 | - * @param string|array $fileOrPath |
|
169 | - * @param string $content Content of the file |
|
170 | - * |
|
171 | - * @return int Filestorage ID |
|
172 | - * @throws LinkDuplicate |
|
173 | - */ |
|
174 | - public static function put($fileOrPath, $content = null) |
|
175 | - { |
|
176 | - $file = $fileOrPath; |
|
177 | - if (! $content && is_string($fileOrPath)) { |
|
178 | - $content = file_get_contents($fileOrPath); |
|
167 | + /** |
|
168 | + * @param string|array $fileOrPath |
|
169 | + * @param string $content Content of the file |
|
170 | + * |
|
171 | + * @return int Filestorage ID |
|
172 | + * @throws LinkDuplicate |
|
173 | + */ |
|
174 | + public static function put($fileOrPath, $content = null) |
|
175 | + { |
|
176 | + $file = $fileOrPath; |
|
177 | + if (! $content && is_string($fileOrPath)) { |
|
178 | + $content = file_get_contents($fileOrPath); |
|
179 | 179 | |
180 | - $file = [ |
|
181 | - 'name' => basename($fileOrPath) |
|
182 | - ]; |
|
183 | - } |
|
180 | + $file = [ |
|
181 | + 'name' => basename($fileOrPath) |
|
182 | + ]; |
|
183 | + } |
|
184 | 184 | |
185 | - if (!empty($file['link']) && self::getIdByLink($file['link'], false)) { |
|
186 | - throw new LinkDuplicate($file['link']); |
|
187 | - } |
|
185 | + if (!empty($file['link']) && self::getIdByLink($file['link'], false)) { |
|
186 | + throw new LinkDuplicate($file['link']); |
|
187 | + } |
|
188 | 188 | |
189 | - $content = $file['content']?? $content; |
|
189 | + $content = $file['content']?? $content; |
|
190 | 190 | |
191 | - if (is_array($content)) { |
|
192 | - $path = $content['path']; |
|
191 | + if (is_array($content)) { |
|
192 | + $path = $content['path']; |
|
193 | 193 | |
194 | - $file['name'] = $file['name']?? basename($path); |
|
194 | + $file['name'] = $file['name']?? basename($path); |
|
195 | 195 | |
196 | - $content = file_get_contents($path); |
|
197 | - } |
|
196 | + $content = file_get_contents($path); |
|
197 | + } |
|
198 | 198 | |
199 | - unset($file['content']); |
|
200 | - |
|
201 | - return self::updateOrCreate(['id' => $file['id']?? null], array_merge([ |
|
202 | - 'created_at' => time(), |
|
203 | - 'created_by' => Auth::id(), |
|
204 | - 'content_id' => FileContent::put($content) |
|
205 | - ], $file))->id; |
|
206 | - } |
|
199 | + unset($file['content']); |
|
200 | + |
|
201 | + return self::updateOrCreate(['id' => $file['id']?? null], array_merge([ |
|
202 | + 'created_at' => time(), |
|
203 | + 'created_by' => Auth::id(), |
|
204 | + 'content_id' => FileContent::put($content) |
|
205 | + ], $file))->id; |
|
206 | + } |
|
207 | 207 | |
208 | - public function getThumbnailAttribute() |
|
209 | - { |
|
210 | - if (! $this->thumbnailPossible()) return false; |
|
208 | + public function getThumbnailAttribute() |
|
209 | + { |
|
210 | + if (! $this->thumbnailPossible()) return false; |
|
211 | 211 | |
212 | - $image = new \Imagick($this->content->path . '[0]'); |
|
212 | + $image = new \Imagick($this->content->path . '[0]'); |
|
213 | 213 | |
214 | - $image->setImageFormat('jpg'); |
|
214 | + $image->setImageFormat('jpg'); |
|
215 | 215 | |
216 | - $mime = 'image/jpeg'; |
|
216 | + $mime = 'image/jpeg'; |
|
217 | 217 | |
218 | - $name = 'preview.jpeg'; |
|
218 | + $name = 'preview.jpeg'; |
|
219 | 219 | |
220 | - $contents = $image . ''; |
|
220 | + $contents = $image . ''; |
|
221 | 221 | |
222 | - return collect(compact('mime', 'name', 'contents')); |
|
223 | - } |
|
222 | + return collect(compact('mime', 'name', 'contents')); |
|
223 | + } |
|
224 | 224 | |
225 | - protected function thumbnailPossible() { |
|
226 | - return $this->content->type == 'application/pdf' && class_exists('Imagick'); |
|
227 | - } |
|
225 | + protected function thumbnailPossible() { |
|
226 | + return $this->content->type == 'application/pdf' && class_exists('Imagick'); |
|
227 | + } |
|
228 | 228 | } |
229 | 229 | \ No newline at end of file |
@@ -34,7 +34,7 @@ |
||
34 | 34 | $grid->setModel($this->getModel()); |
35 | 35 | |
36 | 36 | $grid->addDecorator('name', ['Multiformat', function($row, $column) { |
37 | - return [['Template', '<a href="#" class="file-modal" data-id="' . $row['id'] . '">' . $row[$column] . '</a>']]; |
|
37 | + return [['Template', '<a href="#" class="file-modal" data-id="' . $row['id'] . '">' . $row[$column] . '</a>']]; |
|
38 | 38 | }]); |
39 | 39 | |
40 | 40 | $grid->on('click', '.file-modal', $this->add(new FileModal())->show()); |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | |
21 | 21 | public function __construct($file) |
22 | 22 | { |
23 | - $this->file = is_numeric($file)? File::get($file): $file; |
|
23 | + $this->file = is_numeric($file) ? File::get($file) : $file; |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | public function renderView() |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | |
35 | 35 | protected function setPeriodSelection() |
36 | 36 | { |
37 | - if (! $this->periodSelection) { |
|
37 | + if (!$this->periodSelection) { |
|
38 | 38 | $this->periodSelection = []; |
39 | 39 | foreach ([1, 2, 3, 4] as $count) { |
40 | 40 | $this->periodSelection[$count . ' weeks'] = trans_choice('{1} :count week |[2,*] :count weeks', $count); |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | } |
43 | 43 | |
44 | 44 | foreach ($this->periodSelection as $key => $period) { |
45 | - $default = $key == $this->defaultPeriod? ' (' . __('Default') . ')': ''; |
|
45 | + $default = $key == $this->defaultPeriod ? ' (' . __('Default') . ')' : ''; |
|
46 | 46 | |
47 | 47 | $this->periodSelection[$key] = $period . $default; |
48 | 48 | } |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | |
51 | 51 | protected function addContents() |
52 | 52 | { |
53 | - if (! $this->file) { |
|
53 | + if (!$this->file) { |
|
54 | 54 | $this->set(__('Wrong parameters for file')); |
55 | 55 | return; |
56 | 56 | } |
@@ -70,13 +70,13 @@ discard block |
||
70 | 70 | |
71 | 71 | protected function addFileDetails($container = null) |
72 | 72 | { |
73 | - $container = $container?: $this; |
|
73 | + $container = $container ?: $this; |
|
74 | 74 | |
75 | 75 | $container->add([new FileDetailsLister($this->file)]); |
76 | 76 | } |
77 | 77 | |
78 | 78 | protected function addFileRemoteLinks($container = null) { |
79 | - $container = $container?: $this; |
|
79 | + $container = $container ?: $this; |
|
80 | 80 | |
81 | 81 | foreach ($this->file->userActiveLinks()->get() as $link) { |
82 | 82 | $container->add(['View', __('Remote access link expiring :expiry', ['expiry' => $link->expires_at])]); |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | $container->js(true, new jsExpression('new ClipboardJS(".copy-button")')); |
91 | 91 | |
92 | 92 | $container->on('click', '.delete-link', $this->add(['jsCallback', 'postTrigger' => 'link'])->set(function($j, $linkId) { |
93 | - if (! $link = FileRemoteAccess::find($linkId)) return; |
|
93 | + if (!$link = FileRemoteAccess::find($linkId)) return; |
|
94 | 94 | |
95 | 95 | $link->delete(); |
96 | 96 | |
@@ -101,19 +101,19 @@ discard block |
||
101 | 101 | protected function addFileControlButtons() { |
102 | 102 | $urls = FileStorageAccessJoint::getActionUrls($this->file); |
103 | 103 | |
104 | - if (! $this->actionDisabled('preview') && ($urls['preview']?? null)) { |
|
104 | + if (!$this->actionDisabled('preview') && ($urls['preview']?? null)) { |
|
105 | 105 | $this->add(['Button', 'class' => ['basic'], 'icon' => 'file alternate outline'])->set(__('View'))->link($urls['preview'])->setAttr(['target' => '_blank']); |
106 | 106 | } |
107 | 107 | |
108 | - if (! $this->actionDisabled('download') && ($urls['download']?? null)) { |
|
108 | + if (!$this->actionDisabled('download') && ($urls['download']?? null)) { |
|
109 | 109 | $this->add(['Button', 'class' => ['basic'], 'icon' => 'file download'])->set(__('Download'))->link($urls['download']); |
110 | 110 | } |
111 | 111 | |
112 | - if (! $this->actionDisabled('history')) { |
|
112 | + if (!$this->actionDisabled('history')) { |
|
113 | 113 | $this->add(['Button', 'class' => ['basic'], 'icon' => 'history'])->set(__('Access History'))->link(url('view/filestorage:file-access-history/body') . '?' . http_build_query(['id' => $this->file->id])); |
114 | 114 | } |
115 | 115 | |
116 | - if (! $this->actionDisabled('remote')) { |
|
116 | + if (!$this->actionDisabled('remote')) { |
|
117 | 117 | $linkControl = $this->add(['View', 'ui' => 'basic buttons']); |
118 | 118 | |
119 | 119 | $linkButton = $linkControl->add(['Button', 'class' => ['basic'], 'icon' => 'linkify'])->set(__('Get Remote Link')); |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | $dropdown->setSource($this->periodSelection); |
124 | 124 | |
125 | 125 | $dropdown->onChange(function($value) { |
126 | - $period = array_search($value, $this->periodSelection)?: $this->defaultPeriod; |
|
126 | + $period = array_search($value, $this->periodSelection) ?: $this->defaultPeriod; |
|
127 | 127 | |
128 | 128 | FileRemoteAccess::grant($this->file, $period); |
129 | 129 |
@@ -90,7 +90,9 @@ |
||
90 | 90 | $container->js(true, new jsExpression('new ClipboardJS(".copy-button")')); |
91 | 91 | |
92 | 92 | $container->on('click', '.delete-link', $this->add(['jsCallback', 'postTrigger' => 'link'])->set(function($j, $linkId) { |
93 | - if (! $link = FileRemoteAccess::find($linkId)) return; |
|
93 | + if (! $link = FileRemoteAccess::find($linkId)) { |
|
94 | + return; |
|
95 | + } |
|
94 | 96 | |
95 | 97 | $link->delete(); |
96 | 98 |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | |
16 | 16 | public function __construct($file) |
17 | 17 | { |
18 | - $this->file = is_numeric($file)? File::get($file): $file; |
|
18 | + $this->file = is_numeric($file) ? File::get($file) : $file; |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | public function init() |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | |
35 | 35 | public function getDefaultSource() |
36 | 36 | { |
37 | - return $this->file? [ |
|
37 | + return $this->file ? [ |
|
38 | 38 | 'name' => [ |
39 | 39 | 'title'=> __('Name'), |
40 | 40 | 'descr'=> $this->file->name |
@@ -51,6 +51,6 @@ discard block |
||
51 | 51 | 'title'=> __('Created At'), |
52 | 52 | 'descr'=> $this->file->created_at->format('Y-m-d H:i:s') |
53 | 53 | ] |
54 | - ]: []; |
|
54 | + ] : []; |
|
55 | 55 | } |
56 | 56 | } |
57 | 57 | \ No newline at end of file |