diff options
| -rw-r--r-- | composer.json | 8 | ||||
| -rw-r--r-- | public/index.php | 22 | ||||
| -rw-r--r-- | src/controller/PageManagementController.php | 4 | ||||
| -rw-r--r-- | src/model/entities/NodeData.php | 58 | ||||
| -rw-r--r-- | src/model/entities/Presentation.php | 6 | ||||
| -rw-r--r-- | src/view/MainBuilder.php | 4 | ||||
| -rw-r--r-- | 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 @@ | |||
| 6 | "doctrine/dbal": "^4.3", | 6 | "doctrine/dbal": "^4.3", |
| 7 | "doctrine/orm": "^3.5", | 7 | "doctrine/orm": "^3.5", |
| 8 | "symfony/cache": "^7.0", | 8 | "symfony/cache": "^7.0", |
| 9 | "symfony/http-foundation": "^7.0", | ||
| 10 | "symfony/var-exporter": "^7.0", | ||
| 11 | "symfony/process": "^7.0", | ||
| 9 | "htmlawed/htmlawed": "^1.2", | 12 | "htmlawed/htmlawed": "^1.2", |
| 10 | "tinymce/tinymce": "^8.5", | 13 | "tinymce/tinymce": "^8.5", |
| 11 | "mklkj/tinymce-i18n": "^26.5", | 14 | "mklkj/tinymce-i18n": "^26.5", |
| 12 | "phpmailer/phpmailer": "^7.1", | 15 | "phpmailer/phpmailer": "^7.1", |
| 13 | "twbs/bootstrap-icons": "^1.13", | 16 | "twbs/bootstrap-icons": "^1.13" |
| 14 | "symfony/http-foundation": "^7.0", | ||
| 15 | "symfony/var-exporter": "^7.0", | ||
| 16 | "symfony/process": "^7.0" | ||
| 17 | }, | 17 | }, |
| 18 | "scripts": { | 18 | "scripts": { |
| 19 | "post-install-cmd": [ | 19 | "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 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // public/index/php | 2 | // public/index/php |
| 3 | 3 | ||
| 4 | /* plan d'action pour "symfonyfier" le site | 4 | /* idées pour "symfonyfier" le site |
| 5 | A - | 5 | 1/ router à la manière de symfony? |
| 6 | 1/ de vrais contrôleurs: classes et méthodes prenant une requête en entrée et retournant une réponse | 6 | 2/ utiliser les méthodes HTTP: GET, HEAD, POST, PUT, PATCH, DELETE? |
| 7 | (début de séparation contrôleurs et classes métier) | 7 | 3/ http-foundation possède aussi une classe Session. intéressant! |
| 8 | 2/ routeur structuré: méthodes GET et POST, content-type, admin | 8 | 4/ passer à des chemins modernes "ciblant des ressources" genre /chemin/de/la/page |
| 9 | 3/ routeur amélioré: pré-routage avec méthodes HTTP: GET, HEAD, POST, PUT, PATCH, DELETE, etc | 9 | le mode modification de page doit thérioquement être appelé comme ça: /chemin/de/la/page/modif_page |
| 10 | 4/ réécriture avec les classes Request et Response sans toucher les liens | 10 | apparemment, le from=nom_page pour les formulaires ne se fait pas... |
| 11 | 5/ http-foundation possède aussi une classe Session. intéressant! | 11 | 5/ utiliser le routeur de symfony? => nécéssite que les contrôleurs soient aient tous un namespace |
| 12 | B - | 12 | */ |
| 13 | 1/ passer à des chemins modernes "ciblant des ressources" genre /chemin/de/la/page | ||
| 14 | le mode modification de page doit thérioquement être appelé comme ça: /chemin/de/la/page/modif_page | ||
| 15 | apparemment, le from=nom_page pour les formulaires ne se fait pas... | ||
| 16 | 2/ utiliser le routeur de symfony: nécéssite que tous les contrôleurs soient des classes avec un namespace */ | ||
| 17 | 13 | ||
| 18 | declare(strict_types=1); | 14 | declare(strict_types=1); |
| 19 | 15 | ||
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 | |||
| 132 | $main = $model->getNode(); | 132 | $main = $model->getNode(); |
| 133 | $position = count($main->getChildren()) + 1; // position dans la fraterie | 133 | $position = count($main->getChildren()) + 1; // position dans la fraterie |
| 134 | 134 | ||
| 135 | if(!in_array($request->request->get("bloc_select"), array_keys(Presentation::$blocks), true)){ // 3è param: contrôle du type | 135 | if(!in_array($request->request->get("bloc_select"), array_keys(Presentation::BLOCKS), true)){ // 3è param: contrôle du type |
| 136 | // utiliser une flash error | 136 | // utiliser une flash error |
| 137 | return new RedirectResponse((string)new URL(['page' => $request->query->get('page'), 'error' => 'bad_bloc_type'])); | 137 | return new RedirectResponse((string)new URL(['page' => $request->query->get('page'), 'error' => 'bad_bloc_type'])); |
| 138 | } | 138 | } |
| @@ -311,7 +311,7 @@ class PageManagementController | |||
| 311 | $model = new Model($entityManager); | 311 | $model = new Model($entityManager); |
| 312 | $model->findNodeById($json['id']); | 312 | $model->findNodeById($json['id']); |
| 313 | 313 | ||
| 314 | if(in_array($json['presentation'], array_keys(Presentation::$presentations))){ | 314 | if(in_array($json['presentation'], array_keys(Presentation::PRESENTATIONS))){ |
| 315 | $model->getNode()->getNodeData()->setPresentation($json['presentation']); | 315 | $model->getNode()->getNodeData()->setPresentation($json['presentation']); |
| 316 | $entityManager->flush(); | 316 | $entityManager->flush(); |
| 317 | 317 | ||
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 | |||
| 29 | #[ORM\Column(type: "json")] | 29 | #[ORM\Column(type: "json")] |
| 30 | private array $data; | 30 | private array $data; |
| 31 | 31 | ||
| 32 | #[ORM\Column(type: "string", length: 255, nullable: true)] | ||
| 33 | private ?string $presentation; | ||
| 34 | |||
| 35 | #[ORM\Column(type: "boolean", length: 255, nullable: true)] | ||
| 36 | private ?bool $chrono_order = null; | ||
| 37 | |||
| 38 | #[ORM\Column(type: "integer", nullable: true)] | ||
| 39 | private ?int $grid_cols_min_width = null; // pour le mode grille | ||
| 40 | |||
| 41 | #[ORM\Column(type: "integer", nullable: true)] | ||
| 42 | private ?int $pagination_limit = null; // pour les post_block et news_block | ||
| 43 | |||
| 44 | #[ORM\OneToMany(mappedBy: 'node_data', targetEntity: AssetEmployment::class, cascade: ['persist', 'remove'])] | 32 | #[ORM\OneToMany(mappedBy: 'node_data', targetEntity: AssetEmployment::class, cascade: ['persist', 'remove'])] |
| 45 | private Collection $asset_employment; | 33 | private Collection $asset_employment; |
| 46 | 34 | ||
| @@ -74,52 +62,6 @@ class NodeData | |||
| 74 | unset($this->data[$key]); | 62 | unset($this->data[$key]); |
| 75 | } | 63 | } |
| 76 | } | 64 | } |
| 77 | |||
| 78 | // spécifique aux blocs contenant des articles | ||
| 79 | /*public function getPresentation(): ?string | ||
| 80 | { | ||
| 81 | return $this->presentation; | ||
| 82 | } | ||
| 83 | public function setPresentation(string $presentation): void | ||
| 84 | { | ||
| 85 | $this->presentation = $presentation; | ||
| 86 | } | ||
| 87 | public function getColsMinWidth(): int | ||
| 88 | { | ||
| 89 | $default = 320; // pixels | ||
| 90 | return $this->grid_cols_min_width === null ? $default : $this->grid_cols_min_width; | ||
| 91 | } | ||
| 92 | public function setColsMinWidth(int $columns): void | ||
| 93 | { | ||
| 94 | $this->grid_cols_min_width = $columns; | ||
| 95 | } | ||
| 96 | public function getChronoOrder(): bool | ||
| 97 | { | ||
| 98 | return $this->chrono_order ?? false; | ||
| 99 | } | ||
| 100 | public function setChronoOrder(bool $reverse_order): void | ||
| 101 | { | ||
| 102 | $this->chrono_order = $reverse_order; | ||
| 103 | } | ||
| 104 | |||
| 105 | public function getPaginationLimit(): ?int | ||
| 106 | { | ||
| 107 | $default = 12; // si 0 pas de pagination, 12 rend bien avec des grilles de 2, 3 ou 4 colonnes | ||
| 108 | return $this->pagination_limit === null ? $default : $this->pagination_limit; | ||
| 109 | } | ||
| 110 | public function setPaginationLimit(int $pagination_limit): void | ||
| 111 | { | ||
| 112 | $this->pagination_limit = $pagination_limit; | ||
| 113 | } | ||
| 114 | private int $nb_pages = 1; | ||
| 115 | public function getNumberOfPages(): int | ||
| 116 | { | ||
| 117 | return $this->nb_pages; | ||
| 118 | } | ||
| 119 | public function setNumberOfPages(int $nb_pages): void | ||
| 120 | { | ||
| 121 | $this->nb_pages = $nb_pages; | ||
| 122 | }*/ | ||
| 123 | 65 | ||
| 124 | public function setNode(?Node $node): void | 66 | public function setNode(?Node $node): void |
| 125 | { | 67 | { |
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{ | |||
| 119 | $this->nb_pages = $nb_pages; | 119 | $this->nb_pages = $nb_pages; |
| 120 | } | 120 | } |
| 121 | 121 | ||
| 122 | static public array $blocks = ['post_block' => 'Articles libres', 'news_block' => 'Actualités', | 122 | |
| 123 | /* -- blocs et présentations disponibles dans l'application -- */ | ||
| 124 | const BLOCKS = ['post_block' => 'Articles libres', 'news_block' => 'Actualités', | ||
| 123 | //'galery' => 'Galerie', | 125 | //'galery' => 'Galerie', |
| 124 | 'calendar' => 'Calendrier', 'form' => 'Formulaire' | 126 | 'calendar' => 'Calendrier', 'form' => 'Formulaire' |
| 125 | ]; | 127 | ]; |
| 126 | static public array $presentations = ['fullwidth' => 'Pleine largeur', 'grid' => 'Grille', 'mosaic' => 'Mosaïque' | 128 | const PRESENTATIONS = ['fullwidth' => 'Pleine largeur', 'grid' => 'Grille', 'mosaic' => 'Mosaïque' |
| 127 | //, 'carousel' => 'Carrousel' | 129 | //, 'carousel' => 'Carrousel' |
| 128 | ]; | 130 | ]; |
| 129 | static public function hasPresentation(string $block): bool | 131 | 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 | |||
| 56 | private function viewEditBlocks(Node $node): void | 56 | private function viewEditBlocks(Node $node): void |
| 57 | { | 57 | { |
| 58 | $options = ''; | 58 | $options = ''; |
| 59 | foreach(Presentation::$blocks as $key => $value){ | 59 | foreach(Presentation::BLOCKS as $key => $value){ |
| 60 | $options .= '<option value= "' . $key . '">' . $value . "</option>\n"; | 60 | $options .= '<option value= "' . $key . '">' . $value . "</option>\n"; |
| 61 | } | 61 | } |
| 62 | 62 | ||
| @@ -87,7 +87,7 @@ class MainBuilder extends AbstractBuilder | |||
| 87 | private function makePresentationOptions(string $presentation): string | 87 | private function makePresentationOptions(string $presentation): string |
| 88 | { | 88 | { |
| 89 | $options = ''; | 89 | $options = ''; |
| 90 | foreach(Presentation::$presentations as $key => $value){ | 90 | foreach(Presentation::PRESENTATIONS as $key => $value){ |
| 91 | $options .= '<option value="' . $key . '" ' . ($presentation === $key ? 'selected' : '') . '>' . $value . '</option>'; | 91 | $options .= '<option value="' . $key . '" ' . ($presentation === $key ? 'selected' : '') . '>' . $value . '</option>'; |
| 92 | } | 92 | } |
| 93 | return $options; | 93 | 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 @@ | |||
| 1 | <?php declare(strict_types=1); ?> | 1 | <?php declare(strict_types=1); ?> |
| 2 | <div class="modify_one_block" id="bloc_edit_<?= $child_node->getId() ?>"> | 2 | <div class="modify_one_block" id="bloc_edit_<?= $child_node->getId() ?>"> |
| 3 | <div class="block_options"> | 3 | <div class="block_options"> |
| 4 | <label for="bloc_rename_<?= $child_node->getId() ?>">Type <b><?= App\Entity\Presentation::$blocks[$child_node->getName()] ?? '<i>erreur base de données</i>' ?></b> | 4 | <label for="bloc_rename_<?= $child_node->getId() ?>">Type <b><?= App\Entity\Presentation::BLOCKS[$child_node->getName()] ?? '<i>erreur base de données</i>' ?></b> |
| 5 | </label> | 5 | </label> |
| 6 | <p> | 6 | <p> |
| 7 | <input type="text" id="bloc_rename_<?= $child_node->getId() ?>" name="bloc_rename_title" value="<?= $child_node->getNodeData()->getdata()['title'] ?>" required> | 7 | <input type="text" id="bloc_rename_<?= $child_node->getId() ?>" name="bloc_rename_title" value="<?= $child_node->getNodeData()->getdata()['title'] ?>" required> |
