@@ -100,7 +100,7 @@ public function appendPathToFile($path, $is_windows = false)
100100 return $ path ;
101101 }
102102
103- public function folders ($ column = null )
103+ public function folders ()
104104 {
105105 $ all_folders = array_map (function ($ directory_path ) {
106106 return $ this ->get ($ directory_path );
@@ -110,16 +110,16 @@ public function folders($column = null)
110110 return $ directory ->name !== $ this ->helper ->getThumbFolderName ();
111111 });
112112
113- return $ this ->sortByColumn ($ folders, $ column );
113+ return $ this ->sortByColumn ($ folders );
114114 }
115115
116- public function files ($ column = null )
116+ public function files ()
117117 {
118118 $ files = array_map (function ($ file_path ) {
119119 return $ this ->get ($ file_path );
120120 }, $ this ->storage ->files ());
121121
122- return $ this ->sortByColumn ($ files, $ column );
122+ return $ this ->sortByColumn ($ files );
123123 }
124124
125125 public function get ($ item_path )
@@ -168,15 +168,12 @@ public function normalizeWorkingDir()
168168 * @param mixed $sort_type Alphabetic or time.
169169 * @return array of object
170170 */
171- public function sortByColumn ($ arr_items, $ key_to_sort = null )
171+ public function sortByColumn ($ arr_items )
172172 {
173- if (is_null ($ key_to_sort )) {
174- $ sort_type = $ this ->helper ->input ('sort_type ' );
175- if (!$ sort_type || $ sort_type == 'alphabetic ' ) {
176- $ key_to_sort = 'name ' ;
177- } else {
178- $ key_to_sort = 'time ' ;
179- }
173+ if ($ this ->helper ->input ('sort_type ' ) === 'alphabetic ' ) {
174+ $ key_to_sort = 'name ' ;
175+ } else {
176+ $ key_to_sort = 'time ' ;
180177 }
181178
182179 uasort ($ arr_items , function ($ a , $ b ) use ($ key_to_sort ) {
@@ -200,7 +197,7 @@ public function upload($file)
200197
201198 event (new ImageIsUploading ($ new_file_path ));
202199 try {
203- $ new_filename = $ this ->save ($ file , $ new_filename );
200+ $ new_filename = $ this ->saveFile ($ file , $ new_filename );
204201 } catch (\Exception $ e ) {
205202 \Log::info ($ e );
206203 return $ this ->error ('invalid ' );
@@ -229,11 +226,8 @@ private function uploadValidator($file)
229226 return $ this ->error ('file-exist ' );
230227 }
231228
232- $ mimetype = $ file ->getMimeType ();
233-
234- $ type_key = $ this ->helper ->currentLfmType ();
235-
236229 if (config ('lfm.should_validate_mime ' , false )) {
230+ $ mimetype = $ file ->getMimeType ();
237231 if (false === in_array ($ mimetype , $ this ->helper ->availableMimeTypes ())) {
238232 return $ this ->error ('mime ' ) . $ mimetype ;
239233 }
@@ -263,9 +257,10 @@ private function getNewName($file)
263257 return $ new_filename ;
264258 }
265259
266- private function save ($ file , $ new_filename )
260+ private function saveFile ($ file , $ new_filename )
267261 {
268- $ should_create_thumbnail = $ this ->isUploadingImage ($ file ) && $ this ->shouldCreateThumb ($ file );
262+ $ should_create_thumbnail = $ this ->shouldCreateThumb ($ file );
263+
269264 $ filename = $ this ->setName (null )->thumb (false )->storage ->save ($ file , $ new_filename );
270265
271266 chmod ($ this ->setName ($ filename )->thumb (false )->path ('absolute ' ), config ('lfm.create_file_mode ' , 0644 ));
@@ -288,13 +283,9 @@ public function makeThumbnail($filename)
288283 ->save ($ this ->thumb (true )->setName ($ filename )->path ('absolute ' ));
289284 }
290285
291- private function isUploadingImage ($ file )
292- {
293- return starts_with ($ file ->getMimeType (), 'image ' );
294- }
295-
296286 private function shouldCreateThumb ($ file )
297287 {
298- return !in_array ($ file ->getMimeType (), ['image/gif ' , 'image/svg+xml ' ]);
288+ return starts_with ($ file ->getMimeType (), 'image ' )
289+ && !in_array ($ file ->getMimeType (), ['image/gif ' , 'image/svg+xml ' ]);
299290 }
300291}
0 commit comments