Skip to content

Commit e11988b

Browse files
committed
reorder fixes and debugging
1 parent a237d61 commit e11988b

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

Model/Wiki.php

+18-3
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ public function reorderPages($project_id, $src_wiki_id, $target_wiki_id){
102102
// retrieve wiki pages
103103
$wikiPages = $this->getWikipages($project_id);
104104

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>";
105108
// change order of each in for loop, move matching id to one before target
106109
$orderColumn = 1;
107110
$targetColumn = 1;
@@ -114,21 +117,33 @@ public function reorderPages($project_id, $src_wiki_id, $target_wiki_id){
114117
$orderColumn++;
115118
$targetColumn = $orderColumn;
116119
}
120+
// echo " id: " . $id . " oldOrderColumn: " . $oldOrderColumn . " orderColumn: " . $orderColumn . "<br>";
117121

118122
if ($id == $src_wiki_id) {
119123
$oldSourceColumn = $oldOrderColumn;
120124
} else {
121125
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+
}
123131
}
124-
$orderColumn++;
125132
}
133+
$orderColumn++;
126134
}
127135

128136
// update moved src
137+
// echo "oldSourceColumn: " . $oldSourceColumn . " targetColumn: " . $targetColumn . "<br>";
129138
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+
}
131144
}
145+
146+
return true;
132147
}
133148

134149
public function savePagePosition($wiki_id, $orderColumn) {

0 commit comments

Comments
 (0)