diff options
| author | polo <ordipolo@gmx.fr> | 2025-04-02 00:00:35 +0200 |
|---|---|---|
| committer | polo <ordipolo@gmx.fr> | 2025-04-02 00:00:35 +0200 |
| commit | e4a325c9d5c07f09bc18b7e366ffb82b82c43502 (patch) | |
| tree | b30c9c91106ebdbeef988c2c1ebd955b62051be2 /src/controller/ajax.php | |
| parent | e91841c4e678f955e1a44bf0fa0839e84f0aacd0 (diff) | |
| download | cms-e4a325c9d5c07f09bc18b7e366ffb82b82c43502.tar.gz cms-e4a325c9d5c07f09bc18b7e366ffb82b82c43502.tar.bz2 cms-e4a325c9d5c07f09bc18b7e366ffb82b82c43502.zip | |
modification des titres, aperçus et dates des news
Diffstat (limited to 'src/controller/ajax.php')
| -rw-r--r-- | src/controller/ajax.php | 45 |
1 files changed, 38 insertions, 7 deletions
diff --git a/src/controller/ajax.php b/src/controller/ajax.php index bcba3f2..86acd39 100644 --- a/src/controller/ajax.php +++ b/src/controller/ajax.php | |||
| @@ -14,16 +14,32 @@ if($_SERVER['CONTENT_TYPE'] === 'application/json' && isset($_GET['action'])) | |||
| 14 | { | 14 | { |
| 15 | if(json_last_error() === JSON_ERROR_NONE) | 15 | if(json_last_error() === JSON_ERROR_NONE) |
| 16 | { | 16 | { |
| 17 | $articleId = $json['id']; | 17 | $id = $json['id']; |
| 18 | $id[0] = 'i'; | ||
| 18 | $content = Security::secureString($json['content']); | 19 | $content = Security::secureString($json['content']); |
| 19 | 20 | ||
| 20 | $director = new Director($entityManager); | 21 | $director = new Director($entityManager); |
| 21 | if($director->makeArticleNode($articleId)) // une entrée est trouvée | 22 | if($director->makeArticleNode($id)) // une entrée est trouvée |
| 22 | { | 23 | { |
| 23 | $node = $director->getRootNode(); | 24 | $node = $director->getRootNode(); |
| 24 | $node->getArticle()->setContent($content); | 25 | switch($json['id'][0]){ |
| 26 | case 'i': | ||
| 27 | $node->getArticle()->setContent($content); | ||
| 28 | break; | ||
| 29 | case 'p': | ||
| 30 | $node->getArticle()->setPreview($content); // html de l'éditeur | ||
| 31 | break; | ||
| 32 | case 't': | ||
| 33 | $node->getArticle()->setTitle($content); // html de l'éditeur | ||
| 34 | break; | ||
| 35 | case 'd': | ||
| 36 | echo json_encode(['success' => false, 'message' => 'l\'action editor_submit ne supporte pas les dates, utiliser date_submit.']); | ||
| 37 | die; | ||
| 38 | default: | ||
| 39 | echo json_encode(['success' => false, 'message' => 'identifiant non utilisable']); | ||
| 40 | die; | ||
| 41 | } | ||
| 25 | $entityManager->flush(); | 42 | $entityManager->flush(); |
| 26 | |||
| 27 | echo json_encode(['success' => true]); | 43 | echo json_encode(['success' => true]); |
| 28 | } | 44 | } |
| 29 | else{ | 45 | else{ |
| @@ -37,16 +53,16 @@ if($_SERVER['CONTENT_TYPE'] === 'application/json' && isset($_GET['action'])) | |||
| 37 | } | 53 | } |
| 38 | elseif($_GET['action'] === 'delete_article' && isset($json['id'])) | 54 | elseif($_GET['action'] === 'delete_article' && isset($json['id'])) |
| 39 | { | 55 | { |
| 40 | $articleId = $json['id']; | 56 | $id = $json['id']; |
| 41 | 57 | ||
| 42 | $director = new Director($entityManager); | 58 | $director = new Director($entityManager); |
| 43 | $director->makeArticleNode($articleId); | 59 | $director->makeArticleNode($id); |
| 44 | $node = $director->getRootNode(); | 60 | $node = $director->getRootNode(); |
| 45 | $entityManager->remove($node); | 61 | $entityManager->remove($node); |
| 46 | $entityManager->flush(); | 62 | $entityManager->flush(); |
| 47 | 63 | ||
| 48 | // test avec une nouvelle requête qui ne devrait rien trouver | 64 | // test avec une nouvelle requête qui ne devrait rien trouver |
| 49 | if(!$director->makeArticleNode($articleId)) | 65 | if(!$director->makeArticleNode($id)) |
| 50 | { | 66 | { |
| 51 | echo json_encode(['success' => true]); | 67 | echo json_encode(['success' => true]); |
| 52 | 68 | ||
| @@ -75,6 +91,21 @@ if($_SERVER['CONTENT_TYPE'] === 'application/json' && isset($_GET['action'])) | |||
| 75 | echo json_encode(['success' => true]); | 91 | echo json_encode(['success' => true]); |
| 76 | die; | 92 | die; |
| 77 | } | 93 | } |
| 94 | elseif($_GET['action'] === 'date_submit' && isset($json['id']) && isset($json['date'])) | ||
| 95 | { | ||
| 96 | $id = $json['id']; | ||
| 97 | $id[0] = 'i'; | ||
| 98 | $date = new DateTime($json['date']); | ||
| 99 | |||
| 100 | $director = new Director($entityManager); | ||
| 101 | $director->makeArticleNode($id); | ||
| 102 | $node = $director->getRootNode(); | ||
| 103 | $node->getArticle()->setDateTime($date); | ||
| 104 | $entityManager->flush(); | ||
| 105 | |||
| 106 | echo json_encode(['success' => true]); | ||
| 107 | die; | ||
| 108 | } | ||
| 78 | } | 109 | } |
| 79 | 110 | ||
| 80 | // détection des requêtes d'upload d'image de tinymce | 111 | // détection des requêtes d'upload d'image de tinymce |
