Skip to content

Commit

Permalink
plugin_support
Browse files Browse the repository at this point in the history
  • Loading branch information
helios-ag committed Jan 14, 2015
1 parent e4ca488 commit 3d69a0f
Show file tree
Hide file tree
Showing 3 changed files with 126 additions and 4 deletions.
5 changes: 5 additions & 0 deletions Configuration/ElFinderConfigurationReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class ElFinderConfigurationReader implements ElFinderConfigurationProviderInterf
/**
* @param $parameters
* @param \Symfony\Component\HttpFoundation\RequestStack $requestStack
* @param ContainerInterface $container
*/
public function __construct($parameters, RequestStack $requestStack, ContainerInterface $container)
{
Expand All @@ -55,6 +56,8 @@ public function getConfiguration($instance)
$parameters = $efParameters['instances'][$instance];
$options = array();
$options['debug'] = $parameters['connector']['debug'];
$options['bind'] = $parameters['connector']['bind'];
$options['plugin'] = $parameters['connector']['plugin'];
$options['roots'] = array();

foreach ($parameters['connector']['roots'] as $parameter) {
Expand All @@ -66,6 +69,7 @@ public function getConfiguration($instance)
'driver' => $parameter['driver'],
'service' => $driver,
'disabled' => $parameter['disabled'],
'plugin' => $parameter['plugin'],
'path' => $path . '/',
'URL' => isset($parameter['url']) && $parameter['url']
? strpos($parameter['url'], 'http') === 0
Expand All @@ -77,6 +81,7 @@ public function getConfiguration($instance)
'uploadDeny' => $parameter['upload_deny'],
'uploadMaxSize' => $parameter['upload_max_size']
);

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

Expand Down
50 changes: 50 additions & 0 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public function getConfigTreeBuilder()
->addDefaultsIfNotSet()
->children()
->booleanNode('debug')->defaultFalse()->end()
->append($this->createBindNode())
->append($this->createPluginsNode())
->arrayNode('roots')
->isRequired()
->requiresAtLeastOneElement()
Expand All @@ -57,6 +59,7 @@ public function getConfigTreeBuilder()
->end()
->scalarNode('path')->defaultValue('')->end()
->scalarNode('url')->end()
->append($this->createPluginsNode())
->booleanNode('showhidden')->defaultFalse()->end()
->scalarNode('alias')->defaultValue('')->end()
->integerNode('treeDeep')->defaultValue(0)->end()
Expand Down Expand Up @@ -109,4 +112,51 @@ public function getConfigTreeBuilder()
return $treeBuilder;
}

/**
* @return \Symfony\Component\Config\Definition\Builder\NodeDefinition The plugins node.
*/
private function createPluginsNode()
{
return $this->createNode('plugin')
->useAttributeAsKey('name')
->prototype('array')
->useAttributeAsKey('name')
->prototype('variable')->end()
->end();
}

/**
* @return \Symfony\Component\Config\Definition\Builder\NodeDefinition The plugins node.
*/
private function createBindNode()
{
return $this->createNode('bind')
->useAttributeAsKey('name')
->prototype('array')
->useAttributeAsKey('name')
->prototype('variable')->end()
->end();
}

/**
* Creates a node.
*
* @param string $name The node name.
*
* @return \Symfony\Component\Config\Definition\Builder\NodeDefinition The node.
*/
private function createNode($name)
{
return $this->createTreeBuilder()->root($name);
}

/**
* Creates a tree builder.
*
* @return \Symfony\Component\Config\Definition\Builder\TreeBuilder The tree builder.
*/
private function createTreeBuilder()
{
return new TreeBuilder();
}
}
75 changes: 71 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ FMElfinderBundle
[![Build Status](https://secure.travis-ci.org/helios-ag/FMElfinderBundle.png)](http://travis-ci.org/helios-ag/FMElfinderBundle)
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/604032ab-06ef-4ee2-b0cf-bb5240b9cd17/mini.png)](https://insight.sensiolabs.com/projects/604032ab-06ef-4ee2-b0cf-bb5240b9cd17)
[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/helios-ag/fmelfinderbundle/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
[![Dependency Status](https://www.versioneye.com/user/projects/53db56ab4b3ac87d6a0001ff/badge.svg?style=flat)](https://www.versioneye.com/user/projects/53db56ab4b3ac87d6a0001ff)
[![Dependency Status](https://www.versioneye.com/user/projects/53db56ae4b3ac897b60001d4/badge.svg?style=flat)](https://www.versioneye.com/user/projects/53db56ae4b3ac897b60001d4)

[![Latest Stable Version](https://poser.pugx.org/helios-ag/fm-elfinder-bundle/v/stable.svg)](https://packagist.org/packages/helios-ag/fm-elfinder-bundle) [![Total Downloads](https://poser.pugx.org/helios-ag/fm-elfinder-bundle/downloads.svg)](https://packagist.org/packages/helios-ag/fm-elfinder-bundle) [![Latest Unstable Version](https://poser.pugx.org/helios-ag/fm-elfinder-bundle/v/unstable.svg)](https://packagist.org/packages/helios-ag/fm-elfinder-bundle) [![License](https://poser.pugx.org/helios-ag/fm-elfinder-bundle/license.svg)](https://packagist.org/packages/helios-ag/fm-elfinder-bundle)

Expand Down Expand Up @@ -164,6 +164,71 @@ fm_elfinder:
* connector - root node for defining options for elfinder root directiories and debug option
* roots - define

## Plugins support

ElFinder comes with few plugins, like auto-resize, which can be enabled, by the following configuration:

```
fm_elfinder:
instances:
tinymce:
locale: %locale%
editor: tinymce4 # other choices are tinymce or simple
include_assets: true
relative_path: true
fullscreen: true
connector:
debug: true # defaults to false
bind:
upload.presave:
- Plugin.AutoResize.onUpLoadPreSave
plugin:
AutoResize: # global resize options, applies to root which don't have his own resize configuraion
enable: true
maxWidth: 750
maxHeight: 750
quality: 95 # JPEG image save quality
roots: # at least one root must be defined
uploads:
driver: LocalFileSystem
path: uploads
plugin:
AutoResize:
enable: true
maxWidth: 500
maxHeight: 500
quality: 95 # JPEG image save quality
upload_allow: ['image/png', 'image/jpg', 'image/jpeg']
upload_deny: ['all']
upload_max_size: 2M
resize1:
driver: LocalFileSystem
path: uploads
plugin:
AutoResize:
enable: true # For control by volume driver
maxWidth: 800 # Path to Water mark image
maxHeight: 800 # Margin right pixel
quality: 95 # JPEG image save quality
upload_allow: ['image/png', 'image/jpg', 'image/jpeg']
upload_deny: ['all']
upload_max_size: 2M
resize2:
driver: LocalFileSystem
path: uploads
plugin:
AutoResize:
enable: true
maxWidth: 800
maxHeight: 800
quality: 95
upload_allow: ['image/png', 'image/jpg', 'image/jpeg']
upload_deny: ['all']
upload_max_size: 2M
```

ElFinder comes with other plugins, check it Plugins folder for more information.

## Configuring symfony service as a volumeDriver
volumeDriver can be declared as Symfony service
The service should however be an instance of the FM\ElFinderPHP\Driver\ElFinderVolumeDriver class. This check is to
Expand Down Expand Up @@ -323,7 +388,7 @@ as shown below

instance_name is instance of elfinder's configuration

### Integrating with TinyMCE 4.x
### Integration with TinyMCE 4.x

Update the editor property in your app/config.yml
```yml
Expand Down Expand Up @@ -379,8 +444,10 @@ Manual integration guide can be found [here](/INTEGRATION_GUIDE.md)
##Changelog
### 3.2
* Removed assetic support
### 3.3
* Plugins support
### 3.0
* BC in public api (controllers showAction method with second parameter)
Expand Down

0 comments on commit 3d69a0f

Please sign in to comment.