aboutsummaryrefslogtreecommitdiff
path: root/src/view
diff options
context:
space:
mode:
Diffstat (limited to 'src/view')
-rw-r--r--src/view/AbstractBuilder.php4
-rw-r--r--src/view/NewBuilder.php6
-rw-r--r--src/view/NewsBlockBuilder.php3
-rw-r--r--src/view/PostBlockBuilder.php1
-rw-r--r--src/view/templates/modify_block.php7
-rw-r--r--src/view/templates/news_block.php5
-rw-r--r--src/view/templates/post_block.php5
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
8abstract class AbstractBuilder 8abstract 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 pour le bouton "Nouvel article" => 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