diff --git a/.travis.yml b/.travis.yml
index 688b14a..85d24cc 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -6,39 +6,24 @@ cache:
- $HOME/.composer/cache
- $HOME/symfony-bridge/.phpunit
-env:
- global:
- - COMPOSER_PREFER_LOWEST=false
- - SYMFONY_DEPRECATIONS_HELPER=weak_vendors
- - SYMFONY_PHPUNIT_BRIDGE_VERSION=4.0.*
- - SYMFONY_VERSION=3.4.*
- - PHPUNIT_FLAGS="-v"
- - SYMFONY_PHPUNIT_DIR="$HOME/symfony-bridge/.phpunit"
matrix:
fast_finish: true
include:
- - php: 7.2
- env: SYMFONY_VERSION=4.1.* SYMFONY_PHPUNIT_BRIDGE_VERSION=4.1.* SYMFONY_DEPRECATIONS_HELPER=weak_vendors LEVEL=0
- - php: 7.3
- env: SYMFONY_VERSION=4.1.* SYMFONY_PHPUNIT_BRIDGE_VERSION=4.1.* SYMFONY_DEPRECATIONS_HELPER=weak_vendors LEVEL=0
- - php: 7.1
- env: SYMFONY_VERSION=4.2.* SYMFONY_PHPUNIT_BRIDGE_VERSION=4.2.* SYMFONY_DEPRECATIONS_HELPER=weak_vendors LEVEL=0
- - php: 7.2
- env: SYMFONY_VERSION=4.2.* SYMFONY_PHPUNIT_BRIDGE_VERSION=4.2.* SYMFONY_DEPRECATIONS_HELPER=weak_vendors LEVEL=0
- - php: 7.3
- env: SYMFONY_VERSION=4.2.* SYMFONY_PHPUNIT_BRIDGE_VERSION=4.2.* SYMFONY_DEPRECATIONS_HELPER=weak_vendors LEVEL=0
+ - php: 7.2
+ env: SYMFONY_VERSION="^4.4.0"
+ - php: 7.3
+ env: SYMFONY_VERSION="^5.0.0"
before_install:
- - echo "memory_limit=2G" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
+ - echo "memory_limit=4G" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
+ - phpenv config-rm xdebug.ini || true
+ - composer global require --no-progress --no-scripts --no-plugins symfony/flex dev-master
+ - if [ "$SYMFONY_VERSION" != "" ]; then composer require --no-update "symfony/framework-bundle:${SYMFONY_VERSION}"; fi;
-install:
- - composer require --no-update symfony/symfony:${SYMFONY_VERSION}
- - composer require --no-update symfony/form:${SYMFONY_VERSION}
- - composer require --dev --no-update symfony/phpunit-bridge:${SYMFONY_PHPUNIT_BRIDGE_VERSION}
- - composer update --prefer-source `if [[ $COMPOSER_PREFER_LOWEST = true ]]; then echo "--prefer-lowest --prefer-stable"; fi`
+install: php -d memory_limit=-1 $(phpenv which composer) update $COMPOSER_FLAGS --no-suggest
script:
- - SYMFONY_PHPUNIT_VERSION=6.5 ./vendor/bin/simple-phpunit $PHPUNIT_FLAGS
+ - ./vendor/bin/phpunit --coverage-text --colors
notifications:
email: helios.ag@gmail.com
diff --git a/README.md b/README.md
index 73ca242..4b771b4 100644
--- a/README.md
+++ b/README.md
@@ -65,44 +65,22 @@ For Symfony Flex installation you need to enable community recipes:
composer config extra.symfony.allow-contrib true
```
-And install
+Install
```sh
composer require helios-ag/fm-elfinder-bundle
```
-Other way (non flex way) is to add FMElFinderBundle to your composer.json
-
-```json
-{
- "require": {
- "helios-ag/fm-elfinder-bundle": "~9",
- }
-}
-```
-
-also add **component-dir** under **config** node of composer.json
-
-(also you can manually copy assets to this directory)
-
-```json
-{
- "config": {
- "component-dir": "public/assets"
- }
-}
-```
-
-Now tell composer to download the bundle by running the command:
-
+Copy elfinder assets to public folder
```sh
-composer update helios-ag/fm-elfinder-bundle
+ bin/console elfinder:install
```
-### Step 2: Enable the bundle
-Enable the bundle in the kernel:
+### Step 2: Enable the bundle (Optional)
+
+Enable the bundle in the kernel (not needed with symfony flex):
```php
-
+
./tests
diff --git a/src/Bridge/ElFinderBridge.php b/src/Bridge/ElFinderBridge.php
index e530519..06ddaaf 100644
--- a/src/Bridge/ElFinderBridge.php
+++ b/src/Bridge/ElFinderBridge.php
@@ -6,19 +6,11 @@
use FM\ElfinderBundle\ElFinder\ElFinder;
use elFinderVolumeDriver;
-/**
- * Class ElFinderBridge.
- */
class ElFinderBridge extends ElFinder
{
/** @var SessionInterface */
protected $session;
- /**
- * ElFinderBridge constructor.
- *
- * @param $opts
- */
public function __construct($opts)
{
if ($this->session) {
diff --git a/src/Command/ElFinderInstallerCommand.php b/src/Command/ElFinderInstallerCommand.php
new file mode 100644
index 0000000..6d21f9f
--- /dev/null
+++ b/src/Command/ElFinderInstallerCommand.php
@@ -0,0 +1,56 @@
+fileSystem = $filesystem;
+ $this->parameterBag = $parameterBag;
+ parent::__construct();
+ }
+
+ protected function configure(): void
+ {
+ $this
+ ->setDescription('Copies elfinder assets to public directory')
+ ;
+ }
+
+ protected function execute(InputInterface $input, OutputInterface $output): int
+ {
+ $publicDir = $this->parameterBag->get('kernel.project_dir').'/public/bundles/fmelfinder';
+
+ $this->fileSystem->mirror(self::ELFINDER_CSS_DIR, $publicDir.'/css');
+ $this->fileSystem->mirror(self::ELFINDER_IMG_DIR, $publicDir.'/img');
+ $this->fileSystem->mirror(self::ELFINDER_JS_DIR, $publicDir.'/js');
+ $this->fileSystem->mirror(self::ELFINDER_SOUNDS_DIR, $publicDir.'/sounds');
+
+ $output->writeln('elFinder assets successfully installed');
+
+ return 0;
+ }
+}
diff --git a/src/Configuration/ElFinderConfigurationProviderInterface.php b/src/Configuration/ElFinderConfigurationProviderInterface.php
new file mode 100644
index 0000000..321719c
--- /dev/null
+++ b/src/Configuration/ElFinderConfigurationProviderInterface.php
@@ -0,0 +1,13 @@
+parameters = $parameters;
$this->requestStack = $requestStack;
$this->container = $container;
}
- /**
- * @param $instance
- *
- * @return array
- *
- * @throws \Exception
- */
- public function getConfiguration($instance)
+ public function getConfiguration(string $instance): array
{
$request = $this->requestStack->getCurrentRequest();
$efParameters = $this->parameters;
@@ -166,15 +145,7 @@ public function getConfiguration($instance)
return $options;
}
- /**
- * @param $parameter
- * @param $request
- * @param $homeFolder
- * @param $path
- *
- * @return string
- */
- private function getURL($parameter, Request $request, $homeFolder, $path)
+ private function getURL(array $parameter, Request $request, string $homeFolder, string $path): string
{
if (isset($parameter['url']) && $parameter['url']) {
if (0 === strpos($parameter['url'], 'http')) {
@@ -195,8 +166,6 @@ private function getURL($parameter, Request $request, $homeFolder, $path)
* @param $serviceName
*
* @return Filesystem
- *
- * @throws \MongoConnectionException
*/
private function configureFlysystem($opt, $adapter, $serviceName)
{
@@ -316,7 +285,7 @@ private function configureFlysystem($opt, $adapter, $serviceName)
return $filesystem;
}
- private function getFlysystemFilesystem($serviceName)
+ private function getFlysystemFilesystem(string $serviceName)
{
$filesystem = $this->container->get($serviceName);
if (!is_object($filesystem) || (!$filesystem instanceof Filesystem)) {
@@ -326,14 +295,9 @@ private function getFlysystemFilesystem($serviceName)
return $filesystem;
}
- /**
- * @param array $parameter
- *
- * @return array
- */
- private function configureDriver(array $parameter)
+ private function configureDriver(array $parameter): array
{
- $settings = array();
+ $settings = [];
switch (strtolower($parameter['driver'])) {
case 'ftp':
@@ -428,8 +392,6 @@ public function access($attr, $path, $data, $volume)
* @param ElfinderSecurityInterface $voter
*
* @return array
- *
- * @throws \Exception
*/
protected function parseSecurityConfiguration(ElfinderSecurityInterface $voter)
{
diff --git a/src/Connector/ElFinderConnector.php b/src/Connector/ElFinderConnector.php
index dc6260a..bef5270 100644
--- a/src/Connector/ElFinderConnector.php
+++ b/src/Connector/ElFinderConnector.php
@@ -4,9 +4,6 @@
use elFinder;
-/**
- * Class ElFinderConnector.
- */
class ElFinderConnector extends \elFinderConnector
{
public function run($queryParameters = null)
diff --git a/src/Controller/ElFinderController.php b/src/Controller/ElFinderController.php
index 7233259..f2f7179 100644
--- a/src/Controller/ElFinderController.php
+++ b/src/Controller/ElFinderController.php
@@ -1,23 +1,24 @@
container->getParameter('fm_elfinder');
@@ -53,27 +54,26 @@ public function showAction(Request $request, $instance, $homeFolder)
* @param array $parameters
* @param string $instance
* @param string $homeFolder
- * @param $assetsPath
- * @param null $formTypeId
+ * @param string $assetsPath
+ * @param string $formTypeId
*
* @return array
*
* @throws Exception
*/
- private function selectEditor($parameters, $instance, $homeFolder, $assetsPath, $formTypeId = null)
+ private function selectEditor(array $parameters, string $instance, string $homeFolder, string $assetsPath, string $formTypeId = null): array
{
$editor = $parameters['editor'];
$locale = $parameters['locale'] ?: $this->container->getParameter('locale');
$fullScreen = $parameters['fullscreen'];
$relativePath = $parameters['relative_path'];
$pathPrefix = $parameters['path_prefix'];
- $includeAssets = $parameters['include_assets'];
$theme = $parameters['theme'];
// convert to javascript array
$onlyMimes = count($parameters['visible_mime_types'])
? "['".implode("','", $parameters['visible_mime_types'])."']"
: '[]';
- $result = array();
+ $result = [];
switch ($editor) {
case 'custom':
@@ -82,10 +82,9 @@ private function selectEditor($parameters, $instance, $homeFolder, $assetsPath,
}
$result['template'] = $parameters['editor_template'];
- $result['params'] = array(
+ $result['params'] = [
'locale' => $locale,
'fullscreen' => $fullScreen,
- 'includeAssets' => $includeAssets,
'instance' => $instance,
'homeFolder' => $homeFolder,
'relative_path' => $relativePath,
@@ -93,15 +92,14 @@ private function selectEditor($parameters, $instance, $homeFolder, $assetsPath,
'theme' => $theme,
'pathPrefix' => $pathPrefix,
'onlyMimes' => $onlyMimes,
- );
+ ];
return $result;
case 'ckeditor':
$result['template'] = '@FMElfinder/Elfinder/ckeditor.html.twig';
- $result['params'] = array(
+ $result['params'] = [
'locale' => $locale,
'fullscreen' => $fullScreen,
- 'includeAssets' => $includeAssets,
'instance' => $instance,
'homeFolder' => $homeFolder,
'relative_path' => $relativePath,
@@ -109,15 +107,14 @@ private function selectEditor($parameters, $instance, $homeFolder, $assetsPath,
'theme' => $theme,
'pathPrefix' => $pathPrefix,
'onlyMimes' => $onlyMimes,
- );
+ ];
return $result;
case 'summernote':
$result['template'] = '@FMElfinder/Elfinder/summernote.html.twig';
- $result['params'] = array(
+ $result['params'] = [
'locale' => $locale,
'fullscreen' => $fullScreen,
- 'includeAssets' => $includeAssets,
'instance' => $instance,
'homeFolder' => $homeFolder,
'relative_path' => $relativePath,
@@ -125,29 +122,27 @@ private function selectEditor($parameters, $instance, $homeFolder, $assetsPath,
'theme' => $theme,
'pathPrefix' => $pathPrefix,
'onlyMimes' => $onlyMimes,
- );
+ ];
return $result;
case 'tinymce':
$result['template'] = '@FMElfinderBundle/Elfinder/tinymce.html.twig';
- $result['params'] = array(
+ $result['params'] = [
'locale' => $locale,
- 'tinymce_popup_path' => $this->getAssetsUrl($parameters['tinymce_popup_path']),
- 'includeAssets' => $includeAssets,
+ 'tinymce_popup_path' => $parameters['tinymce_popup_path'],
'instance' => $instance,
'homeFolder' => $homeFolder,
'prefix' => $assetsPath,
'theme' => $theme,
'pathPrefix' => $pathPrefix,
'onlyMimes' => $onlyMimes,
- );
+ ];
return $result;
case 'tinymce4':
$result['template'] = '@FMElfinder/Elfinder/tinymce4.html.twig';
- $result['params'] = array(
+ $result['params'] = [
'locale' => $locale,
- 'includeAssets' => $includeAssets,
'instance' => $instance,
'homeFolder' => $homeFolder,
'relative_path' => $relativePath,
@@ -155,14 +150,13 @@ private function selectEditor($parameters, $instance, $homeFolder, $assetsPath,
'theme' => $theme,
'pathPrefix' => $pathPrefix,
'onlyMimes' => $onlyMimes,
- );
+ ];
return $result;
case 'fm_tinymce':
$result['template'] = '@FMElfinder/Elfinder/fm_tinymce.html.twig';
- $result['params'] = array(
+ $result['params'] = [
'locale' => $locale,
- 'includeAssets' => $includeAssets,
'instance' => $instance,
'homeFolder' => $homeFolder,
'relative_path' => $relativePath,
@@ -170,15 +164,14 @@ private function selectEditor($parameters, $instance, $homeFolder, $assetsPath,
'theme' => $theme,
'pathPrefix' => $pathPrefix,
'onlyMimes' => $onlyMimes,
- );
+ ];
return $result;
case 'form':
$result['template'] = '@FMElfinder/Elfinder/elfinder_type.html.twig';
- $result['params'] = array(
+ $result['params'] = [
'locale' => $locale,
'fullscreen' => $fullScreen,
- 'includeAssets' => $includeAssets,
'instance' => $instance,
'homeFolder' => $homeFolder,
'id' => $formTypeId,
@@ -187,74 +180,59 @@ private function selectEditor($parameters, $instance, $homeFolder, $assetsPath,
'theme' => $theme,
'pathPrefix' => $pathPrefix,
'onlyMimes' => $onlyMimes,
- );
+ ];
return $result;
default:
$result['template'] = '@FMElfinder/Elfinder/simple.html.twig';
- $result['params'] = array(
+ $result['params'] = [
'locale' => $locale,
'fullscreen' => $fullScreen,
- 'includeAssets' => $includeAssets,
'instance' => $instance,
'homeFolder' => $homeFolder,
'prefix' => $assetsPath,
'onlyMimes' => $onlyMimes,
'theme' => $theme,
'pathPrefix' => $pathPrefix,
- );
+ ];
return $result;
}
}
/**
- * Loader service init.
+ * @param SessionInterface $session
+ * @param EventDispatcherInterface $eventDispatcher
+ * @param Request $request
+ * @param string $instance
+ * @param string $homeFolder
*
- * @param Request $request
- * @param string $instance
- * @param string $homeFolder
- *
- * @return JsonResponse/void
+ * @return JsonResponse
*/
- public function loadAction(Request $request, $instance, $homeFolder)
+ public function load(SessionInterface $session, EventDispatcherInterface $eventDispatcher, Request $request, string $instance, string $homeFolder): JsonResponse
{
$loader = $this->get('fm_elfinder.loader');
$loader->initBridge($instance); // builds up the Bridge object for the loader with the given instance
+
if ($loader instanceof ElFinderLoader) {
- $loader->setSession(new ElFinderSession($this->get('session')));
+ $loader->setSession(new ElFinderSession($session));
}
+ /** @var HttpKernel $httpKernel */
$httpKernel = $this->get('http_kernel');
$preExecutionEvent = new ElFinderPreExecutionEvent($request, $httpKernel, $instance, $homeFolder);
- $this->get('event_dispatcher')->dispatch(ElFinderEvents::PRE_EXECUTION, $preExecutionEvent);
+ $eventDispatcher->dispatch($preExecutionEvent);
$result = $loader->load($request); // the instance is already set
$postExecutionEvent = new ElFinderPostExecutionEvent($request, $httpKernel, $instance, $homeFolder, $result);
- $this->get('event_dispatcher')->dispatch(ElFinderEvents::POST_EXECUTION, $postExecutionEvent);
+ $eventDispatcher->dispatch($postExecutionEvent);
// returning result (who may have been modified by a post execution event listener)
return new JsonResponse($postExecutionEvent->getResult());
}
- /**
- * Get url from config string.
- *
- * @param string $inputUrl
- *
- * @return string
- */
- protected function getAssetsUrl($inputUrl)
+ public function mainJS()
{
- /** @var $assets \Symfony\Component\Templating\Helper\CoreAssetsHelper */
- $assets = $this->container->get('templating.helper.assets');
-
- $url = preg_replace('/^asset\[(.+)\]$/i', '$1', $inputUrl);
-
- if ($inputUrl !== $url) {
- return $assets->getUrl($url);
- }
-
- return $inputUrl;
+ return $this->render('@FMElfinder/Elfinder/helper/main.js.twig');
}
}
diff --git a/src/DependencyInjection/Compiler/TwigFormPass.php b/src/DependencyInjection/Compiler/TwigFormPass.php
index 988765b..33cb8d4 100644
--- a/src/DependencyInjection/Compiler/TwigFormPass.php
+++ b/src/DependencyInjection/Compiler/TwigFormPass.php
@@ -5,9 +5,6 @@
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
-/**
- * Class TwigFormPass.
- */
class TwigFormPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container)
@@ -17,7 +14,7 @@ public function process(ContainerBuilder $container)
}
$container->setParameter('twig.form.resources', array_merge(
- array('@FMElfinder/Form/elfinder_widget.html.twig'),
+ ['@FMElfinder/Form/elfinder_widget.html.twig'],
$container->getParameter('twig.form.resources')
));
}
diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php
index 190e6f1..f1d2853 100644
--- a/src/DependencyInjection/Configuration.php
+++ b/src/DependencyInjection/Configuration.php
@@ -17,11 +17,8 @@ class Configuration implements ConfigurationInterface
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder('fm_elfinder');
- if (\method_exists($treeBuilder, 'getRootNode')) {
- $rootNode = $treeBuilder->getRootNode();
- } else {
- $rootNode = $treeBuilder->root('fm_elfinder');
- }
+ $rootNode = $treeBuilder->getRootNode();
+
$rootNode
->fixXmlConfig('instance')
->children()
@@ -40,7 +37,6 @@ public function getConfigTreeBuilder()
->scalarNode('editor_template')->defaultNull()->end()
->booleanNode('fullscreen')->defaultTrue()->end()
->scalarNode('theme')->defaultValue('smoothness')->end() // jQuery UI theme name
- ->booleanNode('include_assets')->defaultTrue()->end()
->scalarNode('tinymce_popup_path')->defaultValue('')->end()
->booleanNode('relative_path')->defaultTrue()->end()
->scalarNode('path_prefix')->defaultValue('/')->end()
@@ -431,7 +427,7 @@ private function createFlysystemNode()
}
/**
- * @return \Symfony\Component\Config\Definition\Builder\NodeDefinition the plugins node
+ * @return NodeDefinition the plugins node
*/
private function createPluginsNode()
{
@@ -444,7 +440,7 @@ private function createPluginsNode()
}
/**
- * @return \Symfony\Component\Config\Definition\Builder\NodeDefinition the bind node
+ * @return NodeDefinition the bind node
*/
private function createBindsNode()
{
@@ -457,7 +453,7 @@ private function createBindsNode()
}
/**
- * @return \Symfony\Component\Config\Definition\Builder\NodeDefinition the bind node
+ * @return NodeDefinition the bind node
*/
private function createDriverOptionsNode()
{
@@ -470,11 +466,9 @@ private function createDriverOptionsNode()
}
/**
- * Creates a node.
- *
* @param string $name the node name
*
- * @return \Symfony\Component\Config\Definition\Builder\NodeDefinition the node
+ * @return NodeDefinition the node
*/
private function createNode($name)
{
diff --git a/src/DependencyInjection/FMElfinderExtension.php b/src/DependencyInjection/FMElfinderExtension.php
index 49098fa..142210a 100644
--- a/src/DependencyInjection/FMElfinderExtension.php
+++ b/src/DependencyInjection/FMElfinderExtension.php
@@ -6,12 +6,8 @@
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\Extension\Extension;
use Symfony\Component\DependencyInjection\Loader;
-use Symfony\Component\HttpKernel\Kernel;
-/**
- * Class FMElfinderExtension.
- */
-class FMElfinderExtension extends Extension
+final class FMElfinderExtension extends Extension
{
/**
* {@inheritdoc}
@@ -23,22 +19,14 @@ public function load(array $configs, ContainerBuilder $container)
$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('elfinder.xml');
$loader->load('form.xml');
+ $loader->load('command.xml');
$container->setParameter('fm_elfinder', $config);
$container->setAlias('fm_elfinder.configurator', $config['configuration_provider']);
$container->setAlias('fm_elfinder.loader', $config['loader']);
$container->getAlias('fm_elfinder.loader')->setPublic(true);
-
- if (Kernel::VERSION_ID < 30000) {
- $container->getDefinition('fm_elfinder.form.type')
- ->clearTag('form.type')
- ->addTag('form.type', array('alias' => 'elfinder'));
- }
}
- /**
- * @return string
- */
- public function getNamespace()
+ public function getNamespace(): string
{
return 'http://helios-ag.github.io/schema/dic/fm_elfinder';
}
diff --git a/src/Event/ElFinderEvents.php b/src/Event/ElFinderEvents.php
deleted file mode 100644
index 11de80f..0000000
--- a/src/Event/ElFinderEvents.php
+++ /dev/null
@@ -1,25 +0,0 @@
-setDefaults(array(
+ ->setDefaults([
'enable' => true,
'instance' => 'default',
'homeFolder' => '',
- ))
+ ])
->setAllowedTypes('enable', 'bool')
- ->setAllowedTypes('instance', array('string', 'null'))
- ->setAllowedTypes('homeFolder', array('string', 'null'));
+ ->setAllowedTypes('instance', ['string', 'null'])
+ ->setAllowedTypes('homeFolder', ['string', 'null']);
}
/**
diff --git a/src/Loader/ElFinderLoader.php b/src/Loader/ElFinderLoader.php
index 4f802cb..ad303cf 100644
--- a/src/Loader/ElFinderLoader.php
+++ b/src/Loader/ElFinderLoader.php
@@ -4,7 +4,7 @@
use FM\ElfinderBundle\Connector\ElFinderConnector;
use FM\ElfinderBundle\Bridge\ElFinderBridge;
-use FM\ElfinderBundle\Model\ElFinderConfigurationProviderInterface;
+use FM\ElfinderBundle\Configuration\ElFinderConfigurationProviderInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
@@ -28,9 +28,6 @@ class ElFinderLoader
/** @var SessionInterface */
protected $session;
- /**
- * @param \FM\ElfinderBundle\Model\ElFinderConfigurationProviderInterface $configurator
- */
public function __construct(ElFinderConfigurationProviderInterface $configurator)
{
$this->configurator = $configurator;
@@ -47,9 +44,8 @@ public function configure()
if (!($configurator instanceof ElFinderConfigurationProviderInterface)) {
throw new \Exception('Configurator class must implement ElFinderConfigurationProviderInterface');
}
- $parameters = $configurator->getConfiguration($this->instance);
- return $parameters;
+ return $configurator->getConfiguration($this->instance);
}
/**
@@ -95,9 +91,6 @@ public function setInstance($instance)
$this->instance = $instance;
}
- /**
- * @param \FM\ElfinderBundle\Model\ElFinderConfigurationProviderInterface $configurator
- */
public function setConfigurator(ElFinderConfigurationProviderInterface $configurator)
{
$this->configurator = $configurator;
@@ -117,7 +110,7 @@ public function encode($path)
$volumes = $this->bridge->getVolumes();
foreach ($volumes as $hashId => $volume) {
- $aPathEncoded[$hashId] = $volume->getPath($path);
+ $aPathEncoded[$hashId] = $volume->getHash($path);
}
if (1 == count($aPathEncoded)) {
diff --git a/src/Model/ElFinderConfigurationProviderInterface.php b/src/Model/ElFinderConfigurationProviderInterface.php
deleted file mode 100644
index 1f77d56..0000000
--- a/src/Model/ElFinderConfigurationProviderInterface.php
+++ /dev/null
@@ -1,16 +0,0 @@
-
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Resources/config/elfinder.xml b/src/Resources/config/elfinder.xml
index afc83e9..6b5da91 100644
--- a/src/Resources/config/elfinder.xml
+++ b/src/Resources/config/elfinder.xml
@@ -21,5 +21,11 @@
+
+
+
+
+
+
diff --git a/src/Resources/config/routing.yml b/src/Resources/config/routing.yml
index ac9dd58..848d4c8 100644
--- a/src/Resources/config/routing.yml
+++ b/src/Resources/config/routing.yml
@@ -1,6 +1,9 @@
ef_connect:
path: /efconnect/{instance}/{homeFolder}
- defaults: { _controller: FM\ElfinderBundle\Controller\ElFinderController::loadAction, instance: default, homeFolder: '' }
+ defaults: { _controller: FM\ElfinderBundle\Controller\ElFinderController::load, instance: default, homeFolder: '' }
+ef_main_js:
+ path: /elfinder.main.js
+ defaults: { _controller: FM\ElfinderBundle\Controller\ElFinderController::mainJS }
elfinder:
path: /elfinder/{instance}/{homeFolder}
- defaults: { _controller: FM\ElfinderBundle\Controller\ElFinderController::showAction, instance: default, homeFolder: '' }
+ defaults: { _controller: FM\ElfinderBundle\Controller\ElFinderController::show, instance: default, homeFolder: '' }
diff --git a/src/Resources/entity/ElFinderFile.php.dst b/src/Resources/entity/ElFinderFile.php.dst
deleted file mode 100644
index 73b0e78..0000000
--- a/src/Resources/entity/ElFinderFile.php.dst
+++ /dev/null
@@ -1,318 +0,0 @@
-content = $content;
- }
-
- /**
- * @return string
- */
- public function getContent()
- {
- return $this->content;
- }
-
- /**
- * @param int $height
- */
- public function setHeight($height)
- {
- $this->height = $height;
- }
-
- /**
- * @return int
- */
- public function getHeight()
- {
- return $this->height;
- }
-
- /**
- * @param string $hidden
- */
- public function setHidden($hidden)
- {
- $this->hidden = $hidden;
- }
-
- /**
- * @return string
- */
- public function getHidden()
- {
- return $this->hidden;
- }
-
- /**
- * @param int $id
- */
- public function setId($id)
- {
- $this->id = $id;
- }
-
- /**
- * @return int
- */
- public function getId()
- {
- return $this->id;
- }
-
- /**
- * @param string $locked
- */
- public function setLocked($locked)
- {
- $this->locked = $locked;
- }
-
- /**
- * @return string
- */
- public function getLocked()
- {
- return $this->locked;
- }
-
- /**
- * @param string $mime
- */
- public function setMime($mime)
- {
- $this->mime = $mime;
- }
-
- /**
- * @return string
- */
- public function getMime()
- {
- return $this->mime;
- }
-
- /**
- * @param int $mtime
- */
- public function setMtime($mtime)
- {
- $this->mtime = $mtime;
- }
-
- /**
- * @return int
- */
- public function getMtime()
- {
- return $this->mtime;
- }
-
- /**
- * @param string $name
- */
- public function setName($name)
- {
- $this->name = $name;
- }
-
- /**
- * @return string
- */
- public function getName()
- {
- return $this->name;
- }
-
- /**
- * @param int $parentId
- */
- public function setParentId($parentId)
- {
- $this->parentId = $parentId;
- }
-
- /**
- * @return int
- */
- public function getParentId()
- {
- return $this->parentId;
- }
-
- /**
- * @param string $read
- */
- public function setRead($read)
- {
- $this->read = $read;
- }
-
- /**
- * @return string
- */
- public function getRead()
- {
- return $this->read;
- }
-
- /**
- * @param int $size
- */
- public function setSize($size)
- {
- $this->size = $size;
- }
-
- /**
- * @return int
- */
- public function getSize()
- {
- return $this->size;
- }
-
- /**
- * @param int $width
- */
- public function setWidth($width)
- {
- $this->width = $width;
- }
-
- /**
- * @return int
- */
- public function getWidth()
- {
- return $this->width;
- }
-
- /**
- * @param string $write
- */
- public function setWrite($write)
- {
- $this->write = $write;
- }
-
- /**
- * @return string
- */
- public function getWrite()
- {
- return $this->write;
- }
-
-}
diff --git a/src/Resources/fixtures/LoadRootElement.php.dst b/src/Resources/fixtures/LoadRootElement.php.dst
deleted file mode 100644
index 12b58d7..0000000
--- a/src/Resources/fixtures/LoadRootElement.php.dst
+++ /dev/null
@@ -1,40 +0,0 @@
-setId(1);
- $rootElement->setParentId(0);
- $rootElement->setName('DATABASE');
- $rootElement->setContent('');
- $rootElement->setSize(0);
- $rootElement->setMtime(0);
- $rootElement->setMime('directory');
- $rootElement->setRead(1);
- $rootElement->setWrite(1);
- $rootElement->setLocked(0);
- $rootElement->setHidden(0);
- $rootElement->setWidth(0);
- $rootElement->setHeight(0);
-
- $manager->persist($rootElement);
- $manager->flush();
- }
-}
diff --git a/src/Resources/views/Elfinder/ckeditor.html.twig b/src/Resources/views/Elfinder/ckeditor.html.twig
index 57ecce5..6885c30 100644
--- a/src/Resources/views/Elfinder/ckeditor.html.twig
+++ b/src/Resources/views/Elfinder/ckeditor.html.twig
@@ -2,53 +2,88 @@
- {% if includeAssets %}
- {{ include("@FMElfinder/Elfinder/helper/assets_css.html.twig") }}
- {% endif %}
-
-
-{% if includeAssets %}
- {{ include("@FMElfinder/Elfinder/helper/assets_js.html.twig") }}
-{% endif %}
-
+
+
+
+
+
+
- {% if fullscreen %}
- $(window).resize(function(){
- var h = $(window).height();
- var $ef = $('.elfinder');
- if($ef.height() != h - 20){
- $ef.height(h -20).resize();
- }
- });
- $(window).resize();
- {% endif %}
- });
-
-
diff --git a/src/Resources/views/Elfinder/elfinder_type.html.twig b/src/Resources/views/Elfinder/elfinder_type.html.twig
index 6ba8b5a..e21c095 100644
--- a/src/Resources/views/Elfinder/elfinder_type.html.twig
+++ b/src/Resources/views/Elfinder/elfinder_type.html.twig
@@ -1,43 +1,79 @@
- {% if includeAssets %}
- {{ include("@FMElfinder/Elfinder/helper/assets_css.html.twig") }}
- {% endif %}
-
-
-{% if includeAssets %}
- {{ include("@FMElfinder/Elfinder/helper/assets_js.html.twig") }}
-{% endif %}
-
+
+
+
+
+
- {% if fullscreen %}
- var $window = $(window);
- $window.resize(function(){
- var $win_height = $window.height();
- if( $f.height() != $win_height ){
- $f.height($win_height).resize();
- }
- });
- $window.resize();
- {% endif %}
- });
-
-
diff --git a/src/Resources/views/Elfinder/fm_tinymce.html.twig b/src/Resources/views/Elfinder/fm_tinymce.html.twig
index 1d02df6..0d8e876 100644
--- a/src/Resources/views/Elfinder/fm_tinymce.html.twig
+++ b/src/Resources/views/Elfinder/fm_tinymce.html.twig
@@ -1,41 +1,87 @@
-{% if includeAssets %}
- {{ include("@FMElfinder/Elfinder:helper/assets_css.html.twig") }}
-{% endif %}
+
+
+
+
+
-{% if includeAssets %}
- {{ include("@FMElfinder/Elfinder/helper/assets_js.html.twig") }}
-{% endif %}
-
-
+
+
+
diff --git a/src/Resources/views/Elfinder/helper/assets_css.html.twig b/src/Resources/views/Elfinder/helper/assets_css.html.twig
deleted file mode 100644
index 92651be..0000000
--- a/src/Resources/views/Elfinder/helper/assets_css.html.twig
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
diff --git a/src/Resources/views/Elfinder/helper/assets_js.html.twig b/src/Resources/views/Elfinder/helper/assets_js.html.twig
deleted file mode 100644
index 433027b..0000000
--- a/src/Resources/views/Elfinder/helper/assets_js.html.twig
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
diff --git a/src/Resources/views/Elfinder/helper/main.js.twig b/src/Resources/views/Elfinder/helper/main.js.twig
new file mode 100644
index 0000000..8500830
--- /dev/null
+++ b/src/Resources/views/Elfinder/helper/main.js.twig
@@ -0,0 +1,131 @@
+(function(){
+ "use strict";
+ var // jQuery and jQueryUI version
+ jqver = '3.3.1',
+ uiver = '1.12.1',
+
+ // Detect language (optional)
+ lang = (function() {
+ var locq = window.location.search,
+ map = {
+ 'pt' : 'pt_BR',
+ 'ug' : 'ug_CN',
+ 'zh' : 'zh_CN'
+ },
+ full = {
+ 'zh_tw' : 'zh_TW',
+ 'zh_cn' : 'zh_CN',
+ 'fr_ca' : 'fr_CA'
+ },
+ fullLang, locm, lang;
+ if (locq && (locm = locq.match(/lang=([a-zA-Z_-]+)/))) {
+ // detection by url query (?lang=xx)
+ fullLang = locm[1];
+ } else {
+ // detection by browser language
+ fullLang = (navigator.browserLanguage || navigator.language || navigator.userLanguage || '');
+ }
+ fullLang = fullLang.replace('-', '_').substr(0,5).toLowerCase();
+ if (full[fullLang]) {
+ lang = full[fullLang];
+ } else {
+ lang = (fullLang || 'en').substr(0,2);
+ if (map[lang]) {
+ lang = map[lang];
+ }
+ }
+ return lang;
+ })(),
+
+ // Start elFinder (REQUIRED)
+ start = function(elFinder, editors, config) {
+ // load jQueryUI CSS
+ elFinder.prototype.loadCss('//cdnjs.cloudflare.com/ajax/libs/jqueryui/'+uiver+'/themes/smoothness/jquery-ui.css');
+
+ $(function() {
+ var optEditors = {
+ commandsOptions: {
+ edit: {
+ editors: Array.isArray(editors)? editors : []
+ }
+ }
+ },
+ opts = {};
+
+ // Interpretation of "elFinderConfig"
+ if (config && config.managers) {
+ $.each(config.managers, function(id, mOpts) {
+ opts = Object.assign(opts, config.defaultOpts || {});
+ // editors marges to opts.commandOptions.edit
+ try {
+ mOpts.commandsOptions.edit.editors = mOpts.commandsOptions.edit.editors.concat(editors || []);
+ } catch(e) {
+ Object.assign(mOpts, optEditors);
+ }
+ // Make elFinder
+ $('#' + id).elfinder(
+ // 1st Arg - options
+ $.extend(true, { lang: lang }, opts, mOpts || {}),
+ // 2nd Arg - before boot up function
+ function(fm, extraObj) {
+ // `init` event callback function
+ fm.bind('init', function() {
+ // Optional for Japanese decoder "encoding-japanese"
+ if (fm.lang === 'ja') {
+ require(
+ [ 'encoding-japanese' ],
+ function(Encoding) {
+ if (Encoding && Encoding.convert) {
+ fm.registRawStringDecoder(function(s) {
+ return Encoding.convert(s, {to:'UNICODE',type:'string'});
+ });
+ }
+ }
+ );
+ }
+ });
+ }
+ );
+ });
+ } else {
+ alert('"elFinderConfig" object is wrong.');
+ }
+ });
+ },
+
+ // JavaScript loader (REQUIRED)
+ load = function() {
+ require([
+ 'elfinder'
+ , 'extras/editors.default.min' // load text, image editors
+ , 'elFinderConfig'
+ // , 'extras/quicklook.googledocs.min' // optional preview for GoogleApps contents on the GoogleDrive volume
+ ],
+ start,
+ function(error) {
+ alert(error.message);
+ }
+ );
+ },
+
+ // is IE8 or :? for determine the jQuery version to use (optional)
+ old = (typeof window.addEventListener === 'undefined' && typeof document.getElementsByClassName === 'undefined')
+ ||
+ (!window.chrome && !document.unqueID && !window.opera && !window.sidebar && 'WebkitAppearance' in document.documentElement.style && document.body.style && typeof document.body.style.webkitFilter === 'undefined');
+
+ // config of RequireJS (REQUIRED)
+ require.config({
+ baseUrl : 'bundles/fmelfinder/js',
+ paths : {
+ 'jquery' : '//cdnjs.cloudflare.com/ajax/libs/jquery/'+(old? '1.12.4' : jqver)+'/jquery.min',
+ 'jquery-ui': '//cdnjs.cloudflare.com/ajax/libs/jqueryui/'+uiver+'/jquery-ui.min',
+ 'elfinder' : 'elfinder.min',
+ 'encoding-japanese': '//cdn.rawgit.com/polygonplanet/encoding.js/1.0.26/encoding.min'
+ },
+ waitSeconds : 10 // optional
+ });
+
+ // load JavaScripts (REQUIRED)
+ load();
+
+})();
diff --git a/src/Resources/views/Elfinder/simple.html.twig b/src/Resources/views/Elfinder/simple.html.twig
index aa9db87..63306b5 100644
--- a/src/Resources/views/Elfinder/simple.html.twig
+++ b/src/Resources/views/Elfinder/simple.html.twig
@@ -1,34 +1,71 @@
- {% if includeAssets %}
- {{ include("@FMElfinder/Elfinder/helper/assets_css.html.twig") }}
- {% endif %}
+
+
+
+
+
-{% if includeAssets %}
- {{ include("@FMElfinder/Elfinder/helper/assets_js.html.twig") }}
-{% endif %}
-
-
+
+
+
diff --git a/src/Resources/views/Elfinder/summernote.html.twig b/src/Resources/views/Elfinder/summernote.html.twig
index 4b24c0b..c6644d9 100644
--- a/src/Resources/views/Elfinder/summernote.html.twig
+++ b/src/Resources/views/Elfinder/summernote.html.twig
@@ -1,38 +1,86 @@
- {% if includeAssets %}
- {{ include("@FMElfinder/Elfinder/helper/assets_css.html.twig") }}
- {% endif %}
+
+
+
+
+
-{% if includeAssets %}
- {{ include("@FMElfinder/Elfinder/helper/assets_js.html.twig") }}
-{% endif %}
-
-
+
+
+
+
diff --git a/src/Resources/views/Elfinder/tinymce.html.twig b/src/Resources/views/Elfinder/tinymce.html.twig
index f4b2b68..b7c4ecd 100644
--- a/src/Resources/views/Elfinder/tinymce.html.twig
+++ b/src/Resources/views/Elfinder/tinymce.html.twig
@@ -1,63 +1,107 @@
- {% if includeAssets %}
- {{ include("@FMElfinder/Elfinder/helper/assets_css.html.twig") }}
- {% endif %}
-
-
-{% if includeAssets %}
- {{ include("@FMElfinder/Elfinder/helper/assets_js.html.twig") }}
-{% endif %}
-
-
+
-
+ });
+
+
+
+
+
+
+
-
+