File tree Expand file tree Collapse file tree 4 files changed +32
-21
lines changed Expand file tree Collapse file tree 4 files changed +32
-21
lines changed Original file line number Diff line number Diff line change @@ -55,19 +55,21 @@ public function getFolders()
55
55
public function getAddfolder ()
56
56
{
57
57
$ folder_name = parent ::translateFromUtf8 (trim (request ('name ' )));
58
-
59
58
$ path = parent ::getCurrentPath ($ folder_name );
60
59
61
60
if (empty ($ folder_name )) {
62
61
return parent ::error ('folder-name ' );
63
- } elseif (File::exists ($ path )) {
62
+ }
63
+
64
+ if (File::exists ($ path )) {
64
65
return parent ::error ('folder-exist ' );
65
- } elseif (config ('lfm.alphanumeric_directory ' ) && preg_match ('/[^\w-]/i ' , $ folder_name )) {
66
- return parent ::error ('folder-alnum ' );
67
- } else {
68
- parent ::createFolderByPath ($ path );
66
+ }
69
67
70
- return parent ::$ success_response ;
68
+ if (config ('lfm.alphanumeric_directory ' ) && preg_match ('/[^\w-]/i ' , $ folder_name )) {
69
+ return parent ::error ('folder-alnum ' );
71
70
}
71
+
72
+ parent ::createFolderByPath ($ path );
73
+ return parent ::$ success_response ;
72
74
}
73
75
}
Original file line number Diff line number Diff line change @@ -32,20 +32,29 @@ public function getItems()
32
32
33
33
private function getView ()
34
34
{
35
- $ view_type = 'grid ' ;
36
- $ show_list = request ('show_list ' );
37
-
38
- if ($ show_list === '1 ' ) {
39
- $ view_type = 'list ' ;
40
- } elseif (is_null ($ show_list )) {
41
- $ type_key = parent ::currentLfmType ();
42
- $ startup_view = config ('lfm. ' . $ type_key . 's_startup_view ' );
43
-
44
- if (in_array ($ startup_view , ['list ' , 'grid ' ])) {
45
- $ view_type = $ startup_view ;
46
- }
35
+ $ view_type = request ('show_list ' );
36
+
37
+ if (null === $ view_type ) {
38
+ return $ this ->composeViewName ($ this ->getStartupViewFromConfig ());
47
39
}
48
40
49
- return 'laravel-filemanager:: ' . $ view_type . '-view ' ;
41
+ $ view_mapping = [
42
+ '0 ' => 'grid ' ,
43
+ '1 ' => 'list '
44
+ ];
45
+
46
+ return $ this ->composeViewName ($ view_mapping [$ view_type ]);
47
+ }
48
+
49
+ private function composeViewName ($ view_type = 'grid ' )
50
+ {
51
+ return "laravel-filemanager:: $ view_type-view " ;
52
+ }
53
+
54
+ private function getStartupViewFromConfig ($ default = 'grid ' )
55
+ {
56
+ $ type_key = parent ::currentLfmType ();
57
+ $ startup_view = config ('lfm. ' . $ type_key . 's_startup_view ' , $ default );
58
+ return $ startup_view ;
50
59
}
51
60
}
Original file line number Diff line number Diff line change @@ -17,7 +17,6 @@ public function __construct()
17
17
{
18
18
$ delimiter = config ('lfm.url_prefix ' ) . '/ ' ;
19
19
$ url = urldecode (request ()->url ());
20
- // dd($delimiter);
21
20
$ external_path = substr ($ url , strpos ($ url , $ delimiter ) + strlen ($ delimiter ));
22
21
23
22
$ this ->file_path = base_path (config ('lfm.base_directory ' , 'public ' ) . '/ ' . $ external_path );
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ public function getResize()
27
27
28
28
$ scaled = false ;
29
29
30
+ // FIXME size should be configurable
30
31
if ($ original_width > 600 ) {
31
32
$ ratio = 600 / $ original_width ;
32
33
$ width = $ original_width * $ ratio ;
You can’t perform that action at this time.
0 commit comments