[SPIP] ~v3.0.20-->v3.0.25
[lhc/web/clavette_www.git] / www / plugins-dist / revisions / afficher_diff / jointure.php
1 <?php
2
3 /***************************************************************************\
4 * SPIP, Systeme de publication pour l'internet *
5 * *
6 * Copyright (c) 2001-2016 *
7 * Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
8 * *
9 * Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
10 * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
11 \***************************************************************************/
12
13 if (!defined("_ECRIRE_INC_VERSION")) return;
14
15 include_spip('inc/diff');
16
17 /**
18 * Afficher le diff d'un champ texte generique
19 * @param string $champ
20 * @param string $old
21 * @param string $new
22 * @param string $format
23 * apercu, diff ou complet
24 * @return string
25 */
26 function afficher_diff_jointure_dist($champ,$old,$new,$format='diff'){
27 $join = substr($champ,9);
28 $objet = objet_type($join);
29
30 $old = explode(',',$old);
31 $new = explode(',',$new);
32
33 $liste = array();
34
35 // les communs
36 $intersection = array_intersect($new,$old);
37 foreach($intersection as $id)
38 if ($id=intval(trim($id)))
39 $liste[$id] = "<a href='".generer_url_entite($id,$objet)."' title='"._T(objet_info($objet,'texte_objet'))." $id'>".generer_info_entite($id,$objet,'titre')."</a>";
40
41 // les supprimes
42 $old = array_diff($old,$intersection);
43 foreach($old as $id)
44 if ($id=intval(trim($id)))
45 $liste[$id] = "<span class='diff-supprime'>"
46 . "<a href='".generer_url_entite($id,$objet)."' title='"._T(objet_info($objet,'texte_objet'))." $id'>".generer_info_entite($id,$objet,'titre')."</a>"
47 . "</span>";
48
49 // les ajoutes
50 $new = array_diff($new,$intersection);
51 foreach($new as $id)
52 if ($id=intval(trim($id)))
53 $liste[$id] = "<span class='diff-ajoute'>"
54 . "<a href='".generer_url_entite($id,$objet)."' title='"._T(objet_info($objet,'texte_objet'))." $id'>".generer_info_entite($id,$objet,'titre')."</a>"
55 . "</span>";
56
57 ksort($liste);
58 $liste = implode(', ',$liste);
59 return $liste;
60 }