-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgeol_albums_pipelines.php
133 lines (118 loc) · 3.28 KB
/
geol_albums_pipelines.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<?php
if (!defined('_ECRIRE_INC_VERSION')) {
return;
}
/**
* Insertion des css du plugin dans les pages publiques
*
* @param $flux
* @return mixed
*/
function geol_albums_insert_head_css($flux) {
$flux .= "\n" . '<link rel="stylesheet" href="' . find_in_path('css/geol_albums.css') . '" />';
return $flux;
}
/**
* Insertion dans le pipeline affiche_milieu (SPIP)
*
* Ajout de contenu sur certaines pages de l'espace privé
* Ajoute le formulaire d'ajout d'auteurs sur la page des collections
*
* @param array $flux
* Le contexte du pipeline
* @return array $flux
* Le contexte du pipeline complété
*/
function geol_albums_affiche_milieu($flux) {
$texte = false;
$e = trouver_objet_exec($flux['args']['exec']);
// auteurs sur les collections
if ($e and !$e['edition'] and in_array($e['type'], ['collection'])) {
$texte = recuperer_fond('prive/objets/editer/liens', [
'table_source' => 'auteurs',
'objet' => $e['type'],
'id_objet' => $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;
}
/**
* Insertion dans le pipeline optimiser_base_disparus (SPIP)
*
* Optimiser la base de données : collections à la poubelle, liens orphelins sur les collections
*
* @param int $n
* @return int
*/
function collections_optimiser_base_disparus($flux) {
// collections à la poubelle
sql_delete('spip_collections', "statut='poubelle' AND maj < " . sql_quote(trim($flux['args']['date'], "'")));
// optimiser les liens des collections vers des objets effacés et depuis des collections effacées
include_spip('action/editer_liens');
$flux['data'] += objet_optimiser_liens(['collection' => '*'], '*');
return $flux;
}
/**
* Insertion dans le pipeline collections_liste_types (plugin collections)
*
* Ajoute les deux types de collections possibles :
* - coopérative
* - personnelle
*
* @param array $flux
* La liste des types de collections disponibles
* @return array $flux
* La liste des types de collections complétée
*/
function geol_albums_collections_liste_types($flux) {
if (!is_array($flux)) {
$flux = [];
}
$flux['perso'] = _T('collection:type_perso');
$flux['coop'] = _T('collection:type_coop');
return $flux;
}
/**
* Insertion dans le pipeline collections_liste_genres (plugin collections)
*
* Ajoute les quatre genres de collections possibles :
* - mixed
* - image
* - audio
* - video
*
* @param array $flux
* La liste des genres possibles
* @return array
* La liste des genres complétés
*/
function geol_albums_collections_liste_genres($flux) {
if (!is_array($flux)) {
$flux = [];
}
$flux['mixed'] = _T('collection:genre_mixed');
$flux['image'] = _T('collection:genre_photo');
$flux['audio'] = _T('collection:genre_musique');
$flux['video'] = _T('collection:genre_video');
return $flux;
}
/**
* Enlever les id_ de la table spip_collections du critère selections conditionnelles,
* ailleurs que sur cette table
*
* @param array $flux
* @return array
*/
function geol_albums_exclure_id_conditionnel($flux) {
if ($flux['args']['table'] !== 'spip_collections') {
$flux['data'] = array_merge($flux['data'], ['id_collection']);
}
return $flux;
}