7 |
david |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
/***************************************************************************\
|
|
|
4 |
* SPIP, Systeme de publication pour l'internet *
|
|
|
5 |
* *
|
|
|
6 |
* Copyright (c) 2001-2005 *
|
|
|
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 |
|
|
|
14 |
//
|
|
|
15 |
// Ce fichier ne sera execute qu'une fois
|
|
|
16 |
if (defined("_ECRIRE_INC_SUIVI_REVISIONS")) return;
|
|
|
17 |
define("_ECRIRE_INC_SUIVI_REVISIONS", "1");
|
|
|
18 |
|
|
|
19 |
include_ecrire("inc_lab.php");
|
|
|
20 |
include_spip("ecrire.php");
|
|
|
21 |
|
|
|
22 |
function afficher_para_modifies ($texte, $court = false) {
|
|
|
23 |
// Limiter la taille de l'affichage
|
|
|
24 |
if ($court) $max = 200;
|
|
|
25 |
else $max = 2000;
|
|
|
26 |
|
|
|
27 |
$paras = explode ("\n",$texte);
|
|
|
28 |
for ($i = 0; $i < count($paras) AND strlen($texte_ret) < $max; $i++) {
|
|
|
29 |
if (strpos($paras[$i], '"diff-')) $texte_ret .= $paras[$i]."\n\n";
|
|
|
30 |
}
|
|
|
31 |
$texte = $texte_ret;
|
|
|
32 |
return $texte;
|
|
|
33 |
}
|
|
|
34 |
|
|
|
35 |
function afficher_suivi_versions ($debut = 0, $id_secteur = 0, $id_auteur = false, $lang = "", $court = false, $rss = false) {
|
|
|
36 |
global $dir_lang;
|
|
|
37 |
|
|
|
38 |
$nb_aff = 10;
|
|
|
39 |
$champs = array('surtitre', 'titre', 'soustitre', 'descriptif', 'nom_site', 'url_site', 'chapo', 'texte', 'ps');
|
|
|
40 |
|
|
|
41 |
if ($id_auteur) {
|
|
|
42 |
$req_where = " AND articles.statut IN ('prepa','prop','publie')";
|
|
|
43 |
$req_where = " AND versions.id_auteur = $id_auteur";
|
|
|
44 |
} else {
|
|
|
45 |
$req_where = " AND articles.statut IN ('prop','publie')";
|
|
|
46 |
}
|
|
|
47 |
|
|
|
48 |
if (strlen($lang) > 0) $req_where .= " AND articles.lang='$lang'";
|
|
|
49 |
|
|
|
50 |
if ($id_secteur > 0) $req_where .= " AND articles.id_secteur = $id_secteur";
|
|
|
51 |
|
|
|
52 |
$query = "
|
|
|
53 |
SELECT versions.*, articles.statut, articles.titre
|
|
|
54 |
FROM spip_versions AS versions, spip_articles AS articles
|
|
|
55 |
WHERE versions.id_article = articles.id_article AND versions.id_version > 1 $req_where ";
|
|
|
56 |
|
|
|
57 |
$result = spip_query($query . " ORDER BY versions.date DESC LIMIT $debut, $nb_aff");
|
|
|
58 |
if (spip_num_rows($result) > 0) {
|
|
|
59 |
|
|
|
60 |
// Afficher l'entete de la boite
|
|
|
61 |
if (!$rss) {
|
|
|
62 |
$titre_table = _T('icone_suivi_revisions').aide('suivimodif');
|
|
|
63 |
if ($court)
|
|
|
64 |
$titre_table = afficher_plus("suivi_revisions.php3")
|
|
|
65 |
. $titre_table;
|
|
|
66 |
|
|
|
67 |
echo "<div style='height: 12px;'></div>";
|
|
|
68 |
echo "<div class='liste'>";
|
|
|
69 |
bandeau_titre_boite2($titre_table, "historique-24.gif");
|
|
|
70 |
|
|
|
71 |
$total = spip_num_rows(spip_query($query . "LIMIT 0, 149"));
|
|
|
72 |
|
|
|
73 |
if ($total > $nb_aff) {
|
|
|
74 |
$nb_tranches = ceil($total / $nb_aff);
|
|
|
75 |
|
|
|
76 |
echo "<div class='arial2' style='background-color: #dddddd; padding: 5px;'>";
|
|
|
77 |
|
|
|
78 |
for ($i = 0; $i < $nb_tranches; $i++) {
|
|
|
79 |
if ($i > 0) echo " | ";
|
|
|
80 |
if ($i*$nb_aff == $debut) echo "<b>";
|
|
|
81 |
else echo "<a href='suivi_revisions.php3?debut=".($i * $nb_aff)."&id_secteur=$id_secteur&uniq_auteur=$uniq_auteur&lang_choisie=$lang'>";
|
|
|
82 |
echo (($i * $nb_aff) + 1);
|
|
|
83 |
if ($i*$nb_aff == $debut) echo "</b>";
|
|
|
84 |
else echo "</a>";
|
|
|
85 |
}
|
|
|
86 |
echo "</div>";
|
|
|
87 |
}
|
|
|
88 |
}
|
|
|
89 |
|
|
|
90 |
// Afficher les 10 elements
|
|
|
91 |
while ($row = spip_fetch_array($result)) {
|
|
|
92 |
$id_version = $row['id_version'];
|
|
|
93 |
$id_auteur = $row['id_auteur'];
|
|
|
94 |
$date = $row['date'];
|
|
|
95 |
$id_article = $row['id_article'];
|
|
|
96 |
$statut = $row['statut'];
|
|
|
97 |
$titre = propre($row['titre']);
|
|
|
98 |
$query_auteur = "
|
|
|
99 |
SELECT nom,email
|
|
|
100 |
FROM spip_auteurs
|
|
|
101 |
WHERE id_auteur = $id_auteur";
|
|
|
102 |
$row_auteur = spip_fetch_array(spip_query($query_auteur));
|
|
|
103 |
$nom = typo($row_auteur["nom"]);
|
|
|
104 |
$email = $row_auteur['email'];
|
|
|
105 |
|
|
|
106 |
|
|
|
107 |
$logo_statut = "puce-".puce_statut($statut).".gif";
|
|
|
108 |
|
|
|
109 |
if (!$rss) {
|
|
|
110 |
echo "<div class='tr_liste' style='padding: 5px; border-top: 1px solid #aaaaaa;'>";
|
|
|
111 |
|
|
|
112 |
echo "<span class='arial2'>";
|
|
|
113 |
if (!$court) echo bouton_block_visible("$id_version-$id_article-$id_auteur");
|
|
|
114 |
echo "<img src='" . _DIR_IMG_PACK . "$logo_statut' border='0'> ";
|
|
|
115 |
echo "<a class='$statut' style='font-weight: bold;' href='articles_versions.php3?id_article=$id_article'>$titre</a>";
|
|
|
116 |
echo "</span>";
|
|
|
117 |
echo "<span class='arial1'$dir_lang>";
|
|
|
118 |
echo " ".date_relative($date)." ";
|
|
|
119 |
if (strlen($nom)>0) echo "($nom)";
|
|
|
120 |
echo "</span>";
|
|
|
121 |
} else {
|
|
|
122 |
$item = array(
|
|
|
123 |
'title' => $titre,
|
|
|
124 |
'url' => lire_meta('adresse_site').'/'._DIR_RESTREINT_ABS."articles_versions.php3?id_article=$id_article&id_version=$id_version",
|
|
|
125 |
'date' => $date,
|
|
|
126 |
'author' => $nom,
|
|
|
127 |
'email' => $email
|
|
|
128 |
);
|
|
|
129 |
}
|
|
|
130 |
|
|
|
131 |
if (!$court) {
|
|
|
132 |
$query_diff = "
|
|
|
133 |
SELECT id_version
|
|
|
134 |
FROM spip_versions
|
|
|
135 |
WHERE id_article=$id_article AND id_version<$id_version
|
|
|
136 |
ORDER BY id_version DESC LIMIT 0,1";
|
|
|
137 |
if ($result_diff = spip_query($query_diff)) {
|
|
|
138 |
$row_diff = spip_fetch_array($result_diff);
|
|
|
139 |
$id_diff = $row_diff['id_version'];
|
|
|
140 |
}
|
|
|
141 |
|
|
|
142 |
|
|
|
143 |
$query_art = "
|
|
|
144 |
SELECT *
|
|
|
145 |
FROM spip_articles
|
|
|
146 |
WHERE id_article='$id_article'";
|
|
|
147 |
$result_art = spip_query($query_art);
|
|
|
148 |
|
|
|
149 |
if ($row_art = spip_fetch_array($result_art)) {
|
|
|
150 |
$id_article = $row_art["id_article"];
|
|
|
151 |
$id_rubrique = $row_art["id_rubrique"];
|
|
|
152 |
$date = $row_art["date"];
|
|
|
153 |
$statut_article = $row_art["statut"];
|
|
|
154 |
$maj = $row_art["maj"];
|
|
|
155 |
$date_redac = $row_art["date_redac"];
|
|
|
156 |
$visites = $row_art["visites"];
|
|
|
157 |
$referers = $row_art["referers"];
|
|
|
158 |
$extra = $row_art["extra"];
|
|
|
159 |
$id_trad = $row_art["id_trad"];
|
|
|
160 |
}
|
|
|
161 |
|
|
|
162 |
$textes = recuperer_version($id_article, $id_version);
|
|
|
163 |
|
|
|
164 |
if ($id_version && $id_diff) {
|
|
|
165 |
if ($id_diff > $id_version) {
|
|
|
166 |
$t = $id_version;
|
|
|
167 |
$id_version = $id_diff;
|
|
|
168 |
$id_diff = $t;
|
|
|
169 |
$old = $textes;
|
|
|
170 |
$new = $textes = recuperer_version($id_article, $id_version);
|
|
|
171 |
}
|
|
|
172 |
else {
|
|
|
173 |
$old = recuperer_version($id_article, $id_diff);
|
|
|
174 |
$new = $textes;
|
|
|
175 |
}
|
|
|
176 |
$textes = array();
|
|
|
177 |
foreach ($champs as $champ) {
|
|
|
178 |
if (!$new[$champ] && !$old[$champ]) continue;
|
|
|
179 |
$diff = new Diff(new DiffTexte);
|
|
|
180 |
$textes[$champ] = afficher_para_modifies(afficher_diff($diff->comparer(preparer_diff($new[$champ]), preparer_diff($old[$champ]))), $court);
|
|
|
181 |
}
|
|
|
182 |
}
|
|
|
183 |
|
|
|
184 |
if (!$rss)
|
|
|
185 |
echo debut_block_visible("$id_version-$id_article-$id_auteur");
|
|
|
186 |
|
|
|
187 |
if (is_array($textes))
|
|
|
188 |
foreach ($textes as $var => $t) {
|
|
|
189 |
if (strlen($t) > 0) {
|
|
|
190 |
if (!$rss) echo "<blockquote class='serif1'>";
|
|
|
191 |
$aff = propre_diff($t);
|
|
|
192 |
if ($GLOBALS['les_notes']) {
|
|
|
193 |
$aff .= '<p>'.$GLOBALS['les_notes'];
|
|
|
194 |
$GLOBALS['les_notes'] = '';
|
|
|
195 |
}
|
|
|
196 |
if (!$rss) {
|
|
|
197 |
echo $aff;
|
|
|
198 |
echo "</blockquote>";
|
|
|
199 |
} else
|
|
|
200 |
$item['description'] = $aff;
|
|
|
201 |
}
|
|
|
202 |
}
|
|
|
203 |
if (!$rss) echo fin_block();
|
|
|
204 |
}
|
|
|
205 |
|
|
|
206 |
if (!$rss) echo "</div>";
|
|
|
207 |
|
|
|
208 |
if ($rss)
|
|
|
209 |
$items[] = $item;
|
|
|
210 |
}
|
|
|
211 |
if (!$rss) echo "</div>";
|
|
|
212 |
}
|
|
|
213 |
|
|
|
214 |
if ($rss)
|
|
|
215 |
return $items;
|
|
|
216 |
}
|
|
|
217 |
|
|
|
218 |
?>
|