From 1e2cee519264f9ab2660540723915aec72bc2116 Mon Sep 17 00:00:00 2001 From: polo Date: Mon, 20 Oct 2025 01:57:21 +0200 Subject: =?UTF-8?q?noeud=20"head"=20unique,=20noms=20fichiers=20CSS=20et?= =?UTF-8?q?=20JSS=20dans=20page,=20nombreux=20changements=20en=20cons?= =?UTF-8?q?=C3=A9quences?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/model/entities/Node.php | 12 ++++-------- src/model/entities/Page.php | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 8 deletions(-) (limited to 'src/model/entities') diff --git a/src/model/entities/Node.php b/src/model/entities/Node.php index db081e4..fe3a1e5 100644 --- a/src/model/entities/Node.php +++ b/src/model/entities/Node.php @@ -22,9 +22,6 @@ class Node #[ORM\Column(type: "string", length: 255)] private string $name_node; - #[ORM\Column(type: "json", nullable: true)] // type: "json" crée un longtext avec mariadb - private ?array $attributes = null; - #[ORM\Column(type: "integer")] private int $position; @@ -52,12 +49,10 @@ class Node // attributs non destinés à doctrine 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 = '', array $attributes = [], int $position = 0, ?self $parent = null, ?Page $page = null, ?Article $article = null) + public function __construct(string $name = '', int $position = 0, ?self $parent = null, ?Page $page = null, ?Article $article = null) { $this->name_node = $name; - $this->attributes = $attributes; $this->position = $position; $this->parent = $parent; $this->page = $page; @@ -77,7 +72,8 @@ class Node { $this->name_node = $name; }*/ - public function getAttributes(): array + + /*public function getAttributes(): array { return $this->attributes; } @@ -97,7 +93,7 @@ class Node if(!in_array($value, $this->attributes[$key])){ $this->attributes[$key][] = $value; } - } + }*/ /*public function removeAttribute(string $key, string $value): void { if(isset($this->attributes[$key])) // sécurité $key inexistante diff --git a/src/model/entities/Page.php b/src/model/entities/Page.php index 5b54ae6..3e90dbc 100644 --- a/src/model/entities/Page.php +++ b/src/model/entities/Page.php @@ -31,6 +31,23 @@ class Page #[ORM\Column(type: "text")] private string $description; + #[ORM\Column(type: "json", nullable: true)] + private ?array $css = null; + + #[ORM\Column(type: "json", nullable: true)] + private ?array $js = null; + + static private array $default_css = ['body', 'head', 'nav', 'foot']; + static private array $default_js = ['main']; + + /* remplissage + UPDATE nb_page + JOIN nb_node ON nb_node.page_id = nb_page.id_page + SET nb_page.css = JSON_EXTRACT(nb_node.attributes, '$.css_array'); + UPDATE nb_page + JOIN nb_node ON nb_node.page_id = nb_page.id_page + SET nb_page.js = JSON_EXTRACT(nb_node.attributes, '$.js_array'); */ + #[ORM\Column(type: "boolean")] private bool $reachable; @@ -103,6 +120,30 @@ class Page { $this->description = $description; } + public function getCSS(): array + { + return $this->css; + } + public function useDefaultCSS(): void + { + $this->css = self::$default_css; + } + public function setCSS(array $css): void + { + $this->css = $css; + } + public function getJS(): array + { + return $this->js; + } + public function useDefaultJS(): void + { + $this->js = self::$default_js; + } + public function setJS(array $js): void + { + $this->js = $js; + } public function isReachable(): bool { return $this->reachable; -- cgit v1.2.3