From 5748434440c01ea3ffabfb4a0f76c5640f84d3a8 Mon Sep 17 00:00:00 2001 From: Geoforce Date: Wed, 22 Oct 2014 10:43:41 +0200 Subject: [PATCH 1/4] Made it possible to use the elfinder widget multiple times in one page/form by including the ID of the element in the jQuery selector. This will make sure that only the selected element is updated and not all elfinder instances. --- Resources/views/Form/elfinder_widget.html.twig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Resources/views/Form/elfinder_widget.html.twig b/Resources/views/Form/elfinder_widget.html.twig index dc0c538..ab775c8 100644 --- a/Resources/views/Form/elfinder_widget.html.twig +++ b/Resources/views/Form/elfinder_widget.html.twig @@ -2,11 +2,11 @@ {% if enable and instance is defined %} {% endif %} From 45f7812706d554fa93ce19178097dc7b22309445 Mon Sep 17 00:00:00 2001 From: Geoforce Date: Thu, 23 Oct 2014 11:00:41 +0200 Subject: [PATCH 2/4] updated the setValue and click handler functions in elfinder_type to include the instance id. Also updated the Controller to pass the id to the elfinder_widget so it can execute the setValue function with the right id. setValue should still work when no id is passed. --- Controller/ElFinderController.php | 3 ++- Resources/views/Elfinder/elfinder_type.html.twig | 2 +- Resources/views/Form/elfinder_widget.html.twig | 6 +++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Controller/ElFinderController.php b/Controller/ElFinderController.php index 6419c0d..e8dc3f9 100644 --- a/Controller/ElFinderController.php +++ b/Controller/ElFinderController.php @@ -76,7 +76,8 @@ private function selectEditor($parameters, $instance) 'locale' => $locale, 'fullscreen' => $fullscreen, 'includeAssets' => $includeAssets, - 'instance' => $instance + 'instance' => $instance, + 'id'=>$this->getRequest()->get("id") ); return $result; default: diff --git a/Resources/views/Elfinder/elfinder_type.html.twig b/Resources/views/Elfinder/elfinder_type.html.twig index af785a5..393a234 100644 --- a/Resources/views/Elfinder/elfinder_type.html.twig +++ b/Resources/views/Elfinder/elfinder_type.html.twig @@ -15,7 +15,7 @@ url : '{{path('ef_connect', { 'instance': instance } )}}', lang : '{{locale}}', getFileCallback: function(file) { - window.opener.setValue(file.path); + window.opener.setValue(file.path, "{{ id }}"); window.close(); } }); diff --git a/Resources/views/Form/elfinder_widget.html.twig b/Resources/views/Form/elfinder_widget.html.twig index ab775c8..b99287d 100644 --- a/Resources/views/Form/elfinder_widget.html.twig +++ b/Resources/views/Form/elfinder_widget.html.twig @@ -3,10 +3,10 @@ {% if enable and instance is defined %} {% endif %} From ba0825f7ccab9001eaf27240e50360ac98df8389 Mon Sep 17 00:00:00 2001 From: Geoforce Date: Fri, 24 Oct 2014 09:45:01 +0200 Subject: [PATCH 3/4] added formTypeId argument to selectEditor method. --- Controller/ElFinderController.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Controller/ElFinderController.php b/Controller/ElFinderController.php index e8dc3f9..84dec53 100644 --- a/Controller/ElFinderController.php +++ b/Controller/ElFinderController.php @@ -23,7 +23,7 @@ public function showAction($instance) { $efParameters = $this->container->getParameter('fm_elfinder'); $parameters = $efParameters['instances'][$instance]; - $result = $this->selectEditor($parameters, $instance); + $result = $this->selectEditor($parameters, $instance, $this->request->get("id")); return $this->render($result['template'], $result['params']); } @@ -33,7 +33,7 @@ public function showAction($instance) * @param $instance * @return array */ - private function selectEditor($parameters, $instance) + private function selectEditor($parameters, $instance, $formTypeId = null) { $editor = $parameters['editor']; $locale = $parameters['locale'] ?: $this->container->getParameter('locale'); @@ -77,7 +77,7 @@ private function selectEditor($parameters, $instance) 'fullscreen' => $fullscreen, 'includeAssets' => $includeAssets, 'instance' => $instance, - 'id'=>$this->getRequest()->get("id") + 'id'=>$formTypeId ); return $result; default: From fdbc9561bed963cbc1f3d106cc74cb3105f1e7d1 Mon Sep 17 00:00:00 2001 From: Geoforce Date: Fri, 24 Oct 2014 10:21:26 +0200 Subject: [PATCH 4/4] injected Request object directly into action --- Controller/ElFinderController.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Controller/ElFinderController.php b/Controller/ElFinderController.php index 84dec53..fb586dc 100644 --- a/Controller/ElFinderController.php +++ b/Controller/ElFinderController.php @@ -3,6 +3,7 @@ use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpFoundation\Request; /** * Loader service for Elfinder backend @@ -19,11 +20,11 @@ class ElFinderController extends Controller * @param string $instance * @return Response */ - public function showAction($instance) + public function showAction(Request $request, $instance) { $efParameters = $this->container->getParameter('fm_elfinder'); $parameters = $efParameters['instances'][$instance]; - $result = $this->selectEditor($parameters, $instance, $this->request->get("id")); + $result = $this->selectEditor($parameters, $instance, $request->get("id")); return $this->render($result['template'], $result['params']); }