diff options
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); |
