1 | <?php |
---|
2 | |
---|
3 | |
---|
4 | // mots_partout.php |
---|
5 | // Fichier créé pour SPIP avec un bout de code emprunté à celui ci. |
---|
6 | // Distribué sans garantie sous licence GPL. |
---|
7 | // |
---|
8 | // Copyright (C) 2005 Pierre ANDREWS |
---|
9 | // |
---|
10 | // This program is free software; you can redistribute it and/or modify |
---|
11 | // it under the terms of the GNU General Public License as published by |
---|
12 | // the Free Software Foundation; either version 2 of the License, or any later version. |
---|
13 | // |
---|
14 | // This program is distributed in the hope that it will be useful, |
---|
15 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
17 | // GNU General Public License for more details. |
---|
18 | // |
---|
19 | // You should have received a copy of the GNU General Public License |
---|
20 | // along with this program; if not, write to the Free Software |
---|
21 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
22 | |
---|
23 | include ("inc.php3"); |
---|
24 | include_ecrire ("inc_version.php3"); |
---|
25 | include_ecrire ("inc_documents.php3"); |
---|
26 | include_ecrire ("inc_abstract_sql.php3"); |
---|
27 | include_ecrire ("inc_objet.php3"); |
---|
28 | include('_libs_/tag-machine/inc_tag-machine.php'); |
---|
29 | |
---|
30 | /*********************************************************************** |
---|
31 | * Définition des choses sur lesquels on peut vouloir mettre des mots clefs |
---|
32 | ***********************************************************************/ |
---|
33 | |
---|
34 | |
---|
35 | $choses_possibles['articles'] = array( |
---|
36 | 'titre_chose' => 'public:articles', |
---|
37 | 'id_chose' => 'id_article', |
---|
38 | 'table_principale' => 'spip_articles', |
---|
39 | 'table_auth' => 'spip_auteurs_articles', |
---|
40 | 'tables_limite' => array( |
---|
41 | 'articles' => array( |
---|
42 | 'table' => 'spip_articles', |
---|
43 | 'nom_id' => 'id_article'), |
---|
44 | 'rubriques' => array( |
---|
45 | 'table' => 'spip_articles', |
---|
46 | 'nom_id' => 'id_rubrique'), |
---|
47 | 'documents' => array( |
---|
48 | 'table' => 'spip_documents_articles', |
---|
49 | 'nom_id' => 'id_document'), |
---|
50 | 'auteurs' => array( |
---|
51 | 'table' => 'spip_auteurs_articles', |
---|
52 | 'nom_id' => 'id_auteur') |
---|
53 | ) |
---|
54 | ); |
---|
55 | |
---|
56 | |
---|
57 | $choses_possibles['documents'] = array( |
---|
58 | 'titre_chose' => 'info_documents', |
---|
59 | 'id_chose' => 'id_document', |
---|
60 | 'table_principale' => 'spip_documents', |
---|
61 | 'tables_limite' => array( |
---|
62 | 'articles' => array( |
---|
63 | 'table' => 'spip_documents_articles', |
---|
64 | 'nom_id' => 'id_article'), |
---|
65 | 'rubriques' => array( |
---|
66 | 'table' => 'spip_documents_rubriques', |
---|
67 | 'nom_id' => 'id_rubrique'), |
---|
68 | 'documents' => array( |
---|
69 | 'table' => 'spip_documents', |
---|
70 | 'nom_id' => 'id_document') |
---|
71 | ) |
---|
72 | ); |
---|
73 | |
---|
74 | $choses_possibles['auteurs'] = array( |
---|
75 | 'titre_chose' => 'auteurs', |
---|
76 | 'id_chose' => 'id_auteur', |
---|
77 | 'table_principale' => 'spip_auteurs', |
---|
78 | 'tables_limite' => array( |
---|
79 | 'auteurs' => array( |
---|
80 | 'table' => 'spip_auteurs', |
---|
81 | 'nom_id' => 'id_auteur'), |
---|
82 | 'articles' => array( |
---|
83 | 'table' => 'spip_auteurs_articles', |
---|
84 | 'nom_id' => 'id_auteur') |
---|
85 | ) |
---|
86 | ); |
---|
87 | |
---|
88 | $choses_possibles['messages'] = array( |
---|
89 | 'titre_chose' => 'Messages', |
---|
90 | 'id_chose' => 'id_message', |
---|
91 | 'table_principale' => 'spip_messages', |
---|
92 | |
---|
93 | 'table_auth' => 'spip_auteurs_messages', |
---|
94 | 'tables_limite' => array( |
---|
95 | 'messages' => array( |
---|
96 | 'table' => 'spip_messages', |
---|
97 | 'nom_id' => 'id_message'), |
---|
98 | 'auteurs' => array( |
---|
99 | 'table' => 'spip_auteurs_messages', |
---|
100 | 'nom_id' => 'id_auteur') |
---|
101 | ) |
---|
102 | ); |
---|
103 | |
---|
104 | /*********************************************************************** |
---|
105 | * installation |
---|
106 | ***********************************************************************/ |
---|
107 | |
---|
108 | if ($HTTP_GET_VARS['installation']=='oui'){ |
---|
109 | spip_query("ALTER TABLE `spip_groupes_mots` ADD `documents` CHAR( 3 ) NOT NULL DEFAULT 'non';"); |
---|
110 | spip_query("ALTER TABLE `spip_groupes_mots` ADD `messages` CHAR( 3 ) NOT NULL DEFAULT 'non';"); |
---|
111 | spip_query("ALTER TABLE `spip_groupes_mots` ADD `auteurs` CHAR( 3 ) NOT NULL DEFAULT 'non';"); |
---|
112 | spip_query("CREATE TABLE `spip_mots_documents` (`id_mot` bigint(20) NOT NULL default '0',`id_document` bigint(1) NOT NULL default '0', |
---|
113 | KEY `id_document` (`id_document`),KEY `id_mot` (`id_mot`)) TYPE=MyISAM;;"); |
---|
114 | spip_query("CREATE TABLE `spip_mots_messages` (`id_mot` bigint(20) NOT NULL default '0',`id_message` bigint(1) NOT NULL default '0', |
---|
115 | KEY `id_message` (`id_message`),KEY `id_mot` (`id_mot`)) TYPE=MyISAM;;"); |
---|
116 | spip_query("CREATE TABLE `spip_mots_auteurs` (`id_mot` bigint(20) NOT NULL default '0',`id_auteur` bigint(1) NOT NULL default '0', |
---|
117 | KEY `id_auteur` (`id_auteur`),KEY `id_mot` (`id_mot`)) TYPE=MyISAM;;"); |
---|
118 | } |
---|
119 | |
---|
120 | |
---|
121 | /*********************************************************************** |
---|
122 | * function |
---|
123 | ***********************************************************************/ |
---|
124 | |
---|
125 | |
---|
126 | function verifier_admin() { |
---|
127 | global $connect_statut, $connect_toutes_rubriques; |
---|
128 | return (($connect_statut == '0minirezo') AND $connect_toutes_rubriques); |
---|
129 | } |
---|
130 | |
---|
131 | function verifier_admin_restreint($id_rubrique) { |
---|
132 | global $connect_id_auteur; |
---|
133 | global $connect_statut, $connect_toutes_rubriques; |
---|
134 | |
---|
135 | } |
---|
136 | |
---|
137 | function verifier_auteur($table, $id_objet, $id) { |
---|
138 | global $connect_id_auteur; |
---|
139 | $select = array('id_auteur'); |
---|
140 | |
---|
141 | $from = array($table); |
---|
142 | |
---|
143 | $where = array("id_auteur = $connect_id_auteur", "$id_chose = $id"); |
---|
144 | |
---|
145 | $result = spip_abstract_select($select,$from,$where); |
---|
146 | |
---|
147 | if (spip_abstract_count($result) > 0) { |
---|
148 | spip_abstract_free($result); |
---|
149 | return true; |
---|
150 | } |
---|
151 | spip_abstract_free($result); |
---|
152 | return false; |
---|
153 | } |
---|
154 | |
---|
155 | |
---|
156 | function calcul_numeros($array, $search, $total) { |
---|
157 | if(is_array($array)) |
---|
158 | $tt = count(array_keys($array,$search)); |
---|
159 | else |
---|
160 | return 0; |
---|
161 | |
---|
162 | if($tt == 0) return 0; |
---|
163 | if($tt < $total) return 1; |
---|
164 | return 2; |
---|
165 | } |
---|
166 | |
---|
167 | function md_afficher_liste($largeurs, $table, $styles = '') { |
---|
168 | global $couleur_claire; |
---|
169 | global $browser_name; |
---|
170 | global $spip_display; |
---|
171 | global $spip_lang_left; |
---|
172 | |
---|
173 | if (!is_array($table)) return; |
---|
174 | reset($table); |
---|
175 | echo "\n"; |
---|
176 | if ($spip_display != 4) { |
---|
177 | while (list(,$t) = each($table)) { |
---|
178 | if (eregi("msie", $browser_name)) $msover = " onMouseOver=\"changeclass(this,'tr_liste_over');\" onMouseOut=\"changeclass(this,'tr_liste');\""; |
---|
179 | echo "<tr class='tr_liste'$msover>"; |
---|
180 | reset($largeurs); |
---|
181 | if ($styles) reset($styles); |
---|
182 | while (list($texte, $sel) = each($t)) { |
---|
183 | $style = $largeur = ""; |
---|
184 | list(, $largeur) = each($largeurs); |
---|
185 | if ($styles) list(,$style) = each($styles); |
---|
186 | if (!trim($texte)) $texte .= " "; |
---|
187 | echo "<td"; |
---|
188 | if ($largeur) echo " width=\"$largeur\""; |
---|
189 | if ($style) echo ' class="'.$style[$sel].'"'; |
---|
190 | echo ">$texte</td>"; |
---|
191 | } |
---|
192 | echo "</tr>\n"; |
---|
193 | } |
---|
194 | } else { |
---|
195 | echo "<ul style='text-align: $spip_lang_left;'>"; |
---|
196 | while (list(, $t) = each($table)) { |
---|
197 | echo "<li>"; |
---|
198 | reset($largeurs); |
---|
199 | if ($styles) reset($styles); |
---|
200 | while (list(, $texte) = each($t)) { |
---|
201 | $style = $largeur = ""; |
---|
202 | list(, $largeur) = each($largeurs); |
---|
203 | |
---|
204 | if (!$largeur) { |
---|
205 | echo $texte." "; |
---|
206 | } |
---|
207 | } |
---|
208 | echo "</li>\n"; |
---|
209 | } |
---|
210 | echo "</ul>"; |
---|
211 | } |
---|
212 | echo "\n"; |
---|
213 | } |
---|
214 | |
---|
215 | |
---|
216 | function find_tables($nom, $tables) { |
---|
217 | $toret = array(); |
---|
218 | foreach($tables as $t => $dec) { |
---|
219 | if(ereg($nom,$t)) { |
---|
220 | $toret[] = $t; |
---|
221 | } |
---|
222 | } |
---|
223 | return $toret; |
---|
224 | } |
---|
225 | |
---|
226 | function calcul_in($mots) { |
---|
227 | for($i=0; $i < count($mots); $i++) { |
---|
228 | if($i > 0) $to_ret .= ','; |
---|
229 | $to_ret .= $mots[$i]; |
---|
230 | } |
---|
231 | |
---|
232 | return $to_ret; |
---|
233 | } |
---|
234 | |
---|
235 | //====================================================================== |
---|
236 | |
---|
237 | function afficher_horizontal_document_assoc($id_document,$with_check, $case) { |
---|
238 | global $connect_id_auteur, $connect_statut; |
---|
239 | global $spip_lang_left, $spip_lang_right; |
---|
240 | |
---|
241 | $bord_droit = 2; |
---|
242 | |
---|
243 | $select = array('*'); |
---|
244 | $from = array('spip_documents'); |
---|
245 | $where = array("id_document = $id_document"); |
---|
246 | |
---|
247 | $results = spip_abstract_select($select,$from,$where); |
---|
248 | |
---|
249 | if($document = spip_abstract_fetch($results)) { |
---|
250 | $id_vignette = $document['id_vignette']; |
---|
251 | $id_type = $document['id_type']; |
---|
252 | $titre = $document['titre']; |
---|
253 | $descriptif = $document['descriptif']; |
---|
254 | $url = generer_url_document($id_document); |
---|
255 | $fichier = $document['fichier']; |
---|
256 | $largeur = $document['largeur']; |
---|
257 | $hauteur = $document['hauteur']; |
---|
258 | $taille = $document['taille']; |
---|
259 | $date = $document['date']; |
---|
260 | $mode = $document['mode']; |
---|
261 | |
---|
262 | if ($case == 0) { |
---|
263 | echo "<tr style='border-top: 1px solid black;'>"; |
---|
264 | } |
---|
265 | |
---|
266 | $style = "border-$spip_lang_left: 1px solid $couleur; border-bottom: 1px solid $couleur;"; |
---|
267 | if ($case == $bord_droit) $style .= " border-$spip_lang_right: 1px solid $couleur;"; |
---|
268 | echo "<td width='33%' style='text-align: $spip_lang_left; $style' valign='top'>"; |
---|
269 | |
---|
270 | echo "<label for='doc$case'>"._T('motspartout:voir').'</label>'; |
---|
271 | echo "<input type='checkbox' name='id_choses[]' id='doc$case' value='$id_document' />"; |
---|
272 | |
---|
273 | // Signaler les documents distants par une icone de trombone |
---|
274 | if ($document['distant'] == 'oui') { |
---|
275 | echo "<img src='"._DIR_IMG_PACK.'attachment.gif'."' style='float: $spip_lang_right;' alt=\"".entites_html($document['fichier'])."\" title=\"" . |
---|
276 | entites_html($document['fichier'])."\" />\n"; |
---|
277 | } |
---|
278 | |
---|
279 | // bloc vignette + rotation |
---|
280 | echo "<div style='text-align:center;'>"; |
---|
281 | |
---|
282 | |
---|
283 | # 'extension', a ajouter dans la base quand on supprimera spip_types_documents |
---|
284 | switch ($id_type) { |
---|
285 | case 1: |
---|
286 | $document['extension'] = "jpg"; |
---|
287 | break; |
---|
288 | case 2: |
---|
289 | $document['extension'] = "png"; |
---|
290 | break; |
---|
291 | case 3: |
---|
292 | $document['extension'] = "gif"; |
---|
293 | break; |
---|
294 | } |
---|
295 | |
---|
296 | // |
---|
297 | // Recuperer la vignette et afficher le doc |
---|
298 | // |
---|
299 | echo document_et_vignette($document, $url, true); |
---|
300 | |
---|
301 | echo "</div>"; // fin du bloc vignette + rotation |
---|
302 | |
---|
303 | |
---|
304 | // bloc titre et descriptif |
---|
305 | if (strlen($titre) > 0) { |
---|
306 | echo "<div class='verdana2'><b>".typo($titre)."</b>"; |
---|
307 | echo '</div>'; |
---|
308 | } else { |
---|
309 | $nom_fichier = basename($fichier); |
---|
310 | |
---|
311 | if (strlen($nom_fichier) > 20) { |
---|
312 | $nom_fichier = substr($nom_fichier, 0, 10)."...".substr($nom_fichier, strlen($nom_fichier)-10, strlen($nom_fichier)); |
---|
313 | } |
---|
314 | echo "<div class='verdana1' style='text-align:center;'>$triangle$nom_fichier"; |
---|
315 | echo '</div>'; |
---|
316 | } |
---|
317 | |
---|
318 | if (strlen($descriptif) > 0) { |
---|
319 | echo "<div class='verdana1'>".propre($descriptif)."</div>"; |
---|
320 | } |
---|
321 | |
---|
322 | // Taille de l'image ou poids du document |
---|
323 | echo "<div class='verdana1' style='text-align: center;'>"; |
---|
324 | if ($largeur * $hauteur) |
---|
325 | echo _T('info_largeur_vignette', |
---|
326 | array('largeur_vignette' => $largeur, |
---|
327 | 'hauteur_vignette' => $hauteur)); |
---|
328 | else |
---|
329 | echo taille_en_octets($taille); |
---|
330 | echo "</div>"; |
---|
331 | |
---|
332 | |
---|
333 | echo "</td>\n"; |
---|
334 | } |
---|
335 | } |
---|
336 | |
---|
337 | function afficher_liste_documents($choses) { |
---|
338 | global $spip_lang_left; |
---|
339 | echo "<table width='100%' cellspacing='0' cellpadding='3' style=\"border-top:1px solid black\">\n"; |
---|
340 | $i=0; |
---|
341 | foreach($choses as $id_chose) { |
---|
342 | afficher_horizontal_document_assoc($id_chose,true,$i); |
---|
343 | $i++; |
---|
344 | if ($i > 2) { |
---|
345 | $i = 0; |
---|
346 | echo "</tr>\n"; |
---|
347 | } |
---|
348 | } |
---|
349 | // fermer la derniere ligne |
---|
350 | if ($i > 0) { |
---|
351 | echo "<td style='border-$spip_lang_left: 1px solid $couleur;'> </td>"; |
---|
352 | echo "</tr>"; |
---|
353 | } |
---|
354 | echo '</table>'; |
---|
355 | } |
---|
356 | |
---|
357 | //====================================================================== |
---|
358 | |
---|
359 | function afficher_liste_articles($choses) { |
---|
360 | // echo "<div style='height: 12px;'></div>"; |
---|
361 | echo "<div class='liste'>"; |
---|
362 | bandeau_titre_boite2('Articles', "article-24.gif"); |
---|
363 | |
---|
364 | echo afficher_liste_debut_tableau(); |
---|
365 | |
---|
366 | $from = array('spip_articles as articles'); |
---|
367 | $select= array(); |
---|
368 | $select[] = 'id_article'; |
---|
369 | $select[] = 'titre'; |
---|
370 | $select[] = 'id_rubrique'; |
---|
371 | $select[] = 'date'; |
---|
372 | $select[] = 'statut'; |
---|
373 | $select[] = 'lang'; |
---|
374 | $select[] = 'descriptif'; |
---|
375 | $where = array('articles.id_article IN ('.calcul_in($choses).')'); |
---|
376 | |
---|
377 | $result = spip_abstract_select($select,$from,$where); |
---|
378 | $i = 0; |
---|
379 | while ($row = spip_abstract_fetch($result)) { |
---|
380 | $i++; |
---|
381 | $vals = ''; |
---|
382 | |
---|
383 | $id_article = $row['id_article']; |
---|
384 | $tous_id[] = $id_article; |
---|
385 | $titre = $row['titre']; |
---|
386 | $id_rubrique = $row['id_rubrique']; |
---|
387 | $date = $row['date']; |
---|
388 | $statut = $row['statut']; |
---|
389 | if ($lang = $row['lang']) changer_typo($lang); |
---|
390 | $descriptif = $row['descriptif']; |
---|
391 | if ($descriptif) $descriptif = ' title="'.attribut_html(typo($descriptif)).'"'; |
---|
392 | |
---|
393 | $vals[] = "<input type='checkbox' name='id_choses[]' value='$id_article' id='id_chose$i'/>"; |
---|
394 | |
---|
395 | // Le titre (et la langue) |
---|
396 | $s = "<div>"; |
---|
397 | |
---|
398 | $s .= "<a href=\"articles.php3?id_article=$id_article\"$descriptif$dir_lang style=\"display:block;\">"; |
---|
399 | |
---|
400 | if ($spip_display != 1 AND $spip_display != 4 AND lire_meta('image_process') != "non") { |
---|
401 | include_ecrire("inc_logos.php3"); |
---|
402 | $logo = decrire_logo("arton$id_article"); |
---|
403 | if ($logo) { |
---|
404 | $fichier = $logo[0]; |
---|
405 | $taille = $logo[1]; |
---|
406 | $taille_x = $logo[3]; |
---|
407 | $taille_y = $logo[4]; |
---|
408 | $taille = image_ratio($taille_x, $taille_y, 26, 20); |
---|
409 | $w = $taille[0]; |
---|
410 | $h = $taille[1]; |
---|
411 | $fid = $logo[2]; |
---|
412 | $hash = calculer_action_auteur ("reduire $w $h"); |
---|
413 | |
---|
414 | $s.= "<div style='float: $spip_lang_right; margin-top: -2px; margin-bottom: -2px;'> |
---|
415 | <img src='../spip_image_reduite.php3?img="._DIR_IMG."$fichier&taille_x=$w&taille_y=$h&hash=$hash&hash_id_auteur=$connect_id_auteur' alt='$fichier' width='$w' height='$h' border='0'></div>"; |
---|
416 | |
---|
417 | } |
---|
418 | } |
---|
419 | |
---|
420 | $s .= typo($titre); |
---|
421 | if ($afficher_langue AND $lang != $langue_defaut) |
---|
422 | $s .= " <font size='1' color='#666666'$dir_lang>(".traduire_nom_langue($lang).")</font>"; |
---|
423 | $s .= "</a>"; |
---|
424 | $s .= "</div>"; |
---|
425 | |
---|
426 | $vals[] = $s; |
---|
427 | |
---|
428 | // La date |
---|
429 | $s = affdate_jourcourt($date); |
---|
430 | $vals[] = $s; |
---|
431 | |
---|
432 | // Le numero (moche) |
---|
433 | if ($options == "avancees") { |
---|
434 | $vals[] = "<b>"._T('info_numero_abbreviation')."$id_article</b>"; |
---|
435 | } |
---|
436 | |
---|
437 | |
---|
438 | $table[] = $vals; |
---|
439 | } |
---|
440 | spip_free_result($result); |
---|
441 | |
---|
442 | if ($options == "avancees") { // Afficher le numero (JMB) |
---|
443 | if ($afficher_auteurs) { |
---|
444 | $largeurs = array(11, '', 80, 100, 35); |
---|
445 | $styles = array('', 'arial2', 'arial1', 'arial1', 'arial1'); |
---|
446 | } else { |
---|
447 | $largeurs = array(11, '', 100, 35); |
---|
448 | $styles = array('', 'arial2', 'arial1', 'arial1'); |
---|
449 | } |
---|
450 | } else { |
---|
451 | if ($afficher_auteurs) { |
---|
452 | $largeurs = array(11, '', 100, 100); |
---|
453 | $styles = array('', 'arial2', 'arial1', 'arial1'); |
---|
454 | } else { |
---|
455 | $largeurs = array(11, '', 100); |
---|
456 | $styles = array('', 'arial2', 'arial1'); |
---|
457 | } |
---|
458 | } |
---|
459 | afficher_liste($largeurs, $table, $styles); |
---|
460 | |
---|
461 | echo afficher_liste_fin_tableau(); |
---|
462 | echo '</div>'; |
---|
463 | } |
---|
464 | |
---|
465 | //====================================================================== |
---|
466 | |
---|
467 | function afficher_liste_messages($choses) { |
---|
468 | echo "<div style='height: 12px;'></div>"; |
---|
469 | echo "<div class='liste'>"; |
---|
470 | bandeau_titre_boite2($titre_table, "stock_mail.gif"); |
---|
471 | |
---|
472 | echo afficher_liste_debut_tableau(); |
---|
473 | |
---|
474 | $from = array('spip_messages as messages'); |
---|
475 | $select= array(); |
---|
476 | $select[] = 'id_message'; |
---|
477 | $select[] = 'titre'; |
---|
478 | $select[] = 'type'; |
---|
479 | $select[] = 'date_heure'; |
---|
480 | $select[] = 'statut'; |
---|
481 | $where = array('messages.id_message IN ('.calcul_in($choses).')'); |
---|
482 | |
---|
483 | $result = spip_abstract_select($select,$from,$where); |
---|
484 | $i = 0; |
---|
485 | while ($row = spip_abstract_fetch($result)) { |
---|
486 | $i++; |
---|
487 | $vals = ''; |
---|
488 | |
---|
489 | $id_message = $row['id_message']; |
---|
490 | $tous_id[] = $id_message; |
---|
491 | $titre = $row['titre']; |
---|
492 | $date = $row['date_heure']; |
---|
493 | $statut = $row['statut']; |
---|
494 | |
---|
495 | $vals[] = "<input type='checkbox' name='id_choses[]' value='$id_message' id='id_chose$i'/>"; |
---|
496 | |
---|
497 | // Le titre (et la langue) |
---|
498 | $s = "<div>"; |
---|
499 | |
---|
500 | $s .= "<a href=\"bloogletter.php3?mode=courrier&id_message=$id_message\" style=\"display:block;\">"; |
---|
501 | |
---|
502 | $s .= typo($titre); |
---|
503 | $s .= "</a>"; |
---|
504 | $s .= "</div>"; |
---|
505 | |
---|
506 | $vals[] = $s; |
---|
507 | |
---|
508 | // La date |
---|
509 | $s = affdate_jourcourt($date); |
---|
510 | $vals[] = $s; |
---|
511 | |
---|
512 | // Le numero (moche) |
---|
513 | if ($options == "avancees") { |
---|
514 | $vals[] = "<b>"._T('info_numero_abbreviation')."$id_message</b>"; |
---|
515 | } |
---|
516 | |
---|
517 | |
---|
518 | $table[] = $vals; |
---|
519 | } |
---|
520 | spip_free_result($result); |
---|
521 | |
---|
522 | if ($options == "avancees") { // Afficher le numero (JMB) |
---|
523 | if ($afficher_auteurs) { |
---|
524 | $largeurs = array(11, '', 80, 100, 35); |
---|
525 | $styles = array('', 'arial2', 'arial1', 'arial1', 'arial1'); |
---|
526 | } else { |
---|
527 | $largeurs = array(11, '', 100, 35); |
---|
528 | $styles = array('', 'arial2', 'arial1', 'arial1'); |
---|
529 | } |
---|
530 | } else { |
---|
531 | if ($afficher_auteurs) { |
---|
532 | $largeurs = array(11, '', 100, 100); |
---|
533 | $styles = array('', 'arial2', 'arial1', 'arial1'); |
---|
534 | } else { |
---|
535 | $largeurs = array(11, '', 100); |
---|
536 | $styles = array('', 'arial2', 'arial1'); |
---|
537 | } |
---|
538 | } |
---|
539 | afficher_liste($largeurs, $table, $styles); |
---|
540 | |
---|
541 | echo afficher_liste_fin_tableau(); |
---|
542 | } |
---|
543 | |
---|
544 | //====================================================================== |
---|
545 | |
---|
546 | function afficher_liste_auteurs($choses) { |
---|
547 | echo "<div style='height: 12px;'></div>"; |
---|
548 | echo "<div class='liste'>"; |
---|
549 | bandeau_titre_boite2($titre_table, "reply-to-all-24.gif"); |
---|
550 | |
---|
551 | echo afficher_liste_debut_tableau(); |
---|
552 | |
---|
553 | $from = array('spip_auteurs as auteurs'); |
---|
554 | $select= array(); |
---|
555 | $select[] = 'id_auteur'; |
---|
556 | $select[] = 'nom'; |
---|
557 | $select[] = 'login'; |
---|
558 | $select[] = 'email'; |
---|
559 | $select[] = 'extra'; |
---|
560 | $select[] = 'statut'; |
---|
561 | $where = array('auteurs.id_auteur IN ('.calcul_in($choses).')'); |
---|
562 | |
---|
563 | $result = spip_abstract_select($select,$from,$where); |
---|
564 | $i = 0; |
---|
565 | while ($row = spip_abstract_fetch($result)) { |
---|
566 | $i++; |
---|
567 | $vals = ''; |
---|
568 | |
---|
569 | $id_auteur = $row['id_auteur']; |
---|
570 | $tous_id[] = $id_auteur; |
---|
571 | $nom = $row['nom']; |
---|
572 | $login = $row['login']; |
---|
573 | $email = $row['email']; |
---|
574 | $extra = $row['extra']; |
---|
575 | $statut = $row['statut']; |
---|
576 | |
---|
577 | $vals[] = "<input type='checkbox' name='id_choses[]' value='$id_auteur' id='id_chose$i'/>"; |
---|
578 | |
---|
579 | // Le titre (et la langue) |
---|
580 | $s = "<div>"; |
---|
581 | $s .= "<a href=\"auteur_edit.php3?id_auteur=$id_auteur\" style=\"display:block;\">"; |
---|
582 | $s .= typo($login); |
---|
583 | $s .= "</a>"; |
---|
584 | $s .= "</div>"; |
---|
585 | $vals[] = $s; |
---|
586 | |
---|
587 | $s = "<div>"; |
---|
588 | $s .= " (<a href=\"mailto:$email\">"; |
---|
589 | |
---|
590 | $s .= typo($nom); |
---|
591 | $s .= "</a>)"; |
---|
592 | $s .= "</div>"; |
---|
593 | |
---|
594 | $vals[] = $s; |
---|
595 | |
---|
596 | // TODO : extra |
---|
597 | // $s = affdate_jourcourt($date); |
---|
598 | // $vals[] = $s; |
---|
599 | |
---|
600 | // Le numero (moche) |
---|
601 | if ($options == "avancees") { |
---|
602 | $vals[] = "<b>"._T('info_numero_abbreviation')."$id_auteur</b>"; |
---|
603 | } |
---|
604 | |
---|
605 | |
---|
606 | $table[] = $vals; |
---|
607 | } |
---|
608 | spip_free_result($result); |
---|
609 | |
---|
610 | if ($options == "avancees") { // Afficher le numero (JMB) |
---|
611 | $largeurs = array(11, '', 100,35); |
---|
612 | $styles = array('', 'arial2', 'arial1', 'arial1'); |
---|
613 | } else { |
---|
614 | $largeurs = array(11, '', 100); |
---|
615 | $styles = array('', 'arial2', 'arial1'); |
---|
616 | } |
---|
617 | afficher_liste($largeurs, $table, $styles); |
---|
618 | |
---|
619 | echo afficher_liste_fin_tableau(); |
---|
620 | } |
---|
621 | |
---|
622 | //====================================================================== |
---|
623 | |
---|
624 | function afficher_liste_defaut($choses) { |
---|
625 | echo '<table>'; |
---|
626 | $i = 0; |
---|
627 | foreach($choses as $id_chose) { |
---|
628 | $i++; |
---|
629 | echo "<td><tr><input type='checkbox' name='id_choses[]' value='$id_chose' id='id_chose$i'/></tr><tr> <label for='id_chose$i'>$id_chose</label></tr></td>"; |
---|
630 | } |
---|
631 | echo '</table>'; |
---|
632 | } |
---|
633 | |
---|
634 | /*********************************************************************** |
---|
635 | * récuperation de la chose sur laquelle on travaille |
---|
636 | ***********************************************************************/ |
---|
637 | |
---|
638 | $nom_chose = $HTTP_GET_VARS['nom_chose']; |
---|
639 | if(!isset($choses_possibles[$nom_chose])) { |
---|
640 | list($nom_chose,) = each($choses_possibles); |
---|
641 | reset($choses_possibles); |
---|
642 | } |
---|
643 | $id_chose = $choses_possibles[$nom_chose]['id_chose']; |
---|
644 | $table_principale = $choses_possibles[$nom_chose]['table_principale']; |
---|
645 | $table_auth = $choses_possibles[$nom_chose]['table_auth']; |
---|
646 | $tables_limite = $choses_possibles[$nom_chose]['tables_limite']; |
---|
647 | |
---|
648 | /*********************************************************************** |
---|
649 | * action |
---|
650 | ***********************************************************************/ |
---|
651 | $mots = $HTTP_GET_VARS['id_mots']; |
---|
652 | $sans_mots = $HTTP_GET_VARS['sans_mots']; |
---|
653 | $choses = $HTTP_GET_VARS['id_choses']; |
---|
654 | $nom_tags = $HTTP_GET_VARS['nom_tags']; |
---|
655 | $limit = $HTTP_GET_VARS['limit']; |
---|
656 | $id_limit = $HTTP_GET_VARS['id_limit']; |
---|
657 | |
---|
658 | if($HTTP_GET_VARS['bouton'] == 'ajouter' && $nom_tags && count($choses)) { |
---|
659 | $tags = parser_liste($nom_tags); |
---|
660 | foreach($choses as $d) { |
---|
661 | $warnings = ajouter_liste_mots($tags,$d,'',$nom_chose,$id_chose); |
---|
662 | } |
---|
663 | } else if ($HTTP_GET_VARS['bouton'] == 'enlever' && $nom_tags && count($choses)) { |
---|
664 | $tags = parser_liste($nom_tags); |
---|
665 | foreach($choses as $d) { |
---|
666 | retirer_liste_mots($tags,$d,'',$nom_chose,$id_chose); |
---|
667 | } |
---|
668 | } |
---|
669 | |
---|
670 | /********************************************************************** |
---|
671 | * recherche des choses. |
---|
672 | ***********************************************************************/ |
---|
673 | |
---|
674 | if(count($choses) <= 0) { |
---|
675 | $select = array(); |
---|
676 | $select[] = "DISTINCT main.$id_chose"; |
---|
677 | |
---|
678 | $from = array(); |
---|
679 | $where = array(); |
---|
680 | $group = ''; |
---|
681 | $order = array(); |
---|
682 | |
---|
683 | if(isset($limit) && $limit != 'rien') { |
---|
684 | $table_lim = $tables_limite[$limit]['table']; |
---|
685 | $nom_id_lim = $tables_limite[$limit]['nom_id']; |
---|
686 | |
---|
687 | $from[] = "$table_lim as main"; |
---|
688 | $where[] = "main.$nom_id_lim IN ($id_limit)"; |
---|
689 | if(count($mots) > 0) { |
---|
690 | $from[] = "spip_mots_$nom_chose as table_temp"; |
---|
691 | $where[] = "table_temp.id_mot IN (".calcul_in($mots).')'; |
---|
692 | $where[] = "table_temp.$id_chose = main.$id_chose"; |
---|
693 | if($HTTP_GET_VARS['strict']) { |
---|
694 | $select[] = 'count(id_mot) as tot'; |
---|
695 | $group = "main.$id_chose"; |
---|
696 | $order = array('tot DESC'); |
---|
697 | } |
---|
698 | } |
---|
699 | } else if(count($mots) > 0) { |
---|
700 | $from[] = "spip_mots_$nom_chose as main"; |
---|
701 | $where[] = "main.id_mot IN (".calcul_in($mots).')'; |
---|
702 | if($HTTP_GET_VARS['strict']) { |
---|
703 | $select[] = 'count(id_mot) as tot'; |
---|
704 | $group = "main.$id_chose"; |
---|
705 | $order = array('tot DESC'); |
---|
706 | } |
---|
707 | } else { |
---|
708 | $from[] = "$table_principale as main"; |
---|
709 | } |
---|
710 | |
---|
711 | |
---|
712 | $res=spip_abstract_select($select,$from,$where,$group,$order); |
---|
713 | |
---|
714 | $choses = array(); |
---|
715 | $avec_sans = (count($sans_mots) > 0); |
---|
716 | if($avec_sans) $in_sans = calcul_in($sans_mots); |
---|
717 | while ($row = spip_abstract_fetch($res)) { |
---|
718 | if(!isset($table_auth) || |
---|
719 | (isset($table_auth) && |
---|
720 | (verifier_admin() || |
---|
721 | verifier_auteur($table_auth,$id_chose,$row[$id_chose]) |
---|
722 | ) |
---|
723 | ) |
---|
724 | ) { |
---|
725 | if($avec_sans) { |
---|
726 | $test = spip_abstract_select(array($id_chose),array("spip_mots_$nom_chose"),array("id_mot IN ($in_sans)","$id_chose = ".$row[$id_chose])); |
---|
727 | if(spip_abstract_count($test) > 0) { |
---|
728 | continue; |
---|
729 | } |
---|
730 | spip_abstract_free($test); |
---|
731 | } |
---|
732 | if(count($mots) > 0 && $HTTP_GET_VARS['strict']) { |
---|
733 | if($row['tot'] >= count($mots)) { |
---|
734 | $choses[] = $row[$id_chose]; |
---|
735 | } else { |
---|
736 | break; |
---|
737 | } |
---|
738 | } else { |
---|
739 | $choses[] = $row[$id_chose]; |
---|
740 | } |
---|
741 | } |
---|
742 | } |
---|
743 | spip_abstract_free($res); |
---|
744 | } |
---|
745 | |
---|
746 | if(count($choses) > 0) { |
---|
747 | $select = array(); |
---|
748 | $from = array(); |
---|
749 | $where = array(); |
---|
750 | $show_mots = array(); |
---|
751 | $from[] = "spip_mots_$nom_chose"; |
---|
752 | $select[] = "spip_mots_$nom_chose.id_mot"; |
---|
753 | $where[] = "spip_mots_$nom_chose.$id_chose IN (".calcul_in($choses).')'; |
---|
754 | $res=spip_abstract_select($select,$from,$where); |
---|
755 | while ($row = spip_abstract_fetch($res)) { |
---|
756 | $show_mots[] = $row['id_mot']; |
---|
757 | } |
---|
758 | spip_abstract_free($res); |
---|
759 | } |
---|
760 | |
---|
761 | /*********************************************************************** |
---|
762 | * affichage |
---|
763 | ***********************************************************************/ |
---|
764 | |
---|
765 | debut_page('« '._T('motspartout:titre_page').' »', 'documents', 'mots'); |
---|
766 | |
---|
767 | echo '<br><br><center>'; |
---|
768 | gros_titre(_T('motspartout:titre_page')); |
---|
769 | echo '</center>'; |
---|
770 | |
---|
771 | //Colonne de gauche |
---|
772 | debut_gauche(); |
---|
773 | |
---|
774 | echo '<a name="voir"></a><form action="mots_partout.php#action">'; |
---|
775 | |
---|
776 | |
---|
777 | // choix de la chose sur laquelle on veut ajouter des mots |
---|
778 | debut_cadre_enfonce('',false,'',_T('motspartout:choses')); |
---|
779 | //echo '<form action="mots_partout.php">'; |
---|
780 | echo '<div class=\'liste\'> |
---|
781 | <table border=0 cellspacing=0 cellpadding=3 width=\"100%\"> |
---|
782 | <tr class=\'tr_liste\'> |
---|
783 | <td colspan=2><select name="nom_chose">'; |
---|
784 | foreach($choses_possibles as $cho => $m) { |
---|
785 | echo "<option value=\"$cho\"".(($cho == $nom_chose)?'selected':'').'>'._T($m['titre_chose']).'</option>'; |
---|
786 | } |
---|
787 | echo '</select></td></tr>'; |
---|
788 | echo '<tr class=\'tr_liste\'><td colspan=2>'. |
---|
789 | _T('motspartout:limite'). |
---|
790 | ':</td></tr>'; |
---|
791 | echo '<tr class=\'tr_liste\'><td><select name="limit"> |
---|
792 | <option value="rien" selected="true">'. |
---|
793 | _T('motspartout:aucune'). |
---|
794 | '</option>'; |
---|
795 | |
---|
796 | foreach($tables_limite as $t => $m) { |
---|
797 | echo "<option value=\"$t\"".(($t == $limit)?'selected':'').">$t</option>"; |
---|
798 | } |
---|
799 | |
---|
800 | echo '</select></td>'; |
---|
801 | echo "<td><input type='text' size='3' name='id_limit' value='$id_limit'></td></tr>"; |
---|
802 | echo '<tr class=\'tr_liste\'>'; |
---|
803 | ?> |
---|
804 | <td><button type='submit'> |
---|
805 | <?php echo _T('motspartout:voir'); ?> |
---|
806 | </button> |
---|
807 | </td> |
---|
808 | <td colspan=2> |
---|
809 | <input type='checkbox' id='strict' name='strict'/><label for='strict'> |
---|
810 | <?php echo _T('motspartout:stricte'); ?> |
---|
811 | </label></td> |
---|
812 | <?php |
---|
813 | echo '</table></div>'; |
---|
814 | fin_cadre_enfonce(); |
---|
815 | |
---|
816 | |
---|
817 | // affichage de mots clefs. |
---|
818 | $select = array('*'); |
---|
819 | $from = array('spip_groupes_mots'); |
---|
820 | $order = array('titre'); |
---|
821 | $m_result_groupes = spip_abstract_select($select,$from,'','',$order); |
---|
822 | |
---|
823 | while ($row_groupes = spip_abstract_fetch($m_result_groupes)) { |
---|
824 | $id_groupe = $row_groupes['id_groupe']; |
---|
825 | $titre_groupe = typo($row_groupes['titre']); |
---|
826 | $unseul = $row_groupes['unseul']; |
---|
827 | $acces_admin = $row_groupes['minirezo']; |
---|
828 | $acces_redacteur = $row_groupes['comite']; |
---|
829 | |
---|
830 | if($row_groupes[$nom_chose] == 'oui' && (($GLOBALS['connect_statut'] == '1comite' AND $acces_redacteur == 'oui') OR ($GLOBALS['connect_statut'] == '0minirezo' AND $acces_admin == 'oui'))) { |
---|
831 | // Afficher le titre du groupe |
---|
832 | debut_cadre_enfonce("groupe-mot-24.gif", false, '', $titre_groupe); |
---|
833 | |
---|
834 | // |
---|
835 | // Afficher les mots-cles du groupe |
---|
836 | // |
---|
837 | $result = spip_abstract_select(array('*'), |
---|
838 | array('spip_mots'), |
---|
839 | array("id_groupe = '$id_groupe'"), |
---|
840 | '', array('titre')); |
---|
841 | $table = ''; |
---|
842 | |
---|
843 | if (spip_abstract_count($result) > 0) { |
---|
844 | echo "<div class='liste'>"; |
---|
845 | echo "<table border=0 cellspacing=0 cellpadding=3 width=\"100%\">"; |
---|
846 | $i =0; |
---|
847 | $table[] = array( |
---|
848 | ' ' => 0, |
---|
849 | _T('motspartout:voir') => 0, |
---|
850 | _T('motspartout:sans') => 0 |
---|
851 | ); |
---|
852 | while ($row = spip_abstract_fetch($result)) { |
---|
853 | $i++; |
---|
854 | $vals = ''; |
---|
855 | |
---|
856 | $id_mot = $row['id_mot']; |
---|
857 | $titre_mot = $row['titre']; |
---|
858 | |
---|
859 | $s = typo($titre_mot); |
---|
860 | |
---|
861 | $vals["<label for='id_mot$i'>$s</label>"] = calcul_numeros($show_mots,$id_mot,count($choses)); |
---|
862 | |
---|
863 | $vals["<input type='checkbox' name='id_mots[]' id='id_mot$i' value='$id_mot'>"] = calcul_numeros($show_mots,$id_mot,count($choses)); |
---|
864 | |
---|
865 | $vals["<input type='checkbox' name='sans_mots[]' id='sans_mot$i' value='$id_mot'>"] = calcul_numeros($show_mots,$id_mot,count($choses)); |
---|
866 | $table[] = $vals; |
---|
867 | } |
---|
868 | |
---|
869 | } |
---|
870 | $largeurs = array(40, 10, 10); |
---|
871 | $styles = array( |
---|
872 | array('arial11', |
---|
873 | 'diff-deplace', |
---|
874 | 'diff-ajoute'), |
---|
875 | array('arial1', |
---|
876 | 'diff-para-deplace', |
---|
877 | 'diff-para-ajoute'), |
---|
878 | array('arial1', |
---|
879 | 'diff-para-deplace', |
---|
880 | 'diff-para-ajoute') |
---|
881 | ); |
---|
882 | md_afficher_liste($largeurs, $table, $styles); |
---|
883 | |
---|
884 | echo "</table>"; |
---|
885 | echo "</div>"; |
---|
886 | spip_abstract_free($result); |
---|
887 | |
---|
888 | fin_cadre_enfonce(); |
---|
889 | } |
---|
890 | } |
---|
891 | spip_abstract_free($m_result_groupes); |
---|
892 | |
---|
893 | //Milieu |
---|
894 | |
---|
895 | debut_droite(); |
---|
896 | |
---|
897 | if(count($warnings) > 0) { |
---|
898 | debut_cadre_relief('',false,'',_T('motspartout:ATTENTION')); |
---|
899 | echo '<div class="liste"><table border=0 cellspacing=0 cellpadding=3 width=\"100%\">'; |
---|
900 | $largeurs = array('100%'); |
---|
901 | $styles = array( 'arial11'); |
---|
902 | afficher_liste($largeurs, $warnings, $styles); |
---|
903 | echo '</table>'; |
---|
904 | echo '</div>'; |
---|
905 | fin_cadre_relief(); |
---|
906 | } |
---|
907 | |
---|
908 | // Affichage de toutes les choses (on pourrait imaginer faire une pagination là) |
---|
909 | debut_cadre_relief('',false,'document', _T('portfolio')); |
---|
910 | if(count($choses) > 0) { |
---|
911 | $function = "afficher_liste_$nom_chose"; |
---|
912 | if(function_exists($function)) |
---|
913 | $function($choses); |
---|
914 | else |
---|
915 | afficher_liste_defaut($choses); |
---|
916 | ?> |
---|
917 | <!-- |
---|
918 | <input type="radio" name="selectall" id="all" onclick="selectAll(this.form, 'id_choses[]', 0);"><label for="all">Select All</label> |
---|
919 | <input type="radio" name="selectall" id="inverse" onclick="selectAll(this.form, 'id_choses[]', 1);"><label for="inverse">Inverse All</label> |
---|
920 | --> |
---|
921 | <?php |
---|
922 | } else { |
---|
923 | echo _T('motspartout:pas_de_documents').'.'; |
---|
924 | } |
---|
925 | |
---|
926 | |
---|
927 | fin_cadre_relief(); |
---|
928 | echo '</form>'; |
---|
929 | |
---|
930 | if(count($choses)) { |
---|
931 | echo '<a name="action"></a><form action="mots_partout.php#voir">'; |
---|
932 | |
---|
933 | echo '<input type="hidden" name="nom_chose" value="'.$HTTP_GET_VARS['nom_chose'].'">'; |
---|
934 | echo "<input type='hidden' name='id_limit' value='$id_limit'>"; |
---|
935 | echo "<input type='hidden' name='limit' value='$limit'>"; |
---|
936 | for($i=0; $i < count($choses); $i++) { |
---|
937 | echo "<input type=\"hidden\" name=\"id_choses[]\" value=\"".$choses[$i].'">'; |
---|
938 | } |
---|
939 | |
---|
940 | // les actions et limitations possibles. |
---|
941 | debut_cadre_enfonce('',false,'',_T('motspartout:action')); |
---|
942 | |
---|
943 | echo '<div class=\'liste\'> |
---|
944 | <table border=0 cellspacing=0 cellpadding=3 width=\"100%\">'; |
---|
945 | echo '<tr class=\'tr_liste\'> |
---|
946 | <td><input type=\'radio\' value=\'ajouter\' name="bouton" id=\'ajouter\'><br><label for=\'ajouter\'>'. |
---|
947 | _T('motspartout:ajouter'). |
---|
948 | '</label></td> |
---|
949 | <td ><input type=\'radio\' value=\'enlever\' name="bouton" id=\'enlever\'><br><label for=\'enlever\'>'. |
---|
950 | _T('motspartout:enlever'). |
---|
951 | '</label></td> |
---|
952 | </tr>'; |
---|
953 | ?> |
---|
954 | <tr class='tr_liste'> |
---|
955 | <td colspan=2><label for="nom_tags">liste des mots à ajouter</label> |
---|
956 | </td> |
---|
957 | </tr> |
---|
958 | <tr class='tr_liste'> |
---|
959 | <td colspan=2><textarea name="nom_tags" rows='10' class='forml' cols='40'></textarea></td> |
---|
960 | </tr> |
---|
961 | <tr class='tr_liste'> |
---|
962 | <td colspan=2><button type='submit'> |
---|
963 | <?php echo _T('bouton_valider'); ?> |
---|
964 | </button></td> |
---|
965 | </tr> |
---|
966 | </table> |
---|
967 | </div> |
---|
968 | |
---|
969 | <?php |
---|
970 | |
---|
971 | fin_cadre_enfonce(); |
---|
972 | echo '</form>'; |
---|
973 | } |
---|
974 | ?> |
---|
975 | |
---|
976 | |
---|
977 | <script> |
---|
978 | function selectAll(formObj, isInverse) |
---|
979 | { |
---|
980 | for (var i=0;i < formObj.length;i++) |
---|
981 | { |
---|
982 | fldObj = formObj.elements[i]; |
---|
983 | if (fldObj.type == 'checkbox') |
---|
984 | { |
---|
985 | if(isInverse) |
---|
986 | fldObj.checked = (fldObj.checked) ? false : true; |
---|
987 | else fldObj.checked = true; |
---|
988 | } |
---|
989 | } |
---|
990 | } |
---|
991 | </script> |
---|
992 | |
---|
993 | <?php |
---|
994 | |
---|
995 | fin_page(); |
---|
996 | ?> |
---|