diff options
author | polo <ordipolo@gmx.fr> | 2025-10-09 14:40:54 +0200 |
---|---|---|
committer | polo <ordipolo@gmx.fr> | 2025-10-09 14:40:54 +0200 |
commit | f0d1cd5d68579b462cf01a4a9f7d558a231bc072 (patch) | |
tree | 2769cef714275d86781a46c2d1f1a8981e3b4bcf | |
parent | 44f4110d53f58086b17d17afe81b0da0978d2a29 (diff) | |
download | cms-f0d1cd5d68579b462cf01a4a9f7d558a231bc072.zip |
description de page déplacée dans la table page
-rw-r--r-- | public/js/modif_page.js | 4 | ||||
-rw-r--r-- | src/controller/ArticleController.php | 4 | ||||
-rw-r--r-- | src/controller/PageManagementController.php | 17 | ||||
-rw-r--r-- | src/installation.php | 30 | ||||
-rw-r--r-- | src/model/entities/Page.php | 14 | ||||
-rw-r--r-- | src/router.php | 2 | ||||
-rw-r--r-- | src/view/HeadBuilder.php | 8 | ||||
-rw-r--r-- | src/view/MainBuilder.php | 8 | ||||
-rw-r--r-- | src/view/templates/modify_page.php | 4 |
9 files changed, 45 insertions, 46 deletions
diff --git a/public/js/modif_page.js b/public/js/modif_page.js index 15f3598..aad53e9 100644 --- a/public/js/modif_page.js +++ b/public/js/modif_page.js | |||
@@ -79,13 +79,13 @@ function changePageTitle(page_id){ | |||
79 | console.error('Erreur:', error); | 79 | console.error('Erreur:', error); |
80 | }); | 80 | }); |
81 | }*/ | 81 | }*/ |
82 | function changeDescription(node_data_id){ | 82 | function changeDescription(page_id){ |
83 | const textarea = document.getElementById("description_textarea"); | 83 | const textarea = document.getElementById("description_textarea"); |
84 | 84 | ||
85 | fetch('index.php?page_edit=page_description', { | 85 | fetch('index.php?page_edit=page_description', { |
86 | method: 'POST', | 86 | method: 'POST', |
87 | headers: { 'Content-Type': 'application/json' }, | 87 | headers: { 'Content-Type': 'application/json' }, |
88 | body: JSON.stringify({description: textarea.value, node_data_id: node_data_id}) | 88 | body: JSON.stringify({description: textarea.value, page_id: page_id}) |
89 | }) | 89 | }) |
90 | .then(response => response.json()) | 90 | .then(response => response.json()) |
91 | .then(data => { | 91 | .then(data => { |
diff --git a/src/controller/ArticleController.php b/src/controller/ArticleController.php index 8bbef19..fabd997 100644 --- a/src/controller/ArticleController.php +++ b/src/controller/ArticleController.php | |||
@@ -151,10 +151,10 @@ class ArticleController | |||
151 | die; | 151 | die; |
152 | } | 152 | } |
153 | 153 | ||
154 | static public function deleteArticle(EntityManager $entityManager, array $json): Response | 154 | static public function deleteArticle(EntityManager $entityManager, array $data): Response // $data peut être un $_GET ou du JSON |
155 | { | 155 | { |
156 | $director = new Director($entityManager); | 156 | $director = new Director($entityManager); |
157 | if(!$director->makeArticleNode($json['id'], true)){ | 157 | if(!$director->makeArticleNode($data['id'], true)){ |
158 | return new Response( | 158 | return new Response( |
159 | '{"success": false, "message": "Erreur: pas d\'article à supprimer"}', | 159 | '{"success": false, "message": "Erreur: pas d\'article à supprimer"}', |
160 | Response::HTTP_INTERNAL_SERVER_ERROR); // 500 | 160 | Response::HTTP_INTERNAL_SERVER_ERROR); // 500 |
diff --git a/src/controller/PageManagementController.php b/src/controller/PageManagementController.php index 8efcb79..e6886b1 100644 --- a/src/controller/PageManagementController.php +++ b/src/controller/PageManagementController.php | |||
@@ -45,25 +45,26 @@ class PageManagementController | |||
45 | 45 | ||
46 | static public function setPageDescription(EntityManager $entityManager, array $json): void | 46 | static public function setPageDescription(EntityManager $entityManager, array $json): void |
47 | { | 47 | { |
48 | $node_data = $entityManager->find('App\Entity\NodeData', $json['node_data_id']); | 48 | $page = $entityManager->find('App\Entity\Page', $json['page_id']); |
49 | $node_data->updateData('description', htmlspecialchars($json['description'])); | 49 | $page->setDescription(htmlspecialchars($json['description'])); |
50 | $entityManager->flush(); | 50 | $entityManager->flush(); |
51 | echo json_encode(['success' => true, 'description' => $node_data->getData()['description']]); | 51 | echo json_encode(['success' => true, 'description' => $page->getDescription()]); |
52 | die; | 52 | die; |
53 | } | 53 | } |
54 | 54 | ||
55 | static public function newPage(EntityManager $entityManager): void | 55 | static public function newPage(EntityManager $entityManager, array $post): void |
56 | { | 56 | { |
57 | // titre et chemin | 57 | // titre et chemin |
58 | $director = new Director($entityManager); | 58 | $director = new Director($entityManager); |
59 | $director->makeMenuAndPaths(); | 59 | $director->makeMenuAndPaths(); |
60 | //Director::$menu_data = new Menu($entityManager); | 60 | //Director::$menu_data = new Menu($entityManager); |
61 | $previous_page = Director::$menu_data->findPageById((int)$_POST["page_location"]); // (int) à cause de declare(strict_types=1); | 61 | $previous_page = Director::$menu_data->findPageById((int)$post["page_location"]); // (int) à cause de declare(strict_types=1); |
62 | $parent = $previous_page->getParent(); | 62 | $parent = $previous_page->getParent(); |
63 | 63 | ||
64 | $page = new Page( | 64 | $page = new Page( |
65 | trim(htmlspecialchars($_POST["page_name"])), | 65 | trim(htmlspecialchars($post["page_name"])), |
66 | trim(htmlspecialchars($_POST["page_name_path"])), | 66 | trim(htmlspecialchars($post["page_name_path"])), |
67 | trim(htmlspecialchars($post["page_description"])), | ||
67 | true, true, false, | 68 | true, true, false, |
68 | $previous_page->getPosition(), | 69 | $previous_page->getPosition(), |
69 | $parent); // peut et DOIT être null si on est au 1er niveau | 70 | $parent); // peut et DOIT être null si on est au 1er niveau |
@@ -86,7 +87,7 @@ class PageManagementController | |||
86 | $page); | 87 | $page); |
87 | $node->useDefaultAttributes(); // fichiers CSS et JS | 88 | $node->useDefaultAttributes(); // fichiers CSS et JS |
88 | 89 | ||
89 | $data = new NodeData(['description' => trim(htmlspecialchars($_POST["page_description"]))], $node); | 90 | $data = new NodeData([], $node); |
90 | 91 | ||
91 | $bulk_data = $entityManager | 92 | $bulk_data = $entityManager |
92 | ->createQuery('SELECT n FROM App\Entity\Image n WHERE n.file_name LIKE :name') | 93 | ->createQuery('SELECT n FROM App\Entity\Image n WHERE n.file_name LIKE :name') |
diff --git a/src/installation.php b/src/installation.php index 452df60..dd0ca77 100644 --- a/src/installation.php +++ b/src/installation.php | |||
@@ -90,13 +90,13 @@ HTACCESS; | |||
90 | function makeStartPage(EntityManager $entityManager){ | 90 | function makeStartPage(EntityManager $entityManager){ |
91 | /* -- table page -- */ | 91 | /* -- table page -- */ |
92 | // paramètres: name_page, end_of_path, reachable, in_menu, hidden, position, parent | 92 | // paramètres: name_page, end_of_path, reachable, in_menu, hidden, position, parent |
93 | $accueil = new Page('Accueil', 'accueil', true, true, false, 1, NULL); | 93 | $accueil = new Page('Accueil', 'accueil', "Page d'accueil", true, true, false, 1, NULL); |
94 | $article = new Page('Article', 'article', true, false, false, NULL, NULL); | 94 | $article = new Page('Article', 'article', "", true, false, false, NULL, NULL); |
95 | $connection = new Page('Connexion', 'connection', true, false, false, NULL, NULL); | 95 | $connection = new Page('Connexion', 'connection', "Connexion", true, false, false, NULL, NULL); |
96 | $my_account = new Page('Mon compte', 'user_edit', true, false, false, NULL, NULL); | 96 | $my_account = new Page('Mon compte', 'user_edit', "Mon compte", true, false, false, NULL, NULL); |
97 | $menu_paths = new Page("Menu et chemins", 'menu_chemins', true, false, false, NULL, NULL); | 97 | $menu_paths = new Page("Menu et chemins", 'menu_chemins', "Menu et chemins", true, false, false, NULL, NULL); |
98 | //$edit_page = new Page("Modification d'une page", 'modif_page', true, false, false, NULL, NULL); // pas de page "Modification de la page" | 98 | //$edit_page = new Page("Modification d'une page", 'modif_page', '', true, false, false, NULL, NULL); // hypothétique page "Modification de la page" |
99 | $new_page = new Page('Nouvelle page', 'nouvelle_page', true, false, false, NULL, NULL); | 99 | $new_page = new Page('Nouvelle page', 'nouvelle_page', "Nouvelle page", true, false, false, NULL, NULL); |
100 | 100 | ||
101 | /* -- table node -- */ | 101 | /* -- table node -- */ |
102 | // paramètres: name_node, article_timestamp, attributes, position, parent, page, article | 102 | // paramètres: name_node, article_timestamp, attributes, position, parent, page, article |
@@ -126,15 +126,15 @@ function makeStartPage(EntityManager $entityManager){ | |||
126 | 126 | ||
127 | /* -- table node_data -- */ | 127 | /* -- table node_data -- */ |
128 | // paramètres: data, node, images | 128 | // paramètres: data, node, images |
129 | $head_accueil_data = new NodeData(["description" => "Page d'accueil"], $head_accueil, new ArrayCollection([$favicon])); | 129 | $head_accueil_data = new NodeData([], $head_accueil, new ArrayCollection([$favicon])); |
130 | $head_login_data = new NodeData(["description" => "Connexion"], $head_login, new ArrayCollection([$favicon])); | 130 | $head_login_data = new NodeData([], $head_login, new ArrayCollection([$favicon])); |
131 | $head_my_account_data = new NodeData(["description" => "Mon compte"], $head_my_account, new ArrayCollection([$favicon])); | 131 | $head_my_account_data = new NodeData([], $head_my_account, new ArrayCollection([$favicon])); |
132 | $head_article_data = new NodeData(["description" => ""], $head_article, new ArrayCollection([$favicon])); | 132 | $head_article_data = new NodeData([], $head_article, new ArrayCollection([$favicon])); |
133 | $head_edit_menu_data = new NodeData(["description" => "Menu et chemins"], $head_edit_menu, new ArrayCollection([$favicon])); | 133 | $head_edit_menu_data = new NodeData([], $head_edit_menu, new ArrayCollection([$favicon])); |
134 | $head_new_page_data = new NodeData(["description" => "Nouvelle page"], $head_new_page, new ArrayCollection([$favicon])); | 134 | $head_new_page_data = new NodeData([], $head_new_page, new ArrayCollection([$favicon])); |
135 | $header_data = new NodeData(["title" => "Titre", "description" => "Sous-titre", "header_logo" => "assets/logo-nb-et-ffn.png", "header_background" => "assets/fond-piscine.jpg", | 135 | $header_data = new NodeData(["title" => "Titre", "description" => "Sous-titre", "header_logo" => "assets/logo-nb-et-ffn.png", "header_background" => "assets/fond-piscine.jpg", |
136 | "social" => ["facebook" => "https://www.facebook.com", "instagram" => "https://www.instagram.com", "linkedin" => "https://www.linkedin.com"]], | 136 | "social" => ["facebook" => "https://www.facebook.com", "instagram" => "https://www.instagram.com", "linkedin" => "https://www.linkedin.com"]], |
137 | $header, new ArrayCollection([$facebook, $instagram, $linkedin, $github])); | 137 | $header, new ArrayCollection([$facebook, $instagram, $linkedin, $github])); |
138 | $footer_data = new NodeData(["contact_nom" => "Nom", "adresse" => "adresse", "e_mail" => "e-mail", "footer_logo" => "assets/logo-nb-et-ffn.png"], $footer); | 138 | $footer_data = new NodeData(["contact_nom" => "Nom", "adresse" => "adresse", "e_mail" => "e-mail", "footer_logo" => "assets/logo-nb-et-ffn.png"], $footer); |
139 | 139 | ||
140 | /* -- table page -- */ | 140 | /* -- table page -- */ |
@@ -143,7 +143,7 @@ function makeStartPage(EntityManager $entityManager){ | |||
143 | $entityManager->persist($connection); | 143 | $entityManager->persist($connection); |
144 | $entityManager->persist($my_account); | 144 | $entityManager->persist($my_account); |
145 | $entityManager->persist($menu_paths); | 145 | $entityManager->persist($menu_paths); |
146 | //$entityManager->persist($edit_page); // pas de page "Modification de la page" | 146 | //$entityManager->persist($edit_page); // hypothétique page "Modification de la page" |
147 | $entityManager->persist($new_page); | 147 | $entityManager->persist($new_page); |
148 | 148 | ||
149 | /* -- table node -- */ | 149 | /* -- table node -- */ |
diff --git a/src/model/entities/Page.php b/src/model/entities/Page.php index bcf49db..5b54ae6 100644 --- a/src/model/entities/Page.php +++ b/src/model/entities/Page.php | |||
@@ -28,6 +28,9 @@ class Page | |||
28 | 28 | ||
29 | private string $page_path = ''; | 29 | private string $page_path = ''; |
30 | 30 | ||
31 | #[ORM\Column(type: "text")] | ||
32 | private string $description; | ||
33 | |||
31 | #[ORM\Column(type: "boolean")] | 34 | #[ORM\Column(type: "boolean")] |
32 | private bool $reachable; | 35 | private bool $reachable; |
33 | 36 | ||
@@ -50,10 +53,11 @@ class Page | |||
50 | /*#[ORM\Column(type: "json", nullable: true)] | 53 | /*#[ORM\Column(type: "json", nullable: true)] |
51 | private ?array $metadata = null;*/ | 54 | private ?array $metadata = null;*/ |
52 | 55 | ||
53 | public function __construct(string $name, string $eop, bool $reachable, bool $in_menu, bool $hidden, ?int $position, ?Page $parent) | 56 | public function __construct(string $name, string $eop, string $description, bool $reachable, bool $in_menu, bool $hidden, ?int $position, ?Page $parent) |
54 | { | 57 | { |
55 | $this->name_page = $name; | 58 | $this->name_page = $name; |
56 | $this->end_of_path = $eop; | 59 | $this->end_of_path = $eop; |
60 | $this->description = $description; | ||
57 | $this->reachable = $reachable; | 61 | $this->reachable = $reachable; |
58 | $this->in_menu = $in_menu; | 62 | $this->in_menu = $in_menu; |
59 | $this->hidden = $hidden; | 63 | $this->hidden = $hidden; |
@@ -91,6 +95,14 @@ class Page | |||
91 | { | 95 | { |
92 | $this->end_of_path = $end_of_path; | 96 | $this->end_of_path = $end_of_path; |
93 | } | 97 | } |
98 | public function getDescription(): string | ||
99 | { | ||
100 | return $this->description; | ||
101 | } | ||
102 | public function setDescription(string $description): void | ||
103 | { | ||
104 | $this->description = $description; | ||
105 | } | ||
94 | public function isReachable(): bool | 106 | public function isReachable(): bool |
95 | { | 107 | { |
96 | return $this->reachable; | 108 | return $this->reachable; |
diff --git a/src/router.php b/src/router.php index 8d19e49..c11a4e0 100644 --- a/src/router.php +++ b/src/router.php | |||
@@ -232,7 +232,7 @@ elseif($request->getMethod() === 'POST'){ | |||
232 | && isset($_POST['page_description']) && $_POST['page_description'] !== null | 232 | && isset($_POST['page_description']) && $_POST['page_description'] !== null |
233 | && isset($_POST['new_page_hidden']) && $_POST['new_page_hidden'] === '') | 233 | && isset($_POST['new_page_hidden']) && $_POST['new_page_hidden'] === '') |
234 | { | 234 | { |
235 | PageManagementController::newPage($entityManager); | 235 | PageManagementController::newPage($entityManager, $_POST); |
236 | } | 236 | } |
237 | 237 | ||
238 | /* -- suppression d'une page -- */ | 238 | /* -- suppression d'une page -- */ |
diff --git a/src/view/HeadBuilder.php b/src/view/HeadBuilder.php index 06a1301..b2f3386 100644 --- a/src/view/HeadBuilder.php +++ b/src/view/HeadBuilder.php | |||
@@ -47,14 +47,8 @@ class HeadBuilder extends AbstractBuilder | |||
47 | $js .= '<script src="' . self::versionedFileURL('js', 'tinymce') . '"></script>' . "\n"; | 47 | $js .= '<script src="' . self::versionedFileURL('js', 'tinymce') . '"></script>' . "\n"; |
48 | } | 48 | } |
49 | 49 | ||
50 | // titre | ||
51 | $title = Director::$page_path->getLast()->getPageName(); | 50 | $title = Director::$page_path->getLast()->getPageName(); |
52 | 51 | $description = Director::$page_path->getLast()->getDescription(); | |
53 | // description | ||
54 | if(!empty($node->getNodeData()->getData())) | ||
55 | { | ||
56 | extract($node->getNodeData()->getData()); | ||
57 | } | ||
58 | 52 | ||
59 | // favicon | 53 | // favicon |
60 | foreach($node->getNodeData()->getImages() as $image) | 54 | foreach($node->getNodeData()->getImages() as $image) |
diff --git a/src/view/MainBuilder.php b/src/view/MainBuilder.php index a04130a..d677971 100644 --- a/src/view/MainBuilder.php +++ b/src/view/MainBuilder.php | |||
@@ -59,14 +59,6 @@ class MainBuilder extends AbstractBuilder | |||
59 | foreach(Blocks::$blocks as $key => $value){ | 59 | foreach(Blocks::$blocks as $key => $value){ |
60 | $options .= '<option value= "' . $key . '">' . $value . "</option>\n"; | 60 | $options .= '<option value= "' . $key . '">' . $value . "</option>\n"; |
61 | } | 61 | } |
62 | |||
63 | $head_node = null; | ||
64 | foreach(ViewController::$root_node->getChildren() as $first_level_node){ | ||
65 | if($first_level_node->getName() === 'head'){ | ||
66 | $head_node = $first_level_node; // normalement c'est le 1er enfant | ||
67 | break; | ||
68 | } | ||
69 | } | ||
70 | 62 | ||
71 | // ceci pourrait être déplacé au début des blocs | 63 | // ceci pourrait être déplacé au début des blocs |
72 | $bloc_edit = ''; | 64 | $bloc_edit = ''; |
diff --git a/src/view/templates/modify_page.php b/src/view/templates/modify_page.php index b799df2..c9da4a4 100644 --- a/src/view/templates/modify_page.php +++ b/src/view/templates/modify_page.php | |||
@@ -18,8 +18,8 @@ | |||
18 | <div id="edit_description"> | 18 | <div id="edit_description"> |
19 | <label for="description_textarea">Description sous le titre dans les moteurs de recherche</label> | 19 | <label for="description_textarea">Description sous le titre dans les moteurs de recherche</label> |
20 | <div> | 20 | <div> |
21 | <textarea id="description_textarea" name="edit_description" cols="40" rows="3" placeholder="ex: nous faisons ceci et cela, etc" required><?= $head_node->getNodeData()->getData()['description'] ?></textarea> | 21 | <textarea id="description_textarea" name="edit_description" cols="40" rows="3" placeholder="ex: nous faisons ceci et cela, etc" required><?= Director::$page_path->getLast()->getDescription(); ?></textarea> |
22 | <button onclick="changeDescription('<?= $head_node->getNodeData()->getId() ?>')">Modifier</button> | 22 | <button onclick="changeDescription('<?= Director::$page_path->getLast()->getId() ?>')">Modifier</button> |
23 | </div> | 23 | </div> |
24 | </div> | 24 | </div> |
25 | </div> | 25 | </div> |