diff options
Diffstat (limited to 'src/view/NewBuilder.php')
-rw-r--r-- | src/view/NewBuilder.php | 68 |
1 files changed, 53 insertions, 15 deletions
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(); |