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

Commit 0ff09da

Browse files
committed
Add a default sorting field and direction for server sorting. Set this params via the filesystem mixin instead of access.fs only.
1 parent 2ca45e1 commit 0ff09da

File tree

5 files changed

+40
-16
lines changed

5 files changed

+40
-16
lines changed

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

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -922,11 +922,13 @@ public function switchAction($action, $httpVars, $fileVars)
922922
break;
923923
}
924924
$orderField = $orderDirection = null;
925-
if ($this->getFilteredOption("REMOTE_SORTING")) {
926-
$orderDirection = isSet($httpVars["order_direction"])?strtolower($httpVars["order_direction"]):"asc";
927-
$orderField = isSet($httpVars["order_column"])?$httpVars["order_column"]: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;
928930
if ($orderField != null && !in_array($orderField, array("ajxp_label", "filesize", "ajxp_modiftime", "mimestring"))) {
929-
$orderField = "ajxp_label";
931+
$orderField = $defaultOrder;
930932
}
931933
}
932934
if(isSet($httpVars["recursive"]) && $httpVars["recursive"] == "true"){
@@ -945,6 +947,7 @@ public function switchAction($action, $httpVars, $fileVars)
945947
if(isSet($crt_nodes)){
946948
$crt_nodes += $countFiles;
947949
}
950+
$totalPages = $crtPage = 1;
948951
if (isSet($threshold) && isSet($limitPerPage) && $countFiles > $threshold) {
949952
$offset = 0;
950953
$crtPage = 1;
@@ -969,13 +972,13 @@ public function switchAction($action, $httpVars, $fileVars)
969972
} else {
970973
AJXP_XMLWriter::renderAjxpHeaderNode($parentAjxpNode);
971974
}
972-
if (isSet($totalPages) && isSet($crtPage)) {
975+
if (isSet($totalPages) && isSet($crtPage) && ($totalPages > 1 || ! AJXP_Utils::userAgentIsNativePydioApp())) {
973976
$remoteOptions = null;
974977
if ($this->getFilteredOption("REMOTE_SORTING")) {
975978
$remoteOptions = array(
976979
"remote_order" => "true",
977-
"currentOrderCol" => isSet($orderField)?$orderField:"ajxp_label",
978-
"currentOrderDir"=> isSet($orderDirection)?$orderDirection:"asc"
980+
"currentOrderCol" => isSet($orderField)?$orderField:$defaultOrder,
981+
"currentOrderDir"=> isSet($orderDirection)?$orderDirection:$defaultDirection
979982
);
980983
}
981984
AJXP_XMLWriter::renderPaginationData(
@@ -987,7 +990,7 @@ public function switchAction($action, $httpVars, $fileVars)
987990
);
988991
if (!$lsOptions["f"]) {
989992
AJXP_XMLWriter::close();
990-
exit(1);
993+
break;
991994
}
992995
}
993996

@@ -1127,13 +1130,13 @@ public function switchAction($action, $httpVars, $fileVars)
11271130
protected function orderNodes($nodes, $path, $orderField, $orderDirection){
11281131

11291132
usort($nodes, "strcasecmp");
1130-
if (isSet($orderField) && isSet($orderDirection) && $orderField == "ajxp_label" && $orderDirection == "desc") {
1133+
if (!empty($orderField) && !empty($orderDirection) && $orderField == "ajxp_label" && $orderDirection == "desc") {
11311134
$nodes = array_reverse($nodes);
11321135
}
11331136
if (!empty($this->driverConf["SCANDIR_RESULT_SORTFONC"])) {
11341137
usort($nodes, $this->driverConf["SCANDIR_RESULT_SORTFONC"]);
11351138
}
1136-
if (isSet($orderField) && isSet($orderDirection) && $orderField != "ajxp_label") {
1139+
if (!empty($orderField) && !empty($orderDirection) && $orderField != "ajxp_label") {
11371140
$toSort = array();
11381141
foreach ($nodes as $node) {
11391142
if($orderField == "filesize") $toSort[$node] = is_file($path."/".$node) ? $this->filesystemFileSize($path."/".$node) : 0;

core/src/plugins/access.fs/manifest.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
<param name="PURGE_AFTER" type="integer" label="CONF_MESSAGE[Purge Days (Hard limit)]" description="CONF_MESSAGE[Option to purge documents after a given number of days (even if shared). This require a manual set up of a CRON task. Leave to 0 if you don't wan't to use this feature.]" default="0"/>
1313
<param name="PURGE_AFTER_SOFT" type="integer" label="CONF_MESSAGE[Purge Days (Soft limit)]" description="CONF_MESSAGE[Option to purge documents after a given number of days (if not shared). This require a manual set up of a CRON task. Leave to 0 if you don't wan't to use this feature.]" default="0"/>
1414
<param name="DATA_TEMPLATE" type="string" label="CONF_MESSAGE[Data template]" description="CONF_MESSAGE[Path to a directory on the filesystem whose content will be copied to the repository the first time it is loaded.]" default=""/>
15-
<param name="REMOTE_SORTING" type="boolean" label="CONF_MESSAGE[Remote Sorting]" description="CONF_MESSAGE[Force remote sorting when in paginated mode. Warning, this can impact the performances.]" default="true"/>
1615
<global_param name="PROBE_REAL_SIZE" type="boolean" label="CONF_MESSAGE[Real Size Probing]" description="CONF_MESSAGE[Use system command line to get the filesize instead of php built-in function (fixes the 2Go limitation)]" default="false"/>
1716
<global_param name="USE_POSIX" type="boolean" label="CONF_MESSAGE[Use POSIX]" description="CONF_MESSAGE[Use php POSIX extension to read files permissions. Only works on *nix systems.]" default="false"/>
1817
<global_param name="USE_XSENDFILE" type="boolean" label="CONF_MESSAGE[X-SendFile Active]" description="CONF_MESSAGE[Delegates all download operations to the webserver using the X-SendFile header. Warning, this is an external module to install for Apache. Module is active by default in Lighttpd. Warning, you have to manually add the folders where files will be downloaded in the module configuration (XSendFilePath directive)]" default="false"/>

core/src/plugins/core.ajaxplorer/ajxp_mixins.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
<param group="MIXIN_MESSAGE[Filesystem Commons]" name="CHARSET" type="string" label="MIXIN_MESSAGE[Character Encoding]" description="MIXIN_MESSAGE[If your server does not set correctly its charset, it can be good to specify it here manually.]" mandatory="false"/>
3434
<param group="MIXIN_MESSAGE[Filesystem Commons]" name="PAGINATION_THRESHOLD" type="integer" label="MIXIN_MESSAGE[Pagination Threshold]" description="MIXIN_MESSAGE[When a folder will contain more items than this number, display will switch to pagination mode, for better performances.]" default="500"/>
3535
<param group="MIXIN_MESSAGE[Filesystem Commons]" name="PAGINATION_NUMBER" type="integer" label="MIXIN_MESSAGE[#Items per page]" description="MIXIN_MESSAGE[Once in pagination mode, number of items to display per page.]" default="200"/>
36+
<param group="MIXIN_MESSAGE[Filesystem Commons]" name="REMOTE_SORTING" type="boolean" label="MIXIN_MESSAGE[Remote Sorting]" description="MIXIN_MESSAGE[Force remote sorting when in paginated mode. Warning, this can impact the performances.]" default="true"/>
37+
<param group="MIXIN_MESSAGE[Filesystem Commons]" name="REMOTE_SORTING_DEFAULT_COLUMN" type="select" label="MIXIN_MESSAGE[Remote Sorting Default Field]" description="MIXIN_MESSAGE[Default field to sort on]" default="ajxp_label" choices="ajxp_label|Name,ajxp_modiftime|Modification date,filesize|File size,mimestring|File Type" mandatory="true" expose="true"/>
38+
<param group="MIXIN_MESSAGE[Filesystem Commons]" name="REMOTE_SORTING_DEFAULT_DIRECTION" type="select" label="MIXIN_MESSAGE[Remote Sorting Default Direction]" description="MIXIN_MESSAGE[Default sorting direction]" default="asc" choices="asc|Ascending,desc|Descending" mandatory="true" expose="true"/>
3639
<global_param group="MIXIN_MESSAGE[Filesystem Commons]" name="SHOW_HIDDEN_FILES" type="boolean" label="MIXIN_MESSAGE[Show hidden files]" description="MIXIN_MESSAGE[Show files beginning with a .]" default="false"/>
3740
<global_param group="MIXIN_MESSAGE[Filesystem Commons]" name="HIDE_RECYCLE" type="boolean" label="MIXIN_MESSAGE[Hide recycle bin]" description="MIXIN_MESSAGE[Whether to show the recycle bin folder. Unlike in the following options, the folder will be hidden but still writeable.]" default="false"/>
3841
<global_param group="MIXIN_MESSAGE[Filesystem Commons]" name="HIDE_EXTENSIONS" type="string" label="MIXIN_MESSAGE[Hide extensions]" description="MIXIN_MESSAGE[Comma-separated list of extensions to hide. Extensions, files and folders that are hidden are also access forbidden.]" default="ser"/>

core/src/plugins/core.ajaxplorer/i18n/conf/en.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,14 +142,16 @@
142142
"For multiple authentication, apply this role to users authenticated via this driver" => "For multiple authentication, apply this role to users authenticated via this driver",
143143
"DSN" => "DSN",
144144
"Data Source Name" => "Data Source Name",
145-
"User" => "User",
146-
"User name" => "User name",
147-
"Password" => "Password",
148-
"User password" => "User password",
149145
"Host" => "Host",
150146
"Database server" => "Database server",
151147
"Database" => "Database",
152148
"Database name" => "Database name",
153149
"File" => "File",
154150
"Database file" => "Database file",
151+
"Remote Sorting" => "Remote Sorting",
152+
"Force remote sorting when in paginated mode. Warning, this can impact the performances." => "Force remote sorting when in paginated mode. Warning, this can impact the performances.",
153+
"Remote Sorting Default Field" => "Remote Sorting Default Field",
154+
"Default field to sort on" => "Default field to sort on",
155+
"Remote Sorting Default Direction" => "Remote Sorting Default Direction",
156+
"Default sorting direction" => "Default sorting direction",
155157
);

core/src/plugins/core.ajaxplorer/i18n/conf/fr.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@
113113
"Hide files" => "Cacher des fichiers",
114114
"Comma-separated list of specific files to hide" => "Liste, séparée par des virgules, de fichiers à cacher.",
115115
"Metadata and indexation" => "Métadonnées et indexation",
116-
"Default Metasources" => "Metasources par défaut",
117116
"Comma-separated list of metastore and meta plugins, that will be automatically applied to all repositories created with this driver" => "Liste des metastore et des plugins meta (séparés par des virgules) appliqués automatiquement lors de la création de dépôts utilisant ce driver.",
118117
"Pydio Main Options" => "Options principales de Pydio",
119118
"Server URL" => "URL du serveur",
@@ -138,4 +137,22 @@
138137
"Explicitly disable WebDAV access for this repository." => "Désactiver explicitement l'accès WebDAV pour ce dépôt.",
139138
"Allow to group admins" => "Autoriser le groupe administrateur",
140139
"Allow group administrators to create a repository from this template." => "Autoriser le groupe administrateur à créer un dépôt à partir de ce modèle.",
140+
"Skip auto-update admin rights" => "Passer la mise à jour des droits admin",
141+
"If you have tons of workspaces (which is not recommanded), admin users login can take a long time while updating admin access to all repositories. Use this option to disable this step, admin will always have access to the Settings." => "Si vous avez de nombreux workspaces (ce qui n'est pas recommandé), l'identification d'un utilisateur administrateur peut prendre du temps afin de s'assurer que l'admin a accès à tous les workspaces. Vous pouvez désactiver cette étape.",
142+
"Auto apply role" => "Appliquer le rôle automatiquement",
143+
"For multiple authentication, apply this role to users authenticated via this driver" => "Pour des authentifications multiples, définir un rôle qui sera appliqué automatiquement aux utilisateurs identifiés via ce driver.",
144+
"DSN" => "DSN",
145+
"Data Source Name" => "Data Source Name",
146+
"Host" => "Hôte",
147+
"Database server" => "Serveur de Base de Données",
148+
"Database" => "Base de Données",
149+
"Database name" => "Nom de la base de données",
150+
"File" => "Fichiers",
151+
"Database file" => "Fichier de la base de données",
152+
"Remote Sorting" => "Tri distant",
153+
"Force remote sorting when in paginated mode. Warning, this can impact the performances." => "Forcer le tri sur le serveur plutôt que dans l'interface en mode paginé. Attention, ceci peut impacter les performances.",
154+
"Remote Sorting Default Field" => "Champ par défaut.",
155+
"Default field to sort on" => "Champ par défaut pour le tri distant.",
156+
"Remote Sorting Default Direction" => "Direction par défaut.",
157+
"Default sorting direction" => "Direction par défaut (croissant / décroissant) pour le tri distant.",
141158
);

0 commit comments

Comments
 (0)