diff options
| author | polo <ordipolo@gmx.fr> | 2025-04-29 00:27:06 +0200 |
|---|---|---|
| committer | polo <ordipolo@gmx.fr> | 2025-04-29 00:27:06 +0200 |
| commit | 5fc1a655e0271b583f3caa009524ea9d99a8bd3e (patch) | |
| tree | 6af87a085a403dbf123907d26dfde7eed1765da4 /src/controller/post.php | |
| parent | 962d315ec0c99974df3dc2261bf94c54ca8cdbdd (diff) | |
| download | cms-5fc1a655e0271b583f3caa009524ea9d99a8bd3e.tar.gz cms-5fc1a655e0271b583f3caa009524ea9d99a8bd3e.tar.bz2 cms-5fc1a655e0271b583f3caa009524ea9d99a8bd3e.zip | |
page menu et chemins, partie4
Diffstat (limited to 'src/controller/post.php')
| -rw-r--r-- | src/controller/post.php | 84 |
1 files changed, 4 insertions, 80 deletions
diff --git a/src/controller/post.php b/src/controller/post.php index 8924686..66de5a0 100644 --- a/src/controller/post.php +++ b/src/controller/post.php | |||
| @@ -5,89 +5,13 @@ declare(strict_types=1); | |||
| 5 | 5 | ||
| 6 | if($_SERVER['REQUEST_METHOD'] === 'POST' && $_SESSION['admin'] === true) | 6 | if($_SERVER['REQUEST_METHOD'] === 'POST' && $_SESSION['admin'] === true) |
| 7 | { | 7 | { |
| 8 | /* -- requêtes non AJAX -- */ | 8 | /* -- formulaires HTML -- */ |
| 9 | // page Menu et chemin | ||
| 10 | /*if(isset($_POST['menu_edit_post']) && isset($_POST['id'])) | ||
| 11 | { | ||
| 12 | // <= flèche gauche: le parent devient le grand-parent position = position du parent + 1, recalculer les positions des enfants restants | ||
| 13 | if($_POST['menu_edit_post'] == 'move_one_level_up'){ | ||
| 14 | Director::$menu_data = new Menu($entityManager); | ||
| 15 | $page = Director::$menu_data->findPageById((int)$_POST['id']); | ||
| 16 | |||
| 17 | $parent = $page->getParent(); // peut être null | ||
| 18 | if($parent === null){ | ||
| 19 | // 1er niveau: ne rien faire | ||
| 20 | header('Location: ' . new URL(['page' => 'menu_chemins'])); | ||
| 21 | die; | ||
| 22 | } | ||
| 23 | else{ | ||
| 24 | $page->setPosition($parent->getPosition() + 1); // nouvelle position | ||
| 25 | |||
| 26 | // 2ème niveau: le parent devient $menu_data, puis null après tri | ||
| 27 | if($parent->getParent() === null){ | ||
| 28 | // connexion dans les deux sens | ||
| 29 | $page->setParent(Director::$menu_data); // => pour la persistance | ||
| 30 | Director::$menu_data->addChild($page); // => pour sortChildren | ||
| 31 | |||
| 32 | //Director::$menu_data->sortChildren(true); // positions décaléees des nouveaux petits frères | ||
| 33 | $page->getParent()->sortChildren(true); // positions décaléees des nouveaux petits frères | ||
| 34 | |||
| 35 | $page->setParent(null); | ||
| 36 | } | ||
| 37 | // 3ème niveau et plus | ||
| 38 | else{ | ||
| 39 | $page->setParent($parent->getParent()); // nouveau parent | ||
| 40 | $page->getParent()->sortChildren(true); // positions décaléees des nouveaux petits frères | ||
| 41 | } | ||
| 42 | //$parent->sortChildren(true); // positions des enfants restants, inutile si la fonction est récursive? | ||
| 43 | echo $page->getPosition(); | ||
| 44 | //die; | ||
| 45 | } | ||
| 46 | $entityManager->flush(); | ||
| 47 | |||
| 48 | header('Location: ' . new URL(['page' => 'menu_chemins'])); | ||
| 49 | die; | ||
| 50 | } | ||
| 51 | // => flèche droite: l'élément précédent devient le parent, position = nombre d'éléments de la fraterie + 1 | ||
| 52 | elseif($_POST['menu_edit_post'] == 'move_one_level_down') | ||
| 53 | { | ||
| 54 | Director::$menu_data = new Menu($entityManager); | ||
| 55 | $page = Director::$menu_data->findPageById((int)$_POST['id']); | ||
| 56 | |||
| 57 | $parent = $page->getParent(); // peut être null | ||
| 58 | if($parent == null){ | ||
| 59 | $parent = Director::$menu_data; | ||
| 60 | } | ||
| 61 | |||
| 62 | $parent->sortChildren(true); // trie et réindexe par sécurité: 1, 2, 3... | ||
| 63 | if($page->getPosition() > 1){ | ||
| 64 | foreach($parent->getChildren() as $child){ | ||
| 65 | echo $child->getPageName(); | ||
| 66 | if($child->getPosition() === $page->getPosition() - 1){ | ||
| 67 | $page->setParent($child); | ||
| 68 | break; | ||
| 69 | } | ||
| 70 | } | ||
| 71 | $page->setPosition(count($page->getParent()->getChildren()) + 1); | ||
| 72 | } | ||
| 73 | $entityManager->flush(); | ||
| 74 | |||
| 75 | header('Location: ' . new URL(['page' => 'menu_chemins'])); | ||
| 76 | die; | ||
| 77 | } | ||
| 78 | else{ | ||
| 79 | // you talking to me? | ||
| 80 | die; | ||
| 81 | } | ||
| 82 | }*/ | ||
| 83 | |||
| 84 | /* -- requêtes AJAX -- */ | ||
| 85 | require '../src/controller/ajax.php'; | ||
| 86 | |||
| 87 | // formulaires HTML | ||
| 88 | /*if(isset($_POST['from']) // page d'où vient la requête | 9 | /*if(isset($_POST['from']) // page d'où vient la requête |
| 89 | && isset($_POST)) // données | 10 | && isset($_POST)) // données |
| 90 | { | 11 | { |
| 91 | echo "requête envoyée en validant un formulaire"; | 12 | echo "requête envoyée en validant un formulaire"; |
| 92 | }*/ | 13 | }*/ |
| 14 | |||
| 15 | /* -- requêtes AJAX -- */ | ||
| 16 | require '../src/controller/ajax.php'; | ||
| 93 | } | 17 | } |
