diff options
| author | polo <ordipolo@gmx.fr> | 2025-10-09 01:35:52 +0200 |
|---|---|---|
| committer | polo <ordipolo@gmx.fr> | 2025-10-09 01:35:52 +0200 |
| commit | 15cbf5d56b4644151d59fee512f5f8fbe496caa3 (patch) | |
| tree | 0da411f4aff53a0249cf3d59ea13f3786897b740 /src/view | |
| parent | 9f88389d78755d7c69c29e9db8f114fd1dbef034 (diff) | |
| download | cms-15cbf5d56b4644151d59fee512f5f8fbe496caa3.tar.gz cms-15cbf5d56b4644151d59fee512f5f8fbe496caa3.tar.bz2 cms-15cbf5d56b4644151d59fee512f5f8fbe496caa3.zip | |
pagination partie 2, nouvelles fonctions + renommage dans Director, ArticleController::fetch, et en JS: fetchArticles, insertLocalDates, modifs dans changePaginationLimit, dans les vues
Diffstat (limited to 'src/view')
| -rw-r--r-- | src/view/AbstractBuilder.php | 4 | ||||
| -rw-r--r-- | src/view/NewBuilder.php | 6 | ||||
| -rw-r--r-- | src/view/NewsBlockBuilder.php | 3 | ||||
| -rw-r--r-- | src/view/PostBlockBuilder.php | 1 | ||||
| -rw-r--r-- | src/view/templates/modify_block.php | 7 | ||||
| -rw-r--r-- | src/view/templates/news_block.php | 5 | ||||
| -rw-r--r-- | src/view/templates/post_block.php | 5 |
7 files changed, 22 insertions, 9 deletions
diff --git a/src/view/AbstractBuilder.php b/src/view/AbstractBuilder.php index ab5e389..0748df0 100644 --- a/src/view/AbstractBuilder.php +++ b/src/view/AbstractBuilder.php | |||
| @@ -7,7 +7,7 @@ use App\Entity\Node; | |||
| 7 | 7 | ||
| 8 | abstract class AbstractBuilder | 8 | abstract class AbstractBuilder |
| 9 | { | 9 | { |
| 10 | protected const string VIEWS_PATH = '../src/view/templates/'; | 10 | public const string VIEWS_PATH = '../src/view/templates/'; |
| 11 | protected string $html = ''; | 11 | protected string $html = ''; |
| 12 | protected int $id_node; | 12 | protected int $id_node; |
| 13 | 13 | ||
| @@ -44,7 +44,7 @@ abstract class AbstractBuilder | |||
| 44 | } | 44 | } |
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | protected function snakeToPascalCase(string $input): string | 47 | private function snakeToPascalCase(string $input): string |
| 48 | { | 48 | { |
| 49 | return str_replace('_', '', ucwords($input, '_')); | 49 | return str_replace('_', '', ucwords($input, '_')); |
| 50 | } | 50 | } |
diff --git a/src/view/NewBuilder.php b/src/view/NewBuilder.php index 83dd728..ec48541 100644 --- a/src/view/NewBuilder.php +++ b/src/view/NewBuilder.php | |||
| @@ -51,9 +51,7 @@ class NewBuilder extends AbstractBuilder | |||
| 51 | } | 51 | } |
| 52 | 52 | ||
| 53 | $content = ''; | 53 | $content = ''; |
| 54 | 54 | if(CURRENT_PAGE === 'article'){ | |
| 55 | // page article unique | ||
| 56 | if(Director::$page_path->getLast()->getEndOfPath() === 'article'){ | ||
| 57 | $content = $node->getArticle()->getContent(); | 55 | $content = $node->getArticle()->getContent(); |
| 58 | $from_to_button = '<p><a class="link_to_article" href="' . new URL(isset($_GET['from']) ? ['page' => $_GET['from']] : []) . '"><button>Retour</button></a></p>'; | 56 | $from_to_button = '<p><a class="link_to_article" href="' . new URL(isset($_GET['from']) ? ['page' => $_GET['from']] : []) . '"><button>Retour</button></a></p>'; |
| 59 | $overflow = ''; | 57 | $overflow = ''; |
| @@ -84,7 +82,7 @@ class NewBuilder extends AbstractBuilder | |||
| 84 | $date_buttons = ''; | 82 | $date_buttons = ''; |
| 85 | $admin_buttons = ''; | 83 | $admin_buttons = ''; |
| 86 | if($_SESSION['admin']){ | 84 | if($_SESSION['admin']){ |
| 87 | if(Director::$page_path->getLast()->getEndOfPath() === 'article'){ | 85 | if(CURRENT_PAGE === 'article'){ |
| 88 | $title_js = 'onclick="openEditor(\'' . $id_title . '\')"'; | 86 | $title_js = 'onclick="openEditor(\'' . $id_title . '\')"'; |
| 89 | $modify_title = '<p id="edit-' . $id_title . '"><button ' . $title_js . '><img class="action_icon" src="assets/edit.svg">Titre</button></p>' . "\n"; | 87 | $modify_title = '<p id="edit-' . $id_title . '"><button ' . $title_js . '><img class="action_icon" src="assets/edit.svg">Titre</button></p>' . "\n"; |
| 90 | $close_js_title = 'onclick="closeEditor(\'' . $id_title . '\')"'; | 88 | $close_js_title = 'onclick="closeEditor(\'' . $id_title . '\')"'; |
diff --git a/src/view/NewsBlockBuilder.php b/src/view/NewsBlockBuilder.php index 963afe6..4c7c4ec 100644 --- a/src/view/NewsBlockBuilder.php +++ b/src/view/NewsBlockBuilder.php | |||
| @@ -28,6 +28,7 @@ class NewsBlockBuilder extends AbstractBuilder | |||
| 28 | $min_width = $node->getNodeData()->getColsMinWidth(); | 28 | $min_width = $node->getNodeData()->getColsMinWidth(); |
| 29 | $cols_min_width = 'grid-template-columns: repeat(auto-fit, minmax(' . (string)$min_width . 'px, 1fr));'; | 29 | $cols_min_width = 'grid-template-columns: repeat(auto-fit, minmax(' . (string)$min_width . 'px, 1fr));'; |
| 30 | } | 30 | } |
| 31 | $fetch_button_hidden = $node->getNodeData()->getNumberOfPages() > 1 ? '' : ' hidden'; | ||
| 31 | 32 | ||
| 32 | // ajouter un article | 33 | // ajouter un article |
| 33 | $new_article = ''; | 34 | $new_article = ''; |
| @@ -54,7 +55,7 @@ class NewsBlockBuilder extends AbstractBuilder | |||
| 54 | $html = ''; | 55 | $html = ''; |
| 55 | $admin_buttons = $new_button . $modify_article . $delete_article . $close_editor . $submit_article; | 56 | $admin_buttons = $new_button . $modify_article . $delete_article . $close_editor . $submit_article; |
| 56 | 57 | ||
| 57 | // post vide mis là pour le bouton "Nouvel article" => déplace vers page "article" | 58 | // insérer post.php pour le bouton "Nouvel article", new.php pour les vrais articles |
| 58 | ob_start(); | 59 | ob_start(); |
| 59 | require self::VIEWS_PATH . 'post.php'; // nécéssite $admin_buttons et $html | 60 | require self::VIEWS_PATH . 'post.php'; // nécéssite $admin_buttons et $html |
| 60 | $new_article = ob_get_clean(); | 61 | $new_article = ob_get_clean(); |
diff --git a/src/view/PostBlockBuilder.php b/src/view/PostBlockBuilder.php index ba54901..ba4de12 100644 --- a/src/view/PostBlockBuilder.php +++ b/src/view/PostBlockBuilder.php | |||
| @@ -28,6 +28,7 @@ class PostBlockBuilder extends AbstractBuilder | |||
| 28 | $min_width = $node->getNodeData()->getColsMinWidth(); | 28 | $min_width = $node->getNodeData()->getColsMinWidth(); |
| 29 | $cols_min_width = 'grid-template-columns: repeat(auto-fit, minmax(' . (string)$min_width . 'px, 1fr));'; | 29 | $cols_min_width = 'grid-template-columns: repeat(auto-fit, minmax(' . (string)$min_width . 'px, 1fr));'; |
| 30 | } | 30 | } |
| 31 | $fetch_button_hidden = $node->getNodeData()->getNumberOfPages() > 1 ? '' : ' hidden'; | ||
| 31 | 32 | ||
| 32 | // ajouter un article | 33 | // ajouter un article |
| 33 | // => fait un peu double emploi avec PostBuilder | 34 | // => fait un peu double emploi avec PostBuilder |
diff --git a/src/view/templates/modify_block.php b/src/view/templates/modify_block.php index 1d097e0..3620100 100644 --- a/src/view/templates/modify_block.php +++ b/src/view/templates/modify_block.php | |||
| @@ -47,4 +47,11 @@ if(Blocks::hasPresentation($child_node->getName())){ | |||
| 47 | <?php | 47 | <?php |
| 48 | } | 48 | } |
| 49 | ?> | 49 | ?> |
| 50 | <div class="pagination_limit"> | ||
| 51 | <label for="pagination_limit_<?= $child_node->getId() ?>"> | ||
| 52 | Nombre max d'articles affichés | ||
| 53 | <input type="number" id="pagination_limit_<?= $child_node->getId() ?>" name="pagination_limit" onchange="changePaginationLimit(<?= $child_node->getId() ?>)" min="0" max="30" value="<?= $child_node->getNodeData()->getPaginationLimit() ?>"> | ||
| 54 | <i>(mettre 0 désactive la pagination)</i> | ||
| 55 | </label> | ||
| 56 | </div> | ||
| 50 | </div> \ No newline at end of file | 57 | </div> \ No newline at end of file |
diff --git a/src/view/templates/news_block.php b/src/view/templates/news_block.php index 9d01513..43dbe01 100644 --- a/src/view/templates/news_block.php +++ b/src/view/templates/news_block.php | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | <?php declare(strict_types=1); ?> | 1 | <?php declare(strict_types=1); ?> |
| 2 | <section class="<?= $section_class ?>" id="<?= $this->id_node ?>"> | 2 | <section class="<?= $section_class ?>" block-type="<?= $node->getName() ?>" id="<?= $this->id_node ?>"> |
| 3 | <h3><?= $title ?></h3> | 3 | <h3><?= $title ?></h3> |
| 4 | <?= $new_article ?> | 4 | <?= $new_article ?> |
| 5 | <script> | 5 | <script> |
| @@ -8,4 +8,7 @@ | |||
| 8 | <div class="section_child" style="<?= $cols_min_width ?>"> | 8 | <div class="section_child" style="<?= $cols_min_width ?>"> |
| 9 | <?= $content ?> | 9 | <?= $content ?> |
| 10 | </div> | 10 | </div> |
| 11 | <div class="fetch_articles"> | ||
| 12 | <button class="<?= $fetch_button_hidden ?>" onclick="fetchArticles(<?= $this->id_node ?>)">Articles suivants</button> | ||
| 13 | </div> | ||
| 11 | </section> \ No newline at end of file | 14 | </section> \ No newline at end of file |
diff --git a/src/view/templates/post_block.php b/src/view/templates/post_block.php index 9d01513..43dbe01 100644 --- a/src/view/templates/post_block.php +++ b/src/view/templates/post_block.php | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | <?php declare(strict_types=1); ?> | 1 | <?php declare(strict_types=1); ?> |
| 2 | <section class="<?= $section_class ?>" id="<?= $this->id_node ?>"> | 2 | <section class="<?= $section_class ?>" block-type="<?= $node->getName() ?>" id="<?= $this->id_node ?>"> |
| 3 | <h3><?= $title ?></h3> | 3 | <h3><?= $title ?></h3> |
| 4 | <?= $new_article ?> | 4 | <?= $new_article ?> |
| 5 | <script> | 5 | <script> |
| @@ -8,4 +8,7 @@ | |||
| 8 | <div class="section_child" style="<?= $cols_min_width ?>"> | 8 | <div class="section_child" style="<?= $cols_min_width ?>"> |
| 9 | <?= $content ?> | 9 | <?= $content ?> |
| 10 | </div> | 10 | </div> |
| 11 | <div class="fetch_articles"> | ||
| 12 | <button class="<?= $fetch_button_hidden ?>" onclick="fetchArticles(<?= $this->id_node ?>)">Articles suivants</button> | ||
| 13 | </div> | ||
| 11 | </section> \ No newline at end of file | 14 | </section> \ No newline at end of file |
