@@ -36,6 +36,11 @@ public function __construct()
3636 }
3737
3838
39+ /*****************************
40+ *** Private Functions ***
41+ *****************************/
42+
43+
3944 private function setFilePath ()
4045 {
4146 if ((Session::has ('lfm_type ' )) && (Session::get ('lfm_type ' ) == 'Files ' )) {
@@ -59,7 +64,7 @@ private function setDirPath()
5964 private function checkMyFolderExists ()
6065 {
6166 if (\Config::get ('lfm.allow_multi_user ' ) === true ) {
62- $ path = base_path ($ this ->file_location . Input::get ('base ' ));
67+ $ path = base_path ($ this ->file_location . Input::get ('working_dir ' ));
6368
6469 if (!File::exists ($ path )) {
6570 File::makeDirectory ($ path , $ mode = 0777 , true , true );
@@ -78,6 +83,47 @@ private function checkSharedFolderExists()
7883 }
7984
8085
86+ private function formatLocation ($ location , $ type = null )
87+ {
88+ $ working_dir = Input::get ('working_dir ' );
89+
90+ if ($ working_dir !== '/ ' ) {
91+ $ location .= $ working_dir . '/ ' ;
92+ }
93+
94+ if ($ type === 'thumb ' ) {
95+ $ location = $ location . Config::get ('lfm.thumb_folder_name ' ) . '/ ' ;
96+ }
97+
98+ return $ location ;
99+ }
100+
101+
102+ /****************************
103+ *** Shared Functions ***
104+ ****************************/
105+
106+
107+ public function getPath ($ type = null )
108+ {
109+ $ path = base_path () . '/ ' . $ this ->file_location ;
110+
111+ $ path = $ this ->formatLocation ($ path , $ type );
112+
113+ return $ path ;
114+ }
115+
116+
117+ public function getUrl ($ type = null )
118+ {
119+ $ url = $ this ->dir_location ;
120+
121+ $ url = $ this ->formatLocation ($ url , $ type );
122+
123+ return $ url ;
124+ }
125+
126+
81127 public function getDirectories ($ path )
82128 {
83129 $ thumb_folder_name = Config::get ('lfm.thumb_folder_name ' );
@@ -86,8 +132,7 @@ public function getDirectories($path)
86132 $ arr_dir = [];
87133
88134 foreach ($ all_directories as $ directory ) {
89- $ path_parts = explode ('/ ' , $ directory );
90- $ dir_name = end ($ path_parts );
135+ $ dir_name = $ this ->getFileName ($ directory );
91136
92137 if ($ dir_name !== $ thumb_folder_name ) {
93138 $ arr_dir [] = $ dir_name ;
@@ -98,6 +143,16 @@ public function getDirectories($path)
98143 }
99144
100145
146+ public function getFileName ($ file )
147+ {
148+ $ path_parts = explode ('/ ' , $ file );
149+
150+ $ filename = end ($ path_parts );
151+
152+ return $ filename ;
153+ }
154+
155+
101156 /**
102157 * Show the filemanager
103158 *
@@ -111,16 +166,13 @@ public function show()
111166 Session::put ('lfm_type ' , 'Images ' );
112167 }
113168
114- if (Input::has ('base ' )) {
115- $ working_dir = Input::get ('base ' );
116- $ base = $ this ->file_location . Input::get ('base ' ) . "/ " ;
169+ if (Input::has ('working_dir ' )) {
170+ $ working_dir = Input::get ('working_dir ' );
117171 } else {
118- $ working_dir = "/ " ;
119- $ base = $ this ->file_location ;
172+ $ working_dir = '/ ' ;
120173 }
121174
122175 return View::make ('laravel-filemanager::index ' )
123- ->with ('base ' , $ base )
124176 ->with ('working_dir ' , $ working_dir );
125177 }
126178
0 commit comments