diff options
| author | polo <ordipolo@gmx.fr> | 2025-06-26 11:11:24 +0200 |
|---|---|---|
| committer | polo <ordipolo@gmx.fr> | 2025-06-26 11:11:24 +0200 |
| commit | f60a9d046088b3bad3e97ff568fc83fecc67ccde (patch) | |
| tree | 7ed05b051abf68c21997e8fab70457ebb8af4b60 | |
| parent | 3e17f6ef6983a9f24ca658fd1b9f856d3f09fcd7 (diff) | |
| download | cms-f60a9d046088b3bad3e97ff568fc83fecc67ccde.tar.gz cms-f60a9d046088b3bad3e97ff568fc83fecc67ccde.tar.bz2 cms-f60a9d046088b3bad3e97ff568fc83fecc67ccde.zip | |
ajout dans css_array à la création d'un bloc
| -rw-r--r-- | public/index.php | 2 | ||||
| -rw-r--r-- | src/controller/post.php | 26 | ||||
| -rw-r--r-- | src/model/entities/Node.php | 8 | ||||
| -rw-r--r-- | src/view/MainBuilder.php | 9 |
4 files changed, 36 insertions, 9 deletions
diff --git a/public/index.php b/public/index.php index 8d3148c..bd3eec7 100644 --- a/public/index.php +++ b/public/index.php | |||
| @@ -53,7 +53,7 @@ require '../src/controller/post.php'; | |||
| 53 | $id = ''; | 53 | $id = ''; |
| 54 | if(!empty($_GET['id'])) | 54 | if(!empty($_GET['id'])) |
| 55 | { | 55 | { |
| 56 | $id = htmlspecialchars($_GET['id']); | 56 | $id = htmlspecialchars($_GET['id']); // nettoyage qui n'abime pas les id du genre "n16" |
| 57 | } | 57 | } |
| 58 | 58 | ||
| 59 | if(isset($_GET['action']) && $_GET['action'] === 'deconnexion') | 59 | if(isset($_GET['action']) && $_GET['action'] === 'deconnexion') |
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 | } |
