1497 |
jpm |
1 |
<?php
|
|
|
2 |
/**
|
|
|
3 |
* Service fournissant des informations concernant COEL au format RSS1, RSS2 ou ATOM.
|
|
|
4 |
* Encodage en entrée : utf8
|
|
|
5 |
* Encodage en sortie : utf8
|
|
|
6 |
*
|
|
|
7 |
* Notes : pour les requêtes sur la table d'historique cela peut être assez compliqué!
|
|
|
8 |
* Voir : http://www.xaprb.com/blog/2006/12/07/how-to-select-the-firstleastmax-row-per-group-in-sql/
|
|
|
9 |
*
|
|
|
10 |
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org>
|
|
|
11 |
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
|
|
|
12 |
* @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
|
|
|
13 |
* @version $Id: CoelSyndication.php 381 2010-05-17 17:10:37Z jpm $
|
|
|
14 |
* @copyright 2009
|
|
|
15 |
*/
|
|
|
16 |
class CoelSyndication extends Coel {
|
|
|
17 |
|
|
|
18 |
private $format = null;
|
|
|
19 |
private $service = null;
|
|
|
20 |
private $squelette = null;
|
|
|
21 |
private $squelette_dossier = null;
|
|
|
22 |
private $squelette_diff = null;
|
|
|
23 |
private $flux = array();
|
|
|
24 |
|
|
|
25 |
/**
|
|
|
26 |
* Méthode appelée avec une requête de type GET.
|
|
|
27 |
*/
|
|
|
28 |
public function getElement($param = array()) {
|
|
|
29 |
// Initialisation des variables
|
|
|
30 |
$info = array();
|
|
|
31 |
$contenu = '';
|
|
|
32 |
|
|
|
33 |
// Pré traitement des paramêtres
|
|
|
34 |
$pour_bdd = false;
|
|
|
35 |
$p = $this->traiterParametresUrl(array('service', 'format'), $param, $pour_bdd);
|
|
|
36 |
|
|
|
37 |
// Récupération de la liste des flux
|
|
|
38 |
$this->chargerListeDesFlux();
|
|
|
39 |
|
|
|
40 |
// Chargement du bon type de service demandé
|
|
|
41 |
if (isset($p['service'])) {
|
|
|
42 |
$this->service = strtolower($p['service']);
|
|
|
43 |
$methode = $this->getNomMethodeService();
|
|
|
44 |
if (method_exists($this, $methode)) {
|
|
|
45 |
if ($this->service != 'liste_des_flux') {
|
|
|
46 |
if (isset($p['format']) && preg_match('/^(?:rss1|rss2|atom)$/i', $p['format'])) {
|
|
|
47 |
// Multiplication par deux de la limite car nous récupérons deux lignes par item
|
|
|
48 |
$this->limit = $this->limit*2;
|
|
|
49 |
// Mise en minuscule de l'indication du format
|
|
|
50 |
$this->format = strtolower($p['format']);
|
|
|
51 |
// Définition du fichier squelette demandé
|
|
|
52 |
$this->squelette_dossier = dirname(__FILE__).DIRECTORY_SEPARATOR.'squelettes'.DIRECTORY_SEPARATOR;
|
|
|
53 |
$this->squelette = $this->squelette_dossier.$this->format.'.tpl.xml';
|
|
|
54 |
$this->squelette_diff = $this->squelette_dossier.'diff.tpl.html';
|
|
|
55 |
} else {
|
|
|
56 |
$this->format = '';
|
|
|
57 |
$this->messages[] = "Le service COEL Syndication nécessite d'indiquer en second paramètre le format : rss1, rss2 ou atom.";
|
|
|
58 |
}
|
|
|
59 |
}
|
|
|
60 |
// Récupération du contenu à renvoyer
|
|
|
61 |
$contenu = $this->$methode();
|
|
|
62 |
} else {
|
|
|
63 |
$this->messages[] = "Le type d'information demandé '$this->service' n'est pas disponible.";
|
|
|
64 |
}
|
|
|
65 |
} else {
|
|
|
66 |
$this->messages[] = "Le service COEL Syndication nécessite d'indiquer en premier paramètre le type d'information demandé.";
|
|
|
67 |
}
|
|
|
68 |
|
|
|
69 |
// Envoie sur la sortie standard
|
|
|
70 |
$encodage = 'utf-8';
|
|
|
71 |
$mime = $this->getTypeMime();
|
|
|
72 |
$formatage_json = $this->getFormatageJson();
|
|
|
73 |
$this->envoyer($contenu, $mime, $encodage, $formatage_json);
|
|
|
74 |
}
|
|
|
75 |
|
|
|
76 |
private function getUrlServiceBase() {
|
|
|
77 |
$url_service = $this->config['coel']['urlBaseJrest'].'CoelSyndication/'.$this->service.'/'.$this->format;
|
|
|
78 |
return $url_service;
|
|
|
79 |
}
|
|
|
80 |
|
|
|
81 |
private function getNomMethodeService() {
|
|
|
82 |
$methode = '';
|
|
|
83 |
$service_formate = str_replace(' ', '', ucwords(implode(' ', explode('_', $this->service))));
|
|
|
84 |
$methode = 'getService'.$service_formate;
|
|
|
85 |
return $methode;
|
|
|
86 |
}
|
|
|
87 |
|
|
|
88 |
private function getTypeMime() {
|
|
|
89 |
$mime = '';
|
|
|
90 |
switch ($this->format) {
|
|
|
91 |
case 'atom' :
|
|
|
92 |
$mime = 'application/atom+xml';
|
|
|
93 |
break;
|
|
|
94 |
case 'rss1' :
|
|
|
95 |
case 'rss2' :
|
|
|
96 |
$mime = 'application/rss+xml';
|
|
|
97 |
break;
|
|
|
98 |
default:
|
|
|
99 |
$mime = 'text/html';
|
|
|
100 |
}
|
|
|
101 |
return $mime;
|
|
|
102 |
}
|
|
|
103 |
|
|
|
104 |
private function getFormatageJson() {
|
|
|
105 |
$json = false;
|
|
|
106 |
switch ($this->service) {
|
|
|
107 |
case 'liste_des_flux' :
|
|
|
108 |
$json = true;
|
|
|
109 |
break;
|
|
|
110 |
default:
|
|
|
111 |
$json = false;
|
|
|
112 |
}
|
|
|
113 |
return $json;
|
|
|
114 |
}
|
|
|
115 |
|
|
|
116 |
private function getFlux($nom) {
|
|
|
117 |
$nom = strtolower($nom);
|
|
|
118 |
return isset($this->flux[$nom]) ? $this->flux[$nom] : array();
|
|
|
119 |
}
|
|
|
120 |
|
|
|
121 |
private function setFlux($nom, $titre, $description) {
|
|
|
122 |
$url_base = $this->config['coel']['urlBaseJrest'].'CoelSyndication/';
|
|
|
123 |
$formats = array('atom', 'rss2', 'rss1');
|
|
|
124 |
$flux = array();
|
|
|
125 |
foreach ($formats as $format) {
|
|
|
126 |
$url = $url_base.$nom.'/'.$format;
|
|
|
127 |
$flux[$format] = $url;
|
|
|
128 |
}
|
|
|
129 |
$this->flux[$nom] = array('titre' => $titre, 'description' => $description, 'urls' => $flux);
|
|
|
130 |
}
|
|
|
131 |
|
|
|
132 |
private function chargerListeDesFlux() {
|
|
|
133 |
$this->setFlux('structure','Flux de syndication des institutions',
|
|
|
134 |
'Ce flux fournit des informations sur les mises à jour des institutions saisies dans COEL.');
|
|
|
135 |
$this->setFlux('collection', 'Flux de syndication des Collections',
|
|
|
136 |
'Ce flux fournit des informations sur les mises à jour des collections saisies dans COEL.');
|
|
|
137 |
$this->setFlux('personne', 'Flux de syndication des personnes',
|
|
|
138 |
'Ce flux fournit des informations sur les mises à jour des personnes saisies dans COEL.');
|
|
|
139 |
$this->setFlux('publication', 'Flux de syndication des publications',
|
|
|
140 |
'Ce flux fournit des informations sur les mises à jour des publications saisies dans COEL.');
|
|
|
141 |
$this->setFlux('commentaire', 'Flux de syndication des notes',
|
|
|
142 |
'Ce flux fournit des informations sur les mises à jour des notes saisies dans COEL.');
|
|
|
143 |
}
|
|
|
144 |
|
|
|
145 |
private function getServiceListeDesFlux() {
|
|
|
146 |
return $this->flux;
|
|
|
147 |
}
|
|
|
148 |
|
|
|
149 |
private function getServiceStructure() {
|
|
|
150 |
$elements = array();
|
|
|
151 |
$elements = array_merge($elements, $this->getHistoriqueTableStructure(120));
|
|
|
152 |
$elements = array_merge($elements, $this->getHistoriqueTableStructure(122));
|
|
|
153 |
$elements = array_merge($elements, $this->getHistoriqueTableStructure(123));
|
|
|
154 |
$elements = array_merge($elements, $this->getHistoriqueStructureAPersonne());
|
|
|
155 |
krsort($elements);
|
|
|
156 |
$elements = array_slice($elements, 0, ($this->limit/2));
|
|
|
157 |
|
|
|
158 |
// Création du contenu
|
|
|
159 |
$contenu = $this->executerService('cs_nom', $elements);
|
|
|
160 |
return $contenu;
|
|
|
161 |
}
|
|
|
162 |
|
|
|
163 |
private function getHistoriqueTableStructure($table_id) {
|
|
|
164 |
$requete = (($this->distinct) ? 'SELECT DISTINCT' : 'SELECT').' '.
|
|
|
165 |
' h1.cmhl_id_historique_ligne, h1.cmhl_ce_table, h1.cmhl_cle_ligne, h1.cmhl_enregistrement, '.
|
|
|
166 |
' h1.cmhl_date_modification, h1.cmhl_ce_etat, h1.cmhl_ip, '.
|
|
|
167 |
' h1.cmhl_cle_ligne AS guid, '.
|
|
|
168 |
" 'str' AS guid_type, ".
|
|
|
169 |
(($table_id != 120) ? ' CONCAT(IF (h1.cmhl_ce_table = 122, "Conservation", "Valorisation"), " - ", cs_nom) AS titre, ' : '').
|
|
|
170 |
' cp_fmt_nom_complet AS modifier_par '.
|
|
|
171 |
'FROM coel_meta_historique_ligne AS h1 '.
|
|
|
172 |
' LEFT JOIN coel_meta_historique_ligne AS h2 '.
|
|
|
173 |
' ON (h1.cmhl_ce_table = h2.cmhl_ce_table '.
|
|
|
174 |
' AND h1.cmhl_cle_ligne = h2.cmhl_cle_ligne '.
|
|
|
175 |
' AND h1.cmhl_date_modification <= h2.cmhl_date_modification ) '.
|
|
|
176 |
' LEFT JOIN coel_personne ON (h1.cmhl_ce_modifier_par = cp_id_personne) '.
|
|
|
177 |
(($table_id != 120) ? ' LEFT JOIN coel_structure ON (cs_id_structure = h1.cmhl_cle_ligne) ' : '').
|
|
|
178 |
"WHERE h1.cmhl_ce_table = $table_id %s ".
|
|
|
179 |
(($table_id != 120) ? ' AND h1.cmhl_ce_etat != 3 ' : '').
|
|
|
180 |
'GROUP BY h1.cmhl_ce_table, h1.cmhl_cle_ligne, h1.cmhl_date_modification '.
|
|
|
181 |
'HAVING COUNT(*) = %s '.
|
|
|
182 |
'ORDER BY '.((!is_null($this->orderby)) ? $this->orderby : 'h1.cmhl_date_modification DESC').' '.
|
|
|
183 |
"LIMIT $this->start,$this->limit ";
|
|
|
184 |
|
|
|
185 |
$elements = $this->executerRequeteHistorique($requete);
|
|
|
186 |
return $elements;
|
|
|
187 |
}
|
|
|
188 |
|
|
|
189 |
private function getHistoriqueStructureAPersonne() {
|
|
|
190 |
$requete = (($this->distinct) ? 'SELECT DISTINCT' : 'SELECT').' '.
|
|
|
191 |
' h1.cmhl_id_historique_ligne, h1.cmhl_ce_table, h1.cmhl_cle_ligne, h1.cmhl_enregistrement, '.
|
|
|
192 |
' h1.cmhl_date_modification, h1.cmhl_ce_etat, h1.cmhl_ip, '.
|
|
|
193 |
' h1.cmhl_cle_ligne AS guid, '.
|
|
|
194 |
" 'csap' AS guid_type, ".
|
|
|
195 |
' p1.cp_fmt_nom_complet AS modifier_par, '.
|
|
|
196 |
' CONCAT(IF(h1.cmhl_ce_etat = 1, "Ajout", IF (h1.cmhl_ce_etat = 3, "Suppression", "Modification")), " d\'une personne liée à «", s1.cs_nom, "»") AS titre, '.
|
|
|
197 |
' CONCAT("Personne «", p2.cp_fmt_nom_complet, "» liée à «", s1.cs_nom, "» avec rôle «", lv1.cmlv_nom, "»") AS description '.
|
|
|
198 |
'FROM coel_meta_historique_ligne AS h1 '.
|
|
|
199 |
' LEFT JOIN coel_meta_historique_ligne AS h2 '.
|
|
|
200 |
' ON (h1.cmhl_ce_table = h2.cmhl_ce_table '.
|
|
|
201 |
' AND h1.cmhl_cle_ligne = h2.cmhl_cle_ligne '.
|
|
|
202 |
' AND h1.cmhl_date_modification <= h2.cmhl_date_modification ) '.
|
|
|
203 |
' LEFT JOIN coel_personne AS p1 ON (h1.cmhl_ce_modifier_par = p1.cp_id_personne) '.
|
|
|
204 |
' LEFT JOIN coel_personne AS p2 '.
|
|
|
205 |
" ON (SUBSTRING_INDEX(h1.cmhl_cle_ligne, '-', 1) = p2.cp_id_personne) ".
|
|
|
206 |
' LEFT JOIN coel_structure AS s1 '.
|
|
|
207 |
" ON (SUBSTRING_INDEX(h1.cmhl_cle_ligne, '-', -1) = s1.cs_id_structure) ".
|
|
|
208 |
' LEFT JOIN coel_meta_liste_valeur AS lv1 '.
|
|
|
209 |
" ON (SUBSTRING_INDEX(SUBSTRING_INDEX(h1.cmhl_cle_ligne, '-', 2), '-', -1) = lv1.cmlv_id_valeur) ".
|
|
|
210 |
'WHERE h1.cmhl_ce_table = 121 %s '.
|
|
|
211 |
'GROUP BY h1.cmhl_ce_table, h1.cmhl_cle_ligne, h1.cmhl_date_modification '.
|
|
|
212 |
'HAVING COUNT(*) = %s '.
|
|
|
213 |
'ORDER BY '.((!is_null($this->orderby)) ? $this->orderby : 'h1.cmhl_date_modification DESC').' '.
|
|
|
214 |
"LIMIT $this->start,$this->limit ";
|
|
|
215 |
|
|
|
216 |
$elements = $this->executerRequeteHistorique($requete);
|
|
|
217 |
return $elements;
|
|
|
218 |
}
|
|
|
219 |
|
|
|
220 |
private function getServiceCollection() {
|
|
|
221 |
$elements = array();
|
|
|
222 |
$elements = array_merge($elements, $this->getHistoriqueTableCollection(101));
|
|
|
223 |
$elements = array_merge($elements, $this->getHistoriqueTableCollection(106));
|
|
|
224 |
$elements = array_merge($elements, $this->getHistoriqueCollectionAPersonne());
|
|
|
225 |
$elements = array_merge($elements, $this->getHistoriqueCollectionAPublication());
|
|
|
226 |
$elements = array_merge($elements, $this->getHistoriqueCollectionACommentaire());
|
|
|
227 |
krsort($elements);
|
|
|
228 |
$elements = array_slice($elements, 0, ($this->limit/2));
|
|
|
229 |
//echo '<pre>'.print_r($elements, true).'</pre>';
|
|
|
230 |
// Création du contenu
|
|
|
231 |
$contenu = $this->executerService('cc_nom', $elements);
|
|
|
232 |
return $contenu;
|
|
|
233 |
}
|
|
|
234 |
|
|
|
235 |
private function getHistoriqueTableCollection($table_id) {
|
|
|
236 |
// Reque générale avec paramêtres
|
|
|
237 |
$requete = (($this->distinct) ? 'SELECT DISTINCT' : 'SELECT').' '.
|
|
|
238 |
' h1.cmhl_id_historique_ligne, h1.cmhl_ce_table, h1.cmhl_cle_ligne, h1.cmhl_enregistrement, '.
|
|
|
239 |
' h1.cmhl_date_modification, h1.cmhl_ce_etat, h1.cmhl_ip, '.
|
|
|
240 |
' h1.cmhl_cle_ligne AS guid, '.
|
|
|
241 |
" 'col' AS guid_type, ".
|
|
|
242 |
(($table_id == 106) ? ' CONCAT("Botanique", " - ", cc_nom) AS titre, ' : '').
|
|
|
243 |
' cp_fmt_nom_complet AS modifier_par '.
|
|
|
244 |
'FROM coel_meta_historique_ligne AS h1 '.
|
|
|
245 |
' LEFT JOIN coel_meta_historique_ligne AS h2 '.
|
|
|
246 |
' ON (h1.cmhl_ce_table = h2.cmhl_ce_table '.
|
|
|
247 |
' AND h1.cmhl_cle_ligne = h2.cmhl_cle_ligne '.
|
|
|
248 |
' AND h1.cmhl_date_modification <= h2.cmhl_date_modification ) '.
|
|
|
249 |
' LEFT JOIN coel_personne ON (h1.cmhl_ce_modifier_par = cp_id_personne) '.
|
|
|
250 |
(($table_id == 106) ? ' LEFT JOIN coel_collection ON (cc_id_collection = h1.cmhl_cle_ligne) ' : '').
|
|
|
251 |
"WHERE h1.cmhl_ce_table = $table_id %s ".
|
|
|
252 |
(($table_id == 106) ? ' AND h1.cmhl_ce_etat != 3 ' : '').
|
|
|
253 |
'GROUP BY h1.cmhl_ce_table, h1.cmhl_cle_ligne, h1.cmhl_date_modification '.
|
|
|
254 |
'HAVING COUNT(*) = %s '.
|
|
|
255 |
'ORDER BY '.((!is_null($this->orderby)) ? $this->orderby : 'h1.cmhl_date_modification DESC').' '.
|
|
|
256 |
"LIMIT $this->start,$this->limit ";
|
|
|
257 |
$elements = $this->executerRequeteHistorique($requete);
|
|
|
258 |
return $elements;
|
|
|
259 |
}
|
|
|
260 |
|
|
|
261 |
private function getHistoriqueCollectionAPersonne() {
|
|
|
262 |
$requete = (($this->distinct) ? 'SELECT DISTINCT' : 'SELECT').' '.
|
|
|
263 |
' h1.cmhl_id_historique_ligne, h1.cmhl_ce_table, h1.cmhl_cle_ligne, h1.cmhl_enregistrement, '.
|
|
|
264 |
' h1.cmhl_date_modification, h1.cmhl_ce_etat, h1.cmhl_ip, '.
|
|
|
265 |
' p1.cp_fmt_nom_complet AS modifier_par, '.
|
|
|
266 |
' h1.cmhl_cle_ligne AS guid, '.
|
|
|
267 |
" 'ccap' AS guid_type, ".
|
|
|
268 |
' CONCAT(IF(h1.cmhl_ce_etat = 1, "Ajout", IF (h1.cmhl_ce_etat = 3, "Suppression", "Modification")), " d\'une personne liée à «", c1.cc_nom, "»") AS titre, '.
|
|
|
269 |
' CONCAT("Personne «", p2.cp_fmt_nom_complet, "» liée à «", c1.cc_nom, "» avec rôle «", lv1.cmlv_nom, "»") AS description '.
|
|
|
270 |
'FROM coel_meta_historique_ligne AS h1 '.
|
|
|
271 |
' LEFT JOIN coel_meta_historique_ligne AS h2 '.
|
|
|
272 |
' ON (h1.cmhl_ce_table = h2.cmhl_ce_table '.
|
|
|
273 |
' AND h1.cmhl_cle_ligne = h2.cmhl_cle_ligne '.
|
|
|
274 |
' AND h1.cmhl_date_modification <= h2.cmhl_date_modification ) '.
|
|
|
275 |
' LEFT JOIN coel_personne AS p1 ON (h1.cmhl_ce_modifier_par = p1.cp_id_personne) '.
|
|
|
276 |
' LEFT JOIN coel_personne AS p2 '.
|
|
|
277 |
" ON (SUBSTRING_INDEX(SUBSTRING_INDEX(h1.cmhl_cle_ligne, '-', 2), '-', -1) = p2.cp_id_personne) ".
|
|
|
278 |
' LEFT JOIN coel_collection AS c1 '.
|
|
|
279 |
" ON (SUBSTRING_INDEX(h1.cmhl_cle_ligne, '-', 1) = c1.cc_id_collection) ".
|
|
|
280 |
' LEFT JOIN coel_meta_liste_valeur AS lv1 '.
|
|
|
281 |
" ON (SUBSTRING_INDEX(h1.cmhl_cle_ligne, '-', -1) = lv1.cmlv_id_valeur) ".
|
|
|
282 |
'WHERE h1.cmhl_ce_table = 103 %s '.
|
|
|
283 |
'GROUP BY h1.cmhl_ce_table, h1.cmhl_cle_ligne, h1.cmhl_date_modification '.
|
|
|
284 |
'HAVING COUNT(*) = %s '.
|
|
|
285 |
'ORDER BY '.((!is_null($this->orderby)) ? $this->orderby : 'h1.cmhl_date_modification DESC').' '.
|
|
|
286 |
"LIMIT $this->start,$this->limit ";
|
|
|
287 |
|
|
|
288 |
$elements = $this->executerRequeteHistorique($requete);
|
|
|
289 |
return $elements;
|
|
|
290 |
}
|
|
|
291 |
|
|
|
292 |
private function getHistoriqueCollectionAPublication() {
|
|
|
293 |
$requete = (($this->distinct) ? 'SELECT DISTINCT' : 'SELECT').' '.
|
|
|
294 |
' h1.cmhl_id_historique_ligne, h1.cmhl_ce_table, h1.cmhl_cle_ligne, h1.cmhl_enregistrement, '.
|
|
|
295 |
' h1.cmhl_date_modification, h1.cmhl_ce_etat, h1.cmhl_ip, '.
|
|
|
296 |
' p1.cp_fmt_nom_complet AS modifier_par, '.
|
|
|
297 |
' h1.cmhl_cle_ligne AS guid, '.
|
|
|
298 |
" 'ccapu' AS guid_type, ".
|
|
|
299 |
' CONCAT(IF(h1.cmhl_ce_etat = 1, "Ajout", IF (h1.cmhl_ce_etat = 3, "Suppression", "Modification")), " d\'une publication liée à «", c1.cc_nom, "»") AS titre, '.
|
|
|
300 |
' CONCAT("Publication «", p2.cpu_fmt_nom_complet, "» liée à «", c1.cc_nom, "»") AS description '.
|
|
|
301 |
'FROM coel_meta_historique_ligne AS h1 '.
|
|
|
302 |
' LEFT JOIN coel_meta_historique_ligne AS h2 '.
|
|
|
303 |
' ON (h1.cmhl_ce_table = h2.cmhl_ce_table '.
|
|
|
304 |
' AND h1.cmhl_cle_ligne = h2.cmhl_cle_ligne '.
|
|
|
305 |
' AND h1.cmhl_date_modification <= h2.cmhl_date_modification ) '.
|
|
|
306 |
' LEFT JOIN coel_personne AS p1 ON (h1.cmhl_ce_modifier_par = p1.cp_id_personne) '.
|
|
|
307 |
' LEFT JOIN coel_publication AS p2 '.
|
|
|
308 |
" ON (SUBSTRING_INDEX(h1.cmhl_cle_ligne, '-', -1) = p2.cpu_id_publication) ".
|
|
|
309 |
' LEFT JOIN coel_collection AS c1 '.
|
|
|
310 |
" ON (SUBSTRING_INDEX(h1.cmhl_cle_ligne, '-', 1) = c1.cc_id_collection) ".
|
|
|
311 |
'WHERE h1.cmhl_ce_table = 104 %s '.
|
|
|
312 |
'GROUP BY h1.cmhl_ce_table, h1.cmhl_cle_ligne, h1.cmhl_date_modification '.
|
|
|
313 |
'HAVING COUNT(*) = %s '.
|
|
|
314 |
'ORDER BY '.((!is_null($this->orderby)) ? $this->orderby : 'h1.cmhl_date_modification DESC').' '.
|
|
|
315 |
"LIMIT $this->start,$this->limit ";
|
|
|
316 |
|
|
|
317 |
$elements = $this->executerRequeteHistorique($requete);
|
|
|
318 |
return $elements;
|
|
|
319 |
}
|
|
|
320 |
|
|
|
321 |
private function getHistoriqueCollectionACommentaire() {
|
|
|
322 |
$requete = (($this->distinct) ? 'SELECT DISTINCT' : 'SELECT').' '.
|
|
|
323 |
' h1.cmhl_id_historique_ligne, h1.cmhl_ce_table, h1.cmhl_cle_ligne, h1.cmhl_enregistrement, '.
|
|
|
324 |
' h1.cmhl_date_modification, h1.cmhl_ce_etat, h1.cmhl_ip, '.
|
|
|
325 |
' p1.cp_fmt_nom_complet AS modifier_par, '.
|
|
|
326 |
' h1.cmhl_cle_ligne AS guid, '.
|
|
|
327 |
" 'ccacm' AS guid_type, ".
|
|
|
328 |
' CONCAT(IF(h1.cmhl_ce_etat = 1, "Ajout", IF (h1.cmhl_ce_etat = 3, "Suppression", "Modification")), " d\'un commentaire lié à «", c1.cc_nom, "»") AS titre, '.
|
|
|
329 |
' CONCAT("Commentaire «", c.ccm_titre, "» liée à «", c1.cc_nom, "»") AS description '.
|
|
|
330 |
'FROM coel_meta_historique_ligne AS h1 '.
|
|
|
331 |
' LEFT JOIN coel_meta_historique_ligne AS h2 '.
|
|
|
332 |
' ON (h1.cmhl_ce_table = h2.cmhl_ce_table '.
|
|
|
333 |
' AND h1.cmhl_cle_ligne = h2.cmhl_cle_ligne '.
|
|
|
334 |
' AND h1.cmhl_date_modification <= h2.cmhl_date_modification ) '.
|
|
|
335 |
' LEFT JOIN coel_personne AS p1 ON (h1.cmhl_ce_modifier_par = p1.cp_id_personne) '.
|
|
|
336 |
' LEFT JOIN coel_commentaire AS c '.
|
|
|
337 |
" ON (SUBSTRING_INDEX(h1.cmhl_cle_ligne, '-', -1) = c.ccm_id_commentaire) ".
|
|
|
338 |
' LEFT JOIN coel_collection AS c1 '.
|
|
|
339 |
" ON (SUBSTRING_INDEX(h1.cmhl_cle_ligne, '-', 1) = c1.cc_id_collection) ".
|
|
|
340 |
'WHERE h1.cmhl_ce_table = 102 %s '.
|
|
|
341 |
'GROUP BY h1.cmhl_ce_table, h1.cmhl_cle_ligne, h1.cmhl_date_modification '.
|
|
|
342 |
'HAVING COUNT(*) = %s '.
|
|
|
343 |
'ORDER BY '.((!is_null($this->orderby)) ? $this->orderby : 'h1.cmhl_date_modification DESC').' '.
|
|
|
344 |
"LIMIT $this->start,$this->limit ";
|
|
|
345 |
|
|
|
346 |
$elements = $this->executerRequeteHistorique($requete);
|
|
|
347 |
return $elements;
|
|
|
348 |
}
|
|
|
349 |
|
|
|
350 |
private function getServicePersonne() {
|
|
|
351 |
$elements = array();
|
|
|
352 |
$elements = array_merge($elements, $this->getHistoriqueTable(113, 'per'));
|
|
|
353 |
$elements = array_merge($elements, $this->getHistoriquePublicationAPersonne());
|
|
|
354 |
krsort($elements);
|
|
|
355 |
$elements = array_slice($elements, 0, ($this->limit/2));
|
|
|
356 |
//echo '<pre>'.print_r($elements, true).'</pre>';
|
|
|
357 |
// Création du contenu
|
|
|
358 |
$contenu = $this->executerService('cp_fmt_nom_complet', $elements);
|
|
|
359 |
return $contenu;
|
|
|
360 |
}
|
|
|
361 |
|
|
|
362 |
private function getHistoriquePublicationAPersonne() {
|
|
|
363 |
$requete = (($this->distinct) ? 'SELECT DISTINCT' : 'SELECT').' '.
|
|
|
364 |
' h1.cmhl_id_historique_ligne, h1.cmhl_ce_table, h1.cmhl_cle_ligne, h1.cmhl_enregistrement, '.
|
|
|
365 |
' h1.cmhl_date_modification, h1.cmhl_ce_etat, h1.cmhl_ip, '.
|
|
|
366 |
' p1.cp_fmt_nom_complet AS modifier_par, '.
|
|
|
367 |
' h1.cmhl_cle_ligne AS guid, '.
|
|
|
368 |
" 'cpap' AS guid_type, ".
|
|
|
369 |
' CONCAT(IF(h1.cmhl_ce_etat = 1, "Ajout", IF (h1.cmhl_ce_etat = 3, "Suppression", "Modification")), " d\'une publication liée à «", p2.cp_fmt_nom_complet, "»") AS titre, '.
|
|
|
370 |
' CONCAT("Publication «", pu.cpu_fmt_nom_complet, "» liée à «", p2.cp_fmt_nom_complet, "» avec rôle «", lv1.cmlv_nom, "»") AS description '.
|
|
|
371 |
'FROM coel_meta_historique_ligne AS h1 '.
|
|
|
372 |
' LEFT JOIN coel_meta_historique_ligne AS h2 '.
|
|
|
373 |
' ON (h1.cmhl_ce_table = h2.cmhl_ce_table '.
|
|
|
374 |
' AND h1.cmhl_cle_ligne = h2.cmhl_cle_ligne '.
|
|
|
375 |
' AND h1.cmhl_date_modification <= h2.cmhl_date_modification ) '.
|
|
|
376 |
' LEFT JOIN coel_personne AS p1 ON (h1.cmhl_ce_modifier_par = p1.cp_id_personne) '.
|
|
|
377 |
' LEFT JOIN coel_publication AS pu '.
|
|
|
378 |
" ON (SUBSTRING_INDEX(SUBSTRING_INDEX(h1.cmhl_cle_ligne, '-', 2), '-', -1) = pu.cpu_id_publication) ".
|
|
|
379 |
' LEFT JOIN coel_personne AS p2 '.
|
|
|
380 |
" ON (SUBSTRING_INDEX(h1.cmhl_cle_ligne, '-', 1) = p2.cp_id_personne) ".
|
|
|
381 |
' LEFT JOIN coel_meta_liste_valeur AS lv1 '.
|
|
|
382 |
" ON (SUBSTRING_INDEX(h1.cmhl_cle_ligne, '-', -1) = lv1.cmlv_id_valeur) ".
|
|
|
383 |
'WHERE h1.cmhl_ce_table = 119 '.
|
|
|
384 |
' %s '.
|
|
|
385 |
" AND SUBSTRING_INDEX(h1.cmhl_cle_ligne, '-', -1) IN (2361,2362,2363) ".
|
|
|
386 |
'GROUP BY h1.cmhl_ce_table, h1.cmhl_cle_ligne, h1.cmhl_date_modification '.
|
|
|
387 |
'HAVING COUNT(*) = %s '.
|
|
|
388 |
'ORDER BY '.((!is_null($this->orderby)) ? $this->orderby : 'h1.cmhl_date_modification DESC').' '.
|
|
|
389 |
"LIMIT $this->start,$this->limit ";
|
|
|
390 |
|
|
|
391 |
$elements = $this->executerRequeteHistorique($requete);
|
|
|
392 |
return $elements;
|
|
|
393 |
}
|
|
|
394 |
|
|
|
395 |
private function getServicePublication() {
|
|
|
396 |
$elements = array();
|
|
|
397 |
$elements = $this->getHistoriqueTable(118, 'pub');
|
|
|
398 |
krsort($elements);
|
|
|
399 |
$elements = array_slice($elements, 0, ($this->limit/2));
|
|
|
400 |
//echo '<pre>'.print_r($elements, true).'</pre>';
|
|
|
401 |
// Création du contenu
|
|
|
402 |
$contenu = $this->executerService('cpu_fmt_nom_complet', $elements);
|
|
|
403 |
return $contenu;
|
|
|
404 |
}
|
|
|
405 |
|
|
|
406 |
private function getServiceCommentaire() {
|
|
|
407 |
$elements = array();
|
|
|
408 |
$elements = $this->getHistoriqueTable(107, 'com');
|
|
|
409 |
krsort($elements);
|
|
|
410 |
$elements = array_slice($elements, 0, ($this->limit/2));
|
|
|
411 |
//echo '<pre>'.print_r($elements, true).'</pre>';
|
|
|
412 |
// Création du contenu
|
|
|
413 |
$contenu = $this->executerService('ccm_titre', $elements);
|
|
|
414 |
return $contenu;
|
|
|
415 |
}
|
|
|
416 |
|
|
|
417 |
private function getHistoriqueTable($table_id, $guid_type) {
|
|
|
418 |
// Reque générale avec paramêtres
|
|
|
419 |
$requete = (($this->distinct) ? 'SELECT DISTINCT' : 'SELECT').' '.
|
|
|
420 |
' h1.cmhl_id_historique_ligne, h1.cmhl_ce_table, h1.cmhl_cle_ligne, h1.cmhl_enregistrement, '.
|
|
|
421 |
' h1.cmhl_date_modification, h1.cmhl_ce_etat, h1.cmhl_ip, '.
|
|
|
422 |
' h1.cmhl_cle_ligne AS guid, '.
|
|
|
423 |
" '$guid_type' AS guid_type, ".
|
|
|
424 |
' cp_fmt_nom_complet AS modifier_par '.
|
|
|
425 |
'FROM coel_meta_historique_ligne AS h1 '.
|
|
|
426 |
' LEFT JOIN coel_meta_historique_ligne AS h2 '.
|
|
|
427 |
' ON (h1.cmhl_ce_table = h2.cmhl_ce_table '.
|
|
|
428 |
' AND h1.cmhl_cle_ligne = h2.cmhl_cle_ligne '.
|
|
|
429 |
' AND h1.cmhl_date_modification <= h2.cmhl_date_modification ) '.
|
|
|
430 |
' LEFT JOIN coel_personne ON (h1.cmhl_ce_modifier_par = cp_id_personne) '.
|
|
|
431 |
"WHERE h1.cmhl_ce_table = $table_id %s ".
|
|
|
432 |
'GROUP BY h1.cmhl_ce_table, h1.cmhl_cle_ligne, h1.cmhl_date_modification '.
|
|
|
433 |
'HAVING COUNT(*) = %s '.
|
|
|
434 |
'ORDER BY '.((!is_null($this->orderby)) ? $this->orderby : 'h1.cmhl_date_modification DESC').' '.
|
|
|
435 |
"LIMIT $this->start,$this->limit ";
|
|
|
436 |
$elements = $this->executerRequeteHistorique($requete);
|
|
|
437 |
return $elements;
|
|
|
438 |
}
|
|
|
439 |
|
|
|
440 |
private function executerRequete($requete) {
|
1785 |
aurelien |
441 |
$infos = null;
|
1497 |
jpm |
442 |
try {
|
|
|
443 |
$infos = $this->bdd->query($requete)->fetchAll(PDO::FETCH_ASSOC);
|
|
|
444 |
if ($infos === false) {
|
|
|
445 |
$this->messages[] = "La requête a retourné aucun résultat.";
|
|
|
446 |
}
|
|
|
447 |
} catch (PDOException $e) {
|
|
|
448 |
$this->messages[] = sprintf($this->getTxt('sql_erreur'), $e->getFile(), $e->getLine(), $e->getMessage());
|
|
|
449 |
}
|
|
|
450 |
return $infos;
|
|
|
451 |
}
|
|
|
452 |
|
|
|
453 |
private function fusionnerEnregistrements($infos) {
|
|
|
454 |
// Fusion des lignes
|
|
|
455 |
$elements = array();
|
|
|
456 |
foreach ($infos as $info) {
|
|
|
457 |
$id = $info['cmhl_ce_table'].'|'.$info['cmhl_cle_ligne'];
|
|
|
458 |
if (!isset($elements[$id])) {
|
|
|
459 |
$elements[$id] = $info;
|
|
|
460 |
} else {
|
|
|
461 |
if ($elements[$id]['cmhl_date_modification'] < $info['cmhl_date_modification']) {
|
|
|
462 |
$elements[$id] = $this->traiterInfosPrecedentes($info, $elements[$id]);
|
|
|
463 |
} else {
|
|
|
464 |
$elements[$id] = $this->traiterInfosPrecedentes($elements[$id], $info);
|
|
|
465 |
}
|
|
|
466 |
}
|
|
|
467 |
}
|
|
|
468 |
|
|
|
469 |
// Nettoyage et utilisation de la date pour pouvoir trier le tableau
|
|
|
470 |
$sortie = array();
|
|
|
471 |
foreach ($elements as $id => $element) {
|
|
|
472 |
$element = $this->nettoyerNomChamps($element);
|
|
|
473 |
$id_avec_date = $element['cmhl_date_modification'].'|'.$id;
|
|
|
474 |
$sortie[$id_avec_date] = $element;
|
|
|
475 |
}
|
|
|
476 |
|
|
|
477 |
return $sortie;
|
|
|
478 |
}
|
|
|
479 |
|
|
|
480 |
private function executerRequeteHistorique($requete) {
|
|
|
481 |
$elements = array();
|
|
|
482 |
|
|
|
483 |
// Récupération des 1er éléments
|
|
|
484 |
$requete_elements_1er = sprintf($requete, '', '1');
|
|
|
485 |
$infos_elements_1er = $this->executerRequete($requete_elements_1er);
|
|
|
486 |
|
|
|
487 |
// Construction de la requête pour récupérer les second éléments
|
|
|
488 |
$elements_1er_cle_ligne = array();
|
|
|
489 |
foreach ($infos_elements_1er as $info) {
|
1785 |
aurelien |
490 |
$elements_1er_cle_ligne[] = '"'.$info['cmhl_cle_ligne'].'"';
|
1497 |
jpm |
491 |
}
|
1743 |
aurelien |
492 |
$chaine_1er_elements = 'AND h1.cmhl_cle_ligne IN ('.str_replace(',,',',',implode(',', $elements_1er_cle_ligne)).') ';
|
1497 |
jpm |
493 |
$requete_elements_2nd = sprintf($requete, $chaine_1er_elements, '2');
|
|
|
494 |
|
|
|
495 |
// Récupération des 2nd éléments
|
|
|
496 |
$infos_elements_2nd = $this->executerRequete($requete_elements_2nd);
|
|
|
497 |
|
|
|
498 |
// Fusion des 1er et 2nd éléments
|
|
|
499 |
$infos = array_merge($infos_elements_1er, $infos_elements_2nd);
|
|
|
500 |
|
|
|
501 |
$elements = $this->fusionnerEnregistrements($infos);
|
|
|
502 |
return $elements;
|
|
|
503 |
}
|
|
|
504 |
|
|
|
505 |
private function executerService($champ_titre, $elements) {
|
|
|
506 |
// Prétraitement des données
|
|
|
507 |
$donnees = $this->construireDonneesCommunesAuFlux($elements);
|
|
|
508 |
foreach ($elements as $element) {
|
|
|
509 |
$xml = $this->getXmlHisto($element);
|
|
|
510 |
$enrg = $this->getTableauDepuisXmlHisto($xml);
|
|
|
511 |
$diff = $this->getDiffInfos($element);
|
|
|
512 |
$diff['differences'] = $this->getDiff($element);
|
|
|
513 |
$diff_html = (!is_null($diff['differences'])) ? Coel::traiterSquelettePhp($this->squelette_diff, $diff) : '';
|
|
|
514 |
|
|
|
515 |
$item = $this->construireDonneesCommunesAuxItems($element);
|
|
|
516 |
$item['titre'] = $this->creerTitre($champ_titre, $element, $enrg);
|
1772 |
aurelien |
517 |
$item['guid'] = sprintf($this->config['coel']['guid'], 'coel:'.$element['guid_type'].$element['guid']);
|
1497 |
jpm |
518 |
$item['lien'] = $this->config['coel']['urlBaseCoel'].'#'.urlencode($item['guid']);
|
|
|
519 |
$item['description'] = '<p>'.$this->getMessageModif($item).'</p>';
|
|
|
520 |
$item['description'] .= $this->creerDescription($element, $enrg);
|
|
|
521 |
$item['description'] .= $diff_html;
|
|
|
522 |
$item['description'] = $this->nettoyerTexte($item['description']);
|
|
|
523 |
$item['description_encodee'] = htmlspecialchars($item['description']);
|
|
|
524 |
|
|
|
525 |
$donnees['items'][] = $item;
|
|
|
526 |
}
|
|
|
527 |
|
|
|
528 |
// Création du contenu à partir d'un template PHP
|
|
|
529 |
$contenu = Coel::traiterSquelettePhp($this->squelette, $donnees);
|
|
|
530 |
|
|
|
531 |
return $contenu;
|
|
|
532 |
}
|
|
|
533 |
|
|
|
534 |
private function creerTitre($champ, $element, $enrg) {
|
|
|
535 |
$titre = '';
|
|
|
536 |
if (isset($element['titre'])) {
|
|
|
537 |
$titre = $element['titre'];
|
|
|
538 |
} else if (isset($element[$champ])) {
|
|
|
539 |
$titre = $element[$champ];
|
|
|
540 |
} else if (isset($enrg[$champ])) {
|
|
|
541 |
$titre = $enrg[$champ];
|
|
|
542 |
}
|
|
|
543 |
$titre = $this->nettoyerTexte($titre);
|
|
|
544 |
return $titre;
|
|
|
545 |
}
|
|
|
546 |
|
|
|
547 |
private function creerDescription($element, $enrg) {
|
|
|
548 |
$description = '';
|
|
|
549 |
if (isset($element['description'])) {
|
|
|
550 |
$description = $element['description'];
|
|
|
551 |
}
|
|
|
552 |
return $description;
|
|
|
553 |
}
|
|
|
554 |
|
|
|
555 |
private function nettoyerNomChamps($infos) {
|
|
|
556 |
$sortie = array();
|
|
|
557 |
foreach ($infos as $champ => $valeur) {
|
|
|
558 |
if (preg_match('/^__(.+)$/', $champ, $match)) {
|
|
|
559 |
$sortie[$match[1]] = $valeur;
|
|
|
560 |
} else {
|
|
|
561 |
$sortie[$champ] = $valeur;
|
|
|
562 |
}
|
|
|
563 |
}
|
|
|
564 |
return $sortie;
|
|
|
565 |
}
|
|
|
566 |
|
|
|
567 |
private function traiterInfosPrecedentes($infos_courantes, $infos_precedentes) {
|
|
|
568 |
$infos_precedentes_traitees = array();
|
|
|
569 |
foreach ($infos_precedentes as $champ => $valeur) {
|
1751 |
mathias |
570 |
$infos_precedentes_traitees['enrg_prec'] = null;
|
|
|
571 |
$infos_precedentes_traitees['date_prec'] = null;
|
1497 |
jpm |
572 |
if ($champ == 'cmhl_date_modification') {
|
|
|
573 |
$infos_precedentes_traitees['date_prec'] = $valeur;
|
|
|
574 |
} else if ($champ == 'cmhl_enregistrement') {
|
|
|
575 |
$infos_precedentes_traitees['enrg_prec'] = $valeur;
|
|
|
576 |
} else if (preg_match('/^__(.+)$/', $champ, $match)) {
|
|
|
577 |
$infos_precedentes_traitees[$match[1].'_prec'] = $valeur;
|
|
|
578 |
}
|
|
|
579 |
}
|
|
|
580 |
$sortie = array_merge($infos_courantes, $infos_precedentes_traitees);
|
|
|
581 |
return $sortie;
|
|
|
582 |
}
|
|
|
583 |
|
|
|
584 |
private function nettoyerTexte($txt) {
|
|
|
585 |
$txt = preg_replace('/&(?!amp;)/i', '&', $txt, -1);
|
|
|
586 |
return $txt;
|
|
|
587 |
}
|
|
|
588 |
|
|
|
589 |
private function getMessageModif($item) {
|
|
|
590 |
$message = $item['etat'].' le '.$item['date_maj_simple'].' par '.$item['modifier_par'].' depuis l\'IP '.$item['ip'];
|
|
|
591 |
return $message;
|
|
|
592 |
}
|
|
|
593 |
|
|
|
594 |
private function construireDonneesCommunesAuxItems($info) {
|
|
|
595 |
$item = array();
|
|
|
596 |
$date_modification_timestamp = strtotime($info['cmhl_date_modification']);
|
|
|
597 |
$item['date_maj_simple'] = strftime('%A %d %B %Y à %H:%M', $date_modification_timestamp);
|
|
|
598 |
$item['date_maj_RSS'] = date(DATE_RSS, $date_modification_timestamp);
|
|
|
599 |
$item['date_maj_ATOM'] = date(DATE_ATOM, $date_modification_timestamp);
|
|
|
600 |
$item['date_maj_W3C'] = date(DATE_W3C, $date_modification_timestamp);
|
|
|
601 |
$item['guid'] = $info['cmhl_id_historique_ligne'];
|
|
|
602 |
$item['cle'] = $info['cmhl_cle_ligne'];
|
|
|
603 |
$item['ip'] = $info['cmhl_ip'];
|
|
|
604 |
$item['modifier_par'] = $info['modifier_par'];
|
|
|
605 |
$item['etat'] = isset($info['cmhl_ce_etat']) ? $this->getTexteEtat($info['cmhl_ce_etat']) : '';
|
|
|
606 |
|
|
|
607 |
return $item;
|
|
|
608 |
}
|
|
|
609 |
|
|
|
610 |
private function getXmlHisto($info) {
|
|
|
611 |
$xml = '';
|
|
|
612 |
if ($info['cmhl_ce_etat'] == '3') {
|
1785 |
aurelien |
613 |
$xml = @$info['enrg_prec'];
|
1497 |
jpm |
614 |
} else {
|
|
|
615 |
$xml = $info['cmhl_enregistrement'];
|
|
|
616 |
}
|
|
|
617 |
return $xml;
|
|
|
618 |
}
|
|
|
619 |
|
|
|
620 |
private function getDiff($info) {
|
|
|
621 |
$diff = null;
|
|
|
622 |
if ($info['cmhl_ce_etat'] == '1') {
|
|
|
623 |
$nouveau = $this->getTableauDepuisXmlHisto($info['cmhl_enregistrement']);
|
|
|
624 |
foreach ($nouveau as $cle => $valeur) {
|
|
|
625 |
$diff[$cle] = array('type' => 'A', 'type_txt' => 'Ajout', 'nouveau' => $valeur, 'ancien' => ' ');
|
|
|
626 |
}
|
|
|
627 |
} else if ($info['cmhl_ce_etat'] == '2') {
|
|
|
628 |
$nouveau = $this->getTableauDepuisXmlHisto($info['cmhl_enregistrement']);
|
1785 |
aurelien |
629 |
$ancien = @$this->getTableauDepuisXmlHisto($info['enrg_prec']);
|
1497 |
jpm |
630 |
foreach ($nouveau as $cle => $valeur) {
|
|
|
631 |
if (!isset($ancien[$cle])) {
|
|
|
632 |
$diff[$cle] = array('type' => 'A', 'type_txt' => 'Ajout', 'nouveau' => $valeur, 'ancien' => ' ');
|
|
|
633 |
} else if (isset($ancien[$cle]) && $ancien[$cle] != $valeur) {
|
|
|
634 |
$diff[$cle] = array('type' => 'M', 'type_txt' => 'Modification', 'nouveau' => $valeur, 'ancien' => $ancien[$cle]);
|
|
|
635 |
}
|
|
|
636 |
}
|
|
|
637 |
foreach ($ancien as $cle => $valeur) {
|
|
|
638 |
if (!isset($nouveau[$cle])) {
|
|
|
639 |
$diff[$cle] = array('type' => 'S', 'type_txt' => 'Suppression', 'nouveau' => ' ', 'ancien' => $valeur);
|
|
|
640 |
}
|
|
|
641 |
}
|
|
|
642 |
}
|
|
|
643 |
return $diff;
|
|
|
644 |
}
|
|
|
645 |
|
|
|
646 |
private function getDiffInfos($info) {
|
|
|
647 |
$diff = null;
|
|
|
648 |
$format = '%d/%m/%Y à %H:%M:%S';
|
|
|
649 |
if ($info['cmhl_ce_etat'] == '1') {
|
|
|
650 |
$diff['date_nouvelle'] = strftime($format, strtotime($info['cmhl_date_modification']));
|
1749 |
mathias |
651 |
$diff['date_ancienne'] = '';
|
1497 |
jpm |
652 |
$diff['etat'] = 'A';
|
|
|
653 |
} else if ($info['cmhl_ce_etat'] == '2') {
|
|
|
654 |
$diff['date_nouvelle'] = strftime($format, strtotime($info['cmhl_date_modification']));
|
1785 |
aurelien |
655 |
$diff['date_ancienne'] = @strftime($format, strtotime($info['date_prec']));
|
1497 |
jpm |
656 |
$diff['etat'] = 'M';
|
|
|
657 |
} else if ($info['cmhl_ce_etat'] == '3') {
|
|
|
658 |
$diff['etat'] = 'S';
|
|
|
659 |
}
|
|
|
660 |
return $diff;
|
|
|
661 |
}
|
|
|
662 |
|
|
|
663 |
private function getTexteEtat($code) {
|
|
|
664 |
$etat = '';
|
|
|
665 |
switch ($code) {
|
|
|
666 |
case '1' :
|
|
|
667 |
$etat = 'Ajouté';
|
|
|
668 |
break;
|
|
|
669 |
case '2' :
|
|
|
670 |
$etat = 'Modifié';
|
|
|
671 |
break;
|
|
|
672 |
case '3' :
|
|
|
673 |
$etat = 'Supprimé';
|
|
|
674 |
break;
|
|
|
675 |
default :
|
|
|
676 |
$etat = '!Problème!';
|
|
|
677 |
$e = "Le champ cmhl_ce_etat possède une valeur innatendue : $code";
|
|
|
678 |
$this->messages[] = $e;
|
|
|
679 |
}
|
|
|
680 |
return $etat;
|
|
|
681 |
}
|
|
|
682 |
|
|
|
683 |
private function construireDonneesCommunesAuFlux($infos) {
|
|
|
684 |
$donnees = $this->getFlux($this->service);
|
|
|
685 |
$donnees['guid'] = $this->getUrlServiceBase();
|
1625 |
aurelien |
686 |
$donnees['lien_service'] = htmlentities($this->creerUrlService());
|
1497 |
jpm |
687 |
$donnees['lien_coel'] = $this->config['coel']['urlBaseCoel'];
|
|
|
688 |
$donnees['editeur'] = $this->config['coel']['editeur'];
|
|
|
689 |
$derniere_info_en_date = reset($infos);
|
|
|
690 |
$date_modification_timestamp = strtotime($derniere_info_en_date['cmhl_date_modification']);
|
|
|
691 |
$donnees['date_maj_RSS'] = date(DATE_RSS, $date_modification_timestamp);
|
|
|
692 |
$donnees['date_maj_ATOM'] = date(DATE_ATOM, $date_modification_timestamp);
|
|
|
693 |
$donnees['date_maj_W3C'] = date(DATE_W3C, $date_modification_timestamp);
|
|
|
694 |
$donnees['annee_courante'] = date('Y');
|
|
|
695 |
$donnees['generateur'] = 'COEL - Jrest';
|
|
|
696 |
preg_match('/([0-9]+)/', '$Revision: 381 $', $match);
|
|
|
697 |
$donnees['generateur_version'] = $match[1];
|
|
|
698 |
return $donnees;
|
|
|
699 |
}
|
|
|
700 |
|
|
|
701 |
private function creerUrlService() {
|
|
|
702 |
$url_service = $this->getUrlServiceBase();
|
|
|
703 |
if (isset($this->start) || isset($this->limit)) {
|
|
|
704 |
$arguments = array();
|
|
|
705 |
if (isset($this->start) && isset($_GET['start'])) {
|
|
|
706 |
$arguments[] = 'start='.$this->start;
|
|
|
707 |
}
|
|
|
708 |
if (isset($this->limit) && isset($_GET['limit'])) {
|
|
|
709 |
$arguments[] = 'limit='.($this->limit/2);
|
|
|
710 |
}
|
|
|
711 |
if (count($arguments) > 0) {
|
|
|
712 |
$url_service .= '?'.implode('&', $arguments);
|
|
|
713 |
}
|
|
|
714 |
}
|
|
|
715 |
return $url_service;
|
|
|
716 |
}
|
|
|
717 |
}
|