diff options
author | polo <ordipolo@gmx.fr> | 2025-10-20 01:57:21 +0200 |
---|---|---|
committer | polo <ordipolo@gmx.fr> | 2025-10-20 01:57:21 +0200 |
commit | 1e2cee519264f9ab2660540723915aec72bc2116 (patch) | |
tree | 1b773307463589f8506ffb0a439976a40e3e7bac /src/model/entities | |
parent | fb3bb6a42f5a8de6d446bc7566e3b766c7f64ce7 (diff) | |
download | cms-1e2cee519264f9ab2660540723915aec72bc2116.zip |
noeud "head" unique, noms fichiers CSS et JSS dans page, nombreux changements en conséquences
Diffstat (limited to 'src/model/entities')
-rw-r--r-- | src/model/entities/Node.php | 12 | ||||
-rw-r--r-- | src/model/entities/Page.php | 41 |
2 files changed, 45 insertions, 8 deletions
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 | |||
22 | #[ORM\Column(type: "string", length: 255)] | 22 | #[ORM\Column(type: "string", length: 255)] |
23 | private string $name_node; | 23 | private string $name_node; |
24 | 24 | ||
25 | #[ORM\Column(type: "json", nullable: true)] // type: "json" crée un longtext avec mariadb | ||
26 | private ?array $attributes = null; | ||
27 | |||
28 | #[ORM\Column(type: "integer")] | 25 | #[ORM\Column(type: "integer")] |
29 | private int $position; | 26 | private int $position; |
30 | 27 | ||
@@ -52,12 +49,10 @@ class Node | |||
52 | // attributs non destinés à doctrine | 49 | // attributs non destinés à doctrine |
53 | private array $children = []; // tableau de Node | 50 | private array $children = []; // tableau de Node |
54 | private ?self $adopted = null; // = "new" est un enfant de "main" lorsque la page est "article" | 51 | private ?self $adopted = null; // = "new" est un enfant de "main" lorsque la page est "article" |
55 | static private array $default_attributes = ['css_array' => ['body', 'head', 'nav', 'foot'],'js_array' => ['main']]; | ||
56 | 52 | ||
57 | public function __construct(string $name = '', array $attributes = [], int $position = 0, ?self $parent = null, ?Page $page = null, ?Article $article = null) | 53 | public function __construct(string $name = '', int $position = 0, ?self $parent = null, ?Page $page = null, ?Article $article = null) |
58 | { | 54 | { |
59 | $this->name_node = $name; | 55 | $this->name_node = $name; |
60 | $this->attributes = $attributes; | ||
61 | $this->position = $position; | 56 | $this->position = $position; |
62 | $this->parent = $parent; | 57 | $this->parent = $parent; |
63 | $this->page = $page; | 58 | $this->page = $page; |
@@ -77,7 +72,8 @@ class Node | |||
77 | { | 72 | { |
78 | $this->name_node = $name; | 73 | $this->name_node = $name; |
79 | }*/ | 74 | }*/ |
80 | public function getAttributes(): array | 75 | |
76 | /*public function getAttributes(): array | ||
81 | { | 77 | { |
82 | return $this->attributes; | 78 | return $this->attributes; |
83 | } | 79 | } |
@@ -97,7 +93,7 @@ class Node | |||
97 | if(!in_array($value, $this->attributes[$key])){ | 93 | if(!in_array($value, $this->attributes[$key])){ |
98 | $this->attributes[$key][] = $value; | 94 | $this->attributes[$key][] = $value; |
99 | } | 95 | } |
100 | } | 96 | }*/ |
101 | /*public function removeAttribute(string $key, string $value): void | 97 | /*public function removeAttribute(string $key, string $value): void |
102 | { | 98 | { |
103 | if(isset($this->attributes[$key])) // sécurité $key inexistante | 99 | 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 | |||
31 | #[ORM\Column(type: "text")] | 31 | #[ORM\Column(type: "text")] |
32 | private string $description; | 32 | private string $description; |
33 | 33 | ||
34 | #[ORM\Column(type: "json", nullable: true)] | ||
35 | private ?array $css = null; | ||
36 | |||
37 | #[ORM\Column(type: "json", nullable: true)] | ||
38 | private ?array $js = null; | ||
39 | |||
40 | static private array $default_css = ['body', 'head', 'nav', 'foot']; | ||
41 | static private array $default_js = ['main']; | ||
42 | |||
43 | /* remplissage | ||
44 | UPDATE nb_page | ||
45 | JOIN nb_node ON nb_node.page_id = nb_page.id_page | ||
46 | SET nb_page.css = JSON_EXTRACT(nb_node.attributes, '$.css_array'); | ||
47 | UPDATE nb_page | ||
48 | JOIN nb_node ON nb_node.page_id = nb_page.id_page | ||
49 | SET nb_page.js = JSON_EXTRACT(nb_node.attributes, '$.js_array'); */ | ||
50 | |||
34 | #[ORM\Column(type: "boolean")] | 51 | #[ORM\Column(type: "boolean")] |
35 | private bool $reachable; | 52 | private bool $reachable; |
36 | 53 | ||
@@ -103,6 +120,30 @@ class Page | |||
103 | { | 120 | { |
104 | $this->description = $description; | 121 | $this->description = $description; |
105 | } | 122 | } |
123 | public function getCSS(): array | ||
124 | { | ||
125 | return $this->css; | ||
126 | } | ||
127 | public function useDefaultCSS(): void | ||
128 | { | ||
129 | $this->css = self::$default_css; | ||
130 | } | ||
131 | public function setCSS(array $css): void | ||
132 | { | ||
133 | $this->css = $css; | ||
134 | } | ||
135 | public function getJS(): array | ||
136 | { | ||
137 | return $this->js; | ||
138 | } | ||
139 | public function useDefaultJS(): void | ||
140 | { | ||
141 | $this->js = self::$default_js; | ||
142 | } | ||
143 | public function setJS(array $js): void | ||
144 | { | ||
145 | $this->js = $js; | ||
146 | } | ||
106 | public function isReachable(): bool | 147 | public function isReachable(): bool |
107 | { | 148 | { |
108 | return $this->reachable; | 149 | return $this->reachable; |