Skip to content
Open
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
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"require": {
"php": ">=5.3.0",
"illuminate/support": "4.x",
"barryvdh/elfinder-builds": "2.1.x"
"barryvdh/elfinder-builds": "2.1.x",
"barryvdh/elfinder-flysystem-driver": "0.1.x@dev"
},
"autoload": {
"psr-4": {
Expand Down
17 changes: 17 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,23 @@ The default configuration requires a directory called 'files' in the public fold

In your app/config/packages/barryvdh/laravel-elfinder, you can change the default folder, the access callback or define your own roots.

### Using Filesystem disks

Laravel 4 has the ability to use Flysystem adapters using the package "graham-campbell/flysystem": "~1.0" [found here](https://github.com/GrahamCampbell/Laravel-Flysystem/tree/v1.0.0) as local/cloud disks. You can add those disks to elFinder, using the `disks` config.

This examples adds the `local` disk and `my-disk`:

'disks' => [
'local',
'my-disk' => [
'URL' => url('to/disk'),
'alias' => 'Local storage',
]
],

You can add an array to provide extra options, like the URL, alias etc. [Look here](https://github.com/Studio-42/elFinder/wiki/Connector-configuration-options-2.1#root-options) for all options.
Also see [elfinder-flysystem-driver](https://github.com/barryvdh/elfinder-flysystem-driver) for [Glide](http://glide.thephpleague.com/) usage.

### TinyMCE 4.x

You can add tinyMCE integration by adding the following route:
Expand Down
44 changes: 30 additions & 14 deletions src/ElfinderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public function showTinyMCE()

public function showTinyMCE4()
{

return $this->app['view']
->make($this->package . '::tinymce4')
->with($this->getViewVars());
Expand All @@ -45,25 +44,42 @@ public function showPopup($input_id)

public function showConnector()
{
$dir = $this->app->config->get($this->package . '::dir');
$roots = $this->app->config->get($this->package . '::roots');
$roots = $this->app->config->get($this->package . '::roots', []);

if (empty($roots)) {

if (!$roots)
{
$roots = array(
array(
$dirs = (array) $this->app->config->get($this->package . '::dir', []);
foreach ($dirs as $dir) {
$roots[] = [
'driver' => 'LocalFileSystem', // driver for accessing file system (REQUIRED)
'path' => $this->app['path.public'] . DIRECTORY_SEPARATOR . $dir, // path to files (REQUIRED)
'URL' => $this->app['url']->asset($dir), // URL to files (REQUIRED)
'path' => public_path($dir), // path to files (REQUIRED)
'URL' => url($dir), // URL to files (REQUIRED)
'accessControl' => $this->app->config->get($this->package . '::access') // filter callback (OPTIONAL)
)
);
];
}

$disks = (array) $this->app['config']->get($this->package . '::disks', []);
if ($this->app->bound('flysystem')) {
foreach ($disks as $key => $root) {
if (is_string($root)) {
$key = $root;
$root = [];
}
$driver = app('flysystem')->connection($key);
if ($driver instanceof \League\Flysystem\Filesystem) {
$defaults = [
'driver' => 'Flysystem',
'filesystem' => $driver,
'alias' => $key,
];
$roots[] = array_merge($defaults, $root);
}
}
}
}

$opts = $this->app->config->get($this->package . '::options', array());
$opts = array_merge(array(
'roots' => $roots
), $opts);
$opts = array_merge(array('roots' => $roots), $opts);

// run elFinder
$connector = new Connector(new \elFinder($opts));
Expand Down
18 changes: 17 additions & 1 deletion src/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,24 @@
| The dir where to store the images (relative from public)
|
*/
'dir' => ['files'],

'dir' => 'files',
/*
|--------------------------------------------------------------------------
| Filesystem disks (Flysytem)
|--------------------------------------------------------------------------
|
| Define an array of Filesystem disks, which use Flysystem.
| You can set extra options, example:
|
| 'my-disk' => [
| 'URL' => url('to/disk'),
| 'alias' => 'Local storage',
| ]
*/
'disks' => [

],

/*
|--------------------------------------------------------------------------
Expand Down