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.
134 lines
3.6 KiB
134 lines
3.6 KiB
<?php |
|
/** |
|
* Utilisations de pipelines par chapitre |
|
* |
|
* @plugin chapitre |
|
* @copyright 2021 |
|
* @author chankalan,vcalame |
|
* @licence GNU/GPL |
|
* @package SPIP\Chapitre\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 libreavous_affiche_enfants($flux) { |
|
if ( |
|
$e = trouver_objet_exec($flux['args']['exec']) |
|
and $e['edition'] === false |
|
) { |
|
$id_objet = $flux['args']['id_objet']; |
|
|
|
$id_rubrique = sql_getfetsel("id_rubrique", "spip_articles", "id_article=" . intval($id_objet)); |
|
$composition_rubrique = sql_getfetsel("composition", "spip_rubriques", "id_rubrique=" . intval($id_rubrique)); |
|
|
|
if ($e['type'] === 'article' and $composition_rubrique === 'emissions') { |
|
$flux['data'] .= recuperer_fond( |
|
'prive/objets/liste/chapitres', |
|
array( |
|
'titre' => _T('chapitre:titre_chapitres'), |
|
'id_article' => $id_objet |
|
) |
|
); |
|
|
|
if (autoriser('creerchapitredans', 'articles', $id_objet)) { |
|
include_spip('inc/presentation'); |
|
$flux['data'] .= icone_verticale( |
|
_T('chapitre:icone_creer_chapitre'), |
|
generer_url_ecrire('chapitre_edit', "id_article=$id_objet"), |
|
'chapitre-24.png', |
|
'new', |
|
'right' |
|
) . "<br class='nettoyeur' />"; |
|
} |
|
} |
|
} |
|
return $flux; |
|
} |
|
|
|
/** |
|
* Afficher des choses dans le premier bloc en colonne gauche |
|
* |
|
* @pipeline boite_infos |
|
* @param array $flux Données du pipeline |
|
* @return array Données du pipeline |
|
**/ |
|
function libreavous_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_chapitres', array('id_article=' . $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; |
|
} |
|
|
|
/** |
|
* 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')) ) { |
|
// pour retrouver la composition, utiliser une fonction existante du plugin "compositions" (cf compositions_fonctions.php) |
|
$compo = compositions_heriter('article', $flux['args'][$e['id_table_objet']]); |
|
if ($compo == 'emission') { |
|
$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; |
|
} |
|
|
|
|
|
/** |
|
* Compter les enfants d'un objet |
|
* |
|
* @pipeline objets_compte_enfants |
|
* @param array $flux Données du pipeline |
|
* @return array Données du pipeline |
|
**/ |
|
function libreavous_objet_compte_enfants($flux) { |
|
if ($flux['args']['objet'] == 'article' and $id_article = intval($flux['args']['id_objet'])) { |
|
$flux['data']['chapitres'] = sql_countsel('spip_chapitres', 'id_article= ' . intval($id_article)); |
|
} |
|
|
|
return $flux; |
|
} |
|
|
|
|
|
|