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