Skip to content

Commit d3947a6

Browse files
committed
modify controllers for new working_dir format
1 parent aa1216b commit d3947a6

11 files changed

+21
-29
lines changed

src/LaravelFilemanagerServiceProvider.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class LaravelFilemanagerServiceProvider extends ServiceProvider {
1717
*/
1818
public function boot()
1919
{
20-
if (Config::get('lfm.use_package_routes'))
20+
if (Config::get('lfm.use_package_routes', true))
2121
include __DIR__ . '/routes.php';
2222

2323
$this->loadTranslationsFrom(__DIR__.'/lang', 'laravel-filemanager');

src/controllers/CropController.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class CropController extends LfmController {
2020
public function getCrop()
2121
{
2222
$working_dir = Input::get('working_dir');
23-
$img = parent::getUrl() . Input::get('img');
23+
$img = parent::getUrl('directory') . Input::get('img');
2424

2525
return View::make('laravel-filemanager::crop')
2626
->with(compact('working_dir', 'img'));
@@ -46,7 +46,7 @@ public function getCropimage()
4646
// make new thumbnail
4747
$thumb_img = Image::make(public_path() . $image);
4848
$thumb_img->fit(200, 200)
49-
->save(parent::getPath('thumb') . parent::getFileName($image));
49+
->save(parent::getPath('thumb') . parent::getFileName($image)['short']);
5050
}
5151

5252
}

src/controllers/DeleteController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function getDelete()
2121
{
2222
$name_to_delete = Input::get('items');
2323

24-
$file_path = parent::getPath();
24+
$file_path = parent::getPath('directory');
2525

2626
$file_to_delete = $file_path . $name_to_delete;
2727
$thumb_to_delete = parent::getPath('thumb') . $name_to_delete;

src/controllers/DownloadController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class DownloadController extends LfmController {
1818
*/
1919
public function getDownload()
2020
{
21-
return Response::download(parent::getPath() . Input::get('file'));
21+
return Response::download(parent::getPath('directory') . Input::get('file'));
2222
}
2323

2424
}

src/controllers/FolderController.php

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
<?php namespace Unisharp\Laravelfilemanager\controllers;
22

33
use Unisharp\Laravelfilemanager\controllers\Controller;
4-
use Illuminate\Support\Facades\Config;
54
use Illuminate\Support\Facades\File;
65
use Illuminate\Support\Facades\Input;
7-
use Illuminate\Support\Facades\View;
8-
use Illuminate\Support\Str;
96
use Lang;
107

118
/**
@@ -29,7 +26,7 @@ public function getFolders()
2926
$lfm_share_path = parent::getFileName($share_path);
3027
$shared_folders = parent::getDirectories($share_path);
3128

32-
return View::make('laravel-filemanager::tree')
29+
return view('laravel-filemanager::tree')
3330
->with('user_dir', $lfm_user_path['long'])
3431
->with('dirs', $user_folders)
3532
->with('share_dir', $lfm_share_path['long'])
@@ -46,7 +43,7 @@ public function getAddfolder()
4643
{
4744
$folder_name = Input::get('name');
4845

49-
$path = parent::getPath() . DIRECTORY_SEPARATOR . $folder_name;
46+
$path = parent::getPath('directory') . $folder_name;
5047

5148
if (!File::exists($path)) {
5249
File::makeDirectory($path, $mode = 0777, true, true);

src/controllers/ItemsController.php

+1-5
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44
use Illuminate\Support\Facades\Config;
55
use Illuminate\Support\Facades\File;
66
use Illuminate\Support\Facades\Input;
7-
use Illuminate\Support\Facades\Redirect;
8-
use Illuminate\Support\Str;
9-
use Illuminate\Support\Facades\View;
10-
use Intervention\Image\Facades\Image;
117

128
/**
139
* Class ItemsController
@@ -32,7 +28,7 @@ public function getItems()
3228
$directories = parent::getDirectories($path);
3329
$thumb_url = parent::getUrl('thumb');
3430

35-
return View::make($view)
31+
return view($view)
3632
->with(compact('files', 'file_info', 'directories', 'thumb_url'));
3733
}
3834

src/controllers/LfmController.php

+7-5
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
use Illuminate\Support\Facades\Config;
55
use Illuminate\Support\Facades\File;
66
use Illuminate\Support\Facades\Input;
7-
use Illuminate\Support\Facades\Request;
8-
use Illuminate\Support\Facades\View;
9-
use Intervention\Image\Facades\Image;
107

118
/**
129
* Class LfmController
@@ -54,7 +51,7 @@ public function show()
5451
$working_dir = DIRECTORY_SEPARATOR;
5552
$working_dir .= (Config::get('lfm.allow_multi_user')) ? \Auth::user()->user_field : Config::get('lfm.shared_folder_name');
5653

57-
return View::make('laravel-filemanager::index')
54+
return view('laravel-filemanager::index')
5855
->with('working_dir', $working_dir)
5956
->with('file_type', $this->file_type);
6057
}
@@ -89,12 +86,17 @@ private function formatLocation($location, $type = null, $get_thumb = false)
8986

9087
$working_dir = Input::get('working_dir');
9188

89+
// remove first slash
9290
if (substr($working_dir, 0, 1) === DIRECTORY_SEPARATOR) {
9391
$working_dir = substr($working_dir, 1);
9492
}
9593

9694
$location .= $working_dir;
9795

96+
if ($type === 'directory' || $type === 'thumb') {
97+
$location .= DIRECTORY_SEPARATOR;
98+
}
99+
98100
if ($type === 'thumb') {
99101
$location .= Config::get('lfm.thumb_folder_name') . DIRECTORY_SEPARATOR;
100102
}
@@ -138,7 +140,7 @@ public function getDirectories($path)
138140
foreach ($all_directories as $directory) {
139141
$dir_name = $this->getFileName($directory);
140142

141-
if ($dir_name !== $thumb_folder_name) {
143+
if ($dir_name['short'] !== $thumb_folder_name) {
142144
$arr_dir[] = $dir_name;
143145
}
144146
}

src/controllers/RenameController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function getRename()
2121
$old_name = Input::get('file');
2222
$new_name = Input::get('new_name');
2323

24-
$file_path = parent::getPath();
24+
$file_path = parent::getPath('directory');
2525
$thumb_path = parent::getPath('thumb');
2626

2727
$old_file = $file_path . $old_name;

src/controllers/ResizeController.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function getResize()
2222
$ratio = 1.0;
2323
$image = Input::get('img');
2424

25-
$path_to_image = parent::getPath() . $image;
25+
$path_to_image = parent::getPath('directory') . $image;
2626
$original_width = Image::make($path_to_image)->width();
2727
$original_height = Image::make($path_to_image)->height();
2828

@@ -46,7 +46,7 @@ public function getResize()
4646
}
4747

4848
return View::make('laravel-filemanager::resize')
49-
->with('img', parent::getUrl() . $image)
49+
->with('img', parent::getUrl('directory') . $image)
5050
->with('height', number_format($height, 0))
5151
->with('width', $width)
5252
->with('original_height', $original_height)

src/middleware/MultiUser.php

-4
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,6 @@ private function validDir($previous_dir)
3636
return true;
3737
}
3838

39-
// if (strpos($previous_dir, (string)\Auth::user()->user_field) === false) {
40-
// return true;
41-
// }
42-
4339
return false;
4440
}
4541
}

src/views/crop.blade.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,13 @@ function performCrop() {
5252
dataType: "text",
5353
url: "/laravel-filemanager/cropimage",
5454
data: {
55-
img: $("#img").val(),
55+
img: '{{ $img }}',
5656
working_dir: $("#working_dir").val(),
5757
dataX: $("#dataX").val(),
5858
dataY: $("#dataY").val(),
5959
dataHeight: $("#dataHeight").val(),
60-
dataWidth: $("#dataWidth").val()
60+
dataWidth: $("#dataWidth").val(),
61+
type: $('#type').val()
6162
},
6263
cache: false
6364
}).done(function (data) {

0 commit comments

Comments
 (0)