@@ -39,9 +39,8 @@ public function __construct()
3939 throw new \Exception ('unexpected type parameter ' );
4040 }
4141
42- $ this ->checkMyFolderExists ();
43-
44- $ this ->checkSharedFolderExists ();
42+ $ this ->checkDefaultFolderExists ('user ' );
43+ $ this ->checkDefaultFolderExists ('share ' );
4544 }
4645
4746
@@ -52,11 +51,8 @@ public function __construct()
5251 */
5352 public function show ()
5453 {
55- if (Input::has ('working_dir ' )) {
56- $ working_dir = Input::get ('working_dir ' );
57- } else {
58- $ working_dir = '/ ' ;
59- }
54+ $ working_dir = DIRECTORY_SEPARATOR ;
55+ $ working_dir .= (Config::get ('lfm.allow_multi_user ' )) ? \Auth::user ()->user_field : Config::get ('lfm.shared_folder_name ' );
6056
6157 return View::make ('laravel-filemanager::index ' )
6258 ->with ('working_dir ' , $ working_dir )
@@ -69,42 +65,38 @@ public function show()
6965 *****************************/
7066
7167
72- private function checkMyFolderExists ( )
68+ private function checkDefaultFolderExists ( $ type = ' share ' )
7369 {
74- if (\Config::get ('lfm.allow_multi_user ' ) === true ) {
75- $ path = $ this ->getPath ();
76-
77- if (!File::exists ($ path )) {
78- File::makeDirectory ($ path , $ mode = 0777 , true , true );
79- }
70+ if ($ type === 'user ' && \Config::get ('lfm.allow_multi_user ' ) !== true ) {
71+ return ;
8072 }
81- }
82-
8373
84- private function checkSharedFolderExists ()
85- {
86- $ path = $ this ->getPath ('share ' );
74+ $ path = $ this ->getPath ($ type );
8775
8876 if (!File::exists ($ path )) {
8977 File::makeDirectory ($ path , $ mode = 0777 , true , true );
9078 }
9179 }
9280
9381
94- private function formatLocation ($ location , $ type = null )
82+ private function formatLocation ($ location , $ type = null , $ get_thumb = false )
9583 {
9684 if ($ type === 'share ' ) {
97- return $ location . Config::get ('lfm.shared_folder_name ' ) . '/ ' ;
85+ return $ location . Config::get ('lfm.shared_folder_name ' );
86+ } elseif ($ type === 'user ' ) {
87+ return $ location . \Auth::user ()->user_field ;
9888 }
9989
10090 $ working_dir = Input::get ('working_dir ' );
10191
102- if ($ working_dir !== ' / ' ) {
103- $ location .= $ working_dir . ' / ' ;
92+ if (substr ( $ working_dir, 0 , 1 ) === DIRECTORY_SEPARATOR ) {
93+ $ working_dir = substr ( $ working_dir, 1 ) ;
10494 }
10595
96+ $ location .= $ working_dir ;
97+
10698 if ($ type === 'thumb ' ) {
107- $ location = $ location . Config::get ('lfm.thumb_folder_name ' ) . ' / ' ;
99+ $ location .= Config::get ('lfm.thumb_folder_name ' ) . DIRECTORY_SEPARATOR ;
108100 }
109101
110102 return $ location ;
@@ -116,9 +108,9 @@ private function formatLocation($location, $type = null)
116108 ****************************/
117109
118110
119- public function getPath ($ type = null )
111+ public function getPath ($ type = null , $ get_thumb = false )
120112 {
121- $ path = base_path () . ' / ' . $ this ->file_location ;
113+ $ path = base_path () . DIRECTORY_SEPARATOR . $ this ->file_location ;
122114
123115 $ path = $ this ->formatLocation ($ path , $ type );
124116
@@ -157,10 +149,14 @@ public function getDirectories($path)
157149
158150 public function getFileName ($ file )
159151 {
160- $ path_parts = explode ('/ ' , $ file );
152+ $ lfm_dir_start = strpos ($ file , $ this ->file_location );
153+ $ working_dir_start = $ lfm_dir_start + strlen ($ this ->file_location );
154+ $ lfm_file_path = substr ($ file , $ working_dir_start );
161155
162- $ filename = end ($ path_parts );
156+ $ arr_dir = explode (DIRECTORY_SEPARATOR , $ lfm_file_path );
157+ $ arr_filename ['short ' ] = end ($ arr_dir );
158+ $ arr_filename ['long ' ] = DIRECTORY_SEPARATOR . $ lfm_file_path ;
163159
164- return $ filename ;
160+ return $ arr_filename ;
165161 }
166162}
0 commit comments