diff options
author | polo <ordipolo@gmx.fr> | 2025-05-10 20:16:56 +0200 |
---|---|---|
committer | polo <ordipolo@gmx.fr> | 2025-05-10 20:16:56 +0200 |
commit | aa8898ae00beaa0ac7e65e45c5f28199b25a9267 (patch) | |
tree | 19cde1aa42478bc594f4a2ea71b8cecdcdcdda85 /src | |
parent | d2bdfa7d0f746f060090a9e8c8ad6e376b5a1480 (diff) | |
download | cms-aa8898ae00beaa0ac7e65e45c5f28199b25a9267.zip |
modification de page en mode modif page, déplacement modif_page js et css et MAJ BDD, vue page nouvelle page
Diffstat (limited to 'src')
-rw-r--r-- | src/view/NewPageBuilder.php | 49 | ||||
-rw-r--r-- | src/view/templates/main.php | 45 | ||||
-rw-r--r-- | src/view/templates/new_page.php | 27 |
3 files changed, 121 insertions, 0 deletions
diff --git a/src/view/NewPageBuilder.php b/src/view/NewPageBuilder.php new file mode 100644 index 0000000..2fae6fa --- /dev/null +++ b/src/view/NewPageBuilder.php | |||
@@ -0,0 +1,49 @@ | |||
1 | <?php | ||
2 | // src/view/NewPageBuilder.php | ||
3 | // | ||
4 | // page Nouvelle page en mode admin, fonctionne avec new_page.js | ||
5 | |||
6 | declare(strict_types=1); | ||
7 | |||
8 | use App\Entity\Node; | ||
9 | use App\Entity\Page; | ||
10 | |||
11 | class NewPageBuilder extends AbstractBuilder | ||
12 | { | ||
13 | //private int $margin_left_multiplier = 29; | ||
14 | private string $options = ''; | ||
15 | |||
16 | public function __construct(Node $node = null) | ||
17 | { | ||
18 | //parent::__construct($node); | ||
19 | $viewFile = self::VIEWS_PATH . $node->getName() . '.php'; | ||
20 | |||
21 | if(isset($_SESSION['admin']) && $_SESSION['admin'] && file_exists($viewFile)) | ||
22 | { | ||
23 | /*if(!empty($node->getNodeData()->getData())) | ||
24 | { | ||
25 | extract($node->getNodeData()->getData()); | ||
26 | }*/ | ||
27 | |||
28 | $this->unfoldOptions(Director::$menu_data); | ||
29 | |||
30 | ob_start(); | ||
31 | require $viewFile; // insertion de $this->html généré par unfoldMenu | ||
32 | $this->html = ob_get_clean(); // pas de concaténation .= cette fois on écrase | ||
33 | } | ||
34 | else{ | ||
35 | header('Location: ' . new URL); | ||
36 | die; | ||
37 | } | ||
38 | } | ||
39 | |||
40 | private function unfoldOptions(Page $page): void | ||
41 | { | ||
42 | foreach($page->getChildren() as $entry){ | ||
43 | $this->options .= '<option value="' . $entry->getId() . '">' . $entry->getPageName() . "</option>\n"; | ||
44 | if(count($entry->getChildren()) > 0){ | ||
45 | $this->unfoldOptions($entry); | ||
46 | } | ||
47 | } | ||
48 | } | ||
49 | } \ No newline at end of file | ||
diff --git a/src/view/templates/main.php b/src/view/templates/main.php new file mode 100644 index 0000000..7ff03a8 --- /dev/null +++ b/src/view/templates/main.php | |||
@@ -0,0 +1,45 @@ | |||
1 | <?php declare(strict_types=1); ?> | ||
2 | <section class="page_modification"> | ||
3 | <h3>Modification de la page</h3> | ||
4 | <div class="edit_page_zone"> | ||
5 | <div class="edit_page_title_zone"> | ||
6 | <p id="edit_page_title"> | ||
7 | <label for="page_name">Titre de la page</label> | ||
8 | <input type="text" id="page_name" name="edit_page_title" value="<?= Director::$page_path->getLast()->getPageName() ?>" onchange="makePageNamePath()" required> | ||
9 | <button onclick="changePageTitle('<?= Director::$page_path->getLast()->getId() ?>')">Renommer</button> | ||
10 | </p> | ||
11 | <form id="edit_page_menu_path" method="post" action="<?= new URL(['page' => CURRENT_PAGE]) ?>"> | ||
12 | <label for="page_name_path">Chemin en "snake_case"</label> | ||
13 | <input type="text" id="page_name_path" name="page_menu_path" value="<?= Director::$page_path->getLast()->getEndOfPath() ?>" placeholder="ex: nouvelle_page" required> | ||
14 | <input type="hidden" name="page_id" value="<?= Director::$page_path->getLast()->getId() ?>"><input type="hidden" name="page_name_path_hidden"> | ||
15 | <input type="submit" value="Modifier"> | ||
16 | </form> | ||
17 | </div> | ||
18 | <div id="edit_description"> | ||
19 | <label for="description_textarea">Description sous le titre dans les moteurs de recherche</label> | ||
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> | ||
22 | <button onclick="changeDescription('<?= $head_node->getNodeData()->getId() ?>')">Modifier</button> | ||
23 | </div> | ||
24 | </div> | ||
25 | </div> | ||
26 | <div class="edit_bloc_zone"> | ||
27 | <div class="new_bloc"> | ||
28 | <p>Ajouter un bloc de page</p> | ||
29 | <form method="post" action="<?= new URL(['page' => CURRENT_PAGE]) ?>"> | ||
30 | <p><label for="bloc_title">Titre</label> | ||
31 | <input type="text" id="bloc_title" name="bloc_title" required></p> | ||
32 | <p><label for="bloc_select">Type</label> | ||
33 | <select id="bloc_select" name="bloc_select" required> | ||
34 | <?= $options ?> | ||
35 | </select> | ||
36 | <input type="hidden" name="bloc_title_hidden"> | ||
37 | <input type="submit" value="Valider"></p> | ||
38 | </form> | ||
39 | </div> | ||
40 | <div class="modify_bloc"> | ||
41 | <p>Modifier un bloc</p> | ||
42 | <?= $bloc_edit ?> | ||
43 | </div> | ||
44 | </div> | ||
45 | </section> \ No newline at end of file | ||
diff --git a/src/view/templates/new_page.php b/src/view/templates/new_page.php new file mode 100644 index 0000000..db48496 --- /dev/null +++ b/src/view/templates/new_page.php | |||
@@ -0,0 +1,27 @@ | |||
1 | <?php declare(strict_types=1); ?> | ||
2 | <section class="new_page"> | ||
3 | <h3>Création d'une nouvelle page</h3> | ||
4 | <div class="form_zone"> | ||
5 | <form method="post" action="<?= new URL(['from' => 'nouvelle_page']) ?>"> | ||
6 | <p> | ||
7 | <label for="new_page_name">Nom de la page</label> | ||
8 | <input id="page_name" type="text" name="new_page_name" onchange="makePageNamePath()" required> | ||
9 | </p> | ||
10 | <p> | ||
11 | <label for="new_page_name_path">Chemin de l'URL</label> | ||
12 | <input id="page_name_path" type="text" name="new_page_name_path" placeholder="ex: nouvelle_page" required> | ||
13 | </p> | ||
14 | <p> | ||
15 | <label for="page_location">Placer la page juste après cette entrée</label> | ||
16 | <select id="page_location" name="page_location"> | ||
17 | <?= $this->options ?> | ||
18 | </select> | ||
19 | </p> | ||
20 | <p> | ||
21 | <label class="label_textarea" for="new_page_description">Description qui apparaît sous le titre dans les moteurs de recherche</label> | ||
22 | <textarea id="new_page_description" name="new_page_description" cols="40" rows="3" placeholder="ex: nous faisons ceci et cela, etc" required></textarea> | ||
23 | </p> | ||
24 | <input type="submit" value="Créer la page"> | ||
25 | </form> | ||
26 | </div> | ||
27 | </section> \ No newline at end of file | ||