Skip to content
This repository has been archived by the owner on Jan 11, 2020. It is now read-only.

Commit

Permalink
Ajout d'un pipeline post_affectation_plugin.
Browse files Browse the repository at this point in the history
Mise à jour du fichier json categorie-plugin de tests.
Ajout du traitement des erreurs json lors de l'importation.
  • Loading branch information
smellup committed Jul 28, 2019
1 parent 2bfd86a commit 218efeb
Show file tree
Hide file tree
Showing 4 changed files with 1,106 additions and 599 deletions.
10 changes: 8 additions & 2 deletions formulaires/importer_typologie.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ function formulaires_importer_typologie_traiter($typologie) {
// Initialisation du retour de traitement du formulaire (message, editable).
$retour = array();
$resultat_import = false;
$erreur_json = '';

// Récupération des saisies
$vue = _request('vue_import');
Expand All @@ -98,7 +99,11 @@ function formulaires_importer_typologie_traiter($typologie) {
@unlink($fichier);

// -- Décodage du contenu JSON en tableau PHP.
$liste = json_decode($contenu, true);
try {
$liste = json_decode($contenu, true);
} catch (Exception $erreur) {
$erreur_json = $erreur->getMessage();
}

// -- Importation du tableau représentant la typologie.
if ($liste) {
Expand All @@ -125,7 +130,8 @@ function formulaires_importer_typologie_traiter($typologie) {
$vue
);
} else {
$retour['message_erreur'] = _T('svptype:import_message_nok');
$retour['message_erreur'] = _T('svptype:import_message_nok')
. ($erreur_json ? "(${erreur_json})" : '');
// On reste sur la page d'importation pour visualiser l'erreur.
$redirect = '';
}
Expand Down
12 changes: 12 additions & 0 deletions inc/svptype_plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,18 @@ function plugin_affecter($plugin, $id_mot, $typologie) {
);
if (sql_insertq('spip_plugins_typologies', $set) === false) {
$retour = false;
} else {
pipeline(
'post_affectation_plugin',
array(
'args' => array(
'typologie' => $typologie,
'prefixe' => $prefixe,
'id_mot' => $id_mot,
),
'data' => array()
)
);
}

return $retour;
Expand Down
3 changes: 2 additions & 1 deletion paquet.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<paquet
prefix="svptype"
categorie="outil"
version="0.2.0"
version="0.2.1"
etat="test"
compatibilite="[3.3.0-dev;3.3.*]"
logo="svptype_logo-64.png"
Expand Down Expand Up @@ -29,6 +29,7 @@
<pipeline nom="declarer_collections_svp" inclure="svptype_pipelines.php" />
<pipeline nom="post_collection_svp" inclure="svptype_pipelines.php" />
<pipeline nom="post_ressource_svp" inclure="svptype_pipelines.php" />
<pipeline nom="post_affectation_plugin" action="" />

<necessite nom="svp" compatibilite="[2.0.7;[" />
<necessite nom="mots" compatibilite="[2.11.0;[" />
Expand Down
Loading

0 comments on commit 218efeb

Please sign in to comment.