Skip to content

Commit

Permalink
Merge branch 'release/v2.4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
alexusmai committed Jul 17, 2019
2 parents 5ff608e + 5005a3a commit 494d67d
Show file tree
Hide file tree
Showing 21 changed files with 739 additions and 184 deletions.
64 changes: 27 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,41 +60,32 @@
* You can use different repositories for the rules - an array (configuration file), a database (there is an example implementation), or you can add your own.
* You can hide files and folders that are not accessible.
* Events (v2.2)
* Supported locales : ru, en, ar
* Thumbnails lazy load
* Dynamic configuration (v2.4)
* Supported locales : ru, en, ar, sr

## In new version 2.3
## In new version 2.4

In new version you can set default disk and default path
Now you can create your own config repositories, it will allow to change your configuration dynamically.

You have two variants for how to do it:
How to do it:

1. Add this params to the config file (config/file-manager.php)
Create new class - example - TestConfigRepository

```php
/**
* Default path for left manager
* null - root directory
*/
'leftPath' => 'directory/sub-directory',

/**
* Default path for right manager
* null - root directory
*/
'rightPath' => null,
```
namespace App\Http;

2 Or you can add this params in URL
use Alexusmai\LaravelFileManager\Services\ConfigService\ConfigRepository;

```
http://site.name/?leftDisk=diskName&leftPath=directory
http://site.name/?leftDisk=diskName&leftPath=directory2&rightDisk=diskName2&rightPath=images
class TestConfigRepository implements ConfigRepository
{
// implement all methods from interface
}
```

leftDisk and leftPath is default for the file manager windows configuration - 1,2
For example see [src/Services/ConfigService/DefaultConfigRepository.php](https://github.com/alexusmai/laravel-file-manager/blob/master/src/Services/ConfigService/DefaultConfigRepository.php)


## Upgrading to version 2.3
## Upgrading to version 2.4

Update pre-compiled css and js files and config file - file-manager.php

Expand All @@ -106,26 +97,25 @@ php artisan vendor:publish --tag=fm-config --force
php artisan vendor:publish --tag=fm-assets --force
```

You can update the config file manually - add new params:
If you use the ACL, now you don't need to add the acl middleware to configuration.

```php
/**
* Default path for left manager
* null - root directory
*/
'leftPath' => null,

/**
* Default path for right manager
* null - root directory
*/
'rightPath' => null,
```
//======= In old versions ==========
'acl' => true,

// add acl middleware to your array
'middleware' => ['web', 'fm-acl'],

//======= In a new version =========
'acl' => true,

'middleware' => ['web'],
```

## Thanks

* Khalid Bj [D34DlyM4N](https://github.com/D34DlyM4N)
* NeoSon [lkloon123](https://github.com/lkloon123)
* Aleksandar Stevanović [aleks989](https://github.com/aleks989)


76 changes: 55 additions & 21 deletions config/file-manager.php
Original file line number Diff line number Diff line change
@@ -1,58 +1,96 @@
<?php

use Alexusmai\LaravelFileManager\Services\ConfigService\DefaultConfigRepository;
use Alexusmai\LaravelFileManager\Services\ACLService\ConfigACLRepository;

return [

/**
* list of disk names that you want to use
* Set Config repository
*
* Default - DefaultConfigRepository get config from this file
*/
'configRepository' => DefaultConfigRepository::class,

/**
* ACL rules repository
*
* Default - ConfigACLRepository (see rules in - aclRules)
*/
'aclRepository' => ConfigACLRepository::class,

//********* Default configuration for DefaultConfigRepository **************

/**
* List of disk names that you want to use
* (from config/filesystems)
*/
'diskList' => ['public'],
'diskList' => ['public'],

/**
* Default disk for left manager
*
* null - auto select the first disk in the disk list
*/
'leftDisk' => null,
'leftDisk' => null,

/**
* Default disk for right manager
*
* null - auto select the first disk in the disk list
*/
'rightDisk' => null,

/**
* Default path for left manager
*
* null - root directory
*/
'leftPath' => null,
'leftPath' => null,

/**
* Default path for right manager
*
* null - root directory
*/
'rightPath' => null,

/**
* Image cache ( Intervention Image Cache )
*
* set null, 0 - if you don't need cache (default)
* if you want use cache - set the number of minutes for which the value should be cached
*/
'cache' => null,

/**
* File manager modules configuration
*
* 1 - only one file manager window
* 2 - one file manager window with directories tree module
* 3 - two file manager windows
*/
'windowsConfig' => 2,

/**
* File upload - Max file size in KB
*
* null - no restrictions
*/
'maxUploadFileSize' => null,

/**
* File upload - Allow these file types
*
* [] - no restrictions
*/
'allowFileTypes' => [],

/***************************************************************************
* Middleware
*
* Add your middleware name to array -> ['web', 'auth', 'admin']
* !!!! RESTRICT ACCESS FOR NON ADMIN USERS !!!!
*
* !!! For using ACL - add 'fm-acl' to array !!! ['web', 'fm-acl']
*/
'middleware' => ['web'],

Expand All @@ -65,6 +103,7 @@

/**
* Hide files and folders from file-manager if user doesn't have access
*
* ACL access level = 0
*/
'aclHideFromFM' => true,
Expand All @@ -76,18 +115,20 @@
*
* whitelist - Deny anything(access - 0 - deny), that not allowed by the ACL rules list
*/
'aclStrategy' => 'blacklist',
'aclStrategy' => 'blacklist',

/**
* ACL rules repository
* ACL Rules cache
*
* default - config file(ConfigACLRepository)
* null or value in minutes
*/
'aclRepository' => Alexusmai\LaravelFileManager\Services\ACLService\ConfigACLRepository::class,
//'aclRepository' => Alexusmai\LaravelFileManager\Services\ACLService\DBACLRepository::class,
'aclRulesCache' => null,

/**
* ACL rules list - used for default repository
//********* Default configuration for DefaultConfigRepository END **********


/***************************************************************************
* ACL rules list - used for default ACL repository (ConfigACLRepository)
*
* 1 it's user ID
* null - for not authenticated user
Expand All @@ -104,7 +145,7 @@
*
* access: 0 - deny, 1 - read, 2 - read/write
*/
'aclRules' => [
'aclRules' => [
null => [
//['disk' => 'public', 'path' => '/', 'access' => 2],
],
Expand All @@ -113,11 +154,4 @@
//['disk' => 'public', 'path' => 'files/*', 'access' => 1],
],
],

/**
* ACL Rules cache
*
* null or value in minutes
*/
'aclRulesCache' => null,
];
5 changes: 1 addition & 4 deletions docs/acl.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@ You can use the access control system to differentiate access to files and folde
For this you need to make the following settings.
Open configuration file - config/file-manager.php

1. Turn ON ACL system and add fm-acl middleware
1. Turn ON ACL system (fm-acl middleware will turn ON automatically)

```php
// set true
'acl' => true,

// add acl middleware to your array
'middleware' => ['web', 'fm-acl'],
```

2. You can hide files and folders to which the user does not have access(access = 0).
Expand Down
39 changes: 39 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,45 @@ leftDisk and leftPath is default for the file manager windows configuration - 1,
'diskList' => ['images', 'public'],
```

## Dynamic configuration

You can create your own configuration, for example for different users or their roles.

Create new class - example - TestConfigRepository

```php
namespace App\Http;

use Alexusmai\LaravelFileManager\Services\ConfigService\ConfigRepository;

class TestConfigRepository implements ConfigRepository
{
// implement all methods from interface

/**
* Get disk list
*
* ['public', 'local', 's3']
*
* @return array
*/
public function getDiskList(): array
{
if (\Auth::id() === 1) {
return [
['public', 'local', 's3'],
];
}

return ['public'];
}

...
}
```

For example see [src/Services/ConfigService/DefaultConfigRepository.php](https://github.com/alexusmai/laravel-file-manager/blob/master/src/Services/ConfigService/DefaultConfigRepository.php)

## What's next

[ACL](./acl.md)
Expand Down
2 changes: 1 addition & 1 deletion resources/assets/css/file-manager.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions resources/assets/js/file-manager.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion resources/assets/js/file-manager.js.map

Large diffs are not rendered by default.

39 changes: 20 additions & 19 deletions resources/lang/ar/response.php
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
<?php

return [
'noConfig' => 'الاعدادت غير متوفرة!',
'notFound' => 'غير متوفر!',
'diskNotFound' => 'القرص غير موجود!',
'pathNotFound' => 'مسار غير موجود!',
'diskSelected' => 'تم اختيار القرص!',
'noConfig' => 'الاعدادت غير متوفرة!',
'notFound' => 'غير متوفر!',
'diskNotFound' => 'القرص غير موجود!',
'pathNotFound' => 'مسار غير موجود!',
'diskSelected' => 'تم اختيار القرص!',
// files
'fileExist' => 'الملف موجود بالفعل!',
'fileCreated' => 'تم إنشاء الملف!',
'fileUpdated' => 'تم تحديث الملف!',
'fileNotFound' => 'الملف غير موجود!',
'fileExist' => 'الملف موجود بالفعل!',
'fileCreated' => 'تم إنشاء الملف!',
'fileUpdated' => 'تم تحديث الملف!',
'fileNotFound' => 'الملف غير موجود!',
// directories
'dirExist' => 'المجلد موجود بالفعل!',
'dirCreated' => 'تم أنشاء المجلد!',
'dirNotFound' => 'المجلد غير موجود',
'dirExist' => 'المجلد موجود بالفعل!',
'dirCreated' => 'تم أنشاء المجلد!',
'dirNotFound' => 'المجلد غير موجود',
// actions
'uploaded' => 'تم تحديث كل الملفات!',
'delNotFound' => 'بعض الملفات غير موجودة! تحديث!',
'deleted' => 'تم الحذف!',
'renamed' => 'أعيدت تسميتها!',
'copied' => 'تم النسخ بنجاح!',
'uploaded' => 'تم تحديث كل الملفات!',
'notAllUploaded' => 'بعض الملفات غير المحملة!',
'delNotFound' => 'بعض الملفات غير موجودة! تحديث!',
'deleted' => 'تم الحذف!',
'renamed' => 'أعيدت تسميتها!',
'copied' => 'تم النسخ بنجاح!',
// zip
'zipError' => 'خطأ في إنشاء الأرشيف!',
'zipError' => 'خطأ في إنشاء الأرشيف!',
// acl
'aclError' => 'تم الرفض!',
'aclError' => 'تم الرفض!',
];
Loading

0 comments on commit 494d67d

Please sign in to comment.