Skip to content

Commit 33d6d91

Browse files
committed
use parent:: to call functions from LfmHelper
1 parent 4d6637b commit 33d6d91

File tree

7 files changed

+39
-39
lines changed

7 files changed

+39
-39
lines changed

src/controllers/DeleteController.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,31 +25,31 @@ public function getDelete()
2525
event(new ImageIsDeleting($file_to_delete));
2626

2727
if (is_null($name_to_delete)) {
28-
return $this->error('folder-name');
28+
return parent::error('folder-name');
2929
}
3030

3131
if (!File::exists($file_to_delete)) {
32-
return $this->error('folder-not-found', ['folder' => $file_to_delete]);
32+
return parent::error('folder-not-found', ['folder' => $file_to_delete]);
3333
}
3434

3535
if (File::isDirectory($file_to_delete)) {
3636
if (!parent::directoryIsEmpty($file_to_delete)) {
37-
return $this->error('delete-folder');
37+
return parent::error('delete-folder');
3838
}
3939

4040
File::deleteDirectory($file_to_delete);
4141

42-
return $this->success_response;
42+
return parent::$success_response;
4343
}
4444

45-
if ($this->fileIsImage($file_to_delete)) {
45+
if (parent::fileIsImage($file_to_delete)) {
4646
File::delete($thumb_to_delete);
4747
}
4848

4949
File::delete($file_to_delete);
5050

5151
event(new ImageWasDeleted($file_to_delete));
5252

53-
return $this->success_response;
53+
return parent::$success_response;
5454
}
5555
}

src/controllers/FolderController.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,18 @@ public function getFolders()
4949
*/
5050
public function getAddfolder()
5151
{
52-
$folder_name = $this->translateFromUtf8(trim(request('name')));
52+
$folder_name = parent::translateFromUtf8(trim(request('name')));
5353

5454
$path = parent::getCurrentPath($folder_name);
5555

5656
if (empty($folder_name)) {
57-
return $this->error('folder-name');
57+
return parent::error('folder-name');
5858
} elseif (File::exists($path)) {
59-
return $this->error('folder-exist');
59+
return parent::error('folder-exist');
6060
} elseif (config('lfm.alphanumeric_directory') && preg_match('/[^\w-]/i', $folder_name)) {
61-
return $this->error('folder-alnum');
61+
return parent::error('folder-alnum');
6262
} else {
63-
$this->createFolderByPath($path);
63+
parent::createFolderByPath($path);
6464
return $this->success_response;
6565
}
6666
}

src/controllers/ItemsController.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,19 @@ class ItemsController extends LfmController
1515
*/
1616
public function getItems()
1717
{
18-
$path = $this->getCurrentPath();
18+
$path = parent::getCurrentPath();
1919
$sort_type = request('sort_type');
2020

21-
$files = $this->sortFilesAndDirectories($this->getFilesWithInfo($path), $sort_type);
22-
$directories = $this->sortFilesAndDirectories($this->getDirectories($path), $sort_type);
21+
$files = parent::sortFilesAndDirectories(parent::getFilesWithInfo($path), $sort_type);
22+
$directories = parent::sortFilesAndDirectories(parent::getDirectories($path), $sort_type);
2323

2424
return [
2525
'html' => (string)view($this->getView())->with([
2626
'files' => $files,
2727
'directories' => $directories,
2828
'items' => array_merge($directories, $files)
2929
]),
30-
'working_dir' => $this->getInternalPath($path)
30+
'working_dir' => parent::getInternalPath($path)
3131
];
3232
}
3333

@@ -40,7 +40,7 @@ private function getView()
4040
if ($show_list === "1") {
4141
$view_type = 'list';
4242
} elseif (is_null($show_list)) {
43-
$type_key = $this->currentLfmType();
43+
$type_key = parent::currentLfmType();
4444
$startup_view = config('lfm.' . $type_key . 's_startup_view');
4545

4646
if (in_array($startup_view, ['list', 'grid'])) {

src/controllers/RedirectController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function getFile(Request $request, $base_path, $file_name)
3636

3737
private function responseImageOrFile($file_name)
3838
{
39-
$file_path = $this->getCurrentPath($file_name);
39+
$file_path = parent::getCurrentPath($file_name);
4040

4141
if (!File::exists($file_path)) {
4242
abort(404);

src/controllers/RenameController.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@ class RenameController extends LfmController
1717
*/
1818
public function getRename()
1919
{
20-
$old_name = $this->translateFromUtf8(request('file'));
21-
$new_name = $this->translateFromUtf8(trim(request('new_name')));
20+
$old_name = parent::translateFromUtf8(request('file'));
21+
$new_name = parent::translateFromUtf8(trim(request('new_name')));
2222

2323
$old_file = parent::getCurrentPath($old_name);
2424

2525
if (empty($new_name)) {
2626
if (File::isDirectory($old_file)) {
27-
return $this->error('folder-name');
27+
return parent::error('folder-name');
2828
} else {
29-
return $this->error('file-name');
29+
return parent::error('file-name');
3030
}
3131
}
3232

@@ -44,25 +44,25 @@ public function getRename()
4444
}
4545

4646
if (config('lfm.alphanumeric_directory') && preg_match('/[^\w-]/i', $new_name)) {
47-
return $this->error('folder-alnum');
47+
return parent::error('folder-alnum');
4848
} elseif (File::exists($new_file)) {
49-
return $this->error('rename');
49+
return parent::error('rename');
5050
}
5151

5252
if (File::isDirectory($old_file)) {
5353
File::move($old_file, $new_file);
5454
event(new FolderWasRenamed($old_file, $new_file));
55-
return $this->success_response;
55+
return parent::$success_response;
5656
}
5757

58-
if ($this->fileIsImage($old_file)) {
58+
if (parent::fileIsImage($old_file)) {
5959
File::move(parent::getThumbPath($old_name), parent::getThumbPath($new_name));
6060
}
6161

6262
File::move($old_file, $new_file);
6363

6464
event(new ImageWasRenamed($old_file, $new_file));
6565

66-
return $this->success_response;
66+
return parent::$success_response;
6767
}
6868
}

src/controllers/ResizeController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function performResize()
6666
event(new ImageIsResizing($image_path));
6767
Image::make($image_path)->resize($width, $height)->save();
6868
event(new ImageWasResized($image_path));
69-
return $this->success_response;
69+
return parent::$success_response;
7070
} catch (Exception $e) {
7171
return "width : " . $width . " height: " . $height;
7272
return $e;

src/controllers/UploadController.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function upload()
3434
}
3535

3636
if (is_array($files)) {
37-
$response = count($error_bag) > 0 ? $error_bag : $this->success_response;
37+
$response = count($error_bag) > 0 ? $error_bag : parent::$success_response;
3838
} else { // upload via ckeditor 'Upload' tab
3939
$response = $this->useFile($new_filename);
4040
}
@@ -54,7 +54,7 @@ private function proceedSingleUpload($file)
5454

5555
event(new ImageIsUploading($new_file_path));
5656
try {
57-
if ($this->fileIsImage($file) && $this->isImageToThumb($file)) {
57+
if (parent::fileIsImage($file) && parent::isImageToThumb($file)) {
5858
Image::make($file->getRealPath())
5959
->orientate() //Apply orientation from exif data
6060
->save($new_file_path, 90);
@@ -65,7 +65,7 @@ private function proceedSingleUpload($file)
6565
File::move($file->path(), $new_file_path);
6666
}
6767
} catch (\Exception $e) {
68-
return $this->error('invalid');
68+
return parent::error('invalid');
6969
}
7070
event(new ImageWasUploaded(realpath($new_file_path)));
7171

@@ -78,40 +78,40 @@ private function uploadValidator($file)
7878
$force_invalid = false;
7979

8080
if (empty($file)) {
81-
return $this->error('file-empty');
81+
return parent::error('file-empty');
8282
} elseif (!$file instanceof UploadedFile) {
83-
return $this->error('instance');
83+
return parent::error('instance');
8484
} elseif ($file->getError() == UPLOAD_ERR_INI_SIZE) {
8585
$max_size = ini_get('upload_max_filesize');
86-
return $this->error('file-size', ['max' => $max_size]);
86+
return parent::error('file-size', ['max' => $max_size]);
8787
} elseif ($file->getError() != UPLOAD_ERR_OK) {
8888
return 'File failed to upload. Error code: ' . $file->getError();
8989
}
9090

9191
$new_filename = $this->getNewName($file);
9292

9393
if (File::exists(parent::getCurrentPath($new_filename))) {
94-
return $this->error('file-exist');
94+
return parent::error('file-exist');
9595
}
9696

9797
$mimetype = $file->getMimeType();
9898

9999
// size to kb unit is needed
100100
$file_size = $file->getSize() / 1000;
101-
$type_key = $this->currentLfmType();
101+
$type_key = parent::currentLfmType();
102102

103103
if (config('lfm.should_validate_mime')) {
104104
$mine_config = 'lfm.valid_' . $type_key . '_mimetypes';
105105
$valid_mimetypes = config($mine_config, []);
106106
if (false === in_array($mimetype, $valid_mimetypes)) {
107-
return $this->error('mime') . $mimetype;
107+
return parent::error('mime') . $mimetype;
108108
}
109109
}
110110

111111
if (config('lfm.should_validate_size')) {
112112
$max_size = config('lfm.max_' . $type_key . '_size', 0);
113113
if ($file_size > $max_size) {
114-
return $this->error('size') . $mimetype;
114+
return parent::error('size') . $mimetype;
115115
}
116116
}
117117

@@ -120,7 +120,7 @@ private function uploadValidator($file)
120120

121121
private function getNewName($file)
122122
{
123-
$new_filename = $this->translateFromUtf8(trim(pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME)));
123+
$new_filename = parent::translateFromUtf8(trim(pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME)));
124124

125125
if (config('lfm.rename_file') === true) {
126126
$new_filename = uniqid();
@@ -134,7 +134,7 @@ private function getNewName($file)
134134
private function makeThumb($new_filename)
135135
{
136136
// create thumb folder
137-
$this->createFolderByPath(parent::getThumbPath());
137+
parent::createFolderByPath(parent::getThumbPath());
138138

139139
// create thumb image
140140
Image::make(parent::getCurrentPath($new_filename))

0 commit comments

Comments
 (0)