Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
FS: Pass __AJXP_ZIP_FLAT__ to makeZip function to force all files to …
Browse files Browse the repository at this point in the history
…be at level 0

Fix tabulator et splitter resizing issues
Download Cart.
  • Loading branch information
cdujeu committed Sep 25, 2013
1 parent 3458a33 commit 8b2353c
Show file tree
Hide file tree
Showing 9 changed files with 156 additions and 34 deletions.
14 changes: 10 additions & 4 deletions core/src/plugins/access.fs/class.fsAccessDriver.php
Expand Up @@ -230,7 +230,7 @@ public function switchAction($action, $httpVars, $fileVars)
// Make a temp zip and send it as download
$loggedUser = AuthService::getLoggedUser();
$file = AJXP_Utils::getAjxpTmpDir()."/".($loggedUser?$loggedUser->getId():"shared")."_".time()."tmpDownload.zip";
$zipFile = $this->makeZip($selection->getFiles(), $file, $dir);
$zipFile = $this->makeZip($selection->getFiles(), $file, empty($dir)?"/":$dir);
if(!$zipFile) throw new AJXP_Exception("Error while compressing");
register_shutdown_function("unlink", $file);
$localName = ($base==""?"Files":$base).".zip";
Expand Down Expand Up @@ -1868,7 +1868,6 @@ public function makeZip ($src, $dest, $basedir)
foreach ($src as $item) {
$realFile = call_user_func(array($this->wrapperClassName, "getRealFSReference"), $this->urlBase."/".$item);
$realFile = AJXP_Utils::securePath($realFile);
$basedir = trim(dirname($realFile));
if (basename($item) == "") {
$filePaths[] = array(PCLZIP_ATT_FILE_NAME => $realFile);
} else {
Expand All @@ -1877,10 +1876,17 @@ public function makeZip ($src, $dest, $basedir)
}
}
$this->logDebug("Pathes", $filePaths);
$this->logDebug("Basedir", array($basedir));
self::$filteringDriverInstance = $this;
$archive = new PclZip($dest);
$vList = $archive->create($filePaths, PCLZIP_OPT_REMOVE_PATH, $basedir, PCLZIP_OPT_NO_COMPRESSION, PCLZIP_OPT_ADD_TEMP_FILE_ON, PCLZIP_CB_PRE_ADD, 'zipPreAddCallback');

if($basedir == "__AJXP_ZIP_FLAT__/"){
$vList = $archive->create($filePaths, PCLZIP_OPT_REMOVE_ALL_PATH, PCLZIP_OPT_NO_COMPRESSION, PCLZIP_OPT_ADD_TEMP_FILE_ON, PCLZIP_CB_PRE_ADD, 'zipPreAddCallback');
}else{
$basedir = call_user_func(array($this->wrapperClassName, "getRealFSReference"), $this->urlBase).trim($basedir);
$this->logDebug("Basedir", array($basedir));
$vList = $archive->create($filePaths, PCLZIP_OPT_REMOVE_PATH, $basedir, PCLZIP_OPT_NO_COMPRESSION, PCLZIP_OPT_ADD_TEMP_FILE_ON, PCLZIP_CB_PRE_ADD, 'zipPreAddCallback');
}

if (!$vList) {
throw new Exception("Zip creation error : ($dest) ".$archive->errorInfo(true));
}
Expand Down
74 changes: 65 additions & 9 deletions core/src/plugins/action.cart/class.CartManager.js
Expand Up @@ -34,6 +34,60 @@ Class.create("CartManager", FetchedResultPane, {
element.applyDragMove = this.applyDragMove.bind(this);
AjxpDroppables.add(element, this._rootNode);

ajaxplorer.observe("server_message", function(event){
var newValue = XPathSelectSingleNode(event, "nodes_diff/update|nodes_diff/remove");
if(newValue && this._dataLoaded){
// Remove or update selection if node has been removed!
}
}.bind(this));


},

downloadContent: function(){
var h = this.getLocalSelectionForPosting();
if(!$("download_form")) return;

var form = $('download_form');
form.action = window.ajxpServerAccessPath;
form.secure_token.value = Connexion.SECURE_TOKEN;
form.select("input").each(function(input){
if(input.name!='get_action' && input.name!='secure_token') input.remove();
});
h.set('dir', '__AJXP_ZIP_FLAT__/');
h.each(function(pair){
form.insert(new Element('input', {type:'hidden', name:pair.key, value:pair.value}));
});
try{
form.submit();
}catch(e){

}
},

addCurrentSelection: function(){

ajaxplorer.getContextHolder().getSelectedNodes().each(function(n){
if(n.isLeaf()){
this.localNodeFromRemoteNode(n);
}else{
this.recurseLeafs(n);
}
}.bind(this));

},

getLocalSelectionForPosting:function(){

var sel = new $H();
var i = 0;
this._rootNode.getChildren().each(function(n){
var key = "file_" + i;
sel.set(key, n.getPath());
i++;
});
return sel;

},

getRootNode: function(){
Expand All @@ -57,17 +111,19 @@ Class.create("CartManager", FetchedResultPane, {

},

localNodeFromRemoteNode: function(n){

if(this._rootNode.findChildByPath(n.getPath())) return;
var newNode = new AjxpNode(n.getPath(), n.isLeaf(), n.getLabel(), n.getIcon());
newNode.setMetadata($H(Object.clone(n.getMetadata().toObject())));
this._rootNode.addChild(newNode);

},

applyDragMove: function(srcName, targetName, nodeId, copy){

if(srcName != 'ajxp-user-selection') return;

ajaxplorer.getContextHolder().getSelectedNodes().each(function(n){
if(n.isLeaf()){
this._rootNode.addChild(new AjxpNode(n.getPath(), n.isLeaf(), n.getLabel(), n.getIcon()));
}else{
this.recurseLeafs(n);
}
}.bind(this));
this.addCurrentSelection();

},

Expand All @@ -81,7 +137,7 @@ Class.create("CartManager", FetchedResultPane, {
if(node.isLoaded()){
node.getChildren().each(function(n){
if(n.isLeaf()){
this._rootNode.addChild(new AjxpNode(n.getPath(), n.isLeaf(), n.getLabel(), n.getIcon()));
this.localNodeFromRemoteNode(n);
}else{
this.recurseLeafs(n);
}
Expand Down
16 changes: 16 additions & 0 deletions core/src/plugins/action.cart/i18n/en.php
@@ -0,0 +1,16 @@
<?php

$mess = array(

"1" => "To selection cart",
"2" => "Add selected items to current cart",
"3" => "Empty",
"4" => "Empty current cart",
"5" => "New",
"6" => "New selection cart",
"7" => "Download",
"8" => "Download whole cart at once",
"9" => "Default cart",
"10"=> "Carts",

);
44 changes: 38 additions & 6 deletions core/src/plugins/action.cart/manifest.xml
Expand Up @@ -5,6 +5,7 @@
<resources>
<js className="CartManager" file="plugins/action.cart/class.CartManager.js" autoload="true"/>
<js className="LocalCartNodeProvider" file="plugins/action.cart/class.LocalCartNodeProvider.js" autoload="true"/>
<i18n namespace="action.cart" path="plugins/action.cart/i18n"/>
</resources>
</client_settings>

Expand All @@ -16,19 +17,50 @@
<client_configs>
<component_config className="AjxpTabulator::topPane">
<additional_tab id="ajxp-cart-manager"
tabInfo='{"id":"cart-manager","iconClass":"icon-suitcase","element":"ajxp-cart-manager","closeable":false,"label":"Carts","dontFocus":true}'
tabInfo='{"id":"cart-manager","iconClass":"icon-suitcase","element":"ajxp-cart-manager","closeable":false,"label":"action.cart.10","dontFocus":true}'
paneInfo='{"type":"widget"}'><![CDATA[
<div id="ajxp-cart-manager" ajxpClass="AjxpPane" ajxpOptions='{"fit":"height"}'>
<div id="cart-manager-header" class="innerTabulator" ajxpClass="AjxpTabulator" ajxpOptions='{"fit":"height", "fitParent":"browser","defaultTabId": "default-cart","tabInfos": [{"id":"default-cart","label":"Default cart","iconClass":"icon-suitcase", "element":"default-cart"}], "headerToolbarOptions":{"submenuClassName":"panelHeaderMenu","submenuPosition":"bottom right","submenuOffsetTop":12,"toolbarsList":["ajxp-cart-manager"],"skipBubbling":true, "skipCarousel":true,"submenuOffsetTop":2}}'>
<div id="cart-manager-header" class="innerTabulator" ajxpClass="AjxpTabulator" ajxpOptions='{"fit":"height", "fitParent":"browser","defaultTabId": "default-cart","tabInfos": [{"id":"default-cart","label":"action.cart.9","iconClass":"icon-suitcase", "element":"default-cart"}], "headerToolbarOptions":{"submenuClassName":"panelHeaderMenu","submenuPosition":"bottom right","submenuOffsetTop":12,"toolbarsList":["ajxp-cart-manager"],"skipBubbling":true, "skipCarousel":true,"submenuOffsetTop":2}}'>
<div id="default-cart" ajxpClass="CartManager" ajxpOptions='{"nodeProviderProperties":{}}'></div>
</div>
</div>
]]></additional_tab>
</component_config>
</client_configs>
<actions>
<action name="create-cart">
<gui src="" iconClass="icon-plus" text="action.cart.5" title="action.cart.6">
<context dir="true" recycle="true" selection="false" actionBar="true" actionBarGroup="ajxp-cart-manager"/>
</gui>
<processing>
<clientCallback><![CDATA[
var tabulator = $('cart-manager-header').ajxpPaneObject;
if(tabulator){
var newLabel = window.prompt('Provide a label for this selection cart');
if(newLabel){
tabulator.addTab({"id":"new-cart","label":newLabel,"iconClass":"icon-suitcase", closeable:true}, {type:"widget", widgetClass:CartManager, widgetOptions:{}});
}
}
]]></clientCallback>
</processing>
</action>
<action name="send-selection-to-cart">
<gui src="" text="action.cart.1" title="action.cart.2" iconClass="icon-suitcase">
<context dir="true" recycle="true" selection="true" actionBar="false" contextMenu="true" actionBarGroup="change"/>
<selectionContext dir="true" file="true" recycle="false" unique="false"/>
</gui>
<rightsContext adminOnly="false" noUser="false" read="true" userLogged="true" write="false"/>
<processing>
<clientCallback><![CDATA[
var object = $('cart-manager-header').ajxpPaneObject.getAndSetAjxpObject( $('cart-manager-header').ajxpPaneObject.selectedTabInfo );
if(object){
object.addCurrentSelection();
}
]]></clientCallback>
</processing>
</action>
<action name="current-cart-empty">
<gui src="" iconClass="icon-trash" text="1" title="2">
<gui src="" iconClass="icon-trash" text="action.cart.3" title="action.cart.4">
<context dir="true" recycle="true" selection="false" actionBar="true" actionBarGroup="ajxp-cart-manager"/>
</gui>
<processing>
Expand All @@ -41,14 +73,14 @@
</processing>
</action>
<action name="current-cart-download">
<gui src="" iconClass="icon-download-alt" text="1" title="2">
<gui src="" iconClass="icon-download-alt" text="action.cart.7" title="action.cart.8">
<context dir="true" recycle="true" selection="false" actionBar="true" actionBarGroup="ajxp-cart-manager"/>
</gui>
<processing>
<clientCallback><![CDATA[
var object = $('cart-manager-header').ajxpPaneObject.getAndSetAjxpObject( $('cart-manager-header').ajxpPaneObject.selectedTabInfo );
if(object){
if(object && $('download_form')){
object.downloadContent();
}
]]></clientCallback>
</processing>
Expand Down
2 changes: 1 addition & 1 deletion core/src/plugins/gui.ajax/res/js/ajaxplorer.js

Large diffs are not rendered by default.

21 changes: 13 additions & 8 deletions core/src/plugins/gui.ajax/res/js/ajaxplorer/class.AjxpTabulator.js
Expand Up @@ -129,10 +129,12 @@ Class.create("AjxpTabulator", AjxpPane, {
var cdataContent = addNode.firstChild.nodeValue;
var anchor = this.htmlElement;
if(cdataContent && anchor){
anchor.insert(cdataContent);
var compReg = $A();
ajaxplorer.buildGUI(anchor.down('#'+addNode.getAttribute("id")), compReg);
if(compReg.length) ajaxplorer.initAjxpWidgets(compReg);
if(!anchor.down('#'+addNode.getAttribute("id"))){
anchor.insert(cdataContent);
var compReg = $A();
ajaxplorer.buildGUI(anchor.down('#'+addNode.getAttribute("id")), compReg);
if(compReg.length) ajaxplorer.initAjxpWidgets(compReg);
}
this.addTab(addNode.getAttribute("tabInfo").evalJSON(), addNode.getAttribute("paneInfo").evalJSON());
}
}.bind(this));
Expand Down Expand Up @@ -193,7 +195,9 @@ Class.create("AjxpTabulator", AjxpPane, {
editor.resize();
}
}else if(paneInfo.type == 'widget'){

if(paneInfo.widgetClass && paneInfo.widgetOptions){
new paneInfo.widgetClass($(tabInfo.element), paneInfo.widgetOptions);
}
}
this.tabulatorData.push(tabInfo);
if(!tabInfo.dontFocus){
Expand Down Expand Up @@ -235,9 +239,9 @@ Class.create("AjxpTabulator", AjxpPane, {
if(ti){
this.tabulatorData = this.tabulatorData.without(ti);
}
this.resize();
if(previousTab) this.switchTabulator(previousTab.id);
else if(this.tabulatorData.length) this.switchTabulator(this.tabulatorData.first().id);
this.resize();
},

/**
Expand All @@ -250,7 +254,7 @@ Class.create("AjxpTabulator", AjxpPane, {
this.tabulatorData.each(function(tabInfo){
var ajxpObject = this.getAndSetAjxpObject(tabInfo);
tabInfo.headerElement.removeClassName("toggleInactiveBeforeActive");
if(tabInfo.id == tabId){
if(tabInfo.id == tabId){
tabInfo.headerElement.removeClassName("toggleInactive");
if(tabInfo.headerElement.down('img')) tabInfo.headerElement.down('img').show();
if(ajxpObject){
Expand All @@ -273,6 +277,7 @@ Class.create("AjxpTabulator", AjxpPane, {
if(toShow){
if($(toShowElement)) $(toShowElement).show();
toShow.showElement(true);
var reFold = false;
if(this.htmlElement.up('div[ajxpClass="Splitter"]') && this.htmlElement.up('div[ajxpClass="Splitter"]').ajxpPaneObject){
var splitter = this.htmlElement.up('div[ajxpClass="Splitter"]').ajxpPaneObject;
if(splitter.splitbar.hasClassName('folded') && (Element.descendantOf(this.htmlElement, splitter.paneA) || this.htmlElement == splitter.paneA ) ){
Expand All @@ -284,7 +289,7 @@ Class.create("AjxpTabulator", AjxpPane, {
this.resize();
this.notify("switch", tabId);
},

/**
* Resizes the widget
*/
Expand Down
5 changes: 4 additions & 1 deletion core/src/plugins/gui.ajax/res/js/lib/prototype/splitter.js
Expand Up @@ -138,7 +138,10 @@ Class.create("Splitter", AjxpPane, {
var folded = this.getUserPreference("folded");
if(sizePref){
if(folded) this.moveSplitter(parseInt(sizePref));
else this.resizeAnimated(parseInt(sizePref));
else {
this.prefoldValue = parseInt(sizePref);
this.resizeAnimated(parseInt(sizePref));
}
}
if(folded){
this.foldWithoutAnim();
Expand Down
12 changes: 8 additions & 4 deletions core/src/plugins/gui.ajax/res/themes/vision/css/ajaxplorer.css
Expand Up @@ -4147,18 +4147,22 @@ td.ip_geo_cell{

.innerTabulator div.panelHeader.tabulatorContainer
{
padding: 0 0 0 4px;
height: auto;
padding: 0 0 0 0;
height: 26px;
}

.innerTabulator span.toggleHeader{
padding: 4px 7px 4px 2px;
padding: 4px 7px 4px 7px;
border-right: 1px dotted rgb(111, 123, 136);
background-color: white;
background-color: #ebedf0;
color: rgb(111, 123, 136);
font-size: 11px;
}

.innerTabulator span.toggleHeader.toggleInactive{
background-color: white;
}

#files_list_header > #display_toolbar a:hover,
#files_list_header > #display_toolbar a,
div.innerTabulator > div.tabulatorContainer > #display_toolbar a:hover,
Expand Down
2 changes: 1 addition & 1 deletion core/src/plugins/gui.ajax/res/themes/vision/css/allz.css

Large diffs are not rendered by default.

0 comments on commit 8b2353c

Please sign in to comment.