Skip to content

Commit

Permalink
reorder fixes and debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
lastlink committed Jul 19, 2024
1 parent a237d61 commit e11988b
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions Model/Wiki.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ public function reorderPages($project_id, $src_wiki_id, $target_wiki_id){
// retrieve wiki pages
$wikiPages = $this->getWikipages($project_id);

// echo json_encode($wikiPages), true;

// echo "project_id: " . $project_id . " src_wiki_id: " . $src_wiki_id . " target_wiki_id: " . $target_wiki_id . "<br>";
// change order of each in for loop, move matching id to one before target
$orderColumn = 1;
$targetColumn = 1;
Expand All @@ -114,21 +117,33 @@ public function reorderPages($project_id, $src_wiki_id, $target_wiki_id){
$orderColumn++;
$targetColumn = $orderColumn;
}
// echo " id: " . $id . " oldOrderColumn: " . $oldOrderColumn . " orderColumn: " . $orderColumn . "<br>";

if ($id == $src_wiki_id) {
$oldSourceColumn = $oldOrderColumn;
} else {
if ($oldOrderColumn != $orderColumn) {
$this->savePagePosition($id, $orderColumn);
// echo "updating ". $id ." column to ". $orderColumn . "<br>";
$result = $this->savePagePosition($id, $orderColumn);
if(!$result){
return false;
}
}
$orderColumn++;
}
$orderColumn++;
}

// update moved src
// echo "oldSourceColumn: " . $oldSourceColumn . " targetColumn: " . $targetColumn . "<br>";
if($oldSourceColumn != $targetColumn -1){
$this->savePagePosition($src_wiki_id, $orderColumn);
// echo "updating src ". $src_wiki_id . " column to ". $targetColumn -1 . "<br>";
$result = $this->savePagePosition($src_wiki_id, $orderColumn -1);
if(!$result){
return false;
}
}

return true;
}

public function savePagePosition($wiki_id, $orderColumn) {
Expand Down

0 comments on commit e11988b

Please sign in to comment.