diff --git a/core/src/plugins/action.cart/class.CartManager.js b/core/src/plugins/action.cart/class.CartManager.js index 8865463b50..b56e5ca102 100644 --- a/core/src/plugins/action.cart/class.CartManager.js +++ b/core/src/plugins/action.cart/class.CartManager.js @@ -65,6 +65,38 @@ Class.create("CartManager", FetchedResultPane, { this.triggerEvent(); }, + downloadFetchedPaneContent:function(fetchedResultPane, paneLabel){ + + if(!$("download_form")) return; + var props = Object.clone(fetchedResultPane.options.nodeProviderProperties); + + // Replace "search" by "search-cart-download" + delete props['get_action']; + if(paneLabel) props["archive_name"] = slugString(paneLabel)+".zip"; + + var form = $('download_form'); + form.action = window.ajxpServerAccessPath; + form.secure_token.value = Connexion.SECURE_TOKEN; + var gAction; + form.select("input").each(function(input){ + if(input.name!='get_action' && input.name!='secure_token') input.remove(); + if(input.name == 'get_action') input.value = 'search-cart-download'; + }); + + $H(props).each(function(pair){ + form.insert(new Element('input', {type:'hidden', name:pair.key, value:pair.value})); + }); + try{ + form.submit(); + }catch(e){ + + } + // Reset download form to initial value + form.down('input[name="get_action"]').setValue('download'); + + }, + + downloadContent: function(){ var h = this.getLocalSelectionForPosting(); if(h.size() == 0) return; @@ -78,6 +110,7 @@ Class.create("CartManager", FetchedResultPane, { if(input.name!='get_action' && input.name!='secure_token') input.remove(); }); h.set('dir', '__AJXP_ZIP_FLAT__/'); + h.set('archive_name', slugString(this.__label)+".zip"); h.each(function(pair){ form.insert(new Element('input', {type:'hidden', name:pair.key, value:pair.value})); }); diff --git a/core/src/plugins/action.cart/class.CartManager.php b/core/src/plugins/action.cart/class.CartManager.php new file mode 100644 index 0000000000..b00e1b876e --- /dev/null +++ b/core/src/plugins/action.cart/class.CartManager.php @@ -0,0 +1,48 @@ + + * This file is part of Pydio. + * + * Pydio is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Pydio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Pydio. If not, see . + * + * The latest code can be found at . + */ + +class CartManager extends AJXP_Plugin { + + public function switchAction ($actionName, $httpVars, $fileVars){ + + if($actionName == "search-cart-download"){ + + // Pipe SEARCH + DOWNLOAD actions. + + $indexer = AJXP_PluginsService::getInstance()->getUniqueActivePluginForType("index"); + if($indexer == false) return; + $httpVars["return_selection"] = true; + unset($httpVars["get_action"]); + $res = AJXP_Controller::findActionAndApply("search", $httpVars, $fileVars); + if(isSet($res) && is_array($res)){ + $newHttpVars = array( + "selection_nodes" => $res, + "dir" => "__AJXP_ZIP_FLAT__/", + "archive_name" => $httpVars["archive_name"] + ); + AJXP_Controller::findActionAndApply("download", $newHttpVars, array()); + } + + } + + } + +} \ No newline at end of file diff --git a/core/src/plugins/action.cart/manifest.xml b/core/src/plugins/action.cart/manifest.xml index fc9793f522..26e97ec216 100644 --- a/core/src/plugins/action.cart/manifest.xml +++ b/core/src/plugins/action.cart/manifest.xml @@ -51,12 +51,18 @@ @@ -129,6 +135,30 @@ ]]> + + + + + + + + + + @@ -176,4 +206,5 @@ +