@@ -867,6 +867,30 @@ public function switchAction($action, $httpVars, $fileVars)
867
867
if ($ selection ->isUnique () && strpos ($ selection ->getUniqueFile (), "/ " ) !== 0 ){
868
868
$ selection ->setFiles (array ($ dir . "/ " . $ selection ->getUniqueFile ()));
869
869
}
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
+
870
894
if (!$ selection ->isEmpty ()){
871
895
$ uniqueNodes = $ selection ->buildNodes ($ this ->repository ->driverInstance );
872
896
$ parentAjxpNode = new AJXP_Node ($ this ->urlBase ."/ " , array ());
@@ -899,14 +923,13 @@ public function switchAction($action, $httpVars, $fileVars)
899
923
// Detect page position: we have to loading "siblings"
900
924
$ parentPath = AJXP_Utils::safeDirname ($ node ->getPath ());
901
925
$ siblings = scandir ($ this ->urlBase .$ parentPath );
902
- $ threshold = $ this ->repository ->getOption ("PAGINATION_THRESHOLD " );
903
- $ limitPerPage = $ this ->repository ->getOption ("PAGINATION_NUMBER " );
904
926
foreach ($ siblings as $ i => $ s ){
905
927
if ($ this ->filterFile ($ s , true )) unset($ siblings [$ i ]);
906
928
if ($ this ->filterFolder ($ s )) unset($ siblings [$ i ]);
907
929
}
908
930
if (count ($ siblings ) > $ threshold ){
909
- usort ($ siblings , "strcasecmp " );
931
+ //usort($siblings, "strcasecmp");
932
+ $ siblings = $ this ->orderNodes ($ siblings , $ this ->urlBase .$ parentPath , $ orderField , $ orderDirection );
910
933
$ index = array_search ($ node ->getLabel (), $ siblings );
911
934
$ node ->mergeMetadata (array ("page_position " => floor ($ index / $ limitPerPage ) +1 ));
912
935
}
@@ -921,27 +944,6 @@ public function switchAction($action, $httpVars, $fileVars)
921
944
AJXP_XMLWriter::close ();
922
945
break ;
923
946
}
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
- }
945
947
946
948
$ countFiles = $ this ->countFiles ($ path , !$ lsOptions ["f " ]);
947
949
if (isSet ($ crt_nodes )){
0 commit comments