diff options
Diffstat (limited to 'src/model/entities/Node.php')
-rw-r--r-- | src/model/entities/Node.php | 28 |
1 files changed, 27 insertions, 1 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 | { |