@@ -17,28 +17,28 @@ discard block |
||
17 | 17 | */ |
18 | 18 | public function boot() |
19 | 19 | { |
20 | - $this->loadTranslationsFrom(__DIR__.'/lang', 'laravel-filemanager'); |
|
20 | + $this->loadTranslationsFrom(__DIR__ . '/lang', 'laravel-filemanager'); |
|
21 | 21 | |
22 | - $this->loadViewsFrom(__DIR__.'/views', 'laravel-filemanager'); |
|
22 | + $this->loadViewsFrom(__DIR__ . '/views', 'laravel-filemanager'); |
|
23 | 23 | |
24 | 24 | $this->publishes([ |
25 | 25 | __DIR__ . '/config/lfm.php' => base_path('config/lfm.php'), |
26 | 26 | ], 'lfm_config'); |
27 | 27 | |
28 | 28 | $this->publishes([ |
29 | - __DIR__.'/../public' => public_path('vendor/laravel-filemanager'), |
|
29 | + __DIR__ . '/../public' => public_path('vendor/laravel-filemanager'), |
|
30 | 30 | ], 'lfm_public'); |
31 | 31 | |
32 | 32 | $this->publishes([ |
33 | - __DIR__.'/views' => base_path('resources/views/vendor/laravel-filemanager'), |
|
33 | + __DIR__ . '/views' => base_path('resources/views/vendor/laravel-filemanager'), |
|
34 | 34 | ], 'lfm_view'); |
35 | 35 | |
36 | 36 | $this->publishes([ |
37 | - __DIR__.'/Handlers/LfmConfigHandler.php' => base_path('app/Handlers/LfmConfigHandler.php'), |
|
37 | + __DIR__ . '/Handlers/LfmConfigHandler.php' => base_path('app/Handlers/LfmConfigHandler.php'), |
|
38 | 38 | ], 'lfm_handler'); |
39 | 39 | |
40 | 40 | if (config('lfm.use_package_routes')) { |
41 | - Route::group(['prefix' => 'filemanager', 'middleware' => ['web', 'auth']], function () { |
|
41 | + Route::group([ 'prefix' => 'filemanager', 'middleware' => [ 'web', 'auth' ] ], function() { |
|
42 | 42 | \UniSharp\LaravelFilemanager\Lfm::routes(); |
43 | 43 | }); |
44 | 44 | } |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | { |
54 | 54 | $this->mergeConfigFrom(__DIR__ . '/config/lfm.php', 'lfm-config'); |
55 | 55 | |
56 | - $this->app->singleton('laravel-filemanager', function () { |
|
56 | + $this->app->singleton('laravel-filemanager', function() { |
|
57 | 57 | return true; |
58 | 58 | }); |
59 | 59 | } |
@@ -110,7 +110,7 @@ |
||
110 | 110 | 'over_write_on_duplicate' => false, |
111 | 111 | |
112 | 112 | // Item Columns |
113 | - 'item_columns' => ['name', 'url', 'time', 'icon', 'is_file', 'is_image', 'thumb_url'], |
|
113 | + 'item_columns' => [ 'name', 'url', 'time', 'icon', 'is_file', 'is_image', 'thumb_url' ], |
|
114 | 114 | |
115 | 115 | /* |
116 | 116 | |-------------------------------------------------------------------------- |
@@ -12,25 +12,25 @@ discard block |
||
12 | 12 | private $isDirectory; |
13 | 13 | private $mimeType = null; |
14 | 14 | |
15 | - private $columns = []; |
|
16 | - public $attributes = []; |
|
15 | + private $columns = [ ]; |
|
16 | + public $attributes = [ ]; |
|
17 | 17 | |
18 | 18 | public function __construct(LfmPath $lfm, Lfm $helper, $isDirectory = false) |
19 | 19 | { |
20 | 20 | $this->lfm = $lfm->thumb(false); |
21 | 21 | $this->helper = $helper; |
22 | 22 | $this->isDirectory = $isDirectory; |
23 | - $this->columns = $helper->config('item_columns')??['name', 'url', 'time', 'icon', 'is_file', 'is_image', 'thumb_url']; |
|
23 | + $this->columns = $helper->config('item_columns') ?? [ 'name', 'url', 'time', 'icon', 'is_file', 'is_image', 'thumb_url' ]; |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | public function __get($var_name) |
27 | 27 | { |
28 | 28 | if (!array_key_exists($var_name, $this->attributes)) { |
29 | 29 | $function_name = Str::camel($var_name); |
30 | - $this->attributes[$var_name] = $this->$function_name(); |
|
30 | + $this->attributes[ $var_name ] = $this->$function_name(); |
|
31 | 31 | } |
32 | 32 | |
33 | - return $this->attributes[$var_name]; |
|
33 | + return $this->attributes[ $var_name ]; |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | public function fill() |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | |
60 | 60 | public function isFile() |
61 | 61 | { |
62 | - return ! $this->isDirectory(); |
|
62 | + return !$this->isDirectory(); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | /** |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | return false; |
175 | 175 | } |
176 | 176 | |
177 | - if (in_array($this->mimeType(), ['image/gif', 'image/svg+xml'])) { |
|
177 | + if (in_array($this->mimeType(), [ 'image/gif', 'image/svg+xml' ])) { |
|
178 | 178 | return false; |
179 | 179 | } |
180 | 180 | |
@@ -195,9 +195,9 @@ discard block |
||
195 | 195 | */ |
196 | 196 | public function humanFilesize($bytes, $decimals = 2) |
197 | 197 | { |
198 | - $size = ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; |
|
198 | + $size = [ 'B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB' ]; |
|
199 | 199 | $factor = floor((strlen($bytes) - 1) / 3); |
200 | 200 | |
201 | - return sprintf("%.{$decimals}f %s", $bytes / pow(1024, $factor), @$size[$factor]); |
|
201 | + return sprintf("%.{$decimals}f %s", $bytes / pow(1024, $factor), @$size[ $factor ]); |
|
202 | 202 | } |
203 | 203 | } |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | public function getDelete() |
17 | 17 | { |
18 | 18 | $item_names = request('items'); |
19 | - $errors = []; |
|
19 | + $errors = [ ]; |
|
20 | 20 | |
21 | 21 | foreach ($item_names as $name_to_delete) { |
22 | 22 | $file = $this->lfm->setName($name_to_delete); |
@@ -35,13 +35,13 @@ discard block |
||
35 | 35 | continue; |
36 | 36 | } |
37 | 37 | |
38 | - if (! $this->lfm->setName($name_to_delete)->exists()) { |
|
39 | - array_push($errors, parent::error('folder-not-found', ['folder' => $file_path])); |
|
38 | + if (!$this->lfm->setName($name_to_delete)->exists()) { |
|
39 | + array_push($errors, parent::error('folder-not-found', [ 'folder' => $file_path ])); |
|
40 | 40 | continue; |
41 | 41 | } |
42 | 42 | |
43 | 43 | if ($this->lfm->setName($name_to_delete)->isDirectory()) { |
44 | - if (! $this->lfm->setName($name_to_delete)->directoryIsEmpty()) { |
|
44 | + if (!$this->lfm->setName($name_to_delete)->directoryIsEmpty()) { |
|
45 | 45 | array_push($errors, parent::error('delete-folder')); |
46 | 46 | continue; |
47 | 47 | } |
@@ -90,11 +90,11 @@ discard block |
||
90 | 90 | |
91 | 91 | public function folders() |
92 | 92 | { |
93 | - $all_folders = array_map(function ($directory_path) { |
|
93 | + $all_folders = array_map(function($directory_path) { |
|
94 | 94 | return $this->pretty($directory_path, true); |
95 | 95 | }, $this->storage->directories()); |
96 | 96 | |
97 | - $folders = array_filter($all_folders, function ($directory) { |
|
97 | + $folders = array_filter($all_folders, function($directory) { |
|
98 | 98 | return $directory->name !== $this->helper->getThumbFolderName(); |
99 | 99 | }); |
100 | 100 | |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | |
104 | 104 | public function files() |
105 | 105 | { |
106 | - $files = array_map(function ($file_path) { |
|
106 | + $files = array_map(function($file_path) { |
|
107 | 107 | $file = $this->pretty($file_path); |
108 | 108 | $file_mime = mime_content_type($this->storage->rootPath() . $file_path); |
109 | 109 | if ($this->helper->availableMimeTypes() == "*" || (is_array($this->helper->availableMimeTypes()) && in_array($file_mime, $this->helper->availableMimeTypes()))) |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | $working_dir = $this->path('working_dir'); |
156 | 156 | $parent_dir = substr($working_dir, 0, strrpos($working_dir, '/')); |
157 | 157 | |
158 | - $parent_directories = array_map(function ($directory_path) { |
|
158 | + $parent_directories = array_map(function($directory_path) { |
|
159 | 159 | return app(static::class)->translateToLfmPath($directory_path); |
160 | 160 | }, app(static::class)->dir($parent_dir)->directories()); |
161 | 161 | |
@@ -201,20 +201,20 @@ discard block |
||
201 | 201 | public function sortByColumn($arr_items) |
202 | 202 | { |
203 | 203 | $sort_by = $this->helper->input('sort_type'); |
204 | - if (in_array($sort_by, ['name', 'time'])) { |
|
204 | + if (in_array($sort_by, [ 'name', 'time' ])) { |
|
205 | 205 | $key_to_sort = $sort_by; |
206 | 206 | } else { |
207 | 207 | $key_to_sort = 'name'; |
208 | 208 | } |
209 | 209 | |
210 | - uasort($arr_items, function ($a, $b) use ($key_to_sort) { |
|
210 | + uasort($arr_items, function($a, $b) use ($key_to_sort) { |
|
211 | 211 | return strcmp($a->{$key_to_sort}, $b->{$key_to_sort}); |
212 | 212 | }); |
213 | 213 | |
214 | 214 | return $arr_items; |
215 | 215 | } |
216 | 216 | |
217 | - public function error($error_type, $variables = []) |
|
217 | + public function error($error_type, $variables = [ ]) |
|
218 | 218 | { |
219 | 219 | throw new \Exception($this->helper->error($error_type, $variables)); |
220 | 220 | } |
@@ -243,10 +243,10 @@ discard block |
||
243 | 243 | { |
244 | 244 | if (empty($file)) { |
245 | 245 | return $this->error('file-empty'); |
246 | - } elseif (! $file instanceof UploadedFile) { |
|
246 | + } elseif (!$file instanceof UploadedFile) { |
|
247 | 247 | return $this->error('instance'); |
248 | 248 | } elseif ($file->getError() == UPLOAD_ERR_INI_SIZE) { |
249 | - return $this->error('file-size', ['max' => ini_get('upload_max_filesize')]); |
|
249 | + return $this->error('file-size', [ 'max' => ini_get('upload_max_filesize') ]); |
|
250 | 250 | } elseif ($file->getError() != UPLOAD_ERR_OK) { |
251 | 251 | throw new \Exception('File failed to upload. Error code: ' . $file->getError()); |
252 | 252 | } |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | |
260 | 260 | $mimetype = $file->getMimeType(); |
261 | 261 | |
262 | - $excutable = ['text/x-php']; |
|
262 | + $excutable = [ 'text/x-php' ]; |
|
263 | 263 | |
264 | 264 | if (in_array($mimetype, $excutable)) { |
265 | 265 | throw new \Exception('Invalid file detected'); |
@@ -304,11 +304,11 @@ discard block |
||
304 | 304 | $file_name_without_extentions = $new_file_name; |
305 | 305 | while ($this->setName(($extension) ? $new_file_name_with_extention : $new_file_name)->exists()) { |
306 | 306 | if (config('lfm.alphanumeric_filename') === true) { |
307 | - $suffix = '_'.$counter; |
|
307 | + $suffix = '_' . $counter; |
|
308 | 308 | } else { |
309 | 309 | $suffix = " ({$counter})"; |
310 | 310 | } |
311 | - $new_file_name = $file_name_without_extentions.$suffix; |
|
311 | + $new_file_name = $file_name_without_extentions . $suffix; |
|
312 | 312 | |
313 | 313 | if ($extension) { |
314 | 314 | $new_file_name_with_extention = $new_file_name . '.' . $extension; |
@@ -106,10 +106,11 @@ |
||
106 | 106 | $files = array_map(function ($file_path) { |
107 | 107 | $file = $this->pretty($file_path); |
108 | 108 | $file_mime = mime_content_type($this->storage->rootPath() . $file_path); |
109 | - if ($this->helper->availableMimeTypes() == "*" || (is_array($this->helper->availableMimeTypes()) && in_array($file_mime, $this->helper->availableMimeTypes()))) |
|
110 | - return $file; |
|
111 | - else |
|
112 | - return null; |
|
109 | + if ($this->helper->availableMimeTypes() == "*" || (is_array($this->helper->availableMimeTypes()) && in_array($file_mime, $this->helper->availableMimeTypes()))) { |
|
110 | + return $file; |
|
111 | + } else { |
|
112 | + return null; |
|
113 | + } |
|
113 | 114 | return $file; |
114 | 115 | }, $this->storage->files()); |
115 | 116 |