aboutsummaryrefslogtreecommitdiff
path: root/src/view/MainBuilder.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/view/MainBuilder.php')
-rw-r--r--src/view/MainBuilder.php34
1 files changed, 5 insertions, 29 deletions
diff --git a/src/view/MainBuilder.php b/src/view/MainBuilder.php
index 889df37..d7a0dfa 100644
--- a/src/view/MainBuilder.php
+++ b/src/view/MainBuilder.php
@@ -36,13 +36,13 @@ class MainBuilder extends AbstractBuilder
36 $this->html .= $builder->render(); 36 $this->html .= $builder->render();
37 } 37 }
38 else{ 38 else{
39 // si action = "modif_page", affiche des commandes pour modifier 39 // si action = "modif_page", affiche des commandes supplémentaires
40 if($_SESSION['admin'] && self::$modif_mode){ 40 if($_SESSION['admin'] && self::$modif_mode){
41 // ajouter un contrôle du champ in_menu 41 // ajouter un contrôle du champ in_menu
42 $this->viewEditBlocks($node); 42 $this->viewEditBlocks($node);
43 } 43 }
44 44
45 // cas normal 45 // dans tous les cas
46 $this->useChildrenBuilder($node); 46 $this->useChildrenBuilder($node);
47 } 47 }
48 48
@@ -53,42 +53,18 @@ class MainBuilder extends AbstractBuilder
53 private function viewEditBlocks($node): void 53 private function viewEditBlocks($node): void
54 { 54 {
55 $viewFile = self::VIEWS_PATH . $node->getName() . '.php'; // mode modification uniquement 55 $viewFile = self::VIEWS_PATH . $node->getName() . '.php'; // mode modification uniquement
56 56 $blocks = Blocks::getTypeNamePairs();
57 // blocs disponibles, même liste dans post.php
58 $blocks = [ // créer une classe pour ça?
59 ['type' => 'blog', 'name' => 'Blog'],
60 ['type' => 'grid', 'name' => 'Grille'],
61 ['type' => 'calendar', 'name' => 'Calendrier'],
62 ['type' => 'galery', 'name' => 'Galerie'],
63 ['type' => 'form', 'name' => 'Formulaire']];
64
65 function getBlockName(array $blocks, string $type){ // créer une classe pour ça?
66 for($i=0; $i < count($blocks); $i++){
67 if($blocks[$i]['type'] === $type){
68 return $blocks[$i]['name'];
69 }
70 }
71 }
72 57
73 $options = ''; 58 $options = '';
74 for($i = 0; $i < count($blocks); $i++){ 59 for($i = 0; $i < count($blocks); $i++){
75 $options .= '<option value= "' . $blocks[$i]['type'] . '">' . $blocks[$i]['name'] . "</option>\n"; 60 $options .= '<option value= "' . $blocks[$i]['type'] . '">' . $blocks[$i]['name'] . "</option>\n";
76 } 61 }
77 62
78 // blabla
79 /*$this->html .= '<aside class="modif_page_explanations">
80 <p>Modification de la structure d\'une page:</p>
81 <div>
82 <p><img></p>
83 <p><img></p>
84 </div>
85 </aside>' . "\n";*/
86
87 //$page_id = Director::$page_path->getLast()->getId(); 63 //$page_id = Director::$page_path->getLast()->getId();
88 $head_node = null; 64 $head_node = null;
89 foreach(ViewController::$root_node->getChildren() as $first_level_node){ 65 foreach(ViewController::$root_node->getChildren() as $first_level_node){
90 if($first_level_node->getName() === 'head'){ 66 if($first_level_node->getName() === 'head'){
91 $head_node = $first_level_node; // normallement c'est le 1er enfant 67 $head_node = $first_level_node; // normalement c'est le 1er enfant
92 break; 68 break;
93 } 69 }
94 } 70 }
@@ -97,7 +73,7 @@ class MainBuilder extends AbstractBuilder
97 foreach($node->getChildren() as $child_node){ 73 foreach($node->getChildren() as $child_node){
98 // renommage d'un bloc 74 // renommage d'un bloc
99 $bloc_edit .= '<div id="bloc_edit_' . $child_node->getId() . '"> 75 $bloc_edit .= '<div id="bloc_edit_' . $child_node->getId() . '">
100 <p><label for="bloc_rename_' . $child_node->getId() . '"><b>' . getBlockName($blocks, $child_node->getName()) . '</b></label> 76 <p><label for="bloc_rename_' . $child_node->getId() . '"><b>' . Blocks::getNameFromType($child_node->getName()) . '</b></label>
101 <input type="text" id="bloc_rename_' . $child_node->getId() . '" name="bloc_rename_title" value="' . $child_node->getNodeData()->getdata()['title'] . '" required> 77 <input type="text" id="bloc_rename_' . $child_node->getId() . '" name="bloc_rename_title" value="' . $child_node->getNodeData()->getdata()['title'] . '" required>
102 <button onclick="renamePageBloc(' . $child_node->getId() . ')">Renommer</button>'. "\n"; 78 <button onclick="renamePageBloc(' . $child_node->getId() . ')">Renommer</button>'. "\n";
103 // déplacement d'un bloc 79 // déplacement d'un bloc