@@ -893,18 +893,33 @@ public function switchAction($action, $httpVars, $fileVars)
893
893
if (!empty ($ node ->metaData ["mimestring_id " ]) && array_key_exists ($ node ->metaData ["mimestring_id " ], $ mess )) {
894
894
$ node ->mergeMetadata (array ("mimestring " => $ mess [$ node ->metaData ["mimestring_id " ]]));
895
895
}
896
+ if (isSet ($ httpVars ["page_position " ]) && $ httpVars ["page_position " ] == "true " ){
897
+ // Detect page position: we have to loading "siblings"
898
+ $ parentPath = AJXP_Utils::safeDirname ($ node ->getPath ());
899
+ $ siblings = scandir ($ this ->urlBase .$ parentPath );
900
+ $ threshold = $ this ->repository ->getOption ("PAGINATION_THRESHOLD " );
901
+ $ limitPerPage = $ this ->repository ->getOption ("PAGINATION_NUMBER " );
902
+ foreach ($ siblings as $ i => $ s ){
903
+ if ($ this ->filterFile ($ s , true )) unset($ siblings [$ i ]);
904
+ if ($ this ->filterFolder ($ s )) unset($ siblings [$ i ]);
905
+ }
906
+ if (count ($ siblings ) > $ threshold ){
907
+ usort ($ siblings , "strcasecmp " );
908
+ $ index = array_search ($ node ->getLabel (), $ siblings );
909
+ $ node ->mergeMetadata (array ("page_position " => floor ($ index / $ limitPerPage ) +1 ));
910
+ }
911
+ }
896
912
if ($ this ->repository ->hasContentFilter ()){
897
913
$ externalPath = $ this ->repository ->getContentFilter ()->externalPath ($ node );
898
914
$ node ->setUrl ($ this ->urlBase .$ externalPath );
899
915
}
916
+
900
917
AJXP_XMLWriter::renderAjxpNode ($ node );
901
918
}
902
919
AJXP_XMLWriter::close ();
903
920
break ;
904
- }/*else if (!$selection->isEmpty() && $selection->isUnique()){
905
- $uniqueFile = $selection->getUniqueFile();
906
- }*/
907
-
921
+ }
922
+ $ orderField = $ orderDirection = null ;
908
923
if ($ this ->getFilteredOption ("REMOTE_SORTING " )) {
909
924
$ orderDirection = isSet ($ httpVars ["order_direction " ])?strtolower ($ httpVars ["order_direction " ]):"asc " ;
910
925
$ orderField = isSet ($ httpVars ["order_column " ])?$ httpVars ["order_column " ]:null ;
@@ -929,18 +944,13 @@ public function switchAction($action, $httpVars, $fileVars)
929
944
$ crt_nodes += $ countFiles ;
930
945
}
931
946
if (isSet ($ threshold ) && isSet ($ limitPerPage ) && $ countFiles > $ threshold ) {
932
- if (isSet ($ uniqueFile )) {
933
- $ originalLimitPerPage = $ limitPerPage ;
934
- $ offset = $ limitPerPage = 0 ;
935
- } else {
936
- $ offset = 0 ;
937
- $ crtPage = 1 ;
938
- if (isSet ($ page )) {
939
- $ offset = (intval ($ page )-1 )*$ limitPerPage ;
940
- $ crtPage = $ page ;
941
- }
942
- $ totalPages = floor ($ countFiles / $ limitPerPage ) + 1 ;
947
+ $ offset = 0 ;
948
+ $ crtPage = 1 ;
949
+ if (isSet ($ page )) {
950
+ $ offset = (intval ($ page )-1 )*$ limitPerPage ;
951
+ $ crtPage = $ page ;
943
952
}
953
+ $ totalPages = floor ($ countFiles / $ limitPerPage ) + 1 ;
944
954
} else {
945
955
$ offset = $ limitPerPage = 0 ;
946
956
}
@@ -988,33 +998,10 @@ public function switchAction($action, $httpVars, $fileVars)
988
998
$ fullList = array ("d " => array (), "z " => array (), "f " => array ());
989
999
990
1000
$ nodes = scandir ($ path );
991
- usort ($ nodes , "strcasecmp " );
992
- if (isSet ($ orderField ) && isSet ($ orderDirection ) && $ orderField == "ajxp_label " && $ orderDirection == "desc " ) {
993
- $ nodes = array_reverse ($ nodes );
994
- }
995
- if (!empty ($ this ->driverConf ["SCANDIR_RESULT_SORTFONC " ])) {
996
- usort ($ nodes , $ this ->driverConf ["SCANDIR_RESULT_SORTFONC " ]);
997
- }
998
- if (isSet ($ orderField ) && isSet ($ orderDirection ) && $ orderField != "ajxp_label " ) {
999
- $ toSort = array ();
1000
- foreach ($ nodes as $ node ) {
1001
- if ($ orderField == "filesize " ) $ toSort [$ node ] = is_file ($ nonPatchedPath ."/ " .$ node ) ? $ this ->filesystemFileSize ($ nonPatchedPath ."/ " .$ node ) : 0 ;
1002
- else if ($ orderField == "ajxp_modiftime " ) $ toSort [$ node ] = filemtime ($ nonPatchedPath ."/ " .$ node );
1003
- else if ($ orderField == "mimestring " ) $ toSort [$ node ] = pathinfo ($ node , PATHINFO_EXTENSION );
1004
- }
1005
- if ($ orderDirection == "asc " ) asort ($ toSort );
1006
- else arsort ($ toSort );
1007
- $ nodes = array_keys ($ toSort );
1008
- }
1009
- //while (strlen($nodeName = readdir($handle)) > 0) {
1001
+ $ nodes = $ this ->orderNodes ($ nodes , $ nonPatchedPath , $ orderField , $ orderDirection );
1002
+
1010
1003
foreach ($ nodes as $ nodeName ) {
1011
- if ($ nodeName == ". " || $ nodeName == ".. " ) continue ;
1012
- if (isSet ($ uniqueFile ) && $ nodeName != $ uniqueFile ) {
1013
- $ cursor ++;
1014
- continue ;
1015
- }
1016
- if ($ offset > 0 && $ cursor < $ offset ) {
1017
- $ cursor ++;
1004
+ if ($ nodeName == ". " || $ nodeName == ".. " ) {
1018
1005
continue ;
1019
1006
}
1020
1007
$ isLeaf = "" ;
@@ -1024,6 +1011,10 @@ public function switchAction($action, $httpVars, $fileVars)
1024
1011
if (RecycleBinManager::recycleEnabled () && $ dir == "" && "/ " .$ nodeName == RecycleBinManager::getRecyclePath ()) {
1025
1012
continue ;
1026
1013
}
1014
+ if ($ offset > 0 && $ cursor < $ offset ) {
1015
+ $ cursor ++;
1016
+ continue ;
1017
+ }
1027
1018
1028
1019
if ($ limitPerPage > 0 && ($ cursor - $ offset ) >= $ limitPerPage ) {
1029
1020
break ;
@@ -1068,9 +1059,6 @@ public function switchAction($action, $httpVars, $fileVars)
1068
1059
1069
1060
$ fullList [$ nodeType ][$ nodeName ] = $ node ;
1070
1061
$ cursor ++;
1071
- if (isSet ($ uniqueFile ) && $ nodeName != $ uniqueFile ) {
1072
- break ;
1073
- }
1074
1062
}
1075
1063
if (isSet ($ httpVars ["recursive " ]) && $ httpVars ["recursive " ] == "true " ) {
1076
1064
$ breakNow = false ;
@@ -1099,7 +1087,7 @@ public function switchAction($action, $httpVars, $fileVars)
1099
1087
array_map (array ("AJXP_XMLWriter " , "renderAjxpNode " ), $ fullList ["f " ]);
1100
1088
1101
1089
// ADD RECYCLE BIN TO THE LIST
1102
- if ($ dir == "" && ! $ uniqueFile && RecycleBinManager::recycleEnabled () && $ this ->getFilteredOption ("HIDE_RECYCLE " , $ this ->repository ->getId ()) !== true ) {
1090
+ if ($ dir == "" && RecycleBinManager::recycleEnabled () && $ this ->getFilteredOption ("HIDE_RECYCLE " , $ this ->repository ->getId ()) !== true ) {
1103
1091
$ recycleBinOption = RecycleBinManager::getRelativeRecycle ();
1104
1092
if (file_exists ($ this ->urlBase .$ recycleBinOption )) {
1105
1093
$ recycleNode = new AJXP_Node ($ this ->urlBase .$ recycleBinOption );
@@ -1134,6 +1122,30 @@ public function switchAction($action, $httpVars, $fileVars)
1134
1122
return $ xmlBuffer ;
1135
1123
}
1136
1124
1125
+ protected function orderNodes ($ nodes , $ path , $ orderField , $ orderDirection ){
1126
+
1127
+ usort ($ nodes , "strcasecmp " );
1128
+ if (isSet ($ orderField ) && isSet ($ orderDirection ) && $ orderField == "ajxp_label " && $ orderDirection == "desc " ) {
1129
+ $ nodes = array_reverse ($ nodes );
1130
+ }
1131
+ if (!empty ($ this ->driverConf ["SCANDIR_RESULT_SORTFONC " ])) {
1132
+ usort ($ nodes , $ this ->driverConf ["SCANDIR_RESULT_SORTFONC " ]);
1133
+ }
1134
+ if (isSet ($ orderField ) && isSet ($ orderDirection ) && $ orderField != "ajxp_label " ) {
1135
+ $ toSort = array ();
1136
+ foreach ($ nodes as $ node ) {
1137
+ if ($ orderField == "filesize " ) $ toSort [$ node ] = is_file ($ path ."/ " .$ node ) ? $ this ->filesystemFileSize ($ path ."/ " .$ node ) : 0 ;
1138
+ else if ($ orderField == "ajxp_modiftime " ) $ toSort [$ node ] = filemtime ($ path ."/ " .$ node );
1139
+ else if ($ orderField == "mimestring " ) $ toSort [$ node ] = pathinfo ($ node , PATHINFO_EXTENSION );
1140
+ }
1141
+ if ($ orderDirection == "asc " ) asort ($ toSort );
1142
+ else arsort ($ toSort );
1143
+ $ nodes = array_keys ($ toSort );
1144
+ }
1145
+ return $ nodes ;
1146
+
1147
+ }
1148
+
1137
1149
public function parseLsOptions ($ optionString )
1138
1150
{
1139
1151
// LS OPTIONS : dz , a, d, z, all of these with or without l
0 commit comments