You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
123 lines
3.4 KiB
123 lines
3.4 KiB
<?php |
|
/** |
|
* Utilisations de pipelines par podcast |
|
* |
|
* @plugin podcast |
|
* @copyright 2021 |
|
* @author chankalan,vcalame |
|
* @licence GNU/GPL |
|
* @package SPIP\Podcast\Pipelines |
|
*/ |
|
|
|
if (!defined('_ECRIRE_INC_VERSION')) { |
|
return; |
|
} |
|
|
|
|
|
/* |
|
* Un fichier de pipelines permet de regrouper |
|
* les fonctions de branchement de votre plugin |
|
* sur des pipelines existants. |
|
*/ |
|
|
|
|
|
/** |
|
* Ajouter les objets sur les vues des parents directs |
|
* |
|
* @pipeline affiche_enfants |
|
* @param array $flux Données du pipeline |
|
* @return array Données du pipeline |
|
**/ |
|
function podcast_affiche_enfants($flux) { |
|
if ( |
|
$e = trouver_objet_exec($flux['args']['exec']) |
|
and $e['edition'] === false |
|
) { |
|
$id_objet = $flux['args']['id_objet']; |
|
|
|
if ($e['type'] === 'article') { |
|
$flux['data'] .= recuperer_fond( |
|
'prive/objets/liste/podcasts', |
|
array( |
|
'titre' => _T('podcast:titre_podcasts'), |
|
'id_article' => $id_objet |
|
) |
|
); |
|
|
|
if (autoriser('creerpodcastdans', 'articles', $id_objet)) { |
|
include_spip('inc/presentation'); |
|
$flux['data'] .= icone_verticale( |
|
_T('podcast:icone_creer_podcast'), |
|
generer_url_ecrire('podcast_edit', "id_article=$id_objet"), |
|
'podcast-24.png', |
|
'new', |
|
'right' |
|
) . "<br class='nettoyeur' />"; |
|
} |
|
} |
|
|
|
if ($e['type'] === 'podcast') { |
|
$flux['data'] .= recuperer_fond( |
|
'prive/objets/liste/chapitres', |
|
array( |
|
'titre' => _T('chapitre:titre_chapitres'), |
|
'id_podcast' => $id_objet |
|
) |
|
); |
|
|
|
if (autoriser('creerchapitredans', 'podcasts', $id_objet)) { |
|
include_spip('inc/presentation'); |
|
$flux['data'] .= icone_verticale( |
|
_T('chapitre:icone_creer_chapitre'), |
|
generer_url_ecrire('chapitre_edit', "id_podcast=$id_objet"), |
|
'chapitre-24.png', |
|
'new', |
|
'right' |
|
) . "<br class='nettoyeur' />"; |
|
} |
|
} |
|
} |
|
return $flux; |
|
} |
|
|
|
/** |
|
* Afficher le nombre d'éléments dans les parents |
|
* |
|
* @pipeline boite_infos |
|
* @param array $flux Données du pipeline |
|
* @return array Données du pipeline |
|
**/ |
|
function podcast_boite_infos($flux) { |
|
if (isset($flux['args']['type']) and isset($flux['args']['id']) and $id = intval($flux['args']['id'])) { |
|
$texte = ''; |
|
if ($flux['args']['type'] == 'article' and $nb = sql_countsel('spip_podcasts', array('id_article=' . $id))) { |
|
$texte .= '<div>' . singulier_ou_pluriel($nb, 'podcast:info_1_podcast', 'podcast:info_nb_podcasts') . "</div>\n"; |
|
} |
|
if ($flux['args']['type'] == 'podcast' and $nb = sql_countsel('spip_chapitres', array('id_podcast=' . $id))) { |
|
$texte .= '<div>' . singulier_ou_pluriel($nb, 'chapitre:info_1_chapitre', 'chapitre:info_nb_chapitres') . "</div>\n"; |
|
} |
|
if ($texte and $p = strpos($flux['data'], '<!--nb_elements-->')) { |
|
$flux['data'] = substr_replace($flux['data'], $texte, $p, 0); |
|
} |
|
} |
|
return $flux; |
|
} |
|
|
|
|
|
/** |
|
* Compter les enfants d'un objet |
|
* |
|
* @pipeline objets_compte_enfants |
|
* @param array $flux Données du pipeline |
|
* @return array Données du pipeline |
|
**/ |
|
function podcast_objet_compte_enfants($flux) { |
|
if ($flux['args']['objet'] == 'article' and $id_article = intval($flux['args']['id_objet'])) { |
|
$flux['data']['podcasts'] = sql_countsel('spip_podcasts', 'id_article= ' . intval($id_article)); |
|
} |
|
if ($flux['args']['objet'] == 'podcast' and $id_podcast = intval($flux['args']['id_objet'])) { |
|
$flux['data']['chapitres'] = sql_countsel('spip_chapitres', 'id_podcast= ' . intval($id_podcast)); |
|
} |
|
|
|
return $flux; |
|
}
|
|
|