diff options
Diffstat (limited to 'src/view/MainBuilder.php')
-rw-r--r-- | src/view/MainBuilder.php | 63 |
1 files changed, 51 insertions, 12 deletions
diff --git a/src/view/MainBuilder.php b/src/view/MainBuilder.php index d7a0dfa..fc80cd1 100644 --- a/src/view/MainBuilder.php +++ b/src/view/MainBuilder.php | |||
@@ -5,10 +5,11 @@ declare(strict_types=1); | |||
5 | 5 | ||
6 | use App\Entity\Article; | 6 | use App\Entity\Article; |
7 | use App\Entity\Node; | 7 | use App\Entity\Node; |
8 | use App\Entity\Presentation; | ||
8 | 9 | ||
9 | class MainBuilder extends AbstractBuilder | 10 | class MainBuilder extends AbstractBuilder |
10 | { | 11 | { |
11 | static bool $modif_mode = false; | 12 | static public bool $modif_mode = false; |
12 | 13 | ||
13 | public function __construct(Node $node) | 14 | public function __construct(Node $node) |
14 | { | 15 | { |
@@ -52,7 +53,8 @@ class MainBuilder extends AbstractBuilder | |||
52 | // mode modification de page uniquement | 53 | // mode modification de page uniquement |
53 | private function viewEditBlocks($node): void | 54 | private function viewEditBlocks($node): void |
54 | { | 55 | { |
55 | $viewFile = self::VIEWS_PATH . $node->getName() . '.php'; // mode modification uniquement | 56 | //$viewFile = self::VIEWS_PATH . $node->getName() . '.php'; // mode modification uniquement |
57 | $viewFile = self::VIEWS_PATH . 'modify_page.php'; // mode modification uniquement | ||
56 | $blocks = Blocks::getTypeNamePairs(); | 58 | $blocks = Blocks::getTypeNamePairs(); |
57 | 59 | ||
58 | $options = ''; | 60 | $options = ''; |
@@ -71,25 +73,62 @@ class MainBuilder extends AbstractBuilder | |||
71 | 73 | ||
72 | $bloc_edit = ''; | 74 | $bloc_edit = ''; |
73 | foreach($node->getChildren() as $child_node){ | 75 | foreach($node->getChildren() as $child_node){ |
76 | // mettre tout ça dans une vue modify_block.php | ||
77 | // => pourrait être déplacé au niveau des articles | ||
78 | |||
74 | // renommage d'un bloc | 79 | // renommage d'un bloc |
75 | $bloc_edit .= '<div id="bloc_edit_' . $child_node->getId() . '"> | 80 | $bloc_edit .= '<div class="modify_one_block" id="bloc_edit_' . $child_node->getId() . '"> |
76 | <p><label for="bloc_rename_' . $child_node->getId() . '"><b>' . Blocks::getNameFromType($child_node->getName()) . '</b></label> | 81 | <div class="block_options"> |
77 | <input type="text" id="bloc_rename_' . $child_node->getId() . '" name="bloc_rename_title" value="' . $child_node->getNodeData()->getdata()['title'] . '" required> | 82 | <label for="bloc_rename_' . $child_node->getId() . '">Type <b>' . Blocks::getNameFromType($child_node->getName()) . '</b></label> |
78 | <button onclick="renamePageBloc(' . $child_node->getId() . ')">Renommer</button>'. "\n"; | 83 | <p> |
84 | <input type="text" id="bloc_rename_' . $child_node->getId() . '" name="bloc_rename_title" value="' . $child_node->getNodeData()->getdata()['title'] . '" required> | ||
85 | <button onclick="renamePageBloc(' . $child_node->getId() . ')">Renommer</button> | ||
86 | </p>'. "\n"; | ||
79 | // déplacement d'un bloc | 87 | // déplacement d'un bloc |
80 | $bloc_edit .= '<img class="action_icon" onclick="switchBlocsPositions(' . $child_node->getId() . ', \'up\', \'' . CURRENT_PAGE . '\')" src="assets/arrow-up.svg"> | 88 | $bloc_edit .= '<div style="display: flex; flex-wrap: wrap;"> |
81 | <img class="action_icon" onclick="switchBlocsPositions(' . $child_node->getId() . ', \'down\', \'' . CURRENT_PAGE . '\')" src="assets/arrow-down.svg">' . "\n"; | 89 | <p> |
90 | <img class="action_icon" onclick="switchBlocsPositions(' . $child_node->getId() . ', \'up\', \'' . CURRENT_PAGE . '\')" src="assets/arrow-up.svg"> | ||
91 | <img class="action_icon" onclick="switchBlocsPositions(' . $child_node->getId() . ', \'down\', \'' . CURRENT_PAGE . '\')" src="assets/arrow-down.svg"> | ||
92 | </p>' . "\n"; | ||
82 | // suppression d'un bloc | 93 | // suppression d'un bloc |
83 | $bloc_edit .= '<form method="post" action="' . new URL(['page' => CURRENT_PAGE]) . '"> | 94 | $bloc_edit .= '<form method="post" action="' . new URL(['page' => CURRENT_PAGE]) . '"> |
84 | <input type="hidden" name="delete_bloc_id" value="' . $child_node->getId() . '"> | 95 | <input type="hidden" name="delete_bloc_id" value="' . $child_node->getId() . '"> |
85 | <input type="hidden" name="delete_bloc_hidden"> | 96 | <input type="hidden" name="delete_bloc_hidden"> |
86 | <input type="submit" value="Supprimer" onclick="return confirm(\'Voulez-vous vraiment supprimer ce bloc?\');"></p> | 97 | <input type="submit" value="Supprimer" onclick="return confirm(\'Voulez-vous vraiment supprimer ce bloc?\');"> |
87 | </form> | 98 | </form> |
99 | </div> | ||
88 | </div>'. "\n"; | 100 | </div>'. "\n"; |
101 | if($child_node->getNodeData()->getPresentation() !== null){ | ||
102 | // select mode de présentation | ||
103 | $bloc_edit .= '<div class="grid_options"><p> | ||
104 | <label for="presentation_select_' . $child_node->getId() . '">Présentation</label> | ||
105 | <select id="presentation_select_' . $child_node->getId() . '" onchange="changePresentation(' . $child_node->getId() . ')">'; | ||
106 | $bloc_edit .= $this->makePresentationOptions($child_node->getNodeData()->getPresentation()->getName()); | ||
107 | $bloc_edit .= '</select>'; | ||
108 | // select largeur minimale colonnes mode grid | ||
109 | $bloc_edit .= '<div id="cols_min_width_edit_' . $child_node->getId() . '" class="' . ($child_node->getNodeData()->getPresentation()->getName() === 'grid' ? '' : 'hidden') . '"> | ||
110 | <label for="cols_min_width_select_' . $child_node->getId() . '">Largeur minimum </label>'; | ||
111 | $bloc_edit .= '<input type="number" id="cols_min_width_select_' . $child_node->getId() . '" onchange="changeColsMinWidth(' . $child_node->getId() . ')" min="150" max="400" value="' . $child_node->getNodeData()->getColsMinWidth() . '">'; | ||
112 | /*$bloc_edit .= '<select id="cols_min_width_select_' . $child_node->getId() . '" onchange="changeColsMinWidth(' . $child_node->getId() . ')">' | ||
113 | . $this->makeColsMinWidthOptions($child_node->getNodeData()->getColsMinWidth()) | ||
114 | . '</select>';*/ | ||
115 | $bloc_edit .= ' pixels</div> | ||
116 | </div>'; | ||
117 | } | ||
118 | $bloc_edit .= "</div>\n"; | ||
89 | } | 119 | } |
90 | 120 | ||
91 | ob_start(); | 121 | ob_start(); |
92 | require $viewFile; | 122 | require $viewFile; |
93 | $this->html .= ob_get_clean(); | 123 | $this->html .= ob_get_clean(); |
94 | } | 124 | } |
125 | |||
126 | private function makePresentationOptions(string $presentation): string | ||
127 | { | ||
128 | $options = ''; | ||
129 | foreach(Presentation::$option_list as $key => $value){ | ||
130 | $options .= '<option value="' . $key . '" ' . ($presentation === $key ? 'selected' : '') . '>' . $value . '</option>'; | ||
131 | } | ||
132 | return $options; | ||
133 | } | ||
95 | } \ No newline at end of file | 134 | } \ No newline at end of file |