aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpolo <ordipolo@gmx.fr>2025-09-05 23:19:59 +0200
committerpolo <ordipolo@gmx.fr>2025-09-05 23:19:59 +0200
commit7be773469a719d4170dcb6418b85277540c08b3f (patch)
tree0dbfe06c80c0a0977ba6689c1b86f66be1f521af
parenta595663f5ccba28ccdca919f89612ce0a3f579c3 (diff)
downloadcms-7be773469a719d4170dcb6418b85277540c08b3f.zip
html dans MainBuilder déplacé dans la vue modify_block.php
-rw-r--r--src/view/MainBuilder.php52
-rw-r--r--src/view/templates/modify_block.php37
2 files changed, 43 insertions, 46 deletions
diff --git a/src/view/MainBuilder.php b/src/view/MainBuilder.php
index b07fa81..e6fc61a 100644
--- a/src/view/MainBuilder.php
+++ b/src/view/MainBuilder.php
@@ -53,8 +53,6 @@ class MainBuilder extends AbstractBuilder
53 // mode modification de page uniquement 53 // mode modification de page uniquement
54 private function viewEditBlocks($node): void 54 private function viewEditBlocks($node): void
55 { 55 {
56 //$viewFile = self::VIEWS_PATH . $node->getName() . '.php'; // mode modification uniquement
57 $viewFile = self::VIEWS_PATH . 'modify_page.php'; // mode modification uniquement
58 $blocks = Blocks::getTypeNamePairs(); 56 $blocks = Blocks::getTypeNamePairs();
59 57
60 $options = ''; 58 $options = '';
@@ -71,58 +69,20 @@ class MainBuilder extends AbstractBuilder
71 } 69 }
72 } 70 }
73 71
72 // ceci pourrait être déplacé au début des blocs
74 $bloc_edit = ''; 73 $bloc_edit = '';
75 foreach($node->getChildren() as $child_node){ 74 foreach($node->getChildren() as $child_node){
76 // mettre tout ça dans une vue modify_block.php 75 ob_start();
77 // => pourrait être déplacé au niveau des articles 76 require self::VIEWS_PATH . 'modify_block.php';
78 77 $bloc_edit .= ob_get_clean();
79 // renommage d'un bloc
80 $bloc_edit .= '<div class="modify_one_block" id="bloc_edit_' . $child_node->getId() . '">
81 <div class="block_options">
82 <label for="bloc_rename_' . $child_node->getId() . '">Type <b>' . Blocks::getNameFromType($child_node->getName()) . '</b></label>
83 <p>
84 <input type="text" id="bloc_rename_' . $child_node->getId() . '" name="bloc_rename_title" value="' . $child_node->getNodeData()->getdata()['title'] . '" required>
85 <button onclick="renamePageBloc(' . $child_node->getId() . ')">Renommer</button>
86 </p>'. "\n";
87 // déplacement d'un bloc
88 $bloc_edit .= '<div>
89 <p>
90 <img class="action_icon" onclick="switchBlocsPositions(' . $child_node->getId() . ', \'up\')" src="assets/arrow-up.svg">
91 <img class="action_icon" onclick="switchBlocsPositions(' . $child_node->getId() . ', \'down\')" src="assets/arrow-down.svg">
92 </p>' . "\n";
93 // suppression d'un bloc
94 $bloc_edit .= '<form method="post" action="' . new URL(['page' => CURRENT_PAGE]) . '">
95 <input type="hidden" name="delete_bloc_id" value="' . $child_node->getId() . '">
96 <input type="hidden" name="delete_bloc_hidden">
97 <input type="submit" value="Supprimer" onclick="return confirm(\'Voulez-vous vraiment supprimer ce bloc?\');">
98 </form>
99 </div>
100 </div>'. "\n";
101 if($child_node->getNodeData()->getPresentation() !== null){
102 // select mode de présentation
103 $bloc_edit .= '<div class="grid_options"><p>
104 <label for="presentation_select_' . $child_node->getId() . '">Présentation</label>
105 <select id="presentation_select_' . $child_node->getId() . '" onchange="changePresentation(' . $child_node->getId() . ')">';
106 $bloc_edit .= $this->makePresentationOptions($child_node->getNodeData()->getPresentation()->getName());
107 $bloc_edit .= '</select>';
108 // select largeur minimale colonnes mode grid
109 $bloc_edit .= '<div id="cols_min_width_edit_' . $child_node->getId() . '" class="' . ($child_node->getNodeData()->getPresentation()->getName() === 'grid' ? '' : 'hidden') . '">
110 <label for="cols_min_width_select_' . $child_node->getId() . '">Largeur minimum </label>';
111 $bloc_edit .= '<input type="number" id="cols_min_width_select_' . $child_node->getId() . '" onchange="changeColsMinWidth(' . $child_node->getId() . ')" min="150" max="400" value="' . $child_node->getNodeData()->getColsMinWidth() . '">';
112 /*$bloc_edit .= '<select id="cols_min_width_select_' . $child_node->getId() . '" onchange="changeColsMinWidth(' . $child_node->getId() . ')">'
113 . $this->makeColsMinWidthOptions($child_node->getNodeData()->getColsMinWidth())
114 . '</select>';*/
115 $bloc_edit .= ' pixels</div>
116 </div>';
117 }
118 $bloc_edit .= "</div>\n";
119 } 78 }
120 79
121 ob_start(); 80 ob_start();
122 require $viewFile; 81 require self::VIEWS_PATH . 'modify_page.php';
123 $this->html .= ob_get_clean(); 82 $this->html .= ob_get_clean();
124 } 83 }
125 84
85 // utilisée dans modify_block.php
126 private function makePresentationOptions(string $presentation): string 86 private function makePresentationOptions(string $presentation): string
127 { 87 {
128 $options = ''; 88 $options = '';
diff --git a/src/view/templates/modify_block.php b/src/view/templates/modify_block.php
new file mode 100644
index 0000000..dae8994
--- /dev/null
+++ b/src/view/templates/modify_block.php
@@ -0,0 +1,37 @@
1<div class="modify_one_block" id="bloc_edit_<?= $child_node->getId() ?>">
2 <div class="block_options">
3 <label for="bloc_rename_<?= $child_node->getId() ?>">Type <b><?= Blocks::getNameFromType($child_node->getName()) ?></b>
4 </label>
5 <p>
6 <input type="text" id="bloc_rename_<?= $child_node->getId() ?>" name="bloc_rename_title" value="<?= $child_node->getNodeData()->getdata()['title'] ?>" required>
7 <button onclick="renamePageBloc(<?= $child_node->getId() ?>)">Renommer</button>
8 </p>
9 <div>
10 <p>
11 <img class="action_icon" onclick="switchBlocsPositions(<?= $child_node->getId() ?>, 'up')" src="assets/arrow-up.svg">
12 <img class="action_icon" onclick="switchBlocsPositions(<?= $child_node->getId() ?>, 'down')" src="assets/arrow-down.svg">
13 </p>
14 <form method="post" action="<?= new URL(['page' => CURRENT_PAGE]) ?>">
15 <input type="hidden" name="delete_bloc_id" value="<?= $child_node->getId() ?>">
16 <input type="hidden" name="delete_bloc_hidden">
17 <input type="submit" value="Supprimer" onclick="return confirm('Voulez-vous vraiment supprimer ce bloc?');">
18 </form>
19 </div>
20 </div>
21<?php
22if($child_node->getNodeData()->getPresentation() !== null){
23?>
24 <div class="grid_options"><p>
25 <label for="presentation_select_<?= $child_node->getId() ?>">Présentation</label>
26 <select id="presentation_select_<?= $child_node->getId() ?>" onchange="changePresentation(<?= $child_node->getId() ?>)">
27 <?= $this->makePresentationOptions($child_node->getNodeData()->getPresentation()->getName()) ?>
28 </select>
29 <div id="cols_min_width_edit_<?= $child_node->getId() ?>" class="<?= ($child_node->getNodeData()->getPresentation()->getName() === 'grid' ? '' : 'hidden') ?>">
30 <label for="cols_min_width_select_' . $child_node->getId() . '">Largeur minimum </label>
31 <input type="number" id="cols_min_width_select_<?= $child_node->getId() ?>" onchange="changeColsMinWidth(<?= $child_node->getId() ?>)" min="150" max="400" value="<?= $child_node->getNodeData()->getColsMinWidth() ?>"> pixels
32 </div>
33 </div>
34<?php
35}
36?>
37</div> \ No newline at end of file