From df3612ed7e6691530503f79483d2fdbc032d01b8 Mon Sep 17 00:00:00 2001 From: polo-pc-greta Date: Thu, 27 Mar 2025 10:13:03 +0100 Subject: mise en ligne github --- src/model/entities/Node.php | 168 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 168 insertions(+) create mode 100644 src/model/entities/Node.php (limited to 'src/model/entities/Node.php') diff --git a/src/model/entities/Node.php b/src/model/entities/Node.php new file mode 100644 index 0000000..49e16ba --- /dev/null +++ b/src/model/entities/Node.php @@ -0,0 +1,168 @@ +name_node = $name; + $this->article_timestamp = $article_timestamp; + $this->attributes = $attributes; + $this->position = $position; + $this->parent = $parent; + $this->page = $page; + $this->article = $article; + } + + 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--; + } + } + + // pfff... + public function getId(): int + { + return $this->id_node; + } + public function getName(): string + { + return $this->name_node; + } + /*public function setName(string $name): void + { + $this->name_node = $name; + }*/ + public function getArticleTimestamp(): string + { + return $this->article_timestamp; + } + public function getAttributes(): array + { + return $this->attributes; + } + /*public function setAttributes(array $attributes): void + { + $this->attributes = $attributes; + }*/ + public function getParent(): ?self + { + return $this->parent; + } + /*public function setParent(?self $parent): void + { + $this->parent = $parent; + }*/ + public function getPosition(): int + { + return $this->position; + } + /*public function setPosition(int $position): void + { + $this->position = $position; + }*/ + public function getPage(): Page + { + return $this->page; + } + /*public function setPage(Page $page): void + { + $this->page = $page; + }*/ + public function getArticle(): Article + { + return $this->article; + } + /*public function setArticle(Article $article): void + { + $this->article = $article; + }*/ + public function getNodeData(): ?NodeData + { + return $this->node_data; + } + public function getChildren(): array + { + return $this->children; + } + + public function getTempChild(): ?self // peut renvoyer null + { + return $this->temp_child; + } + public function setTempChild(self $child): void + { + $this->temp_child = $child; + } +} -- cgit v1.2.3