From c79868282c7fd835d6216815816f240b90a7ad4e Mon Sep 17 00:00:00 2001 From: Quentin Marchand <114567503+QuentinEcollectivites@users.noreply.github.com> Date: Thu, 16 May 2024 09:33:24 +0200 Subject: [PATCH] Delete alerte_module_pleiade directory --- .../alerte_module_pleiade.info.yml | 12 -- .../alerte_module_pleiade.install | 117 ------------------ .../alerte_module_pleiade.libraries.yml | 11 -- .../alerte_module_pleiade.links.menu.yml | 7 -- .../alerte_module_pleiade.module | 14 --- .../alerte_module_pleiade.routing.yml | 8 -- .../css/alerte_module_pleiade.css | 10 -- .../js/alerte_module_pleiade.js | 53 -------- alerte_module_pleiade/readme.md | 8 -- .../src/Controller/AlerteModuleController.php | 47 ------- 10 files changed, 287 deletions(-) delete mode 100644 alerte_module_pleiade/alerte_module_pleiade.info.yml delete mode 100644 alerte_module_pleiade/alerte_module_pleiade.install delete mode 100644 alerte_module_pleiade/alerte_module_pleiade.libraries.yml delete mode 100644 alerte_module_pleiade/alerte_module_pleiade.links.menu.yml delete mode 100644 alerte_module_pleiade/alerte_module_pleiade.module delete mode 100644 alerte_module_pleiade/alerte_module_pleiade.routing.yml delete mode 100644 alerte_module_pleiade/css/alerte_module_pleiade.css delete mode 100644 alerte_module_pleiade/js/alerte_module_pleiade.js delete mode 100644 alerte_module_pleiade/readme.md delete mode 100644 alerte_module_pleiade/src/Controller/AlerteModuleController.php diff --git a/alerte_module_pleiade/alerte_module_pleiade.info.yml b/alerte_module_pleiade/alerte_module_pleiade.info.yml deleted file mode 100644 index 062be92..0000000 --- a/alerte_module_pleiade/alerte_module_pleiade.info.yml +++ /dev/null @@ -1,12 +0,0 @@ -name: 'Module Alerte Pleiade' -type: module -description: 'Message entête pour Pléiade' -package: Pleiade -# version: 8.x + -core: 8.x -core_version_requirement: ^9.5 || ^10 || ^10 - -# Information -version: '1.0.x-dev' -project: 'alerte_module_pleiade' -datestamp: 1624364473 diff --git a/alerte_module_pleiade/alerte_module_pleiade.install b/alerte_module_pleiade/alerte_module_pleiade.install deleted file mode 100644 index e9c3cbe..0000000 --- a/alerte_module_pleiade/alerte_module_pleiade.install +++ /dev/null @@ -1,117 +0,0 @@ - 'message_informatif', - 'name' => 'Message informatif', - 'description' => 'Type de contenu pour les messages informatif à afficher en haut du bureau.', - 'display_submitted' => TRUE, - 'preview_mode' => 'default', - 'help' => '', - ]); - $news_type->save(); - - // Ajouter un champ 'description'. - $field_description_storage = \Drupal\field\Entity\FieldStorageConfig::create([ - 'field_name' => 'field_message_a_afficher', - 'entity_type' => 'node', - 'type' => 'text_long', - ]); - $field_description_storage->save(); - - $field_description_instance = \Drupal\field\Entity\FieldConfig::create([ - 'field_storage' => $field_description_storage, - 'bundle' => 'message_informatif', - 'label' => 'Description', - 'required' => TRUE, - // Spécifier le format de texte complet HTML. - 'settings' => [ - 'text_processing' => 0, - ], - ]); - $field_description_instance->save(); - - $field_nom_storage = \Drupal\field\Entity\FieldStorageConfig::create([ - 'field_name' => 'field_importance_du_message', - 'entity_type' => 'node', - 'type' => 'list_string', // Utiliser le type 'list_string' pour une liste de chaînes. - 'settings' => [ - 'allowed_values' => [ - 'Informatif' => 'Informatif', - 'Avertissement' => 'Avertissement', - 'Attention' => 'Attention', - ], - ], - ]); - $field_nom_storage->save(); - - $field_nom_instance = \Drupal\field\Entity\FieldConfig::create([ - 'field_storage' => $field_nom_storage, - 'bundle' => 'message_informatif', - 'label' => 'Importance du message', - 'required' => FALSE, - ]); - $field_nom_instance->save(); - - // Activer les champs sur le formulaire d'affichage du type de contenu. - $entity_display_repository = \Drupal::service('entity_display.repository'); - $form_display = $entity_display_repository->getFormDisplay('node', 'message_informatif', 'default'); - - // Activer l'affichage du champ 'field_description'. - $form_display->setComponent('field_message_a_afficher', ['type' => 'text_textarea']); - - // Activer l'affichage du champ 'field_importance_du_message'. - $form_display->setComponent('field_importance_du_message', ['type' => 'text_textfield']); - - $form_display->save(); - // Vider le cache pour appliquer les changements. - drupal_flush_all_caches(); - } -} - -/** - * Implements hook_uninstall(). - */ -function alerte_module_pleiade_uninstall() -{ - // Delete all nodes of type 'message_informatif'. - $query = \Drupal::entityQuery('node') - ->condition('type', 'message_informatif') - ->accessCheck(TRUE); - $nids = $query->execute(); - $query = \Drupal::entityQuery('node') - ->condition('type', 'message_informatif') - ->accessCheck(FALSE); // Disable access checks for uninstallation. - $nids = $query->execute(); - - foreach ($nids as $nid) { - $node = \Drupal\node\Entity\Node::load($nid); - if ($node) { - $node->delete(); - } - } - - // Check if the field exists before attempting to delete it. - if ($field_description = \Drupal\field\Entity\FieldStorageConfig::loadByName('node', 'field_message_a_afficher')) { - $field_description->delete(); - } - if ($field_description = \Drupal\field\Entity\FieldStorageConfig::loadByName('node', 'field_importance_du_message')) { - $field_description->delete(); - } - - // Delete the type of content. - if ($node_type = \Drupal::entityTypeManager()->getStorage('node_type')->load('message_informatif')) { - $node_type->delete(); - } - - // Clear the cache to apply the changes. - \Drupal::entityTypeManager()->clearCachedDefinitions(); - // Cache la configuration pour que les changements prennent effet. - drupal_flush_all_caches(); -} - diff --git a/alerte_module_pleiade/alerte_module_pleiade.libraries.yml b/alerte_module_pleiade/alerte_module_pleiade.libraries.yml deleted file mode 100644 index 5dbc284..0000000 --- a/alerte_module_pleiade/alerte_module_pleiade.libraries.yml +++ /dev/null @@ -1,11 +0,0 @@ -alerte_module_pleiade_js: - js: - js/alerte_module_pleiade.js: {} - dependencies: - - core/drupal - - core/once -alerte_module_pleiade_css: - version: 1.x - css: - theme: - css/alerte_module_pleiade.css: {} diff --git a/alerte_module_pleiade/alerte_module_pleiade.links.menu.yml b/alerte_module_pleiade/alerte_module_pleiade.links.menu.yml deleted file mode 100644 index fea2849..0000000 --- a/alerte_module_pleiade/alerte_module_pleiade.links.menu.yml +++ /dev/null @@ -1,7 +0,0 @@ -# alerte_module_pleiade.admin: -# title: 'API Pléiade - Alerte Module Pléiade' -# description: 'Page de configuration du module Alerte Pléiade' -# parent: pleiade.group.admin -# route_name: alerte_module_pleiade.settings -# weight: 999 - diff --git a/alerte_module_pleiade/alerte_module_pleiade.module b/alerte_module_pleiade/alerte_module_pleiade.module deleted file mode 100644 index 4bf951c..0000000 --- a/alerte_module_pleiade/alerte_module_pleiade.module +++ /dev/null @@ -1,14 +0,0 @@ - 0) { - const div_alert = document.querySelector('.message_avertissement'); - for (var i = 0; i < donnees.length; i++) { - switch (donnees[i].importance) { - case "Informatif": - div_alert.innerHTML += '
' + donnees[i].field_message_a_afficher + '
'; - break; - case "Avertissement": - div_alert.innerHTML += '
' + donnees[i].field_message_a_afficher + '
'; - break; - case "Attention": - div_alert.innerHTML += '
' + donnees[i].field_message_a_afficher + '
'; - break; - default: - break; - } - } - } - }; - xhr.onerror = function () { - console.log("Error making AJAX call"); - }; - xhr.onabort = function () { - console.log("AJAX call aborted"); - }; - xhr.ontimeout = function () { - console.log("AJAX call timed out"); - }; - xhr.onloadend = function () { - } - }; - xhr.send(); - }); // end once - - }, - }; -})(Drupal, drupalSettings, once); \ No newline at end of file diff --git a/alerte_module_pleiade/readme.md b/alerte_module_pleiade/readme.md deleted file mode 100644 index 3cdc05b..0000000 --- a/alerte_module_pleiade/readme.md +++ /dev/null @@ -1,8 +0,0 @@ -Pour fonctionner, il est nécéssaire de créer un type de contenu côté Drupal, pour récupérer et afficher les contenus créés par l'administrateur. - -Le type de contenu à créer se nomme "Message Informatif", dont le nom système est "message_informatif". (/admin/structure/types/add) - -Pour ce type de contenu, il faut créer deux champs : - -- Un champ texte (brut) appelé 'Body' dont le nom sysème est "body" -- Un champ liste (texte) "Importance du message" dont le nom système est "field_importance_du_message" diff --git a/alerte_module_pleiade/src/Controller/AlerteModuleController.php b/alerte_module_pleiade/src/Controller/AlerteModuleController.php deleted file mode 100644 index aea3e4c..0000000 --- a/alerte_module_pleiade/src/Controller/AlerteModuleController.php +++ /dev/null @@ -1,47 +0,0 @@ -moduleExists('alerte_module_pleiade')) { - $this->settings_message = \Drupal::config('alerte_module_pleiade.settings'); - } - } - - public function message_fields(Request $request) - { - $entityTypeManager = \Drupal::entityTypeManager(); - $query = $entityTypeManager->getStorage('node')->getQuery(); - $query->condition('type', 'message_informatif'); - $query->condition('status', 1); // Published content condition - $query->accessCheck(FALSE); - $entityIds = $query->execute(); - $messages = $entityTypeManager->getStorage('node')->loadMultiple($entityIds); - - $msg = []; - - foreach ($messages as $message) { - $body = $message->get('field_message_a_afficher')->value; - $importance = $message->get('field_importance_du_message')->value; - - $msg[] = [ - 'field_message_a_afficher' => $body, - 'importance' => $importance, - ]; - } - - return new JsonResponse(json_encode($msg), 200, [], true); - } - - -}