From 17318969b75c26c6f1f8aa4371afecb707e4faaf Mon Sep 17 00:00:00 2001 From: Geoforce Date: Mon, 27 Oct 2014 13:48:16 +0100 Subject: [PATCH 1/3] Patch for 2.3: multiple elfinder fields in one form/page --- Controller/ElFinderController.php | 7 ++++--- Resources/views/Elfinder/elfinder_type.html.twig | 2 +- Resources/views/Form/elfinder_widget.html.twig | 8 ++++---- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Controller/ElFinderController.php b/Controller/ElFinderController.php index 6419c0d..683509b 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->getRequest()->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, $id = null) { $editor = $parameters['editor']; $locale = $parameters['locale'] ?: $this->container->getParameter('locale'); @@ -76,7 +76,8 @@ private function selectEditor($parameters, $instance) 'locale' => $locale, 'fullscreen' => $fullscreen, 'includeAssets' => $includeAssets, - 'instance' => $instance + 'instance' => $instance, + "id"=>$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 dc0c538..082fe86 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 ce9ccfd5f1396c164e1e493f7e6bf3cd63d53008 Mon Sep 17 00:00:00 2001 From: Geoforce Date: Mon, 27 Oct 2014 15:55:24 +0100 Subject: [PATCH 2/3] replaced double quotes --- Controller/ElFinderController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Controller/ElFinderController.php b/Controller/ElFinderController.php index 683509b..addf2f9 100644 --- a/Controller/ElFinderController.php +++ b/Controller/ElFinderController.php @@ -77,7 +77,7 @@ private function selectEditor($parameters, $instance, $id = null) 'fullscreen' => $fullscreen, 'includeAssets' => $includeAssets, 'instance' => $instance, - "id"=>$id + 'id'=>$id ); return $result; default: From 6a74e353ad8c8aa22da24b5559229a5066ed8d7b Mon Sep 17 00:00:00 2001 From: Geoforce Date: Mon, 27 Oct 2014 16:14:25 +0100 Subject: [PATCH 3/3] changed var names to match changes in 2.5.1 --- Controller/ElFinderController.php | 4 ++-- Resources/views/Form/elfinder_widget.html.twig | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Controller/ElFinderController.php b/Controller/ElFinderController.php index addf2f9..5af2bfc 100644 --- a/Controller/ElFinderController.php +++ b/Controller/ElFinderController.php @@ -33,7 +33,7 @@ public function showAction($instance) * @param $instance * @return array */ - private function selectEditor($parameters, $instance, $id = null) + 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, $id = null) 'fullscreen' => $fullscreen, 'includeAssets' => $includeAssets, 'instance' => $instance, - 'id'=>$id + 'id'=>$formTypeId ); return $result; default: diff --git a/Resources/views/Form/elfinder_widget.html.twig b/Resources/views/Form/elfinder_widget.html.twig index 082fe86..2724173 100644 --- a/Resources/views/Form/elfinder_widget.html.twig +++ b/Resources/views/Form/elfinder_widget.html.twig @@ -5,8 +5,8 @@ $('[data-type="elfinder-input-field"][id="{{ id }}"]').on("click",function() { var childWin = window.open("{{path('elfinder', {'instance': instance })}}?id={{ id }}", "popupWindow", "height=450, width=900"); }); - function setValue(value, id) { - $('[data-type="elfinder-input-field"]'+ (id ? '[id="'+ id +'"]': '')).val(value); + function setValue(value, element_id) { + $('[data-type="elfinder-input-field"]'+ (element_id ? '[id="'+ element_id +'"]': '')).val(value); } {% endif %}