diff options
author | polo <ordipolo@gmx.fr> | 2025-04-02 00:00:35 +0200 |
---|---|---|
committer | polo <ordipolo@gmx.fr> | 2025-04-02 00:00:35 +0200 |
commit | e4a325c9d5c07f09bc18b7e366ffb82b82c43502 (patch) | |
tree | b30c9c91106ebdbeef988c2c1ebd955b62051be2 /src/view | |
parent | e91841c4e678f955e1a44bf0fa0839e84f0aacd0 (diff) | |
download | cms-e4a325c9d5c07f09bc18b7e366ffb82b82c43502.zip |
modification des titres, aperçus et dates des news
Diffstat (limited to 'src/view')
-rw-r--r-- | src/view/ArticleBuilder.php | 2 | ||||
-rw-r--r-- | src/view/NewBuilder.php | 68 | ||||
-rw-r--r-- | src/view/templates/article.php | 1 | ||||
-rw-r--r-- | src/view/templates/new.php | 17 |
4 files changed, 67 insertions, 21 deletions
diff --git a/src/view/ArticleBuilder.php b/src/view/ArticleBuilder.php index 6c2f63c..f86f9bd 100644 --- a/src/view/ArticleBuilder.php +++ b/src/view/ArticleBuilder.php | |||
@@ -25,7 +25,7 @@ class ArticleBuilder extends AbstractBuilder | |||
25 | // partage | 25 | // partage |
26 | $share_link = new URL(['page' => CURRENT_PAGE], $id); | 26 | $share_link = new URL(['page' => CURRENT_PAGE], $id); |
27 | $share_js = 'onclick="copyInClipBoard(\'' . $share_link . '\')"'; | 27 | $share_js = 'onclick="copyInClipBoard(\'' . $share_link . '\')"'; |
28 | $share_button = '<p><a href="' . $share_link . '" ' . $share_js . '><img class="action_icon" src="assets/share.svg"></a></p>' . "\n"; | 28 | $share_button = '<a class="share" href="' . $share_link . '" ' . $share_js . '><img class="action_icon" src="assets/share.svg"></a>' . "\n"; |
29 | 29 | ||
30 | // modifier un article | 30 | // modifier un article |
31 | $admin_buttons = ''; | 31 | $admin_buttons = ''; |
diff --git a/src/view/NewBuilder.php b/src/view/NewBuilder.php index 94823bd..acde8b4 100644 --- a/src/view/NewBuilder.php +++ b/src/view/NewBuilder.php | |||
@@ -20,14 +20,23 @@ class NewBuilder extends AbstractBuilder | |||
20 | // html, date | 20 | // html, date |
21 | $title = $node->getArticle()->getTitle(); | 21 | $title = $node->getArticle()->getTitle(); |
22 | $preview = $node->getArticle()->getPreview(); | 22 | $preview = $node->getArticle()->getPreview(); |
23 | |||
24 | // lettre au début de l'id: i = article, p = preview, t = title, d = date | ||
23 | $id = $node->getArticleTimestamp(); | 25 | $id = $node->getArticleTimestamp(); |
26 | $id_title = $id; | ||
27 | $id_title[0] = 't'; | ||
28 | $id_preview = $id; | ||
29 | $id_preview[0] = 'p'; | ||
30 | $id_date = $id; | ||
31 | $id_date[0] = 'd'; | ||
32 | |||
24 | $content = ''; | 33 | $content = ''; |
25 | 34 | ||
26 | // page article unique | 35 | // page article unique |
27 | if(Director::$page_path->getLast()->getEndOfPath() === 'article') | 36 | if(Director::$page_path->getLast()->getEndOfPath() === 'article') |
28 | { | 37 | { |
29 | $content = $node->getArticle()->getContent(); | 38 | $content = $node->getArticle()->getContent(); |
30 | $from_to_button = '<p><a class="link_to_article" href="' . new URL(['page' => 'accueil']) . '"><button>Retour page d\'accueil</button></a></p>'; | 39 | $from_to_button = '<p><a class="link_to_article" href="' . new URL(['page' => 'accueil']) . '"><button>Page<br>d\'accueil</button></a></p>'; |
31 | } | 40 | } |
32 | // page d'accueil (avec des news) | 41 | // page d'accueil (avec des news) |
33 | else | 42 | else |
@@ -38,32 +47,59 @@ class NewBuilder extends AbstractBuilder | |||
38 | 47 | ||
39 | $date_object = $node->getArticle()->getDateTime(); // class DateTime | 48 | $date_object = $node->getArticle()->getDateTime(); // class DateTime |
40 | $date = 'le ' . str_replace(':', 'h', $date_object->format('d-m-Y à H:i')); | 49 | $date = 'le ' . str_replace(':', 'h', $date_object->format('d-m-Y à H:i')); |
50 | //$date = str_replace(':', 'h', $date_object->format('d-m-Y à H:i')); | ||
41 | 51 | ||
42 | // partage | 52 | // partage |
43 | $share_link = new URL(['page' => CURRENT_PAGE], $id); | 53 | $share_link = new URL(['page' => CURRENT_PAGE], $id); |
44 | isset($_GET['id']) ? $share_link->addParams(['id' => $_GET['id']]) : ''; | 54 | isset($_GET['id']) ? $share_link->addParams(['id' => $_GET['id']]) : ''; |
45 | $share_js = 'onclick="copyInClipBoard(\'' . $share_link . '\')"'; | 55 | $share_js = 'onclick="copyInClipBoard(\'' . $share_link . '\')"'; |
46 | $share_button = '<p><a href="' . $share_link . '" ' . $share_js . '><img class="action_icon" src="assets/share.svg"></a></p>' . "\n"; | 56 | $share_button = '<a class="share" href="' . $share_link . '" ' . $share_js . '><img class="action_icon" src="assets/share.svg"></a>' . "\n"; |
47 | 57 | ||
48 | // modifier un article | 58 | // modifier un article |
59 | $title_buttons = ''; | ||
60 | $preview_buttons = ''; | ||
61 | $article_buttons = ''; | ||
62 | $date_buttons = ''; | ||
49 | $admin_buttons = ''; | 63 | $admin_buttons = ''; |
50 | if($_SESSION['admin']) | 64 | if($_SESSION['admin']) |
51 | { | 65 | { |
52 | if(Director::$page_path->getLast()->getEndOfPath() === 'article'){ | 66 | if(Director::$page_path->getLast()->getEndOfPath() === 'article'){ |
53 | $modify_js = 'onclick="openEditor(\'' . $id . '\', \'article\')"'; | 67 | $title_js = 'onclick="openEditor(\'' . $id_title . '\', \'article\')"'; |
54 | $modify_article = '<p id="edit-' . $id . '"><a href="#"><img class="action_icon" src="assets/edit.svg" ' . $modify_js . '></a></p>' . "\n"; | 68 | $modify_title = '<p id="edit-' . $id_title . '"><a href="#"><button ' . $title_js . '><img class="action_icon" src="assets/edit.svg">Titre</button></a></p>' . "\n"; |
69 | $close_js_title = 'onclick="closeEditor(\'' . $id_title . '\', \'article\', \'preview\')"'; | ||
70 | $close_editor_title = '<p id="cancel-' . $id_title . '" class="hidden"><a href="#"><button ' . $close_js_title . '>Annuler</button></a></p>'; | ||
71 | $submit_js_title = 'onclick="submitArticle(\'' . $id_title . '\', \'article\')"'; | ||
72 | $submit_title = '<p id="submit-' . $id_title . '" class="hidden"><a href="#"><button ' . $submit_js_title . '>Valider</button></a></p>'; | ||
73 | $title_buttons = '<div class="button_zone">' . $modify_title . $close_editor_title . $submit_title . '</div>'; | ||
74 | |||
75 | $preview_js = 'onclick="openEditor(\'' . $id_preview . '\', \'article\')"'; | ||
76 | $modify_preview = '<p id="edit-' . $id_preview . '"><a href="#"><button ' . $preview_js . '><img class="action_icon" src="assets/edit.svg">Aperçu</button></a></p>' . "\n"; | ||
77 | $close_js_preview = 'onclick="closeEditor(\'' . $id_preview . '\', \'article\', \'preview\')"'; | ||
78 | $close_editor_preview = '<p id="cancel-' . $id_preview . '" class="hidden"><a href="#"><button ' . $close_js_preview . '>Annuler</button></a></p>'; | ||
79 | $submit_js_preview = 'onclick="submitArticle(\'' . $id_preview . '\', \'article\')"'; | ||
80 | $submit_preview = '<p id="submit-' . $id_preview . '" class="hidden"><a href="#"><button ' . $submit_js_preview . '>Valider</button></a></p>'; | ||
81 | $preview_buttons = '<div class="button_zone">' . $modify_preview . $close_editor_preview . $submit_preview . '</div>'; | ||
82 | |||
83 | $article_js = 'onclick="openEditor(\'' . $id . '\', \'article\')"'; | ||
84 | $modify_article = '<p id="edit-' . $id . '"><a href="#"><button ' . $article_js . '><img class="action_icon" src="assets/edit.svg">Article</button></a></p>' . "\n"; | ||
85 | $close_js_article = 'onclick="closeEditor(\'' . $id . '\', \'article\')"'; | ||
86 | $close_editor_article = '<p id="cancel-' . $id . '" class="hidden"><a href="#"><button ' . $close_js_article . '>Annuler</button></a></p>'; | ||
87 | $submit_js_article = 'onclick="submitArticle(\'' . $id . '\', \'article\')"'; | ||
88 | $submit_article = '<p id="submit-' . $id . '" class="hidden"><a href="#"><button ' . $submit_js_article . '>Valider</button></a></p>'; | ||
89 | $article_buttons = '<div class="button_zone">' . $modify_article . $close_editor_article . $submit_article . '</div>'; | ||
90 | |||
91 | $date_js = 'onclick="changeDate(\'' . $id_date . '\', \'article\');'; | ||
92 | $modify_date = '<p id="edit-' . $id_date . '"><a href="#"><button ' . $date_js . '"><img class="action_icon" src="assets/edit.svg">Date</button></a></p>' . "\n"; | ||
93 | $close_js_date = 'onclick="closeInput(\'' . $id_date . '\')"'; | ||
94 | $close_editor_date = '<p id="cancel-' . $id_date . '" class="hidden"><a href="#"><button ' . $close_js_date . '>Annuler</button></a></p>'; | ||
95 | $submit_js_date = 'onclick="submitDate(\'' . $id_date . '\')"'; | ||
96 | $submit_date = '<p id="submit-' . $id_date . '" class="hidden"><a href="#"><button ' . $submit_js_date . '>Valider</button></a></p>'; | ||
97 | $date_buttons = '<div class="button_zone">' . $modify_date . $close_editor_date . $submit_date . '</div>'; | ||
55 | 98 | ||
56 | $up_button = ''; | ||
57 | $down_button = ''; | ||
58 | |||
59 | $delete_js = 'onclick="deleteArticle(\'' . $id . '\', \'' . CURRENT_PAGE . '\')"'; | 99 | $delete_js = 'onclick="deleteArticle(\'' . $id . '\', \'' . CURRENT_PAGE . '\')"'; |
60 | $delete_article = '<p id="delete-' . $id . '"><a href="#"><img class="action_icon" src="assets/delete-bin.svg" ' . $delete_js . '></a></p>' . "\n"; | 100 | $delete_article = '<p id="delete-' . $id . '"><a href="#"><button ' . $delete_js . '"><img class="action_icon" src="assets/delete-bin.svg" ' . $delete_js . '>Retirer<br>la publication</button></a></p>' . "\n"; |
61 | 101 | ||
62 | $close_js = 'onclick="closeEditor(\'' . $id . '\', \'article\')"'; | 102 | $admin_buttons = $delete_article; |
63 | $close_editor = '<p id="cancel-' . $id . '" class="hidden"><a href="#"><button ' . $close_js . '>Annuler</button></a></p>'; | ||
64 | |||
65 | $submit_js = 'onclick="submitArticle(\'' . $id . '\', \'article\')"'; | ||
66 | $submit_article = '<p id="submit-' . $id . '" class="hidden"><a href="#"><button ' . $submit_js . '>Valider</button></a></p>'; | ||
67 | } | 103 | } |
68 | else{ | 104 | else{ |
69 | $modify_article = '<p id="edit-' . $id . '"></p>' . "\n"; | 105 | $modify_article = '<p id="edit-' . $id . '"></p>' . "\n"; |
@@ -81,8 +117,10 @@ class NewBuilder extends AbstractBuilder | |||
81 | $submit_article = '<p id="submit-' . $id . '" class="hidden"></p>'; | 117 | $submit_article = '<p id="submit-' . $id . '" class="hidden"></p>'; |
82 | 118 | ||
83 | $submit_article = '<p id="submit-' . $id . '" class="hidden"></p>'; | 119 | $submit_article = '<p id="submit-' . $id . '" class="hidden"></p>'; |
120 | |||
121 | $admin_buttons = $modify_article . $up_button . $down_button . $delete_article . $close_editor . $submit_article; | ||
84 | } | 122 | } |
85 | $admin_buttons = $modify_article . $up_button . $down_button . $delete_article . $close_editor . $submit_article; | 123 | |
86 | } | 124 | } |
87 | 125 | ||
88 | ob_start(); | 126 | ob_start(); |
diff --git a/src/view/templates/article.php b/src/view/templates/article.php index d34697e..f3ab32f 100644 --- a/src/view/templates/article.php +++ b/src/view/templates/article.php | |||
@@ -1,7 +1,6 @@ | |||
1 | <article> | 1 | <article> |
2 | <div class="article_content"> | 2 | <div class="article_content"> |
3 | <div class="article_title_zone"> | 3 | <div class="article_title_zone"> |
4 | <h4><?= $title ?></h4> | ||
5 | <?= $share_button ?> | 4 | <?= $share_button ?> |
6 | </div> | 5 | </div> |
7 | <div id="<?= $id ?>" class="html_from_editor"> | 6 | <div id="<?= $id ?>" class="html_from_editor"> |
diff --git a/src/view/templates/new.php b/src/view/templates/new.php index 9dd8969..9515c70 100644 --- a/src/view/templates/new.php +++ b/src/view/templates/new.php | |||
@@ -1,20 +1,29 @@ | |||
1 | <article> | 1 | <article> |
2 | <div class="new_content"> | 2 | <div class="new_content"> |
3 | <div class="article_title_zone"> | 3 | <div class="article_title_zone"> |
4 | <h4><?= $title ?></h4> | ||
5 | <?= $share_button ?> | 4 | <?= $share_button ?> |
5 | <div id="<?= $id_title ?>"> | ||
6 | <?= $title ?> | ||
7 | </div> | ||
8 | <?= $title_buttons ?> | ||
6 | </div> | 9 | </div> |
7 | <div class="new_content_text"> | 10 | <div id="<?= $id_preview ?>" class="new_content_text"> |
8 | <?= $preview ?> | 11 | <?= $preview ?> |
9 | </div> | 12 | </div> |
13 | <?= $preview_buttons ?> | ||
10 | <div id="<?= $id ?>" class="article_content_text"> | 14 | <div id="<?= $id ?>" class="article_content_text"> |
11 | <?= $content ?> | 15 | <?= $content ?> |
12 | </div> | 16 | </div> |
17 | <?= $article_buttons ?> | ||
13 | <div class="under_an_article"> | 18 | <div class="under_an_article"> |
14 | <p><img src="assets/calendar.svg"><?= $date ?></p> | 19 | <p> |
15 | <?= $from_to_button ?> | 20 | <img src="assets/calendar.svg"> |
21 | <span id="<?= $id_date ?>"><?= $date ?></span> | ||
22 | </p> | ||
16 | </div> | 23 | </div> |
24 | <?= $date_buttons ?> | ||
17 | <div class="article_admin_zone"> | 25 | <div class="article_admin_zone"> |
26 | <?= $from_to_button ?> | ||
18 | <?= $admin_buttons ?> | 27 | <?= $admin_buttons ?> |
19 | </div> | 28 | </div> |
20 | </div> | 29 | </div> |