diff options
| author | polo-pc-greta <ordipolo@gmx.fr> | 2025-04-07 21:38:12 +0200 |
|---|---|---|
| committer | polo-pc-greta <ordipolo@gmx.fr> | 2025-04-07 21:38:12 +0200 |
| commit | 1937a2f49ebe920b79604cb5df3649f9f1dff738 (patch) | |
| tree | fac9a39aae9690b0e5a860bdb2cc88565e83daac /src | |
| parent | 09bea09c8157ff45279f0d06aa9d313448c0bec5 (diff) | |
| download | cms-1937a2f49ebe920b79604cb5df3649f9f1dff738.tar.gz cms-1937a2f49ebe920b79604cb5df3649f9f1dff738.tar.bz2 cms-1937a2f49ebe920b79604cb5df3649f9f1dff738.zip | |
bouton suppression après création d'une "news"
Diffstat (limited to 'src')
| -rw-r--r-- | src/Config.php | 2 | ||||
| -rw-r--r-- | src/controller/ajax.php | 9 | ||||
| -rw-r--r-- | src/view/MainBuilder.php | 5 | ||||
| -rw-r--r-- | src/view/NewBuilder.php | 17 | ||||
| -rw-r--r-- | src/view/templates/new.php | 8 |
5 files changed, 16 insertions, 25 deletions
diff --git a/src/Config.php b/src/Config.php index 882ec98..500d6ea 100644 --- a/src/Config.php +++ b/src/Config.php | |||
| @@ -15,7 +15,7 @@ class Config | |||
| 15 | 15 | ||
| 16 | // classe URL | 16 | // classe URL |
| 17 | static public string $protocol = 'http'; | 17 | static public string $protocol = 'http'; |
| 18 | //static public string $host = ''; | 18 | static public string $index_path = ''; |
| 19 | static public string $port = '80'; | 19 | static public string $port = '80'; |
| 20 | 20 | ||
| 21 | // copier dans ce tableau les variables contenant des chemins | 21 | // copier dans ce tableau les variables contenant des chemins |
diff --git a/src/controller/ajax.php b/src/controller/ajax.php index 4863681..a4b61e4 100644 --- a/src/controller/ajax.php +++ b/src/controller/ajax.php | |||
| @@ -29,10 +29,6 @@ if($_SERVER['CONTENT_TYPE'] === 'application/json' && isset($_GET['action'])) | |||
| 29 | } | 29 | } |
| 30 | else{ | 30 | else{ |
| 31 | $content = Security::secureString($json['content']); | 31 | $content = Security::secureString($json['content']); |
| 32 | if($content === ''){ | ||
| 33 | echo json_encode(['success' => false, 'message' => 'pas de données à sauvegarder']); | ||
| 34 | die; | ||
| 35 | } | ||
| 36 | } | 32 | } |
| 37 | 33 | ||
| 38 | // nouvel article | 34 | // nouvel article |
| @@ -43,12 +39,7 @@ if($_SERVER['CONTENT_TYPE'] === 'application/json' && isset($_GET['action'])) | |||
| 43 | $node = $director->getNode(); // = <section> | 39 | $node = $director->getNode(); // = <section> |
| 44 | 40 | ||
| 45 | if(is_array($content)){ | 41 | if(is_array($content)){ |
| 46 | // | ||
| 47 | //$timestamp = time(); // int | ||
| 48 | $date = new \DateTime($content['d']); | 42 | $date = new \DateTime($content['d']); |
| 49 | |||
| 50 | //echo substr($content['i'], 1) . ' '; | ||
| 51 | //echo $article_id;die; | ||
| 52 | $article = new Article($content['i'], $date, $content['t'], $content['p']); | 43 | $article = new Article($content['i'], $date, $content['t'], $content['p']); |
| 53 | $article_node = new Node('new', 'i' . (string)$date->getTimestamp(), [], count($node->getChildren()) + 1, $node, $node->getPage(), $article); | 44 | $article_node = new Node('new', 'i' . (string)$date->getTimestamp(), [], count($node->getChildren()) + 1, $node, $node->getPage(), $article); |
| 54 | 45 | ||
diff --git a/src/view/MainBuilder.php b/src/view/MainBuilder.php index ea7b8c3..e73b298 100644 --- a/src/view/MainBuilder.php +++ b/src/view/MainBuilder.php | |||
| @@ -18,12 +18,9 @@ class MainBuilder extends AbstractBuilder | |||
| 18 | } | 18 | } |
| 19 | 19 | ||
| 20 | if($node->getAdoptedChild() == null){ | 20 | if($node->getAdoptedChild() == null){ |
| 21 | // on pourrait raccourcir ça | ||
| 22 | $timestamp = time(); // int | ||
| 23 | $date = new \DateTime; | 21 | $date = new \DateTime; |
| 24 | $date->setTimestamp($timestamp); // \DateTime | ||
| 25 | $article = new Article('', $date); | 22 | $article = new Article('', $date); |
| 26 | $new = new Node('new', 'i' . (string)$timestamp, [], 0, null, null, $article); | 23 | $new = new Node('new', 'i' . (string)$date->getTimestamp(), [], 0, null, null, $article); |
| 27 | } | 24 | } |
| 28 | else{ | 25 | else{ |
| 29 | $new = $node->getAdoptedChild(); | 26 | $new = $node->getAdoptedChild(); |
diff --git a/src/view/NewBuilder.php b/src/view/NewBuilder.php index a862a08..d93155e 100644 --- a/src/view/NewBuilder.php +++ b/src/view/NewBuilder.php | |||
| @@ -103,16 +103,19 @@ class NewBuilder extends AbstractBuilder | |||
| 103 | 103 | ||
| 104 | $delete_article = ''; | 104 | $delete_article = ''; |
| 105 | $submit_article = ''; | 105 | $submit_article = ''; |
| 106 | // modification: bouton "supprimer" | 106 | $delete_class = ''; |
| 107 | if($_GET['id'][0] === 'i'){ | ||
| 108 | $delete_js = 'onclick="deleteArticle(\'' . $id . '\', \'' . Director::$page_path->getLast()->getEndOfPath() . '\')"'; | ||
| 109 | $delete_article = '<p id="delete-' . $id . '"><button ' . $delete_js . '><img class="action_icon" src="assets/delete-bin.svg" ' . $delete_js . '>Retirer<br>la publication</button></p>' . "\n"; | ||
| 110 | } | ||
| 111 | // nouvel article: bouton pour valider la création d'un nouvel article | 107 | // nouvel article: bouton pour valider la création d'un nouvel article |
| 112 | else{ | 108 | if($_GET['id'][0] != 'i'){ |
| 113 | $submit_js = 'onclick="submitArticle(\'' . $_GET['id'] . '\', \'' . Director::$page_path->getLast()->getEndOfPath() . '\')"'; | 109 | $submit_js = 'onclick="submitArticle(\'' . $_GET['id'] . '\', \'' . Director::$page_path->getLast()->getEndOfPath() . '\')"'; |
| 114 | $submit_article = '<p id="submit-' . $id . '"><button ' . $submit_js . '><img class="action_icon" src="assets/edit.svg">Tout<br>enregistrer</button></p>' . "\n"; | 110 | $submit_article = '<p id="save-' . $id . '"><button ' . $submit_js . '><img class="action_icon" src="assets/edit.svg">Tout<br>enregistrer</button></p>' . "\n"; |
| 111 | $delete_class = 'class="hidden"'; | ||
| 112 | } | ||
| 113 | // modification: bouton "supprimer" | ||
| 114 | else{ | ||
| 115 | $delete_class = 'class=""'; | ||
| 115 | } | 116 | } |
| 117 | $delete_js = 'onclick="deleteArticle(\'' . $id . '\', \'' . Director::$page_path->getLast()->getEndOfPath() . '\')"'; | ||
| 118 | $delete_article = '<p ' . $delete_class . ' id="delete-' . $id . '"><button ' . $delete_js . '><img class="action_icon" src="assets/delete-bin.svg">Retirer<br>la publication</button></p>' . "\n"; | ||
| 116 | 119 | ||
| 117 | $admin_buttons = $delete_article . $submit_article; | 120 | $admin_buttons = $delete_article . $submit_article; |
| 118 | } | 121 | } |
diff --git a/src/view/templates/new.php b/src/view/templates/new.php index 9515c70..2a965cb 100644 --- a/src/view/templates/new.php +++ b/src/view/templates/new.php | |||
| @@ -2,23 +2,23 @@ | |||
| 2 | <div class="new_content"> | 2 | <div class="new_content"> |
| 3 | <div class="article_title_zone"> | 3 | <div class="article_title_zone"> |
| 4 | <?= $share_button ?> | 4 | <?= $share_button ?> |
| 5 | <div id="<?= $id_title ?>"> | 5 | <div class="data" id="<?= $id_title ?>"> |
| 6 | <?= $title ?> | 6 | <?= $title ?> |
| 7 | </div> | 7 | </div> |
| 8 | <?= $title_buttons ?> | 8 | <?= $title_buttons ?> |
| 9 | </div> | 9 | </div> |
| 10 | <div id="<?= $id_preview ?>" class="new_content_text"> | 10 | <div class="data" id="<?= $id_preview ?>" class="new_content_text"> |
| 11 | <?= $preview ?> | 11 | <?= $preview ?> |
| 12 | </div> | 12 | </div> |
| 13 | <?= $preview_buttons ?> | 13 | <?= $preview_buttons ?> |
| 14 | <div id="<?= $id ?>" class="article_content_text"> | 14 | <div class="data" id="<?= $id ?>" class="article_content_text"> |
| 15 | <?= $content ?> | 15 | <?= $content ?> |
| 16 | </div> | 16 | </div> |
| 17 | <?= $article_buttons ?> | 17 | <?= $article_buttons ?> |
| 18 | <div class="under_an_article"> | 18 | <div class="under_an_article"> |
| 19 | <p> | 19 | <p> |
| 20 | <img src="assets/calendar.svg"> | 20 | <img src="assets/calendar.svg"> |
| 21 | <span id="<?= $id_date ?>"><?= $date ?></span> | 21 | <span class="data" id="<?= $id_date ?>"><?= $date ?></span> |
| 22 | </p> | 22 | </p> |
| 23 | </div> | 23 | </div> |
| 24 | <?= $date_buttons ?> | 24 | <?= $date_buttons ?> |
