PageRenderTime 512ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/spip/ecrire/inc/selectionner.php

https://github.com/eyeswebcrea/espace-couture-sittler.fr
PHP | 124 lines | 96 code | 12 blank | 16 comment | 5 complexity | a494a4157aede7c21daa2dd5e9aad7a3 MD5 | raw file
Possible License(s): LGPL-2.1, GPL-3.0
  1. <?php
  2. /***************************************************************************\
  3. * SPIP, Systeme de publication pour l'internet *
  4. * *
  5. * Copyright (c) 2001-2011 *
  6. * Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
  7. * *
  8. * Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
  9. * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
  10. \***************************************************************************/
  11. if (!defined('_ECRIRE_INC_VERSION')) return;
  12. include_spip('inc/filtres');
  13. //
  14. // Affiche un mini-navigateur ajax positionne sur la rubrique $sel
  15. //
  16. // http://doc.spip.org/@inc_selectionner_dist
  17. function inc_selectionner_dist ($sel, $idom="", $exclus=0, $aff_racine=false, $recur=true, $do='aff') {
  18. if ($recur) $recur = mini_hier($sel); else $sel = 0;
  19. if ($aff_racine) {
  20. $info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id=");
  21. $idom3 = $idom . "_selection";
  22. $onClick = " aff_selection(0, '$idom3', '$info', event);";
  23. $ondbClick = strtr(str_replace("'", "&#8217;",
  24. str_replace('"', "&#34;",
  25. textebrut(_T('info_racine_site')))),
  26. "\n\r", " ");
  27. $js_func = $do . '_selection_titre';
  28. $ondbClick = "$js_func('$ondbClick',0,'selection_rubrique','id_parent');";
  29. $aff_racine = "<div class='arial11 petite-racine'\nonclick=\""
  30. . $onClick
  31. . "\"\nondbclick=\""
  32. . $ondbClick
  33. . $onClick
  34. . "\">\n<div class='highlight off'>"
  35. . _T("info_racine_site")
  36. . "</div></div>";
  37. } else $onClick = '';
  38. $url_init = generer_url_ecrire('plonger',"rac=$idom&exclus=$exclus&id=0&col=1&do=$do");
  39. $plonger = charger_fonction('plonger', 'inc');
  40. $plonger_r = $plonger($sel, $idom, $recur, 1, $exclus, $do);
  41. // url completee par la fonction JS onkeypress_rechercher
  42. $url = generer_url_ecrire('rechercher', "exclus=$exclus&rac=$idom&do=$do&type=");
  43. return construire_selectionner_hierarchie($idom, $plonger_r, $aff_racine, $url, 'id_parent', $url_init);
  44. }
  45. // http://doc.spip.org/@construire_selectionner_hierarchie
  46. function construire_selectionner_hierarchie($idom, $liste, $racine, $url, $name, $url_init='')
  47. {
  48. global $spip_lang_right;
  49. $idom1 = $idom . "_champ_recherche";
  50. $idom2 = $idom . "_principal";
  51. $idom3 = $idom . "_selection";
  52. $idom4 = $idom . "_col_1";
  53. $idom5 = 'img_' . $idom4;
  54. $idom6 = $idom."_fonc";
  55. return "<div id='$idom'>"
  56. . "<a id='$idom6' style='visibility: hidden;'"
  57. . ($url_init ? "\nhref='$url_init'" : '')
  58. . "></a>"
  59. . "<div class='recherche_rapide_parent'>"
  60. . http_img_pack("searching.gif", "*", "style='visibility: hidden;float:$spip_lang_right' id='$idom5'")
  61. . ""
  62. . "<input style='width: 100px;float:$spip_lang_right;' type='search' id='$idom1'"
  63. // eliminer Return car il provoque la soumission (balise unique)
  64. // ce serait encore mieux de ne le faire que s'il y a encore plusieurs
  65. // resultats retournes par la recherche
  66. . "\nonkeypress=\"k=event.keyCode;if (k==13 || k==3){return false;}\""
  67. // lancer la recherche apres le filtrage ci-dessus
  68. . "\nonkeyup=\"return onkey_rechercher(this.value,"
  69. // la destination de la recherche
  70. . "'$idom4'"
  71. # . "this.parentNode.parentNode.parentNode.parentNode.nextSibling.firstChild.id"
  72. . ",'"
  73. // l'url effectuant la recherche
  74. . $url
  75. . "',"
  76. // le noeud contenant un gif anime
  77. // . "'idom5'"
  78. . "this.parentNode.previousSibling.firstChild"
  79. . ",'"
  80. // la valeur de l'attribut Name a remplir
  81. . $name
  82. . "','"
  83. // noeud invisible memorisant l'URL initiale (pour re-initialisation)
  84. . $idom6
  85. . "')\""
  86. . " />"
  87. . "\n</div>"
  88. . ($racine?"<div>$racine</div>":"")
  89. . "<div id='"
  90. . $idom2
  91. . "'><div id='$idom4'"
  92. . " class='arial1'>"
  93. . $liste
  94. . "</div></div>\n<div id='$idom3'></div></div>\n";
  95. }
  96. // http://doc.spip.org/@mini_hier
  97. function mini_hier ($id_rubrique) {
  98. $liste = $id_rubrique;
  99. $id_rubrique = intval($id_rubrique);
  100. while ($id_rubrique = sql_getfetsel("id_parent", "spip_rubriques", "id_rubrique = " . $id_rubrique))
  101. $liste = $id_rubrique . ",$liste";
  102. return explode(',',"0,$liste");
  103. }
  104. ?>