From 1937a2f49ebe920b79604cb5df3649f9f1dff738 Mon Sep 17 00:00:00 2001 From: polo-pc-greta Date: Mon, 7 Apr 2025 21:38:12 +0200 Subject: =?UTF-8?q?bouton=20suppression=20apr=C3=A8s=20cr=C3=A9ation=20d'u?= =?UTF-8?q?ne=20"news"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Config.php | 2 +- src/controller/ajax.php | 9 --------- src/view/MainBuilder.php | 5 +---- src/view/NewBuilder.php | 17 ++++++++++------- src/view/templates/new.php | 8 ++++---- 5 files changed, 16 insertions(+), 25 deletions(-) (limited to 'src') 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 // classe URL static public string $protocol = 'http'; - //static public string $host = ''; + static public string $index_path = ''; static public string $port = '80'; // 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'])) } else{ $content = Security::secureString($json['content']); - if($content === ''){ - echo json_encode(['success' => false, 'message' => 'pas de données à sauvegarder']); - die; - } } // nouvel article @@ -43,12 +39,7 @@ if($_SERVER['CONTENT_TYPE'] === 'application/json' && isset($_GET['action'])) $node = $director->getNode(); // =
if(is_array($content)){ - // - //$timestamp = time(); // int $date = new \DateTime($content['d']); - - //echo substr($content['i'], 1) . ' '; - //echo $article_id;die; $article = new Article($content['i'], $date, $content['t'], $content['p']); $article_node = new Node('new', 'i' . (string)$date->getTimestamp(), [], count($node->getChildren()) + 1, $node, $node->getPage(), $article); 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 } if($node->getAdoptedChild() == null){ - // on pourrait raccourcir ça - $timestamp = time(); // int $date = new \DateTime; - $date->setTimestamp($timestamp); // \DateTime $article = new Article('', $date); - $new = new Node('new', 'i' . (string)$timestamp, [], 0, null, null, $article); + $new = new Node('new', 'i' . (string)$date->getTimestamp(), [], 0, null, null, $article); } else{ $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 $delete_article = ''; $submit_article = ''; - // modification: bouton "supprimer" - if($_GET['id'][0] === 'i'){ - $delete_js = 'onclick="deleteArticle(\'' . $id . '\', \'' . Director::$page_path->getLast()->getEndOfPath() . '\')"'; - $delete_article = '

' . "\n"; - } + $delete_class = ''; // nouvel article: bouton pour valider la création d'un nouvel article - else{ + if($_GET['id'][0] != 'i'){ $submit_js = 'onclick="submitArticle(\'' . $_GET['id'] . '\', \'' . Director::$page_path->getLast()->getEndOfPath() . '\')"'; - $submit_article = '

' . "\n"; + $submit_article = '

' . "\n"; + $delete_class = 'class="hidden"'; + } + // modification: bouton "supprimer" + else{ + $delete_class = 'class=""'; } + $delete_js = 'onclick="deleteArticle(\'' . $id . '\', \'' . Director::$page_path->getLast()->getEndOfPath() . '\')"'; + $delete_article = '

' . "\n"; $admin_buttons = $delete_article . $submit_article; } 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 @@
-
+
-
+
-
+

- +

-- cgit v1.2.3