Bogdan Savluk avatar Bogdan Savluk committed b6866b7

Adding support for multiple ServerFileInput instances with different connectors

Comments (0)

Files changed (1)

ServerFileInput.php

         $(\'#\'+aFieldId).attr(\'value\',url);
         }';
         $settings['closeOnEditorCallback'] = true;
-        $connectorUrl = $this->settings['url'];
+        $connectorUrl = CJavaScript::encode($this->settings['url']);
         $settings = CJavaScript::encode($settings);
         $script = <<<EOD
-        window.elfinderBrowse = function(field_id) {
+        window.elfinderBrowse = function(field_id, connector) {
             var aFieldId = field_id, aWin = this;
             if($("#elFinderBrowser").length == 0) {
                 $("body").append($("<div/>").attr("id", "elFinderBrowser"));
-                $("#elFinderBrowser").elfinder($settings);
+                var settings = $settings;
+                settings["url"] = connector;
+                $("#elFinderBrowser").elfinder(settings);
             }
             else {
-                $("#elFinderBrowser").elfinder("open","$connectorUrl");
+                $("#elFinderBrowser").elfinder("open", connector);
             }
         }
 EOD;
         $cs->registerScript('ServerFileInput#global', $script);
 
         $js = //'$("#'.$id.'").focus(function(){window.elfinderBrowse("'.$name.'")});'.
-            '$("#' . $id . 'browse").click(function(){window.elfinderBrowse("' . $id . '")});';
+            '$("#' . $id . 'browse").click(function(){window.elfinderBrowse("' . $id . '", '.$connectorUrl.')});';
+
 
         $cs->registerScript('ServerFileInput#' . $id, $js);
     }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.