This commit is contained in:
root 2021-10-26 15:21:20 +02:00
commit 6909f1f6bd
5 changed files with 41 additions and 12 deletions

View File

@ -7,8 +7,10 @@ return;
* Importation du JSON des chapitres * Importation du JSON des chapitres
* et des autres informations (durée, taille, etc) * et des autres informations (durée, taille, etc)
***************************************/ ***************************************/
include_spip('inc/actions');
function action_importer_emission_dist($arg = null) { function action_importer_emission_dist($arg = null) {
if (!$arg) { if (!$arg) {
$securiser_action = charger_fonction('securiser_action', 'inc'); $securiser_action = charger_fonction('securiser_action', 'inc');
$arg = $securiser_action(); $arg = $securiser_action();
@ -152,7 +154,8 @@ function action_importer_emission_dist($arg = null) {
if (count($erreurs) > 0) { if (count($erreurs) > 0) {
$texteReponse .= "<br><br>Erreurs : <br>".implode(" <br> ", $erreurs); $texteReponse .= "<br><br>Erreurs : <br>".implode(" <br> ", $erreurs);
} }
return $texteReponse; // return $texteReponse;
ajax_retour($texteReponse, false);
} }
function libreavous_import_getDuration($code_emission, $code_sujet) { function libreavous_import_getDuration($code_emission, $code_sujet) {

View File

@ -102,7 +102,7 @@ function libreavous_import_run($id_article) {
$jsonContents = file_get_contents("https://forge.april.org/libreavous/lav-outils/raw/branch/master/podcasts/config/lav-".$code_emission.".json"); $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); $json = json_decode($jsonContents, true);
if (!$json) { 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) { } catch (Exception $e) {
$erreurs[] = $e->getMessage(); $erreurs[] = $e->getMessage();

View File

@ -80,8 +80,32 @@ function libreavous_boite_infos($flux) {
} }
} }
if ($flux['args']['type'] == 'article' and $id_article = $flux['args']['id'] and autoriser('instituer', 'article', $id_article)) { return $flux;
$flux['data'] .= recuperer_fond('prive/squelettes/inclure/importer_emission', array('id_article'=>$id_article)); }
/**
* Afficher des choses au milieu de la page
*
* @pipeline affiche_milieu
* @param array $flux Données du pipeline
* @return array Données du pipeline
**/
function libreavous_affiche_milieu($flux) {
$texte = '';
$e = trouver_objet_exec($flux['args']['exec']);
if ($e and !$e['edition'] and in_array($e['type'], array('article')) ) {
$texte .= recuperer_fond('prive/squelettes/inclure/importer_emission', array(
'id_article' => $flux['args'][$e['id_table_objet']]
));
}
if ($texte) {
if ($p = strpos($flux['data'], '<!--affiche_milieu-->')) {
$flux['data'] = substr_replace($flux['data'], $texte, $p, 0);
} else {
$flux['data'] .= $texte;
}
} }
return $flux; return $flux;

View File

@ -28,6 +28,7 @@
<pipeline nom="affiche_enfants" inclure="libreavous_pipelines.php" /> <pipeline nom="affiche_enfants" inclure="libreavous_pipelines.php" />
<pipeline nom="boite_infos" inclure="libreavous_pipelines.php" /> <pipeline nom="boite_infos" inclure="libreavous_pipelines.php" />
<pipeline nom="objet_compte_enfants" inclure="libreavous_pipelines.php" /> <pipeline nom="objet_compte_enfants" inclure="libreavous_pipelines.php" />
<pipeline nom="affiche_milieu" inclure="libreavous_pipelines.php" />
<!-- <menu nom="configurer_librealire" titre="librealire:options_lal" parent="menu_squelette" icone="images/baz_april-16.png" /> --> <!-- <menu nom="configurer_librealire" titre="librealire:options_lal" parent="menu_squelette" icone="images/baz_april-16.png" /> -->

View File

@ -1,2 +1,3 @@
<div class="ajax">
[(#BOUTON_ACTION{<:libreavous:importer_l_emission:>,#URL_ACTION_AUTEUR{importer_emission,#ID_ARTICLE,#SELF}})] [(#BOUTON_ACTION{<:libreavous:importer_l_emission:>,#URL_ACTION_AUTEUR{importer_emission,#ID_ARTICLE}, 'ajax', 'Confirmer ou annuler limport'})]
</div>