From 3d69a0fb99a9b7383d533dbcf5033fee1c8546d8 Mon Sep 17 00:00:00 2001 From: Albert Ganiev Date: Wed, 14 Jan 2015 19:41:02 +1000 Subject: [PATCH] plugin_support --- Configuration/ElFinderConfigurationReader.php | 5 ++ DependencyInjection/Configuration.php | 50 +++++++++++++ README.md | 75 ++++++++++++++++++- 3 files changed, 126 insertions(+), 4 deletions(-) diff --git a/Configuration/ElFinderConfigurationReader.php b/Configuration/ElFinderConfigurationReader.php index 7b72543..9e501c6 100644 --- a/Configuration/ElFinderConfigurationReader.php +++ b/Configuration/ElFinderConfigurationReader.php @@ -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) { @@ -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) { @@ -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 @@ -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)); } diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index bab8faa..5f1d3b3 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -43,6 +43,8 @@ public function getConfigTreeBuilder() ->addDefaultsIfNotSet() ->children() ->booleanNode('debug')->defaultFalse()->end() + ->append($this->createBindNode()) + ->append($this->createPluginsNode()) ->arrayNode('roots') ->isRequired() ->requiresAtLeastOneElement() @@ -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() @@ -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(); + } } diff --git a/README.md b/README.md index b5db613..58386f6 100644 --- a/README.md +++ b/README.md @@ -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) @@ -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 @@ -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 @@ -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)