From d0c39f9c0d2724111a7b1019eacb1b675fd5fd94 Mon Sep 17 00:00:00 2001 From: polo Date: Sun, 12 Jul 2026 12:35:04 +0200 Subject: =?UTF-8?q?suppression=20colonnes=20dans=20NodeData,=20blocs=20et?= =?UTF-8?q?=20pr=C3=A9sentations=20dans=20des=20constantes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- composer.json | 8 ++-- public/index.php | 22 +++++------ src/controller/PageManagementController.php | 4 +- src/model/entities/NodeData.php | 58 ----------------------------- src/model/entities/Presentation.php | 6 ++- src/view/MainBuilder.php | 4 +- src/view/templates/modify_block.php | 2 +- 7 files changed, 22 insertions(+), 82 deletions(-) diff --git a/composer.json b/composer.json index b7ad2e5..b8ddaa2 100644 --- a/composer.json +++ b/composer.json @@ -6,14 +6,14 @@ "doctrine/dbal": "^4.3", "doctrine/orm": "^3.5", "symfony/cache": "^7.0", + "symfony/http-foundation": "^7.0", + "symfony/var-exporter": "^7.0", + "symfony/process": "^7.0", "htmlawed/htmlawed": "^1.2", "tinymce/tinymce": "^8.5", "mklkj/tinymce-i18n": "^26.5", "phpmailer/phpmailer": "^7.1", - "twbs/bootstrap-icons": "^1.13", - "symfony/http-foundation": "^7.0", - "symfony/var-exporter": "^7.0", - "symfony/process": "^7.0" + "twbs/bootstrap-icons": "^1.13" }, "scripts": { "post-install-cmd": [ diff --git a/public/index.php b/public/index.php index cdcfd34..2ab799b 100644 --- a/public/index.php +++ b/public/index.php @@ -1,19 +1,15 @@ nécéssite que les contrôleurs soient aient tous un namespace +*/ declare(strict_types=1); diff --git a/src/controller/PageManagementController.php b/src/controller/PageManagementController.php index bfad474..11aab09 100644 --- a/src/controller/PageManagementController.php +++ b/src/controller/PageManagementController.php @@ -132,7 +132,7 @@ class PageManagementController $main = $model->getNode(); $position = count($main->getChildren()) + 1; // position dans la fraterie - if(!in_array($request->request->get("bloc_select"), array_keys(Presentation::$blocks), true)){ // 3è param: contrôle du type + if(!in_array($request->request->get("bloc_select"), array_keys(Presentation::BLOCKS), true)){ // 3è param: contrôle du type // utiliser une flash error return new RedirectResponse((string)new URL(['page' => $request->query->get('page'), 'error' => 'bad_bloc_type'])); } @@ -311,7 +311,7 @@ class PageManagementController $model = new Model($entityManager); $model->findNodeById($json['id']); - if(in_array($json['presentation'], array_keys(Presentation::$presentations))){ + if(in_array($json['presentation'], array_keys(Presentation::PRESENTATIONS))){ $model->getNode()->getNodeData()->setPresentation($json['presentation']); $entityManager->flush(); diff --git a/src/model/entities/NodeData.php b/src/model/entities/NodeData.php index f6d6b01..1646c92 100644 --- a/src/model/entities/NodeData.php +++ b/src/model/entities/NodeData.php @@ -29,18 +29,6 @@ class NodeData #[ORM\Column(type: "json")] private array $data; - #[ORM\Column(type: "string", length: 255, nullable: true)] - private ?string $presentation; - - #[ORM\Column(type: "boolean", length: 255, nullable: true)] - private ?bool $chrono_order = null; - - #[ORM\Column(type: "integer", nullable: true)] - private ?int $grid_cols_min_width = null; // pour le mode grille - - #[ORM\Column(type: "integer", nullable: true)] - private ?int $pagination_limit = null; // pour les post_block et news_block - #[ORM\OneToMany(mappedBy: 'node_data', targetEntity: AssetEmployment::class, cascade: ['persist', 'remove'])] private Collection $asset_employment; @@ -74,52 +62,6 @@ class NodeData unset($this->data[$key]); } } - - // spécifique aux blocs contenant des articles - /*public function getPresentation(): ?string - { - return $this->presentation; - } - public function setPresentation(string $presentation): void - { - $this->presentation = $presentation; - } - public function getColsMinWidth(): int - { - $default = 320; // pixels - return $this->grid_cols_min_width === null ? $default : $this->grid_cols_min_width; - } - public function setColsMinWidth(int $columns): void - { - $this->grid_cols_min_width = $columns; - } - public function getChronoOrder(): bool - { - return $this->chrono_order ?? false; - } - public function setChronoOrder(bool $reverse_order): void - { - $this->chrono_order = $reverse_order; - } - - public function getPaginationLimit(): ?int - { - $default = 12; // si 0 pas de pagination, 12 rend bien avec des grilles de 2, 3 ou 4 colonnes - return $this->pagination_limit === null ? $default : $this->pagination_limit; - } - public function setPaginationLimit(int $pagination_limit): void - { - $this->pagination_limit = $pagination_limit; - } - private int $nb_pages = 1; - public function getNumberOfPages(): int - { - return $this->nb_pages; - } - public function setNumberOfPages(int $nb_pages): void - { - $this->nb_pages = $nb_pages; - }*/ public function setNode(?Node $node): void { diff --git a/src/model/entities/Presentation.php b/src/model/entities/Presentation.php index 912c19e..d66bf24 100644 --- a/src/model/entities/Presentation.php +++ b/src/model/entities/Presentation.php @@ -119,11 +119,13 @@ class Presentation{ $this->nb_pages = $nb_pages; } - static public array $blocks = ['post_block' => 'Articles libres', 'news_block' => 'Actualités', + + /* -- blocs et présentations disponibles dans l'application -- */ + const BLOCKS = ['post_block' => 'Articles libres', 'news_block' => 'Actualités', //'galery' => 'Galerie', 'calendar' => 'Calendrier', 'form' => 'Formulaire' ]; - static public array $presentations = ['fullwidth' => 'Pleine largeur', 'grid' => 'Grille', 'mosaic' => 'Mosaïque' + const PRESENTATIONS = ['fullwidth' => 'Pleine largeur', 'grid' => 'Grille', 'mosaic' => 'Mosaïque' //, 'carousel' => 'Carrousel' ]; static public function hasPresentation(string $block): bool diff --git a/src/view/MainBuilder.php b/src/view/MainBuilder.php index b888a56..1df5846 100644 --- a/src/view/MainBuilder.php +++ b/src/view/MainBuilder.php @@ -56,7 +56,7 @@ class MainBuilder extends AbstractBuilder private function viewEditBlocks(Node $node): void { $options = ''; - foreach(Presentation::$blocks as $key => $value){ + foreach(Presentation::BLOCKS as $key => $value){ $options .= '\n"; } @@ -87,7 +87,7 @@ class MainBuilder extends AbstractBuilder private function makePresentationOptions(string $presentation): string { $options = ''; - foreach(Presentation::$presentations as $key => $value){ + foreach(Presentation::PRESENTATIONS as $key => $value){ $options .= ''; } return $options; diff --git a/src/view/templates/modify_block.php b/src/view/templates/modify_block.php index 1da3176..e966ee3 100644 --- a/src/view/templates/modify_block.php +++ b/src/view/templates/modify_block.php @@ -1,7 +1,7 @@
-