[SPIP] ~v3.0.20-->v3.0.25
[lhc/web/clavette_www.git] / www / ecrire / inc / selectionner.php
1 <?php
2
3 /***************************************************************************\
4 * SPIP, Systeme de publication pour l'internet *
5 * *
6 * Copyright (c) 2001-2016 *
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 = "jQuery(this).parent().addClass('on');jQuery('#choix_parent_principal .on').removeClass('on'); aff_selection(0, '$idom3', '$info', event);return false;";
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='petite-racine item'>"
41 . "<a href='#'"
42 . "onclick=\""
43 . $onClick
44 . "\"\nondbclick=\""
45 . $ondbClick
46 . $onClick
47 . "\">"
48 . _T("info_racine_site")
49 . "</a></div>";
50 }
51
52 $url_init = generer_url_ecrire('plonger',"rac=$idom&exclus=$exclus&id=0&col=1&do=$do");
53
54 $plonger = charger_fonction('plonger', 'inc');
55 $plonger_r = $plonger($sel, $idom, $recur, 1, $exclus, $do);
56
57 // url completee par la fonction JS onkeypress_rechercher
58 $url = generer_url_ecrire('rechercher', "exclus=$exclus&rac=$idom&do=$do&type=");
59 return construire_selectionner_hierarchie($idom, $plonger_r, $aff_racine, $url, 'id_parent', $url_init);
60 }
61
62 // http://doc.spip.org/@construire_selectionner_hierarchie
63 function construire_selectionner_hierarchie($idom, $liste, $racine, $url, $name, $url_init='')
64 {
65 global $spip_lang_right;
66
67 $idom1 = $idom . "_champ_recherche";
68 $idom2 = $idom . "_principal";
69 $idom3 = $idom . "_selection";
70 $idom4 = $idom . "_col_1";
71 $idom5 = 'img_' . $idom4;
72 $idom6 = $idom."_fonc";
73
74 return "<div id='$idom'>"
75 . "<a id='$idom6' style='visibility: hidden;'"
76 . ($url_init ? "\nhref='$url_init'" : '')
77 . "></a>"
78 . "<div class='recherche_rapide_parent'>"
79 . http_img_pack("searching.gif", "*", "style='visibility: hidden;float:$spip_lang_right' id='$idom5'")
80 . ""
81 . "<input style='width: 100px;float:$spip_lang_right;' type='search' id='$idom1'"
82 // eliminer Return car il provoque la soumission (balise unique)
83 // ce serait encore mieux de ne le faire que s'il y a encore plusieurs
84 // resultats retournes par la recherche
85 . "\nonkeypress=\"k=event.keyCode;if (k==13 || k==3){return false;}\""
86 // lancer la recherche apres le filtrage ci-dessus
87 . "\nonkeyup=\"return onkey_rechercher(this.value,"
88 // la destination de la recherche
89 . "'$idom4'"
90 # . "this.parentNode.parentNode.parentNode.parentNode.nextSibling.firstChild.id"
91 . ",'"
92 // l'url effectuant la recherche
93 . $url
94 . "',"
95 // le noeud contenant un gif anime
96 // . "'idom5'"
97 . "this.parentNode.previousSibling.firstChild"
98 . ",'"
99 // la valeur de l'attribut Name a remplir
100 . $name
101 . "','"
102 // noeud invisible memorisant l'URL initiale (pour re-initialisation)
103 . $idom6
104 . "')\""
105 . " />"
106 . "\n</div>"
107 . ($racine?"<div>$racine</div>":"")
108 . "<div id='"
109 . $idom2
110 . "'><div id='$idom4'"
111 . " class=''>"
112 . $liste
113 . "</div></div>\n<div id='$idom3'></div></div>\n";
114 }
115
116 // http://doc.spip.org/@mini_hier
117 function mini_hier ($id_rubrique) {
118
119 $liste = $id_rubrique;
120 $id_rubrique = intval($id_rubrique);
121 while ($id_rubrique = sql_getfetsel("id_parent", "spip_rubriques", "id_rubrique = " . $id_rubrique))
122 $liste = $id_rubrique . ",$liste";
123 return explode(',',"0,$liste");
124 }
125
126 ?>