Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions src/LaravelFilemanagerServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
<?php namespace Unisharp\Laravelfilemanager;
<?php

namespace Unisharp\Laravelfilemanager;

use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\ServiceProvider;

/**
* Class LaravelFilemanagerServiceProvider
* @package Unisharp\Laravelfilemanager
* Class LaravelFilemanagerServiceProvider.
*/
class LaravelFilemanagerServiceProvider extends ServiceProvider {

class LaravelFilemanagerServiceProvider extends ServiceProvider
{
/**
* Bootstrap the application services.
*
Expand Down Expand Up @@ -37,7 +38,7 @@ public function boot()
], 'lfm_view');

$this->publishes([
__DIR__.'/Handlers/LfmConfigHandler.php' => base_path('app/Handlers/LfmConfigHandler.php')
__DIR__.'/Handlers/LfmConfigHandler.php' => base_path('app/Handlers/LfmConfigHandler.php'),
], 'lfm_handler');
}

Expand Down
6 changes: 3 additions & 3 deletions src/config/lfm.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

// Middlewares which should be applied to all package routes.
// For laravel 5.1 and before, remove 'web' from the array.
'middlewares' => ['web','auth'],
'middlewares' => ['web', 'auth'],

// The url to this package. Change it if necessary.
'prefix' => 'laravel-filemanager',
Expand Down Expand Up @@ -164,7 +164,7 @@
| directives are not supported.
*/
'php_ini_overrides' => [
'memory_limit' => '256M'
]
'memory_limit' => '256M',
],

];
4 changes: 3 additions & 1 deletion src/controllers/Controller.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php namespace Unisharp\Laravelfilemanager\controllers;
<?php

namespace Unisharp\Laravelfilemanager\controllers;

use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
Expand Down
23 changes: 11 additions & 12 deletions src/controllers/CropController.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<?php namespace Unisharp\Laravelfilemanager\controllers;
<?php

namespace Unisharp\Laravelfilemanager\controllers;

use Unisharp\Laravelfilemanager\controllers\Controller;
use Intervention\Image\Facades\Image;
use Unisharp\Laravelfilemanager\Events\ImageIsCropping;
use Unisharp\Laravelfilemanager\Events\ImageWasCropped;

/**
* Class CropController
* @package Unisharp\Laravelfilemanager\controllers
* Class CropController.
*/
class CropController extends LfmController
{
/**
* Show crop page
* Show crop page.
*
* @return mixed
*/
Expand All @@ -25,20 +25,19 @@ public function getCrop()
->with(compact('working_dir', 'img'));
}


/**
* Crop the image (called via ajax)
* Crop the image (called via ajax).
*/
public function getCropimage($overWrite = true)
{
$dataX = request('dataX');
$dataY = request('dataY');
$dataX = request('dataX');
$dataY = request('dataY');
$dataHeight = request('dataHeight');
$dataWidth = request('dataWidth');
$dataWidth = request('dataWidth');
$image_path = parent::getCurrentPath(request('img'));
$crop_path = $image_path;
$crop_path = $image_path;

if(!$overWrite) {
if (! $overWrite) {
$fileParts = explode('.', request('img'));
$fileParts[count($fileParts) - 2] = $fileParts[count($fileParts) - 2] . '_cropped_' . time();
$crop_path = parent::getCurrentPath(implode('.', $fileParts));
Expand Down
13 changes: 7 additions & 6 deletions src/controllers/DeleteController.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
<?php namespace Unisharp\Laravelfilemanager\controllers;
<?php

namespace Unisharp\Laravelfilemanager\controllers;

use Illuminate\Support\Facades\File;
use Unisharp\Laravelfilemanager\Events\ImageIsDeleting;
use Unisharp\Laravelfilemanager\Events\ImageWasDeleted;

/**
* Class CropController
* @package Unisharp\Laravelfilemanager\controllers
* Class CropController.
*/
class DeleteController extends LfmController
{
/**
* Delete image and associated thumbnail
* Delete image and associated thumbnail.
*
* @return mixed
*/
Expand All @@ -28,12 +29,12 @@ public function getDelete()
return parent::error('folder-name');
}

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

if (File::isDirectory($file_to_delete)) {
if (!parent::directoryIsEmpty($file_to_delete)) {
if (! parent::directoryIsEmpty($file_to_delete)) {
return parent::error('delete-folder');
}

Expand Down
8 changes: 4 additions & 4 deletions src/controllers/DemoController.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php namespace Unisharp\Laravelfilemanager\controllers;
<?php

namespace Unisharp\Laravelfilemanager\controllers;

/**
* Class DemoController
* @package Unisharp\Laravelfilemanager\controllers
* Class DemoController.
*/
class DemoController extends LfmController
{

/**
* @return mixed
*/
Expand Down
9 changes: 5 additions & 4 deletions src/controllers/DownloadController.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<?php namespace Unisharp\Laravelfilemanager\controllers;
<?php

namespace Unisharp\Laravelfilemanager\controllers;

/**
* Class DownloadController
* @package Unisharp\Laravelfilemanager\controllers
* Class DownloadController.
*/
class DownloadController extends LfmController
{
/**
* Download a file
* Download a file.
*
* @return mixed
*/
Expand Down
17 changes: 9 additions & 8 deletions src/controllers/FolderController.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
<?php namespace Unisharp\Laravelfilemanager\controllers;
<?php

namespace Unisharp\Laravelfilemanager\controllers;

use Illuminate\Support\Facades\File;

/**
* Class FolderController
* @package Unisharp\Laravelfilemanager\controllers
* Class FolderController.
*/
class FolderController extends LfmController
{
/**
* Get list of folders as json to populate treeview
* Get list of folders as json to populate treeview.
*
* @return mixed
*/
Expand All @@ -34,21 +35,20 @@ public function getFolders()
return strcmp($a->name, $b->name);
});

array_push($root_folders, (object)[
array_push($root_folders, (object) [
'name' => trans('laravel-filemanager::lfm.title-' . $lang_key),
'path' => parent::getInternalPath($root_folder_path),
'children' => $children,
'has_next' => !($lang_key == end($folder_types))
'has_next' => ! ($lang_key == end($folder_types)),
]);
}

return view('laravel-filemanager::tree')
->with(compact('root_folders'));
}


/**
* Add a new folder
* Add a new folder.
*
* @return mixed
*/
Expand All @@ -66,6 +66,7 @@ public function getAddfolder()
return parent::error('folder-alnum');
} else {
parent::createFolderByPath($path);

return parent::$success_response;
}
}
Expand Down
18 changes: 8 additions & 10 deletions src/controllers/ItemsController.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
<?php namespace Unisharp\Laravelfilemanager\controllers;
<?php

use Illuminate\Support\Facades\File;
namespace Unisharp\Laravelfilemanager\controllers;

/**
* Class ItemsController
* @package Unisharp\Laravelfilemanager\controllers
* Class ItemsController.
*/
class ItemsController extends LfmController
{
/**
* Get the images to load for a selected folder
* Get the images to load for a selected folder.
*
* @return mixed
*/
Expand All @@ -22,22 +21,21 @@ public function getItems()
$directories = parent::sortFilesAndDirectories(parent::getDirectories($path), $sort_type);

return [
'html' => (string)view($this->getView())->with([
'html' => (string) view($this->getView())->with([
'files' => $files,
'directories' => $directories,
'items' => array_merge($directories, $files)
'items' => array_merge($directories, $files),
]),
'working_dir' => parent::getInternalPath($path)
'working_dir' => parent::getInternalPath($path),
];
}


private function getView()
{
$view_type = 'grid';
$show_list = request('show_list');

if ($show_list === "1") {
if ($show_list === '1') {
$view_type = 'list';
} elseif (is_null($show_list)) {
$type_key = parent::currentLfmType();
Expand Down
11 changes: 6 additions & 5 deletions src/controllers/LfmController.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?php namespace Unisharp\Laravelfilemanager\controllers;
<?php

namespace Unisharp\Laravelfilemanager\controllers;

use Unisharp\Laravelfilemanager\traits\LfmHelpers;

/**
* Class LfmController
* @package Unisharp\Laravelfilemanager\controllers
* Class LfmController.
*/
class LfmController extends Controller
{
Expand All @@ -18,7 +19,7 @@ public function __construct()
}

/**
* Show the filemanager
* Show the filemanager.
*
* @return mixed
*/
Expand All @@ -39,7 +40,7 @@ public function getErrors()
$mine_config = 'lfm.valid_' . $type_key . '_mimetypes';
$config_error = null;

if (!is_array(config($mine_config))) {
if (! is_array(config($mine_config))) {
array_push($arr_errors, 'Config : ' . $mine_config . ' is not a valid array.');
}

Expand Down
17 changes: 9 additions & 8 deletions src/controllers/RedirectController.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<?php namespace Unisharp\Laravelfilemanager\controllers;
<?php

namespace Unisharp\Laravelfilemanager\controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Response;
use Illuminate\Http\Request;

/**
* Class RedirectController
* @package Unisharp\Laravelfilemanager\controllers
* Class RedirectController.
*/
class RedirectController extends LfmController
{
Expand All @@ -23,7 +24,7 @@ public function __construct()
}

/**
* Get image from custom directory by route
* Get image from custom directory by route.
*
* @param string $image_path
* @return string
Expand All @@ -34,7 +35,7 @@ public function getImage($base_path, $image_name)
}

/**
* Get file from custom directory by route
* Get file from custom directory by route.
*
* @param string $file_name
* @return string
Expand All @@ -50,15 +51,15 @@ private function responseImageOrFile()
{
$file_path = $this->file_path;

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

$file = File::get($file_path);
$type = parent::getFileType($file_path);

$response = Response::make($file);
$response->header("Content-Type", $type);
$response->header('Content-Type', $type);

return $response;
}
Expand Down
Loading