From 6ddffd80053e268789f1b168ff3a8ee223681e47 Mon Sep 17 00:00:00 2001 From: polo Date: Sun, 11 May 2025 17:45:14 +0200 Subject: =?UTF-8?q?cr=C3=A9ation=20de=20page?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/model/entities/Node.php | 28 +++++++++++++++++++++++++++- src/model/entities/Page.php | 3 ++- 2 files changed, 29 insertions(+), 2 deletions(-) (limited to 'src/model/entities') diff --git a/src/model/entities/Node.php b/src/model/entities/Node.php index 103163b..fea9d50 100644 --- a/src/model/entities/Node.php +++ b/src/model/entities/Node.php @@ -55,6 +55,7 @@ class Node private array $children = []; // tableau de Node private ?self $adopted = null; // = "new" est un enfant de "main" lorsque la page est "article" + static private array $default_attributes = ['css_array' => ['body', 'head', 'nav', 'foot'],'js_array' => ['main']]; public function __construct(string $name = '', ?string $article_timestamp = null, array $attributes = [], int $position = 0, ?self $parent = null, ?Page $page = null, ?Article $article = null) { @@ -88,9 +89,34 @@ class Node { return $this->attributes; } - /*public function setAttributes(array $attributes): void + public function setDefaultAttributes(array $attributes): void { $this->attributes = $attributes; + } + public function useDefaultAttributes(): void + { + $this->attributes = self::$default_attributes; + } + /*public function addAttribute(string $key, string $value): void + { + if(!isset($this->attributes[$key])) { // sécurité $key inexistante + $this->attributes[$key] = []; + } + $this->attributes[$key][] = $value; + }*/ + /*public function removeAttribute(string $key, string $value): void + { + if(isset($this->attributes[$key])) // sécurité $key inexistante + { + // supprime et réindex avec un nouveau tableau + $tmp_array = $this->attributes[$key]; + $this->attributes[$key] = []; + foreach($tmp_array as $entry){ + if($entry !== $value){ + $this->attributes[$key][] = $entry; + } + } + } }*/ public function getParent(): ?self { diff --git a/src/model/entities/Page.php b/src/model/entities/Page.php index 1ad9ddb..7448e5d 100644 --- a/src/model/entities/Page.php +++ b/src/model/entities/Page.php @@ -26,7 +26,7 @@ class Page #[ORM\Column(type: "string", length: 255)] private string $end_of_path; // morceau d'URL plus exactement - private string $page_path; + private string $page_path = ''; #[ORM\Column(type: "boolean")] private bool $reachable; @@ -128,6 +128,7 @@ class Page return $this->children; } + // utilisée par $menu_path public function fillChildrenPagePath(string $parent_path = ''): void { $this->page_path = $parent_path != '' ? $parent_path . '/' . $this->end_of_path : $this->end_of_path; -- cgit v1.2.3