[SPIP] v3.2.1-->v3.2.2
[lhc/web/www.git] / www / ecrire / inc / plonger.php
1 <?php
2
3 /***************************************************************************\
4 * SPIP, Systeme de publication pour l'internet *
5 * *
6 * Copyright (c) 2001-2019 *
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')) {
14 return;
15 }
16
17 include_spip('inc/texte');
18
19 // http://code.spip.net/@inc_plonger_dist
20 function inc_plonger_dist($id_rubrique, $idom = "", $list = array(), $col = 1, $exclu = 0, $do = 'aff') {
21
22 if ($list) {
23 $id_rubrique = $list[$col - 1];
24 }
25
26 $ret = '';
27
28 # recherche les filles et petites-filles de la rubrique donnee
29 # en excluant une eventuelle rubrique interdite (par exemple, lorsqu'on
30 # deplace une rubrique, on peut la deplacer partout a partir de la
31 # racine... sauf vers elle-meme ou sa propre branche)
32 $ordre = array();
33 $rub = array();
34
35 $res = sql_select("rub1.id_rubrique, rub1.titre, rub1.id_parent, rub1.lang, rub1.langue_choisie, rub2.id_rubrique AS id_enfant",
36 "spip_rubriques AS rub1 LEFT JOIN spip_rubriques AS rub2 ON (rub1.id_rubrique = rub2.id_parent)",
37 "rub1.id_parent = " . sql_quote($id_rubrique) . "
38 AND rub1.id_rubrique!=" . sql_quote($exclu) . "
39 AND (rub2.id_rubrique IS NULL OR rub2.id_rubrique!=" . sql_quote($exclu) . ")", "", "0+rub1.titre,rub1.titre");
40
41 while ($row = sql_fetch($res)) {
42 if (autoriser('voir', 'rubrique', $row['id_rubrique'])) {
43 $rub[$row['id_rubrique']]['enfants'] = $row['id_enfant'];
44 if ($row['id_parent'] == $id_rubrique) {
45 $t = trim(typo(supprimer_numero($row['titre'])));
46 if ($row['langue_choisie'] != 'oui') {
47 $t .= ' <small title="'
48 . traduire_nom_langue($row['lang'])
49 . '">[' . $row['lang'] . ']</small>';
50 }
51 $ordre[$row['id_rubrique']] = $t;
52 }
53 }
54 }
55 $next = isset($list[$col]) ? $list[$col] : 0;
56 if ($ordre) {
57 $rec = generer_url_ecrire('plonger', "rac=$idom&exclus=$exclu&do=$do&col=" . ($col + 1));
58 $info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id=");
59 $args = "'$idom',this,$col,'" . $GLOBALS['spip_lang_left'] . "','$info',event";
60 while (list($id, $titrebrut) = each($ordre)) {
61
62 $titre = supprimer_numero($titrebrut);
63
64 $classe1 = $id_rubrique ? 'petite-rubrique' : "petit-secteur";
65 if (isset($rub[$id]["enfants"])) {
66 $classe2 = " class='rub-ouverte'";
67 $url = "\nhref='$rec&amp;id=$id'";
68 } else {
69 $classe2 = $url = '';
70 $url = "\nhref='javascript:void(0)'";
71 }
72
73 $js_func = $do . '_selection_titre';
74 $click = "\nonclick=\"changerhighlight(this.parentNode.parentNode.parentNode);\nreturn "
75 . (!is_array($list) ? ' false'
76 : "aff_selection_provisoire($id,$args)")
77 # ce lien provoque la selection (directe) de la rubrique cliquee
78 # et l'affichage de son titre dans le bandeau
79 . "\"\nondblclick=\""
80 . "$js_func(this."
81 . "firstChild.nodeValue,"
82 . $id
83 . ",'selection_rubrique','id_parent');"
84 . "\nreturn aff_selection_provisoire($id,$args);"
85 . "\"";
86
87 $ret .= "<div class='"
88 . (($id == $next) ? "item on" : "item")
89 . "'><div class='"
90 . $classe1
91 . "'><div$classe2><a"
92 . $url
93 . $click
94 . ">"
95 . $titre
96 . "</a></div></div></div>";
97 }
98 }
99
100 $idom2 = $idom . "_col_" . ($col + 1);
101 $left = ($col * 150);
102
103 return http_img_pack("searching.gif", "*",
104 "style='visibility: hidden; position: absolute; " . $GLOBALS['spip_lang_left'] . ": "
105 . ($left - 30)
106 . "px; top: 2px; z-index: 2;' id='img_$idom2'")
107 . "<div style='width: 150px; height: 100%; overflow: auto; position: absolute; top: 0px; " . $GLOBALS['spip_lang_left'] . ": "
108 . ($left - 150)
109 . "px;'>"
110 . $ret
111 . "\n</div>\n<div id='$idom2'>"
112 . ($next
113 ? inc_plonger_dist($id_rubrique, $idom, $list, $col + 1, $exclu)
114 : "")
115 . "\n</div>";
116 }