Skip to content

Commit

Permalink
Merge pull request #122 from nicolasmure/connector-options-override
Browse files Browse the repository at this point in the history
connector options override
  • Loading branch information
helios-ag committed Mar 20, 2015
2 parents cace52d + b32a5d2 commit 7e575d4
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 21 deletions.
52 changes: 40 additions & 12 deletions Configuration/ElFinderConfigurationReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,30 +88,58 @@ public function getConfiguration($instance)
$driver = $this->container->has($parameter['driver']) ? $this->container->get($parameter['driver']) : null;

$driverOptions = array(
'driver' => $parameter['driver'],
'service' => $driver,
'glideURL' => $parameter['glide_url'],
'glideKey' => $parameter['glide_key'],
'disabled' => $parameter['disabled_commands'],
'plugin' => $parameter['plugin'],
'alias' => $parameter['alias'],
'path' => $path . $homeFolder, //removed slash for Flysystem compatibility
'URL' => isset($parameter['url']) && $parameter['url']
'driver' => $parameter['driver'],
'service' => $driver,
'glideURL' => $parameter['glide_url'],
'glideKey' => $parameter['glide_key'],
'plugin' => $parameter['plugin'],
'path' => $path . $homeFolder, //removed slash for Flysystem compatibility
'startPath' => $parameter['start_path'],
'URL' => isset($parameter['url']) && $parameter['url']
? strpos($parameter['url'], 'http') === 0
? $parameter['url']
: sprintf('%s://%s%s/%s/%s', $request->getScheme(), $request->getHttpHost(), $request->getBasePath(), $parameter['url'], $homeFolder)
: sprintf('%s://%s%s/%s/%s', $request->getScheme(), $request->getHttpHost(), $request->getBasePath(), $path, $homeFolder),
'uploadAllow' => $parameter['upload_allow'],
'uploadDeny' => $parameter['upload_deny'],
'uploadMaxSize' => $parameter['upload_max_size']
'alias' => $parameter['alias'],
'mimeDetect' => $parameter['mime_detect'],
'mimefile' => $parameter['mimefile'],
'imgLib' => $parameter['img_lib'],
'tmbPath' => $parameter['tmb_path'],
'tmbPathMode' => $parameter['tmb_path_mode'],
'tmbUrl' => $parameter['tmb_url'],
'tmbSize' => $parameter['tmb_size'],
'tmbCrop' => $parameter['tmb_crop'],
'tmbBgColor' => $parameter['tmb_bg_color'],
'copyOverwrite' => $parameter['copy_overwrite'],
'copyJoin' => $parameter['copy_join'],
'copyFrom' => $parameter['copy_from'],
'copyTo' => $parameter['copy_to'],
'uploadOverwrite' => $parameter['upload_overwrite'],
'uploadAllow' => $parameter['upload_allow'],
'uploadDeny' => $parameter['upload_deny'],
'uploadMaxSize' => $parameter['upload_max_size'],
'defaults' => $parameter['defaults'],
'attributes' => $parameter['attributes'],
'acceptedName' => $parameter['accepted_name'],
'accessControl' => $parameter['access_control'],
'accessControlData' => $parameter['access_control_data'],
'disabled' => $parameter['disabled_commands'],
'treeDeep' => $parameter['tree_deep'],
'checkSubfolders' => $parameter['check_subfolders'],
'separator' => $parameter['separator'],
'timeFormat' => $parameter['time_format'],
'archiveMimes' => $parameter['archive_mimes'],
'archivers' => $parameter['archivers']
);

if(!$parameter['show_hidden']) {
$driverOptions['accessControl'] = array($this, 'access');
};

if($parameter['driver'] == 'Flysystem') {
$driverOptions['filesystem'] = $filesystem;
}

$options['roots'][] = array_merge($driverOptions, $this->configureDriver($parameter));
}

Expand Down
59 changes: 50 additions & 9 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ public function getConfigTreeBuilder()
->requiresAtLeastOneElement()
->prototype('array')
->children()
->scalarNode('driver')
->isRequired()
->defaultValue('LocalFileSystem')->end()
->arrayNode('flysystem')
->canBeEnabled()
->children()
Expand All @@ -64,16 +61,28 @@ public function getConfigTreeBuilder()
->end()
->scalarNode('glide_url')->defaultValue('')->end()
->scalarNode('glide_key')->defaultValue('')->end()
->arrayNode('disabled_commands')
->prototype('scalar')->end()
->defaultValue(array())
->scalarNode('driver')
->isRequired()
->defaultValue('LocalFileSystem')
->end()
->scalarNode('path')->defaultValue('')->end()
->scalarNode('start_path')->defaultValue('')->end()
->scalarNode('url')->end()
->append($this->createPluginsNode())
->booleanNode('show_hidden')->defaultFalse()->end()
->scalarNode('alias')->defaultValue('')->end()
->integerNode('tree_deep')->defaultValue(0)->end()
->scalarNode('mime_detect')->defaultValue('auto')->end()
->scalarNode('mimefile')->defaultValue('')->end()
->scalarNode('img_lib')->defaultValue('auto')->end()
->scalarNode('tmb_path')->defaultValue('.tmb')->end()
->scalarNode('tmb_path_mode')->defaultValue(0777)->end()
->scalarNode('tmb_url')->defaultValue('')->end()
->integerNode('tmb_size')->defaultValue(48)->end()
->booleanNode('tmb_crop')->defaultTrue()->end()
->scalarNode('tmb_bg_color')->defaultValue('#ffffff')->end()
->booleanNode('copy_overwrite')->defaultTrue()->end()
->booleanNode('copy_join')->defaultTrue()->end()
->booleanNode('copy_from')->defaultTrue()->end()
->booleanNode('copy_to')->defaultTrue()->end()
->booleanNode('upload_overwrite')->defaultTrue()->end()
->arrayNode('upload_allow')
->prototype('scalar')->end()
->defaultValue(array('image'))
Expand All @@ -83,6 +92,38 @@ public function getConfigTreeBuilder()
->defaultValue(array('all'))
->end()
->scalarNode('upload_max_size')->defaultValue('2M')->end()
->arrayNode('defaults')
->useAttributeAsKey('defaults')
->normalizeKeys(false)
->prototype('boolean')->end()
->defaultValue(array('read' => true, 'write' => true))
->end()
->arrayNode('attributes')
->prototype('scalar')->end()
->defaultValue(array())
->end()
->scalarNode('accepted_name')->defaultValue('/^\w[\w\s\.\%\-]*$/u')->end()
->scalarNode('access_control')->defaultValue(null)->end()
->scalarNode('access_control_data')->defaultValue(null)->end()
->arrayNode('disabled_commands')
->prototype('scalar')->end()
->defaultValue(array())
->end()
->integerNode('tree_deep')->defaultValue(1)->end()
->booleanNode('check_subfolders')->defaultTrue()->end()
->scalarNode('separator')->defaultValue(DIRECTORY_SEPARATOR)->end()
->scalarNode('date_format')->defaultValue('j M Y H:i')->end()
->scalarNode('time_format')->defaultValue('H:i')->end()
->arrayNode('archive_mimes')
->prototype('scalar')->end()
->defaultValue(array())
->end()
->arrayNode('archivers')
->prototype('scalar')->end()
->defaultValue(array())
->end()
->append($this->createPluginsNode())
->booleanNode('show_hidden')->defaultFalse()->end()
->arrayNode('dropbox_settings')
->canBeEnabled()
->children()
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ fm_elfinder:
upload_allow: ['image/png', 'image/jpg', 'image/jpeg']
upload_deny: ['all']
upload_max_size: 2M

```
* default - instance of elfinder, can be used to define multiple configurations of ElFinder, allows simultaneous configuration for different types of WYSIWYG editors in your project
* path - define root directory for the files inside web/ directory, default is "uploads". Make sure to set proper write/read permissions to this directory.
Expand All @@ -181,6 +182,9 @@ fm_elfinder:
* upload_allow: ['image/png', 'image/jpg', 'image/jpeg']
* upload_deny: ['all']
* upload_max_size: 2M
You can see the full list of roots options [here](https://github.com/Studio-42/elFinder/wiki/Connector-configuration-options#root-options "connector options list"). To use them,
convert camelCased option name to under_scored option name.
**Note:** `crypt_lib` option is not available as not implemented yet by elFinder PHP library.

### Use multiple upload folder by instance
You can set multiple upload root folder by instance configuration.
Expand Down

0 comments on commit 7e575d4

Please sign in to comment.