summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorpolo <ordipolo@gmx.fr>2025-06-26 11:11:24 +0200
committerpolo <ordipolo@gmx.fr>2025-06-26 11:11:24 +0200
commitf60a9d046088b3bad3e97ff568fc83fecc67ccde (patch)
tree7ed05b051abf68c21997e8fab70457ebb8af4b60 /src
parent3e17f6ef6983a9f24ca658fd1b9f856d3f09fcd7 (diff)
downloadcms-f60a9d046088b3bad3e97ff568fc83fecc67ccde.zip
ajout dans css_array à la création d'un bloc
Diffstat (limited to 'src')
-rw-r--r--src/controller/post.php26
-rw-r--r--src/model/entities/Node.php8
-rw-r--r--src/view/MainBuilder.php9
3 files changed, 35 insertions, 8 deletions
diff --git a/src/controller/post.php b/src/controller/post.php
index 3ba0656..7e6ed53 100644
--- a/src/controller/post.php
+++ b/src/controller/post.php
@@ -132,8 +132,32 @@ if($_SERVER['REQUEST_METHOD'] === 'POST' && $_SESSION['admin'] === true)
132 $main = $director->getNode(); 132 $main = $director->getNode();
133 $position = count($main->getChildren()) + 1; // position dans la fraterie 133 $position = count($main->getChildren()) + 1; // position dans la fraterie
134 134
135 $blocs_true_names = ['blog', 'grid', 'calendar', 'galery', 'form']; // même liste dans FormBuilder.php
136 if(!in_array($_POST["bloc_select"], $blocs_true_names, true)) // 3è param: contrôle du type
137 {
138 header("Location: " . new URL(['page' => $_GET['page'], 'error' => 'bad_bloc_type']));
139 die;
140 }
141
142 if($_POST["bloc_select"] === 'calendar'){
143 $dql = 'SELECT n FROM App\Entity\Node n WHERE n.page = :page AND n.name_node = :name'; // noeud 'head' de la page
144 $bulk_data = $entityManager
145 ->createQuery($dql)
146 ->setParameter('page', $page)
147 ->setParameter('name', 'head')
148 ->getResult();
149
150 if(count($bulk_data) != 1){ // 1 head par page
151 header("Location: " . new URL(['page' => $_GET['page'], 'error' => 'head_node_not_found']));
152 die;
153 }
154
155 $bulk_data[0]->addAttribute('css_array', 'calendar');
156 $entityManager->persist($bulk_data[0]);
157 }
158
135 $bloc = new Node( 159 $bloc = new Node(
136 trim(htmlspecialchars($_POST["bloc_select"])), 160 $_POST["bloc_select"],
137 null, [], 161 null, [],
138 $position, 162 $position,
139 $main, 163 $main,
diff --git a/src/model/entities/Node.php b/src/model/entities/Node.php
index 711eb3e..c4d0830 100644
--- a/src/model/entities/Node.php
+++ b/src/model/entities/Node.php
@@ -98,13 +98,15 @@ class Node
98 { 98 {
99 $this->attributes = self::$default_attributes; 99 $this->attributes = self::$default_attributes;
100 } 100 }
101 /*public function addAttribute(string $key, string $value): void 101 public function addAttribute(string $key, string $value): void
102 { 102 {
103 if(!isset($this->attributes[$key])) { // sécurité $key inexistante 103 if(!isset($this->attributes[$key])) { // sécurité $key inexistante
104 $this->attributes[$key] = []; 104 $this->attributes[$key] = [];
105 } 105 }
106 $this->attributes[$key][] = $value; 106 if(!in_array($value, $this->attributes[$key])){
107 }*/ 107 $this->attributes[$key][] = $value;
108 }
109 }
108 /*public function removeAttribute(string $key, string $value): void 110 /*public function removeAttribute(string $key, string $value): void
109 { 111 {
110 if(isset($this->attributes[$key])) // sécurité $key inexistante 112 if(isset($this->attributes[$key])) // sécurité $key inexistante
diff --git a/src/view/MainBuilder.php b/src/view/MainBuilder.php
index 11f5c4b..a478412 100644
--- a/src/view/MainBuilder.php
+++ b/src/view/MainBuilder.php
@@ -55,8 +55,8 @@ class MainBuilder extends AbstractBuilder
55 $viewFile = self::VIEWS_PATH . $node->getName() . '.php'; // mode modification uniquement 55 $viewFile = self::VIEWS_PATH . $node->getName() . '.php'; // mode modification uniquement
56 56
57 // blocs disponibles 57 // blocs disponibles
58 $blocs = ['Blog', 'Grille', 'Calendrier', 'Galerie']; // générer ça dynamiquement! 58 $blocs = ['Blog', 'Grille', 'Calendrier', 'Galerie', 'Formulaire']; // générer ça dynamiquement!
59 $blocs_true_names = ['blog', 'grid', 'calendar', 'galery']; 59 $blocs_true_names = ['blog', 'grid', 'calendar', 'galery', 'form']; // même liste dans post.php
60 60
61 $options = ''; 61 $options = '';
62 for($i = 0; $i < count($blocs); $i++){ 62 for($i = 0; $i < count($blocs); $i++){
@@ -85,7 +85,8 @@ class MainBuilder extends AbstractBuilder
85 foreach($node->getChildren() as $child_node){ 85 foreach($node->getChildren() as $child_node){
86 // renommage d'un bloc 86 // renommage d'un bloc
87 $bloc_edit .= '<div id="bloc_edit_' . $child_node->getId() . '"> 87 $bloc_edit .= '<div id="bloc_edit_' . $child_node->getId() . '">
88 <p><label for="bloc_rename_' . $child_node->getId() . '">Titre</label> 88 <p><label>Type <i>' . $child_node->getName() . '</i>, </label>
89 <label for="bloc_rename_' . $child_node->getId() . '">Titre</label>
89 <input type="text" id="bloc_rename_' . $child_node->getId() . '" name="bloc_rename_title" value="' . $child_node->getNodeData()->getdata()['title'] . '" required> 90 <input type="text" id="bloc_rename_' . $child_node->getId() . '" name="bloc_rename_title" value="' . $child_node->getNodeData()->getdata()['title'] . '" required>
90 <button onclick="renamePageBloc(' . $child_node->getId() . ')">Renommer</button>'. "\n"; 91 <button onclick="renamePageBloc(' . $child_node->getId() . ')">Renommer</button>'. "\n";
91 // déplacement d'un bloc 92 // déplacement d'un bloc
@@ -95,7 +96,7 @@ class MainBuilder extends AbstractBuilder
95 $bloc_edit .= '<form method="post" action="' . new URL(['page' => CURRENT_PAGE]) . '"> 96 $bloc_edit .= '<form method="post" action="' . new URL(['page' => CURRENT_PAGE]) . '">
96 <input type="hidden" name="delete_bloc_id" value="' . $child_node->getId() . '"> 97 <input type="hidden" name="delete_bloc_id" value="' . $child_node->getId() . '">
97 <input type="hidden" name="delete_bloc_hidden"> 98 <input type="hidden" name="delete_bloc_hidden">
98 <input type="submit" value="Supprimer"></p> 99 <input type="submit" value="Supprimer" onclick="return confirm(\'Voulez-vous vraiment supprimer cette page?\');"></p>
99 </form> 100 </form>
100 </div>'. "\n"; 101 </div>'. "\n";
101 } 102 }