Correction du nom de la chronique non traité

This commit is contained in:
Vincent Calame 2021-10-27 16:45:55 +02:00 committed by root
parent cbd6b6ced4
commit 9470f57bde
2 changed files with 22 additions and 3 deletions

View File

@ -28,6 +28,7 @@ function action_importer_emission_dist($arg = null) {
return "Émission inconnue = ".$id_article;
}
$erreurs = array();
$logs = array();
$json = false;
$podcast_duree = "";
$ogg_size = "";
@ -36,7 +37,7 @@ function action_importer_emission_dist($arg = null) {
$jsonContents = file_get_contents("https://forge.april.org/libreavous/lav-outils/raw/branch/master/podcasts/config/lav-".$code_emission.".json");
$json = json_decode($jsonContents, true);
if (!$json) {
$erreurs[] = "JSON incorrect";
$erreurs[] = "JSON incorrect : https://forge.april.org/libreavous/lav-outils/raw/branch/master/podcasts/config/lav-".$code_emission.".json";
}
} catch (Exception $e) {
$erreurs[] = $e->getMessage();
@ -125,6 +126,7 @@ function action_importer_emission_dist($arg = null) {
'podcast_mp3' => $mp3_size,
'podcast_ogg' => $ogg_size
);
$logs[] = sql_updateq("spip_articles", $emissionArray, "id_article=".$id_article,'','',false);
sql_updateq("spip_articles", $emissionArray, "id_article=".$id_article);
foreach ($chapitres as $chapitre) {
$code_chapitre = $chapitre["short_chapter_name"];
@ -145,14 +147,29 @@ function action_importer_emission_dist($arg = null) {
if ($chapitreExistant and sql_count($chapitreExistant)>0) {
$r = sql_fetch($chapitreExistant);
$id_chapitre = $r["id_chapitre"];
$logs[] = sql_updateq("spip_chapitres", $chapitreArray, "id_chapitre=".$id_chapitre,'','',false);
sql_updateq("spip_chapitres", $chapitreArray, "id_chapitre=".$id_chapitre);
} else {
$logs[] = sql_insertq("spip_chapitres", $chapitreArray, '', '', false);
$id_nouveau_chapitre = sql_insertq("spip_chapitres", $chapitreArray);
}
}
$texteReponse = "Émission traitée : ". $code_emission;
$texteReponse = "<p>Émission traitée : ". $code_emission." / ".$titre_emission."</p>";
if (count($erreurs) > 0) {
$texteReponse .= "<br><br>Erreurs : <br>".implode(" <br> ", $erreurs);
$texteReponse .= "<h2>Erreurs</h2>";
$texteReponse .= "<ul>";
foreach ($erreurs as $erreur) {
$texteReponse .= "<li><p>".$erreur."</p></li>";
}
$texteReponse .= "</ul>";
}
if (count($logs) > 0) {
$texteReponse .= "<h2>Requêtes effectuées</h2>";
$texteReponse .= "<ul>";
foreach ($logs as $log) {
$texteReponse .= "<li><p>".$log."</p></li>";
}
$texteReponse .= "</ul>";
}
// return $texteReponse;
ajax_retour($texteReponse, false);
@ -205,6 +222,7 @@ function libreavous_import_checkType($chapitre) {
if ($idx === 0) {
$result[] = "CH";
$nom_chronique = substr($code, strlen("chronique-"));
$result[] = $nom_chronique;
} else {
$result[] = "SC";
}

View File

@ -286,6 +286,7 @@ function libreavous_import_checkType($chapitre) {
if ($idx === 0) {
$result[] = "CH";
$nom_chronique = substr($code, strlen("chronique-"));
$result[] = $nom_chronique;
} else {
$result[] = "SC";
}