diff --git a/Configuration/ElFinderConfigurationReader.php b/Configuration/ElFinderConfigurationReader.php index 6389e62..e591439 100644 --- a/Configuration/ElFinderConfigurationReader.php +++ b/Configuration/ElFinderConfigurationReader.php @@ -88,23 +88,50 @@ 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'); }; @@ -112,6 +139,7 @@ public function getConfiguration($instance) if($parameter['driver'] == 'Flysystem') { $driverOptions['filesystem'] = $filesystem; } + $options['roots'][] = array_merge($driverOptions, $this->configureDriver($parameter)); } diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 1555a33..6de09dc 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -52,9 +52,6 @@ public function getConfigTreeBuilder() ->requiresAtLeastOneElement() ->prototype('array') ->children() - ->scalarNode('driver') - ->isRequired() - ->defaultValue('LocalFileSystem')->end() ->arrayNode('flysystem') ->canBeEnabled() ->children() @@ -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')) @@ -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() diff --git a/README.md b/README.md index 23e8f9d..c0a8136 100644 --- a/README.md +++ b/README.md @@ -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. @@ -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.