From e11988bebb52c4b33bdecf5e71648cfa833a95e5 Mon Sep 17 00:00:00 2001 From: lastlink Date: Fri, 19 Jul 2024 16:46:38 -0400 Subject: [PATCH] reorder fixes and debugging --- Model/Wiki.php | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/Model/Wiki.php b/Model/Wiki.php index 5b79bd0..fdac61e 100755 --- a/Model/Wiki.php +++ b/Model/Wiki.php @@ -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 . "
"; // change order of each in for loop, move matching id to one before target $orderColumn = 1; $targetColumn = 1; @@ -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 . "
"; if ($id == $src_wiki_id) { $oldSourceColumn = $oldOrderColumn; } else { if ($oldOrderColumn != $orderColumn) { - $this->savePagePosition($id, $orderColumn); + // echo "updating ". $id ." column to ". $orderColumn . "
"; + $result = $this->savePagePosition($id, $orderColumn); + if(!$result){ + return false; + } } - $orderColumn++; } + $orderColumn++; } // update moved src + // echo "oldSourceColumn: " . $oldSourceColumn . " targetColumn: " . $targetColumn . "
"; if($oldSourceColumn != $targetColumn -1){ - $this->savePagePosition($src_wiki_id, $orderColumn); + // echo "updating src ". $src_wiki_id . " column to ". $targetColumn -1 . "
"; + $result = $this->savePagePosition($src_wiki_id, $orderColumn -1); + if(!$result){ + return false; + } } + + return true; } public function savePagePosition($wiki_id, $orderColumn) {