diff options
author | polo <ordipolo@gmx.fr> | 2025-09-18 00:27:20 +0200 |
---|---|---|
committer | polo <ordipolo@gmx.fr> | 2025-09-18 00:27:20 +0200 |
commit | fa3c582a2bd91433399a5b275616052028a5a011 (patch) | |
tree | 64a5c2c0eb54dc033fb5ed78ed69745bd492aa05 /src/controller/ArticleController.php | |
parent | 027af942de75f7c5bc519fabfa5fa11de9bc89ea (diff) | |
download | cms-fa3c582a2bd91433399a5b275616052028a5a011.zip |
news positionnées en fonction de leur date, suppression de leurs boutons position, améliorations routage page article, bouton share en bas pour les news
Diffstat (limited to 'src/controller/ArticleController.php')
-rw-r--r-- | src/controller/ArticleController.php | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/controller/ArticleController.php b/src/controller/ArticleController.php index cb132cf..411c1dc 100644 --- a/src/controller/ArticleController.php +++ b/src/controller/ArticleController.php | |||
@@ -36,14 +36,19 @@ class ArticleController | |||
36 | if($json['id'][0] === 'n') // ici $id est un bloc | 36 | if($json['id'][0] === 'n') // ici $id est un bloc |
37 | { | 37 | { |
38 | $section_id = (int)substr($id, 1); // id du bloc <section> | 38 | $section_id = (int)substr($id, 1); // id du bloc <section> |
39 | if(!$director->findNodeById($section_id)){ | 39 | if(!$director->findNodeById($section_id)){ // erreur mauvais id |
40 | echo json_encode(['success' => false, 'error' => 'article_not_saved']); | 40 | echo json_encode(['success' => false, 'error' => 'article_not_saved, bad id']); |
41 | die; | 41 | die; |
42 | } | 42 | } |
43 | $director->makeSectionNode(); | 43 | $director->makeSectionNode(); |
44 | $node = $director->getNode(); // = <section> | 44 | $node = $director->getNode(); // = <section> |
45 | 45 | ||
46 | if(is_array($content)){ // cas d'une nouvelle "news" | 46 | if(is_array($content)){ // cas d'une nouvelle "news" |
47 | if($node->getPage()->getEndOfPath() !== $json['from']){ // erreur mauvais from | ||
48 | echo json_encode(['success' => false, 'error' => 'article_not_saved, bad from']); | ||
49 | die; | ||
50 | } | ||
51 | |||
47 | $date = new \DateTime($content['d'] . ':' . (new \DateTime)->format('s')); // l'input type="datetime-local" ne donne pas les secondes, on les ajoute: 'hh:mm' . ':ss' | 52 | $date = new \DateTime($content['d'] . ':' . (new \DateTime)->format('s')); // l'input type="datetime-local" ne donne pas les secondes, on les ajoute: 'hh:mm' . ':ss' |
48 | $article = new Article($content['i'], $date, $content['t'], $content['p']); | 53 | $article = new Article($content['i'], $date, $content['t'], $content['p']); |
49 | $article_node = new Node('new', [], count($node->getChildren()) + 1, $node, $node->getPage(), $article); | 54 | $article_node = new Node('new', [], count($node->getChildren()) + 1, $node, $node->getPage(), $article); |