[SPIP] +2.1.12
[velocampus/web/www.git] / www / ecrire / inc / selectionner.php
1 <?php
2
3 /***************************************************************************\
4 * SPIP, Systeme de publication pour l'internet *
5 * *
6 * Copyright (c) 2001-2011 *
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/filtres');
16
17 //
18 // Affiche un mini-navigateur ajax positionne sur la rubrique $sel
19 //
20
21 // http://doc.spip.org/@inc_selectionner_dist
22 function inc_selectionner_dist ($sel, $idom="", $exclus=0, $aff_racine=false, $recur=true, $do='aff') {
23
24 if ($recur) $recur = mini_hier($sel); else $sel = 0;
25
26 if ($aff_racine) {
27 $info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id=");
28 $idom3 = $idom . "_selection";
29
30 $onClick = " aff_selection(0, '$idom3', '$info', event);";
31
32 $ondbClick = strtr(str_replace("'", "&#8217;",
33 str_replace('"', "&#34;",
34 textebrut(_T('info_racine_site')))),
35 "\n\r", " ");
36
37 $js_func = $do . '_selection_titre';
38 $ondbClick = "$js_func('$ondbClick',0,'selection_rubrique','id_parent');";
39
40 $aff_racine = "<div class='arial11 petite-racine'\nonclick=\""
41 . $onClick
42 . "\"\nondbclick=\""
43 . $ondbClick
44 . $onClick
45 . "\">\n<div class='highlight off'>"
46 . _T("info_racine_site")
47 . "</div></div>";
48 } else $onClick = '';
49
50 $url_init = generer_url_ecrire('plonger',"rac=$idom&exclus=$exclus&id=0&col=1&do=$do");
51
52 $plonger = charger_fonction('plonger', 'inc');
53 $plonger_r = $plonger($sel, $idom, $recur, 1, $exclus, $do);
54
55 // url completee par la fonction JS onkeypress_rechercher
56 $url = generer_url_ecrire('rechercher', "exclus=$exclus&rac=$idom&do=$do&type=");
57 return construire_selectionner_hierarchie($idom, $plonger_r, $aff_racine, $url, 'id_parent', $url_init);
58 }
59
60 // http://doc.spip.org/@construire_selectionner_hierarchie
61 function construire_selectionner_hierarchie($idom, $liste, $racine, $url, $name, $url_init='')
62 {
63 global $spip_lang_right;
64
65 $idom1 = $idom . "_champ_recherche";
66 $idom2 = $idom . "_principal";
67 $idom3 = $idom . "_selection";
68 $idom4 = $idom . "_col_1";
69 $idom5 = 'img_' . $idom4;
70 $idom6 = $idom."_fonc";
71
72 return "<div id='$idom'>"
73 . "<a id='$idom6' style='visibility: hidden;'"
74 . ($url_init ? "\nhref='$url_init'" : '')
75 . "></a>"
76 . "<div class='recherche_rapide_parent'>"
77 . http_img_pack("searching.gif", "*", "style='visibility: hidden;float:$spip_lang_right' id='$idom5'")
78 . ""
79 . "<input style='width: 100px;float:$spip_lang_right;' type='search' id='$idom1'"
80 // eliminer Return car il provoque la soumission (balise unique)
81 // ce serait encore mieux de ne le faire que s'il y a encore plusieurs
82 // resultats retournes par la recherche
83 . "\nonkeypress=\"k=event.keyCode;if (k==13 || k==3){return false;}\""
84 // lancer la recherche apres le filtrage ci-dessus
85 . "\nonkeyup=\"return onkey_rechercher(this.value,"
86 // la destination de la recherche
87 . "'$idom4'"
88 # . "this.parentNode.parentNode.parentNode.parentNode.nextSibling.firstChild.id"
89 . ",'"
90 // l'url effectuant la recherche
91 . $url
92 . "',"
93 // le noeud contenant un gif anime
94 // . "'idom5'"
95 . "this.parentNode.previousSibling.firstChild"
96 . ",'"
97 // la valeur de l'attribut Name a remplir
98 . $name
99 . "','"
100 // noeud invisible memorisant l'URL initiale (pour re-initialisation)
101 . $idom6
102 . "')\""
103 . " />"
104 . "\n</div>"
105 . ($racine?"<div>$racine</div>":"")
106 . "<div id='"
107 . $idom2
108 . "'><div id='$idom4'"
109 . " class='arial1'>"
110 . $liste
111 . "</div></div>\n<div id='$idom3'></div></div>\n";
112 }
113
114 // http://doc.spip.org/@mini_hier
115 function mini_hier ($id_rubrique) {
116
117 $liste = $id_rubrique;
118 $id_rubrique = intval($id_rubrique);
119 while ($id_rubrique = sql_getfetsel("id_parent", "spip_rubriques", "id_rubrique = " . $id_rubrique))
120 $liste = $id_rubrique . ",$liste";
121 return explode(',',"0,$liste");
122 }
123
124 ?>