44use Illuminate \Support \Facades \Config ;
55use Illuminate \Support \Facades \File ;
66use Illuminate \Support \Facades \Input ;
7+ use Illuminate \Support \Facades \Session ;
78use Illuminate \Support \Str ;
89
910/**
1213 */
1314class RenameController extends Controller {
1415
16+ protected $ file_location ;
17+
18+ function __construct ()
19+ {
20+ if (Session::get ('lfm_type ' ) == "Images " )
21+ $ this ->file_location = Config::get ('lfm.images_dir ' );
22+ else
23+ $ this ->file_location = Config::get ('lfm.files_dir ' );
24+ }
25+
1526 /**
1627 * @return string
1728 */
@@ -23,49 +34,53 @@ function getRename(){
2334
2435 if ($ dir == "/ " )
2536 {
26- if (File::exists (base_path () . "/ " . Config:: get ( ' lfm.images_dir ' ) . $ new_name ))
37+ if (File::exists (base_path () . "/ " . $ this -> file_location . $ new_name ))
2738 {
2839 return "File name already in use! " ;
2940 } else
3041 {
31- if (File::isDirectory (base_path () . "/ " . Config:: get ( ' lfm.images_dir ' ) . $ file_to_rename ))
42+ if (File::isDirectory (base_path () . "/ " . $ this -> file_location . $ file_to_rename ))
3243 {
33- File::move (base_path () . "/ " . Config:: get ( ' lfm.images_dir ' ) . $ file_to_rename ,
34- base_path () . "/ " . Config:: get ( ' lfm.images_dir ' ) . $ new_name );
44+ File::move (base_path () . "/ " . $ this -> file_location . $ file_to_rename ,
45+ base_path () . "/ " . $ this -> file_location . $ new_name );
3546
3647 return "OK " ;
3748 } else
3849 {
39- File::move (base_path () . "/ " . Config::get ('lfm.images_dir ' ) . $ file_to_rename ,
40- base_path () . "/ " . Config::get ('lfm.images_dir ' ) . $ new_name );
41- // rename thumbnail
42- File::move (base_path () . "/ " . Config::get ('lfm.images_dir ' ) . "thumbs/ " . $ file_to_rename ,
43- base_path () . "/ " . Config::get ('lfm.images_dir ' ) . "thumbs/ " . $ new_name );
50+ File::move (base_path () . "/ " . $ this ->file_location . $ file_to_rename ,
51+ base_path () . "/ " . $ this ->file_location . $ new_name );
52+
53+ if (Session::get ('lfm_type ' ) == "Images " )
54+ {
55+ // rename thumbnail
56+ File::move (base_path () . "/ " . $ this ->file_location . "thumbs/ " . $ file_to_rename ,
57+ base_path () . "/ " . $ this ->file_location . "thumbs/ " . $ new_name );
58+ }
4459
4560 return "OK " ;
4661 }
4762 }
4863 } else
4964 {
50- if (File::exists (base_path () . "/ " . Config:: get ( ' lfm.images_dir ' ) . $ dir . "/ " . $ new_name ))
65+ if (File::exists (base_path () . "/ " . $ this -> file_location . $ dir . "/ " . $ new_name ))
5166 {
5267 return "File name already in use! " ;
5368 } else
5469 {
55- //return base_path() . "/" . Config::get('lfm.images_dir') . $dir . "/" . $file_to_rename;
56-
57- if (File::isDirectory (base_path () . "/ " . Config::get ('lfm.images_dir ' ) . $ dir . "/ " . $ file_to_rename ))
70+ if (File::isDirectory (base_path () . "/ " . $ this ->file_location . $ dir . "/ " . $ file_to_rename ))
5871 {
59- File::move (base_path () . "/ " . Config:: get ( ' lfm.images_dir ' ) . $ dir . "/ " . $ file_to_rename ,
60- base_path () . "/ " . Config:: get ( ' lfm.images_dir ' ) . $ dir . "/ " . $ new_name );
72+ File::move (base_path () . "/ " . $ this -> file_location . $ dir . "/ " . $ file_to_rename ,
73+ base_path () . "/ " . $ this -> file_location . $ dir . "/ " . $ new_name );
6174 } else
6275 {
63- File::move (base_path () . "/ " . Config::get ('lfm.images_dir ' ) . $ dir . "/ " . $ file_to_rename ,
64- base_path () . "/ " . Config::get ('lfm.images_dir ' ) . $ dir . "/ " . $ new_name );
65- // rename thumbnail
66- File::move (base_path () . "/ " . Config::get ('lfm.images_dir ' ) . $ dir . "/thumbs/ " . $ file_to_rename ,
67- base_path () . "/ " . Config::get ('lfm.images_dir ' ) . $ dir . "/thumbs/ " . $ new_name );
76+ File::move (base_path () . "/ " . $ this ->file_location . $ dir . "/ " . $ file_to_rename ,
77+ base_path () . "/ " . $ this ->file_location . $ dir . "/ " . $ new_name );
6878
79+ if (Session::get ('lfm_type ' ) == "Images " )
80+ {
81+ File::move (base_path () . "/ " . $ this ->file_location . $ dir . "/thumbs/ " . $ file_to_rename ,
82+ base_path () . "/ " . $ this ->file_location . $ dir . "/thumbs/ " . $ new_name );
83+ }
6984 return "OK " ;
7085 }
7186 }
0 commit comments