diff options
| author | polo <ordipolo@gmx.fr> | 2025-05-10 23:51:37 +0200 |
|---|---|---|
| committer | polo <ordipolo@gmx.fr> | 2025-05-10 23:51:37 +0200 |
| commit | 4efa19d4357ab204d62397f1849e4651906e0e70 (patch) | |
| tree | d35c82fdf20762fd6d778eba9bc6d76c9098e9b6 /src/view/MainBuilder.php | |
| parent | aa8898ae00beaa0ac7e65e45c5f28199b25a9267 (diff) | |
| download | cms-4efa19d4357ab204d62397f1849e4651906e0e70.tar.gz cms-4efa19d4357ab204d62397f1849e4651906e0e70.tar.bz2 cms-4efa19d4357ab204d62397f1849e4651906e0e70.zip | |
fichiers manquant du commit précédent
Diffstat (limited to 'src/view/MainBuilder.php')
| -rw-r--r-- | src/view/MainBuilder.php | 47 |
1 files changed, 23 insertions, 24 deletions
diff --git a/src/view/MainBuilder.php b/src/view/MainBuilder.php index 5096134..11f5c4b 100644 --- a/src/view/MainBuilder.php +++ b/src/view/MainBuilder.php | |||
| @@ -14,7 +14,7 @@ class MainBuilder extends AbstractBuilder | |||
| 14 | { | 14 | { |
| 15 | $this->html .= "<main>\n"; | 15 | $this->html .= "<main>\n"; |
| 16 | 16 | ||
| 17 | // cas particulier de la page article où l'article est greffé sur main | 17 | // page article: cas particulier où l'article est greffé sur main |
| 18 | if(Director::$page_path->getLast()->getEndOfPath() === 'article'){ | 18 | if(Director::$page_path->getLast()->getEndOfPath() === 'article'){ |
| 19 | // pas censé arriver | 19 | // pas censé arriver |
| 20 | if(!isset($_GET['id'])){ | 20 | if(!isset($_GET['id'])){ |
| @@ -42,14 +42,18 @@ class MainBuilder extends AbstractBuilder | |||
| 42 | $this->viewEditBlocks($node); | 42 | $this->viewEditBlocks($node); |
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | // cas normal | ||
| 45 | $this->useChildrenBuilder($node); | 46 | $this->useChildrenBuilder($node); |
| 46 | } | 47 | } |
| 47 | 48 | ||
| 48 | $this->html .= "</main>\n"; | 49 | $this->html .= "</main>\n"; |
| 49 | } | 50 | } |
| 50 | 51 | ||
| 52 | // mode modification de page uniquement | ||
| 51 | private function viewEditBlocks($node): void | 53 | private function viewEditBlocks($node): void |
| 52 | { | 54 | { |
| 55 | $viewFile = self::VIEWS_PATH . $node->getName() . '.php'; // mode modification uniquement | ||
| 56 | |||
| 53 | // blocs disponibles | 57 | // blocs disponibles |
| 54 | $blocs = ['Blog', 'Grille', 'Calendrier', 'Galerie']; // générer ça dynamiquement! | 58 | $blocs = ['Blog', 'Grille', 'Calendrier', 'Galerie']; // générer ça dynamiquement! |
| 55 | $blocs_true_names = ['blog', 'grid', 'calendar', 'galery']; | 59 | $blocs_true_names = ['blog', 'grid', 'calendar', 'galery']; |
| @@ -68,41 +72,36 @@ class MainBuilder extends AbstractBuilder | |||
| 68 | </div> | 72 | </div> |
| 69 | </aside>' . "\n";*/ | 73 | </aside>' . "\n";*/ |
| 70 | 74 | ||
| 71 | // création d'un bloc | 75 | //$page_id = Director::$page_path->getLast()->getId(); |
| 72 | $this->html .= '<div class="edit_bloc_zone"> | 76 | $head_node = null; |
| 73 | <div class="new_bloc"> | 77 | foreach(ViewBuilder::$root_node->getChildren() as $first_level_node){ |
| 74 | <p>Ajouter un bloc de page</p> | 78 | if($first_level_node->getName() === 'head'){ |
| 75 | <form method="post" action="' . new URL(['page' => CURRENT_PAGE]) . '"> | 79 | $head_node = $first_level_node; // normallement c'est le 1er enfant |
| 76 | <p><label for="bloc_title">Titre</label> | 80 | break; |
| 77 | <input type="text" id="bloc_title" name="bloc_title" required></p> | 81 | } |
| 78 | <p><label for="bloc_select">Type</label> | 82 | } |
| 79 | <select id="bloc_select" name="bloc_select" required>' | 83 | |
| 80 | . $options . | 84 | $bloc_edit = ''; |
| 81 | '</select> | ||
| 82 | <input type="hidden" name="bloc_title_hidden"> | ||
| 83 | <input type="submit" value="Valider"></p> | ||
| 84 | </form> | ||
| 85 | </div>' . "\n"; | ||
| 86 | $this->html .= '<div class="modify_bloc"> | ||
| 87 | <p>Modifier un bloc</p>'; | ||
| 88 | foreach($node->getChildren() as $child_node){ | 85 | foreach($node->getChildren() as $child_node){ |
| 89 | // renommage d'un bloc | 86 | // renommage d'un bloc |
| 90 | $this->html .= '<div id="bloc_edit_' . $child_node->getId() . '"> | 87 | $bloc_edit .= '<div id="bloc_edit_' . $child_node->getId() . '"> |
| 91 | <p><label for="bloc_rename_' . $child_node->getId() . '">Titre</label> | 88 | <p><label for="bloc_rename_' . $child_node->getId() . '">Titre</label> |
| 92 | <input type="text" id="bloc_rename_' . $child_node->getId() . '" name="bloc_rename_title" value="' . $child_node->getNodeData()->getdata()['title'] . '" required> | 89 | <input type="text" id="bloc_rename_' . $child_node->getId() . '" name="bloc_rename_title" value="' . $child_node->getNodeData()->getdata()['title'] . '" required> |
| 93 | <button onclick="renamePageBloc(' . $child_node->getId() . ')">Renommer</button>'. "\n"; | 90 | <button onclick="renamePageBloc(' . $child_node->getId() . ')">Renommer</button>'. "\n"; |
| 94 | // déplacement d'un bloc | 91 | // déplacement d'un bloc |
| 95 | $this->html .= '<img class="action_icon" onclick="switchBlocsPositions(' . $child_node->getId() . ', \'up\', \'' . CURRENT_PAGE . '\')" src="assets/arrow-up.svg"> | 92 | $bloc_edit .= '<img class="action_icon" onclick="switchBlocsPositions(' . $child_node->getId() . ', \'up\', \'' . CURRENT_PAGE . '\')" src="assets/arrow-up.svg"> |
| 96 | <img class="action_icon" onclick="switchBlocsPositions(' . $child_node->getId() . ', \'down\', \'' . CURRENT_PAGE . '\')" src="assets/arrow-down.svg">' . "\n"; | 93 | <img class="action_icon" onclick="switchBlocsPositions(' . $child_node->getId() . ', \'down\', \'' . CURRENT_PAGE . '\')" src="assets/arrow-down.svg">' . "\n"; |
| 97 | // suppression d'un bloc | 94 | // suppression d'un bloc |
| 98 | $this->html .= '<form method="post" action="' . new URL(['page' => CURRENT_PAGE]) . '"> | 95 | $bloc_edit .= '<form method="post" action="' . new URL(['page' => CURRENT_PAGE]) . '"> |
| 99 | <input type="hidden" name="delete_bloc_id" value="' . $child_node->getId() . '"> | 96 | <input type="hidden" name="delete_bloc_id" value="' . $child_node->getId() . '"> |
| 100 | <input type="hidden" name="delete_bloc_hidden"> | 97 | <input type="hidden" name="delete_bloc_hidden"> |
| 101 | <input type="submit" value="Supprimer"></p> | 98 | <input type="submit" value="Supprimer"></p> |
| 102 | </form> | 99 | </form> |
| 103 | </div>'. "\n"; | 100 | </div>'. "\n"; |
| 104 | } | 101 | } |
| 105 | $this->html .= "</div> | 102 | |
| 106 | </div>\n"; | 103 | ob_start(); |
| 104 | require $viewFile; | ||
| 105 | $this->html .= ob_get_clean(); | ||
| 107 | } | 106 | } |
| 108 | } | 107 | } \ No newline at end of file |
