diff options
Diffstat (limited to 'src/view/MainBuilder.php')
-rw-r--r-- | src/view/MainBuilder.php | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/view/MainBuilder.php b/src/view/MainBuilder.php index e73b298..fbdfbdd 100644 --- a/src/view/MainBuilder.php +++ b/src/view/MainBuilder.php | |||
@@ -1,15 +1,20 @@ | |||
1 | <?php | 1 | <?php |
2 | // src/view/MainBuilder.php | 2 | // src/view/MainBuilder.php |
3 | 3 | ||
4 | declare(strict_types=1); | ||
5 | |||
4 | use App\Entity\Article; | 6 | use App\Entity\Article; |
5 | use App\Entity\Node; | 7 | use App\Entity\Node; |
6 | 8 | ||
7 | class MainBuilder extends AbstractBuilder | 9 | class MainBuilder extends AbstractBuilder |
8 | { | 10 | { |
11 | static bool $modif_mode = false; | ||
12 | |||
9 | public function __construct(Node $node) | 13 | public function __construct(Node $node) |
10 | { | 14 | { |
11 | $this->html .= "<main>\n"; | 15 | $this->html .= "<main>\n"; |
12 | 16 | ||
17 | // cas particulier de la page article où l'article est greffé sur main | ||
13 | if(Director::$page_path->getLast()->getEndOfPath() === 'article'){ | 18 | if(Director::$page_path->getLast()->getEndOfPath() === 'article'){ |
14 | // pas censé arriver | 19 | // pas censé arriver |
15 | if(!isset($_GET['id'])){ | 20 | if(!isset($_GET['id'])){ |
@@ -31,9 +36,53 @@ class MainBuilder extends AbstractBuilder | |||
31 | $this->html .= $builder->render(); | 36 | $this->html .= $builder->render(); |
32 | } | 37 | } |
33 | else{ | 38 | else{ |
39 | // si action = "modif_page", affiche des commandes pour modifier | ||
40 | if($_SESSION['admin'] && self::$modif_mode){ | ||
41 | // ajouter un contrôle du champ in_menu | ||
42 | $this->viewEditBlocks($node); | ||
43 | } | ||
44 | |||
34 | $this->useChildrenBuilder($node); | 45 | $this->useChildrenBuilder($node); |
35 | } | 46 | } |
36 | 47 | ||
37 | $this->html .= "</main>\n"; | 48 | $this->html .= "</main>\n"; |
38 | } | 49 | } |
50 | |||
51 | private function viewEditBlocks($node): void | ||
52 | { | ||
53 | // blocs disponibles | ||
54 | $blocs = ['Blog', 'Grille', 'Calendrier', 'Galerie']; // générer ça dynamiquement! | ||
55 | $blocs_true_names = ['blog', 'grid', 'calendar', 'galery']; | ||
56 | |||
57 | $options = ''; | ||
58 | for($i = 0; $i < count($blocs); $i++){ | ||
59 | $options .= '<option value= "' . $blocs_true_names[$i] . '">' . $blocs[$i] . "</option>\n"; | ||
60 | } | ||
61 | |||
62 | // blabla | ||
63 | /*$this->html .= '<aside class="modif_page_explanations"> | ||
64 | <p>Modification de la structure d\'une page:</p> | ||
65 | <div> | ||
66 | <p><img></p> | ||
67 | <p><img></p> | ||
68 | </div> | ||
69 | </aside>' . "\n";*/ | ||
70 | |||
71 | // ajout d'un nouveau bloc | ||
72 | $this->html .= '<div class="new_bloc"> | ||
73 | <p>Ajouter un bloc dans la page:</p> | ||
74 | <form method="post" action="' . new URL(['page' => CURRENT_PAGE]) . '"> | ||
75 | <p><label for="bloc_title">Titre</label> | ||
76 | <input type="text" id="bloc_title" name="bloc_title" required></p> | ||
77 | <p><label for="bloc_select">Type</label> | ||
78 | <select id="bloc_select" name="bloc_select" required>' | ||
79 | . $options . | ||
80 | '</select> | ||
81 | <input type="submit" value="Valider"></p> | ||
82 | </form> | ||
83 | </div>' . "\n"; | ||
84 | foreach($node->getChildren() as $child_node){ | ||
85 | //$this->html .= | ||
86 | } | ||
87 | } | ||
39 | } | 88 | } |