diff options
| author | polo <ordipolo@gmx.fr> | 2025-05-11 17:45:14 +0200 |
|---|---|---|
| committer | polo <ordipolo@gmx.fr> | 2025-05-11 17:45:14 +0200 |
| commit | 6ddffd80053e268789f1b168ff3a8ee223681e47 (patch) | |
| tree | 7539761c4454d9ff8c92e1d4e64a7da0c103c21b /src/model/entities | |
| parent | 4efa19d4357ab204d62397f1849e4651906e0e70 (diff) | |
| download | cms-6ddffd80053e268789f1b168ff3a8ee223681e47.tar.gz cms-6ddffd80053e268789f1b168ff3a8ee223681e47.tar.bz2 cms-6ddffd80053e268789f1b168ff3a8ee223681e47.zip | |
création de page
Diffstat (limited to 'src/model/entities')
| -rw-r--r-- | src/model/entities/Node.php | 28 | ||||
| -rw-r--r-- | src/model/entities/Page.php | 3 |
2 files changed, 29 insertions, 2 deletions
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 | |||
| 55 | 55 | ||
| 56 | private array $children = []; // tableau de Node | 56 | private array $children = []; // tableau de Node |
| 57 | private ?self $adopted = null; // = "new" est un enfant de "main" lorsque la page est "article" | 57 | private ?self $adopted = null; // = "new" est un enfant de "main" lorsque la page est "article" |
| 58 | static private array $default_attributes = ['css_array' => ['body', 'head', 'nav', 'foot'],'js_array' => ['main']]; | ||
| 58 | 59 | ||
| 59 | public function __construct(string $name = '', ?string $article_timestamp = null, array $attributes = [], int $position = 0, ?self $parent = null, ?Page $page = null, ?Article $article = null) | 60 | public function __construct(string $name = '', ?string $article_timestamp = null, array $attributes = [], int $position = 0, ?self $parent = null, ?Page $page = null, ?Article $article = null) |
| 60 | { | 61 | { |
| @@ -88,9 +89,34 @@ class Node | |||
| 88 | { | 89 | { |
| 89 | return $this->attributes; | 90 | return $this->attributes; |
| 90 | } | 91 | } |
| 91 | /*public function setAttributes(array $attributes): void | 92 | public function setDefaultAttributes(array $attributes): void |
| 92 | { | 93 | { |
| 93 | $this->attributes = $attributes; | 94 | $this->attributes = $attributes; |
| 95 | } | ||
| 96 | public function useDefaultAttributes(): void | ||
| 97 | { | ||
| 98 | $this->attributes = self::$default_attributes; | ||
| 99 | } | ||
| 100 | /*public function addAttribute(string $key, string $value): void | ||
| 101 | { | ||
| 102 | if(!isset($this->attributes[$key])) { // sécurité $key inexistante | ||
| 103 | $this->attributes[$key] = []; | ||
| 104 | } | ||
| 105 | $this->attributes[$key][] = $value; | ||
| 106 | }*/ | ||
| 107 | /*public function removeAttribute(string $key, string $value): void | ||
| 108 | { | ||
| 109 | if(isset($this->attributes[$key])) // sécurité $key inexistante | ||
| 110 | { | ||
| 111 | // supprime et réindex avec un nouveau tableau | ||
| 112 | $tmp_array = $this->attributes[$key]; | ||
| 113 | $this->attributes[$key] = []; | ||
| 114 | foreach($tmp_array as $entry){ | ||
| 115 | if($entry !== $value){ | ||
| 116 | $this->attributes[$key][] = $entry; | ||
| 117 | } | ||
| 118 | } | ||
| 119 | } | ||
| 94 | }*/ | 120 | }*/ |
| 95 | public function getParent(): ?self | 121 | public function getParent(): ?self |
| 96 | { | 122 | { |
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 | |||
| 26 | #[ORM\Column(type: "string", length: 255)] | 26 | #[ORM\Column(type: "string", length: 255)] |
| 27 | private string $end_of_path; // morceau d'URL plus exactement | 27 | private string $end_of_path; // morceau d'URL plus exactement |
| 28 | 28 | ||
| 29 | private string $page_path; | 29 | private string $page_path = ''; |
| 30 | 30 | ||
| 31 | #[ORM\Column(type: "boolean")] | 31 | #[ORM\Column(type: "boolean")] |
| 32 | private bool $reachable; | 32 | private bool $reachable; |
| @@ -128,6 +128,7 @@ class Page | |||
| 128 | return $this->children; | 128 | return $this->children; |
| 129 | } | 129 | } |
| 130 | 130 | ||
| 131 | // utilisée par $menu_path | ||
| 131 | public function fillChildrenPagePath(string $parent_path = ''): void | 132 | public function fillChildrenPagePath(string $parent_path = ''): void |
| 132 | { | 133 | { |
| 133 | $this->page_path = $parent_path != '' ? $parent_path . '/' . $this->end_of_path : $this->end_of_path; | 134 | $this->page_path = $parent_path != '' ? $parent_path . '/' . $this->end_of_path : $this->end_of_path; |
