Commit | Line | Data |
---|---|---|
c495c100 P |
1 | <?php |
2 | ||
3 | /***************************************************************************\ | |
4 | * SPIP, Systeme de publication pour l'internet * | |
5 | * * | |
6 | * Copyright (c) 2001-2007 * | |
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 | include_spip('base/abstract_sql'); | |
15 | ||
16 | // http://doc.spip.org/@inc_plonger_dist | |
17 | function inc_plonger_dist($id_rubrique, $idom="", $list=array(), $col = 1, $exclu=0) { | |
18 | global $spip_lang_left; | |
19 | ||
20 | if ($list) $id_rubrique = $list[$col-1]; | |
21 | ||
22 | $ret = ''; | |
23 | ||
24 | # recherche les filles et petites-filles de la rubrique donnee | |
25 | $ordre = array(); | |
26 | $rub = array(); | |
27 | ||
28 | // en deux etapes : d'abord on recupere les enfants | |
29 | $res = spip_query($q="SELECT rub1.id_rubrique, rub1.titre, rub1.id_parent, rub1.lang, rub1.langue_choisie FROM spip_rubriques AS rub1 WHERE rub1.id_parent = $id_rubrique AND rub1.id_rubrique!=$exclu GROUP BY rub1.id_rubrique ORDER BY 0+rub1.titre,rub1.titre"); | |
30 | while ($row = spip_fetch_array($res)) { | |
31 | if (autoriser('voir','rubrique',$row['id_rubrique'])){ | |
32 | if ($row['id_parent'] == $id_rubrique) | |
33 | $ordre[$row['id_rubrique']]= trim(typo($row['titre'])) | |
34 | . (($row['langue_choisie'] != 'oui') | |
35 | ? '' : (' [' . $row['lang'] . ']')); | |
36 | } | |
37 | } | |
38 | $liste_rub = calcul_mysql_in('id_parent',implode(',',array_keys($ordre))); | |
39 | $res = spip_query($q="SELECT id_parent,count(id_rubrique) as n FROM spip_rubriques WHERE $liste_rub GROUP BY id_parent"); | |
40 | ||
41 | while ($row = spip_fetch_array($res)) { | |
42 | $rub[$row['id_parent']]['enfants'] = true; | |
43 | } | |
44 | ||
45 | $next = isset($list[$col]) ? $list[$col] : 0; | |
46 | if ($ordre) { | |
47 | //asort($ordre); | |
48 | $rec = generer_url_ecrire('plonger',"rac=$idom&exclus=$exclu&col=".($col+1)); | |
49 | $info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&id="); | |
50 | $args = "'$idom',this,$col,'$spip_lang_left','$info',event"; | |
51 | while (list($id, $titrebrut) = each($ordre)) { | |
52 | ||
53 | $titre = supprimer_numero($titrebrut); | |
54 | ||
55 | $classe1 = $id_rubrique ? 'petite-rubrique' : "petit-secteur"; | |
56 | if (isset($rub[$id]["enfants"])) { | |
57 | $classe2 = " class='rub-ouverte'"; | |
58 | $url = "\nhref='$rec&id=$id'" ; | |
59 | } else { $url = $classe2 = '' ; } | |
60 | ||
61 | $click = "\nonclick=\"changerhighlight(this.parentNode.parentNode.parentNode);\nreturn " | |
62 | . (!is_array($list) ? ' false' | |
63 | : "aff_selection_provisoire($id,$args)") | |
64 | # ce lien provoque la selection (directe) de la rubrique cliquee | |
65 | # et l'affichage de son titre dans le bandeau | |
66 | . "\"\nondblclick=\"" | |
67 | . "aff_selection_titre(this." | |
68 | . "firstChild.nodeValue," | |
69 | . $id | |
70 | . ",'selection_rubrique','id_parent');" | |
71 | . "\nreturn aff_selection_provisoire($id,$args);" | |
72 | . "\""; | |
73 | ||
74 | $ret .= "<div class='" | |
75 | . (($id == $next) ? "highlight" : "pashighlight") | |
76 | . "'><div class='" | |
77 | . $classe1 | |
78 | . "'><div$classe2><a" | |
79 | . $url | |
80 | . $click | |
81 | . ">" | |
82 | . $titre | |
83 | . "</a></div></div></div>"; | |
84 | } | |
85 | } | |
86 | ||
87 | $idom2 = $idom . "_col_".($col+1); | |
88 | $left = ($col*150); | |
89 | ||
90 | return http_img_pack("searching.gif", "*", "style='visibility: hidden; position: absolute; $spip_lang_left: " | |
91 | . ($left-30) | |
92 | . "px; top: 2px; z-index: 2;' id='img_$idom2'") | |
93 | . "<div style='width: 150px; height: 100%; overflow: auto; position: absolute; top: 0px; $spip_lang_left: " | |
94 | .($left-150) | |
95 | ."px;'>" | |
96 | . $ret | |
97 | . "\n</div>\n<div id='$idom2'>" | |
98 | . ($next | |
99 | ? inc_plonger_dist($id_rubrique, $idom, $list, $col+1, $exclu) | |
100 | : "") | |
101 | . "\n</div>"; | |
102 | } | |
103 | ||
104 | ?> |