From 43c962f442165327d73756c62501ff823d43f9f3 Mon Sep 17 00:00:00 2001 From: polo Date: Mon, 31 Mar 2025 18:43:53 +0200 Subject: positions dans table page, fil d'ariane en haut, logo dans footer --- src/controller/Director.php | 2 +- src/controller/installation.php | 18 +++++++++--------- src/model/entities/Page.php | 31 ++++++++++++++++++++++++++++++- src/view/HeaderBuilder.php | 12 ++++++++---- src/view/templates/footer.php | 5 +++-- src/view/templates/header.php | 13 ++++++++----- 6 files changed, 59 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/controller/Director.php b/src/controller/Director.php index 896cde1..5ff8f47 100644 --- a/src/controller/Director.php +++ b/src/controller/Director.php @@ -62,7 +62,7 @@ class Director return true; } - public function feedObjects(array $bulk_data): void // $bulk_data = tableau de Node + private function feedObjects(array $bulk_data): void // $bulk_data = tableau de Node { // puis on les range // (attention, risque de disfonctionnement si les noeuds de 1er niveau ne sont pas récupérés en 1er dans la BDD) diff --git a/src/controller/installation.php b/src/controller/installation.php index a692618..c2b38fd 100644 --- a/src/controller/installation.php +++ b/src/controller/installation.php @@ -76,13 +76,13 @@ HTACCESS; // les informations ici ne sont pas demandées à l'utilisateur pour l'instant (on verra ça plus tard) function makeStartPage(EntityManager $entityManager){ /* -- table page -- */ - // paramètres: name_page, end_of_path, reachable, in_menu, parent - $accueil = new Page('Accueil', 'accueil', true, true, NULL); - $connection = new Page('Connexion', 'connexion', true, false, NULL); - $article = new Page('Article', 'article', true, false, NULL); - $edit_page = new Page("Modification d'une page", 'modif_page', true, false, NULL); - $new_page = new Page('Nouvelle page', 'nouvelle_page', true, false, NULL); - $edit_paths = new Page("Menu et chemins", 'menu_chemins', true, false, NULL); + // paramètres: name_page, end_of_path, reachable, in_menu, position, parent + $accueil = new Page('Accueil', 'accueil', true, true, 1, NULL); + $connection = new Page('Connexion', 'connexion', true, false, NULL, NULL); + $article = new Page('Article', 'article', true, false, NULL, NULL); + $edit_page = new Page("Modification d'une page", 'modif_page', true, false, NULL, NULL); + $new_page = new Page('Nouvelle page', 'nouvelle_page', true, false, NULL, NULL); + $edit_paths = new Page("Menu et chemins", 'menu_chemins', true, false, NULL, NULL); /* -- table node -- */ // paramètres: name_node, article_timestamp, attributes, position, parent, page, article @@ -91,7 +91,7 @@ function makeStartPage(EntityManager $entityManager){ $nav = new Node('nav', NULL, [], 1, $header, NULL, NULL); $main = new Node('main', NULL, [], 3, NULL, NULL, NULL); $footer = new Node('footer', NULL, [], 4, NULL, NULL, NULL); - $breadcrumb = new Node('breadcrumb', NULL, [], 1, $footer, NULL, NULL); + $breadcrumb = new Node('breadcrumb', NULL, [], 2, $header, NULL, NULL); $head_login = new Node('head', NULL, ["stop" => true, 'css_array' => ['body', 'head', 'nav', 'main'], 'js_array' => ['main']], 1, NULL, $connection, NULL); $login = new Node('login', NULL, [], 1, $main, $connection, NULL); $head_article = new Node('head', NULL, ['css_array' => ['body', 'head', 'nav', 'main', 'foot'], 'js_array' => ['main']], 1, NULL, $article, NULL); @@ -108,7 +108,7 @@ function makeStartPage(EntityManager $entityManager){ // paramètres: data, node $head_accueil_data = new NodeData(["description" => "Club, École de natation et Perfectionnement", "title" => "Les Nageurs Bigoudens"], $head_accueil, new ArrayCollection([$favicon])); $header_data = new NodeData(["description" => "Club, École de natation et Perfectionnement", "title" => "Les Nageurs Bigoudens", "facebook_link" => "https://www.facebook.com/nageursbigoudens29120", "instagram_link" => "https://www.instagram.com/nageursbigoudens/"], $header, new ArrayCollection([$logo, $facebook, $instagram, $fond_piscine])); - $footer_data = new NodeData(["adresse" => "17, rue Raymonde Folgoas Guillou, 29120 Pont-l’Abbé", "contact_nom" => "Les Nageurs Bigoudens", "e_mail" => "nb.secretariat@orange.fr"], $footer); + $footer_data = new NodeData(["adresse" => "17, rue Raymonde Folgoas Guillou, 29120 Pont-l’Abbé", "contact_nom" => "Les Nageurs Bigoudens", "e_mail" => "nb.secretariat@orange.fr", "logo_footer" => "assets/logo-nb-et-ffn.png"], $footer); $head_login_data = new NodeData(["description" => "Connexion", "title" => "Connexion"], $head_login, new ArrayCollection([$favicon])); $head_article_data = new NodeData(["description" => "", "title" => ""], $head_article, new ArrayCollection([$favicon])); diff --git a/src/model/entities/Page.php b/src/model/entities/Page.php index d7d8098..fbf0f27 100644 --- a/src/model/entities/Page.php +++ b/src/model/entities/Page.php @@ -32,6 +32,9 @@ class Page #[ORM\Column(type: "boolean")] private bool $in_menu; + #[ORM\Column(type: "integer", nullable: true)] // null si hors menu + private ?int $position; + #[ORM\ManyToOne(targetEntity: self::class)] #[ORM\JoinColumn(name: "parent_id", referencedColumnName: "id_page", onDelete: "SET NULL", nullable: true)] private ?self $parent = null; @@ -42,12 +45,13 @@ class Page /*#[ORM\Column(type: "json", nullable: true)] private ?array $metadata = null;*/ - public function __construct(string $name, string $eop, bool $reachable, bool $in_menu, ?Page $parent) + public function __construct(string $name, string $eop, bool $reachable, bool $in_menu, ?int $position, ?Page $parent) { $this->name_page = $name; $this->end_of_path = $eop; $this->reachable = $reachable; $this->in_menu = $in_menu; + $this->position = $position; $this->parent = $parent; $this->children = new ArrayCollection(); } @@ -73,6 +77,10 @@ class Page { return $this->in_menu; } + public function getPosition(): ?int + { + return $this->position; + } public function getParent(): ?Page { return $this->parent; @@ -93,5 +101,26 @@ class Page public function addChild(self $child): void { $this->children[] = $child; + $this->sortChildren(); + } + + // utiliser $position pour afficher les éléments dans l'ordre + private function sortChildren(): void + { + $iteration = count($this->children); + while($iteration > 1) + { + for($i = 0; $i < $iteration - 1; $i++) + { + //echo '
' . $this->children[$i]->getPosition() . ' - ' . $this->children[$i + 1]->getPosition(); + if($this->children[$i]->getPosition() > $this->children[$i + 1]->getPosition()) + { + $tmp = $this->children[$i]; + $this->children[$i] = $this->children[$i + 1]; + $this->children[$i + 1] = $tmp; + } + } + $iteration--; + } } } diff --git a/src/view/HeaderBuilder.php b/src/view/HeaderBuilder.php index 252958a..eef2663 100644 --- a/src/view/HeaderBuilder.php +++ b/src/view/HeaderBuilder.php @@ -6,20 +6,24 @@ use App\Entity\Node; class HeaderBuilder extends AbstractBuilder { private ?Node $nav = null; + private ?Node $breadcrumb = null; public function __construct(Node $node) { - // nav - // n'utilise pas useChildrenBuilder, il faudrait peut-être + // pas de useChildrenBuilder, il faudrait peut-être $children = $node->getChildren(); foreach($children as $child) { - if($child->getName() === 'nav') - { + if($child->getName() === 'nav'){ $this->nav = $child; $nav_builder = new NavBuilder($this->nav); $nav = $nav_builder->render(); } + elseif($child->getName() === 'breadcrumb'){ + $this->breadcrumb = $child; + $breadcrumb_builder = new BreadcrumbBuilder($this->breadcrumb); + $breadcrumb = $breadcrumb_builder->render(); + } } $viewFile = self::VIEWS_PATH . $node->getName() . '.php'; diff --git a/src/view/templates/footer.php b/src/view/templates/footer.php index 5af7924..a4e3544 100644 --- a/src/view/templates/footer.php +++ b/src/view/templates/footer.php @@ -1,15 +1,16 @@
- \ No newline at end of file diff --git a/src/view/templates/header.php b/src/view/templates/header.php index fa55cea..0bf4396 100644 --- a/src/view/templates/header.php +++ b/src/view/templates/header.php @@ -13,11 +13,14 @@

-
- - <?= $facebook_alt ?> - - <?= $instagram_alt ?> +
+ +
\ No newline at end of file -- cgit v1.2.3