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

Commit 7546380

Browse files
committed
Handle remote sorting when trying to guess the page position.
1 parent 48d98a2 commit 7546380

File tree

4 files changed

+42
-33
lines changed

4 files changed

+42
-33
lines changed

core/src/plugins/access.fs/class.fsAccessDriver.php

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -867,6 +867,30 @@ public function switchAction($action, $httpVars, $fileVars)
867867
if($selection->isUnique() && strpos($selection->getUniqueFile(), "/") !== 0){
868868
$selection->setFiles(array($dir . "/" . $selection->getUniqueFile()));
869869
}
870+
871+
$orderField = $orderDirection = null;
872+
$threshold = 500; $limitPerPage = 200;
873+
$defaultOrder = $this->repository->getOption("REMOTE_SORTING_DEFAULT_COLUMN");
874+
$defaultDirection = $this->repository->getOption("REMOTE_SORTING_DEFAULT_DIRECTION");
875+
if ($this->repository->getOption("REMOTE_SORTING")) {
876+
$orderDirection = isSet($httpVars["order_direction"])?strtolower($httpVars["order_direction"]):$defaultDirection;
877+
$orderField = isSet($httpVars["order_column"])?$httpVars["order_column"]:$defaultOrder;
878+
if ($orderField != null && !in_array($orderField, array("ajxp_label", "filesize", "ajxp_modiftime", "mimestring"))) {
879+
$orderField = $defaultOrder;
880+
}
881+
}
882+
if(isSet($httpVars["recursive"]) && $httpVars["recursive"] == "true"){
883+
$max_depth = (isSet($httpVars["max_depth"])?intval($httpVars["max_depth"]):0);
884+
$max_nodes = (isSet($httpVars["max_nodes"])?intval($httpVars["max_nodes"]):0);
885+
$crt_depth = (isSet($httpVars["crt_depth"])?intval($httpVars["crt_depth"])+1:1);
886+
$crt_nodes = (isSet($httpVars["crt_nodes"])?intval($httpVars["crt_nodes"]):0);
887+
}else{
888+
$threshold = $this->repository->getOption("PAGINATION_THRESHOLD");
889+
if(!isSet($threshold) || intval($threshold) == 0) $threshold = 500;
890+
$limitPerPage = $this->repository->getOption("PAGINATION_NUMBER");
891+
if(!isset($limitPerPage) || intval($limitPerPage) == 0) $limitPerPage = 200;
892+
}
893+
870894
if(!$selection->isEmpty()){
871895
$uniqueNodes = $selection->buildNodes($this->repository->driverInstance);
872896
$parentAjxpNode = new AJXP_Node($this->urlBase."/", array());
@@ -899,14 +923,13 @@ public function switchAction($action, $httpVars, $fileVars)
899923
// Detect page position: we have to loading "siblings"
900924
$parentPath = AJXP_Utils::safeDirname($node->getPath());
901925
$siblings = scandir($this->urlBase.$parentPath);
902-
$threshold = $this->repository->getOption("PAGINATION_THRESHOLD");
903-
$limitPerPage = $this->repository->getOption("PAGINATION_NUMBER");
904926
foreach($siblings as $i => $s){
905927
if($this->filterFile($s, true)) unset($siblings[$i]);
906928
if($this->filterFolder($s)) unset($siblings[$i]);
907929
}
908930
if(count($siblings) > $threshold){
909-
usort($siblings, "strcasecmp");
931+
//usort($siblings, "strcasecmp");
932+
$siblings = $this->orderNodes($siblings, $this->urlBase.$parentPath, $orderField, $orderDirection);
910933
$index = array_search($node->getLabel(), $siblings);
911934
$node->mergeMetadata(array("page_position" => floor($index / $limitPerPage) +1));
912935
}
@@ -921,27 +944,6 @@ public function switchAction($action, $httpVars, $fileVars)
921944
AJXP_XMLWriter::close();
922945
break;
923946
}
924-
$orderField = $orderDirection = null;
925-
$defaultOrder = $this->repository->getOption("REMOTE_SORTING_DEFAULT_COLUMN");
926-
$defaultDirection = $this->repository->getOption("REMOTE_SORTING_DEFAULT_DIRECTION");
927-
if ($this->repository->getOption("REMOTE_SORTING")) {
928-
$orderDirection = isSet($httpVars["order_direction"])?strtolower($httpVars["order_direction"]):$defaultDirection;
929-
$orderField = isSet($httpVars["order_column"])?$httpVars["order_column"]:$defaultOrder;
930-
if ($orderField != null && !in_array($orderField, array("ajxp_label", "filesize", "ajxp_modiftime", "mimestring"))) {
931-
$orderField = $defaultOrder;
932-
}
933-
}
934-
if(isSet($httpVars["recursive"]) && $httpVars["recursive"] == "true"){
935-
$max_depth = (isSet($httpVars["max_depth"])?intval($httpVars["max_depth"]):0);
936-
$max_nodes = (isSet($httpVars["max_nodes"])?intval($httpVars["max_nodes"]):0);
937-
$crt_depth = (isSet($httpVars["crt_depth"])?intval($httpVars["crt_depth"])+1:1);
938-
$crt_nodes = (isSet($httpVars["crt_nodes"])?intval($httpVars["crt_nodes"]):0);
939-
}else{
940-
$threshold = $this->repository->getOption("PAGINATION_THRESHOLD");
941-
if(!isSet($threshold) || intval($threshold) == 0) $threshold = 500;
942-
$limitPerPage = $this->repository->getOption("PAGINATION_NUMBER");
943-
if(!isset($limitPerPage) || intval($limitPerPage) == 0) $limitPerPage = 200;
944-
}
945947

946948
$countFiles = $this->countFiles($path, !$lsOptions["f"]);
947949
if(isSet($crt_nodes)){

core/src/plugins/gui.ajax/res/js/ajaxplorer.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/src/plugins/gui.ajax/res/js/pydio/model/class.AjxpDataModel.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,13 @@ Class.create("AjxpDataModel", {
112112
this.setSelectedNodes([selNode], this);
113113
}else{
114114
if(ajxpNode.getMetadata().get("paginationData") && arguments.length < 3){
115-
var newPage;
115+
var newPage, getPage=true;
116116
var currentPage = ajxpNode.getMetadata().get("paginationData").get("current");
117+
var remoteOrderData = ajxpNode.getMetadata().get("remote_order");
118+
if(remoteOrderData) getPage = remoteOrderData;
117119
this.loadPathInfoSync(selPath, function(foundNode){
118120
newPage = foundNode.getMetadata().get("page_position");
119-
}, true);
121+
}, getPage);
120122
if(newPage && newPage != currentPage){
121123
ajxpNode.getMetadata().get("paginationData").set("new_page", newPage);
122124
this.requireContextChange(ajxpNode, true, true);

core/src/plugins/gui.ajax/res/js/pydio/model/class.RemoteNodeProvider.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,13 @@ Class.create("RemoteNodeProvider", {
8585
conn.sendAsync();
8686
},
8787

88-
/**
89-
* Load a node
90-
* @param node AjxpNode
91-
* @param nodeCallback Function On node loaded
92-
* @param aSync bool
93-
*/
88+
/**
89+
* Load a node
90+
* @param node AjxpNode
91+
* @param nodeCallback Function On node loaded
92+
* @param aSync bool
93+
* @param getPage bool or Object {order_column:'', order_direction:''}
94+
*/
9495
loadLeafNodeSync : function(node, nodeCallback, aSync, getPage){
9596
var conn = new Connexion();
9697
conn.addParameter("get_action", "ls");
@@ -99,6 +100,10 @@ Class.create("RemoteNodeProvider", {
99100
conn.addParameter("file", getBaseName(node.getPath()));
100101
if(getPage){
101102
conn.addParameter("page_position", "true");
103+
if(typeof getPage == 'object' && getPage._object){
104+
conn.addParameter("order_column", getPage.get('order_column'));
105+
conn.addParameter("order_direction", getPage.get('order_direction'));
106+
}
102107
}
103108
if(this.properties){
104109
$H(this.properties).each(function(pair){

0 commit comments

Comments
 (0)