1 | <?php |
---|
2 | /** |
---|
3 | * Utilisations de pipelines par Sélections éditoriales |
---|
4 | * |
---|
5 | * @plugin Sélections éditoriales |
---|
6 | * @copyright 2014 |
---|
7 | * @author Les Développements Durables |
---|
8 | * @licence GNU/GPL v3 |
---|
9 | * @package SPIP\Selections_editoriales\Pipelines |
---|
10 | */ |
---|
11 | |
---|
12 | if (!defined('_ECRIRE_INC_VERSION')) return; |
---|
13 | |
---|
14 | /** |
---|
15 | * Pas de logo de survol pour les contenus sélectionés |
---|
16 | * |
---|
17 | * @pipeline formulaire_charger |
---|
18 | * @param array $flux Données du pipeline |
---|
19 | * @return array Données du pipeline |
---|
20 | */ |
---|
21 | function selections_editoriales_formulaire_charger($flux) { |
---|
22 | if ( |
---|
23 | $flux['args']['form'] == 'editer_logo' |
---|
24 | AND $flux['args']['args'][0] == 'selections_contenu' |
---|
25 | ) { |
---|
26 | $flux['data']['logo_survol'] = false; |
---|
27 | $flux['data']['logo_off'] = false; |
---|
28 | } |
---|
29 | |
---|
30 | return $flux; |
---|
31 | } |
---|
32 | |
---|
33 | /** |
---|
34 | * Insérer du JS à la fin du traiter |
---|
35 | * |
---|
36 | * @pipeline formulaire_fond |
---|
37 | * @param array $flux Données du pipeline |
---|
38 | * @return array Données du pipeline |
---|
39 | */ |
---|
40 | function selections_editoriales_formulaire_fond($flux) { |
---|
41 | if ( |
---|
42 | $flux['args']['form'] == 'editer_logo' |
---|
43 | and $flux['args']['args'][0] == 'selections_contenu' |
---|
44 | and $id_selections_contenu = intval($flux['args']['args'][1]) |
---|
45 | and $flux['args']['je_suis_poste'] |
---|
46 | ) { |
---|
47 | // On cherche la sélection parente |
---|
48 | $id_selection = intval(sql_getfetsel('id_selection', 'spip_selections_contenus', 'id_selections_contenu = '.$id_selections_contenu)); |
---|
49 | // Animation de ce qu'on vient de modifier |
---|
50 | $callback = "jQuery('#selection$id_selection-contenu$id_selections_contenu').animateAppend();"; |
---|
51 | // Rechargement du conteneur de la sélection |
---|
52 | $js = "if (window.jQuery) jQuery(function(){ajaxReload('selection$id_selection', {args:{editer_contenu_logo:'non', time:'".time()."'}, callback:function(){ $callback }});});"; |
---|
53 | $js = "<script type='text/javascript'>$js</script>"; |
---|
54 | $flux['data'] .= $js; |
---|
55 | } |
---|
56 | |
---|
57 | return $flux; |
---|
58 | } |
---|
59 | |
---|
60 | /** |
---|
61 | * Ajout de contenu sur certaines pages, |
---|
62 | * notamment des formulaires de liaisons entre objets |
---|
63 | * |
---|
64 | * @pipeline affiche_milieu |
---|
65 | * @param array $flux Données du pipeline |
---|
66 | * @return array Données du pipeline |
---|
67 | */ |
---|
68 | function selections_editoriales_affiche_milieu($flux) { |
---|
69 | $texte = ""; |
---|
70 | $e = trouver_objet_exec($flux['args']['exec']); |
---|
71 | |
---|
72 | // auteurs sur les selections |
---|
73 | if (!$e['edition'] AND in_array($e['type'], array('selection'))) { |
---|
74 | $texte .= recuperer_fond('prive/objets/editer/liens', array( |
---|
75 | 'table_source' => 'auteurs', |
---|
76 | 'objet' => $e['type'], |
---|
77 | 'id_objet' => $flux['args'][$e['id_table_objet']] |
---|
78 | )); |
---|
79 | } |
---|
80 | |
---|
81 | |
---|
82 | |
---|
83 | if ($texte) { |
---|
84 | if ($p=strpos($flux['data'],"<!--affiche_milieu-->")) |
---|
85 | $flux['data'] = substr_replace($flux['data'],$texte,$p,0); |
---|
86 | else |
---|
87 | $flux['data'] .= $texte; |
---|
88 | } |
---|
89 | |
---|
90 | return $flux; |
---|
91 | } |
---|
92 | |
---|
93 | /** |
---|
94 | * Ajout d'un bouton de suppression si vide |
---|
95 | * |
---|
96 | * @pipeline boite_infos |
---|
97 | * @param array $flux Données du pipeline |
---|
98 | * @return array Données du pipeline |
---|
99 | */ |
---|
100 | function selections_editoriales_boite_infos($flux) { |
---|
101 | if ( |
---|
102 | $flux['args']['type'] == 'selection' |
---|
103 | and $id_selection = intval($flux['args']['id']) |
---|
104 | and include_spip('inc/autoriser') |
---|
105 | and autoriser('supprimer', 'selection', $id_selection) |
---|
106 | and include_spip('inc/filtres') |
---|
107 | and include_spip('inc/actions') |
---|
108 | ) { |
---|
109 | $flux['data'] .= filtrer('bouton_action_horizontal', |
---|
110 | generer_action_auteur('supprimer_selection', $id_selection, generer_url_ecrire('selections')), |
---|
111 | _T('lien_supprimer'), |
---|
112 | 'selection-24.png', |
---|
113 | 'del', |
---|
114 | 'link' |
---|
115 | ); |
---|
116 | } |
---|
117 | |
---|
118 | return $flux; |
---|
119 | } |
---|
120 | |
---|
121 | /** |
---|
122 | * Ajoute des sélections sous les objets configurés pour ça |
---|
123 | * |
---|
124 | * |
---|
125 | * @pipeline afficher_complement_objet |
---|
126 | * @param array $flux Données du pipeline |
---|
127 | * @return array Données du pipeline |
---|
128 | */ |
---|
129 | function selections_editoriales_afficher_complement_objet($flux){ |
---|
130 | $exec = trouver_objet_exec($flux['args']['type']); |
---|
131 | $id = intval($flux['args']['id']); |
---|
132 | |
---|
133 | if ( |
---|
134 | $exec !== false // page d'un objet éditorial |
---|
135 | and $exec['edition'] === false // pas en mode édition |
---|
136 | and $type = $exec['type'] |
---|
137 | and autoriser('associerselections', $type, $id) |
---|
138 | and autoriser('creer', 'selection') |
---|
139 | ) { |
---|
140 | $flux['data'] .= recuperer_fond('prive/squelettes/inclure/selections_objet', array( |
---|
141 | 'objet' => $type, |
---|
142 | 'id_objet' => $id, |
---|
143 | ), |
---|
144 | array('ajax'=>'selections') |
---|
145 | ); |
---|
146 | } |
---|
147 | return $flux; |
---|
148 | } |
---|
149 | |
---|
150 | /** |
---|
151 | * Optimiser la base de données en supprimant les liens orphelins |
---|
152 | * de l'objet vers quelqu'un et de quelqu'un vers l'objet. |
---|
153 | * |
---|
154 | * @pipeline optimiser_base_disparus |
---|
155 | * @param array $flux Données du pipeline |
---|
156 | * @return array Données du pipeline |
---|
157 | */ |
---|
158 | function selections_editoriales_optimiser_base_disparus($flux){ |
---|
159 | include_spip('action/editer_liens'); |
---|
160 | $flux['data'] += objet_optimiser_liens(array('selection'=>'*'),'*'); |
---|
161 | return $flux; |
---|
162 | } |
---|
163 | |
---|
164 | ?> |
---|