@@ -102,6 +102,9 @@ public function reorderPages($project_id, $src_wiki_id, $target_wiki_id){
102
102
// retrieve wiki pages
103
103
$ wikiPages = $ this ->getWikipages ($ project_id );
104
104
105
+ // echo json_encode($wikiPages), true;
106
+
107
+ // echo "project_id: " . $project_id . " src_wiki_id: " . $src_wiki_id . " target_wiki_id: " . $target_wiki_id . "<br>";
105
108
// change order of each in for loop, move matching id to one before target
106
109
$ orderColumn = 1 ;
107
110
$ targetColumn = 1 ;
@@ -114,21 +117,33 @@ public function reorderPages($project_id, $src_wiki_id, $target_wiki_id){
114
117
$ orderColumn ++;
115
118
$ targetColumn = $ orderColumn ;
116
119
}
120
+ // echo " id: " . $id . " oldOrderColumn: " . $oldOrderColumn . " orderColumn: " . $orderColumn . "<br>";
117
121
118
122
if ($ id == $ src_wiki_id ) {
119
123
$ oldSourceColumn = $ oldOrderColumn ;
120
124
} else {
121
125
if ($ oldOrderColumn != $ orderColumn ) {
122
- $ this ->savePagePosition ($ id , $ orderColumn );
126
+ // echo "updating ". $id ." column to ". $orderColumn . "<br>";
127
+ $ result = $ this ->savePagePosition ($ id , $ orderColumn );
128
+ if (!$ result ){
129
+ return false ;
130
+ }
123
131
}
124
- $ orderColumn ++;
125
132
}
133
+ $ orderColumn ++;
126
134
}
127
135
128
136
// update moved src
137
+ // echo "oldSourceColumn: " . $oldSourceColumn . " targetColumn: " . $targetColumn . "<br>";
129
138
if ($ oldSourceColumn != $ targetColumn -1 ){
130
- $ this ->savePagePosition ($ src_wiki_id , $ orderColumn );
139
+ // echo "updating src ". $src_wiki_id . " column to ". $targetColumn -1 . "<br>";
140
+ $ result = $ this ->savePagePosition ($ src_wiki_id , $ orderColumn -1 );
141
+ if (!$ result ){
142
+ return false ;
143
+ }
131
144
}
145
+
146
+ return true ;
132
147
}
133
148
134
149
public function savePagePosition ($ wiki_id , $ orderColumn ) {
0 commit comments